Commit Graph
437 Commits
Author SHA1 Message Date
David Muñoz Reyandmorluto cd3590c8ee feat(artifacts): inspect NES 2.0 container headers and regions (#10674)
* feat(artifacts): inspect NES 2.0 container headers and regions

Problem: the iNES lane refused every header whose byte 7 bits 2-3 select
NES 2.0, so NES 2.0 cartridges could not be inventoried, extracted or
reconstructed even though their file layout extends classic iNES.

Fix: the single iNES-family header parser now reads NES 2.0 alongside
classic iNES. It reports the 12-bit mapper, submapper, 12-bit and
exponent-multiplier PRG/CHR sizes, declared PRG/CHR RAM and NVRAM sizes,
CPU/PPU timing, console type with Vs. System and extended console codes,
miscellaneous ROM count and default expansion device in a "nes-2.0"
header variant; classic headers keep their exact serialization. Regions
add one prg.bin/chr.bin for exponent sizes and misc-rom.bin for the bytes
after CHR-ROM when miscellaneous ROMs are declared. Oversized
declarations (with exact totals, including exponent sizes beyond safe
integers), nonzero unused header bits, empty PRG-ROM and declared but
absent miscellaneous ROM bytes are refused through the existing format
error. Nested byte classification now admits NES 2.0 through the same
parser. The reader limitation, tool description, guide and skill
reference now state that UNIF remains unsupported and that RAM, timing
and console values are declarations.

Validation: new synthetic NES 2.0 unit cases fail on the base (15 of 24)
and pass after the change; focused boundary and acceptance iNES suites
(75 tests) pass, including NES 2.0 inventory, extraction, reconstruction
and compiled CLI inspection; npm run check:fast passes.

Refs morluto/rea#2072

* test(artifacts): extract an exponent-sized NES 2.0 ROM area

Review follow-up for NES 2.0 headers.

The exponent-multiplier case stopped at parseInesLayout, and the
extraction test used counted ROM units, so prg.bin and chr.bin from
an exponent-sized area never went through the reader or extraction.
A boundary case now builds a NES 2.0 file with a 2^10 * 3 byte PRG-ROM
area beside one counted 8 KiB CHR-ROM unit. It checks the header omits
the PRG unit count, the source offsets of prg.bin and chr/000.bin,
the verified reconstruction order, and that the extracted regions
match the original bytes exactly.

Tests: tests/boundary/filesystem/inesArtifact.test.ts passes (38).

* refactor(artifacts): read NES header bytes through one helper

The NES 2.0 declaration added a sixth raw Buffer read to
inesContainer.ts. On current main the architecture guard allows five
there, so the merged tree failed Static checks. iNES and NES 2.0
declarations and the format probe now read header bytes through one
headerByte helper. The file has one raw read, and its counted baseline
drops from 5 to 1 through --shrink-baselines.

Tests: inesContainer domain tests (24) and the NES boundary and
acceptance tests (76) pass. architecture-guards, format:check and
check:ci:fast pass on the branch merged with main.

* refactor(artifacts): report iNES header failures through ParseFailure

Review follow-up: the NES 2.0 declaration added plain-string failures.
The iNES-family parser now returns Result<_, ParseFailure> with its
kind and where it was found:
- malformed: a missing signature, a dirty legacy header, an empty
  PRG-ROM area, reserved NES 2.0 bits or an invalid file extent;
- truncated: a short header, a short payload, or declared
  miscellaneous ROM with no bytes;
- unsupported: UNIF or another header variant, with undecoded content.
The detail text is unchanged.

The format registry refuses with the detail, and the iNES reader and
root classifier translate the failure at their boundary into the
existing format ArtifactReaderFailure, with the ParseFailureError as
its cause.

Tests: the refusal table now asserts each failure's kind and format
as well as its detail. iNES domain and recognition tests, NES boundary
and acceptance tests (76), architecture-guards, format:check and
check:ci:fast pass on the branch merged with main.

* fix(artifacts): preserve NES header declarations and iNES evidence

---------

Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
2026-11-19 20:49:33 +00:00
morluto aaa8e1cee0 refactor(elf): share bounded RISC-V attribute reads (#12515) 2026-11-19 20:41:56 +00:00
RRFZ 5433f65d95 refactor(cutter): share descriptor cleanup aggregation (#12504) 2026-11-19 15:19:46 -05:00
morluto 7f151e9d0f refactor(flutter): share Dart ELF and snapshot field reads (#12507) 2026-11-19 20:19:09 +00:00
RRFZ 6cbd9cf994 refactor(managed): read CLI header fields through BinaryReader (#12503) 2026-11-19 15:11:23 -05:00
7fd50eb361 fix(zstd): share exact-frame Zstandard decoding across ELF and OTA (#12416)
* fix(zstd): share exact-frame Zstandard decoding across ELF and OTA

Walk RFC 8878 frames once so ELF sections, Android OTA REPLACE_ZSTD, and GPU payloads reject truncated headers, blocks, checksums, and trailing bytes on every supported Node runtime. Bound that walk with the runtime zstd.max_frames setting.

* fix(zstd): keep frame output tight and report GPU frame-cap refusals

Copy each Node 22 frame off its decoder chunk before the next frame is decoded. Map a GPU zstd.max_frames refusal through the resource-limit contract instead of a provider failure.

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

* fix(zstd): keep frame-cap refusals and bad seeds out of malformed results

Project zstd.max_frames through one resource-limit helper for ELF notes, DWARF, GPU, and artifact reads. An invalid REA_ZSTD_MAX_FRAMES seed stays a configuration failure, and frame-header tests cover content size, window, dictionary id, and RLE blocks.

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

* fix(zstd): yield GPU frame decoding so cancellation can land

The frame-by-frame fallback awaits a caller pause before each data frame. GPU yields and checks the read signal there, so a many-frame payload does not finish before a disconnect is observed.

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

* fix(zstd): advertise the frame cap and keep strict GPU decode cancellable

List every operation that enforces zstd.max_frames, including GPU, DWARF, and ELF notes. The strict sequence uses the async decoder and checks the caller signal again after it returns, and a single output buffer is not copied a second time.

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

* fix(zstd): refresh analysis-setting schemas and GPU frame-cap projection

Regenerate the advertised input summaries for inspect_analysis_settings and update_analysis_settings. GPU inventory now throws the projected zstd.max_frames resource limit from payload decode and #retainFailure, so the adjustable setting survives the public failure.

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

* style(gpu): format the frame-cap projection throw

oxfmt keeps the zstd.max_frames throw in #retainFailure on one line so CI format:check matches the local formatter.

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

* fix(zstd): yield after the last frame-by-frame GPU decode

The fallback returned success in the same turn as the final synchronous frame, so a queued abort was still invisible to the caller's signal check. Pause once more before that success, matching the strict sequence.

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

* fix(zstd): yield ELF, OTA, and DWARF frame decoding on the caller signal

The synchronous frame loop ignored abort signals owned by inspect_elf_notes, inspect_dwarf_units, and Android OTA partition reads. Those callers now use the cooperative decoder and yield before Zstandard work, and 32-frame cancellations cover each path.

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

* fix(zstd): observe cancellation during structural parsing

* fix(zstd): project section-name frame caps at the ELF directory boundary

readElfDirectoryFromBuffer now requires the caller's operation and throws the adjustable zstd.max_frames resource limit. Hardening, unwind, and the other directory consumers keep that typed refusal instead of an adapter or I/O error.

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

* fix(zstd): preserve optional ELF evidence when frames are capped

* fix(zip): validate Zstandard members through frame completion (#12461)

fix(zip): require complete Zstandard member frames

* fix(elf): yield hardening section name decoding

* fix(elf): yield section names for unwind and export reads

* fix(zstd): yield ELF directory reads that already own a cancellation signal

Hardening, unwind, initializers, exports, kernel modules, debug link, and Android JNI now read section names through the cooperative directory when their caller has a signal. Readers with no signal stay synchronous.

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

* fix(elf): share one initializer directory and retain its snapshot

* fix(android): reuse the admitted JNI ELF directory

* fix(elf): retain optional debug candidate evidence through cooperative decoding

* fix(zstd): yield ELF section names for Go, Rust, and IL2CPP

These inspections already own an abort signal. Their ELF directory read now uses the cooperative container decoder so a queued cancellation can land during a many-frame section-name table.

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

* fix(elf): recognize compressed kernel modules before ELF decoding

The cooperative module reader decoded the bytes as ELF before the container check, so gzip, xz, and zstd modules became malformed images. The compression check now returns the unsupported-container report first.

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

* refactor(elf): classify each container once before reading it

* fix(il2cpp): preserve admission order during cooperative linking

* fix(elf): reuse section-name decoding in debug-link comparison (#12472)

* style(elf): format updated section-reader test calls

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: morluto <morluto@users.noreply.github.com>
2026-11-19 19:45:26 +00:00
吴佳浩Albenand吴佳浩 3d0fa7dae2 refactor(managed): read metadata pointer rows through BinaryReader (#12483)
Co-authored-by: 吴佳浩 <wujiahao@supremind.com>
2026-11-19 14:23:54 -05:00
morluto 1b0a118192 fix(hopper): verify Mach-O profile signature before loader selection (#12485)
fix(hopper): verify the admitted Mach-O profile signature
2026-11-19 19:23:29 +00:00
吴佳浩Albenand吴佳浩 410b64ab1f refactor(native): read the format sniff magic through BinaryReader (#12473)
Co-authored-by: 吴佳浩 <wujiahao@supremind.com>
2026-11-19 18:52:41 +00:00
吴佳浩Albenand吴佳浩 acc3fbb12a refactor(native): read recorded-crash fields through BinaryReader (#12464)
* refactor(pwndbg): read the mapping-table count through BinaryReader

* refactor(pwntools): read a recorded register through BinaryReader

---------

Co-authored-by: 吴佳浩 <wujiahao@supremind.com>
2026-11-19 13:40:11 -05:00
吴佳浩Albenand吴佳浩 0356ea8cdd refactor(apple): read an ObjC binding slot through BinaryReader (#12466)
Co-authored-by: 吴佳浩 <wujiahao@supremind.com>
2026-11-19 13:39:56 -05:00
morluto 8349201627 fix(elf): report empty kernel module signature ranges as malformed (#12471) 2026-11-19 18:39:07 +00:00
morluto 5a62623cd1 fix(macho): validate symbol extents before the hardening scan limit (#12465)
fix(macho): validate hardening symbol extents before capacity
2026-11-19 18:23:37 +00:00
morluto 11c014f022 fix(dol): require exact file extent for header admission (#12460) 2026-11-19 18:10:34 +00:00
speedcubing d58942a4ea refactor(apk): read signing block and v1 local header fields through BinaryReader (#12450)
Move the eight remaining raw DataView reads in src/domain/apkSignature
onto the shared BinaryReader and drop the three APK signature entries
from the raw-buffer-read baseline. Every read stays behind its existing
range check, so results, error kinds and messages are unchanged.

Refs #11865
2026-11-19 17:59:56 +00:00
morluto 1ba93c8a1b refactor(elf): share fixed header declaration widths (#12391) 2026-11-19 15:59:06 +00:00
morluto ad996352c3 refactor(macho): own complete fixed segment and section fields (#12405) 2026-11-19 15:44:31 +00:00
morluto e9af636128 fix(macho): share marker-bearing dylib field decoding (#12400)
* fix(macho): share marker-bearing dylib field decoding

* fix(macho): retain legacy lazy dylib timestamps
2026-11-19 15:33:09 +00:00
morluto 205ab4a587 refactor(elf): share fixed symbol record widths (#12379) 2026-11-19 15:28:37 +00:00
morluto 0eac37277d fix(pe): distinguish positional resource framing from capacity (#12402) 2026-11-19 15:26:52 +00:00
morluto bd4339ade9 fix(model): project the enforced parser limit and cause (#12399) 2026-11-19 15:24:26 +00:00
morluto 88983ebac7 fix(macho): prove command table framing before capacity (#12376)
* fix(macho): prove command table framing before capacity

* test(macho): match shared table admission precedence

* test(macho): separate encryption capacity from invalid framing
2026-11-19 15:19:50 +00:00
morluto cf9b474292 refactor(nativeaot): share checked MethodTable framing (#12375) 2026-11-19 15:00:02 +00:00
morluto 1b172f1e02 refactor(dotnet): share checked CIL operand and exception reads (#12372) 2026-11-19 14:43:25 +00:00
morluto 7eac002d5e fix(pcap): retain admitted DNS truncation facts (#12373) 2026-11-19 14:35:56 +00:00
morluto 091b8b0339 refactor(dotnet): read metadata constant scalars through BinaryReader (#12371) 2026-11-19 14:26:54 +00:00
morluto 17ad9c14ff fix(pe): validate resource name extents before capacity (#12368) 2026-11-19 14:22:26 +00:00
morluto 5f258086b0 refactor(macho): share checked segment and section framing (#12366) 2026-11-19 09:08:25 -05:00
morluto 156303f6ed refactor(python): read marshal scalars and bytecode magic through BinaryReader (#12362)
refactor(python): read marshal numbers through BinaryReader
2026-11-19 09:07:48 -05:00
morluto 7758d03c5d fix(artifacts): require DOS magic before applying Windows path semantics (#12340) 2026-11-19 13:52:31 +00:00
morluto 7e7516fbe9 refactor(il2cpp): share metadata section table framing (#12364) 2026-11-19 13:50:12 +00:00
morluto 1530507a7e refactor(rust): project dependency limits from parser facts (#12358) 2026-11-19 13:40:30 +00:00
morluto be54ffc8cd refactor(png): share chunk framing and metadata reads (#12357) 2026-11-19 13:39:49 +00:00
morluto 14aca264ea fix(windows): report out-of-spec shortcut StringData counts (#12352) 2026-11-19 13:33:05 +00:00
morluto 5a27508ae3 refactor(pe): read optional header fields through BinaryReader (#12351) 2026-11-19 08:26:25 -05:00
morluto 9a3aec331b refactor(elf): use shared readers for fixed and dynamic fields (#12345) 2026-11-19 08:24:57 -05:00
morluto 9b2c666033 fix(mips): validate GNU attribute extents before read limits (#12348) 2026-11-19 08:21:16 -05:00
morluto 66bb3e932e fix(desktop): validate ELF dependency table extents before capacity (#12344)
fix(desktop): validate ELF table extents before inventory limits
2026-11-19 13:10:17 +00:00
morluto 00170c74bb fix(bun): validate graph extents before payload limits (#12330) 2026-11-19 13:04:47 +00:00
morluto 15150b017a fix(pe): validate certificate entry framing before capacity (#12336)
fix(pe): frame certificate entries before count admission
2026-11-19 12:57:45 +00:00
morluto 7d5e9be81c fix(trace): report the enforced JSON parser limit (#12335)
fix(browser): report Playwright trace parser limits
2026-11-19 12:57:34 +00:00
morluto 77be47fbf9 refactor(dotnet): decode manifest fields through BinaryReader (#12332) 2026-11-19 12:56:14 +00:00
b6363efc97 refactor(errors): compose multi-part provider cleanup failures through one owner (#12002)
* refactor(errors): compose multi-part provider cleanup failures through one owner

CdpBrowserProvider, CdpElectronProvider, FridaInstrumentationManager and
PlaywrightBrowserScenarioProvider each built the same composite by hand: a
ProviderCleanupError listing the parts' resources, an AggregateError cause,
and bindCleanupDependencies over the parts. providerCleanupErrorFromFailures
in src/domain/analysisErrorCleanup.ts now owns that composition. `causes`
keeps non-AnalysisError failures in the aggregate cause without making them
own completion, as the CDP providers did; `message` keeps the aggregate
messages Frida and Playwright used.

Tests: helper unit tests, new close-composition tests for both CDP providers,
and a Playwright test with two failed cleanup retries. They pass on the base
revision and on this change, and fail when the helper drops the dependency
binding, the extra causes or the message.

Lowers the cleanup-dependency-binding baseline to 43 files / 73 sites.

Refs #11859

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

* style(test): format the Playwright cleanup test with oxfmt

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

* test(errors): assert cleanup composition facts instead of reason prose

Follows docs/development/testing.md: the close-composition tests now check
provider, operation, resources, aggregate causes and completion, not the
explanatory reason or aggregate message. A harmless wording change passes;
a lost binding, lost cause or wrong operation still fails.

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

---------

Co-authored-by: Anant Mandanka <anant.mandanka@renaissancejewel.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
2026-11-19 12:51:28 +00:00
morluto 9b642175b0 fix(nib): validate row framing before decode capacity (#12327)
* fix(nib): validate value row framing before capacity

* fix(nib): reserve framing for later table rows
2026-11-19 12:50:32 +00:00
Vaibhav Gupta 5bdb7af43e refactor(model): read GGUF and safetensors fields via BinaryReader (#12318)
Route the 26 raw Buffer reads in GgufHeader and the 2 in
SafetensorsHeader through BinaryReader. Add u8, i8, i16, i32, i64,
f32 and f64 accessors to BinaryReader, with the same range checks as
u16/u32/word, since GGUF metadata stores signed and floating scalars.

Every migrated site reads an exact-size buffer from
ModelHeaderReader.take(), so outputs and errors are unchanged.
Shrink the raw-buffer-read baseline from 102 files / 711 sites to
100 / 683.

Refs #11865
2026-11-19 07:42:40 -05:00
morluto 96dae7de70 fix(node-sea): reserve framing for required blob fields (#12317) 2026-11-19 12:36:50 +00:00
vaibhav375andClaude Opus 5.5 c569982ef3 refactor(gpu): read GPU container fields through BinaryReader (#12313)
Move the CUDA fatbinary, Clang offload bundle, CCOB, AMDGPU metadata
and inventory reads in src/gpu onto BinaryReader and drop the four
files from the raw-buffer-read baseline. GpuSource.read already admits
every range, so refusals are unchanged.

Refs #11865

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 12:32:50 +00:00
ClarkandClark 7bc8a62c21 refactor(errors): inherit live cleanup ownership through shared domain helper (#12077)
Co-authored-by: Clark <301422770+clark970417-eng@users.noreply.github.com>
2026-11-19 07:31:26 -05:00
morluto 23ad8ce578 fix(nib): validate table extents before decode budgets (#12315) 2026-11-19 12:28:49 +00:00
morluto cffff06ee7 fix(apple): bound FAT disambiguation to plausible JVM classes (#12316) 2026-11-19 07:28:34 -05:00