Skip to content

Handle truncated Kubernetes audit logs#697

Open
Haihan-Jiang wants to merge 1 commit into
GoogleCloudPlatform:mainfrom
Haihan-Jiang:codex/khi-skip-truncated-audit-manifests
Open

Handle truncated Kubernetes audit logs#697
Haihan-Jiang wants to merge 1 commit into
GoogleCloudPlatform:mainfrom
Haihan-Jiang:codex/khi-skip-truncated-audit-manifests

Conversation

@Haihan-Jiang

Copy link
Copy Markdown
Contributor

Fixes #193.

Summary:

  • read the GKE audit log audit.k8s.io/truncated label into the Kubernetes audit field set
  • skip manifest reconstruction for truncated audit entries so partial payloads are not shown as full resource revisions
  • keep the previous known manifest revision available for later non-truncated events

Tests:

  • go test ./pkg/task/inspection/googlecloudlogk8saudit/contract ./pkg/task/inspection/commonlogk8saudit/contract ./pkg/task/inspection/commonlogk8saudit/impl

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for handling truncated Kubernetes audit logs. It adds a Truncated boolean field to the K8sAuditLogFieldSet struct and updates the GCP audit log reader to parse the audit.k8s.io/truncated label. The manifest generator is updated to return a placeholder message and avoid advancing the resource revision when a log is truncated. Relevant unit tests have been added to verify this behavior. There are no review comments to address.

@Haihan-Jiang

Copy link
Copy Markdown
Contributor Author

This is ready for maintainer review from my side. The remaining github-deploy-ondemand check appears to require project-side approval/run permissions; could someone take a look or trigger it when convenient?

@kyasbal

kyasbal commented May 30, 2026

Copy link
Copy Markdown
Member

I'm sorry to reply late. I should have write our roadmap somewhere,but this part would be rewritten a lot in the next upcoming big release concerning a file format improvement to make KHI much more scalable.

I would also implement this with the similar codes as you did if I would implement the feature on the current main implementation. But I would like to consider the best shape after the file format change being placed. It will take 2 weeks to a month.

Could we hold this until the change?

@Haihan-Jiang

Copy link
Copy Markdown
Contributor Author

Thanks for explaining the roadmap. Holding this until the file format change lands sounds good to me. If the new shape needs a different implementation, I can revisit this PR or open a smaller follow-up after that work is in place.

@Haihan-Jiang Haihan-Jiang force-pushed the codex/khi-skip-truncated-audit-manifests branch from 47aeb08 to 36cab28 Compare June 14, 2026 10:53
@kyasbal

kyasbal commented Jun 23, 2026

Copy link
Copy Markdown
Member

Our new version 0.56.0 is released. We no longer need to hold this PR. Are you still willing to contribute this feature?

Unfortunately, there would be a lot of efforts needed to this PR works. I saw this PR just added truncated field in the fieldset struct. However, the parser result would be differ if a subsequent log is truncated within the series of audit logs for a single resource. The main problem we need to address the truncated issue is that. I'm actually estimating this is a bit complex issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support audit.k8s.io/truncated label on audit log

2 participants