Repository navigation
feat(artifacts): inventory auditd logs offline - #12062
Conversation
An acquired Linux audit.log can only be read today with ausearch or aureport, which means letting a host tool interpret the file. Add a read-only inventory that joins records on the full audit event identity: timestamp seconds, milliseconds and serial, never the serial alone, because auditd reuses serials across boots and on wraparound. The first increment reports line, record and event totals, per-type counts, the malformed line count with a bounded sample, and the duplicate, out-of-order and interleaved records it found, with a bounded window of events whose totals still cover the whole file. Record bodies are not decoded yet: key-value fields, hex and escaped values, argument ordering and decoded syscall or permission meanings are named as limitations, and the reader treats the log as neither complete nor authentic. An auditd log declares no members, so the inventory is attached to the root occurrence and open() refuses every entry. Verified: npm run check:fast (typecheck, lint, architecture guards) and npm run docs:check pass; 89 tests across the new reader test, format descriptors, target-format vocabularies, recognition, graph, snapshot and subject suites pass. No built or packaged CLI/MCP workflow was run.
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 reviewed changes appear safe to merge; no new actionable issue was found. SummaryAdds a read-only inventory for captured Linux audit logs.
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart LR
A["Admitted audit.log"] --> B["Read chunks"]
B --> C["Split bounded lines"]
C --> D["Join records by node, timestamp and serial"]
D --> E["Root metadata and limitations"]
Reviews (28) · Last reviewed commit: "fix(auditd): decode long candidate prefi..." · Reviewed by Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 28262817d4
ℹ️ 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".
format:check failed on src/domain/linux/auditdLog.ts and its reader test in CI; applying oxfmt is the whole change.
Repeated types were joined on items=, which is the path count on a SYSCALL record, not a per-record index. Every PATH record of a multi-path event therefore shared one key: the second path was reported as a duplicate and the per-event PATH count came out as one. Use item= instead, and cover a two-path event.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 994b941ce3
ℹ️ 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: 5044981eb7
ℹ️ 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".
Resolve the test-file conflict by keeping both sides: the auditd\nrecognition case added on this branch and the FIT recognition cases that\nlanded on main.
Upstream moved the target-format catalogue into targetFormats.ts, so the hand-written format lists this branch extended now conflict. Keep upstream's derived forms (BINARY_TARGET_FORMATS, targetFormatsOfKind) in the four touched schemas and register "auditd-log" in the one canonical catalogue instead of maintaining a second list. Verified: the resulting format set matches the pre-merge branch exactly (checked programmatically), `node scripts/run-typescript.mjs --noEmit` passes, and vitest on src/domain plus src/artifacts passes (1795 tests, 17 skipped).
main added uefi and this branch added auditd-log to the same union. Keep both so the reader-format list stays complete.
main dropped src/artifacts/artifactFormats.test.ts in c7353f4 ("remove descriptor registry mirror checks") with the zipFamily capability row it mirrored, and stopped tracking docs/specs in a1dec2d. Take both decisions as-is: auditd-log stays registered in artifactFormats.ts, the format recognition union and the metadata table.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 459053a30d
ℹ️ 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".
|
Thanks for the work on this. I reviewed head
Several other open threads (split |
Address the review on morluto#12062: - Include the node= prefix in the event join key. Timestamp plus serial is only unique within one host, so a centralized log merged records from different hosts into one event. The reported event_id carries the node. - Bound retained event state to a window. Duplicate and interleaving detection kept every PendingEvent for the whole file; records past the window are counted in the totals and a limitation says their status is not established. - Pad the reported event timestamp millis to three digits so audit(1700000000.005:12) no longer reads as 500 ms, while still joining a padded record to an unpadded peer (via the numeric key). - Detect duplicates per record content instead of record type plus item=, so split EXECVE continuations are counted, not called duplicates. - Re-check cancellation after the coverage callback resolves, so an abort during the final await reports cancelled rather than success. - Account for bytes dropped after a line overflows, so EOF trailing_bytes covers the whole tail. - Drop docs/specs/linux/auditd-log/, which conflicts with AGENTS.md.
|
Addressed all four blockers in
Also in the same commit, for the threads you flagged to answer or fix:
Validation run locally: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 053151eaf2
ℹ️ 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".
oxfmt --check failed on this line after 053151e: the guard exceeds the 80-column print width, so Static checks never reached typecheck or lint.
|
The four blockers from your review are addressed in |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Bring the branch up to date with main. The only conflict was the fixed-ceiling registry: main dropped the Deno standalone entry because that reader now takes artifact_limits controls, so keep main's deletion and the branch's auditd entry. `node scripts/verify/fixed-ceilings.mjs` passes on the merged tree.
…in merge Main renamed the region decoder's format kind to malformed (morluto#14265), so the auditd branch's `kind: "format"` no longer compiles. Keep the same behaviour through main's naming: the domain scanner reports `malformed`, and the reader turns it into `malformedArtifact` instead of building a bare `format` failure, matching DecodedRegionArtifactReader.
|
Merged Verified locally on the merged tree: |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Resolve the registry, format-metadata and recognition-test additions from the Android sparse-image inventory landing on main: keep both the auditd and sparse-image entries.
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Resolve the adjacent-additions conflict in androidAndSystemMetadata.ts by keeping both the auditd-log schema and the vbmeta descriptor schemas. Typecheck passes apart from two pre-existing dependency-pin errors (javascriptSemanticExecutionPoints.ts, releaseProposal.test.ts) that also reproduce on origin/main. Ran artifactFormatMetadata, artifactFormatRecognition, ArtifactGraphConstruction and AuditdLogArtifactReader tests: 108 passed.
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Resolve the ArtifactReader format union: keep both the PR's "auditd-log" entry and main's "pkg" entry added since the branch point.
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
The auditd-log recognizer was registered on main while this branch added PE_OVERLAY_LEADING_FORMATS entries, so recognizeLeadingFormat's return type no longer assigned to PeOverlayLeadingFormat and typecheck failed. Recognizers can name auditd-log, so the overlay leading-format list has to include it.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 36d968c4bf
ℹ️ 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".
Two retained tables grew with the file rather than with the fixed budgets: the whole-file per-type totals kept every distinct type= label a crafted log named, and a single event kept one per distinct label it met. Both are now capped, and records under a label past a cap are still counted in record_count/line_count while the omitted labels are reported: the file total names its omission in a limitation, and a sampled event carries record_types_omitted next to record_types. The tail event bound also now distinguishes an upper bound (a repeat while other tail identities were held) from a lower bound (the single tail identity repeated) and from no bound at all (an identity could not be held), so event_count no longer claims a direction it cannot support.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9ec3b0d3f4
ℹ️ 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".
…ithful Four review findings against the auditd inventory: - Ordering compared every record against one global maximum, so a centralized log with two hosts reported normal mixed-node acquisitions as out of order. Track the greatest identity per node, bounded like the type table. - Header bytes were decoded lossily, so two node/type values differing only in bytes UTF-8 cannot represent collapsed to the same U+FFFD and joined as one event. Decode each byte to its own code point so identity is preserved. - The per-event type cap counted records rather than distinct labels, so two records of one 65th type reported two omitted labels and two affected events for a single event. Count distinct labels in a set. - A tail run that reclaimed a retained identity still reported the total as an exact count or a lower bound. Any repeat inflates the total, so only the upper bound holds; event_count_lower_bound is now always false. - The reader blamed the bytes before re-verifying the source, so a file that changed mid-read reported as malformed. Re-verify before translating.
|
Addressed the outstanding review threads in Ordering (codex Header identity (greptile Per-event type cap (greptile Tail bounds (codex Reader failure reason (greptile Verification: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 511fff54fd
ℹ️ 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".
… written The per-event set of labels named past the type cap grew with the file, so a crafted log could retain millions of strings after the event and digest caps were full. It is now bounded by AUDITD_RETAINED_OMITTED_TYPE_LIMIT; past it the event reports record_types_omitted_exact: false and a limitation says the count is a lower bound. The byte-faithful header mapping kept identities apart but was also returned as text, so a UTF-8 node, type or malformed-line excerpt such as hôte or échec was reported as different characters. Lookup keys stay byte-faithful; reported text is decoded as UTF-8, with a *_hex field carrying the raw bytes only when they are not valid UTF-8. event_id percent-encodes the node bytes so distinct raw nodes still never share an identity. Recognition now reads the first line through the same decoding as the scanner.
Format recognition hands every candidate the whole leading buffer, and the byte-faithful header mapping spread its code points into one String.fromCodePoint call. A prefix of a few hundred kilobytes therefore overflowed the call stack, so a large text member surfaced as an adapter failure instead of a refused auditd claim. Nine ReleaseExposureReader members with oversized text hit this. Decode in fixed-size chunks so the argument list stays bounded; the mapping is unchanged, and 4 MiB of prefix now answers instead of throwing.
|
Pushed Root cause. Fix. Decode in fixed 4096-byte chunks so the argument list stays bounded. The mapping itself is unchanged: ASCII maps to U+0000..U+007F, other bytes into the private block above U+00FF, one-to-one. An 8 MiB buffer decodes and round-trips byte-for-byte. Validation.
Not run: the full suite and the boundary/acceptance projects locally; CI covers those. |
Maintainer review: defects fixed and brittleness passPushed 3cb1f89 on top of your branch. Nothing of yours was rewritten. Defects fixed (all four review threads):
Brittleness found and fixed:
Deliberately left:
Sources (format cross-checked):
Validation: |
Fixes #11345
Summary
Adds an offline, read-only inventory for acquired Linux audit subsystem logs (
audit.log). Records are joined on the whole audit event identity — timestamp seconds, milliseconds and serial — rather than the serial alone, because auditd reuses serials across boots and on wraparound.This is step 1 of the issue. It establishes the record/event inventory; body decoding, filtering and cross-file timelines stay on
docs/specs/linux/auditd-log/plan.md.Problem and expected behavior
Reading an acquired
audit.logtoday means runningausearchoraureporton the analyst's host. This adds a reader that streams the admitted file and reports:items=index), out-of-order records, and interleaved events — the file's own line order is preserved and reported, never reordered;Change and scope
src/domain/linux/auditdLog.ts— streaming line scanner and the event join. Lines are bounded at a fixed 64 KiB, the file at 4 GiB reported as alimitfailure.src/artifacts/AuditdLogArtifactReader.ts— the reader. A log declares no members, so the inventory attaches to the root occurrence andopen()refuses every entry.auditd-logid and descriptor (with its reader limitation), the metadata schema, a recognizer that accepts a file only when its first line is a fulltype=… msg=audit(...)record, and the subject/target-kind/snapshot enumerations.docs/specs/linux/auditd-log/{spec,plan,tasks}.mdand the specs index.Not included, per the issue's step boundaries: key-value body decoding, hex/escaped value handling, argument ordering, syscall and permission decoding, filters, rotated-file timelines. Record bodies, decoded meanings, completeness and authenticity are named as limitations in the reader.
Contribution scope: this reads supplied captured files only. It does not execute, attach to a process, contact a service, or recover protected code; maintainer scope decision not applicable.
Contract and boundary impact
Semantic owner and earliest changed stage:
src/domain/linux/auditdLog.tsowns the parsed record/event facts; the reader consumes them and the format metadata schema is the persisted projection. No superseded path.Contribution scope fit and linked maintainer decision: step 1 of [Feature] Import Linux auditd logs as structured, offline security-event Evidence #11345; no scope decision needed.
CLI and MCP/tool-catalog contract: a new artifact format id
auditd-logis advertised alongside the other artifact formats.Provider, bridge, target-format, or platform compatibility: none — no provider or platform gate.
Evidence, artifact, provenance, or reconstruction contract: the inventory is the artifact's own root occurrence, as for the other self-describing log formats.
Target selection, authority, upstream behavior, and cleanup details: none.
Generated metadata: none edited; ignored catalogs regenerate in CI.
Read existing files or captured data.
Evidence and regression coverage
Tests added:
src/artifacts/AuditdLogArtifactReader.test.ts(10 cases: event join on timestamp+serial, same-timestamp different-serial and same-serial different-time stay separate, duplicate type counting, interleaved/out-of-order reporting, malformed-line diagnostics not dropping valid events,node=prefix, trailing bytes, the 32-event window against whole-file totals, refusal of a non-auditd file, andopen()refusal), plus a recognition case insrc/domain/artifactFormatRecognition.test.tsand the fixture entry inTargetFormatVocabularies.test.ts.Base reproduction: on
mainthe format is unrecognized, so no inventory exists.Remaining proof gaps: no real
audit.logfrom a live host was used; fixtures are hand-written records with the documented header shape.Observed, derived, and inferred claims remain distinguishable.
Artifact identity, source provenance, and failed attempts remain preserved.
Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.
Validation performed
npm run check:fast— typecheck, lint and architecture guards pass (2874 source files).npm run docs:check— passes, including the built documentation and README consistency test.npm run test:local -- src/artifacts/AuditdLogArtifactReader.test.ts src/artifacts/artifactFormats.test.ts src/application/binary/TargetFormatVocabularies.test.ts src/domain/artifactFormatRecognition.test.ts src/domain/artifactGraph.test.ts src/domain/analysisSnapshot.test.ts src/domain/evidenceSubject.test.ts— 89 tests pass across 7 files.check:prgate.Compatibility, safety, and release
Author readiness
Human owner: @2SinceJuly
Before merge
type(scope): outcome.