Repository navigation
feat(artifacts): inventory Kubernetes audit logs offline - #14952
Conversation
A Kubernetes audit log exported from kube-apiserver is JSON-lines that the inventory treated as an unknown file: no format claim, no reader, and no way to see what an acquired log declares without a live cluster. Recognize the format from its first event and report, offline, the line, stage and verb totals and a bounded window of the events joined on their auditID. Each line stays an event in its own right, so a request whose stages were written out of order, repeated at one stage, or missing a stage is reported rather than reordered into a tidy request. Unknown API versions keep their auditID and stage but are not interpreted under field names the version may not use. Malformed lines are counted and bounded, never dropped silently. Refs morluto#11352 (first slice: request, user, object reference and response code; request/response bodies, annotations and impersonation metadata are not read).
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
[Medium impact] The PR appears safe to merge based on the reviewed changes. SummaryAdds offline Kubernetes audit-log recognition and inventory, with bounded request samples, stage facts, and coverage limits.
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart LR
A[Selected file] --> B[Probe top-level audit identity]
B --> C[Kubernetes audit-log reader]
C --> D{Record fits line allowance?}
D -->|No| E[Count unexamined skip]
D -->|Yes| F[Read bounded fields]
F --> G[Count stages and verbs]
F --> H[Join sampled requests by auditID]
E --> I[Root metadata and limitations]
G --> I
H --> I
Reviews (26) · Last reviewed commit: "fix(artifacts): keep audit status codes ..." · Reviewed by Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 59d71ea638
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: df672b51e2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ad49454e24
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
manuelanthoni7-max
left a comment
There was a problem hiding this comment.
Holaaa esta bueno lonrecomeindo
|
Status: green and conflict-free on Two points in the diff that are easy to misread, since they are the decisions the issue left open:
Validation gap, stated plainly: the fixtures are synthetic, hand-written from the published event schema. There is no exported Would you rather review this as-is, or split it so recognition plus inventory lands first and the 32-request join/sampling follows on top? |
Recognition stopped at the first newline and rejected a leading UTF-8 BOM, while the reader skipped blank lines and trimmed that BOM away. Both now treat empty lines, JSON whitespace, and one leading U+FEFF as padding. Request fields come from the first stage whose API version is modelled, so an earlier unmodelled stage no longer hides a later v1 record.
|
@greptileai review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f2b145c9ad
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
JSON.parse built a value tree for ignored request and response objects, so a deeply nested body could abort the process. Each line is tokenized and only the summary fields are kept. The tokenizer stops at 64 containers; identity already read is kept, and a deeper body before that identity is one line diagnostic.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f7c7bab4cd
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
A container where a scalar or string list was required now leaves that field null, and a source address or group list past the retained text budget is not stored. Lines that exceed the tokenizer depth are counted separately from malformed JSON, and a sampled request says when the scan stopped early. Recognition uses the same depth cap and does not flush a tokenizer that already stopped.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: be11607760
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
A source address or group list past the retained text budget sets request_fields_omitted instead of looking absent. Owned strings stop growing once they pass that budget. A later scalar that replaces user, objectRef, or responseStatus clears the earlier object.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1b48ab5b19
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 79ec9cc39a
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
A first stage whose request body hits the JSON depth cap observes no apiVersion, so its request fields are withheld. The sample still marked fieldsRecorded true because only a declared unsupported version counted, so a later readable stage for the same auditID never supplied the URI, verb, user, or object details. Gate both the flag and the later fill on suppressFields so depth-suppressed stages stay fillable.
A later duplicate that supplies a small user agent, URI, or list no longer leaves request_fields_omitted set for the value that was replaced.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d707145668
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
A later null or container for an owned field clears the budget-omission mark left by the value it replaces.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2cfcfd582d
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…slices Nested field omission no longer shares a key with a top-level property of the same spelling. Replacing a list with an object clears that list's budget mark. Recognition drops the first-record replay buffer when the line ends and when the probe finishes.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b17faa1e25
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…e line is read A later null for sourceIPs or groups clears that list's budget mark. Recognition keeps the first record's slices until that line has been tokenized, then drops them.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 995ca403bc
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…y text A later null or object for user.groups clears that list's budget mark, and a new user or objectRef object clears its child marks. Syntax failures drop the recognition replay buffer before the probe returns.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b79bf2ba91
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
An over-budget apiVersion no longer sets request_fields_omitted. Replacing an objectRef field, or starting a new sourceIPs or groups list, clears that field's budget mark.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b99f9e5ccc
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
A status lexeme such as 200.00000000000000000 is still the safe integer 200. The number text bound is 64 characters, which covers that form and still rejects an unbounded digit string.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6f8eeb31ef
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
The response code is now admitted by its numeric value instead of a 20-character text bound. Pin the two edges that keep the wider bound honest: the widest safe integer on both sides, an exponent form that evaluates to a safe integer, and a value past the safe range that is still dropped.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d54789e4e4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Trailing zeros after a decimal do not drop an integral status code. A verb dropped by the text budget counts as unlisted. A recognition finish before the first line ends stays pending and keeps its replay text.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 173d9cc392
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
A status code is the safe integer its lexeme evaluates to, including a fraction that an exponent cancels. Leading padding has its own recognition allowance, and a verb dropped before an unread API version stays out of the histogram.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 690d14cbb6
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
A large exponent is rejected only when it cannot cancel to a safe integer inside the maximum line. The final shift still decides the code.
Summary
Refs #11352.
kube-apiserverwrites its audit log as JSON-lines. REA classified neither the format nor its contents: an acquiredaudit.logfell to ordinary inventory, so an analyst could not see what requests the log declares without a live cluster orkubectl.This adds an offline, read-only reader. A top-level
auditIDand recognizedstagein the first JSON line establish the format. File and directory routes stream bounded JSON tokens when earlier properties extend beyond the ordinary prefix. Recognition retains only the top-level identity facts. The inventory reader applies the caller’s allowance before decoding a complete record. The reader reports line and stage totals, a bounded verb histogram, and a bounded window of requests joined onauditID.Problem and expected behavior
A Kubernetes audit log has no magic bytes and no extension REA classifies, so it stayed an unknown file. The expected behavior is that
inspect_artifactreports it as root formatkubernetes-audit-logwith the request URI, verb, user and groups, source IPs, object reference, response code, and the stages the request passed through — with fields the event omits reported as null rather than empty text.Change and scope
Follows the contribution scope. No maintainer scope decision was needed: this is a new reader in the existing artifact-inventory boundary, with no target execution, injection, mutation or protection recovery.
src/domain/linux/kubernetesAuditLog.tsowns recognition and parsing and returns aResultfailure of kindmalformedorlimit.KubernetesAuditLogArtifactReaderreads the admitted file, parses it line by line, and exposes the inventory throughformatMetadata().auditd-log.Two decisions the issue did not settle, and why they went this way:
ResponseCompleteorPanicestablishes the observed terminal stage. The file is reported as written.apiVersionis notaudit.k8s.io/v1orv1beta1keeps itsauditIDand stage, but its other fields stay null and a limitation says so, rather than reading a field under a name the version may not have used it for.Intentionally not included, and stated in every result's
limitations:Contract and boundary impact
src/domain/linux/kubernetesAuditLog.tsproduces the parsed inventory from the file's own bytes;KubernetesAuditLogArtifactReaderis its only consumer, publishing it asformatMetadata(). No ownership was duplicated.inspect_artifactreports thekubernetes-audit-logroot format. The per-callartifact_limits.kubernetes_audit_log.line_bytessetting defaults to 4 MiB and accepts up to 16 MiB. CLI and MCP use the same advertised input schema.kubernetes-audit-logis classedarchivein target formats, asauditd-logandsystemd-journalare.derived, neverinferred.inspect_artifactandextract_artifactadvertised schema summaries reflect the shared line-limit control.Expected effects:
Evidence and regression coverage
hasKubernetesAuditEventdid not exist and no reader claimed the format, so a JSON-lines audit log reached ordinary inventory. The new recognition test fails on the base revision withundefinedinstead of{ state: "recognized", format: "kubernetes-audit-log" }.{"event_count":1,"line_bytes_limit":78,"malformed_line_count":0,"oversized_line_count":1}frominspect-artifactwith a 78-byte allowance. At exactly 408 bytes, it produces{"event_count":2,"line_bytes_limit":408,"malformed_line_count":0,"oversized_line_count":0}.kube-apiserverexport; the fixtures are synthetic and hand-written from the published event schema.For evidence-bearing changes:
Validation performed
On
1e34160b1, 142 focused tests passed, and the CI changed-file typed-lint command reported zero errors.npm run check:fastpassed for the streaming recognition change on6d3ea8333. The three compiled CLI cases cover line allowance recovery, file and directory recognition beyond the original prefix, and an oversized first record whose identity still establishes the format. Validation used synthetic events. An exported cluster log and the full localcheck:prgate remain outside this verification.Compatibility, safety, and release
Author readiness
Human owner: @2SinceJuly
Author checklist (completed by the PR author before requesting review)
type(scope): outcome.REA_runtime setting with a default, floor, and maximum, unless a fixed ceiling has a stated reason.Review follow-up
f2b145c9aaligns recognition with the reader. Empty lines, JSON whitespace, and one leading U+FEFF are padding and do not hide the first audit record. A non-JSON space such as U+00A0 does not. Request fields come from the first stage whoseapiVersionthis reader models.f7c7bab4ctokenizes each admitted line and keeps only the summary fields. Ignored objects and arrays are not built. The tokenizer stops at 64 containers. Identity already read is kept; a deeper body before that identity is one line diagnostic.