fix: container/pod inequality filters should not exclude host events#5226
Draft
yanivagman wants to merge 1 commit into
Draft
fix: container/pod inequality filters should not exclude host events#5226yanivagman wants to merge 1 commit into
yanivagman wants to merge 1 commit into
Conversation
… fields This fixes an issue where container/pod filters with inequality operators (!=) implicitly excluded host events. Previously, when using a filter like 'podNamespace!=kube-system', the addContainer() function would automatically set containerFilter to require that events come from containers. This meant host events (which have empty container/pod fields) would be filtered out. Now, when using inequality operators (!=), the containerFilter is not enabled, allowing host events to pass through. Host events have empty values for container/pod fields, which correctly do not match the excluded values (e.g., '' != 'kube-system' is true). Equality operators (=) still require events to come from containers, as users explicitly want to match specific container/pod values. Fixes: #5224 Co-authored-by: yaniv <yaniv@aquasec.com>
|
Cursor Agent can help with this pull request. Just |
|
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5226 +/- ##
==========================================
+ Coverage 33.51% 35.50% +1.99%
==========================================
Files 250 239 -11
Lines 28908 31488 +2580
==========================================
+ Hits 9688 11181 +1493
- Misses 18609 19591 +982
- Partials 611 716 +105
🚀 New features to boost your workflow:
|
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
1. Explain what the PR does
Resolves #5224. Previously, container/pod-related filters using inequality operators (e.g.,
podNamespace!=kube-system) implicitly excluded host events. This PR modifiespkg/filters/scope.go::addContainerto only enforce container scope (i.e., require a non-empty container ID) when an equality operator (=) is used. For inequality operators (!=), host events are now correctly allowed to pass through, as their empty container/pod fields will not match the excluded values.2. Explain how to test it
Verify host events are included with
!=filter:sudo ./tracee --output json --scope podNamespace!=kube-systemExpected: You should see both container events (from pods not in
kube-system) and host events (events with emptyContainer.IDandKubernetesfields).Verify host events are excluded with
=filter (existing behavior):Expected: You should only see container events from pods in the
defaultnamespace. Host events should be filtered out.3. Other comments
Fixes: #5224