Skip to content

feat(artifacts): inventory auditd logs offline - #12062

Merged
morluto merged 35 commits into
morluto:mainfrom
2SinceJuly:feat/11345-auditd-logs
Nov 27, 2026
Merged

morluto merged 35 commits into
morluto:mainfrom
2SinceJuly:feat/11345-auditd-logs

Conversation

@2SinceJuly

Copy link
Copy Markdown
Contributor

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.log today means running ausearch or aureport on the analyst's host. This adds a reader that streams the admitted file and reports:

  • line, record and event totals, and record counts by type across the whole file;
  • the malformed-line count with a bounded sample of the offending lines;
  • duplicate records (a repeated type within one event, keyed on its items= index), out-of-order records, and interleaved events — the file's own line order is preserved and reported, never reordered;
  • a bounded window of the first 32 events with their identity, line span and per-type counts, with the omitted count alongside.

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 a limit failure.
  • src/artifacts/AuditdLogArtifactReader.ts — the reader. A log declares no members, so the inventory attaches to the root occurrence and open() refuses every entry.
  • Format registration: the auditd-log id and descriptor (with its reader limitation), the metadata schema, a recognizer that accepts a file only when its first line is a full type=… msg=audit(...) record, and the subject/target-kind/snapshot enumerations.
  • docs/specs/linux/auditd-log/{spec,plan,tasks}.md and 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.ts owns 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-log is 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, and open() refusal), plus a recognition case in src/domain/artifactFormatRecognition.test.ts and the fixture entry in TargetFormatVocabularies.test.ts.

  • Base reproduction: on main the format is unrecognized, so no inventory exists.

  • Remaining proof gaps: no real audit.log from 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.
  • Not run: the packaged CLI/MCP workflow end to end, and the full check:pr gate.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real OS coverage: no real host log was inspected.
  • Package or release metadata impact: a new artifact format id.
  • Security, privacy, process, or containment review: read-only; no execution, no network.

Author readiness

Human owner: @2SinceJuly

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

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.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-27T16:58:26.161424Z 081a8ee New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · The reviewed changes appear safe to merge; no new actionable issue was found.RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The reviewed changes appear safe to merge; no new actionable issue was found.

Summary

Adds a read-only inventory for captured Linux audit logs.

  • Captured auditd logs get a read-only inventory on their root artifact.

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"]
Loading

Reviews (28) · Last reviewed commit: "fix(auditd): decode long candidate prefi..." · Reviewed by Greptile

Comment thread src/domain/linux/auditdLog.ts Resolved
Comment thread src/domain/linux/auditdLog.ts Resolved
Comment thread src/domain/linux/auditdLog.ts Resolved
Comment thread src/domain/linux/auditdLog.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread src/domain/linux/auditdLog.ts Resolved
Comment thread src/domain/linux/auditdLog.ts Resolved
Comment thread src/domain/linux/auditdLog.ts Resolved
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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread src/domain/linux/auditdLog.ts Resolved
Comment thread src/domain/linux/auditdLog.ts Resolved
Comment thread src/domain/linux/auditdLog.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread src/domain/linux/auditdLog.ts Resolved
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.
Comment thread src/domain/linux/auditdLog.ts Resolved
Comment thread src/artifacts/artifactFormats.ts Resolved
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).
Comment thread src/domain/linux/auditdLog.ts Resolved
main added uefi and this branch added auditd-log to the same union.
Keep both so the reader-format list stays complete.
Comment thread src/domain/linux/auditdLog.ts Resolved
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.
Comment thread docs/specs/linux/auditd-log/plan.md Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread docs/specs/linux/auditd-log/plan.md Resolved
@N0zoM1z0

Copy link
Copy Markdown
Collaborator

