-
Notifications
You must be signed in to change notification settings - Fork 376
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
filters: implement in_init_tree filter
Implement a new export filter for the process.in_init_tree field. Signed-off-by: William Findlay <[email protected]>
- Loading branch information
1 parent
b80a338
commit 50ba9b5
Showing
11 changed files
with
741 additions
and
582 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
405 changes: 211 additions & 194 deletions
405
contrib/tetragon-rthooks/vendor/github.com/cilium/tetragon/api/v1/tetragon/events.pb.go
Large diffs are not rendered by default.
Oops, something went wrong.
5 changes: 5 additions & 0 deletions
5
contrib/tetragon-rthooks/vendor/github.com/cilium/tetragon/api/v1/tetragon/events.proto
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Copyright Authors of Tetragon | ||
|
||
package filters | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
v1 "github.com/cilium/cilium/pkg/hubble/api/v1" | ||
"github.com/cilium/tetragon/api/v1/tetragon" | ||
"github.com/stretchr/testify/assert" | ||
"google.golang.org/protobuf/types/known/wrapperspb" | ||
) | ||
|
||
func TestContainerID(t *testing.T) { | ||
f := []*tetragon.Filter{{ContainerId: []string{ | ||
"^2f00a73446e0", | ||
}}} | ||
fl, err := BuildFilterList(context.Background(), f, []OnBuildFilter{&ContainerIDFilter{}}) | ||
assert.NoError(t, err) | ||
process := tetragon.Process{Docker: "2f00a73446e0"} | ||
ev := v1.Event{ | ||
Event: &tetragon.GetEventsResponse{ | ||
Event: &tetragon.GetEventsResponse_ProcessExec{ | ||
ProcessExec: &tetragon.ProcessExec{ | ||
Process: &process, | ||
}, | ||
}, | ||
}, | ||
} | ||
assert.True(t, fl.MatchOne(&ev)) | ||
process.Docker = "foo" | ||
assert.False(t, fl.MatchOne(&ev)) | ||
} | ||
|
||
func TestInInitTree(t *testing.T) { | ||
f := []*tetragon.Filter{{InInitTree: &wrapperspb.BoolValue{Value: true}}} | ||
fl, err := BuildFilterList(context.Background(), f, []OnBuildFilter{&InInitTreeFilter{}}) | ||
assert.NoError(t, err) | ||
process := tetragon.Process{} | ||
ev := v1.Event{ | ||
Event: &tetragon.GetEventsResponse{ | ||
Event: &tetragon.GetEventsResponse_ProcessExec{ | ||
ProcessExec: &tetragon.ProcessExec{ | ||
Process: &process, | ||
}, | ||
}, | ||
}, | ||
} | ||
process.InInitTree = &wrapperspb.BoolValue{Value: true} | ||
assert.True(t, fl.MatchOne(&ev)) | ||
process.InInitTree = &wrapperspb.BoolValue{Value: false} | ||
assert.False(t, fl.MatchOne(&ev)) | ||
process.InInitTree = nil | ||
assert.False(t, fl.MatchOne(&ev)) | ||
|
||
f = []*tetragon.Filter{{InInitTree: &wrapperspb.BoolValue{Value: false}}} | ||
fl, err = BuildFilterList(context.Background(), f, []OnBuildFilter{&InInitTreeFilter{}}) | ||
assert.NoError(t, err) | ||
|
||
process.InInitTree = &wrapperspb.BoolValue{Value: true} | ||
assert.False(t, fl.MatchOne(&ev)) | ||
process.InInitTree = &wrapperspb.BoolValue{Value: false} | ||
assert.True(t, fl.MatchOne(&ev)) | ||
process.InInitTree = nil | ||
assert.True(t, fl.MatchOne(&ev)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.