fix: use correct datasource fields for iouring events#751
Conversation
The iouring event handler was accessing fields that don't exist in the iouring gadget datasource, causing a "field not found" warning on every single event (~97% of all node-agent log lines on affected nodes). Two mismatches fixed: - event_handler_factory used GetIdentifier() for the rule policy allowedProcess param, but the iouring datasource has no "identifier" field. Use GetComm() instead, matching exec/symlink/hardlink events. - GetFlags()/GetFlagsRaw() accessed "flags_raw", but the iouring gadget exposes "flags". Also, decodeOpenFlags() is for file open flags, not io_uring SQE flags. Made-with: Cursor Signed-off-by: Ben <ben@armosec.io>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughReplaced IoUring event reporting payload to use the event's comm (GetComm()) instead of identifier, and added IoUring-specific branching in GetFlags/GetFlagsRaw to read "flags" as uint32/string while preserving prior behavior for other event types. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@pkg/utils/datasource_event.go`:
- Around line 412-423: The GetFlags() accessor currently reads the io_uring
"flags" field as a string but the schema defines it as __u32; change the
IoUringEventType branch in GetFlags() to call
e.getFieldAccessor("flags").Uint32(e.Data), handle the zero/empty case, convert
the uint32 to a string (use strconv.FormatUint(uint64(val), 10)) and return it
as []string{...}; also add "strconv" to imports if missing. Ensure you reference
GetFlags(), IoUringEventType, and getFieldAccessor("flags") when making the
change.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 8955cd9a-4c35-4a6e-8b40-5d2946225a9e
📒 Files selected for processing (2)
pkg/containerwatcher/v2/event_handler_factory.gopkg/utils/datasource_event.go
The iouring gadget defines flags as __u32 in the eBPF struct. Reading it via .String() would silently fail and always return empty. Use .Uint32() and convert to string for the []string return type. Made-with: Cursor Signed-off-by: Ben <ben@armosec.io>
|
@slashben did you try deploying it in your cluster? |
Summary
The iouring event handler was accessing fields that don't exist in the iouring gadget datasource, causing a
field not foundwarning on every single iouring event. On affected nodes this accounted for ~97% of all node-agent log lines (~6249 out of 6433).Two field mismatches fixed:
identifier→GetComm(): The rule policy reporter calledGetIdentifier()for iouring events, but the iouring datasource has noidentifierfield. Changed toGetComm()(process name), matching the pattern used by exec, symlink, and hardlink events. This was the main source of log noise.flags_raw→flags:GetFlags()andGetFlagsRaw()accessedflags_raw, but the iouring gadget exposesflags(no_rawsuffix). Also avoided applyingdecodeOpenFlags()(file open flags) to io_uring SQE flags.Available iouring datasource fields (from
iouring_test.go)Note: no
identifierorflags_rawin this list.Test plan
field not foundwarnings for iouring are gonego test ./...)Made with Cursor
Summary by CodeRabbit