-
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 container_id filter
Implement a container_id filter, primarily to support its use in docker-based unit testing. Signed-off-by: William Findlay <[email protected]>
- Loading branch information
1 parent
f816ef5
commit 9c4ff53
Showing
14 changed files
with
584 additions
and
494 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
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
336 changes: 174 additions & 162 deletions
336
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.
3 changes: 3 additions & 0 deletions
3
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
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,42 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Copyright Authors of Cilium | ||
|
||
package filters | ||
|
||
import ( | ||
"context" | ||
"strings" | ||
|
||
v1 "github.com/cilium/cilium/pkg/hubble/api/v1" | ||
hubbleFilters "github.com/cilium/cilium/pkg/hubble/filters" | ||
"github.com/cilium/tetragon/api/v1/tetragon" | ||
) | ||
|
||
func filterByContainerID(ids []string) (hubbleFilters.FilterFunc, error) { | ||
return func(ev *v1.Event) bool { | ||
process := GetProcess(ev) | ||
if process == nil { | ||
return false | ||
} | ||
for _, id := range ids { | ||
if strings.HasPrefix(process.Docker, id) { | ||
return true | ||
} | ||
} | ||
return false | ||
}, nil | ||
} | ||
|
||
type ContainerIDFilter struct{} | ||
|
||
func (f *ContainerIDFilter) OnBuildFilter(_ context.Context, ff *tetragon.Filter) ([]hubbleFilters.FilterFunc, error) { | ||
var fs []hubbleFilters.FilterFunc | ||
if ff.ContainerId != nil { | ||
filters, err := filterByContainerID(ff.ContainerId) | ||
if err != nil { | ||
return nil, err | ||
} | ||
fs = append(fs, filters) | ||
} | ||
return fs, nil | ||
} |
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
Oops, something went wrong.