Commit Graph
6626 Commits
Author SHA1 Message Date
gensokyo-devandgensokyo-dev bcb38e2ae5 test(javascript): use the file MCP session in factory completion tests
Each test opened its own default MCP server; they now use the file's shared session.

Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
2026-11-29 04:08:09 +08:00
gensokyo-devandgensokyo-dev c26fe5b6ff test(javascript): share one MCP session in GraphQL contract tests
Four tests opened an MCP server each with the same catalog; one lazy file session now serves them.

Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
2026-11-29 04:08:09 +08:00
gensokyo-devandgensokyo-dev c227b8e4de test(javascript): share sessions in builtin default tests
Each test ran the CLI as a fresh process and opened its own MCP server. They now use the file's shared CLI worker with complete Evidence, which the inherited test budget used to select, and one lazy MCP session that keeps the ping.

Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
2026-11-29 04:08:09 +08:00
gensokyo-devandgensokyo-dev 4f486d5262 test(web): use the file MCP session in HAR boundary fact tests
The tests opened a default MCP server each; they now use the file's shared session.

Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
2026-11-29 04:08:01 +08:00
gensokyo-devandgensokyo-dev 32ed734250 test(applications): share one MCP session in Playwright trace tests
Six tests opened an MCP server each with three slightly different catalogs. One file session with the application and session families serves all of them; no browser is installed or launched.

Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
2026-11-29 04:08:01 +08:00
gensokyo-devandgensokyo-dev dfd32bf380 test(browser): share sessions in historical HAR capture tests
Each test ran the CLI as a fresh process and opened its own MCP server. They now use the file's shared CLI worker and MCP session, with the complete Evidence the inherited test budget used to select.

Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
2026-11-29 04:08:01 +08:00
gensokyo-devandgensokyo-dev 660b135f41 test(cli): accept any account configuration behind an empty test HOME
With HOME and USERPROFILE empty, the child reads the account's real home,
whose saved configuration the test does not control. The case now checks
only that the file's home was not used.

Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
2026-11-29 03:32:25 +08:00
gensokyo-devandgensokyo-dev df5caa7778 test(cli): pin which home CLI test children read
A shared and a fresh CLI process read saved settings from the file's home.
A caller's USERPROFILE-only or empty HOME selection is kept instead. The
selection rule is checked for each home variable.

Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
2026-11-29 03:32:25 +08:00
gensokyo-devandgensokyo-dev e5f6643d2f test(applications): share sessions in keyed archive scalar tests
The tests set a per-test HOME only for isolation and opened an MCP server per
test. They now use the file's home and shared MCP session. Each test still
opens its own archive before the implicit-target call.

Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
2026-11-29 03:32:25 +08:00
gensokyo-devandgensokyo-dev 05aef29425 test(applications): share sessions in mobile directory component tests
Each test set its own HOME only to avoid the account's home, which restarted
the shared CLI worker and opened a new MCP server per test. They now use the
file's home and shared MCP session; the per-family fresh process check stays.

Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
2026-11-29 03:32:25 +08:00
gensokyo-devandgensokyo-dev 6e5b6f1ede test: give CLI and MCP test children an owned home
A test child given no home resolved the account's real home and read its
saved REA configuration. cliTest's shared worker, its fresh processes, its
file MCP session and direct connectLocalToolsMcp() connections all did so.

