@@ -67,7 +67,7 @@ func Run(ctx context.Context, configFilePath string, hostDNSServer DNSServer,
6767 return err
6868 }
6969
70- apiclient := & ApiClient {Client : & http.Client {Timeout : 3 * time .Second }, APIURL : config .APIURL , DisableTelemetry : config .DisableTelemetry , EgressPolicy : config .EgressPolicy , OneTimeKey : config .OneTimeKey }
70+ apiclient := & ApiClient {Client : & http.Client {Timeout : 3 * time .Second }, APIURL : config .APIURL , TelemetryURL : config . TelemetryURL , DisableTelemetry : config .DisableTelemetry , EgressPolicy : config .EgressPolicy , OneTimeKey : config .OneTimeKey }
7171
7272 config .OneTimeKey = ""
7373 // TODO: pass in an iowriter/ use log library
@@ -167,15 +167,18 @@ func Run(ctx context.Context, configFilePath string, hostDNSServer DNSServer,
167167 WriteLog ("\n " )
168168 WriteLog ("updated resolved" )
169169
170- // Change DNS for docker, causes process in containers to use agent's DNS proxy
171- if err := dnsConfig .SetDockerDNSServer (cmd , dockerDaemonConfigPath , tempDir ); err != nil {
172- WriteLog (fmt .Sprintf ("Error setting DNS server for docker %v" , err ))
173- RevertChanges (iptables , nflog , cmd , resolvdConfigPath , dockerDaemonConfigPath , dnsConfig , sudo )
174- return err
175- }
170+ // we uninstall docker using go routine, handle case where that routine finishes before we come here
171+ if ! config .DisableSudoAndContainers {
172+ // Change DNS for docker, causes process in containers to use agent's DNS proxy
173+ if err := dnsConfig .SetDockerDNSServer (cmd , dockerDaemonConfigPath , tempDir ); err != nil {
174+ WriteLog (fmt .Sprintf ("Error setting DNS server for docker %v" , err ))
175+ RevertChanges (iptables , nflog , cmd , resolvdConfigPath , dockerDaemonConfigPath , dnsConfig , sudo )
176+ return err
177+ }
176178
177- WriteLog ("\n " )
178- WriteLog ("set docker config\n " )
179+ WriteLog ("\n " )
180+ WriteLog ("set docker config\n " )
181+ }
179182
180183 if config .EgressPolicy == EgressPolicyAudit {
181184 netMonitor := NetworkMonitor {
@@ -233,22 +236,27 @@ func Run(ctx context.Context, configFilePath string, hostDNSServer DNSServer,
233236 APIURL : config .APIURL ,
234237 Repo : config .Repo ,
235238 CorrelationID : config .CorrelationId ,
236- OneTimeKey : config .OneTimeKey ,
239+ OneTimeKey : apiclient .OneTimeKey ,
237240 DisableTelemetry : config .DisableTelemetry ,
238241 },
242+ EnableCustomDetectionRules : IsCustomDetectionRulesEnabled (),
239243 }
240244
241245 conf .Files = append (conf .Files , getProcFilesOfInterest ()... )
242246
243247 conf .Files = append (conf .Files , getFilesOfInterest ()... )
244248
245- mArmour := armour .NewArmour (ctx , conf )
246- err := mArmour .Attach ()
249+ err := InitArmour (ctx , conf )
247250 if err != nil {
248251 WriteLog ("Armour attachment failed" )
249252 } else {
250- defer mArmour .Detach ()
253+ if GlobalArmour != nil {
254+ defer GlobalArmour .Detach ()
255+ }
251256 WriteLog ("Armour attached" )
257+ if IsCustomDetectionRulesEnabled () {
258+ WriteLog ("[armour] Custom detection rules enabled" )
259+ }
252260 }
253261 }
254262
@@ -370,10 +378,13 @@ func addImplicitEndpoints(endpoints map[string][]Endpoint, disableTelemetry bool
370378 }
371379 }
372380
373- stepsecurity := Endpoint {domainName : "agent.api.stepsecurity.io" , port : 443 } // Should be implicit based on user feedback
381+ stepsecurity := Endpoint {domainName : "agent.api.stepsecurity.io" , port : 443 } // Should be implicit based on user feedback
382+ stepsecurityTelemetry := Endpoint {domainName : "prod.app-api.stepsecurity.io" , port : 443 } // Telemetry endpoint for sending DNS and net connections to StepSecurity
383+
374384 if ! disableTelemetry {
375385 // allowing only if disable_telemetry is set to false
376386 normalEndpoints [stepsecurity .domainName ] = append (normalEndpoints [stepsecurity .domainName ], stepsecurity )
387+ normalEndpoints [stepsecurityTelemetry .domainName ] = append (normalEndpoints [stepsecurityTelemetry .domainName ], stepsecurityTelemetry )
377388 }
378389
379390 return normalEndpoints , wildcardEndpoints
0 commit comments