* feat(native): identify Nim, Zig, GHC, OCaml and D toolchains
Add identify_native_toolchain, a static, read-only reader that reports
whether a local ELF, PE or thin or universal Mach-O image was built by
Nim, Zig, Haskell (GHC), OCaml or D, including stripped images without
a DWARF producer.
The reader searches a bounded part of the selected image for a fixed
table of runtime symbol names, runtime messages, mangled names, source
paths and producer strings, and returns each observed marker with its
file offset, section or segment, matched text and occurrence count.
Data sections are searched before bytes outside sections and before
instruction sections, so a bounded scan reaches strings first;
coverage reports the bytes examined.
The verdict is derived from the listed markers only: a language needs
two distinct markers, one strong. Conflicting, too few or no markers
give unknown, and a version is reported only when a marker states it.
* perf(native): order toolchain scan ranges in linear time
Intersect instruction sections with the bytes outside data sections in one pass, so an image with tens of thousands of sections does not take quadratic time before the scan starts.
* fix(native): bound stated toolchain versions and describe scan order
Track distinct versions per marker in a Set and list at most eight,
counting the rest in versions_omitted, so an image with many version
strings costs constant time per match and a bounded result. A candidate
reports a version only when exactly one was stated.
Describe max_scan_bytes and examined_bytes as a total in scan order
rather than a prefix from the image start, and place the chunk-boundary
test's marker across an actual read boundary.
* fix(native): keep every stated toolchain version in the report
* fix(native): bound stated toolchain version bytes before keeping them
* feat(native): make the stated version budget a per-call control
* fix(native): give no larger-limit retry once a toolchain control is at its maximum
* fix(native): do not match toolchain markers on truncated runs
* fix(native): keep exact markers on a final run at the image end
* style(native): format the toolchain changes
---------
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
Two cleanup-retry cases rewrote the 21-byte source with another 21-byte
string. File identity compares stat fields, so on file systems whose
timestamps advance in coarse ticks, such as ext4, a rewrite in the same tick
kept the identity. The case that also fails descriptor close then expected
AnalysisArtifactChangedError and received the reader failure. Writing a
different size makes the mutation visible regardless of timestamp
resolution.
Co-authored-by: gensokyo-dev <gensokyo-dev@users.noreply.github.com>
Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
The FAT fixture now ends with its last slice, so shifting that slice by
one byte would run past the file and fail as truncated before the
alignment check. The case adds the byte it needs, like the matching
load-command reader test.
Refs #15534
* fix(packages): report the declared ZIP entry total in entry-count refusals
inspect_vsix_package and inspect_nuget_nupkg reported the stopping counter
(max_entries + 1) as the requirement, so retrying with it failed one entry
later each time. The end-of-central-directory record declares the total
before enumeration; zipDirectoryRecords now carries that total with each
record, and the VSIX, NuGet and artifact ZIP readers report it as the
requirement (artifact_limits.zip.member_count now reports required_value).
inspect_pe_imports said the image "declares" max + 1 descriptors or
functions. Those tables are null-terminated and declare no total, so the
refusal now says the count is above the allowance and leaves the total
unknown.
Refs #15608
* test(zip): cover the ZIP64 entry total in member-count refusals
* test: fix false-pass assertions, consolidate suites, and close coverage gaps
* test: finish signal-0, unchecked close_binary, and vacuous .every() audit
* test(registration): run shared capture inside test so child inherits scaled deadline
* test(artifacts): bind final verification fault to reader source and post-read phase
* test(providers): assert the specific refusal behind each bare toThrow
Replace bare toThrow() in adapter, artifact, parser and server tests with the errno code of a removed path or closed descriptor, the Zod issue path and code per case, the parse failure kind and message or reason per case, the cleanup retry failure and the resources it still holds, or the contract message each refusal reports.
* test(artifacts,ghidra): assert retained cleanup resources instead of their message
* test(artifacts): assert the keyed-archive truncation as its parse failure facts
* test(artifacts): assert exact refusal reasons, limits and cleanup reports
Replace ok:false-only, bare toThrow, class-only, expect.any and negative-only checks in parser and artifact tests with the exact failure kind, reason, limit, cleanup report, classification and retained samples the producers report.
* test(uefi): assert the receipt issue path through the retained cause
Inventory EVTX file, chunk and record headers with source-scoped identities, full timestamp precision and explicit partial coverage. Discover the reader from first-contact inspection.
Refs #9174.
* feat(artifacts): inventory Android super image metadata
Refs #14391
* fix(artifacts): preserve partial Android super metadata evidence
* fix(artifacts): recognize Android super PE overlays
Refs #14928
* fix(artifacts): reject an Android super device with no usable sector
A first usable sector at the device size was accepted, so extent checks
reported a different field. Keep stored copy failures to malformed,
truncated, and unsupported now that format failures include unrecognized.
* fix(artifacts): preserve Android super partial evidence on budget exhaustion
* fix(mcp): preserve existing provider partial observation contracts
---------
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
* fix(native): keep inspect_macho usable when dyld_info rejects the chained-fixups segment count
dyld_info exits 1 with 'chained fixups, seg_count does not match number
of segments' for every report on Docker Desktop 4.87's backend, whose
trailing __DWARF segment is not counted in dyld_chained_starts_in_image.
inspect_macho then failed as an unclassified execution_failure although
nm, dwarfdump and the load table still describe the slice. Admit this
refusal like the other slice refusals: imports are reported unavailable,
exports keep the nm observations, and the diagnostic is a limitation.
Fixes#15146
* test(native): cover the seg_count refusal on a chained-fixups trailing-__DWARF layout
Build the refused case from __TEXT, __LINKEDIT and a trailing __DWARF
segment with LC_DYLD_CHAINED_FIXUPS, and check that the chained import path
adds no nm call and no chained-table limitation. State the comment in terms
of the layout and the observed dyld_info reports.
* style(native): trim the seg_count refusal comments
* fix(xml): refuse element depth at the syntax check
saxes keeps one handler per event and walks the open-element stack on
every start tag. checkXmlSyntax now owns opentagstart and closetag, runs
every caller handler after the depth check, and refuses depth above 1024
as xml-element-depth. 1024 stays above the desktop XML view cap and the
plist nesting cap. This release adds no runtime override.
* fix(xml): keep the depth limit when package parsers read XML
XAR TOC, installer XML, Maven POM, and VSIX manifest parsing wrapped
every syntax failure as malformed or a node budget. A depth limit is
returned as the limit failure those callers already accept.
* test(xml): cover element depth past the syntax ceiling
A document one element past 1024 fails the syntax check, including a
XAR TOC that used to parse because a later opentagstart handler replaced
the depth guard. A sibling range after a branch at the ceiling still
matches.
* test(plist): keep nesting refusals inside the XML depth ceiling
Plist fixtures deeper than 1024 now fail at syntax, so the nesting-limit
cases sit on the deepest document the syntax check admits. One plist and
one keyed archive assert the syntax limit past that ceiling.
* fix(xml): type the depth guard as a saxes start tag
opentagstart emits a start tag, not the finished SaxesTagNS. The handler call failed typecheck on that assignment.
* fix(xml): report element depth from the package providers
A VSIX manifest or Maven POM past the syntax ceiling is an XML limit. Those providers only translated their own format, so the refusal became an I/O error.
* fix(xml): report element depth as a fixed allowance
* fix(firmware): report SVD element depth as the XML ceiling
* fix(nuget): preserve XML element depth on package XML
* fix(capture): preserve XML element depth in SAZ metadata
* style(nuget): format the package fixture
* fix(plist): report XML element depth from native inspection
* fix(pkg): carry the XML depth allowance through a deep TOC
* test(plist): narrow the XML depth refusal before projection
The native depth failure is an analysis error. Project it after that check.
* fix(macho): separate chained bind addends from import names
dyld_info prints a nonzero chained bind addend as a +0x suffix on the
import name, so rows such as __ZTVN10__cxxabiv117__class_type_infoE+0x10
were reported with name null and name_status "ambiguous". When the slice's
chained-fixup import table names the row's ordinal, a row that is that
name plus a hex suffix now reports the exact name and the suffix as
addend. A row equal to the table name keeps a literal suffix, and rows the
table does not settle stay ambiguous with the full expression in raw_name.
* fix(macho): take only dyld's 0x addend prefix and either ordinal spacing
An addend after the import-table name is accepted only with the lowercase
0x prefix dyld_info prints, so a +0X suffix stays ambiguous instead of
yielding an addend that fails the hex address schema. The arm64e CLI test
accepts one or two spaces after the ordinal, as the parser does.
---------
Co-authored-by: Akshat <akshatg9536@gmail.com>
* fix(native): report ivar layouts that a Swift initializer assigns at load as unknown
A Swift class whose field layout is not fixed at compile time, for
example one holding an @Observable registrar or another resilient type,
sets RO_HAS_SWIFT_INITIALIZER in its class_ro_t. Swift stores 0 as the
placeholder offset of each field without a fixed offset, and size 0 and
alignment 1 for a field type without a fixed layout. The metadata
initializer writes the real values at load. inspect_native_dispatch_metadata
reported those placeholders as decoded offsets and sizes.
In such a class, a stored offset of 0 is now a null offset, and a
stored size of 0 nulls size, alignment and type encoding, which the
initializer replaces together. The row is partial with
ivar_layout_assigned_at_load. Classes without the flag keep their stored
values, including a genuine zero offset. The reader profile becomes
apple-metadata-reader-6 so earlier snapshots are not replayed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* docs(native): state that a zero-size Swift field has placeholder bytes
In a class with RO_HAS_SWIFT_INITIALIZER, Swift stores a field of a
zero-size type such as Void with offset 0, size 0 and alignment 1, the
same bytes as a field whose layout the initializer assigns at load.
ivar_t does not record the field's type, so its size stays unknown.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* fix(limits): report details.limit for ELF dependency, unwind, and kernel reader refusals
Attach structured `details.limit` metadata to per-call budget refusals across
the remaining `src/native/elf/` providers (`ElfDependenciesProvider`,
`KernelModuleProvider`, `KernelBuildConfigProvider`, and
`ElfUnwindRangesProvider`), following the `#14243` shared-budget pattern:
- Generalize `elfReadBudgetLimit` in `src/domain/native/elfReadBudgets.ts` so
ELF and kernel readers share one parameter-limit builder.
- Export `ELF_DEPENDENCIES_READ_BUDGETS`, `KERNEL_MODULE_READ_BUDGETS`,
`KERNEL_BUILD_CONFIG_READ_BUDGETS`, and `ELF_UNWIND_RANGES_READ_BUDGETS` from
their domain schemas so Zod input bounds and projected `details.limit`
metadata have a single owner.
- Report `details.limit` for caller-selected file, entry, inflation, and record
budgets, including `compressed_candidate_bytes` (`max_config_bytes`), while
moving `KernelBuildConfigProvider` file-size handling onto
`offlineArtifactFailureDialect.fileSize` and removing its unreachable
`capacity` branch.
- Report `ElfUnwindRangesProvider`'s fixed 16 MiB `symbol_name_text_bytes`
allowance through `fixedAllowanceOptions` with narrowing guidance and
`related: { parameters: ["limit", "offset"] }`, registered in
`scripts/verify/fixed-ceiling-registry.json` under `#14235`, rather than
reporting an inverted `details.limit`.
- Remove `ElfDependenciesProvider.ts`, `ElfUnwindRangesProvider.ts`, and
`KernelBuildConfigProvider.ts` from
`scripts/verify/untyped-budget-refusal-baseline.json`, clearing all
`src/native/elf/` entries from the baseline, and update
`docs/reference/rea-limit-inventory.md` and
`docs/reference/limits-and-recovery.md`.
Part of #14234
* test(elf): assert CLI details.limit and flags for kernel module budgets
* fix(elf): report required_value for KernelModuleProvider max_file_bytes and add MCP recovery test
resolveGotBase returned the first nonzero DT_PLTGOT, so a later row naming
another base, a table with no DT_NULL, or a table longer than the
4096-entry scan bound still produced a GOT base, and DW_EH_PE_datarel FDE
starts were reported with complete coverage. A PT_DYNAMIC outside the file
fell back to .got.plt or .got instead.
The table is now read through the shared dynamic-table walker. A base is
used only when the rows are read through DT_NULL and every nonzero
DT_PLTGOT agrees; rows after DT_NULL are ignored. Otherwise, or when the
declared table lies outside the file, the base stays unknown and the
affected ranges are omitted with partial coverage. Independently decoded
FDEs remain.
Fixes#12446
Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
The unwind fixture can now declare its .dynamic rows in order, without an
implied DT_NULL, and a .got.plt section next to a DT_PLTGOT-only GOT, so
tests can build conflicting, unterminated or oversized dynamic tables.
Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>