cliTest now owns one home per file, and a direct MCP connection owns one per
connection, removed only after its server closes. A caller that selects
HOME, USERPROFILE, HOMEDRIVE or HOMEPATH, even as an empty value, keeps its
whole selection.

Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
2026-11-29 03:32:25 +08:00
Oke Iyanuoluwa EnochandYsopwnable 21cfc809bc ci(windows): run the caller path separator regression in the Windows lane (#4988)
test(ci): keep the separator regression in the Windows-only lane guard

Fold windowsTargetSeparators.test.ts into the existing guard for
Windows-only cases instead of a separate test with the same reason.

Co-authored-by: Ysopwnable <161784452+N0zoM1z0@users.noreply.github.com>
2026-11-28 23:49:35 +08:00
ShuaixinHuangandShuaixinHuang 3fad5920b9 fix(firmware): summarize RISC-V vectors by decoded jumps (#15014)
Co-authored-by: ShuaixinHuang <197200901+ShuaixinHuang@users.noreply.github.com>
2026-11-28 10:37:14 -05:00
gensokyo-devandgensokyo-dev b6163bfbc0 fix(ghidra): name contract operations and fields in selector and type-edit recovery
Ghidra selector misses, type-edit refusals and the Mach-O LC_MAIN entry
hint wrote CLI and MCP spellings into one remediation, such as 'CLI: rea
search <path> . --kind procedures ...' or 'For CLI decompile, use
--procedure ...', so each adapter showed the other's commands. The
errors already carried their related operations.

The recovery now names only contract operations and the procedure field.
The entry hint also reports procedure as a related parameter, so the CLI
renders it as --procedure through related_cli_flags, as it does for the
related operations.

Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
2026-11-28 23:33:05 +08:00
gensokyo-devandgensokyo-dev 2dcdacce92 fix(ci): accept a skipped selection the macOS lane runs
A selection whose every module is gated to macOS, such as a change to only
tests/acceptance/applications/nativePlistNesting.test.ts, can only report
skipped modules on Linux, and the portable report then failed with 'Every
portable test module was skipped' although the macOS lane ran the tests.

The report now accepts an entirely skipped selection when the plan selected
the macOS lane and every reported module is gated to macOS by the same
isDarwinGatedTestSource rule that the macOS lane uses to discover its
tests. The summary says so. Any other entirely skipped selection, and an
entirely skipped complete suite, still fail.

Fixes #14596

Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
2026-11-28 23:31:40 +08:00
gensokyo-devandgensokyo-dev 48cef4662f fix(ci): select the macOS lane when every selected test may be gated to it
The plan selected the macOS lane only for a changed test that may be gated
to macOS. A source change whose affected tests are all such modules left
Linux to skip every one of them while no lane ran them.

Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
2026-11-28 23:31:40 +08:00
RRFZ 2c07552b64 fix(limits): report details.limit for KernelModuleProvider refusals (#14306)
* fix(limits): report details.limit for ELF dependency, unwind, and kernel reader refusals

Attach structured `details.limit` metadata to per-call budget refusals across
the remaining `src/native/elf/` providers (`ElfDependenciesProvider`,
`KernelModuleProvider`, `KernelBuildConfigProvider`, and
`ElfUnwindRangesProvider`), following the `#14243` shared-budget pattern:

- Generalize `elfReadBudgetLimit` in `src/domain/native/elfReadBudgets.ts` so
  ELF and kernel readers share one parameter-limit builder.
- Export `ELF_DEPENDENCIES_READ_BUDGETS`, `KERNEL_MODULE_READ_BUDGETS`,
  `KERNEL_BUILD_CONFIG_READ_BUDGETS`, and `ELF_UNWIND_RANGES_READ_BUDGETS` from
  their domain schemas so Zod input bounds and projected `details.limit`
  metadata have a single owner.
- Report `details.limit` for caller-selected file, entry, inflation, and record
  budgets, including `compressed_candidate_bytes` (`max_config_bytes`), while
  moving `KernelBuildConfigProvider` file-size handling onto
  `offlineArtifactFailureDialect.fileSize` and removing its unreachable
  `capacity` branch.
- Report `ElfUnwindRangesProvider`'s fixed 16 MiB `symbol_name_text_bytes`
  allowance through `fixedAllowanceOptions` with narrowing guidance and
  `related: { parameters: ["limit", "offset"] }`, registered in
  `scripts/verify/fixed-ceiling-registry.json` under `#14235`, rather than
  reporting an inverted `details.limit`.
- Remove `ElfDependenciesProvider.ts`, `ElfUnwindRangesProvider.ts`, and
  `KernelBuildConfigProvider.ts` from
  `scripts/verify/untyped-budget-refusal-baseline.json`, clearing all
  `src/native/elf/` entries from the baseline, and update
  `docs/reference/rea-limit-inventory.md` and
  `docs/reference/limits-and-recovery.md`.

Part of #14234

* test(elf): assert CLI details.limit and flags for kernel module budgets

* fix(elf): report required_value for KernelModuleProvider max_file_bytes and add MCP recovery test
2026-11-28 22:58:31 +08:00
RRFZ f9e9e8e4c0 fix(windows-shortcut): keep target_extension unknown when declared LinkInfo or RELATIVE_PATH is unread (#13946) 2026-11-28 22:16:39 +08:00
rodricksz4h5andCursor Agent 8e057e08d6 fix(labview): read section names past the declared block-info extent (#14970)
* fix(labview): read section names past the declared block-info extent

* fix(labview): count the block-info extent from the info header

A +48 word that ends before the section-start tables is a truncated
list. The fixture writes that word from the info header through those
tables, and section names still run to the end of the info section.

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2026-11-28 08:47:03 -05:00
0c7ebd68c4 ci(mutation): run four Stryker workers on the sweep's 4-vCPU runner (#15001)
Stryker divides concurrency between TypeScript checkers and test runners,
so the configurations' concurrency of 2 ran one checker and one test
runner. The reverse-tools sweep reached 884 of 1034 mutants before its
90-minute budget and has not completed since 2026-11-14. On four pinned
cores, a reverse-tools subset (167 mutants) took 1642 s at 2 and 801 s at
4, with identical outcomes. The workflow now passes --concurrency 4; the
configurations keep 2 for shared local machines.

Co-authored-by: gensokyo-dev <gensokyo-dev@users.noreply.github.com>
Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
2026-11-28 18:58:43 +08:00
gensokyo-devandgensokyo-dev c22c1ab179 ci: build the runtime in the deep static job explicitly
The deep job got dist/ only because its Knip task depended on compile.
Its Python producer suite imports the runtime, so with Knip moved to the
build job a fresh full-tier runner would fail test:python. Name compile in
check:ci:deep:tasks.

Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
2026-11-28 18:47:05 +08:00
gensokyo-devandgensokyo-dev b5460632c9 ci: run Knip in the build job on every code change
Knip ran only in the full-tier deep static job, so pull requests merged
with unused exports and the next scheduled run failed; 3 of the last 12
scheduled CI runs on main failed only on Knip. It needs the built workers
that package imports name, so it now runs in the build job after
test:prepare, where it adds the Knip run itself (about 20 s cold) to a
job every code change already runs. Its cache steps move with it and the
deep job no longer repeats it.

Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
2026-11-28 18:47:05 +08:00
gensokyo-devandgensokyo-dev 72d6d275d4 test(ghidra): compare native value graphs by cited procedure across adapters
The real-Ghidra verifier required identical CLI and MCP dependency
graphs, including upstream Evidence IDs. An MCP session states session
limitations once and the CLI records the caller input path, so the same
analysis has different record IDs in each adapter. Each adapter now checks
that every cited ID is a linked procedure record of its trace, and the
graphs are compared with those IDs replaced by the procedures they record.

Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
2026-11-28 16:46:31 +08:00
3c60922615 fix(cli): list --columns among the global options in help (#14981)
The flag selects row fields for csv and tsv output and was already named
in command descriptions, but help omitted it. It is listed only where the
entry accepts a delimited format.

Co-authored-by: gensokyo-dev <gensokyo-dev@users.noreply.github.com>
Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
2026-11-28 15:31:40 +08:00
gensokyo-devandgensokyo-dev c5cbb212d7 fix(cli): report argv parse failures as PARSE_ERROR
Unknown flags, missing flag values and surplus positional arguments
reported the catch-all UNKNOWN code, while a misspelled flag already
reported PARSE_ERROR. Every argv parse failure now reports PARSE_ERROR
with retryable false; UNKNOWN stays reserved for unexpected failures.

Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
2026-11-28 15:30:06 +08:00
ShuaixinHuangandShuaixinHuang 8ff3570430 fix(deb): preserve byte-counted PAX values (#14958)
Co-authored-by: ShuaixinHuang <197200901+ShuaixinHuang@users.noreply.github.com>
2026-11-28 00:26:06 -05:00
ShuaixinHuangandShuaixinHuang a04fcd85ab fix(tar): compare stored symlink targets (#14964)
* fix(tar): compare stored symlink targets

* fix(tar): retain observed empty symlink targets

---------

Co-authored-by: ShuaixinHuang <197200901+ShuaixinHuang@users.noreply.github.com>
2026-11-27 23:23:10 -05:00
CyberSproutandmorluto a91d9fa2b5 feat(firmware): decode ARM M-profile and RISC-V mtvec interrupt vector tables (#14421)
* feat(firmware): decode ARM M-profile and RISC-V mtvec interrupt vector tables

* fix(firmware): name vector-table exceptions per ARM variant and report unbound SVD interrupts

The architecture field now takes the ARM M-profile variant names REA uses
for raw images (armv6-m through armv8.1-m.main) plus riscv. ARMv8-M
Baseline gets ARMv6-M's exceptions; only Mainline names MemManage,
BusFault, UsageFault, SecureFault and DebugMonitor. The old armv8-m value
named Mainline faults on Cortex-M23 tables.

vtor_aligned checks the 128-byte ARMv7-M/ARMv8-M minimum and is null on
ARMv6-M, whose VTOR is optional and implementation-defined. Slots past the
end of the 32-bit address space are no longer decoded with wrapped
addresses, and an initial stack pointer that is not word-aligned is
flagged.

CMSIS-SVD interrupts without a name or with a non-integer value are
reported as anomalies instead of skipped silently, and the expanded-name
budget is charged once while parsing instead of twice with two formulas.
likely_default_stub is removed: every shared-handler group set it to true.
RISC-V limitations now cover vectored exceptions on slot 0, CLIC address
tables and the mcause numbering assumed for SVD bindings.

* fix(firmware): bound SVD anomaly diagnostics, RISC-V pair addresses, and shared budget recovery

* fix(firmware): index SVD duplicates per peripheral and admit one-slot RISC-V tables

Duplicate interrupt declarations were found by rebuilding a key that
repeats the full peripheral name for every <interrupt>, so a long name
repeated across many declarations cost name length times declaration
count. Bound names are now indexed per peripheral name, looked up once
per <peripheral>.

The 8-byte minimum held for every architecture, but only an ARM table
must start with InitialSP and Reset; a RISC-V Direct-mode table can be
one instruction. max_entries and max_file_bytes now admit one slot.

* refactor(firmware): hoist the SVD IRQ value patterns to module scope

* fix(firmware): record RISC-V pair byte extent and attribute caller input errors

* style(firmware): format the vector-table provider

* fix(firmware): add summary delivery and analysis views for vector tables

* test(firmware): check vector-table recoveries and budgets through their owners

Recovery assertions compare the delivered action with the shared refusal
formatter applied to the reported limit, instead of pinning sentences.
The summary-delivery test set REA_AGENT_RESULT_MAX_BYTES, which nothing
reads, and used a result large enough to exceed the default budget too;
it now sets REA_AGENT_RESULT_BUDGET_BYTES, asserts the reported budget,
and uses a result between the minimum and default budgets, checking that
the default delivers it complete.

The view counts active ARM entries and recognized RISC-V slots with a loop
instead of filtered copies.

* perf(firmware): count active vector slots once in the report producer

The analysis view recounted active ARM entries and recognized RISC-V slots
on every summary and page request. The producer already collects exactly
those slots as handler targets, so the report now stores
active_arm_entry_count and recognized_riscv_slot_count from them, and the
view reads the stored fields. The service checks the stored counts against
the slots once when it validates the provider's report.

---------

Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
2026-11-27 20:07:08 -05:00
88373e3fba feat(apple): inspect Image4 (IMG4, IM4P, IM4M) firmware containers offline (#14907)
* feat(apple): inspect Image4 (IMG4, IM4P, IM4M) firmware containers offline

Image4 files are recognized from a DER SEQUENCE whose first element is
the IA5String IMG4, IM4P, or IM4M, independent of the filename, and are
inventoried as apple-img4. The stored payload octet string is exposed as
payload, the embedded IM4M sequence as manifest.der, and the IM4R
sequence as restore-info.der. Keybags contribute a count and key types,
with initialization vectors and keys left out of metadata; an encrypted
payload is refused on open; signatures and certificates are reported by
size; LZFSE and complzss payloads stay compressed; IM4R property names
are listed and their values stay redacted. Four fixed allowances refuse
excessive DER depth, element count, property count, and string length,
and inventory coverage is unknown whenever a limitation is recorded.

* fix(apple): read Image4 fields by universal tag and position

Compare universal tag numbers instead of identifier octets, so constructed
OCTET STRING and string values are recognized and reported. Read IM4P fields
by position so an unsupported payload keeps its slot and a constructed keybag
still marks the payload encrypted. Walk every constructed value once, caching
the children of header-walked values so each element is charged once, and
check large values a consumer does not decode. Report unknown restore members,
extra property and object fields and a mistyped certificate chain. Decode
UTF8String as UTF-8, accept DER sign padding on unsigned 32-bit integers, and
recognize the magic with the shared BER header decoder.

* fix(apple): read IM4P and IMG4 slots by position and keep unknown counts null

Follow img4tool and img4lib: after the payload, an optional keybag OCTET
STRING, then an optional compression SEQUENCE, then PAYP in [0]; IMG4 holds
IM4P, [0] IM4M and [1] IM4R in that order. A value outside its slot is
reported as unknown and never takes another field's role, and an EXPLICIT
wrapper holds exactly one value. An absent or undecodable description is
null rather than empty, and an undecoded keybag reports a null count and
types instead of zero; a decoded keybag counts every entry.

* fix(apple): keep Image4 compression unknown when it cannot be read

An encrypted payload without a compression field, or a declared algorithm
other than LZFSE with no recognizable magic, now reports compression
"unknown" instead of "none". Make ia5Text the single owner of the
retained-text allowance so a string too large to tree-parse is refused
rather than reported absent, keep the canonical BOOLEAN check in the
structural pass only, check the keybag's inner SEQUENCE through the shared
decoder instead of its first octet, note a manifest version other than 0,
and name the spec constants after their sources. Add a hand-encoded IM4P
golden that does not use the fixture builders.

* fix(apple): keep stopped Image4 slots and bound retained bytes

A value whose end cannot be found keeps its identifier, so a stopped keybag
still marks the payload encrypted and a stopped payload keeps its slot; the
values after it become a limitation. The IMG4 payload slot is consumed
whatever it holds, so an unsupported value does not hide the manifest and
restore slots. A property body that is not a SET or SEQUENCE is reported
instead of read as empty, and an entry whose name cannot be read is one
unknown entry whose value is never walked for more names, so restore values
stay redacted. Load a value only when it may be decoded and fits an 8 MiB
retained budget; larger primitives and values past the budget are walked by
header.

* fix(apple): keep restore properties opaque and small fields readable

A PRIVATE-tagged restore value is one property: only its name is reported,
and its value is never searched for names, even when the name is unreadable
or is IM4R. Only the IM4R property SET is walked as a container. Small
primitives are always loaded, so names and scalars stay readable after the
retained budget is used. A declared uncompressed size that is negative or
not an exact integer is reported as a limitation.

* fix(apple): reserve tree budget only for parsed values and keep PRIVATE manifest entries opaque

Reserve retained bytes only for a value that will be tree-parsed, so a
ranged wrapper around a large payload no longer uses budget a later small
indefinite value needs. A PRIVATE manifest entry must name itself; when its
name cannot be read it is reported and its value is never interpreted as
manifest facts.

* fix(apple): report MANB, MANP and IM4R entries with no body

A MANB, MANP or IM4R entry that holds only its name is a missing body, not a
confirmed-empty one, so it is reported as a limitation while sibling facts
are kept.

* fix(apple): require a SEQUENCE for named manifest entries

A context-, application- or other-tagged manifest value that begins with a
name is unsupported structure, reported as an unknown tag rather than read
as a manifest entry.

* fix(apple): assign IMG4 values to slots by position and context tag

One slot assigner owns the IMG4 layout: a context-tagged value fills the
slot with its tag number, skipping earlier optional slots, and any other
value occupies the next slot even when it cannot fill it. An unsupported
manifest value therefore no longer hides a following [1] IM4R.

---------

Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: morluto <morluto@users.noreply.github.com>
2026-11-28 01:01:22 +00:00
morluto 13f618e8e3 fix(native): report non-native bytes as unrecognized, not malformed (#14936)
* fix(native): report non-native bytes as unrecognized, not malformed

A file that is not the format a reader owns was reported as a broken file
of that format. `inspect_native_initializers` called a PE file or random
bytes a malformed target, and the thin Mach-O reader called any bytes
without Mach-O magic a malformed Mach-O.

Format owners can now say "these bytes are not my format": parse failures
and format target failures gain the `unrecognized` kind that target
failures already define ("no reader for this operation recognizes the
bytes"). The owners report it once:

- the thin Mach-O reader, for bytes without Mach-O magic;
- the shared native container reader, for bytes that are not ELF, PE or
  Mach-O (previously `unsupported`);
- the initializers provider, for a file with neither ELF nor Mach-O magic.

Function starts no longer pre-checks the header itself; the shared reader
owns that decision. IL2CPP keeps mapping unknown native bytes to its
unsupported-container reason. A recognized header that is cut off or
broken stays truncated or malformed.

* fix(resources): keep every format failure kind's facts through artifact wrappers

`ArtifactReaderFailure` kept the owner's facts only for its own list of
three format kinds, and `artifactOperationReason` had a second list. With
`unrecognized` added, `artifactFormatFailure` and `artifactParseFailure`
dropped its facts, so `translateArtifactFailure` raised an internal
invariant error instead of the target failure.

The format kinds are now one list, `FORMAT_TARGET_FAILURE_KINDS`, and
`isFormatTargetFailureKind` is the one guard. `FormatTargetFailure`,
`ParseFailureKind` and `BinaryFormatFailure` derive from that list, and
the reader-failure constructor and the operation-reason check both use the
guard, so a new kind cannot be carried by one wrapper and dropped by another.

* test(conformance): expect unrecognized for foreign bytes on native readers

The Go, Rust and native-initializers readers now report bytes that are not
ELF, PE or Mach-O as unrecognized, so their foreign-bytes conformance cases
expect that kind. The case names follow the kind.
2026-11-27 23:03:26 +00:00
ShuaixinHuangandShuaixinHuang f43cacb61b fix(dotnet): reuse validated bundle entries across enumerations (#14885)
fix(dotnet): retain validated bundle entries across enumerations

Co-authored-by: ShuaixinHuang <197200901+ShuaixinHuang@users.noreply.github.com>
2026-11-28 06:32:50 +08:00
zhuweiyeandmorluto f25312a8bc feat(labview): inspect RSRC containers and embedded VI trees (#13337)
* feat(labview): inspect RSRC containers and embedded VI trees

Add inspect_labview_artifact, a static reader for LabVIEW RSRC containers in
.vi/.ctl/.llb files and in LabVIEW-built PE resources. It reports the container
header, the recorded LabVIEW version, the complete block inventory with each
section's coding, and whether the block-diagram and front-panel heaps are
present, without starting LabVIEW or any process.

Only zlib-coded sections are decoded, for their byte count; no payload is
returned. An absent block-diagram heap is reported as a limitation rather than
reconstructed.

* docs(labview): document RSRC inspection

Describe the inspect_labview_artifact contract, section codings, and the
block-diagram limitation, and list the target in the supported-targets table
and the documentation index.

* test(labview): cover provider admission for the RSRC reader

Add the provider-admission coverage the repository requires for a new
provider, without changing the reader:

- Move the synthetic RSRC container builder into a shared test fixture so
  the unit and boundary tests build the same bytes once.
- Add a CLI and stdio MCP boundary test for inspect_labview_artifact.
- Register `rea-labview-rsrc` lifecycle coverage for operation and cancel.
- Declare the `labviewArtifact` conformance case.
- Regenerate the advertised catalog summary for inspect_labview_artifact.

* fix(labview): require an absolute path in the inspection contract

`inspect_labview_artifact` admitted a relative `path`, while every other
caller-path contract requires an absolute one. The CLI/contract parity
check caught it: the CLI resolves a relative argument before admission,
so the contract must hold the absolute rule alone.

Use `absoluteLocalPathStringSchema`, the schema the other caller-path
contracts already use.

* fix(labview): bound inspection work and preserve parse facts

Address the review findings on the RSRC reader:

- Bound the PE resource walk with a visited set, a total visit budget,
  directory-entry and container allowances, and a typed limit failure
  instead of a silently partial scan.
- Check the resource directory and its data against the declared resource
  range rather than the whole file.
- Cap zlib inflation at its declared length, add a total decoded-work
  budget, and recognise any valid zlib header instead of three byte pairs.
- Check nested RSRC records against their declared data/info sections and
  cap the total section count across blocks.
- Read the artifact through readStableArtifact so identity, bounds and
  cancellation bind to the bytes actually inspected.
- Carry parse failures as ParseFailureError facts: malformed input keeps
  its kind/offset/field, and a limit becomes a typed fixed-allowance
  refusal instead of invalid_format.
- Report heap presence as `unknown` when an embedded program tree or an
  unexamined container could still hold it, not as `absent`.
- Cover cancellation that arrives after the read starts.
- Move the analyst guide under docs/guides/native/.

* fix(labview): retry retained cleanup and keep read failures distinct

- Own the artifact resource scope and run each read through it, so a
  retained failed close is retried before later work and reported at
  shutdown.
- Translate the read failure as recorded instead of replacing it with the
  signal's current state; the stable read owns its cancellation facts.
- State the 256 MiB input ceiling as a fixed allowance so an oversized
  artifact keeps its structured maximum and recovery.
- Match the guide to the decoded-byte behavior: a section over the budget
  is reported `unknown` and the inventory continues.

* fix(labview): bound the version scan and keep cleanup on refusal

- Replace the unbounded `\d+\.\d+` scan with a bounded single-pass search
  over the first 64 KiB of each vers section; a digit-only section no
  longer drives quadratic matching work in the shared server.
- Classify read failures through the shared provider classifier with a
  LabVIEW dialect, so the size ceiling is restated as a fixed allowance
  and the read's cleanup, partial observation and cancellation facts
  survive the refusal.
- Cover both with regressions.

* fix(labview): reuse the shared PE layout and bound the decode work

- Walk PE resources through readPeResourceLayout, so RVA lookup is indexed,
  a payload may map through any admitted section, and the home-grown
  section scan is gone. Add a total entry budget.
- Charge every attempted inflation against the container's decode budget,
  including failed and length-mismatched attempts.
- Bound block records by the list's declared extent, clamped to the
  container because real LabVIEW-built PEs declare more than the resource
  payload holds.
- Reject a named section whose name leaves the list instead of reporting
  it as unnamed.
- Pass the selected container to the parser without copying it.
- Cover the PE path and the over-declared list extent with regressions.

* fix(labview): bound repeated decodes and report unexamined coverage

- Charge compressed input bytes as well as declared output, and memoize
  the decoding of one stored section, so records that share a stream do
  not repeat its work.
- Keep a zlib-coded `vers` section's decoded bytes for the version scan.
- Cap list records by both the declared extent and the info section.
- Report PE walk coverage, and keep heap presence `unknown` for a `.llb`
  archive or an unreadable PE resource branch.

* fix(labview): key cached decoding by block and section

A section's coding depends on both its stored bytes and the block that
declares it: LVzp is XOR regardless of the bytes, while another block may
read the same bytes as raw or zlib. Include the block identifier in the
memo key so a shared section keeps each block's interpretation.

Cover the shared-section case with a regression.

* fix(labview): derive block facts once and stop inferring format from names

- Compute the block-diagram, front-panel and program-tree facts in one
  pass over the inventory and reuse them.
- Check the visited set before charging the PE directory-visit budget, so
  aliases of one directory do not exhaust it.
- Deduplicate aliased resource payload ranges before counting containers.
- Report a direct RSRC container's heap facts as unknown: its content does
  not establish whether it is a VI, a control, or an archive of member VIs,
  and the caller's spelling is not evidence of format.

* fix(labview): decode the packed version record and keep resource type

- Read the LabVIEW version from the packed four-byte word at the start of
  a `vers` record instead of scanning the whole record as Latin-1, and
  report `version_coverage` so an undecodable record is unknown rather
  than absent.
- Accept only RT_RCDATA (type 10) PE resource payloads, so the
  `pe-rcdata-rsrc` kind is accurate and a larger custom resource cannot
  win selection.

* fix(labview): walk only the RCDATA subtree and validate packed digits

- Walk only the RCDATA (type 10) resource subtree, so a shared directory
  reached under another type cannot hide the container and unrelated
  branches are not charged to the entry budget.
- Reject a packed version word whose digit nibbles are not decimal; a
  damaged record is skipped and a damaged-only container reports
  `version_coverage: unknown`.
- Derive the heap and program-tree facts in the parser and consume them in
  the provider, so one owner defines their meaning.

* fix(labview): filter root resource entries before dispatch

- Apply the RCDATA root-type filter before either target branch, so a root
  entry that points straight at a payload cannot enter the result.
- Validate only the decimal major, minor and bugfix fields; the build
  field is not part of the reported version.

* fix(labview): filter PE root types before dispatch and validate only reported version digits

The RT_RCDATA filter ran only for directory targets, so a noncanonical root
entry of another type pointing straight at a data entry could be counted
and labelled pe-rcdata-rsrc. Filter the depth-0 type identity before
either target branch, and share the RT_RCDATA constant with the PE
resource facts owner.

The vers check rejected a record whose build bits held a nibble above 9.
Only major.minor is reported, and pylabview (decimal build digits) and the
classic NumVersion layout (binary non-release revision) disagree on the
build, so only the reported major and minor nibbles are validated.

* fix(labview): resolve names against the shared list and keep read identity

- Locate the one section-name list after every block's start table and use
  it for all blocks, so named sections before the last block keep their
  identity instead of reading a neighbouring table.
- Retain the completed read's byte identity on later refusals and failed
  closes, so a parse failure still names the bytes that were read.

* fix(labview): report why recognized zlib sections stay undecoded

A valid RFC 1950 header with FDICT set was classified as uncompressed, so
a vers section's four-byte length prefix was read as version 0.0. FDICT
now marks the section as recognized-but-undecodable zlib.

Each undecoded zlib section records its reason (preset dictionary,
compressed-input or decoded-output allowance, or failed inflation), and the
report names the fixed allowance that stopped it, so a capacity omission is
distinguishable from damaged bytes.

A PE whose RCDATA branch could not be read is no longer described as
carrying no embedded RSRC resource. The RSRC magic and zlib header fields
are named once and shared.

* fix(labview): keep PE admission separate from an unreadable tree

A file that does not declare `MZ` is not a PE, so it must not be reported
as a malformed PE resource tree. The scan reports whether the file was
admitted as a PE separately from whether the walk was complete.

* fix(labview): take PE identity from the MZ owner and bound section tables

A two-byte MZ check treated plain DOS MZ and NE/LE/LX images as declared
PEs, so an ordinary non-LabVIEW file was reported as an unreadable PE
resource tree. PE identity now comes from observeMzWindowsHeader: only a
PE signature at e_lfanew declares a PE. The unused admitted field is
removed.

A section-start offset inside the count word or block-header rows was
accepted and could fabricate an inventory from block metadata. Tables must
start at or after the end of every block header; blocks may still share a
later table.

The refusal tests now assert the error type unconditionally.

* fix(labview): report embedded parse failures in file coordinates

A malformed RSRC embedded in a PE failed with container-relative offsets,
but the refusal names the selected executable and carries no
container.file_offset, so callers could not locate the failure. The
parser now takes the container origin and moves a failure offset into the
selected file's coordinates; successful results keep container-relative
ranges with container.file_offset.

* fix(labview): frame RSRC tables before applying their count allowances

A damaged container declaring an impossible block or section count was
refused as a capacity limit before its table extent was checked, so a
truncated target surfaced as resource_constraint. Each table is now framed
first; a fully framed table over its allowance is still a capacity
refusal.

* fix(labview): keep unread PE resource roots and rows out of observed absence

A nonzero resource RVA whose file-backed run cannot hold one directory
header returned complete coverage without reading anything, so the file
was reported as carrying no embedded RSRC. Only a zero RVA is observed
absence now; a short declared root is an unread tree.

Directory rows were checked against the entry allowances before their
extent, so a damaged directory declaring impossible counts surfaced as
resource_constraint. Rows are framed first; a fully framed directory over
its allowance is still a capacity refusal.

* fix(labview): reject RSRC data sections that overlap the fixed header

A data offset inside the 32-byte RSRC header let a section's stored-length
word be read from header fields, returning a fabricated empty section as a
successful inventory. A data offset below the header is now malformed.

* fix(labview): check decode-omission guidance structurally and own the RSRC magic once

The allowance test froze the delivered sentence. It now checks the parser's
decodeOmissions fact and the effective allowance, and compares the public
limitation with the provider's own formatter output.

The RSRC magic was declared again in artifact recognition; it now has one
owner in the LabVIEW domain contract, used by recognition, the parser, the
PE scan and the provider.

* feat(labview): summarize and page the RSRC inventory from retained Evidence

inspect_labview_artifact returned every block and section inline, so an
admitted container with 4096 named sections could exceed a megabyte and
bypass the agent result budget. The tool now takes detail: complete keeps
the inline inventory; summary, or omitted detail over the budget, returns
container, version and heap facts with block and section counts, and the
complete inventory is paged with inspect_analysis_view kind
labview-artifact (blocks, sections, optional block filter) or read with
evidence-json. The CLI delivers the same way.

RSRC data and info ranges that intersect are refused as malformed rather
than reading list metadata as section data.

* test(labview): read the CLI report as the complete inventory

The advertised output now admits complete or summary detail, so the test
parses the complete report schema explicitly.

* perf(labview): build view rows only for the requested page

Each view call copied every section before reading the request, so a
summary or one-row page did work proportional to the whole inventory. A
section index (block and section position, and positions per block) is
built once per immutable retained report and reused; summaries read
counts from it, and section pages build objects only for selected rows.

---------

Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
2026-11-27 22:26:04 +00:00
ba1ddffd7e feat(artifacts): inspect Sega Mega Drive and Genesis ROM headers offline (#14895)
* feat(artifacts): inspect Sega Mega Drive and Genesis ROM headers offline

These ROMs are inventoried as containers. A plain image matches when the
four bytes at offset 0x100 are SEGA; an SMD dump matches the copier mark
0xAA 0xBB and a block count whose de-interleaved bytes carry SEGA, then
the odd and even halves are merged into the linear image. The root
record stores the 68000 vectors, header strings, declared and computed
word checksum, ROM and RAM ranges, devices, external RAM, and region,
with members vectors.bin, header.bin, and program.bin (SMD members carry
an image offset and a null file range). A checksum or range disagreement
leaves coverage unknown, 32X and Sega CD remain labels only, and a file
past 8 MiB or 512 SMD blocks is refused under the named fixed ceilings
before its body is buffered; the shared region reader maps that refusal
onto the typed allowance, and the guide, CLI, supported-targets table,
CI scopes, and ceiling registry include the format.

* Address review feedback

* Address review feedback

* Address review feedback

* fix(artifacts): read Mega Drive work RAM on the 24-bit bus and keep ambiguous regions

A header that declares work RAM as 0xE0FF0000-0xE0FFFFFF, the SGDK
default, was reported outside the work-RAM window because the check
compared full 32-bit values. The 68000 drives 24 address lines, so the
window check now compares bus addresses; metadata keeps the declared
values.

A region field of a lone A, B or E is both a classic region letter and
a one-digit mask, and references disagree on which it is. It was
reported as letters with no limitation. It is now region_style
ambiguous, keeps both readings in region_characters and region_mask,
and records a limitation.

* refactor(artifacts): name Mega Drive header fields once and share the SMD half layout

Header field offsets and lengths were literals repeated at each read, and
device support was sliced twice from separate literals. One TEXT_FIELDS
table, the named numeric offsets and the EXTERNAL_RAM block now hold the
layout, citing SGDK's rom_head.c and Genesis Plus GX's getrominfo and
sram_init.

SMD recognition and de-interleaving each encoded which block half holds
the odd bytes. Both now use SMD_ODD_HALF and SMD_EVEN_HALF, and the
decoder takes the block count from the de-interleaved image instead of
recomputing it from the file size.

The SMD round-trip test only checked the fixture against its own inverse.
It now also pins the fixture's file bytes to the Genesis Plus GX
deinterleave_block layout.

* fix(artifacts): model the Mega Drive 68000 bus once and decide SMD dumps before ESP images

Header addresses were compared in three places with two rules: the RAM
check masked to 24 bits while the reset-PC check compared raw 32-bit
values, and neither knew the work-RAM mirror. One owner now holds the
MC68000 24-bit bus (the top byte is not driven) and the Mega Drive work
RAM, 64 KiB mirrored through 0xE00000-0xFFFFFF (Genesis Plus GX gen_init
maps pages 0xE0-0xFF to it). The reset PC is checked against the ROM
range on that bus, so 0xFF000200 fetches from 0x200, and a RAM range is
work RAM when it covers at most 64 KiB inside the mirror, such as
0xE00000-0xE0FFFF. Metadata keeps the declared values.

An SMD dump of 233 or 489 blocks has 0xE9, the ESP image magic, in its
copier header's block-count byte, so the ESP image recognizer claimed
it. The shared recognizer table now decides the SMD layout, whose
signature also needs the AA BB mark, interleaved SEGA bytes and an exact
size, before the ESP recognizers, and the plain layout keeps its place
after the leading-magic formats.

* fix(docs): restore separate Mega Drive and N64 entries after the main merge

* fix(mega-drive): read ROM range and checksum window on the 24-bit bus

The reset PC check already masked the top address byte, but ROM ordering,
extent, the nonzero-start note and the checksum window still used the raw
declared endpoints. A 0x400-byte image declaring 0xFF000000-0xFF0002FF
summed through 0x3FF instead of 0x2FF, and a full 0xFF000000-0xFF0003FF
alias was marked incomplete. Derive bus addresses once in the parser and
keep the declared values in metadata.

* fix(artifacts): order every Mega Drive header range on the 24-bit bus

The ROM range was ordered on the 68000 bus, but the RAM range and the
external RAM range still compared raw 32-bit endpoints. A header whose
endpoints alias through different top bytes, such as RAM
0xE0FF0000-0x00FFFFFF, was reported as reversed even though the bus
range is the 0xFF0000-0xFFFFFF work RAM.

The bus owner now has one ordering rule, busOrdered, and the ROM, RAM
and external RAM checks all use it. Declared values stay in metadata. A
range whose end wraps past the 24-bit bus, such as 0xFF0000-0x1000000,
is now reported as reversed, which is what the bus sees.

* fix(artifacts): keep truncated region failures typed and publish Mega Drive bus addresses

A region decoder could only report malformed, limit or unsupported, and
the shared DecodedRegionArtifactReader mapped every kind but malformed to
a fixed-limit refusal. A recognized Mega Drive header cut short was
therefore reported as malformed, and an unsupported region failure would
have surfaced as a limit. RegionDecodeFailure now has truncated, with
the measured extent, and the reader maps each kind to its own typed
failure: malformed, truncated, unsupported or limit.

The header checks already interpret ROM, RAM and reset addresses on the
68000's 24-bit bus, but metadata exposed only the stored longwords, so
the raw m68k hand-off told callers to load at the stored ROM start. A
header that stores 0xFF000000 then loads at the wrong address. ROM and
RAM ranges now carry bus_start and bus_end, the reset vector carries
reset_pc_bus, and the guide and skill hand off with rom.bus_start.

---------

Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
2026-11-27 22:25:43 +00:00
morluto 72c0f5caf2 fix(yara): refuse rule files with include directives before yara starts (#14937)
* fix(yara): refuse rule files with include directives before yara starts

yara opens an included file while it lexes, outside the hashed snapshot, so
the rules it adds were not bound to the scan's Evidence. A selected rule file
with an `include` directive is now refused with a typed input error naming
each directive's line, byte column and path, and the recovery to pass the
included file as another rule_paths entry or inline its rules.

Detection follows libyara 4.x's flex lexer (lexer.l at v4.5.0): the
`include[ \t]+"` rule fires at any token start in the initial state,
including inside a rule body, and never inside comments, text strings or
regular expressions. One streaming scanner sees the staged bytes unchanged.

The relative-include rewriter, the `include` compile-error kind and its
repair advice, and the stub's include support are removed, since no include
reaches yara.

* test(yara): check the include scanner against libyara's own answers

Twenty-four rule sources cover the scanner's lexer assumptions: directives
in rule bodies and after punctuation or number tokens, and include inside
comments, strings, regexes, hex strings and longer tokens. Each case records
the include paths libyara 4.5.4 asked to open through yara-python's
include_callback, so the expected values come from yara, not the scanner. A
real-yara test compares the same cases with the installed yara's missing
include error where one is installed.
2026-11-27 22:15:58 +00:00
Beqaandmorluto d74703ff50 feat(artifacts): report declared Ogg Opus, RIFF/XMA2, Bink 2 and Vulkan pipeline-cache headers (#14700)
* feat(artifacts): report declared Ogg Opus, RIFF/XMA2, Bink 2 and Vulkan pipeline-cache headers

Recognize the four remaining #14155 media/cache containers by their public
header signatures and inventory them as archives. Root format metadata
carries the declared header facts; each named byte region is a member that
is hashed and extractable. Payloads stay opaque: no audio, video or
pipeline-cache body decode.

Disagreeing extents stay in extent_check with unknown coverage rather than
a refusal. Structural header faults refuse as malformed input with format
and offset.

Completes the remaining formats from #14155 after #14248.

* fix(artifacts): bound media-asset header walks and document formats

Stop RIFF inventory from buffering opaque chunks, keep chunk walks inside
the declared form, follow spanned OpusTags before audio, preserve first-page
truncation, ground the Bink fixture/table split, and document the formats.

* fix(media): keep truncated RIFF chunk facts and register guide sidebar

Record incomplete RIFF/XMA2 chunk headers in metadata, treat cut-off fmt as
truncated rather than missing, and add media-asset-headers to the VitePress
sidebar registry.

* fix(artifacts): report cut-off media headers as truncated

Short RIFF, Bink 2, and Vulkan pipeline-cache headers that end before the
declared header size are truncated inputs, not malformed structure.

* fix(artifacts): read Bink 2 headers at their demuxer offsets and keep Ogg and RIFF facts

* fix(pe): name media asset formats as PE overlay leading formats

* refactor(artifacts): format the Bink revision byte with the shared hex helper

* fix(artifacts): bound Bink frames.bin to the declared file end

Trailing bytes past the header size field are no longer claimed as
frame payload. Tables that do not fit the declared extent stay unlisted.

* fix(artifacts): keep unlisted Bink tables in the extent check

When header tables end past the declared file size, still measure the
frame-offset table against the file so extent_check reports truncated
instead of consistent while the tables remain unlisted.

* fix(artifacts): admit media asset regions with a per-call limit and report incomplete headers

* refactor(artifacts): import the reader limit failure through the resources entry

* fix(artifacts): keep Ogg page records as ranges, not buffer slices

Growing the read buffer with Buffer.concat left each saved page's packet
slice pinning the previous copy, so a long OpusTags continuation retained
O(n²) bytes before region_count refused the walk. Page records now store
packet offsets and read from the final buffer.

* fix(media-asset): read Ogg pages by position and report required region count

* fix(media-asset): keep Bink audio track facts inside the declared end

Refuse to decode track tables past declaredEnd so appended physical
bytes are not reported as audio_tracks.

* fix(artifacts): keep Ogg header reads inside their own packet

---------

Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
2026-11-27 15:47:04 -05:00
2SinceJulyandmorluto 742cdf0428 feat(artifacts): inventory systemd journal headers and object table offline (#10151)
* feat(artifacts): inventory systemd journal headers and object table offline

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.

* style(artifacts): format the systemd journal reader and its fixtures

`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.

* fix(artifacts): read journal objects the way systemd lays them out

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.

* style(artifacts): apply repository formatting

* chore(systemd): merge main and read the journal through BinaryReader

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.

* chore(systemd): apply oxfmt to the journal header helper

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.

* chore(systemd): record the open_binary output schema summary

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.

* fix(contracts): recognize damaged systemd journals by signature

hasSystemdJournalHeader also required a usable header_size, so a journal with
a short or unaligned header never reached SystemdJournalArtifactReader: normal
inventory classified it as a plain file and dropped the header facts and the
object-walk limitation the reader already reports. The malformed-header test
only passed because it constructed the reader directly.

Recognition is now the signature alone. Deciding whether header_size anchors
the object area belongs to the owning reader, which keeps whatever it could
read and records why traversal stopped.

* fix(journal): separate undersized objects from truncation and bound the tail

- An object declaring a size below its own 16-byte header is a contradictory
  declaration, not a file cut short: it is counted separately so the analyst
  is not told the writer was interrupted.
- An object size above 2^53-1 now carries `size_overflowed` on its header
  record, matching how the header fields already report the ceiling.
- Object extents are validated against the declared arena, not only the
  physical file, so a short arena is reported instead of accepted.
- `tail_object_offset = 0` with `n_objects = 0` is an empty chain rather
  than an absent boundary; a declared tail the walk never reaches is
  reported as an incomplete object area.
- `tail_entry_boot_id` is null unless the compatible `tail-entry-boot-id`
  flag is set, so the legacy boot id at the same offset is not published
  as a tail-entry identity.
- A header the probe could not anchor reports `unread_fields`, so its
  zeroed numeric declarations are not read as observed values.

* fix(journal): keep journal occurrences out of the executable role

A recognized .journal with no special path role fell through to the default
executable role, so every ordinary journal was inventoried as a program.
The bytes are data, not code, so the format now keeps the resource role the
same path would carry without a recognized content format.

* fix(journal): report a short signed journal as truncated input

The reader mapped every format failure to `malformed`, so a file that
carries the signature and stops before the header shape was complete was
reported as damaged structure rather than missing bytes. The signature is
now read before the decoder runs, and a signed short file carries a
`truncatedInput` cause; unsigned bytes keep `malformedInput`.

* fix(journal): keep the legacy boot id and read flags once

The 56-71 id has two readings selected by the compatible `tail-entry-boot-id`
bit; nulling it when the bit is clear dropped a readable header value. Both
names are now reported with exactly one non-null, and `readIdFacts` takes
the compatible flags the caller already read instead of a second u32
reader.

* Merge origin/main into feat/10123-systemd-journal

Import systemdJournalMetadataSchema from androidAndSystemMetadata directly instead
of the artifactFormatMetadata barrel. main moved format metadata into per-group
modules; the barrel re-exports platform parsers that import back through
resources, and the cycle left the schema undefined at module init, failing every
SystemdJournalArtifactReader test.

* test(filesystem): align stable artifact stream failures with split error reasons

Upstream #14225 split reader path refusals from malformed target bytes and moved two stable-artifact contract breaks off ArtifactReaderFailure("format"): an invalid chunk size is now an internal invariant violation, and a descriptor returning an impossible byte count is an io failure. The suite still asserted reason "format" for both, so shard 9 and the required CI lane went red on every branch that re-merged main.

Update the assertions to the reasons the producers now raise so the boundary suite matches the intended contract.

* test(filesystem): assert path refusal for a directory entry in the reader suite

DirectoryArtifactReader has refused non-file entries as reason "path" since the reader moved into src/resources (#11520), but the boundary test still expected "format", so the re-merged branch fails shard 4 with an ArtifactReaderFailure whose reason is path.

Assert the reason the reader raises.

* fix(artifacts): report unknown journal layouts as unsupported, not truncated

A complete journal whose header sets an incompatible flag bit this reader does not know was refused through the signature-based path, which wraps every decode refusal in truncatedInput. Callers therefore told the analyst the artifact was invalid and to obtain a fresh copy, although no bytes are missing and a fresh copy cannot help.

Carry an unsupported tag from the journal decoder through the artifact boundary so truncation stays reserved for genuinely short structures, and the public reason selects the compatible-decoder recovery.

* fix(pe): accept systemd-journal as a PE overlay leading format

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.

* fix(systemd-journal): bound the scan by its window, not a file-size ceiling

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

* feat(artifacts): page format record headers past the inline window

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 (#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 #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 #14919

* fix(artifacts): page record headers only from a caller-named file

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

* fix(artifacts): scope record-page file selection and cleanup to its owners

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

* fix(views): own the record-page row type beside the view parent

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.

---------

Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
2026-11-27 15:46:45 -05:00
CyberSproutandmorluto f6cf6a867f feat(firmware): decode ESP-IDF Non-Volatile Storage (NVS) flash partitions (#14436)
* feat(firmware): decode ESP-IDF Non-Volatile Storage (NVS) flash partitions

Add offline ESP-IDF v1/v2 NVS partition decoding via `inspect_esp_nvs`
(`rea inspect-esp-nvs`) with complete retained Evidence, `detail: "summary"`
and `inspect_analysis_view` (`kind: "esp-nvs"`) paging, linear O(N+M) v2
multi-chunk blob reassembly, slot-by-slot CRC recovery past damaged item
headers, fail-closed `partition_offset`/`partition_bytes` bounds validation,
and full capability conformance and provider lifecycle coverage.

* fix(firmware): follow ESP-IDF NVS page states, header rules and encryption layout

Page states now follow ESP-IDF's PageState constants (corrupt 0xfffffff0,
invalid 0, unknown otherwise), with the header CRC and whether entries were
walked reported separately. NVS encryption keeps page headers in plaintext,
so an encrypted page is reported as a valid page whose item headers are all
unreadable instead of as a header CRC failure.

Item headers follow Item::checkHeaderConsistency: span per type, BLOB_IDX
and BLOB_DATA chunk-index rules, and a variable item's span matching its
length. An inconsistent header is not trusted and the walk advances one
slot. Unrecognized types are no longer entries with unknown values, and
namespace index 0 items that are not definitions are reported instead of
skipped silently.

Adds float (0x24) and double (0x28) items, keeps the bytes of non-UTF-8
strings and keys, and marks older copies of a key superseded by a higher
page sequence number or a later slot. Spec constants are named once and
v2 blob reassembly moves to its own module.

* fix(firmware): preserve NVS key byte identity, summary retention, bitmap span checks and artifact handoff

* fix(firmware): preserve intact NVS values, copied blob chunks, unknown page versions and -0

* fix(firmware): report older copies of used NVS blob chunks instead of dropping them

An interrupted page move leaves an older copy of a BLOB_DATA chunk next to
the copy a recovered blob used. a2e8fc1a70 stopped reporting it as an
orphan by skipping every chunk with a claimed index, which also dropped the
older copy silently, including one whose bytes differ. It is now reported
as blob_data_copy, superseded, with its own CRC-based completeness, and
does not make coverage partial.

* fix(firmware): require CRC-valid replacement before marking copied NVS blob chunks superseded

* fix(firmware): bound decoded NVS representation growth and fuse coverage flags

---------

Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
2026-11-27 20:32:53 +00:00
61fb6cf68a feat(native): list Mach-O function starts and data-in-code entries offline (#14897)
* feat(native): list Mach-O function starts and data-in-code entries offline

The diff adds a static reader for LC_FUNCTION_STARTS and LC_DATA_IN_CODE
on one thin Mach-O or one selected slice of a universal file. Starts are
absolute VM addresses from ULEB128 deltas off the __TEXT vmaddr, and
each data-in-code entry reports offset, length, kind, and the function
start that owns its address, with one offset and limit applied to each
selected table and counts covering every entry.
inspect_macho_function_starts and inspect-macho-function-starts expose
that report, require architecture only for a universal file, and refuse
a combined table above max_entries with no partial result. The shared
load-command walk now yields each command once and stores the Mach-O
segment name and vmaddr on load regions, and the guides and limit docs
record coverage, paging, and the read and entry budgets.

* build: add advertised schema summary for inspect_macho_function_starts

* Address review feedback

* fix(native): bound function-start decoding and page before building rows

- Check each start against an interval index of executable segments, built
  once, instead of scanning every segment per start.
- Walk LC_FUNCTION_STARTS once. Count and check every start and
  data-in-code entry, but build result objects only for the requested page,
  and resolve owners for that page during the same walk.
- Keep every declared Mach-O segment in the shared reader (macho_segments),
  so a __TEXT with no file bytes still anchors the deltas, as
  llvm-objdump does. LoadRegion no longer carries macho_segment.
- On 32-bit ARM, clear the Thumb tag (bit 0) from published starts and
  report it as `thumb`, keeping the tagged value for the next delta, as
  ld64 encodes and LLDB decodes. Wrap 32-bit images at 2^32.
- Intersect Evidence file ranges with the selected universal slice.

* refactor(native): normalize function-start format facts once

- One table, MACHO_DICE_KIND_NAMES, names data-in-code kinds for the
  reader, the schema and the report check, which each had their own copy.
- Each linkedit command's dataoff/datasize is normalized once against the
  slice (end, 32-bit fit, in-slice bytes) instead of the overflow check and
  the in-slice length being recomputed in three helpers.
- Name CPU_TYPE_ARM, VM_PROT_EXECUTE and UINT32_MAX after their headers.
- Report coverage.text_not_at_header when __TEXT does not map file offset
  0: llvm-objdump anchors the deltas on the __TEXT vmaddr and dyld on the
  mach_header address, and they disagree there.
- Pin the fixture's expected starts to literal addresses.

* build: refresh the inspect_macho_function_starts schema summary after merging main

* fix(cli): keep lipo's flag name out of --architecture help text

The architecture help for four commands said "as lipo -thin does", which
the CLI option-alias check reads as a registered short flag `-thin`.
Describe the lipo behavior without spelling its flag.

* Revert "fix(cli): keep lipo's flag name out of --architecture help text"

This reverts commit 68f25adf74.

* refactor(cli): use the shared universal-slice help for inspect-macho-function-starts

* fix(native): bound decoding by max_entries and map data-in-code from the header

- Refuse a data table above max_entries from its byte count, and stop the
  start walk at the remaining allowance, so the allowance bounds decoding
  work. The refusal no longer claims a required_value it did not measure.
- Map each data-in-code offset as the mach_header's VM address plus the
  offset, the way ld64 encodes it and dyld documents it. MH_OBJECT does not
  map its header, so its base is 0. The shared container now carries
  mach_header.filetype.
- Use the same header address for text_not_at_header, which also catches a
  header shifted by SG_HIGHVM.
- Report a list that ends without its zero terminator as
  unterminated_starts.
- Accept an observed empty section name in both result schemas.

* fix(native): tally LINKEDIT commands compactly and report a known entry total

- Count LC_FUNCTION_STARTS and LC_DATA_IN_CODE commands during the shared
  load-command walk into a compact tally (two 32-bit words per command)
  instead of retaining a view and an object for each one. The shared
  visitor now hands over the image's byte order.
- When the image has no starts to decode, a data table above max_entries is
  refused with its exact count as required_value.

* fix(native): report a non-Mach-O input as unrecognized, not malformed

Ask the shared Mach-O header recognizer before the thin reader. An ELF or
PE file passed without `architecture` has no Mach-O magic, so it is an
unrecognized target for this operation. A recognized Mach-O with a broken
or cut-off header still fails as malformed or truncated.

---------

Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
2026-11-27 20:29:07 +00:00
Ryan Sandmorluto b3f70898e4 feat(firmware): inspect and extract Android DTBO partition images (#14398)
* feat(firmware): inspect and extract Android DTBO partition images

* fix(firmware): replace fixed DTBO limits with artifact_limits

* fix(artifacts): keep saved effective_limits compatible without android_dtbo

* fix(firmware): accept shared DTBO payloads and keep unknown facts unknown

mkdtimg writes a repeated input file once and points every entry for it at
the same payload (libufdt mkdtimg_core.c search_fdt_info), so an exactly
shared range is valid; only partial overlaps are refused.

A compressed entry's inner FDT magic was not examined, so
fdt_magic_valid is now null rather than false. Bytes inside total_size
that the header, entry table and payloads do not claim are reported with
their range and make coverage unknown. dt_table_header and dt_table_entry
field offsets are named after dt_table.h.

* fix(firmware): charge every DTBO row against artifact_limits.expanded_bytes

Shared payloads are valid, but each row is hashed and can be extracted
separately, so 4096 rows naming one 16 MiB payload multiplied inventory
and extraction work to 64 GiB. Admit the declared bytes of every row
against the shared aggregate expansion allowance before reading any
payload, as PCK aliases do.

* test(firmware): throw the parser's typed error in DTBO success cases

Success cases asserted ok and returned, so a parse failure showed only a
boolean mismatch. They now throw the typed ParseFailureError, as the
testing guide requires.

* test(firmware): drop a duplicated result guard

---------

Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
2026-11-27 19:41:33 +00:00
jeromeskiiiandmorluto 3273cbd1e2 fix(mutation): unblock the daily mutation sweep (#14748)
* fix(mutation): include every mutated file in the mutation project

Stryker's typescript-checker watches the files the mutation project
includes. A mutated file the project leaves out has no watcher, and the
sweep aborts with "no watcher is registered for it" before it reports a
score. The semantics suite mutates src/rizin/RizinDebugFrames.ts and
src/rizin/RizinDebugEvidence.ts, and the reverse-tools suite mutates
src/domain/analysisResourceLimits.ts; none of the three was in
tsconfig.reverse-tools-mutation.json, so the daily mutation sweep failed
before it produced a report.

Add the three files to the project. Add scripts/verify/mutation-target-tsconfig.mjs,
which reads the resolved mutation targets from both configurations and
fails when the project does not cover them or lists a file the repository
no longer has. The guard runs in the deep static lane and before the
sweep, so the drift is reported by name instead of as a checker
abort.

* fix(mutation): give the reverse-tools sweep the time it needs

The reverse-tools suite reached 805 of 1008 mutants after 57 minutes of
mutation testing on the 2026-11-26 scheduled run and was killed by the
60-minute job budget before it could report a score. The suite needs
about 70 minutes of mutation testing plus the setup it runs before it.

Raise the job budget to 90 minutes so the sweep reports instead of
being cancelled. The budget is the only change; the suite and its
mutant set are untouched.

* fix(ci): select mutation quality for debugger limit changes

---------

Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
2026-11-27 19:13:03 +00:00
bbd1540d10 feat(yara): scan an admitted artifact with caller-supplied YARA rules (#14688)
* feat(yara): scan an admitted artifact with caller-supplied YARA rules

Add inspect_yara_matches (CLI inspect-yara-matches), which runs the
installed yara command (REA_YARA_COMMAND or yara on PATH) with
caller-supplied rule files against one local file. The result lists
matching rules with tags, typed metadata and string match offsets,
bound to the SHA-256 of the scanned file and of each rule file.

yara is launched with an argument list under owned process supervision.
Its stdout is parsed as it streams, and the scanned file is re-verified
after the scan. command_timeout_ms, max_output_bytes and max_matches are
per-call arguments and runtime analysis settings with REA_YARA_* launch
seeds; max_file_bytes is per call. String matches beyond max_matches are
counted and coverage is partial. A rule compile error is an input error
naming the rule file, and a missing yara command is reported as
capability_unavailable without affecting other tools. REA bundles no
rules and downloads nothing.

* Address review feedback

* fix(yara): keep the scanned file's observation when a rule file fails

* fix(yara): require qualified Windows paths and resolve relative POSIX commands

* fix(yara): stage owned snapshot, preserve CLI array bounds, and report file-size required_value

* fix(yara): preserve relative includes, retain completed matches, order snapshot cleanup, and declare writesFilesystem

* chore(yara): update advertised schema summary for inspect_yara_matches

* fix(yara): handle regex arguments in include rewriter and retain completed matches across process cleanup

* fix(yara): preserve raw include bytes and staged file identity across close

* fix(yara): preserve completed rule identities and malformed-output primaries

* fix(yara): bound rewritten rule staging and preserve cleanup cancellation

* fix(yara): record completed rule identity before flushing rewritten includes

* Address review feedback

* Address review feedback

* fix(skills): restore the macOS flat installer guidance this branch dropped

The authored native-and-artifacts reference had lost main's macOS .pkg
paragraph, so the generated Cursor plugin copy no longer matched it and
the skill freshness check failed in docs, source tests and packaging.

* fix(yara): classify compile errors by kind and keep unrecognized diagnostics

yara 4.x prints compiler diagnostics in two forms, with and without a rule
(cli/yara.c print_compiler_error). The include failure in the stub used a
form yara never prints, so a real missing include was untested. Parse both
forms once into severity, source, line, rule and message, classify the
message by libyara's text (include, syntax, undefined, duplicate,
unreadable file, other), and give one repair per kind present. Stderr lines
that match no documented form are kept verbatim instead of only counted.

* fix(yara): decode every meta escape yara prints and anchor diagnostic file names

Meta strings: yara 4.x print_escaped_data also escapes an apostrophe and
writes \a \b \v \f, so a meta value such as "author's" failed the whole
scan as an unknown escape. Decode exactly the escapes yara writes, named
after that function, and refuse octal forms it never writes.

Diagnostics: a file name or message can contain "(N): ". Match the rule
files yara was given exactly and end any other file name at the first
location rather than the last. Name yara's EXIT_FAILURE.

* fix(yara): keep an ambiguous diagnostic location unknown and scope duplicate advice

A file name and a message can both contain "(N): ". Split an unnamed
file only where one complete diagnostic remains; several splits leave the
source and line null with the whole text kept, instead of shortening the
file name or dropping the line to unrecognized stderr. Duplicate advice now
covers string, tag and metadata identifiers within their rule, not only
rule names.

---------

Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
2026-11-27 18:57:06 +00:00
17b53ee004 feat(artifacts): inventory Nintendo 64 ROM images and normalize byte order offline (#14911)
* feat(artifacts): inventory Nintendo 64 ROM images and normalize byte order offline

An n64-rom image is recognized from the first word in z64 (80 37 12 40),
v64 (37 80 40 12), or n64 (40 12 37 80) order plus a 4-byte-aligned boot
address in KSEG0 or KSEG1. The reader normalizes the cartridge header
and serves header.bin, ipl3.bin, and program.z64 in big-endian order,
swapping v64 and n64 bytes and recording that swap as decoded. It names
the IPL3/CIC variant from the CRC32 of bytes 0x40..0x1000 and, for a
known variant, recomputes the CRC pair over the 1 MiB window; a
mismatch, unknown CIC, short window, or non-zero reserved header bytes
leave coverage unknown, and a file above 64 MiB is refused before any
swap. Comparison ignores n64-rom and n64-rom-entry metadata so dump
order is not treated as a content change, and decoded members share the
idle-abort helper the Switch executable reader now calls.

* fix(n64): admit members before reading and follow each byte order's swap unit

Charge artifact_limits.expanded_bytes from the file size and byte order
before the checksum window is read and swapped. The member layout now has
one owner, n64RomRegions, which the parser and the allowance both use.

The length rule follows the order's swap unit, as in mupen64plus-core: a
z64 image of any length needs no swap, a v64 image needs an even length and
an n64 image a multiple of 4. The guide now says that a printable
destination byte outside the known table keeps its code with a null
destination_name.

* refactor(n64): name header fields from the spec and share the boot-address check

Header offsets, the first-word magics, the CIC 6105 table offset and the
KSEG bounds are now named constants with their reference sources, and
recognition and parsing share one boot-address decision. A closed-form
test checks the cartridge checksum on an all-zero window for every CIC,
derived from the checksum routine rather than from n64CartridgeCrc.

* fix(n64): keep the present bytes of a final partial word in the checksum window

The checksum routine now reads one defined window, n64ChecksumWindow: the
image through 0x101000 with only the bytes past a shorter file taken as
zero. A z64 or v64 image that ends inside a word keeps that word's bytes
instead of losing the whole word. The limitation now says how many bytes
were assumed.

---------

Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
2026-11-27 18:56:42 +00:00
morluto 943a1f329e fix(uefi): decode LZMA sections through one shared LZMA1 owner (#14918)
* fix(uefi): decode LZMA sections through one shared LZMA1 owner

UEFI LZMA custom sections whose header declared a dictionary above 64 MiB
were refused as an output limit even when their output was tiny, because the
worker compared the dictionary with the output budget and handed it to
lzma-purejs, which allocates a window of that size. EDK II's one-call
LzmaDecode uses its output buffer as the dictionary, so a valid stream never
needs more window than its output.

src/compression/Lzma1.ts now owns LZMA1 for UEFI and UnityFS: the
LZMA-Alone header and LZMA1 property bounds (lc 0-8, lp 0-4, pb 0-4), the
range coder lead-in, a decoder window of max(4 KiB, min(dictionary, output
bound)), bounded output, and the verdict on a stream. Lzma1Header.ts reads the
header fields with BinaryReader at the host boundary. The UEFI worker keeps
its framing, x86 branch filter and reply protocol; a corrupt stream or invalid
properties are now reported as malformed rather than as a decoder fault. The
UnityFS worker thread loads the same module instead of an inline decoder.

Closes #14917

* fix(compression): leave LZMA1 host faults to their host

decodeLzma1Alone reported every exception from the codec as a malformed stream, so an allocation failure or codec defect inside the decoding host looked like corrupt input, and the codec's own verdict text was lost. Only lzma-purejs's verdict literals ("Error in data stream", "Incorrect stream properties") are now a malformed verdict; anything else is rethrown for the host to classify (UEFI reports it as a decoder fault, the UnityFS worker as a runtime failure).
2026-11-27 18:48:32 +00:00
f7f67575ac perf(ghidra): read ahead in the background and for batch_decompile (#14898)
* perf(ghidra): read ahead in the background and for batch_decompile

Read-ahead used to decompile a whole window before answering the request
that carried it, starting up to eight native decompiler processes one
after another (about 200 ms each). Small runs paid that startup before
their first result, so batch_decompile could not use it and a small
decompile-all was slower than a serial one.

The carrying request now decompiles its own function at once on the
session decompiler. The rest of the window is queued for REA's own
worker threads, started only for the queued work (none for a single
function, at most eight), and each opens its decompiler on its own
thread and takes the next queued function as soon as it is open. A
later request uses a finished result, including a failure or timeout,
without decompiling again; waits for a running one, which its own
earlier-started deadline bounds; or takes back a queued one and
decompiles it itself. Cancelling a request cancels the read-ahead; an
edit, a payload change or shutdown stops the workers, including those
still opening, and idle workers close after 30 seconds.

batch_decompile now names its next functions the same way, through the
window size shared with decompile-all on the analysis port.

Closes #14836

* fix(ghidra): redecompile read-ahead failures under a changed deadline

A read-ahead task keeps the decompile deadline it ran under, but its
lookup ignored it. After ghidra.decompile_timeout_seconds changed, a
later request reused a timeout produced under the old deadline, reported
the new limit in its message, and could wait without bound for work
started with no deadline.

The task lookup now decides reuse by the cache policy: a completed
decompilation is reusable under any deadline, as cached results are,
while a failure, a timeout or unfinished work under a different deadline
is cancelled and decompiled again under the request's own deadline. The
result cache needs no change: it holds only completed decompilations.

* fix(ghidra): bound finished read-ahead and cancel it with the workflow

Finished results were trimmed only when another hint arrived, so tasks that completed after the last hint stayed strongly held. Trim them when they finish too.

A cancelled export could also leave workers running after the carrying request had returned, because only an in-flight procedure_pseudo_code monitor disposed them. The same workflow signal now sends abandon_decompile_read_ahead for that gap.

The failure probe derives its worker count from the bridge cap, waits until a reused task has actually completed, and releases startup latches before disposal if a check fails.

* fix(ghidra): keep a read-ahead abort watch across unrelated requests

Every Program request called noteRequest, which dropped the owning signal whenever the next request used a different one. A list or journal gap could then leave the workers running after that owner cancelled.

Only a request that carries its own read-ahead window replaces the owner. The bridge has one worker pool, so that new window is the owner that a later abort disposes.

Co-authored-by: morluto <morluto@users.noreply.github.com>

* fix(ghidra): ignore an older read-ahead watch after a newer owner

A queued read-ahead took ownership before the carrying request settled, and that request's finally installed its watch again. Cancelling the older workflow then abandoned the newer window.

watch now leaves the newer owner in place.

Co-authored-by: morluto <morluto@users.noreply.github.com>

* fix(ghidra): admit read-ahead ownership and cap the queued backlog

A window with no signal left the previous abort listener armed, so that abort disposed the new workers. Ownership now moves when the request is admitted, including a signal-less window, and a request removed while queued does not move it. An abandon queued for an older generation is not written.

Queued tasks no worker has started are dropped with finished results beyond two windows. A decompile a worker has already started stays, and the worker cap bounds how many of those exist.

Co-authored-by: morluto <morluto@users.noreply.github.com>

* fix(ghidra): abandon read-ahead without waiting for the active request

The cleanup frame waited in the Program queue, so a slow analysis request held a cancelled workflow's workers. The reader now disposes those workers the way it applies cancel, and the client writes that frame beside the FIFO.

Co-authored-by: morluto <morluto@users.noreply.github.com>

* fix(ghidra): cancel read-ahead on the reader without waiting

abandon_decompile_read_ahead runs on the socket reader and was waiting up to 10s for workers. The cancel frame behind it then missed the 2s grace, and the client closed the session. A task already taken by the waiting request was also absent from the map, so that wait did not cancel it.

The reader now only cancels monitors, including taken tasks, and returns. The handler still waits for workers on edit, shutdown, and its own dispose.

Co-authored-by: morluto <morluto@users.noreply.github.com>

* fix(ghidra): stop the failure probe calling the removed abandon handler

The real-Ghidra probe invoked abandon_decompile_read_ahead through handleRequest. That method is only accepted on the socket reader now, so the probe threw method_unavailable before it could report success.

The probe now blocks the handler on a taken task, calls cancelDecompileAhead, and checks that the call returns inside a second and the waiting request is cancelled.

Co-authored-by: morluto <morluto@users.noreply.github.com>

* style(ghidra): format the read-ahead client files

CI format:check rejected GhidraClient, GhidraReadAheadCancellation, and the request-queue test. The shard jobs never started because static checks failed first.

Co-authored-by: morluto <morluto@users.noreply.github.com>

* fix(ghidra): take read-ahead ownership after wire admission

A carrying request can leave the queue and still be refused when it
exceeds bridge.max_request_bytes. Ownership now moves only immediately
before the wire writes a frame that passed admission, so a refused hint
leaves the previous window's abort owner in place.

Co-authored-by: morluto <morluto@users.noreply.github.com>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: morluto <morluto@users.noreply.github.com>
2026-11-27 13:19:09 -05:00
Deepak Jain (DJ)andmorluto 580c944a24 fix(ghidra): admit recordless MIPS32 executables that declare o32 (#14423)
* fix(ghidra): admit recordless MIPS32 executables that declare o32

Use the o32 declaration in the ELF header when inspection confirms there is no separate ABI flags record. Keep floating-point storage unknown and reject declared-o32 MIPS-I, whose load delays need separate verification.

Signed-off-by: Deepak Jain <deepujain@gmail.com>

* fix(ghidra): keep an uninspected MIPS ABI flags record unknown in the declared-o32 lane

A declared-o32 MIPS32 executable whose ABI flags record was never inspected
was refused with the message for a record-bearing image, conflating unknown
with present. Report the uninspected case as unknown, and decide the session
floating-point limitation from the committed profile basis alone, since
admission to that basis already required an inspected absence.

* refactor(ghidra): name MIPS ELF header fields after the specification

The MIPS admission tested e_flags through raw literals in two modules, each
with its own copy of the EF_MIPS_ARCH values, and refused EF_MIPS_FP64 and
EF_MIPS_NAN2008 in two branches. One domain module now names every field as
binutils, glibc and LLVM define it, both consumers use it, and the shared
refusals run once before the recordless and declared branches.

The declared-o32 refusal cases now name the rule that rejects each one, so
a later rule cannot hide an earlier one that widened.

---------

Signed-off-by: Deepak Jain <deepujain@gmail.com>
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
2026-11-27 13:01:08 -05:00
Beqaandmorluto 6b269dbd97 feat(uefi): read TianoCore EDK2 NVRAM variable stores (#14701)
* feat(uefi): read TianoCore EDK2 NVRAM variable stores

Add read-only parsing of gEfiVariableGuid /
gEfiAuthenticatedVariableGuid VARIABLE_STORE_HEADER regions to
inspect_uefi_nvram via additive edk2_stores, preserving the AMI NVAR
stores contract and reporting added vs superseded variable states.

* fix(uefi): harden EDK2 NVRAM scan coverage and accounting

Occupy store ranges and charge decoded names before retention, keep
truncated and damaged-name facts, examine unread tails, and compose
empty-format diagnostics from scanner facts with a provider-level test.

* fix(uefi): preserve enclosing EDK2 stores and scan erased ranges in blocks

Walk store GUID candidates in ascending offset order, claim only verified
spans so damaged oversized headers cannot hide later stores, and checkpoint
erased suffixes per 64 KiB block.

* fix(uefi): keep unusable EDK2 store signatures from reading as absence

A gEfiVariableGuid or gEfiAuthenticatedVariableGuid match whose header
lacks the formatted marker was skipped silently, so an image holding only
such a header reported that no EDK2 store exists. It is now reported as a
rejected signature, and the absence statement is qualified.

A formatted store that is not HEALTHY is walked with EDK2's verdict as a
caveat: EDK2 treats it as invalid, while UEFITool still parses it. A store at
an unaligned image offset states the HEADER_ALIGN assumption.

An in-use EDK2 fault-tolerant-write queue is noted, because REA does not
replay FTW writes or rebuild a store from the spare area.

AMI NVAR and EDK2 scans now share one structural record budget, as the
limit documents. GUID signature encoding moves to UefiGuid beside its
decoder, header field offsets are named after VariableFormat.h, the
limitation-line cap is a named limit, and the store walk is split from
header admission with unreachable branches removed.

* fix(uefi): distinguish unchecked EDK2 stores from absence

Carry an explicit completed-search absence fact from the EDK2 scanner.
Partial or budget-stopped searches report that presence is unknown
instead of claiming no store exists.

---------

Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
2026-11-27 12:47:09 -05:00
Afloatandmorluto b14844d99c feat(artifacts): recognize Zip64 archives after leading bytes (#14105)
* feat(artifacts): recognize Zip64 archives after leading bytes

* test(artifacts): pin the unadjusted Zip64 extensible-sector refusal

---------

Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
2026-11-27 12:44:30 -05:00
Beqaandmorluto a6cca9dc62 feat(artifacts): decode UnityFS LZMA blocks (#14699)
* feat(artifacts): decode UnityFS LZMA blocks

Unity's default AssetBundle compression (type 1) left members as
hash_status unavailable. Decode 5-byte Unity LZMA streams with the
existing lzma-purejs dependency so inventory can hash and extract them.

* fix(compression): read Unity LZMA dictionary via BinaryReader

Architecture guards forbid raw Buffer numeric reads outside
binaryContainer; match the UEFI LZMA path.

* style(compression): format UnityFS LZMA helper

* fix(compression): make UnityFS LZMA cancelable and end-marker safe

Accept optional LZMA end markers without trailing junk, decode off-thread so
timer aborts land, return one expected-sized buffer, and mark xinzexi unverified.

* fix(compression): await Unity LZMA worker exit and transfer alone buffer

Await worker.terminate() before settling abort/reply paths, and allocate the
synthesized alone header with allocUnsafeSlow so the worker receives it without
a second encoded-stream copy.

* chore: retrigger CI after Greptile worker-exit follow-up

* test(compression): clarify Unity LZMA cancellation case title

Retriggers Actions after the worker-exit follow-up push did not receive a
GitHub Actions check suite.

* fix(unityfs): keep the directory for over-budget LZMA blocks and decode spec-valid streams

UnityFS writers emit one LZMA block for a whole data stream, so the per-block
decode budget refused the whole inventory of any LZMA bundle above 64 MiB,
where before this change the directory was retained. An over-budget block now
keeps the directory and only members inside it report an unavailable read
naming the budget, for LZ4 and LZMA alike.

The LZMA decoder window is bounded by the declared output instead of the
declared dictionary, so a large dictionary on a small block decodes and no
longer allocates a dictionary-sized window. Properties follow the LZMA
specification (lc 0-8, lp 0-4, pb 0-4) rather than the LZMA2 lc + lp limit.
Worker error events and exits without a reply stay runtime failures instead of
being reported as a malformed block.

Tests decode a liblzma-produced stream as a known answer, settle only after
the worker exits on completion and cancellation, and share one encoder.

* fix(artifacts): report Unity LZMA size mismatch as malformed

Overflow past the bundle's declared length is a format error, not a
decoder budget exhaustion. Declarations above maximumBytes still fail
closed as a resource limit before decode starts.

* fix(unityfs): name the encoded or decoded bound that refused a block

A block refused by its encoded size reported its decoded size against the decoded budget. The block now records which bound refused it, and the member read names that bound, its declared size and the budget.

---------

Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
2026-11-27 12:44:20 -05:00
RRFZ 2e59f08992 feat(gpu)!: add per-call object, work, report, metadata, structure, and parser budgets to inspect_gpu_code_objects (#14882)
* feat(gpu)!: add per-call object, work, report, metadata, structure, and parser budgets to inspect_gpu_code_objects

Replace the pending GPU object and parser ceilings in GpuCodeObjectsProvider
with domain-owned optional per-call parameters (max_object_bytes, max_work_bytes,
max_report_bytes, max_metadata_bytes, max_structure_bytes, max_parser_entries,
max_parser_visits, and max_token_bytes) reporting details.limit and
adjustable_budget, remove superseded hardcoded constants, and register only the
recursive container and AMDGPU MessagePack nesting caps as a fixed
representation allowance.

BREAKING CHANGE: inspect_gpu_code_objects adds optional per-call budget
parameters and reports details.limit with details.refusal.kind
"adjustable_budget" instead of "fixed_ceiling" on top-level object, work,
report, metadata, structure, and parser budget refusals.

* fix(gpu): clamp padding scans, classify multi-frame CCOB budget cuts, and keep max_work_bytes at 512 MiB

* fix(gpu): align --max-work-bytes help text, release partial decode before refill, and admit floats under small token budgets

* test(gpu): keep multi-frame CCOB v1 decoded size within cut budgets

* fix(gpu): report decoder inputExhausted to refill and bound trailing Zstandard frames

* fix(gpu): peek next Zstd frame, charge AMD structure reads to work budget, and keep 128-token PTX limit

* fix(gpu): fix CCOB refill work double-charge, meter section reads, decouple non-GPU recognition, and align frame/recovery bounds

* refactor(gpu): drop redundant lookahead on non-refill path and pin refill/readBounded regressions

* fix(gpu): keep standalone PTX peak heap at 1x, use explicit scan reads, forward CUDA cancel signal, and report max_report_bytes required_value

* fix(gpu): report lower-bound report bytes in reported_limits and enforce max_token_bytes on recognized PTX headers
2026-11-27 16:14:15 +00:00
Lewis WangandClaude Opus 5.5 92b082bcaf fix(macho)!: select arm64e.x1 slices of universal Mach-O files by exact subtype (#14881)
* fix(macho): select arm64e.x1 slices of universal Mach-O files by exact subtype

macOS 27 system binaries such as /bin/ls and /usr/bin/codesign hold
x86_64, arm64e and arm64e.x1 slices. The caller's architecture selector
counted arm64e.x1 as arm64e and had no value of its own for it, so
inspect_native_initializers, inspect_go_binary, inspect_rust_binary and
inspect_dwarf_units refused arm64e as matching several slices and
rejected arm64e.x1 as an argument. Neither arm64e slice could be read.

Name each arm64e subtype exactly, as lipo -thin and otool -arch do:
arm64e reads only the arm64e slice and the new arm64e.x1 value only the
arm64e.x1 slice. arm64 keeps reading its family's only slice. A refusal
and the unread-slice limitation now offer arm64e.x1 where it selects one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(macho): record the advertised schemas that accept arm64e.x1

The architecture enum of inspect_native_initializers, inspect_go_binary,
inspect_rust_binary and inspect_dwarf_units gained arm64e.x1, which
changes their advertised input schemas. Commit the regenerated summaries
so verify-advertised-schemas matches the catalog.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(macho): check the selected DWARF slice subtype and document arm64e.x1

inspect_dwarf_units accepted a report whose CPU family matched the
request, so an arm64e or arm64e.x1 request answered by the other arm64e
slice still produced Evidence. Validate the report's selected_slice with
machoSelectionAnswersArchitecture, as the initializer, Go and Rust
readers do.

The tool's architecture field, its CLI option and dwarf-units.md still
described a CPU family and listed only x86, x86_64, arm and arm64. Name
arm64e and arm64e.x1 and their exact-subtype rule there as well.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 10:56:06 -05:00