Thanks for the work on this. I reviewed head 459053a30 on current main. These blockers are confirmed in the source and still unresolved in the review threads:

  1. Events from different hosts merge. AUDIT_LINE captures node=, but the join key is occurrenceKey(seconds, millis, serial). In a centralized (log_format=ENRICHED/remote) log, two hosts that emit the same timestamp and serial become one event, with false duplicates and interleaving. The node, or its explicit absence, needs to be part of the event identity.
  2. Retained event state is unbounded. #events keeps one PendingEvent per event, with its typeCounts and seenRecords, for the whole file. Only the 32-event sample is reported, yet a 4 GiB admission can retain millions of entries. Duplicate and interleaving detection needs a bounded window, with the reported coverage stating what that window can establish.
  3. Event IDs lose milliseconds zeros. eventId prints String(event.millis), so msg=audit(1700000000.005:12) is reported as 1700000000.5:12, which reads as 500 ms. Preserve the source spelling, or pad to three digits as the ordering key already does.
  4. Planning documents in Git. docs/specs/linux/auditd-log/{plan,spec,tasks}.md conflict with AGENTS.md ("Keep specs, implementation plans, task lists … in issue or pull request discussions or in local drafts outside Git"). Please move them into [Feature] Import Linux auditd logs as structured, offline security-event Evidence #11345 or the PR description.

Several other open threads (split EXECVE records counted as duplicates, late cancellation returning success, EOF byte accounting after an overflowing line) also need an answer or a fix. I'll re-review once these are addressed.

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.
@2SinceJuly

Copy link
Copy Markdown
Contributor Author

Addressed all four blockers in 053151eaf. Details per point:

  1. Per-host event identity. The join key now includes the node= prefix, and the summary carries node (null when unqualified). A centralized log's node=hostA and node=hostB records with the same timestamp/serial are now separate events. Ordering stays temporal (timestamp then serial); node only splits events.
  2. Bounded retained state. Per-record identity is retained for a window of 4096 events (AUDITD_RETAINED_EVENT_LIMIT). Events and records past it are still counted in event_count and record_count, and a limitation states how many were not joined and that their duplicate/interleaving status is not established. Duplicate detection is now per record content (a SHA-256 per record, held per event), so retained state is one short key per record across the window rather than every raw body.
  3. Millis spelling. event_id pads millis to three digits, so audit(1700000000.005:12) reads 1700000000.005:12. The numeric join key is unchanged, so an unpadded record still joins its padded peers.
  4. Planning docs. Removed docs/specs/linux/auditd-log/{plan,spec,tasks}.md from the branch.

Also in the same commit, for the threads you flagged to answer or fix:

  • Split EXECVE continuations: duplicate detection is per record content now, so a long argument list across several EXECVE records with no item= is counted as continuations, not duplicates. A byte-identical repeat is still a duplicate.
  • Late cancellation: entries() now re-checks the signal after onCoverage via yieldArtifactRead, so an abort during the final await reports cancelled.
  • EOF byte accounting: bytes dropped after a line overflows the ceiling now feed trailing_bytes.

Validation run locally: AuditdLogArtifactReader.test.ts and artifactFormatRecognition.test.ts pass (33 tests), typecheck/lint pass, architecture-guards pass. I could not run the full suite because this worktree's node_modules is incomplete; I did not run npm run check:pr.

Comment thread src/domain/linux/auditdLog.ts Resolved
Comment thread src/domain/linux/auditdLog.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread src/domain/linux/auditdLog.ts Resolved
Comment thread src/domain/linux/auditdLog.ts Resolved
oxfmt --check failed on this line after 053151e: the guard exceeds the
80-column print width, so Static checks never reached typecheck or lint.
@2SinceJuly

Copy link
Copy Markdown
Contributor Author

a004bd46b fixes the one hard failure left in Static checks: oxfmt --check flagged src/domain/linux/auditdLog.ts because the retained-window guard exceeded the 80-column print width, which aborted the turbo run before typecheck and lint ever reported. The commit is the formatter's own output — a line wrap, no logic change.

The four blockers from your review are addressed in 053151eaf; the new P1/P2 threads from the 08:34–08:40 review round are the next thing I look at, and they are not in this commit.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

Comment thread src/domain/linux/auditdLog.ts Resolved
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.
@2SinceJuly

Copy link
Copy Markdown
Contributor Author

