Skip to content

Commit 1b8cefd

Browse files
committed
wip add other tracers
Signed-off-by: Matthias Bertschy <[email protected]>
1 parent 628d939 commit 1b8cefd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+2288
-1996
lines changed

build/Dockerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,13 @@ RUN --mount=target=. \
1111

1212
FROM --platform=$BUILDPLATFORM ghcr.io/inspektor-gadget/ig:v0.44.1 AS ig
1313

14+
RUN ["ig", "image", "pull", "trace_tcp:v0.44.1"]
15+
RUN ["ig", "image", "pull", "advise_seccomp:v0.44.1"]
16+
RUN ["ig", "image", "pull", "trace_capabilities:v0.44.1"]
17+
RUN ["ig", "image", "pull", "trace_dns:v0.44.1"]
1418
RUN ["ig", "image", "pull", "trace_exec:v0.44.1"]
1519
RUN ["ig", "image", "pull", "trace_open:v0.44.1"]
16-
RUN ["ig", "image", "export", "trace_exec:v0.44.1", "trace_open:v0.44.1", "/tmp/tracers.tar"]
20+
RUN ["ig", "image", "export", "trace_tcp:v0.44.1", "advise_seccomp:v0.44.1", "trace_capabilities:v0.44.1", "trace_dns:v0.44.1", "trace_exec:v0.44.1", "trace_open:v0.44.1", "/tmp/tracers.tar"]
1721

1822
FROM gcr.io/distroless/static-debian12:latest
1923

build/Dockerfile.debug

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ FROM --platform=$BUILDPLATFORM golang:1.25-bookworm AS builder
33
ENV GO111MODULE=on CGO_ENABLED=0
44
WORKDIR /work
55
ARG TARGETOS TARGETARCH
6+
67
RUN go install github.com/go-delve/delve/cmd/dlv@latest
78
RUN --mount=target=. \
89
--mount=type=cache,target=/root/.cache/go-build \
@@ -11,9 +12,13 @@ RUN --mount=target=. \
1112

1213
FROM --platform=$BUILDPLATFORM ghcr.io/inspektor-gadget/ig:v0.44.1 AS ig
1314

15+
RUN ["ig", "image", "pull", "trace_tcp:v0.44.1"]
16+
RUN ["ig", "image", "pull", "advise_seccomp:v0.44.1"]
17+
RUN ["ig", "image", "pull", "trace_capabilities:v0.44.1"]
18+
RUN ["ig", "image", "pull", "trace_dns:v0.44.1"]
1419
RUN ["ig", "image", "pull", "trace_exec:v0.44.1"]
1520
RUN ["ig", "image", "pull", "trace_open:v0.44.1"]
16-
RUN ["ig", "image", "export", "trace_exec:v0.44.1", "trace_open:v0.44.1", "/tmp/tracers.tar"]
21+
RUN ["ig", "image", "export", "trace_tcp:v0.44.1", "advise_seccomp:v0.44.1", "trace_capabilities:v0.44.1", "trace_dns:v0.44.1", "trace_exec:v0.44.1", "trace_open:v0.44.1", "/tmp/tracers.tar"]
1722

1823
FROM gcr.io/distroless/static-debian12:debug
1924

@@ -26,4 +31,4 @@ ARG image_version
2631
ENV RELEASE=$image_version
2732

