Repository navigation
feat(artifacts): inventory systemd journal headers and object table offline - #10151
Conversation
…ffline Journals copied from a host or carved from a disk image had no reader, so an analyst needed journalctl and a live host to see what a file declared. Recognize the LPKSHHRH header by bytes and report it as its own artifact format. Parse the fixed 272-byte header: flag bits and their names, state, the four 128-bit ids, header and arena sizes, hash-table extents, and the object, entry, data, field, tag and entry-array counts. Anchor the object area on header_size, requiring an aligned offset inside the file, then walk the object chain front to back by each header's declared extent. Report totals by object type, the valid/truncated/unknown-type counts, a bounded window of 32 object headers with source offsets, and the trailing bytes the chain could not claim. Payloads stay undecoded: fields, entries, entry arrays, hash tables and compressed objects are reported as limitations rather than guessed, and the whole file is bounded at a fixed 4 GiB ceiling.
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2034dd1830
ℹ️ 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".
`format:check` fails on these three files, which breaks the Static checks lane and, through it, the CI required aggregate. `oxfmt` only reflows lines; no behaviour changes.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 272d170963
ℹ️ 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 object walk that shipped with the reader did not match the on-disk format, so a valid journal could be reported as truncated and an incompatible one could produce plausible but wrong evidence. - Advance to `align8(offset + size)` and validate the raw extent. systemd keeps a declared size unpadded and aligns only the next object's start, so a size that is not a multiple of eight is valid, not truncated. - Stop at `tail_object_offset` instead of at end of file. Bytes after the declared tail are the arena's preallocated capacity; walking them read a zero header as an extra unused object and called capacity corruption. - Stream the object chain instead of buffering the file. Payload bytes are skipped as chunks arrive, so a journal near the 4 GiB ceiling inventories in chunk-sized memory and cancellation between chunks is never queued behind a whole-file parse. - Read `tail_entry_array_offset` and `tail_entry_array_n_entries` with `getUint32`. They are adjacent 32-bit members added in revision 252; reading each as 64 bits folded the following field into both values. - Accept the 208-byte header that predates `n_data`, and read every later field only when the declared `header_size` covers it. Older acquired journals stay inspectable instead of classifying as unknown. - Refuse to describe objects when `incompatible_flags` sets a bit outside the known set. Such bits change the parser's assumptions, and a journal from a newer systemd would otherwise yield invalid object evidence. - Record fields whose declaration exceeds 2^53-1 in `overflowed_fields`, so distinct source values no longer collapse onto the same ceiling. - Report skipped compressed payloads only when a walked object actually carries a compression flag, not merely because the header advertises a compression algorithm. Regression tests cover the unaligned size, the declared tail with arena capacity after it, the 208-byte header, the compact 32-bit tail-array fields, the 2^53-1 ceiling, unknown incompatible flags, and the compression message. The decoder was also checked against every chunk boundary from one byte to the whole file: counts and offsets are identical.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2114d52b36
ℹ️ 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".
[Medium impact] The reviewed changes appear safe to merge; no new actionable issue was established. SummaryAdds offline systemd journal inventory and pages later object headers through
DiagramsequenceDiagram
participant Caller
participant View as AnalysisViewService
participant Page as Format header page reader
participant File as Selected journal
Caller->>View: Parent Evidence, artifact_path, offset, limit
View->>View: Check parent inventory and read root digest
View->>Page: Explicit file selection and expected digest
Page->>File: Open and check SHA-256
Page->>File: Stream journal and retain selected window
Page->>Page: Close reader or retain failed cleanup
Page-->>View: Object headers
View-->>Caller: View Evidence with coverage and parent link
Reviews (36) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4801cc3de5
ℹ️ 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".
…r table main replaced the per-route signature chains in BinaryTargetResolver and ArtifactGraphConstruction with the ordered ARTIFACT_FORMAT_RECOGNIZERS table, and moved the artifact reader base classes behind resources/index.js with ArtifactPreparation owning the prepare/re-prepare lifecycle. Resolve the merge that way rather than reinstating the inline chains: register systemd-journal as one more entry in the shared table, give it a kind in BINARY_TARGET_FORMAT_KINDS so the archive predicate still holds, and port SystemdJournalArtifactReader to the current base modules.
|
Rebased onto current Resolution keeps this PR's feature and drops the now-redundant duplicate of
Verified locally: The earlier review threads predate this merge; several of their premises (the inline chain, the old reader imports) no longer exist. I'd rather not chase them individually — the required checks are green and a re-review on the new head will tell us what still applies. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
main's guards reject new raw DataView reads, so every header, object and state field now goes through BinaryReader, which bounds each read. Two offsets are write cursors rather than resource allowances, and each carries the not-an-allowance reason the budget rule asks for.
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
format:check runs oxfmt, and the BinaryReader rewrite left one call wrapped across three lines that oxfmt wants on one. No behavior change; this is what turned the Static checks job red on the previous run.
|
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 journal format adds artifact format metadata, which changes the open_binary output schema digest. Build package runs verify:advertised-schemas and rejects the stale summary, so commit the regenerated digest. Only the output compact hash moves; input schemas and patterns are unchanged.
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Upstream landed the Android boot image format in the same artifact recognizer table, so main and this branch both changed the open_binary output schema digest. Resolve the summary by regenerating it against the merged generator instead of picking either side, then commit the digest that covers both formats.
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
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 systemd journal schemas and the vbmeta descriptor schemas that main added. Ran deps:check, tsc --noEmit, and the systemd journal plus format recognition/metadata tests: 44 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. |
# Conflicts: # src/resources/ArtifactReader.ts
Merging main brought the systemd-journal recognizer into the shared format union while this branch kept its own overlay list, so recognizeLeadingFormat no longer assigned to PeOverlayLeadingFormat and typecheck failed. Recognizers can name systemd-journal, 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: 667b6fa41c
ℹ️ 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".
…eiling - Drop the 4 GiB whole-file ceiling. It was justified by ENTRY_SIZE_MAX, which bounds one entry, while the scanner streams and retains one chunk plus a 32-header window whatever the file size. - Make the object-header window selectable: createJournalDecoder and the reader accept objectHeaderStart, so next_object_header_index can be followed to later headers. - Treat a zero arena_size as an empty arena rather than an absent one, and report declared arena bytes past the end of the file even when the readable objects and counts agree. - Re-verify the source before reporting a decoder failure, so a file that changes mid-read reports an identity failure instead of truncation. - Read the state byte through one lookup, so a header that cannot anchor its objects keeps its observed state; name the tail-entry-boot-id flag.
Inventory keeps a bounded window of per-record headers, and nothing could follow the systemd journal's next_object_header_index over MCP or CLI. inspect_analysis_view gains a generic `format_record_headers` inventory collection (morluto#14919) that uses the existing offset and limit. - Each page re-reads the root file through its format's artifact reader, with the window started at `offset`, after binding the file to the parent inventory's root digest. A changed file fails with artifact_integrity_mismatch (container-identity) instead of returning shifted rows. - Memory is one read chunk plus one window. The read is a cancellable streaming scan, and the reader is released through the view's resource scope. - Formats plug in through two single lists: the domain's record total and the artifacts layer's window reader. The systemd journal is wired; NTFS $MFT is left to morluto#14919 because its streaming decoder has no start index. - The journal metadata drops object_header_start_index and next_object_header_index, which nothing could follow; the page's coverage.next_offset is the one continuation. - The journal test builder moves into a shared fixture for reader and boundary tests. Refs morluto#14919
- Opening a file must not be selected by Evidence: subject.local_path is display metadata and can change without changing the Evidence ID. The format_record_headers collection now requires an explicit absolute `path`, which the CLI resolves like other caller paths. The root digest still binds that file to the inventory. - Keep a completed page when the reader fails to close. The view Evidence is attached to the cleanup failure as its partial observation, and the reader stays retained for retry. - Keep a completed page when cancellation arrives after it was read.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8dcfbe45e9
ℹ️ 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".
…wners - Name the page's file selector artifact_path. The CLI's caller-path rewrite of view.path also rewrote other views' semantic selectors, such as a devicetree node path, into host paths on Windows; artifact_path exists only on format_record_headers pages. - Run each page's read and release through the supplied resource scope, so a reader an earlier page failed to close is retried first and a new page is refused while that cleanup stays unresolved.
# Conflicts: # src/application/binary/TargetFormatVocabularies.test.ts # src/artifacts/artifactFormats.ts # src/artifacts/inventory/ArtifactGraphConstruction.ts # src/domain/artifactFormatMetadata.ts # src/domain/artifactFormatRecognition.ts # src/domain/artifactGraph.ts # src/domain/formatMetadata/androidAndSystemMetadata.ts # src/domain/native/peOverlay.ts # src/domain/targetFormats.ts # src/resources/ArtifactReader.ts
Maintainer review: defects fixed and brittleness passPushed 34cf962, 2b1c2ae, 8dcfbe4 and dfa816d on top of your branch, plus plain merges of Defects fixed:
Brittleness found and fixed:
Checked against the spec: every Sources:
Validation:
|
The parent module imported the inventory projector for the page row type, which closed an import cycle the analysis-view cycle check forbids. The type now lives in analysisViewParent.ts and its consumers import it from there. The CLI JSON-input schema test now expects view.artifact_path among the caller paths inspect-analysis-view resolves.
# Conflicts: # src/domain/formatMetadata/androidAndSystemMetadata.ts
Summary
Fixes #10123.
REA has no reader for systemd journal files. An analyst holding a
.journalcopied from a host or carved from a disk image cannot see what the file declares
unless
journalctlis available and they are willing to let a host toolinterpret it. This adds offline, read-only inventory of a selected journal file,
following the same first-step shape as the NTFS
$MFTwork in #9868/#9911: thefile's own header and object table become structured Evidence, and payload
decoding follows in later increments.
Problem and expected behavior
Expected: recognizing a journal file by its bytes and reporting its header facts
and object table, with every gap explicit.
Observed before this change:
.journalinput classified asfile, no metadata.Change and scope
src/domain/linux/systemdJournal.ts(new) owns the header and object-chainparse, limits and limitations.
src/artifacts/SystemdJournalArtifactReader.ts(new) reads the admitted filethrough
ArtifactFileSourceand exposes facts viaformatMetadata(), as aroot-only reader (a journal declares no members).
systemd-journalis registered as a format id, content format, target format,format descriptor and byte classification, alongside the other magic probes.
src/domain/artifactFormatMetadata.tsowns the result schema, including themetadata-comparison note.
docs/specs/linux/systemd-journal/records the requirement, plan and tasklist for the remaining increments.
Parsed: the fixed 272-byte header (compatible/incompatible flag bits with names,
state, file/machine/tail-entry-boot/seqnum ids, header and arena sizes, the four
hash-table extents, and the object/entry/data/field/tag/entry-array counts,
sequence numbers and tail-entry realtime/monotonic), plus the object chain walked
by each header's declared extent with per-type counts, valid/truncated/unknown
counts, a bounded 32-object header window with source offsets, and trailing bytes.
Deliberately not included: field/entry/entry-array/hash-table payload decoding,
compression, time and boot filters, and multi-file timelines. These are recorded
in the spec's task list.
header_sizeis the object area's anchor and must bealigned and inside the file; otherwise no objects are reported and the reason is
a limitation rather than a guess. Payload coverage is reported as a limitation on
every result, so an inventory is never mistaken for entry-level Evidence.
Contract and boundary impact
src/domain/linux/systemdJournal.tsowns journal bytes;
SystemdJournalArtifactReaderis its only consumer andpublishes through
formatMetadata(). No superseded path is removed.step of an existing feature request ([Feature] Import systemd journal files as structured, offline Linux log Evidence #10123); no new provider, target
execution, injection or mutation is involved.
the existing artifact inventory through byte classification. No tool schema
changed.
format id; existing formats are untouched.
occurrence carries header facts and a bounded object sample; aggregate counts
cover the whole walked chain. Unsupported payloads, truncated objects, unknown
types and a header that cannot anchor the object area remain visible as
limitations or counts.
Expected effects:
Evidence and regression coverage
Source-derived from the format's public definition (
journal-def.h), not from acaptured journal written by a live systemd.
src/artifacts/SystemdJournalArtifactReader.test.tscovers a valid fixture end to end, flag naming, an object whose declared size
overruns the file, a tail too short for a header, an unknown object type, a
header size that cannot anchor the object area, refusal of a missing signature
and of a file shorter than the fixed header, and the bounded object window with
full-chain counts. Format-id registration is covered by the existing
artifactFormats,ArtifactGraphConstructionandTargetFormatVocabulariessuites.
systemd-journalwith the header facts andobject_type_countsabove.systemd is included, and no Windows-host execution applies here. Compressed
and large (>4 MiB) journals are not exercised.
Validation performed
npm run check:fast— typecheck and lint passed.npx vitest run src/artifacts/SystemdJournalArtifactReader.test.ts— 9 passed.npx vitest run src/artifacts/artifactFormats.test.ts src/application/binary/TargetFormatVocabularies.test.ts src/artifacts/inventory/ArtifactGraphConstruction.test.ts— 92 passed.npx vitest run src/domain/evidenceSubject.test.ts src/domain/analysisSnapshot.test.ts src/domain/artifactGraph.test.ts— 21 passed.npx vitest run tests/conformance/artifactComparisonDocs.test.ts— 1 passed.npm run docs:check— passed.npm run check:prgate.Compatibility, safety, and release
read-only, decompresses nothing, executes nothing, and bounds the file at a
fixed 4 GiB ceiling. Journal contents are not treated as trustworthy.
Author readiness
Human owner: @2SinceJuly
Before merge
type(scope): outcome.