Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[agent-smith] account for egress traffic #4677

Merged
merged 6 commits into from
Jul 9, 2021
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
23 changes: 20 additions & 3 deletions chart/templates/agent-smith-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,29 @@ data:
"blacklists": {
"very": {
"signatures": [
{"name":"testtarget","domain":"process","kind":"elf","pattern":"YWdlbnRTbWl0aFRlc3RUYXJnZXQ=","regexp":false}
{
"name": "testtarget",
"domain": "process",
"kind": "elf",
"pattern": "YWdlbnRTbWl0aFRlc3RUYXJnZXQ=",
"regexp": false
}
]
}
},
"pprofAddr": "localhost:6060",
"prometheusAddr": "localhost:9500",
"hostURL": "https://{{ $.Values.hostname }}"
"hostURL": "https://{{ $.Values.hostname }}",
"egressTraffic": {
"dt": "2m",
"excessive": {
"baseBudget": "300Mi",
"perDtThreshold": "100Mi"
},
"veryExcessive": {
"baseBudget": "2Gi",
"perDtThreshold": "250Mi"
}
}
}
{{- end -}}
{{- end -}}
3 changes: 2 additions & 1 deletion components/ee/agent-smith/BUILD.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ packages:
- name: app
type: go
srcs:
- "pkg/agent/testdata/**"
- "**/*.go"
- "go.mod"
- "go.sum"
Expand Down Expand Up @@ -59,5 +60,5 @@ scripts:
- components/ee/agent-smith/cmd/testbed:app
- components/ee/agent-smith/cmd/testtarget:app
script: |
scp vm ./components-ee-agent-smith--falco-bpf-probe/probe.o ./components-ee-agent-smith--app/agent-smith ./components-ee-agent-smith--example-config/example-config.json ./components-ee-agent-smith-cmd-testbed--app/testbed ./components-ee-agent-smith-cmd-testtarget--app/testtarget root@localhost:/
scp -P 2222 -i ~/.ssh/id_rsa_vm -o StrictHostKeyChecking=no vm ./components-ee-agent-smith--falco-bpf-probe/probe.o ./components-ee-agent-smith--app/agent-smith ./components-ee-agent-smith--example-config/example-config.json ./components-ee-agent-smith-cmd-testbed--app/testbed ./components-ee-agent-smith-cmd-testtarget--app/testtarget root@localhost:/
echo "copied agent-smith to /"
6 changes: 6 additions & 0 deletions components/ee/agent-smith/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ ssh vm

If you now go under the `/workspace` folder in the VM, you will find all your workspace stuff.

If you want to compile with leeway and have the compiled artifacts in the VM you can do

```
leeway run components/ee/agent-smith:copy-to-qemu
```

## Falco libs BPF probe development

In case you need to do development of new features or fix bugs against the
Expand Down
15 changes: 13 additions & 2 deletions components/ee/agent-smith/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package cmd

import (
"context"
"fmt"
"net/http"
"os"
Expand Down Expand Up @@ -61,7 +62,11 @@ var runCmd = &cobra.Command{
log.WithError(err).Fatal("cannot register metrics")
}

go smith.Start(func(violation agent.InfringingWorkspace, penalties []agent.PenaltyKind) {
ctx := context.Background()
ctx, cancel := context.WithCancel(ctx)
defer cancel()

go smith.Start(ctx, func(violation agent.InfringingWorkspace, penalties []agent.PenaltyKind) {
log.WithField("violation", violation).WithField("penalties", penalties).Info("Found violation")

if cfg.SlackWebhooks != nil {
Expand Down Expand Up @@ -94,7 +99,13 @@ var runCmd = &cobra.Command{

sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, os.Interrupt, syscall.SIGTERM)
<-sigChan

select {
case <-ctx.Done():
return
case <-sigChan:
return
}
},
}

Expand Down
22 changes: 19 additions & 3 deletions components/ee/agent-smith/example-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,26 @@
"probePath": "./probe.o",
"blacklists": {
"very": {
"binaries": ["find"],
"signatures": [
{"name":"testtarget","domain":"process","kind":"elf","pattern":"YWdlbnRTbWl0aFRlc3RUYXJnZXQ=","regexp":false}
{
"name": "testtarget",
"domain": "process",
"kind": "elf",
"pattern": "YWdlbnRTbWl0aFRlc3RUYXJnZXQ=",
"regexp": false
}
]
}
},
"egressTraffic": {
"dt": "2m",
"excessive": {
"baseBudget": "300Mi",
"perDtThreshold": "100Mi"
},
"veryExcessive": {
"baseBudget": "2Gi",
"perDtThreshold": "250Mi"
}
}
}
}
Loading