Skip to content

Commit

Permalink
fix(filters): handle syscall arg
Browse files Browse the repository at this point in the history
Handle syscall arg when set as a syscall name (string).

E.g.: sys_enter.args.syscall=bpf
  • Loading branch information
geyslan committed Feb 22, 2024
1 parent 5cb5760 commit a9a3f53
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions pkg/filters/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ package filters

import (
"fmt"
"strconv"
"strings"

"github.com/aquasecurity/tracee/pkg/errfmt"
"github.com/aquasecurity/tracee/pkg/events"
"github.com/aquasecurity/tracee/pkg/logger"
"github.com/aquasecurity/tracee/pkg/utils"
"github.com/aquasecurity/tracee/types/trace"
)
Expand Down Expand Up @@ -45,6 +47,7 @@ func (filter *ArgFilter) Filter(eventID events.ID, args []trace.Argument) bool {
for argName, filter := range filter.filters[eventID] {
found := false
var argVal interface{}

for _, arg := range args {
if arg.Name == argName {
found = true
Expand All @@ -55,10 +58,18 @@ func (filter *ArgFilter) Filter(eventID events.ID, args []trace.Argument) bool {
if !found {
return false
}
// TODO: use type assertion instead of string conversion
if argName != "syscall" {
argVal = fmt.Sprint(argVal)

argVal = fmt.Sprint(argVal)
if argName == "syscall" {
syscallID, err := strconv.Atoi(argVal.(string))
if err != nil {
logger.Errorw("failed to convert syscall id to int", "syscall", argVal, "error", err)
return false
}

argVal = events.Core.GetDefinitionByID(events.ID(syscallID)).GetName()
}

res := filter.Filter(argVal)
if !res {
return false
Expand Down

0 comments on commit a9a3f53

Please sign in to comment.