2833
WORKDIR /root
29-
ENTRYPOINT ["/usr/bin/dlv", "--listen=:40000", "--headless=true","--accept-multiclient", "--api-version=2", "--log", "exec", "/usr/bin/node-agent"]
34+
ENTRYPOINT ["/usr/bin/dlv", "--listen=:40000", "--headless=true", "--continue", "--accept-multiclient", "--api-version=2", "--log", "exec", "/usr/bin/node-agent"]

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ require (
302302
github.com/subosito/gotenv v1.6.0 // indirect
303303
github.com/sylabs/sif/v2 v2.21.1 // indirect
304304
github.com/sylabs/squashfs v1.0.4 // indirect
305+
github.com/tetratelabs/wazero v1.9.0 // indirect
305306
github.com/therootcompany/xz v1.0.1 // indirect
306307
github.com/titanous/rocacheck v0.0.0-20171023193734-afe73141d399 // indirect
307308
github.com/tklauser/go-sysconf v0.3.12 // indirect

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,6 +1117,8 @@ github.com/sylabs/squashfs v1.0.4/go.mod h1:PDgf8YmCntvN4d9Y8hBUBDCZL6qZOzOQwRGx
11171117
github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA=
11181118
github.com/terminalstatic/go-xsd-validate v0.1.5 h1:RqpJnf6HGE2CB/lZB1A8BYguk8uRtcvYAPLCF15qguo=
11191119
github.com/terminalstatic/go-xsd-validate v0.1.5/go.mod h1:18lsvYFofBflqCrvo1umpABZ99+GneNTw2kEEc8UPJw=
1120+
github.com/tetratelabs/wazero v1.9.0 h1:IcZ56OuxrtaEz8UYNRHBrUa9bYeX9oVY93KspZZBf/I=
1121+
github.com/tetratelabs/wazero v1.9.0/go.mod h1:TSbcXCfFP0L2FGkRPxHphadXPjo1T6W+CseNNY7EkjM=
11201122
github.com/therootcompany/xz v1.0.1 h1:CmOtsn1CbtmyYiusbfmhmkpAAETj0wBIH6kCYaX+xzw=
11211123
github.com/therootcompany/xz v1.0.1/go.mod h1:3K3UH1yCKgBneZYhuQUvJ9HPD19UEXEI0BWbMn8qNMY=
11221124
github.com/titanous/rocacheck v0.0.0-20171023193734-afe73141d399 h1:e/5i7d4oYZ+C1wj2THlRK+oAhjeS/TRQwMfkIuet3w0=

pkg/containerprofilemanager/containerprofile_manager_interface.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package containerprofilemanager
22

33
import (
44
containercollection "github.com/inspektor-gadget/inspektor-gadget/pkg/container-collection"
5-
"github.com/inspektor-gadget/inspektor-gadget/pkg/datasource"
65
tracerhardlinktype "github.com/kubescape/node-agent/pkg/ebpf/gadgets/hardlink/types"
76
tracerhttptype "github.com/kubescape/node-agent/pkg/ebpf/gadgets/http/types"
87
tracersymlinktype "github.com/kubescape/node-agent/pkg/ebpf/gadgets/symlink/types"
@@ -12,7 +11,6 @@ import (
1211

1312
type ContainerProfileManagerClient interface {
1413
ContainerCallback(notif containercollection.PubSubEvent)
15-
RegisterPeekFunc(peek func(mntns uint64) ([]string, error))
1614
ReportCapability(containerID, capability string)
1715
ReportFileExec(containerID string, event *utils.EnrichEvent)
1816
ReportFileOpen(containerID string, event *utils.EnrichEvent)
@@ -21,7 +19,8 @@ type ContainerProfileManagerClient interface {
2119
ReportIdentifiedCallStack(containerID string, callStack *v1beta1.IdentifiedCallStack)
2220
ReportSymlinkEvent(containerID string, event *tracersymlinktype.Event)
2321
ReportHardlinkEvent(containerID string, event *tracerhardlinktype.Event)
24-
ReportNetworkEvent(containerID string, event *datasource.Data)
22+
ReportNetworkEvent(containerID string, event *utils.EnrichEvent)
23+
ReportSyscalls(containerID string, syscalls []string)
2524
ReportDroppedEvent(containerID string)
2625
RegisterForContainerEndOfLife(notificationChannel chan *containercollection.Container)
2726
OnQueueError(profile *v1beta1.ContainerProfile, containerID string, err error)

pkg/containerprofilemanager/containerprofile_manager_mock.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package containerprofilemanager
22

33
import (
44
containercollection "github.com/inspektor-gadget/inspektor-gadget/pkg/container-collection"
5-
"github.com/inspektor-gadget/inspektor-gadget/pkg/datasource"
65
tracerhardlinktype "github.com/kubescape/node-agent/pkg/ebpf/gadgets/hardlink/types"
76
tracerhttptype "github.com/kubescape/node-agent/pkg/ebpf/gadgets/http/types"
87
tracersymlinktype "github.com/kubescape/node-agent/pkg/ebpf/gadgets/symlink/types"
@@ -23,19 +22,19 @@ func (a ContainerProfileManagerMock) ContainerCallback(_ containercollection.Pub
2322
// noop
2423
}
2524

26-
func (a ContainerProfileManagerMock) RegisterPeekFunc(_ func(mntns uint64) ([]string, error)) {
25+
func (a ContainerProfileManagerMock) ReportSyscalls(_ string, _ []string) {
2726
// noop
2827
}
2928

3029
func (a ContainerProfileManagerMock) ReportCapability(_, _ string) {
3130
// noop
3231
}
3332

34-
func (a ContainerProfileManagerMock) ReportFileExec(containerID string, event *utils.EnrichEvent) {
33+
func (a ContainerProfileManagerMock) ReportFileExec(_ string, _ *utils.EnrichEvent) {
3534
// noop
3635
}
3736

38-
func (a ContainerProfileManagerMock) ReportFileOpen(containerID string, event *utils.EnrichEvent) {
37+
func (a ContainerProfileManagerMock) ReportFileOpen(_ string, _ *utils.EnrichEvent) {
3938
// noop
4039
}
4140

@@ -67,7 +66,7 @@ func (a ContainerProfileManagerMock) RegisterForContainerEndOfLife(_ chan *conta
6766
// noop
6867
}
6968

70-
func (a ContainerProfileManagerMock) ReportNetworkEvent(_ string, _ *datasource.Data) {
69+
func (a ContainerProfileManagerMock) ReportNetworkEvent(_ string, _ *utils.EnrichEvent) {
7170
// noop
7271
}
7372

pkg/containerprofilemanager/v1/container_data.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ import (
1313
"k8s.io/utils/ptr"
1414
)
1515

16-
// emptyEvents clears all event data except syscalls (which are kept for peek function)
16+
// emptyEvents clears all event data
1717
func (cd *containerData) emptyEvents() {
1818
cd.size.Store(0)
1919
cd.capabilites = nil
20-
// cd.syscalls is intentionally not set to nil, as we want to keep the syscalls for the peek function
20+
cd.syscalls = nil
2121
cd.endpoints = nil
2222
cd.execs = nil
2323
cd.opens = nil
@@ -95,6 +95,13 @@ func (cd *containerData) getOpens() []v1beta1.OpenCalls {
9595
return opens
9696
}
9797

98+
func (cd *containerData) getSyscalls() []string {
99+
if cd.syscalls == nil {
100+
return []string{}
101+
}
102+
return cd.syscalls.ToSlice()
103+
}
104+
98105
// getEndpoints returns all HTTP endpoints recorded for this container
99106
func (cd *containerData) getEndpoints() []v1beta1.HTTPEndpoint {
100107
var endpoints []v1beta1.HTTPEndpoint

pkg/containerprofilemanager/v1/container_operations.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,3 @@ func (cpm *ContainerProfileManager) removeContainerEntry(containerID string) (*C
102102

103103
return entry, exists
104104
}
105-
106-
// RegisterPeekFunc registers the syscall peek function
107-
func (cpm *ContainerProfileManager) RegisterPeekFunc(peek func(mntns uint64) ([]string, error)) {
108-
cpm.syscallPeekFunc = peek
109-
}

pkg/containerprofilemanager/v1/containerprofile_manager.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ type ContainerProfileManager struct {
6969
k8sObjectCache objectcache.K8sObjectCache
7070
storageClient storage.StorageClient
7171
dnsResolverClient dnsmanager.DNSResolver
72-
syscallPeekFunc func(nsMountId uint64) ([]string, error)
7372
seccompManager seccompmanager.SeccompManagerClient
7473
enricher containerprofilemanager.Enricher
7574
ruleBindingCache rulebindingmanager.RuleBindingCache

pkg/containerprofilemanager/v1/containerprofile_manager_test.go

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -596,51 +596,6 @@ func TestContainerDataEmptyEvents(t *testing.T) {
596596
// Note: syscalls should remain not nil as per the comment in the code
597597
}
598598

599-
func TestContainerProfileManagerRegisterPeekFunc(t *testing.T) {
600-
// Create a unique temporary directory for this test
601-
tempDir, err := os.MkdirTemp("", "fake-storage-queue-*")
602-
if err != nil {
603-
t.Fatalf("Failed to create temp directory: %v", err)
604-
}
605-
defer os.RemoveAll(tempDir) // Clean up after test
606-
607-
// Override the queue directory for this test
608-
t.Setenv("QUEUE_DIR", tempDir)
609-
610-
cfg := config.Config{}
611-
ctx := context.TODO()
612-
k8sClient := &k8sclient.K8sClientMock{}
613-
storageClient := &storage.StorageHttpClientMock{}
614-
k8sObjectCacheMock := &objectcache.K8sObjectCacheMock{}
615-
seccompManagerMock := &seccompmanager.SeccompManagerMock{}
616-
617-
cpm, err := NewContainerProfileManager(
618-
ctx,
619-
cfg,
620-
k8sClient,
621-
k8sObjectCacheMock,
622-
storageClient,
623-
nil,
624-
seccompManagerMock,
625-
nil,
626-
nil,
627-
)
628-
require.NoError(t, err)
629-
630-
// Register a peek function
631-
peekFunc := func(mntns uint64) ([]string, error) {
632-
return []string{"open", "read"}, nil
633-
}
634-
635-
cpm.RegisterPeekFunc(peekFunc)
636-
assert.NotNil(t, cpm.syscallPeekFunc)
637-
638-
// Test the registered function
639-
result, err := cpm.syscallPeekFunc(12345)
640-
assert.NoError(t, err)
641-
assert.Equal(t, []string{"open", "read"}, result)
642-
}
643-
644599
func TestEndpointKindConstants(t *testing.T) {
645600
assert.Equal(t, EndpointKind("pod"), EndpointKindPod)
646601
assert.Equal(t, EndpointKind("svc"), EndpointKindService)

0 commit comments

Comments
 (0)