Merged origin/main (ae3a2a6) and fixed the resulting compile break (d0f0fb2). The merge conflict was only scripts/verify/fixed-ceiling-registry.json: main dropped the Deno standalone entry because that reader now takes artifact_limits controls, so I kept main's deletion and this branch's auditd entry. Main also renamed the region decoder's format kind to malformed (#14265), so the scanner now reports malformed and the reader raises it through malformedArtifact, matching DecodedRegionArtifactReader.

Verified locally on the merged tree: node scripts/verify/fixed-ceilings.mjs and node scripts/verify/architecture-guards.mjs pass, AuditdLogArtifactReader.test.ts passes (23/23), and the touched files typecheck. Two typecheck errors remain in javascriptSemanticExecutionPoints.ts and releaseProposal.test.ts; both reproduce on a clean origin/main worktree, so they are not from this change.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

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.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

Comment thread src/domain/linux/auditdLog.ts Resolved
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.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

Resolve the ArtifactReader format union: keep both the PR's "auditd-log"
entry and main's "pkg" entry added since the branch point.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread src/domain/linux/auditdLog.ts Resolved
Comment thread src/domain/linux/auditdLog.ts Resolved
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.
Comment thread src/domain/linux/auditdLog.ts Resolved
Comment thread src/domain/linux/auditdLog.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread src/domain/linux/auditdLog.ts Resolved
Comment thread src/domain/linux/auditdLog.ts Resolved
…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.
@2SinceJuly

Copy link
Copy Markdown
Contributor Author

Addressed the outstanding review threads in 511fff54f. Each maps to a concrete change:

Ordering (codex auditdLog.ts serial-order, greptile Inflated totals) — ordering was compared against one global maximum, so a centralized log with two hosts reported normal mixed-node acquisitions as out of order. It now tracks the greatest identity per node=, bounded by a new AUDITD_ORDERING_NODE_LIMIT; past that cap the count is documented as a lower bound. Regression: two hosts at the same millisecond with unrelated serials yield out_of_order_record_count: 1 (only the genuine reorder).

Header identity (greptile Different headers become identical) — #acceptLine decoded the line lossily, so two node=/type= values differing only in bytes UTF-8 cannot represent both became host� and joined as one event. decodeHeaderBytes now maps each byte to its own code point, so the mapping is one-to-one and \S still matches. Regression: headers differing only by 0x80 vs 0x81 stay two events; mutation-verified (reverting to toString("utf8") fails it).

Per-event type cap (greptile Missing type counts, codex Keep omitted-type counts in distinct-label units) — the cap counted records, not distinct labels, so two records of one 65th type reported two omitted labels and two affected events for one event. record_types_omitted is now typeCounts overflow plus the size of an omitted-label set, and the affected-event tally counts the event once. Regression asserts 49, not 50; mutation-verified.

Tail bounds (codex Preserve uncertainty after tail identity tracking fills, greptile Inflated totals become minimums) — a re-claimed tail identity could still leave the total advertised as exact or a lower bound. Any repeat now sets only the upper bound, and event_count_lower_bound is always false (documented in the schema). This also removes the old #tailEventStarts < 2 exception both findings called out.

Reader failure reason (greptile Changed files look malformed) — decoder failures are now re-verified against the source before being translated, via #stableFailure matching NtfsMftArtifactReader, so a file that changes mid-read reports the source change rather than "malformed".

Verification: src/artifacts/AuditdLogArtifactReader.test.ts 28/28, check:fast green, architecture guards 3241 files. Three regressions mutation-verified (header decode, per-node ordering, distinct-label count). Not run: full suite, acceptance, boundary projects.

Comment thread src/domain/linux/auditdLog.ts Resolved
Comment thread src/domain/linux/auditdLog.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread src/domain/linux/auditdLog.ts Resolved
Comment thread src/domain/linux/auditdLog.ts Resolved
… 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.
Comment thread src/domain/linux/auditdLog.ts Resolved
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.
@2SinceJuly

Copy link
Copy Markdown
Contributor Author

