Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ func Run(ctx context.Context, configFilePath string, hostDNSServer DNSServer,
InitGlobalFeatureFlags(config.APIURL, apiclient)
WriteLog("initialized global feature flags")
WriteLog("\n")
globalFlags := GetGlobalFeatureFlags()

globalBlocklistResponse, err := apiclient.getGlobalBlocklist()
globalBlocklist := NewGlobalBlocklist(globalBlocklistResponse)
Expand Down Expand Up @@ -253,6 +254,7 @@ func Run(ctx context.Context, configFilePath string, hostDNSServer DNSServer,
Pids: getPidsOfInterest(),
Files: []string{},
EnforceReadBlock: false,
EnforceKillBlock: !globalFlags.DisableKillEnforcement,
ApiConf: &armour.ApiConf{
APIURL: config.APIURL,
Repo: config.Repo,
Expand Down
1 change: 1 addition & 0 deletions global_feature_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type GlobalFeatureFlags struct {
AgentType string `json:"agent_type"`
EnableArmour bool `json:"enable_armour"`
EnableCustomDetectionRules bool `json:"enable_custom_detection_rules"`
DisableKillEnforcement bool `json:"disable_kill_enforcement,omitempty"`
}

// GlobalFeatureFlagManager manages fetching and caching of global feature flags.
Expand Down
21 changes: 13 additions & 8 deletions netmon.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,27 +104,32 @@ func (netMonitor *NetworkMonitor) handlePacket(attrs nflog.Attribute) {

cacheKey := fmt.Sprintf("%s:%s:%s", ipv4Address, port, status)
_, found := ipAddresses[cacheKey]
if !found {
ipAddresses[cacheKey] = true
if found {
netMonitor.netMutex.Unlock()
return
}
ipAddresses[cacheKey] = true
netMonitor.netMutex.Unlock()

if isSYN || isUDP {
if status == "Dropped" {

if ipv4Address != StepSecuritySinkHoleIPAddress { // Sinkhole IP address will be covered by DNS block

if isSYN || isUDP {
if status == "Dropped" {
netMonitor.ApiClient.sendNetConnection(netMonitor.CorrelationId, netMonitor.Repo,
ipv4Address, port, "", status, matchedPolicy, reason, timestamp, Tool{Name: Unknown, SHA256: Unknown})

logMessage := fmt.Sprintf("ip address dropped: %s", ipv4Address)
if reason != "" {
logMessage = fmt.Sprintf("%s, reason: %s", logMessage, reason)
}

go WriteLog(logMessage)

if ipv4Address != StepSecuritySinkHoleIPAddress { // Sinkhole IP address will be covered by DNS block
go WriteAnnotation(fmt.Sprintf("StepSecurity Harden Runner: Traffic to IP Address %s was blocked", ipv4Address))
}
go WriteAnnotation(fmt.Sprintf("StepSecurity Harden Runner: Traffic to IP Address %s was blocked", ipv4Address))
}
}
}
netMonitor.netMutex.Unlock()
}

}
Loading