mirror of
https://github.com/morluto/rea.git
synced 2026-11-30 16:18:26 +00:00
bcb38e2ae5eee0ffa79d61baa5981dc37e1fdd5c
37
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
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> |
||
|
|
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> |
||
|
|
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> |
||
|
|
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
|
||
|
|
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> |
||
|
|
395a6df911 |
feat(artifacts): inventory auditd logs offline (#12062)
* feat(artifacts): inventory auditd logs offline (#11345)
An acquired Linux audit.log can only be read today with ausearch or
aureport, which means letting a host tool interpret the file. Add a
read-only inventory that joins records on the full audit event identity:
timestamp seconds, milliseconds and serial, never the serial alone,
because auditd reuses serials across boots and on wraparound.
The first increment reports line, record and event totals, per-type
counts, the malformed line count with a bounded sample, and the duplicate,
out-of-order and interleaved records it found, with a bounded window of
events whose totals still cover the whole file. Record bodies are not
decoded yet: key-value fields, hex and escaped values, argument ordering
and decoded syscall or permission meanings are named as limitations, and
the reader treats the log as neither complete nor authentic.
An auditd log declares no members, so the inventory is attached to the
root occurrence and open() refuses every entry.
Verified: npm run check:fast (typecheck, lint, architecture guards) and
npm run docs:check pass; 89 tests across the new reader test, format
descriptors, target-format vocabularies, recognition, graph, snapshot and
subject suites pass. No built or packaged CLI/MCP workflow was run.
* style(auditd): format the auditd reader and its test
format:check failed on src/domain/linux/auditdLog.ts and its reader test in CI; applying oxfmt is the whole change.
* fix(auditd): key repeated records on the PATH item index
Repeated types were joined on items=, which is the path count on a SYSCALL record, not a per-record index. Every PATH record of a multi-path event therefore shared one key: the second path was reported as a duplicate and the per-event PATH count came out as one. Use item= instead, and cover a two-path event.
* fix(auditd): join events per host and bound retained state
Address the review on #12062:
- Include the node= prefix in the event join key. Timestamp plus serial is
only unique within one host, so a centralized log merged records from
different hosts into one event. The reported event_id carries the node.
- Bound retained event state to a window. Duplicate and interleaving
detection kept every PendingEvent for the whole file; records past the
window are counted in the totals and a limitation says their status is
not established.
- Pad the reported event timestamp millis to three digits so
audit(1700000000.005:12) no longer reads as 500 ms, while still joining a
padded record to an unpadded peer (via the numeric key).
- Detect duplicates per record content instead of record type plus item=,
so split EXECVE continuations are counted, not called duplicates.
- Re-check cancellation after the coverage callback resolves, so an abort
during the final await reports cancelled rather than success.
- Account for bytes dropped after a line overflows, so EOF trailing_bytes
covers the whole tail.
- Drop docs/specs/linux/auditd-log/, which conflicts with AGENTS.md.
* style(auditd): wrap the retained-window guard to the repo width
oxfmt --check failed on this line after
|
||
|
|
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 |
||
|
|
3a8a717b02 |
feat(ghidra): set function signatures and define the types they use (#14859)
* feat(ghidra): set function signatures and define the types they use annotate_native_function accepts an optional C prototype, applied with USER_DEFINED source in the same transaction as the name and comments, verified by readback and rolled back with them on refusal. define_native_data_types stores caller-authored struct, union, enum and typedef definitions atomically under /rea_caller_defined and refuses existing names. inspect_native_data_type reports those types with source caller-defined, and annotation readback reports the applied prototype and its source. Refs #14831 * feat(ghidra): bound caller C text with launch controls and refuse unapplied constructs The lengths of a signature and of type declarations and the nesting depth of parentheses are launch-only REA_ controls with measured defaults, floors and maxima, written into the bridge's session descriptor. A refusal names the control, its effective value, source and range. The bridge tokenizes caller C before Ghidra's parser sees it and refuses what that parser accepts without applying: attributes, storage-class specifiers, variable declarations, directives other than #pragma pack, literals, function bodies, default arguments, unnamed enums and repeated member names. A type name that names different types is refused. When a function has no calling convention and the prototype names none, the compiler specification's default convention, which Ghidra already uses to assign the locked storage, is recorded, and annotation readback reports the convention. Refs #14831 * fix(ghidra): apply the signature bound to the caller's text The bridge appended the semicolon its parser needs before checking the length, so a prototype of exactly the admitted length was refused. The readback prototype is documented as reusable only when its function and type names are C identifiers. Refs #14831 * chore(mcp): refresh advertised schema summaries for Ghidra type edits Refs #14831 * fix(ghidra): bound caller C text per call and report dropped qualifiers Ghidra's C parser cannot be cancelled, so REA bounds the text it parses. The three launch-only environment controls left an agent that hit them with a restart as its only recovery. The two length bounds are now per-call parameters, signature_max_utf16 on annotate_native_function and declarations_max_utf16 on define_native_data_types, with the same defaults and measured maxima. A refusal reports details.limit with control_kind "parameter" and required_value, the text's length, so the generated recovery names the value to pass or asks for shorter text. The text fields no longer carry a schema maximum, so every over-length refusal is typed. Parenthesis nesting is a fixed ceiling of 8 levels, registered as a representation bound, because each level doubles parse time. The session descriptor no longer carries C parser limits, and the config module, environment entries and restart-only registry rows are removed. const and volatile are still applied without effect, because Ghidra's types have no representation for them. Both edits now return dropped_qualifiers with each qualifier's line and column, and for a signature its parameter index, null for the return type, instead of dropping them silently. * fix(ghidra): read caller C through one tokenizer and bound nesting per call The C admission scan tracked lines only at LF and read directives as raw lines matched by a regular expression, so a CR-only line break shifted dropped-qualifier positions and a trailing comment on #pragma pack was refused. One tokenizer now owns caller C positions, comments and literals: CR, LF and CRLF each end a line as in Ghidra's parser, and directives are admitted from its tokens, so comments read as whitespace there too. A block comment that would carry a directive onto another line is refused. Parenthesis nesting was a fixed ceiling justified by parse time, a resource limit. It is now the per-call parenthesis_max_depth (default 8, range 1..12) on both type-edit tools. The bridge measures the deepest nesting over the whole text and sends it, with a text's length, as the wire failure's required_value, so details.limit reports the bridge's own measurement instead of the adapter re-reading the request. The tokenizer also decides whether a prototype is terminated, so the parser sees the caller's text unchanged: no leading whitespace is stripped, and a trailing line comment no longer swallows the appended terminator. * fix(ghidra): parse caller C inside the edit's rollback and refuse parser diagnostics Ghidra's C parser writes the type database even with storeDataType false: a definition whose name matches an existing empty composite fills that type in place, in the parser's own nested transaction. Both type edits parsed before opening their transaction, so a refused definition, such as one conflicting with a DWARF placeholder, left that placeholder filled. Parsing, validation and storage now share the edit's one transaction, and parseCallerC refuses to run outside one. The parser also records diagnostics it cannot apply, such as a repeated enumerator it drops, and still reports success. Both edits now refuse any diagnostic with Ghidra's message, before anything is stored. The real-Ghidra verifier gains a phase with an ELF object whose DWARF declares an opaque struct, proving a refused definition leaves that empty composite unchanged, and refuses a repeated enumerator. * fix(ghidra): admit caller C from one audited table of tokens Ghidra drops Review kept finding one more construct Ghidra's C parser consumes without applying, because admission listed spellings piecemeal. The tokenizer now owns one table, audited against every token and production of Ghidra 12.2's C.jj and checked on Ghidra 12.2, in that grammar's own spellings: - Refused, because meaning is lost: __ptr32 and __ptr64 (stored as a native-width pointer), __near and __far, every attribute, declspec, __readableTo, alignas, packed and asm spelling, [[...]] attributes, storage and inline specifiers including __forceinline, __pragma and _Pragma, _Static_assert, Objective-C @ blocks (Ghidra skips their whole text), and backslashes. - Reported in dropped_qualifiers as pure qualifiers: every const and volatile spelling, restrict, __unaligned and __w64. #pragma pack is admitted only in the operand forms Ghidra applies as written with a decimal value; (0x1), (010), (show) and (pop, n) were ignored or read differently, and "# pragma" is a line marker Ghidra skips. An enum tag that neither the text nor the database defines made Ghidra invent an empty enum without a diagnostic; declarations now refuse it as they do an invented struct or union. Identifiers admit $, as C.jj's do, and the tokenizer reads numbers and [[ as single tokens. * fix(ghidra): bound caller type depth, admit only constant expressions Ghidra evaluates, refuse unmatched pack pops Recursion: the tokenizer's [[ lookahead re-entered next() for each "[", and the dependency walk recursed per pointer, array and member level. Both are iterative now. Ghidra 12.2's own data-type code recurses too: 1024 pointer or array levels resolve, 2048 exhaust the stack inside addDataType while its database lock is held, leaving the Program unable to save. Every parsed type's chain through pointers, arrays, typedefs and members, including existing database types, is now measured iteratively and refused beyond a fixed 256-level ceiling before Ghidra walks it. An unexpected StackOverflowError ends the session with a reason instead of being caught by the parser call, since Ghidra's lock may then be held. Constant expressions: Ghidra leaves names, casts, sizeof, floating and binary literals unevaluated and substitutes a default, so "MASK = FIRST << 4" was stored as 2, and it truncates values outside int. Enum values, array sizes and bit-field widths are admitted only as integer literals with arithmetic, shift, comparison, bitwise and logical operators, checked iteratively with C's rules to stay in int, including implicit enumerator values; anything else is refused at its position. Pragma pack: Ghidra ignores a bare (push), a pop with nothing pushed keeps the current packing, and a plain pop pops past labelled entries. The tokenizer tracks admitted pushes and admits a pop only when Ghidra's result matches C's. * fix(ghidra): admit constant expressions only as one literal, skip absent pointer targets, state the type-depth recovery truthfully Constant expressions: emulating C against Ghidra's own evaluator is an open-ended class of mismatches (comparisons, unsigned arithmetic such as ~0U >> 1 giving -1, names, casts, truncation). The evaluator is removed. Enum values, array sizes and bit-field widths are admitted only as one decimal or hex integer literal within int, optionally negated, without suffixes; anything else is refused at the first token that leaves that form, and the refusal says to write the computed value. Implicit enumerator values are still checked against int. Dependency walk: Ghidra's generic pointer has a null pointed-to type, and pushing it onto the ArrayDeque threw. Both the dependency and depth walks now take children from one cTypeChildren and skip an absent child. Type depth: the depth is measured over the whole chain before comparing it with the limit, so the refusal reports the depth it used, and it names the type from the parser's table rather than walking the type for a name. The recovery no longer suggests splitting into named types, which cannot help because depth counts through typedefs and existing types; it says only fewer nested levels do. * refactor(ghidra): refuse parentheses in definitions and keep parenthesis_max_depth on signatures only Under the literal-only rule for constant expressions, every parenthesis in a define_native_data_types text already ended in a refusal (function declarators, attributes, casts, sizeof, or a Ghidra diagnostic for a grouped declarator), so parenthesis_max_depth changed only which refusal a caller saw. A definition now refuses its first parenthesis at its position, and the parameter is removed from that tool's schema; it stays on annotate_native_function, whose prototype has a parameter list. * fix(ghidra): refuse distinct types that share one parser name Ghidra keeps struct tags, enum tags and typedefs in separate maps. Combining those maps dropped a typedef such as typedef int item when struct item was also defined, and the call still succeeded. Overlapping names are stored only when the definitions are equivalent, which keeps typedef struct s { ... } s as one struct. Any other overlap is refused with conflicting_type_definitions before the transaction stores anything. Co-authored-by: morluto <morluto@users.noreply.github.com> * fix(ghidra): roll back a composite the parser fills in place Ghidra's parser replaces an empty composite during parsing and returns that same object. A later same-path check would store the fill as unchanged. Record those empty composites before parsing and refuse if parsing fills one, so the open transaction restores them. A different layout of a non-empty caller type still conflicts and leaves the stored type in place. Co-authored-by: morluto <morluto@users.noreply.github.com> * fix(ghidra): close line comments at EOF and refuse overflowing pack values Ghidra's // skip token requires a line break, so a comment at the end of declarations or of an already-terminated signature was rejected. A newline is appended whenever the text ends in a line comment, before any semicolon added for an unterminated prototype. Integer.parseInt drops a pack operand outside a Java int and leaves the previous packing, so #pragma pack(2147483648) stored a natural layout. Decimal pack operands are admitted only when that parse succeeds. Co-authored-by: morluto <morluto@users.noreply.github.com> * test(ghidra): assert the empty-composite refusal by code and readback Defining a struct over the DWARF placeholder fills that empty composite during parsing, so the refusal is data_type_conflict before the old name-conflict message. The verifier checks that code and that the placeholder still has no fields. 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> |
||
|
|
0f5ab1e042 |
feat(artifacts): inspect Debian package control metadata and contents (#10689)
* feat(artifacts): inspect Debian package control metadata and contents * fix(deb): throw ParseFailureError and record the new tool's schema counts DebPackageFormatFailure now extends ParseFailureError, as the architecture guard requires of parser failure classes; its kind, partial and message are unchanged. The advertised-dialect baseline takes the counts the inspect_deb_package input schema adds ($schema in both profiles, and allOf, default, examples, the \/ escape, the unanchored path pattern and untyped nodes in the full profile). * docs(deb): say dpkg runs maintainer scripts, not dpkg-deb dpkg-deb only reads the archive; installing with dpkg is what runs the maintainer scripts. Correct the spec so the safety rationale names the right tool. * refactor(deb): project format failures through parseFailureAnalysisError The provider now maps DebPackageFormatFailure with the shared parseFailureAnalysisError instead of its own instanceof ladder, passing the partial ar/control/data observation as diagnostics. The helper takes that optional diagnostics argument. DebPackageCapacityFailure extends ParseFailureError<"limit"> with the resource and maximum as its limit, and the provider keeps its limit recovery. * test(deb): resolve inspect_deb_package from its contract family The CLI acceptance and MCP boundary tests now take the contract from DEB_PACKAGE_TOOL_CONTRACTS instead of the full catalog, as the testing guide asks of focused contract tests. * fix(deb): require debian-binary and a control file for complete coverage Coverage was complete with a missing or empty debian-binary, or a control.tar that held no control file. It now needs a known format version and the control file as well as the control and data members, and each gap adds a limitation. * fix(deb): count hardlinks in the md5sums path cross-check dpkg lists every name of a hardlinked file in md5sums, while tar stores the later names as hardlink entries. The cross-check inventory now takes hardlink paths as well as regular files, so those names are no longer counted missing. * fix(deb): decode xz only when its index declares a size within the limit The sync @napi-rs/lzma decoder takes no output bound, so a member whose index could not be read was decoded with no limit and checked only after allocation. decodeXz now refuses such a member, as truncated when the footer is missing and malformed otherwise, before calling the decoder. * fix(deb): leave the md5sums cross-check unknown when an input is unread md5sums that is not UTF-8 counted as zero listed paths, and a package with no data.tar counted as an empty inventory. The cross-check is now computed only when both were read; otherwise it stays null and a limitation says which input was missing. * fix(deb): refuse Version and Installed-Size values the output schema rejects A Version with an empty upstream part or Debian revision (1:, 1:-1, 1.0-) and an Installed-Size past the safe integer range reached DebControl and failed the output schema, so the service lost the report. The parser now records a malformed field issue and leaves the value null. * build(deb): declare src/deb as a provider module layer Main now requires every top-level src unit in UNIT_LAYERS. src/deb is a provider like src/sqlite, and its two type imports of application ports are recorded in the upward-import baseline the same way. The xz spy binding now accepts the string or bytes input XzApi.compressSync takes. * fix(deb): keep tar names and link targets as stored Read ustar name, prefix and linkname fields, and GNU long names, as NUL-terminated UTF-8 without trimming or rewriting backslashes, and keep spaces in md5sums paths. A name that is not UTF-8 is shown with U+FFFD replacements and counted in a limitation, since it may not match md5sums. * fix(deb): read control files from the control.tar root only Look up control, conffiles, md5sums and maintainer scripts by their normalized root path, so a nested subdir/control or subdir/postinst no longer stands in for the root file. * fix(deb): read PAX records by byte length PAX record lengths count bytes, so walk the extended header bytes and decode each record on its own. A UTF-8 path no longer swallows part of the next record. A path or linkpath record that is not UTF-8 is counted in the same not-UTF-8 limitation as ustar names. * fix(deb): keep unreadable relationship alternatives as issues Accept hyphenated architecture qualifiers such as kfreebsd-amd64, and have parseDebianRelationshipField return the alternatives it cannot read. parseControl records each as a malformed issue on its field, so the package reports partial coverage instead of dropping a dependency. * fix(deb): deliver the whole partial report on a refusal A Debian package refusal now carries the bounded partial report as diagnostics.partial, so control facts, relationships, maintainer-script facts, ar member offsets and file rows read before the failure reach CLI and MCP callers, not just member names and a count. * fix(deb): decode only the maintainer script interpreter line interpreterLine now finds the first newline in the script bytes and decodes only the #! line, so non-UTF-8 bytes later in the script, or a cut through a multi-byte character at byte 256, no longer hide a valid interpreter. * fix(deb): bound unreadable relationship diagnostics per field parseDebianRelationshipField now counts unreadable alternatives and keeps only the first, and parseControl records one issue per field with that count and the first term cut to 120 characters, so a field of many `|` separators no longer grows the report with its input. * test(deb): check parser guidance through its owning formatters Export undecodableTarNamesLimitation and unreadableRelationshipsDetail from the parser and assert delivered limitations and issue details through them, so wording edits change one place. * fix(deb): bound PAX header work before each tar entry Keep only the path and linkpath PAX keys the reader uses, set in place rather than copying an accumulated object per header, and refuse more than eight GNU long name/link or PAX headers before one entry as malformed, so a run of short PAX headers cannot stall the server. * fix(deb): apply PAX owner records to the following entry PAX uid, gid, uname and gname now override the fixed ustar fields, which can hold shortened or fallback values. A uid or gid that is not a safe decimal integer falls back to the fixed field. * fix(deb): keep GNU ar string tables as counted members A // string-table member is now kept in the ar inventory and counted against max_ar_members like any other member. As an unknown role it is listed in extra_member_names, so coverage reports partial. * fix(deb): honor PAX size records and escaped md5sums names - A PAX size record overrides the next entry's ustar size field. Reading and skipping by the header field reported an empty file and then parsed its data as a header, refusing a valid archive. - GNU md5sum writes a leading backslash and escapes names that contain a backslash, newline or carriage return. Those lines were dropped, so the cross-check counted listed files as missing; they are now read, and lines that are not digest lines are counted in a limitation. * fix(deb): bound relationship alternatives and read PAX headers faithfully - Count relationship alternatives across the control file before building any, refusing more than a fixed 65,536; a field of '|' separators within the control budget could build millions of report objects. - Refuse a PAX extended header whose record length is unreadable or runs past the member, instead of using the fields read so far. - Keep global (g) PAX values for every later entry and per-file (x) values for the next entry only; global values were cleared after the first file. * refactor(deb): drop an unused import * chore(mcp): drop the dialect baseline main retired in #10693 * fix(analysis-view): call completeWithinViewCoverage with main's single count Main dropped its redundant second argument; both arguments were the same count here. * test(mcp): record this PR's advertised-schema summary Add the advertised-schema summary for inspect_deb_package, generated with npm run verify:advertised-schemas -- --update-summary. * fix(deb): bound repeated global PAX text and accept xz stream padding A global PAX path, linkpath, uname or gname is copied into every later row, so each reuse is now charged to the member byte budget (max_data_bytes or max_control_bytes) and refused before the row is added. An empty global PAX value now deletes the earlier global override, so later entries read their header owner again. xzUncompressedSize and the footer check skip trailing zero Stream Padding in 4-byte groups before locating the footer, so valid padded xz members are no longer reported as truncated. * fix(deb): trim trailing tar path slashes with a backward scan The unanchored /\/+$/u retried from every slash, so a PAX path or md5sums name made of a long slash run and a final non-slash took quadratic time. logicalTarPath now trims trailing slashes with a linear charCodeAt scan from the end. * fix(deb): parse global PAX owner ids once per global record Global uid and gid values were run through paxId for every later entry, and the repeated-text budget skips numeric keys, so a long global owner value was rescanned once per row. Parse them when the global record is read and reuse the numbers. * refactor(deb): report coverage with the shared coverage status schema * refactor(deb): classify provider failures through classifyProviderFailure * fix(deb): bound resolved ar member names before copying them GNU ar /N references can repeat one string-table entry without charging its text to any budget, and every resolved name is copied into the report and its Evidence. Refuse a BSD or GNU long name above 4096 bytes before it is read or sliced, so repeated references cannot expand a small table into large report text. * test(deb): register the debPackage capability conformance case debPackage is declared in CAPABILITY_DECLARATIONS but had no entry in PROVIDER_CAPABILITY_CONFORMANCE, so the conformance suite failed for it. Name the existing Debian package CLI acceptance test as its case. * fix(deb): flag repeated control and data members as extra Only the first debian-binary, control.tar*, and data.tar* member is read. A later member with the same role was neither decoded nor listed, so a package with an empty first data.tar and a populated second one reported complete coverage. Repeated members now land in extra_member_names with a limitation, which keeps coverage partial. * refactor(deb): use the shared excerpt and error message owners The architecture guards from main count a hand-written ellipsis cut in the relationship issue detail and two inline error-to-message copies. Use ellipsisExcerpt and errorMessage instead. * refactor(deb): move DebPackagePort to src/ports/deb The provider imported its port from the application layer, which needed an upward allowance in the module-layer baseline. Put the port beside the other provider ports and drop the allowance. * fix(deb): record only caller-selected budgets in Evidence Omitted inspect_deb_package budgets no longer appear in Evidence parameters as if the caller set them; only supplied fields are kept. * fix(deb): report fixed reader allowances as limits The ar member name, tar extension header, and relationship alternatives allowances stop inspection without showing the input is invalid. Report them as `limit` parse failures (DebPackageAllowanceFailure) with the partial report attached, and project them as resource_constraint with a fixed-allowance recovery instead of invalid_request. * fix(deb): refuse GNU ar long name references outside the string table A `/<offset>` reference past the end of the `//` string table, or one that lands on an empty entry, resolved to an empty member name. The report then failed debPackageSchema and callers got AnalysisOutputError with no file identity or partial facts. Check the offset and the resolved name, and refuse as a malformed DebPackageFormatFailure that carries the partial report. * fix(deb): align ar members by stored size and require padding Advance past each ar member using the stored header size, so a BSD #1/N extended name with odd length keeps the next header aligned. Refuse an odd-sized member whose padding byte is missing at end of file instead of reporting complete coverage for a truncated container. * fix(deb): trim NUL-terminated header fields in linear time Trim fixed-width ar and tar header fields at the first NUL with indexOf instead of a NUL-to-end regex, which retried from every NUL when a continuation line followed a NUL run. Control-field decimal parsing no longer applies header NUL trimming. * fix(deb): skip the tar path prefix on GNU headers GNU tar headers use the 345-499 region for atime, ctime and sparse data, not a POSIX path prefix. Only join the prefix when the header carries the POSIX "ustar\0" magic. * docs(readme): drop duplicated target tables in five translations The fa, ko, th, zh-TW and zh guides carried the target table twice. Restore each to upstream and add the single Debian packages row. * fix(deb): report oversized Zstandard windows as a fixed allowance A valid control or data zstd member can request a decoder window above the fixed 128 MiB ceiling. Node raises ZSTD_error_frameParameter_windowTooLarge, which the parser reported as malformed. Map it to a DebPackageAllowanceFailure naming the new zstd_window_bytes allowance, matching ZipArtifactReader. * fix(package): bundle XZ decoder binaries for every plugin host The plugin archive is produced on Linux x64, where npm ci drops other platforms' optional packages. The packaging step only restored the PTY binaries, so Codex plugin installs on macOS and Windows had no @napi-rs/lzma binding and valid XZ packages failed as unsupported. Derive the platform packages from the locked runtime tree instead: every optional dependency of a runtime package that targets darwin/linux/win32 on x64/arm64 is restored at its locked path with a verified integrity, and the packed archive is checked for each one. * fix(deb): keep only applied PAX keys while reading records parsePax stored every record's key before PAX_KEYS filtered them, so one extended header of many short records with distinct keys grew an object property per record before any entry limit ran. Records whose key is not one this reader applies are now read and dropped, and parsePax is covered directly in DebPackageParser.test.ts. * Address review feedback * Trim deb822 lines with linear scans The trailing-whitespace alternative of the shared trim expression retried from every position of a long interior whitespace run, so a package Description could take quadratic time. Scan from each end instead and cover a long tab and space run in a test. * fix(deb): read only the first control paragraph parseControl used the first paragraph of the control file, but deb822Paragraphs built a map for every paragraph first. A control file of many small paragraphs could allocate millions of maps within the decompressed-size budget. deb822Paragraphs now takes a paragraph limit and yields string lines lazily, and parseControl stops after the first paragraph. * fix(deb): report unreadable tar modes as null A tar header whose mode field is not octal was reported as mode 0000, which invents a permission the archive never stated. Report the mode as null and add a malformed issue for the member, so coverage is partial. * fix(deb): refuse GNU sparse tar entries GNU PAX sparse headers (GNU.sparse.*) rename the following entry to a synthetic GNUSparseFile path and store only mapped segments, so reading it as a regular file reported the wrong name and size and could miss md5sums cross-checks. Old GNU sparse (S) entries can also carry extension blocks their size field does not count. Refuse both as an unsupported format instead of reporting wrong file facts. * refactor: use shared artifact inspection for Debian packages * fix(deb): report per-call budget refusals as parameter limits * Address review feedback * Address review feedback * fix(deb): bound xz decoding, inherit global PAX size, and redact Homepage URLs * fix(deb): bound xz index preflight memory and preserve typed cancellation with partial facts * fix(deb): bound nested relationship lists, align tar stored-body rule, and scope async parse * fix(deb): walk actual XZ block boundaries, scan control lines without arrays, and guard XZ close gate * refactor(deb): avoid throwaway filter arrays in DebPackageParser --------- 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: Matt Van Horn <mvanhorn@MacBook-Pro-10.local> |
||
|
|
14b4d1f7ad |
feat(firmware): inventory and extract UBI image volumes offline (#13333)
* feat(firmware): inventory and extract UBI image volumes offline * docs: name ubi-volume among compared format metadata kinds The artifact comparison contract lists every format metadata kind that compare_artifacts compares. ubi-volume now carries a declaration, so the contract names it beside the other members. * fix(firmware): keep UBI LEB ranges private to the reader entries() yielded copyArtifactEntry(entry), which spreads the private volume field by reference, so a caller could rewrite volume.ranges and change the bytes the next open() read. Yield only the public entry fields, and test that a returned entry carries no volume mapping. * fix(firmware): keep LEB source ranges in ubi-volume metadata Saved Evidence now records the lnum, PEB, image offset and length of each chosen LEB, so a reassembled volume can be traced to its image bytes. The image summary keeps counts. * fix(firmware): reject smaller UBI eraseblock sizes whose LEB padding is invalid A dynamic LEB with data_size 0 and data_pad equal to a smaller candidate LEB passed the size check, so a valid aligned image was refused as ambiguous. Require data_pad below the candidate LEB, as classifyUbiPeb and the volume table alignment rule already do. * fix(ubi): refuse a UBI# file shorter than its erase-counter header recognizeUbiImage recognized any 4 to 63 byte file starting with UBI# without a CRC or version to check, so open_binary accepted it as an archive and inventory labelled it a container. It now takes the file size and refuses a file that cannot hold the 64-byte header. A short prefix read from a longer file still defers to the reader. * fix(ubi): refuse a volume whose only surviving LEB copy failed its CRC When both competing PEBs for a LEB are wear-leveling copies and both fail their data CRC, the older failed copy still won and open() served bytes that had already failed verification. Mark that LEB unverified and refuse the volume with extract refusal unverified_copy, keeping its inventory. * fix(ubi): refuse an image whose EC headers disagree instead of skipping them Eraseblock discovery and both spacing checks skipped a valid erase-counter header whose image_seq or layout differed from PEB 0, treating it as absent. Alternating sequences or a conflicting second header then measured a multiple of the real eraseblock size and read the image, so a volume became an extractable empty or header-polluted volume. Any valid header now begins an eraseblock, and classifyUbiPeb and checkUbiPebs refuse the disagreement. * fix(ubi): rule out a smaller eraseblock size whose volume table is invalid The ambiguity check declared a smaller eraseblock size equally valid from erased header positions and LEB fit alone. With 128 KiB eraseblocks, data_offset 4096 and a volume of alignment 6144, data_pad is 4096, but a 64 KiB LEB would need data_pad 0, so that size cannot describe the image and a valid image was refused. The check now also requires a volume table copy to stay valid under the smaller geometry, and runs after the table copies are read. * fix(ubi): compare the volume ID in a UBI volume declaration The compared ubi-volume declaration left out the volume ID. A volume renumbered from ID 0 to ID 1 keeps its path and reconstructed bytes, so artifact comparison reported it unchanged even though consumers that address volumes by number now see a different volume. The declaration now includes the ID, and PEB placement stays out of it. * fix(ubi): refuse a volume with no mapped LEB when PEBs are corrupt When a volume's only data PEB had a bad EC or VID header CRC, classification dropped its mapping and reassembly read the absence of surviving headers as an empty volume: a static volume got used_ebs 0, a dynamic one zero LEBs, and both were served as extractable empty files. A corrupt PEB may have held that data, so a volume with no mapped LEB in an image with corrupt PEBs is now inventoried but refused as lost_lebs, with used_ebs null and a named limitation. An image without corrupt PEBs still reads an unmapped volume as empty. * fix(ubi): accept EC headers in static LEB data no smaller eraseblock holds A static volume holding a nested UBI image with the same EC layout puts valid EC headers on a smaller grid inside its payload. With 128 KiB eraseblocks, data_offset 4096 and full 126976-byte static LEBs, the spacing check and the smaller-grid scan refused such a header as a geometry conflict, though ubiSmallerPebSizeHoldsLebs already rules out every smaller size those LEBs would have to fit. Both scans now run their verdict after the PEBs and volume table copies are read, and set aside a header at a position only ruled-out sizes would begin at. A spacing conflict still takes precedence over later failures, and a header where a smaller size stays possible, as under dynamic LEBs, is still refused. * Address review feedback * Address review feedback * Address review feedback * Address review feedback * fix(ubi-image): carry parser limit facts through reader refusals parseFailure now passes the named parser limit and a typed parser fixedAllowance when it wraps a UBI limit refusal, so the 16 MiB eraseblock size ceiling and the 262,144-eraseblock count ceiling reach CLI and MCP with reported_limits and the fixed-ceiling recovery. * fix(ubi-image): ignore nested EC headers no eraseblock could begin at The second-header scan now skips headers inside the data the first PEB's own VID header declares, so a static LEB holding a nested UBI image no longer measures the eraseblock at the nested header. The spacing check now counts only headers at positions an eligible smaller eraseblock (dividing the measured size, larger than data_offset) would begin at, and after the LEBs are read only the sizes they still admit. A dynamic LEB holding a nested image of small eraseblocks parses the same in PEB 2 as in PEB 5. * fix(ubi-image): read only the first VID header within the eraseblock ceiling The eraseblock search read every byte from offset 0 through the first PEB's declared vid_hdr_offset to find its VID header. A CRC-valid EC header could declare an offset of 1 GiB and make the reader allocate a buffer that size before the eraseblock ceiling refused the image. ubiFirstVidHeaderOffset now admits the VID header only when it lies inside the file and the fixed eraseblock ceiling, and the reader reads just those 64 bytes. A header past the ceiling is never read, so the search reaches its bounded eraseblock-size refusal as before. * fix(ubi-image): skip EC headers whose offset cannot be the eraseblock size A dynamic VID header declares data_size 0, so a first PEB holding a nested UBI image only rules out the nested header at data_offset. The next nested header, 6144 bytes into a 128 KiB eraseblock, was taken as the eraseblock size and the valid 524288-byte image was refused as not a multiple of it. The second-header search now skips headers at offsets that do not divide the file size, since no eraseblock size could put them there. The first header at any offset is still kept for the refusal when no size fits. * fix(ubi-image): reject truncated dumps with misleading PEB headers * Address review feedback * Address review feedback * Address review feedback * Keep undersized UBI candidates provisional on valid VID extents A CRC-valid VID header whose data_pad and data_size do not fit a candidate LEB now records the eraseblock size it needs. A dividing candidate smaller than that stays retryable, with its image kept as the fallback, so a later candidate that holds every LEB in full is accepted. * Address review feedback * Address review feedback * Exercise the UBI PEB count ceiling in memory * fix: reject unrelated UBI header conflicts * fix: verify static UBI payloads before retrying geometry * fix: bound UBI static payload CRC work across PEB size candidates * fix: repair UBI integration after merging main * Address review feedback * fix: let cancellation retire paused UBI volume streams * test: synchronize paused UBI volume cancellation * fix: preserve UBI read failures during cancellation * perf(ubi): count PEB states and extractable volumes in one pass Replace the per-state .filter(...).length scans in assembleUbiImage and summarizeUbiImage with single loops, per docs/development/tool-design.md. * Address review feedback * fix(firmware): close UBI geometry ambiguity and corrupt-PEB tail gaps * fix(firmware): verify erased UBI PEB bodies and validate layout VID headers * fix(firmware): defer and cache UBI erased-body scans and deduplicate stream check helper * fix(firmware): eliminate quadratic UBI erased-range scans and cache dynamic copy CRCs * test(firmware): assert UBI erased-range coalescing, walk steps, and elapsed time * perf(ubi): cache EC header scan across block-size retries * fix(ubi): bound EC header scan cache and stream past cap --------- Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com> Co-authored-by: Matt Van Horn <mvanhorn@MacBook-Pro-10.local> Co-authored-by: morluto <76467478+morluto@users.noreply.github.com> |
||
|
|
2c89136469 |
feat(artifacts): inspect VS Code extension packages offline (#12469)
* feat(artifacts): inspect VS Code extension packages offline REA had no owner for a local .vsix ZIP. inspect_vsix_package and inspect-vsix-package now read extension.vsixmanifest and extension/package.json, report identity disagreements, engine range, activation events, a contributes summary, hashed native/wasm/executable members, and a ZIP inventory without installing the extension or contacting a marketplace. Missing or malformed manifests return the inventory with limitations. Invalid ZIP input fails without partial success. Signature files are reported present or absent and are not verified. * fix(vsix): bound vsixmanifest XML nodes before building the tree A compressed extension.vsixmanifest within the 16 MiB byte budget can still expand into millions of XML nodes. Count nodes as a stream first, as the Maven POM reader does, and refuse the manifest with an xml_nodes limit before parseXmlDocument allocates its document. * fix(vsix): report the vsixmanifest node ceiling as a fixed allowance The xml_nodes limit is a fixed parser ceiling, not a caller budget, so the provider fell through to a generic memory refusal that implied more memory could help. Map it through fixedAllowanceOptions as the Maven provider does and cover the public error from the provider. * refactor(vsix): classify provider failures through the shared owner VsixPackageProvider kept its own chain for cancellation, identity, path, selected-file and cleanup failures. It now supplies a dialect to classifyProviderFailure with only the package's own refusals: its parse ceilings and budget recovery, format failures, fixed reader allowances and the max_file_bytes refusal. The held snapshot still supplies the completed identity for a parser failure after the read. * fix(vsix): report an empty contributes key instead of failing the report A package.json with an empty contributes key produced a key with an empty name, which the contract refuses, so the whole inventory was rejected. The empty key is now left out of contributes.keys and reported as a limitation. * fix(vsix): charge member decoding to one package-wide budget Each hashed member was read with a fresh per-member budget, so a small compressed package with thousands of members could make the parser decode several GiB. Member reads now draw on one artifactExpansionBudgetBytes budget for the package; once it is spent, remaining members stay in the inventory without a digest and a limitation names the spent budget. * fix(vsix): resolve dot segments in package.json entry points packageJsonEntryPath stripped only one leading ./, so a main such as ./out/./extension.js named extension/out/./extension.js and was reported absent even when extension/out/extension.js existed. Entry points now resolve . and .. segments under extension/; a path that climbs out of extension/ keeps its unresolved form and matches no member. * fix(vsix): resolve entry points with the loader's lookup rules An extension-less main such as ./out/extension was looked up as a literal ZIP name and reported absent although Node resolves it to extension/out/extension.js. main now tries Node's CommonJS file and directory suffixes, browser tries the .js the web extension host adds, and the reported path is the member found. * fix(vsix): resolve a directory main through its own package.json Node's directory lookup reads the directory's package.json main before falling back to index files, so an entry like main: ./out with out/package.json naming ./start.js now resolves as present. * Address review feedback * fix(vsix): report interesting member sizes past 4 GiB A ZIP64 member can declare an uncompressed size above 0xffffffff while the compressed package stays under max_file_bytes. The parser skips hashing it and reports the declared size, but interesting_members[].bytes used the 32-bit uint schema, so the service rejected the whole report. The field now takes any nonnegative integer, matching contents[].uncompressed_size. * fix(vsix): report a malformed directory package.json instead of its index When main names a directory whose package.json is not a JSON object, Node's loader throws ERR_INVALID_PACKAGE_CONFIG rather than falling back to index.js. Keep that outcome distinct from a manifest with no usable main: mark the entry point absent and add a limitation naming the member. * fix(vsix): classify Java archives as nested archives A bundled .jar, .war or .ear is a ZIP, but the path classifier returned unknown for it, so it was never hashed or counted as a nested archive. * fix(vsix): match entry points by exact member case Resolve main and browser entry points against exact ZIP member names, as a case-sensitive file system would, and report a member that matches only when case is ignored as a limitation instead of marking the entry present. The directory package.json used to resolve a directory main is matched exactly too. * fix(vsix): keep directory-only intent for a trailing-slash main A main such as "./out/", ".", "..", or one ending in "/." or "/.." can only name a directory under Node's loader. Normalizing it to a bare path let a sibling file like extension/out.js match and report the entry as present. Carry a directory-only flag from the raw value and skip file candidates in the declared-path lookup and in the check that decides whether to read <main>/package.json. * fix(vsix): only blame case when the spelling differs The case-only entry point warning scanned index candidates even when a malformed directory package.json had already stopped the main lookup, so an exact extension/out/index.js could be reported as a case mismatch. Skip index candidates when the directory manifest is malformed, and skip any candidate whose member is spelled exactly as declared. * fix(vsix): stop main lookup at an over-budget directory package.json When main names a directory whose package.json exceeds max_manifest_bytes, its main is unknown, so falling back to index.* could report a file Node would not load. Treat the unread manifest like a malformed one: report main unresolved, add a limitation that says the index files were not used, and skip the index files in the case-only scan. * fix(vsix): resolve a main that normalizes to the package root A main of ".", "./" or "./out/.." normalized to "extension/", so the directory lookups searched "extension//package.json" and "extension//index.js" and reported a present index file as absent. Return "extension" for the root so those lookups name real members. * fix(vsix): stop main lookup at an unread directory package.json An encrypted or duplicated directory package.json left the directory main unresolved as "none", so lookup fell through to index files even though the unread manifest may name another file or be invalid. Mark it unread and stop the lookup, as the over-budget branch already does. * test(vsix): tag the decode-budget regression long-running The package-wide decode budget test passed a fixed 60-second deadline, which also turned off coverage and CI deadline scaling. Use the long-running tag the testing guide prescribes instead. * fix(vsix): leave unread dependency declarations unknown A missing, encrypted, or malformed manifest reported its extension dependencies and extension pack as empty lists, so a declaration on the other side showed up as a disagreement. Report the unread side as null and only flag a disagreement when both manifests were read. * fix(vsix): look up entry points by their literal text package.json main, browser, and a directory package.json main were trimmed before lookup. A ZIP member name can begin or end with whitespace and Node does not trim the specifier, so "./out/start.js " was reported absent or matched the different "out/start.js" member. Use the declared text as written; only an empty string names nothing. * fix(vsix): keep activation events literal before eager classification VS Code matches activation events as exact strings, so "* " and "onStartupFinished " are not startup activations. The parser read activationEvents through the whitespace-trimming ID helper, which turned those values into "*" and "onStartupFinished" and reported them as eager. Read activation events with a literal helper that drops only empty strings and exact duplicates, and cover the padded values next to their exact-name controls. * fix(vsix): keep mode-executable members inventoried when unread A member with no recognized suffix but Unix execute bits was only classified after its magic was read. When the hash budget, the package decode budget, encryption, or traversal skipped that read, it stayed unknown and fell out of interesting_members and the executable count. Unread mode-executable members now keep an inferred executable kind. * fix(vsix): count a singleton contributes.commands object VS Code accepts contributes.commands as one command object as well as an array. Normalize the singleton form before capping and counting so a package with one command reports commands_total 1 and the commands key count matches. * fix(vsix): keep contributed command identifiers literal VS Code registers and invokes a contributed command by its exact identifier, and the parser already keeps onCommand activation events literal. Commands went through the trimming text helper, so a declared "demo.run " was reported as "demo.run" next to an "onCommand:demo.run " event, giving two different identities for the same command. Keep the declared command text as written and report null only for an empty string. Titles are display text and stay trimmed. * fix(vsix): do not infer executables from symlink modes A Unix symlink entry carries 0o120777, so its permission bits made an unread link look like an executable helper. Only regular files, or entries with no recorded file type, now count toward mode-inferred executables. * style(vsix): apply oxfmt to manifest limit guard * fix(vsix): keep mode-executable kind when read bytes have no known magic A suffixless regular Unix member with execute bits but no recognized magic (for example a shell helper without a shebang) was listed as an executable only when the hash budget skipped its read. Raising the budget enough to hash it resolved the kind to unknown and dropped it from interesting_members and the executable count. Fall back to the mode-derived executable kind when the read bytes match no magic. * fix(vsix): charge failed member expansions to the package budget A member whose ZIP header understates its uncompressed size can decode its whole allowance before the bounded writer refuses it. That work was not charged to the package-wide decode budget, so every later failing member got the same allowance again. Charge the allowance on a max_member_bytes failure so later members see the spent budget. * fix(vsix): bound JSON values before parsing manifests Both package.json readers called JSON.parse after a byte-only check, so a 16 MiB manifest of many tiny values could allocate far more memory than its text. A one-pass countJsonValues scan now runs first: an extension/package.json holding more than 1,048,576 values is refused with a fixed json_values parser allowance, and an over-allowance directory package.json is left unread with a limitation, so its index files are not used. * Address review feedback * fix(vsix): treat absolute directory package.json main as outside the package Node resolves a directory package main with path.resolve(dir, main), so an absolute main names a host file, never a package member. Report it as no main so the lookup falls back to index.* or reports the entry absent. * fix(vsix): tag escaped entry points instead of matching them as members A package.json main or browser that climbs out of extension/ was kept as an ordinary member path string. A traversal ZIP member with the same name (extension/../outside.js) is in the inventory, so the lookup reported the entry point present even though that member is never extracted. packageJsonEntryPath now returns a tagged resolved/escaped value. Escaped entry points skip the member, directory manifest and case-only lookups and are reported with present: false. * fix(vsix): decode directory package.json as UTF-8 like Node Node reads a nested package.json as UTF-8 only. A UTF-16 manifest fails with ERR_INVALID_PACKAGE_CONFIG, so report it malformed instead of transcoding it and marking main present. * fix(vsix): keep directory package.json main inside the extension root A directory package.json main such as ../../outside.js could pop the extension segment and resolve to an archive-root member, which was then reported as the present main entry point. Treat any main that climbs out of extension/ as naming no main, so the lookup falls back to index.* or reports the entry absent. * fix(vsix): keep a root directory main from matching archive-root files A nested package.json main such as ".." in extension/out resolves to the extension root itself. Trying file suffixes on that path matched an archive-root extension.js, which sits outside the installed payload. Mark such a main directoryOnly and resolve it through extension/index.* only, as Node does. * fix(vsix): skip member reads once the package decode budget is spent A compressed member declaring zero uncompressed bytes passed the declared-size check even with no package allowance left, so its decoder still ran and produced output before the writer rejected it. The failure then charged zero, letting each later zero-declared member decompress again past the package ceiling. Skip the read and report the spent budget once nothing remains. * fix(vsix): keep declared API proposal names literal Read enabledApiProposals with the literal list reader used for activation events. VS Code matches proposal names exactly, so trimming whitespace or splitting on commas reported identifiers the package never declared and collapsed declarations that differ only in surrounding whitespace. * fix(vsix): select manifests by their exact member path Count ZIP members by exact logical path. A package holding only extension/Package.json no longer has it parsed as extension/package.json, and a case-only sibling no longer marks the real lowercase manifest as a duplicate and drops its facts. Names that differ only in case, and a manifest present only under another case, are reported as their own limitations. * fix(vsix): treat shared libraries as interesting members Bundled .dll, .so (including versioned .so.N names) and .dylib files without Unix execute bits were classified unknown, so their magic was never read and they were missing from interesting_members and the summary count. Classify these suffixes as executable so they are hashed and listed like .exe and .node members. * refactor(vsix): run inspection through the shared artifact runner VsixPackageService now delegates input parsing, the provider call, output checks, Evidence creation and late cancellation to executeArtifactInspection, as NugetNupkgService does, keeping only the VSIX-specific report checks. * feat(vsix): point first-contact inspection of a .vsix to the VSIX reader inspect_artifact now suggests inspect_vsix_package when a ZIP holds a root extension.vsixmanifest file. The non-ZIP refusal test follows main's unsupported_target classification for malformed target bytes. * fix(vsix): align artifact failures with main * fix(vsix): bound inspect_vsix_package output with shared detail/summary contract * Address review feedback * fix(vsix): bound summary text fields and report structured parameter limits * fix(vsix): omit required_value on early-stop parameter limits * refactor(vsix): count eager activation events without intermediate array --------- Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com> Co-authored-by: Matt Van Horn <mvanhorn@MacBook-Pro-10.local> Co-authored-by: morluto <76467478+morluto@users.noreply.github.com> |
||
|
|
51b3671b08 |
feat(artifacts): inventory Nintendo DS ROM binaries, overlays and file tables offline (#14664)
* feat(artifacts): inventory Nintendo DS ROM binaries, overlays and file tables offline Recognition now claims a Nintendo DS ROM from the cartridge header: stored logo CRC 0xCF56, unit code 0, 2, or 3, an ARM9 offset after the header, and a matching logo-area or header CRC. Inspection records those header facts on the root and lists arm9.bin, arm7.bin, overlays/<cpu>/overlay_<id>.bin, FNT-named data/<path> files, and unnamed fat/<id>.bin files as stored byte ranges. A checksum mismatch, a partial table, or a range past the end of the file leaves coverage unknown. Secure-area encryption, compressed overlays, and NitroARC archives stay undecoded, and the format is registered for inventory, extraction, and the docs. * docs: move the Nintendo DS ROM guide under guides/firmware * Address review feedback * Address review feedback * Address review feedback * fix: Compare NDS entry addresses and overlay facts * fix(artifacts): bound NDS path expansion and enforce expanded_bytes * fix(artifacts): omit NDS format declaration for ordinary filesystem files --------- Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com> Co-authored-by: morluto <76467478+morluto@users.noreply.github.com> |
||
|
|
d97b796076 |
fix(dwarf)!: bound PE COFF section-name decoding with max_structure_bytes (#14787)
BREAKING CHANGE: Oversized individual PE COFF long section names in inspect_dwarf_units now project an adjustable_budget refusal (boundary max_structure_bytes with details.limit) instead of fixed_ceiling (pe-section-name-bytes). |
||
|
|
47875ba073 |
fix(native)!: bound Android packed relocations with max_structure_bytes (#14788)
BREAKING CHANGE: Oversized Android APS2 packed relocation tables in inspect_native_initializers now project a memory/adjustable_budget refusal (boundary max_structure_bytes with details.limit) instead of capacity/fixed_ceiling (native-index-capacity). |
||
|
|
192177f0c9 |
feat(artifacts): inventory and expand Android sparse images offline (#13244)
* feat(artifacts): inventory and expand Android sparse images offline * chore(schemas): update artifact tool schema summaries for the sparse image limit * fix(artifacts): retire undrained sparse image streams on cancellation * fix(artifacts): keep large RAW reads in the sparse stream's owner A large RAW run was streamed through a nested readFileHandleChunks Readable, which could prefetch a descriptor read while the outer iterator was idle, so close or cancellation could retire the stream with that read still running. Read the run directly in the expansion iterator so every read is pending in the owner that cancellation waits on, and add held-read close and cancellation regressions. * fix(firmware): drop unused ANDROID_SPARSE_MAGIC_BYTES export * test(artifacts): release held sparse reads before restoring mocks Release the held RAW read and join the retiring close or cancellation in finally before restoring the read spy, so a failed assertion cannot leave reader.close() waiting on a read nobody will finish. Use awaitAcknowledgement for the held-read start barrier and drop the per-test five-second timeouts in favor of the shared test deadlines. * fix(lint): register sparse-image forwarded fixed ceiling Upstream main added the fixed-ceiling registry check. The sparse-image reader projects the parser's own named ceiling, so register it as forwarding like the boot-image reader. * Address review feedback * test(android-sparse): expect partial code for chunk budget refusal * test(android-sparse): expect partial code in MCP chunk budget refusal * fix(artifacts): keep the chunk_sz offset when a RAW chunk outgrows its header --------- Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com> Co-authored-by: Matt Van Horn <mvanhorn@MacBook-Pro-10.local> |
||
|
|
155715942e |
fix(limits)!: budget Rust dependency parser ceilings per call (#14666)
* fix(limits)!: budget Rust dependency parser ceilings per call inspect_rust_binary refused a compressed .dep-v0 stream or its inflated JSON with one fixed parser allowance. Those ceilings are now the per-call parameters max_compressed_dependency_bytes (1 MiB), max_inflated_dependency_bytes (8 MiB) and max_dependency_inflate_ratio (64). A refusal is adjustable_budget and names the parameter that stopped the parse. Allocation before the consumed length is known uses the stored extent, including PE alignment padding. Omitted fields keep the previous defaults. BREAKING CHANGE: Rust dependency-parser refusals report details.limit for the binding parameter instead of a fixed_ceiling allowance. Co-authored-by: morluto <morluto@users.noreply.github.com> * test(rust): admit dependency sections above the former ceilings A stored section larger than 1 MiB and 8 MiB is refused at those defaults and parsed once both budgets are raised. A stream that inflates more than 64 times is refused at the default ratio and parsed once the ratio is raised. 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> |
||
|
|
0eb19a395e |
fix(limits)!: let apktool and assetutil take producer_limits.output_bytes and type Android and process capture refusals (#14624)
* fix(limits)!: let apktool and assetutil take producer_limits.output_bytes and type Android and process capture refusals decode_android_resources and inspect_asset_catalog refused larger apktool or assetutil output with a fixed capture ceiling. Both now accept producer_limits.output_bytes (defaults 4 MiB and 64 MiB) and report details.limit for it. assetutil's budget covers each stream and the JSON retained across catalogs, capped at 128 MiB for the in-process decode. capture_process's retained-frame refusal reports details.limit for limits.output_bytes, and a JADX JVM heap failure is marked as measured exhaustion. The lipo field-retention allowance is reclassified as derived from the native command output capture, and the JADX external DEX representation allowance as protocol (a fraction of the bridge's local MCP frame). BREAKING CHANGE: apktool and assetutil output refusals report details.limit for producer_limits.output_bytes instead of a fixed_ceiling refusal. * test(apktool): decode raised output after the default refuses it, and check deadlines leave the output budget unchanged * fix(resources): keep a file-size refusal's observed size through failure rebuilds |
||
|
|
4c9dca63a0 |
feat(native)!: give the Go and Rust readers max_structure_bytes and Rust max_wasm_sections (#14661)
* feat(native)!: give the Go and Rust readers max_structure_bytes and Rust max_wasm_sections inspect_go_binary and inspect_rust_binary read the ELF directory and Mach-O load commands through the shared container reader with the fixed 16 MiB structural allowance. Both now accept max_structure_bytes, threaded through readBinaryContainerFromReader. inspect_rust_binary's fixed 65,536-section WebAssembly walk becomes max_wasm_sections (default 65,536, at most 16,777,216). Refusals report details.limit and the generated recovery. The Go budget refusals drop their authored prose and always report their limit, so a value at its maximum gets the generated narrowing advice. Part of #14235. BREAKING CHANGE: Go and Rust structural refusals and the WebAssembly section refusal report details.limit instead of a fixed_ceiling refusal. * chore: refresh the Go and Rust advertised schema summaries * test: keep the Rust section-walk admission check type-correct * refactor(native): own the max_structure_bytes refusal in the native domain The Go and Rust providers may not import src/native, so nativeStructureConstraint moves to src/domain/native/nativeStructureBudget.ts next to the limit it builds, and every provider imports it from there. * fix(native): report the effective Go structure budget and document max_wasm_sections The Go limitation text named a fixed 16 MiB structural bound after a caller could raise it; it now names the effective max_structure_bytes. The Rust guide and MCP boundary test describe max_wasm_sections as a per-call control, and the admission test requires a raised value to succeed. * fix(native): report the effective Go structure budget and Rust section control Go inspection limitations named a fixed 16 MiB structural bound after max_structure_bytes selected another value. The report now uses that effective budget, including the shared default when the field is omitted. Rust WebAssembly section refusals are an adjustable max_wasm_sections budget. The MCP expectation, the Rust guide, and the CLI and MCP checks follow that control, and a raised budget must admit the same module. * style(rust): format the section-walk CLI assertion oxfmt rejects the wrapped cast in the CLI recovery check. Static checks run format:check, which check:fast does not. 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> |
||
|
|
0aca049128 |
feat(native)!: give the PE readers per-call text, entry and metadata budgets (#14659)
* feat(native)!: give the PE readers per-call text, entry and metadata budgets inspect_pe_imports refused at a fixed 16 MiB of retained names, inspect_pe_unwind_ranges at a fixed 2,097,152 exception-directory entries and inspect_pe_resources at a fixed 8 MiB result. They now accept max_text_bytes (default 16 MiB, at most 256 MiB), max_entries (default 2,097,152, at most 16,777,216) and max_metadata_bytes (default 8 MiB, at most 256 MiB). The DLL, function and TLS callback refusals report details.limit for max_dlls, max_functions and max_callbacks instead of authored recovery, and an unwind refusal reports the declared entry count as required_value. The shared PE failure projection no longer maps an unnamed BinaryResourceFailure to "The PE structural decoding allowance": no PE reader produces one, since PE header and section tables are bounded by the format. Part of #14234 and #14235. BREAKING CHANGE: the PE retained-text, exception-directory entry and resource metadata refusals report details.limit instead of a fixed_ceiling refusal. * fix(native): update PE advertised schema summaries, test types, and assert retry success * test: compare PE resource refusals across adapters with each adapter's control spelling * test: avoid shadowing the CLI fixture in the PE resources parity check |
||
|
|
4d3fa5a080 |
feat(native)!: give inspect_native_exports per-call inventory, text and structure budgets (#14658)
* feat(native)!: give inspect_native_exports per-call inventory, text and structure budgets The native export reader refused at a fixed 262,144-row inventory, a fixed 16 MiB retained-text allowance and the fixed 16 MiB structural allowance. It now accepts max_entries (rows and declared symbol counts; default 262,144, at most 4,194,304), max_text_bytes (default 16 MiB, at most 256 MiB) and max_structure_bytes, which now also bounds the ELF dynamic, symbol and version tables located through PT_DYNAMIC. The parser threads one NativeExportBudgets object through the ELF and PE paths and elfDynamicExportTables; the Android JNI reader keeps the defaults. Refusals report details.limit and the generated recovery. A declared table count is reported as required_value; the text budget stops at the first excess and reports none. Part of #14235. BREAKING CHANGE: export inventory and retained-text refusals report details.limit for max_entries or max_text_bytes instead of a fixed_ceiling refusal, and MAX_NATIVE_EXPORT_ROWS is renamed DEFAULT_NATIVE_EXPORT_ROWS. * chore: refresh the inspect_native_exports advertised schema summary * fix(native): omit lower-bound GNU hash required_value, decouple version work from max_entries, and update export recovery tests * test: expect the lower-bound marker on a stopped GNU hash chain walk * fix(native): cap ELF version traversal work and aggregate malformed version definition diagnostics |
||
|
|
1cc655bbc0 |
feat(native)!: give inspect_dwarf_units a per-call max_decompressed_bytes (#14660)
* feat(native)!: give inspect_dwarf_units a per-call max_decompressed_bytes inspect_dwarf_units refused at a fixed 256 MiB of decompressed DWARF sections for one image. It now accepts max_decompressed_bytes (default 256 MiB, at most 1 GiB) and reports details.limit; the sections decompress in turn, so the refusal reports no required_value. The ELF note text, hash and scan allowance is reclassified as derived: it equals the admitted image length plus its decoded section names. Part of #14235. BREAKING CHANGE: a DWARF decompression refusal reports details.limit for max_decompressed_bytes instead of a fixed_ceiling refusal. * fix(native): document DWARF decompression budget charges, update schema summary, and test raise-and-retry |
||
|
|
1badb6a8ae |
fix(native)!: report details.limit for remaining native reader budgets and make BEAM table rows adjustable (#14631)
* fix(native)!: report details.limit for native reader per-call budgets Devicetree, Windows shortcut, kernel build config, firmware staging and byte-entropy refusals of caller-selected budgets named their control only in remediation prose. Each now sets details.limit from a domain-owned budget object that also builds the schema (src/domain/parameterBudget.ts), so the reported range is the one the next call accepts. inspect_devicetree's fixed 32 MiB decoded representation allowance becomes the per-call max_decoded_bytes (default 32 MiB, 1 KiB to 256 MiB); its refusal reports boundary max_decoded_bytes instead of decoded_bytes. The pwntools allocation failure declares measuredExhaustion, the firmware inherited RLIMIT_FSIZE refusal declares measuredExhaustion, and the LLDB combined-result ceiling is a registered representation bound. Part of #14234 and #14235. BREAKING CHANGE: inspect_devicetree's decoded-representation refusal reports reported_limits.boundary "max_decoded_bytes" with details.limit, instead of "decoded_bytes". * fix(native): keep FIT decoded-budget boundary, LLDB narrowing and entropy length range exact The FIT reader compared the renamed devicetree limit against decoded_bytes, so a decoded-budget refusal became capacity; it now checks max_decoded_bytes, with a test. The LLDB representation ceiling keeps a short name and carries its recovery as narrowing. The byte-entropy length maximum is the window the selected block_size admits. * fix(cli): describe inspect-devicetree --max-decoded-bytes * refactor(native): let the generated adjustable-budget recovery name the native reader controls With #14625 the refusal owns per-call recovery, so the devicetree, Windows shortcut, kernel build config, firmware staging and byte-entropy refusals drop their authored sentences. inspect_byte_entropy reports the smallest admitting block_size as required_value. * fix(native)!: report details.limit for remaining native reader budgets and make BEAM table rows adjustable inspect_elf_dependencies, inspect_elf_unwind_ranges, inspect_apple_ips, inspect_dwarf_units, inspect_native_initializers and inspect_pe_resources named their per-call budgets only in remediation prose. Each now reports details.limit from a domain-owned budget object that also builds the schema. The unwind per-page symbol-name text refusal names the page size `limit`, the control that admits it. The fixed 65,536-row BEAM table ceiling becomes the per-call max_table_rows (default 65,536, at most 1,048,576). The plist nesting allowance is reclassified as a representation bound (MAX_JSON_DEPTH less the report envelope). GPU and APK input refusals that named their fixed allowances only in prose now declare them, registered as pending #14235. Part of #14234 and #14235. BREAKING CHANGE: a BEAM table-row refusal reports details.limit for max_table_rows instead of a fixed_ceiling refusal. * fix(native): keep naming the dependency and BEAM row controls in recovery * refactor(native): let the generated adjustable-budget recovery name the remaining native controls With #14625 the refusal owns per-call recovery, so the ELF dependency, ELF unwind, Apple IPS, DWARF, initializer, PE resource and BEAM refusals drop their authored sentences. BEAM reports the complete row and atom counts as required_value. The unwind per-page text allowance is a registered fixed allowance whose narrowing names a smaller limit, because a larger page would not admit it. * style: format the PE resources provider test * refactor(native): keep one owner of the IPS budget bounds and document the unwind text allowance |
||
|
|
50d13f9f08 |
fix(native)!: report details.limit for native reader per-call budgets (#14622)
* fix(native)!: report details.limit for native reader per-call budgets Devicetree, Windows shortcut, kernel build config, firmware staging and byte-entropy refusals of caller-selected budgets named their control only in remediation prose. Each now sets details.limit from a domain-owned budget object that also builds the schema (src/domain/parameterBudget.ts), so the reported range is the one the next call accepts. inspect_devicetree's fixed 32 MiB decoded representation allowance becomes the per-call max_decoded_bytes (default 32 MiB, 1 KiB to 256 MiB); its refusal reports boundary max_decoded_bytes instead of decoded_bytes. The pwntools allocation failure declares measuredExhaustion, the firmware inherited RLIMIT_FSIZE refusal declares measuredExhaustion, and the LLDB combined-result ceiling is a registered representation bound. Part of #14234 and #14235. BREAKING CHANGE: inspect_devicetree's decoded-representation refusal reports reported_limits.boundary "max_decoded_bytes" with details.limit, instead of "decoded_bytes". * fix(native): keep FIT decoded-budget boundary, LLDB narrowing and entropy length range exact The FIT reader compared the renamed devicetree limit against decoded_bytes, so a decoded-budget refusal became capacity; it now checks max_decoded_bytes, with a test. The LLDB representation ceiling keeps a short name and carries its recovery as narrowing. The byte-entropy length maximum is the window the selected block_size admits. * fix(cli): describe inspect-devicetree --max-decoded-bytes * refactor(native): let the generated adjustable-budget recovery name the native reader controls With #14625 the refusal owns per-call recovery, so the devicetree, Windows shortcut, kernel build config, firmware staging and byte-entropy refusals drop their authored sentences. inspect_byte_entropy reports the smallest admitting block_size as required_value. |
||
|
|
a5c71e8c88 |
fix(limits)!: let inspect_sqlite_database take producer_limits.input_bytes and type SQLite, Kuna and web-bundle refusals (#14627)
* fix(limits)!: let inspect_sqlite_database take producer_limits.input_bytes and type SQLite, Kuna and web-bundle refusals The SQLite snapshot refused a database and WAL above a fixed 256 MiB. The copy streams to private disk, so inspect_sqlite_database now accepts producer_limits.input_bytes (default 256 MiB) and reports details.limit for it. Refusals that carried recovery only in prose are typed: SQLite's result-column limit and the 16 MiB value/statement/reply allowance as fixed ceilings, occupied SQLite slots and live Kuna and web-bundle heap headroom as measured exhaustion, and the Kuna cache capacity as the REA_KUNA_CACHE_MAX_BYTES environment control. The SQLite worker diagnostic capture is reclassified as protocol. BREAKING CHANGE: the SQLite snapshot refusal reports details.limit for producer_limits.input_bytes, and the SQLite column and reply refusals carry a fixed_ceiling refusal in place of their authored remediation. * fix(sqlite): keep producer_limits in Evidence parameters and report the effective input bound |
||
|
|
9edc95c512 | refactor(elf): share note reader limit error projection (#14644) | ||
|
|
98d83d0787 |
feat(trace)!: give Playwright trace import per-call trace_limits (#14628)
* feat(trace)!: give Playwright trace import per-call trace_limits inspect_playwright_trace refused large ordinary traces at a fixed archive allowance, a fixed record nesting allowance and four authored-only budgets (decoded streams, retained facts, metadata reads, line bytes). It now accepts trace_limits (CLI --trace-limits JSON) with today's values as defaults, and each refusal reports details.limit. The record parser node allowance is derived from facts_bytes and recovers through it; nesting_depth is capped where a retained record still fits the Evidence JSON depth. The capture JSON parser takes the trace's depth from the caller instead of a format special case. The source-location view's page refusal now reports view.max_bytes in details.limit. GraphQL AST nesting is registered as a representation bound, and GraphQL host-limit, web-bundle host-capacity and the trace decoder's occupied slot declare measured exhaustion. BREAKING CHANGE: PlaywrightTracePort.inspect takes the resolved limits, and trace archive and nesting refusals report details.limit instead of a fixed_ceiling refusal. * fix(trace): project trace records at the selected depth and record trace_limits The HAR projection of a trace record read the network capture's depth (64 by default), so a record admitted under a raised trace_limits.nesting_depth was dropped as malformed. Projection now runs under the selected trace depth. Evidence parameters record the caller's trace_limits selection as given, in complete and partial results. |
||
|
|
e540cbdafd |
feat(native)!: give the native structural decoding allowance a per-call max_structure_bytes (#14626)
* feat(native)!: give the native structural decoding allowance a per-call max_structure_bytes The 16 MiB structural budget on native header, section, load-command and ELF dynamic-directory table reads, and on decoded section names, was a fixed ceiling with no override. inspect_elf_unwind_ranges, inspect_kernel_module, inspect_elf_debug_link, inspect_dwarf_units, inspect_binary_hardening and inspect_native_initializers now accept max_structure_bytes (64 bytes to 512 MiB, default 16 MiB) and report details.limit when it stops them. binaryContainer owns the default, the limit name and the failure (nativeStructureFailure); the directory readers take a NativeDirectoryBudgets object in place of the positional decoded-name budget, and Mach-O, the ELF dynamic directory and the ELF pointer relocation pass take the same budget. Other allowances that shared the "structure" limit name now carry their own: the PE per-name decode, the retained DWARF section bound (derived from the admitted image), and the hardening table-entry count. The ELF dependency provider's structural projection was unreachable and is removed. Part of #14235. BREAKING CHANGE: refusals at the structural budget report reported_limits.boundary "max_structure_bytes" instead of "structure". * fix(native): apply max_structure_bytes to the ELF hardening dynamic table and scope its help inspect_binary_hardening read PT_DYNAMIC under its entry count only, so a sectionless ELF could exceed the selected max_structure_bytes; the dynamic table is now checked first. The shared help no longer names tables a reader does not bound, and the limits reference states hardening's Mach-O and PE coverage. The initializer CLI recovery test asserts a parsed successful report. * fix(native): refuse a partial ELF hardening dynamic table as malformed before its budget |
||
|
|
4f66985978 |
feat(metadata)!: give NTFS, Maven report and NuGet budgets typed per-call controls (#14629)
* feat(metadata)!: give NTFS, Maven report and NuGet budgets typed per-call controls inspect_ntfs_journal refused acquisitions above a fixed 64 MiB allowance; it now takes max_file_bytes (default 64 MiB) and re-admits a retained acquisition under the call's budget, so lowering it cannot reuse a larger cached read. inspect_maven_gradle_metadata refused at six fixed report allowances; they are now report_limits fields (CLI --report-limits JSON) with today's values as defaults. Maven max_file_bytes and NuGet max_file_bytes, max_entries and max_nuspec_bytes refusals now report details.limit from the same bounds objects the schemas use. The Ghidra installation-properties read allowance is registered as a protocol bound: it reads the provider's own short installation descriptor, not analysis input. BREAKING CHANGE: NTFS and Maven report refusals report details.limit instead of a fixed_ceiling refusal, and parseMavenGradleMetadata and the inspect_ntfs_journal input contract gain the new controls. * fix(metadata): keep omitted NTFS budgets omitted and type host and maximum recovery inspect_ntfs_journal recorded the default max_file_bytes as if the caller had chosen it; the field is now optional and resolved for execution only, so Evidence keeps omission. A host allocation failure while holding an admitted acquisition is reported as measured memory exhaustion instead of generic I/O. A Maven report refusal whose need exceeds the control's maximum no longer suggests raising it. A public CLI/MCP test covers report_limits refusal and recovery for a POM. |
||
|
|
49e2eca4f9 |
feat(flutter)!: give Flutter APK admission per-call apk_limits (#14623)
* feat(flutter)!: give Flutter APK admission per-call apk_limits identify_flutter_build and inspect_dart_aot refused a large but ordinary APK at seven fixed allowances (APK snapshot, ZIP metadata, library read, cumulative extraction, ABI count, library path and snapshot-hash candidates) with no recovery. They now accept apk_limits (CLI --apk-limits JSON) with today's values as defaults. Each refusal reports details.limit naming the apk_limits field, its effective value and range. The domain owns one bounds object that feeds both the schema and the reported limit. library_path_bytes is capped by the 16-bit ZIP name field, and the inspect_dart_aot ABI selector length now follows that maximum instead of the old 1 KiB default. BREAKING CHANGE: Flutter size, inventory and candidate refusals report details.limit instead of a fixed_ceiling refusal, and the inspect_dart_aot abi selector admits labels up to 65,521 characters. * fix(flutter): bound library_path_bytes by the decoded ZIP name size Inventory counts a library path's decoded UTF-8 bytes, and one stored byte decodes to at most three (a CP437 box-drawing character), so the maximum is three times the 16-bit stored name length rather than the stored length itself. The ABI selector keeps its character bound from the stored name. Recovery tests now assert the reported facts after raising a limit. |
||
|
|
3dae567185 |
feat(artifacts)!: give Deno, wxapkg and tar readers artifact_limits controls (#14620)
* feat(artifacts)!: give Deno, wxapkg and tar readers artifact_limits controls Deno compile, wxapkg and tar readers refused large ordinary inputs at fixed allowances with no recovery. Their admission budgets are now per-call artifact_limits.deno, .wxapkg and .tar fields with today's values as defaults, and each refusal reports details.reader_limit. artifact_limits.expanded_bytes now also applies to Deno and wxapkg. The shared artifact path registry names its owning group's path_parts and path_nodes controls instead of a fixed fallback. audit_release_exposure max_file_bytes keeps its 256 MiB default but is no longer capped there; its refusal reports details.limit. The Deno VFS recursion depth is registered as a representation bound and the wxapkg member-I/O allowance as derived from expanded_bytes. BREAKING CHANGE: artifactReaderLimitsSchema now requires deno, wxapkg and tar groups, so saved Evidence whose effective_limits predates them fails validation and must be re-inspected. A release-exposure refusal at max_file_bytes reports details.limit instead of a fixed_ceiling refusal. * fix(artifacts): keep Deno indexed paths representable and omit undercounted retained size artifact_limits.deno.path_parts now has a minimum of 2: indexed fallbacks live under a reserved top-level namespace directory, so a one-part selection could only refuse the whole inspection. The retained-bytes refusal no longer reports a required value, because the bounded byte count stops at the allowance and understates it. |
||
|
|
33e4e07dd0 |
fix(limits)!: report packet and signal producer budgets as details.limit and page discovery at its record budget (#14621)
* fix(limits)!: report packet and signal producer budgets as details.limit and page discovery at its record budget Owned packet and signal producers (inspect_packet_capture, inspect_packet_fields, decode_signal_recording, inspect_signal_decoders) refused an exhausted producer_limits.input_bytes, output_bytes or command_timeout_ms with the control named only in remediation prose. ArtifactAnalysisResources now takes the selected input budget as an AnalysisParameterLimit and the command's selected and default budgets, so each refusal carries details.limit. Packet-field and sigrok decoder discovery refused a page whose records exceeded a fixed representation budget. The budget now ends the page early with has_more and output_window.record_budget_reached, so the rest is retrieved from offset + returned instead of being refused. BREAKING CHANGE: discovery output_window gains record_budget_reached, a page can return fewer than limit records, and discovery no longer refuses at the record or line budget. * test(verify): expect record_budget_reached in real discovery pages |
||
|
|
8e49a4f8b9 |
refactor(recordings): share producer failure classification (#14470)
* refactor(recordings): share producer failure classification * refactor(recordings): keep classification with the provider failure owner * refactor(recordings): keep catalog limits with their providers * refactor(process): remove the unused fixed command budget path (#14481) |
||
|
|
a85859e147 |
feat(pe): inspect x64 exception-directory function ranges (#14254)
* feat(pe): inspect x64 exception-directory function ranges Add inspect_pe_unwind_ranges, a provider-free reader of the PE32+ exception directory (.pdata). It reports each RUNTIME_FUNCTION's begin, end and unwind RVAs, whether the entry starts a function or is a chained fragment (UNW_FLAG_CHAININFO or an indirect unwind RVA), the chain's parent and primary entry, and empty, unsorted, overlapping, unmapped or unresolvable entries as explicit issues. Counts cover every entry while kind, offset and limit select the page. It reads headers through the shared PE image owner without changing its admission. Failures use the existing PE failure projection. Refs #14181 * chore(pe): record the unwind-ranges advertised schema and cursor skill * fix(pe): index chain parents, map the whole exception directory and keep high RVAs unsigned An unsorted table looked up every chain parent with a linear scan, and chain resolution did not yield, so a crafted table could stall the server. Parents are now found through one begin-RVA order and the pass yields to cancellation. The file-backed check covers every declared directory byte, including trailing bytes, and clearing the indirect bit keeps RVAs at or above 0x80000000 unsigned. * fix(pe): bound unwind reads and report unreadable codes, mismatched parents and unsorted overlaps Unwind data is visited in ascending RVA order, so the windowed reader moves forward and reads each region about once whatever the table order. A primary entry whose declared code array leaves the file-backed bytes is unknown (unwind_codes_unmapped), and its header facts are kept. A chain parent must match the whole RUNTIME_FUNCTION; an entry with the same begin but another end or unwind RVA is chain_parent_mismatch. Order and overlap are checked separately. The guide moves under docs/guides/native, and its route is unchanged. * fix(pe): index whole RUNTIME_FUNCTION records for chain parents Entries sharing a begin RVA were scanned for every parent lookup. The table is now ordered once by (begin, end, unwind), and a parent is a binary search for the exact record, with a second search for a begin mismatch. * test(pe): register the unwind-ranges provider lifecycle coverage The provider lifecycle registry needs one entry per provider id. Add rea-pe-unwind-ranges with its public CLI/MCP workflow and a typed resource and cancellation failure test. * test(cli): record inspect-pe-unwind-ranges in the completion goldens * fix(pe): keep a verified unwind report through cleanup failure and check the directory before its allowance A report completed before final close failed was replaced by the file hash. The provider now records the verified report and the shared PE failure projection retains it, as the ELF readers do. The entry allowance now applies only after the directory is shown file-backed, so an oversized count that leaves the file is a malformed target. * chore(pe): register the exception-directory entry allowance as a pending fixed ceiling |
||
|
|
225a19ae7a |
feat(artifacts): inventory and extract stored and gzip-compressed tar archives (#14245)
* feat(artifacts): inventory and extract stored and gzip-compressed tar archives Recognize POSIX ustar and GNU tar headers, plain or as the first block of a gzip member, as the new tar artifact format, so Linux release tarballs and Unity .unitypackage files inventory and extract like ZIP archives. The tar reader walks every header once, applying pax path, linkpath and size records, GNU long names and the ustar prefix. Regular files, directories and symlinks are occurrences with typeflag, mode, owner, mtime and link target; devices, FIFOs, hard links and sparse members are traversal omissions. Gzip members are read by forward decompression with an idle stream reused for in-order opens, and every decompressed byte is charged to artifact_limits.expanded_bytes. A later corrupt header, a truncated member or gzip stream, and non-zero bytes after the end marker keep the members read so far with unknown coverage and an explicit end_state; a first block with the ustar magic and a bad checksum is refused with that reason. Fixes #14177 * docs(compare): name tar-entry among the compared format metadata kinds * fix(tar): keep complete members and header facts across tar edge cases - Charge omitted devices, FIFOs and links to the retained-metadata allowance. - Probe a small gzip tar without verifying its trailer, and feed the final trailer to zlib separately so data before a bad CRC stays readable; queue decompressed output so a later failure cannot drop it. - Decode negative GNU base-256 numbers; only mtime may be negative. - Apply pending pax records only to the next member, never to extension headers, and let an empty pax value delete the keyword. - Push a member once its data is complete, then skip its padding. - Treat a cut-off zero block as truncation, not an end marker. - Stop with malformed partial coverage, not a refusal, when a later header declares an unsafe size. * fix(tar): charge gzip expansion as zlib produces it The decompressed-output queue charged the plaintext-work allowance only when the reader took a chunk, so bytes queued for an idle reader were not bounded by artifact_limits.expanded_bytes. Each chunk is now charged in the data handler before it is queued; an exhausted allowance stops the inflater, and the queued, already-charged bytes are served before the limit failure. * fix(tar): validate numeric pax records and probe gzip past its header fields - A pax size, uid, gid or mtime record that does not parse now stops the walk as malformed at that member, keeping earlier members, instead of silently falling back to the header field. - The gzip-wrapped tar probe skips the RFC 1952 FEXTRA, FNAME, FCOMMENT and FHCRC fields before applying its 2 KiB compressed-data bound, so a long name or comment no longer hides the archive. |
||
|
|
789ca04125 |
fix(pe)!: bound static readers by the bytes they read, not file size (#14262)
* fix(pe)!: share one loader-equivalent PE header owner across static readers Resources and certificates now admit headers through readPeImage, and resources map RVAs through the shared file-backed mapping. The owner reads the optional header at fixed offsets, caps data directories at 16, and lets a PE signature at e_lfanew override a DOS relocation table. Export, import, TLS and resource directories are read at their RVA whatever Size declares. Disregarded declarations are reported in header_anomalies. BREAKING CHANGE: import and delay-import walks continue to the null descriptor past a short directory Size instead of stopping with a malformed_entry issue, and inspect-pe-resources reports an unsupported optional-header magic as unsupported_target. * fix(pe): keep valid DOS relocation tables owning e_lfanew Only a relocation table that describes no DOS load module yields e_lfanew to a PE signature; update MZ/PE conformance to the shared owner. * fix(pe)!: bound static readers by the bytes they read, not file size max_file_bytes now counts the header prefix and every positional read of headers, directory tables and their referenced ranges. The identity pass that hashes the whole file is bounded only by a fixed whole-file ceiling: 4 GiB minus one byte for the PE-only readers, whose file offsets are 32-bit, and 512 MiB for hardening and exports. An exhausted allowance is a capacity refusal with a typed parameter details.limit. BREAKING CHANGE: max_file_bytes no longer refuses a large file whose reads fit; an exhausted read allowance reports resource capacity instead of file-size, and only a file above the fixed ceiling reports file-size. * fix(pe): walk resource trees within file-backed bytes and cite TLS reads The resource walk is bounded by the file-backed run from the directory RVA rather than its Size, and a Size that ends before the bytes walked is a directory_size_below_structure anomaly. The TLS result carries structure_location for the structure read past a short Size, and Evidence cites it. * test(pe): assert a refused read never reaches the descriptor * test(pe): use a resource cycle as damage now that a short Size is read * fix(pe): read resource trees past an oversized Size and keep damaged MZ headers malformed An oversized resource Size is reported without requiring its unused bytes to map. A Windows-header candidate is malformed when the DOS module is also invalid, and the guide states that a valid DOS relocation table owns e_lfanew. * feat(pe): report image_base and IAT slot VAs in static PE results (#14263) * feat(pe): report image_base and IAT slot VAs in static PE results Every static PE result reports the optional-header image_base once as a hex VA, and import rows add iat_va beside iat_rva so a slot goes straight to xrefs. Fields name their space as rva, va or file_offset; the new fields are optional so saved Evidence still parses, and the imports service rejects an iat_va that disagrees with image_base plus iat_rva. * fix(pe): document iat_va for rebased databases and test VA rejection iat_va is relative to the file's ImageBase; a rebased provider database needs its own base plus iat_rva. Cover the service rejection of a slot VA that disagrees with image_base plus iat_rva. * chore(pe): register the forwarded whole-file ceiling and shrink refusal baselines |
||
|
|
fd09e2b9a1 |
fix(limits)!: let inspect_pcap_capture take producer_limits for its snapshot and TShark output (#14280)
* fix(limits)!: let inspect_pcap_capture take producer_limits for its snapshot and TShark output inspect_pcap_capture kept private copies of the producer budgets that inspect_packet_capture already exposes. It now accepts producer_limits with input_bytes (the streamed capture snapshot, default 2 GiB) and output_bytes (each TShark JSON pass, default 8 MiB, at most the fixed 128 MiB decoded-JSON allowance). Refusals report details.limit for the parameter instead of a fixed ceiling. The decoded-JSON expansion and retained-fact allowances stay fixed because raising them needs a streaming decoder; the version and summary probe capture is reclassified as protocol. Part of #14237 BREAKING CHANGE: an inspect_pcap_capture refusal at the snapshot or TShark JSON budget reports details.limit for producer_limits.input_bytes or producer_limits.output_bytes and no longer carries details.refusal fixed_ceiling. * fix(limits): keep the DNS pass's producer limit and cover raised pcap budgets When only the DNS wire-identity pass exceeds producer_limits.output_bytes, the partial summary now records dns_identity_limit with the parameter, effective value, default and range. The pcap output budget is documented as combined stdout and stderr, as producer_limits.output_bytes is elsewhere. Acceptance covers TShark output above the old 8 MiB ceiling in both passes. |
||
|
|
6ab595cfd6 |
fix(limits)!: make the IL2CPP pointer index adjustable and require owned refusal limits (#14243)
* fix(limits): make the IL2CPP pointer index adjustable and name ELF note budgets in details.limit inspect_il2cpp_metadata accepts max_native_index_bytes (default 1 GiB, needs binary_path) for the estimated ELF virtual pointer index. The index refusal now carries its own limit name (virtual-pointer-index-bytes) and a details.limit naming the parameter, its effective value, default and range, instead of a fixed ceiling with no override. The binary file allowance and the loader's fixed capacities are unchanged. inspect_elf_notes and inspect_elf_debug_link refusals for max_file_bytes, the decoded section-name budget and max_entries now set details.limit. One domain-owned bounds object per operation feeds both the schema and the limit. Two guards keep new in-code refusal limits owned: - scripts/verify/fixed-ceilings.mjs (run by npm run lint) requires every fixedAllowanceOptions, fixedProducerInputAllowance, artifactFixedLimitFailure or inline fixedAllowance declaration to be listed in fixed-ceiling-registry.json with its class (format, protocol, representation, derived, forwarding, or pending with an issue) and reason, and fails on stale entries. - The untyped-budget-refusal architecture guard counts refusals whose only recovery is an authored remediationAction, with a shrink-only baseline. Fixes #14175 Part of #14234 BREAKING CHANGE: an inspect_il2cpp_metadata refusal at the ELF pointer index reports reported_limits.boundary "virtual-pointer-index-bytes" and details.limit for max_native_index_bytes, and no longer carries a details.refusal fixed_ceiling. * fix(limits): track IL2CPP's remaining fixed allowances with the native readers * fix(limits): run the authored-only refusal count from lint, where TypeScript is installed The architecture guards run before npm ci in CI and must stay dependency-free, so the AST-based count moves into fixed-ceilings.mjs with its own shrink-only baseline and --shrink-baselines. * fix(limits): register producer and native wrapper ceilings by the allowance they name fixedProducerInputAllowance names its allowance in its second argument, and fixedNativeAllowance forwards its first, so the guard now reads each helper's allowance argument and checks the callers of both. * fix(limits): delete the authored-only baseline when its last count is removed reconcileBaselineFile returns delete once no count remains, but the verifier ignored it and the next run read the file unconditionally, so --shrink-baselines could not finish. An absent baseline now reads as empty and shrinking removes the file. * fix(limits): record the advertised IL2CPP input schema with max_native_index_bytes |