Skip to content

Commit

Permalink
Merge pull request #426 from kubescape/fix/enricher_syscalls
Browse files Browse the repository at this point in the history
Added syscalls consts
  • Loading branch information
matthyx authored Dec 5, 2024
2 parents addb2f0 + 39a27d8 commit 293b090
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 8 deletions.
13 changes: 13 additions & 0 deletions pkg/containerwatcher/v1/consts.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package containerwatcher

// The numbers can be arbitrary identifiers since they're not actually used for system calls,
// so we don't need to handle other architecture specifically.
const (
SYS_LINKAT = 265
SYS_LINK = 86
SYS_SYMLINKAT = 266
SYS_SYMLINK = 88
SYS_OPEN = 2
SYS_OPENAT = 257
SYS_EXECVE = 59
)
3 changes: 1 addition & 2 deletions pkg/containerwatcher/v1/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
tracerexectype "github.com/inspektor-gadget/inspektor-gadget/pkg/gadgets/trace/exec/types"
"github.com/inspektor-gadget/inspektor-gadget/pkg/types"
events "github.com/kubescape/node-agent/pkg/ebpf/events"
"golang.org/x/sys/unix"
)

func (ch *IGContainerWatcher) execEventCallback(event *tracerexectype.Event) {
Expand All @@ -16,7 +15,7 @@ func (ch *IGContainerWatcher) execEventCallback(event *tracerexectype.Event) {
}

execEvent := &events.ExecEvent{Event: *event}
ch.enrichEvent(execEvent, []uint64{unix.SYS_EXECVE, unix.SYS_EXECVEAT})
ch.enrichEvent(execEvent, []uint64{SYS_EXECVE})

if event.Retval > -1 && event.Comm != "" {
ch.execWorkerChan <- execEvent
Expand Down
3 changes: 1 addition & 2 deletions pkg/containerwatcher/v1/hardlink.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

tracerhardlink "github.com/kubescape/node-agent/pkg/ebpf/gadgets/hardlink/tracer"
tracerhardlinktype "github.com/kubescape/node-agent/pkg/ebpf/gadgets/hardlink/types"
"golang.org/x/sys/unix"

"github.com/inspektor-gadget/inspektor-gadget/pkg/types"
"github.com/kubescape/go-logger"
Expand All @@ -22,7 +21,7 @@ func (ch *IGContainerWatcher) hardlinkEventCallback(event *tracerhardlinktype.Ev
return
}

ch.enrichEvent(event, []uint64{unix.SYS_LINK, unix.SYS_LINKAT})
ch.enrichEvent(event, []uint64{SYS_LINK, SYS_LINKAT})

ch.hardlinkWorkerChan <- event
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/containerwatcher/v1/open.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
traceropentype "github.com/inspektor-gadget/inspektor-gadget/pkg/gadgets/trace/open/types"
"github.com/inspektor-gadget/inspektor-gadget/pkg/types"
events "github.com/kubescape/node-agent/pkg/ebpf/events"
"golang.org/x/sys/unix"
)

func (ch *IGContainerWatcher) openEventCallback(event *traceropentype.Event) {
Expand All @@ -16,7 +15,7 @@ func (ch *IGContainerWatcher) openEventCallback(event *traceropentype.Event) {
}

openEvent := &events.OpenEvent{Event: *event}
ch.enrichEvent(openEvent, []uint64{unix.SYS_OPEN, unix.SYS_OPENAT})
ch.enrichEvent(openEvent, []uint64{SYS_OPEN, SYS_OPENAT})

if event.Err > -1 && event.FullPath != "" {
ch.openWorkerChan <- openEvent
Expand Down
3 changes: 1 addition & 2 deletions pkg/containerwatcher/v1/symlink.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

tracersymlink "github.com/kubescape/node-agent/pkg/ebpf/gadgets/symlink/tracer"
tracersymlinktype "github.com/kubescape/node-agent/pkg/ebpf/gadgets/symlink/types"
"golang.org/x/sys/unix"

"github.com/inspektor-gadget/inspektor-gadget/pkg/types"
"github.com/kubescape/go-logger"
Expand All @@ -17,7 +16,7 @@ func (ch *IGContainerWatcher) symlinkEventCallback(event *tracersymlinktype.Even
return
}

ch.enrichEvent(event, []uint64{unix.SYS_SYMLINK, unix.SYS_SYMLINKAT})
ch.enrichEvent(event, []uint64{SYS_SYMLINK, SYS_SYMLINKAT})

if isDroppedEvent(event.Type, event.Message) {
logger.L().Ctx(ch.ctx).Warning("symlink tracer got drop events - we may miss some realtime data", helpers.Interface("event", event), helpers.String("error", event.Message))
Expand Down

0 comments on commit 293b090

Please sign in to comment.