Skip to content

Commit

Permalink
feat: parse dirfd for special case AT_FDCWD
Browse files Browse the repository at this point in the history
syscalls with dirfd arg now parse for special case AT_FDCWD when
ParseArgumentsFDs is true.
  • Loading branch information
geyslan committed Jan 15, 2025
1 parent af50e8b commit 9676369
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/events/parse_args.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,12 @@ func ParseArgsFDs(event *trace.Event, origTimestamp uint64, fdArgPathMap *bpf.BP
}
}

if dirfdArg := GetArg(event, "dirfd"); dirfdArg != nil {
if dirfd, isInt32 := dirfdArg.Value.(int32); isInt32 {
parseDirfdAt(dirfdArg, uint64(dirfd))
}
}

return nil
}

Expand Down
10 changes: 10 additions & 0 deletions pkg/events/parse_args_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,21 @@ package events
import (
"strconv"

"golang.org/x/sys/unix"

"github.com/aquasecurity/tracee/pkg/events/parsers"
"github.com/aquasecurity/tracee/pkg/logger"
"github.com/aquasecurity/tracee/types/trace"
)

func parseDirfdAt(arg *trace.Argument, dirfd uint64) {
if int32(dirfd) == unix.AT_FDCWD {
arg.Type = "string"
arg.Value = "AT_FDCWD"
return
}
}

func parseMMapProt(arg *trace.Argument, prot uint64) {
mmapProtArgument := parsers.ParseMmapProt(prot)
arg.Type = "string"
Expand Down

0 comments on commit 9676369

Please sign in to comment.