Pushed 081a8eebf, which fixes the Source tests failure on 3cb1f8957.

Root cause. hasAuditdLogRecord now reads the first line through decodeHeaderBytes, and that decoded the whole candidate prefix in one String.fromCodePoint(...codePoints). Format recognition hands every candidate the entire leading buffer, so a large text member spread a few hundred thousand arguments and threw RangeError: Maximum call stack size exceeded. The error escaped as a provider failure rather than a refused auditd claim, which is what 9 of the ReleaseExposureReader member-allowance cases were reporting — all of them failed at auditdLog.ts:227 in decodeHeaderBytes.

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.

  • ReleaseExposureReader.test.ts 313 passed / 17 skipped (was 9 failed).
  • artifactFormatRecognition.test.ts 31 passed, including a new regression that recognizes 4 MiB prefixes (all-0xFF and header-plus-4 MiB body) without throwing; reverting the chunking fails that test.
  • AuditdLogArtifactReader.test.ts 30/30.
  • npm run check:fast green, architecture guards 3241 files.

Not run: the full suite and the boundary/acceptance projects locally; CI covers those.

@morluto
morluto merged commit 395a6df into morluto:main Nov 27, 2026
57 checks passed
@morluto

morluto commented Nov 27, 2026

Copy link
Copy Markdown
Owner

Maintainer review: defects fixed and brittleness pass

Pushed 3cb1f89 on top of your branch. Nothing of yours was rewritten.

Defects fixed (all four review threads):

  • Unbounded per-event state: omittedTypeLabels grew with the file once the per-event type cap was full. It is now bounded by AUDITD_RETAINED_OMITTED_TYPE_LIMIT; past it the event reports record_types_omitted_exact: false and a limitation names the count as a lower bound.
  • Source text changed: the byte-faithful header mapping was used both as the identity key and as the reported text, so UTF-8 such as hôte or échec came back as different characters. Keys stay byte-faithful, and reported text goes through one projection (sourceText, built on the shared decodeUtf8PreservingBomOrNull): valid UTF-8 as written, otherwise lossy text plus node_hex, type_hex or excerpt_hex. event_id percent-encodes node bytes, so it stays injective.

Brittleness found and fixed:

  • Recognition and inspection decoded the first line differently: toString("utf8") versus the byte-faithful mapping. Both now use the same decoding.
  • Per-event type tally and limitation assembly were inline in long methods: extracted into #tallyEventType and #limitations, so each bound is decided in one place.
  • A local fatal TextDecoder was flagged by the architecture guard: replaced with the shared strictUtf8 helper.

Deliberately left:

  • 4 GiB file ceiling: AUDITD_LOG_MAX_FILE_BYTES stays. It is already registered as pending in fixed-ceiling-registry.json under [Feature] Import Linux auditd logs as structured, offline security-event Evidence #11345, and the scanner's retained state is now bounded regardless.
  • Accepted header forms: only the type= first, msg=audit(...) form auditd writes is accepted, with an optional node= prefix. Other producers' spellings are malformed lines, not guesses.

Sources (format cross-checked):

  • DeepWiki, linux-audit/audit-userspace: src/auditd-event.c (format_raw and format_enrich) writes node=<name> before type=; ENRICHED appends interpreted fields after 0x1d (AUDIT_INTERP_SEPARATOR), which the opaque body accepts; MAX_AUDIT_MESSAGE_LENGTH is 8970, which the 64 KiB line ceiling is derived from; auparse and ausearch group records by timestamp, serial and node, matching this PR's join key.
  • The same source shows milliseconds written zero-padded to three digits, but it does not guarantee every kernel message is spelled that way. Accepting 1–3 digits and keeping the original spelling for the key is the conservative reading.

Validation: npm run test:local on the auditd reader, recognition, graph construction and vocabulary tests (183 passed); npm run check:fast; oxfmt --check.

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

Labels

area: evidence Evidence, artifacts, and reconstruction enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Import Linux auditd logs as structured, offline security-event Evidence

3 participants