Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
119 commits
Select commit Hold shift + click to select a range
5cacec1
Update procmon.go
varunsh-coder Oct 20, 2022
174872f
Write log when sudo process called
varunsh-coder Oct 20, 2022
58a07fa
Update eventhandler.go
varunsh-coder Oct 20, 2022
b3abb14
Update eventhandler.go
varunsh-coder Oct 20, 2022
d87d72c
Update eventhandler.go
varunsh-coder Oct 20, 2022
2cd030e
Update eventhandler.go
varunsh-coder Oct 20, 2022
77b7532
Update eventhandler.go
varunsh-coder Oct 20, 2022
945fb45
Update eventhandler.go
varunsh-coder Oct 20, 2022
2b644ec
Update eventhandler.go
varunsh-coder Oct 21, 2022
8f0a42c
Update eventhandler.go
varunsh-coder Oct 21, 2022
47d0741
Update eventhandler.go
varunsh-coder Oct 21, 2022
9ba37cd
Update eventhandler.go
varunsh-coder Oct 21, 2022
f38fd4a
Merge pull request #312 from step-security/log-sudo
varunsh-coder Oct 21, 2022
19f56d0
Update eventhandler.go
varunsh-coder Oct 21, 2022
26d6cfc
Update file monitoring
varunsh-coder Oct 22, 2022
c76494f
Update procmon_linux.go
varunsh-coder Oct 22, 2022
036739b
Merge pull request #313 from step-security/update-file-log
varunsh-coder Oct 22, 2022
48dce30
Update config.go
varunsh-coder Oct 22, 2022
319e808
Implement disable sudo
varunsh-coder Oct 22, 2022
67b2a36
Update agent-allowed-endpoints.json
varunsh-coder Oct 22, 2022
766e82b
Separate test for disable sudo
varunsh-coder Oct 22, 2022
4dc4d99
Update agent-disable-sudo.json
varunsh-coder Oct 22, 2022
d225420
Merge pull request #314 from step-security/disable-sudo
varunsh-coder Oct 22, 2022
fc3c951
Add authorization check for private repos
varunsh-coder Oct 22, 2022
efb2e5d
Update agent.go
varunsh-coder Oct 22, 2022
e7e201c
Update logic
varunsh-coder Oct 23, 2022
ab31dab
Add test cases
varunsh-coder Oct 23, 2022
3b55e6c
Merge pull request #315 from step-security/add-auth-check
varunsh-coder Oct 23, 2022
b4eac5a
Add config to disable file monitoring
varunsh-coder Oct 23, 2022
271cfd9
Update agent.go
varunsh-coder Oct 23, 2022
7e81d16
Merge pull request #316 from step-security/config-file-monitor
varunsh-coder Oct 23, 2022
fbd5c08
Update dnsconfig.go
varunsh-coder Oct 23, 2022
7d6a4b7
Merge pull request #317 from step-security/dnsconfig-bug-fixes
varunsh-coder Oct 23, 2022
c76ed29
Update agent.go
varunsh-coder Oct 24, 2022
6496d53
Merge pull request #319 from step-security/add-timeout
varunsh-coder Oct 24, 2022
5109b29
Merge branch 'main' into int
varunsh-coder Oct 25, 2022
563abb9
Retry dns requests (#320)
varunsh-coder Oct 25, 2022
90709c1
Update eventhandler.go (#321)
varunsh-coder Oct 25, 2022
6ce4845
Update agent.go (#322)
varunsh-coder Oct 25, 2022
73c54f5
updated containerd tag
h0x0er Feb 1, 2023
afeec6a
Add bug fix for dockerChain (#348)
h0x0er Feb 8, 2023
652d9e2
Merge pull request #344 from h0x0er/containerd-updates
varunsh-coder Feb 8, 2023
a9da361
Update dnsproxy.go
varunsh-coder Feb 8, 2023
8a99cbe
Merge branch 'main' into int
varunsh-coder Feb 8, 2023
e023b38
Merge pull request #349 from step-security/rc-2
varunsh-coder Feb 8, 2023
2439dab
Merge branch 'main' into int
varunsh-coder Apr 23, 2023
2e72a9e
Add fix to not run docker containers with root access (#376)
varunsh-coder Apr 23, 2023
938e122
Add support for wildcard allowed-endpoints (#377)
varunsh-coder Apr 23, 2023
92ffdc2
Update go and dependencies (#378)
varunsh-coder Apr 23, 2023
0ae705b
Merge branch 'main' into int
varunsh-coder Apr 25, 2023
d8cce90
Revert docker userns-remap (#381)
h0x0er Apr 25, 2023
28cec27
Merge pull request #382 from step-security/revert-userns
varunsh-coder Apr 25, 2023
5c7085b
adding a workflow for reviewing code changes using stepsecurity code …
ashishkurmi Apr 30, 2023
fed1662
Merge pull request #387 from step-security/ak-code-reviwer
ashishkurmi Apr 30, 2023
7df2ef4
Update code-review.yml
varunsh-coder Apr 30, 2023
066d45f
Merge pull request #389 from step-security/ak-main-to-int-code-review
ashishkurmi May 1, 2023
552b03b
Merge branch 'main' into int
varunsh-coder May 4, 2023
1e0ed97
Merge pull request #390 from step-security/fix-wildcard-resolution
varunsh-coder May 4, 2023
69c1a02
adding id-token write permission for code review action
ashishkurmi May 7, 2023
136fdc7
Merge pull request #393 from step-security/ak-updating-code-reviewer-…
ashishkurmi May 7, 2023
d59888c
using codewise int for dogfooding
ashishkurmi May 14, 2023
54e9f37
Merge pull request #397 from step-security/ak-codewise-dogfooding
ashishkurmi May 15, 2023
a0d239d
Merge branch 'main' into int
varunsh-coder Jun 15, 2023
93c2522
Improve logging (#411)
varunsh-coder Jun 15, 2023
f9fe83d
Merge branch 'main' into int
varunsh-coder Jun 15, 2023
d3f9b1e
Add fallback DNS (#413)
varunsh-coder Jun 15, 2023
88d0fda
Merge branch 'main' into int
varunsh-coder Aug 9, 2023
61e3f30
Update allowed endpoint
varunsh-coder Aug 9, 2023
7b76e44
Merge pull request #422 from step-security/add-new-allowed-endpoints
varunsh-coder Aug 9, 2023
008a5fc
Update int.yml
varunsh-coder Aug 9, 2023
2caac49
Update agent.go
varunsh-coder Aug 9, 2023
0ba274c
Update int.yml
varunsh-coder Aug 9, 2023
8a6eedf
Merge pull request #423 from step-security/add-new-allowed-endpoints
varunsh-coder Aug 9, 2023
80d81b5
Merge branch 'main' into int
varunsh-coder Oct 6, 2023
33fd822
Update procmon_linux.go
varunsh-coder Oct 6, 2023
607eb23
Revert "Update procmon_linux.go"
varunsh-coder Oct 6, 2023
fcf4599
Update harden-runner versions
varunsh-coder Jun 6, 2024
e1d89e8
Add one-time-key logic (#430)
h0x0er Jun 6, 2024
d5c86b5
Merge pull request #431 from step-security/one-time-key-int
varunsh-coder Jun 6, 2024
89aff7a
feat: add armour
rohan-stepsecurity Apr 11, 2025
13695da
fix: linter errors
rohan-stepsecurity Apr 11, 2025
56f65a0
add vendor to gitignore
rohan-stepsecurity Apr 11, 2025
cd1cb63
add private-src to gitignore
rohan-stepsecurity Apr 11, 2025
ade2838
add log
rohan-stepsecurity Apr 11, 2025
f1d907c
Merge pull request #438 from rohan-stepsecurity/feat/armour
varunsh-coder Apr 13, 2025
6b615ea
Update test.yml
varunsh-coder Apr 13, 2025
52e94f6
Merge branch 'armour-integration-int' of https://github.com/step-secu…
varunsh-coder Apr 13, 2025
e0dc8ee
update workflows
varunsh-coder Apr 13, 2025
9adbf6c
Merge branch 'main' into int
varunsh-coder Apr 13, 2025
e0f820b
Merge pull request #439 from step-security/armour-integration-int
varunsh-coder Apr 13, 2025
663349e
feat: add ability to disable sudo and containers
rohan-stepsecurity Apr 13, 2025
390c7dc
Merge pull request #440 from rohan-stepsecurity/feat/disable-sudo-and…
varunsh-coder Apr 13, 2025
35ee5f0
fix: update user for docker group
rohan-stepsecurity Apr 13, 2025
6e91234
feat: uninstall docker
rohan-stepsecurity Apr 14, 2025
eb59a62
Merge pull request #442 from rohan-stepsecurity/feat/disable-sudo-and…
varunsh-coder Apr 14, 2025
731bcf0
feat: remove revert
rohan-stepsecurity Apr 14, 2025
93890c0
fix: change to WriteLog
rohan-stepsecurity Apr 14, 2025
d309322
Merge pull request #443 from rohan-stepsecurity/feat/disable-sudo-and…
varunsh-coder Apr 14, 2025
465b6de
Merge pull request #441 from step-security/armour-integration-int
varunsh-coder Apr 14, 2025
9b3de4c
Merge branch 'main' into int
varunsh-coder May 2, 2025
9ec15c4
feat: enhance network monitoring for UDP packets
rohan-stepsecurity Nov 20, 2025
2293144
fix: consolidate UDP monitoring logging
rohan-stepsecurity Nov 20, 2025
f6e71c1
feat: add UDP NFLOG rule for blocked traffic logging
rohan-stepsecurity Jan 9, 2026
a7f760e
Merge pull request #464 from step-security/rp/udp
varunsh-coder Jan 13, 2026
70060bc
Merge branch 'main' into int
varunsh-coder Feb 16, 2026
9261b3a
restrict calls to dns_servers from agent-uid
h0x0er Feb 17, 2026
918fb72
Merge pull request #467 from h0x0er/jatin/int/restrict-dns-ips
varunsh-coder Feb 17, 2026
378ef52
feat: update armour version
rohan-stepsecurity Mar 16, 2026
8192dfe
feat: integrate custom detection rules with Armour
rohan-stepsecurity Mar 16, 2026
93e00d3
feat: add TelemetryURL support to ApiClient and configuration
rohan-stepsecurity Mar 16, 2026
a1eac7b
refactor: remove redundant DNS event submission in handleNetworkEvent
rohan-stepsecurity Mar 16, 2026
ee69267
feat: whitelist telemetry endpoint for StepSecurity
rohan-stepsecurity Mar 16, 2026
75a349e
feat: enable custom detection rules in agent configuration
rohan-stepsecurity Mar 17, 2026
d4bfe1b
fix: update OneTimeKey assignment and upgrade Armour dependency
rohan-stepsecurity Mar 18, 2026
72f6f12
chore: update OpenTelemetry dependencies to v1.40.0 and golang.org/x/…
rohan-stepsecurity Mar 18, 2026
025b442
refactor: reorder file event submission in handleFileEvent
rohan-stepsecurity Mar 23, 2026
9076e47
Merge pull request #472 from step-security/rp/feat/custom-detection
varunsh-coder Mar 26, 2026
6d86062
chore: update Armour dependency to v1.2.1
rohan-stepsecurity Apr 3, 2026
1b1a192
Merge pull request #474 from step-security/rp/feat/armour-cdr
rohan-stepsecurity Apr 13, 2026
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
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ coverage.txt
.vscode/

vendor
private-src
private-src

dist
local
39 changes: 25 additions & 14 deletions agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func Run(ctx context.Context, configFilePath string, hostDNSServer DNSServer,
return err
}

apiclient := &ApiClient{Client: &http.Client{Timeout: 3 * time.Second}, APIURL: config.APIURL, DisableTelemetry: config.DisableTelemetry, EgressPolicy: config.EgressPolicy, OneTimeKey: config.OneTimeKey}
apiclient := &ApiClient{Client: &http.Client{Timeout: 3 * time.Second}, APIURL: config.APIURL, TelemetryURL: config.TelemetryURL, DisableTelemetry: config.DisableTelemetry, EgressPolicy: config.EgressPolicy, OneTimeKey: config.OneTimeKey}

config.OneTimeKey = ""
// TODO: pass in an iowriter/ use log library
Expand Down Expand Up @@ -167,15 +167,18 @@ func Run(ctx context.Context, configFilePath string, hostDNSServer DNSServer,
WriteLog("\n")
WriteLog("updated resolved")

// Change DNS for docker, causes process in containers to use agent's DNS proxy
if err := dnsConfig.SetDockerDNSServer(cmd, dockerDaemonConfigPath, tempDir); err != nil {
WriteLog(fmt.Sprintf("Error setting DNS server for docker %v", err))
RevertChanges(iptables, nflog, cmd, resolvdConfigPath, dockerDaemonConfigPath, dnsConfig, sudo)
return err
}
// we uninstall docker using go routine, handle case where that routine finishes before we come here
if !config.DisableSudoAndContainers {
// Change DNS for docker, causes process in containers to use agent's DNS proxy
if err := dnsConfig.SetDockerDNSServer(cmd, dockerDaemonConfigPath, tempDir); err != nil {
WriteLog(fmt.Sprintf("Error setting DNS server for docker %v", err))
RevertChanges(iptables, nflog, cmd, resolvdConfigPath, dockerDaemonConfigPath, dnsConfig, sudo)
return err
}

WriteLog("\n")
WriteLog("set docker config\n")
WriteLog("\n")
WriteLog("set docker config\n")
}

if config.EgressPolicy == EgressPolicyAudit {
netMonitor := NetworkMonitor{
Expand Down Expand Up @@ -233,22 +236,27 @@ func Run(ctx context.Context, configFilePath string, hostDNSServer DNSServer,
APIURL: config.APIURL,
Repo: config.Repo,
CorrelationID: config.CorrelationId,
OneTimeKey: config.OneTimeKey,
OneTimeKey: apiclient.OneTimeKey,
DisableTelemetry: config.DisableTelemetry,
},
EnableCustomDetectionRules: IsCustomDetectionRulesEnabled(),
}

conf.Files = append(conf.Files, getProcFilesOfInterest()...)

conf.Files = append(conf.Files, getFilesOfInterest()...)

mArmour := armour.NewArmour(ctx, conf)
err := mArmour.Attach()
err := InitArmour(ctx, conf)
if err != nil {
WriteLog("Armour attachment failed")
} else {
defer mArmour.Detach()
if GlobalArmour != nil {
defer GlobalArmour.Detach()
}
WriteLog("Armour attached")
if IsCustomDetectionRulesEnabled() {
WriteLog("[armour] Custom detection rules enabled")
}
}
}

Expand Down Expand Up @@ -370,10 +378,13 @@ func addImplicitEndpoints(endpoints map[string][]Endpoint, disableTelemetry bool
}
}

stepsecurity := Endpoint{domainName: "agent.api.stepsecurity.io", port: 443} // Should be implicit based on user feedback
stepsecurity := Endpoint{domainName: "agent.api.stepsecurity.io", port: 443} // Should be implicit based on user feedback
stepsecurityTelemetry := Endpoint{domainName: "prod.app-api.stepsecurity.io", port: 443} // Telemetry endpoint for sending DNS and net connections to StepSecurity

if !disableTelemetry {
// allowing only if disable_telemetry is set to false
normalEndpoints[stepsecurity.domainName] = append(normalEndpoints[stepsecurity.domainName], stepsecurity)
normalEndpoints[stepsecurityTelemetry.domainName] = append(normalEndpoints[stepsecurityTelemetry.domainName], stepsecurityTelemetry)
}

return normalEndpoints, wildcardEndpoints
Expand Down
5 changes: 3 additions & 2 deletions apiclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type NetworkConnection struct {
type ApiClient struct {
Client *http.Client
APIURL string
TelemetryURL string
DisableTelemetry bool
EgressPolicy string
OneTimeKey string
Expand All @@ -57,7 +58,7 @@ func (apiclient *ApiClient) sendDNSRecord(correlationId, repo, domainName, ipAdd
dnsRecord.ResolvedIPAddress = ipAddress
dnsRecord.TimeStamp = time.Now().UTC()

url := fmt.Sprintf("%s/github/%s/actions/jobs/%s/dns", apiclient.APIURL, repo, correlationId)
url := fmt.Sprintf("%s/github/%s/actions/jobs/%s/dns", apiclient.TelemetryURL, repo, correlationId)

return apiclient.sendApiRequest("POST", url, dnsRecord)
}
Expand All @@ -76,7 +77,7 @@ func (apiclient *ApiClient) sendNetConnection(correlationId, repo, ipAddress, po
networkConnection.TimeStamp = timestamp
networkConnection.Tool = tool

url := fmt.Sprintf("%s/github/%s/actions/jobs/%s/networkconnection", apiclient.APIURL, repo, correlationId)
url := fmt.Sprintf("%s/github/%s/actions/jobs/%s/networkconnection", apiclient.TelemetryURL, repo, correlationId)

return apiclient.sendApiRequest("POST", url, networkConnection)
}
Expand Down
31 changes: 31 additions & 0 deletions armour_manager.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package main

import (
"context"
"fmt"

"github.com/step-security/armour/armour"
)

// NOTE: before usage, make sure to nil check
var GlobalArmour *armour.Armour = nil

func InitArmour(ctx context.Context, conf *armour.Config) error {

GlobalArmour = armour.NewArmour(ctx, conf)
err := GlobalArmour.Init()
if err != nil {
GlobalArmour = nil
return err
}

runnerWorkerPID, err := getRunnerWorkerPID()
if err != nil {
WriteLog(fmt.Sprintf("[armour] Error getting Runner.Worker PID: %v", err))
return nil
}
GlobalArmour.SetRunnerWorkerPID(runnerWorkerPID)
WriteLog(fmt.Sprintf("[armour] Runner.Worker PID: %d", runnerWorkerPID))

return nil
}
4 changes: 4 additions & 0 deletions common.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,7 @@ func getProcMemFiles(pid uint64) []string {

return out
}

func getRunnerWorkerPID() (uint64, error) {
return pidOf("Runner.Worker")
}
6 changes: 6 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type config struct {
RunId string
WorkingDirectory string
APIURL string
TelemetryURL string
OneTimeKey string
Endpoints map[string][]Endpoint
EgressPolicy string
Expand All @@ -37,6 +38,7 @@ type configFile struct {
RunId string `json:"run_id"`
WorkingDirectory string `json:"working_directory"`
APIURL string `json:"api_url"`
TelemetryURL string `json:"telemetry_url"`
OneTimeKey string `json:"one_time_key"`
AllowedEndpoints string `json:"allowed_endpoints"`
EgressPolicy string `json:"egress_policy"`
Expand Down Expand Up @@ -65,6 +67,10 @@ func (c *config) init(configFilePath string) error {
c.RunId = configFile.RunId
c.WorkingDirectory = configFile.WorkingDirectory
c.APIURL = configFile.APIURL
c.TelemetryURL = configFile.TelemetryURL
if c.TelemetryURL == "" {
c.TelemetryURL = c.APIURL
}
c.Endpoints = parseEndpoints(configFile.AllowedEndpoints)
c.EgressPolicy = configFile.EgressPolicy
c.DisableTelemetry = configFile.DisableTelemetry
Expand Down
20 changes: 20 additions & 0 deletions dnsproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

"github.com/miekg/dns"
"github.com/pkg/errors"
"github.com/step-security/armour/armour"
)

type DNSProxy struct {
Expand Down Expand Up @@ -239,6 +240,8 @@ func (proxy *DNSProxy) getIPByDomain(domain string) (string, error) {

go proxy.ApiClient.sendDNSRecord(proxy.CorrelationId, proxy.Repo, domain, answer.Data)

go proxy.submitDNSEvent(answer.Data)

return answer.Data, nil

}
Expand Down Expand Up @@ -296,6 +299,23 @@ func (proxy *DNSProxy) processTypeA(q *dns.Question, requestMsg *dns.Msg) (*dns.
return &rr, nil
}

// submitDNSEvent submits a DNS event to the detection manager.
func (proxy *DNSProxy) submitDNSEvent(dest string) {
if !IsCustomDetectionRulesEnabled() {
return
}
if GlobalArmour == nil {
return
}
dm := GlobalArmour.DetectionManager()
if dm == nil {
return
}
dm.SubmitNetwork(&armour.NetworkDetectionEvent{
Dest: dest,
})
}

func startDNSServer(dnsProxy *DNSProxy, server DNSServer, errc chan error) {
dns.HandleFunc(".", func(w dns.ResponseWriter, r *dns.Msg) {
switch r.Opcode {
Expand Down
72 changes: 72 additions & 0 deletions eventhandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (

"github.com/docker/docker/api/types"
"github.com/docker/docker/client"
"github.com/step-security/armour/armour"
)

type EventHandler struct {
Expand Down Expand Up @@ -90,6 +91,8 @@ func (eventHandler *EventHandler) handleFileEvent(event *Event) {
}

eventHandler.fileMutex.Unlock()

eventHandler.submitFileEvent(event)
}

func isSourceCodeFile(fileName string) bool {
Expand Down Expand Up @@ -123,6 +126,8 @@ func (eventHandler *EventHandler) handleProcessEvent(event *Event) {
} else {
eventHandler.procMutex.Unlock()
}

eventHandler.submitProcessEvent(event)
}

/*
Expand Down Expand Up @@ -199,6 +204,8 @@ func (eventHandler *EventHandler) handleNetworkEvent(event *Event) {
}

eventHandler.netMutex.Unlock()

eventHandler.submitNetworkEvent(event)
}

func (eventHandler *EventHandler) HandleEvent(event *Event) {
Expand Down Expand Up @@ -440,3 +447,68 @@ func isPrivateIPAddress(ipAddress string) bool {
func isIPv6(ip string) bool {
return strings.Contains(ip, ":")
}

func (eventHandler *EventHandler) submitProcessEvent(event *Event) {
if !IsCustomDetectionRulesEnabled() {
return
}
if GlobalArmour == nil {
return
}
dm := GlobalArmour.DetectionManager()
if dm == nil {
return
}
dm.SubmitProcess(&armour.ProcessDetectionEvent{
Pid: event.Pid,
PPid: event.PPid,
Exe: event.Exe,
Arguments: event.ProcessArguments,
Cwd: event.Path,
Timestamp: event.Timestamp,
})
}

// submitFileEvent submits a file event to the detection manager.
func (eventHandler *EventHandler) submitFileEvent(event *Event) {
if !IsCustomDetectionRulesEnabled() {
return
}
if GlobalArmour == nil {
return
}
dm := GlobalArmour.DetectionManager()
if dm == nil {
return
}
dm.SubmitFile(&armour.FileDetectionEvent{
Syscall: event.Syscall,
FileName: filepath.Base(event.FileName),
Path: event.FileName,
Exe: event.Exe,
Pid: event.Pid,
PPid: event.PPid,
Timestamp: event.Timestamp,
})
}

// submitNetworkEvent submits a network event to the detection manager.
func (eventHandler *EventHandler) submitNetworkEvent(event *Event) {
if GlobalArmour == nil {
return
}
dm := GlobalArmour.DetectionManager()
if dm == nil {
return
}

dm.SubmitNetwork(&armour.NetworkDetectionEvent{
Pid: event.Pid,
PPid: event.PPid,
Exe: event.Exe,
Dest: event.IPAddress,
DestIP: event.IPAddress,
DestPort: event.Port,
Timestamp: event.Timestamp,
})
}
29 changes: 19 additions & 10 deletions firewall.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"fmt"
"os"

"github.com/coreos/go-iptables/iptables"
"github.com/pkg/errors"
Expand Down Expand Up @@ -77,6 +78,24 @@ func addBlockRules(firewall *Firewall, endpoints []ipAddressEndpoint, chain, net
}
}

// Agent uses HTTPs to resolve domain names
// Only apply UID filtering for OUTPUT chain
if chain == outputChain {
agentUID := fmt.Sprintf("%d", os.Getuid())
for _, dnsServer := range dnsServers {
err = ipt.Append(filterTable, chain, direction, netInterface,
"-m", "owner", "--uid-owner", agentUID,
protocol, tcp,
destination, dnsServer,
destinationPort, "443",
target, accept)

if err != nil {
return errors.Wrapf(err, "failed to add rule for DNS server %s", dnsServer)
}
}
}

for _, endpoint := range endpoints {
err = ipt.Append(filterTable, chain, direction, netInterface, protocol, tcp,
destination, endpoint.ipAddress,
Expand All @@ -87,16 +106,6 @@ func addBlockRules(firewall *Firewall, endpoints []ipAddressEndpoint, chain, net
}
}

// Agent uses HTTPs to resolve domain names
for _, dnsServer := range dnsServers {
err = ipt.Append(filterTable, chain, direction, netInterface, protocol, tcp,
destination, dnsServer, target, accept)

if err != nil {
return errors.Wrapf(err, "failed to add rule for DNS server %s", dnsServer)
}
}

// Allow AzureIPAddress
err = ipt.Append(filterTable, chain, direction, netInterface, protocol, tcp,
destination, AzureIPAddress, target, accept)
Expand Down
Loading
Loading