-
Notifications
You must be signed in to change notification settings - Fork 130
OCPBUGS-62730 - Fixed typos and truncated field values in JSON audit logs generated by the JSON enricher #3071
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -313,6 +313,8 @@ func (e *JsonEnricher) Run(ctx context.Context, runErr chan<- error) { | |||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| // Capture proc/pid/(cmdLine/environ) early; these files are ephemeral on some OS (e.g., Ubuntu). | ||||||||||||||||||||||||||||||||||||
| logBucket.Mu.Lock() | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| if logBucket.ProcessInfo == nil { | ||||||||||||||||||||||||||||||||||||
| uid, gid, err := auditsource.GetUidGid(line) | ||||||||||||||||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||||||||||||||||
|
|
@@ -324,12 +326,18 @@ func (e *JsonEnricher) Run(ctx context.Context, runErr chan<- error) { | |||||||||||||||||||||||||||||||||||
| auditLine.Executable, uid, gid) | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| logBucket.Mu.Unlock() | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| e.processEbpf(logBucket, auditLine) | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| logBucket.Mu.Lock() | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| if logBucket.ContainerInfo == nil { | ||||||||||||||||||||||||||||||||||||
| logBucket.ContainerInfo = e.fetchContainerInfo(ctx, auditLine.ProcessID, nodeName) | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| logBucket.Mu.Unlock() | ||||||||||||||||||||||||||||||||||||
|
Comment on lines
+333
to
+339
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Consider narrowing the lock to just the pointer assignment:
Suggested change
|
||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| logBucket.SyscallIds.LoadOrStore(auditLine.SystemCallID, struct{}{}) | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| if !e.logLinesCache.Has(auditLine.ProcessID) { | ||||||||||||||||||||||||||||||||||||
|
|
@@ -341,6 +349,9 @@ func (e *JsonEnricher) Run(ctx context.Context, runErr chan<- error) { | |||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| func (e *JsonEnricher) processEbpf(logBucket *types.LogBucket, auditLine *types.AuditLine) { | ||||||||||||||||||||||||||||||||||||
| logBucket.Mu.Lock() | ||||||||||||||||||||||||||||||||||||
| defer logBucket.Mu.Unlock() | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| if e.bpfProcessCache != nil && logBucket.ProcessInfo != nil && logBucket.ProcessInfo.CmdLine == "" { | ||||||||||||||||||||||||||||||||||||
| cmdLine, errCmdLine := e.bpfProcessCache.GetCmdLine(auditLine.ProcessID) | ||||||||||||||||||||||||||||||||||||
| if errCmdLine == nil { | ||||||||||||||||||||||||||||||||||||
|
|
@@ -435,6 +446,10 @@ func (e *JsonEnricher) dispatchSeccompLine( | |||||||||||||||||||||||||||||||||||
| return true | ||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| // Acquire read lock to safely access ProcessInfo and ContainerInfo | ||||||||||||||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comment restates what the code does.
Suggested change
|
||||||||||||||||||||||||||||||||||||
| logBucket.Mu.RLock() | ||||||||||||||||||||||||||||||||||||
| defer logBucket.Mu.RUnlock() | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| var resource map[string]string | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| if logBucket.ProcessInfo == nil { | ||||||||||||||||||||||||||||||||||||
|
|
@@ -448,10 +463,14 @@ func (e *JsonEnricher) dispatchSeccompLine( | |||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| if logBucket.ContainerInfo != nil { | ||||||||||||||||||||||||||||||||||||
|
BhargaviGudi marked this conversation as resolved.
|
||||||||||||||||||||||||||||||||||||
| podName := logBucket.ContainerInfo.PodName | ||||||||||||||||||||||||||||||||||||
| namespace := logBucket.ContainerInfo.Namespace | ||||||||||||||||||||||||||||||||||||
| containerName := logBucket.ContainerInfo.ContainerName | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| resource = map[string]string{ | ||||||||||||||||||||||||||||||||||||
| "pod": logBucket.ContainerInfo.PodName, | ||||||||||||||||||||||||||||||||||||
| "namespace": logBucket.ContainerInfo.Namespace, | ||||||||||||||||||||||||||||||||||||
| "container": logBucket.ContainerInfo.ContainerName, | ||||||||||||||||||||||||||||||||||||
| "pod": podName, | ||||||||||||||||||||||||||||||||||||
| "namespace": namespace, | ||||||||||||||||||||||||||||||||||||
| "container": containerName, | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
Comment on lines
+466
to
474
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These local variables add no safety since the
Suggested change
|
||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same concern as the
fetchContainerInfoblock below: the lock wraps both the nil check andfetchProcessInfo, which reads/procfiles. Consider fetching outside the lock and only locking for the pointer assignment:This eliminates the lock-unlock-lock-unlock pattern in
Run(), keeping locks to short pointer assignments only.