Commit Graph
936 Commits
Author SHA1 Message Date
Eliran Zachandmorluto 73582aa342 feat(native): identify Nim, Zig, GHC, OCaml and D toolchains (#16252)
* 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>
2026-12-04 12:09:21 -05:00
Vincent Koc ffc1a1e24a refactor(macho): reuse formatted versions across report rows (#16708) 2026-12-04 19:47:47 +08:00
Vincent Koc 3f130ac90b refactor(elf): derive unwind records from the retained schema (#16693) 2026-12-04 18:51:20 +08:00
Vincent Koc 64f2e3e932 refactor(dwarf): derive the compile-unit draft from its schema (#16690) 2026-12-04 18:29:57 +08:00
Vincent Koc fdbcb29c0c test(elf): share ordered import name expectations (#16675) 2026-12-04 17:24:37 +08:00
Vincent Koc 65f18c4ca7 test(swift): share nominal declaration fixtures (#16659) 2026-12-04 16:54:37 +08:00
Vincent Koc f1a4d80a6e test(apple): share crash report diagnostic fixtures (#16643) 2026-12-04 15:50:02 +08:00
Vincent Koc 41c3963cff test(native): share ELF text initializer expectations (#16635) 2026-12-04 15:25:58 +08:00
Vincent Koc 26bbb443b1 test(macho): share chained fixup parser fixtures (#16612) 2026-12-04 14:21:11 +08:00
Vincent Koc 803ec4aca8 test(native): share empty Swift dispatch coverage fixtures (#16473) 2026-12-03 20:59:11 +00:00
Vincent Koc 1e6d47667e refactor(macho): share fixed-width name projection (#16443) 2026-12-03 19:10:28 +00:00
Vincent Koc 542c07ab98 refactor(plist): share projected scalar limitations (#16392) 2026-12-03 15:29:18 +00:00
Vincent Koc 958864a2ac test(swift): share relative pointer fixtures (#16308) 2026-12-03 10:24:53 +00:00
Vincent Koc f1c1787b8f refactor(elf): share kernel version report fields (#16286) 2026-12-03 08:28:57 +00:00
Vincent Koc eb779420bc test(dwarf): share compile-unit abbreviation fixtures (#16282) 2026-12-03 08:14:20 +00:00
Vincent Koc a52d543f73 refactor(pe): share import descriptor walking (#16225) 2026-12-03 04:57:56 +00:00
Vincent Koc 3ad95af7fa refactor(lnk): share LinkInfo block validation (#16219) 2026-12-03 04:25:29 +00:00
Vincent Koc 56f9215346 refactor(elf): share empty debug-link build ID records (#16135) 2026-12-02 23:12:02 +00:00
Vincent Koc 7fe0c023c2 refactor(elf): share GNU version record accounting (#16133) 2026-12-02 23:00:38 +00:00
Vincent Koc cadaa428b8 test(swift): reuse witness table fixture maps (#16055) 2026-12-02 17:25:45 +00:00
Vincent Koc 65b4706819 test(native): share Objective-C dispatch projection fixtures (#15892) 2026-12-02 11:33:36 +00:00
Vincent Koc 0ca5e5733e refactor(native): reuse prefix-backed hardening reads (#15882) 2026-12-02 10:42:55 +00:00
044f3309a8 test(native): change the Mach-O source size when simulating a mutation (#15798)
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>
2026-12-02 14:08:05 +08:00
Anurag Singh 0bfff49176 test(native): give the unaligned FAT slice case its spare byte explicitly
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
2026-12-02 13:41:41 +08:00
Vincent Koc 8f8a8539fc refactor(text): share unpaired surrogate checks (#15770) 2026-12-02 03:59:29 +00:00
Vincent Koc b5bcc214bd refactor(swift): share Objective-C conformance reads (#15760) 2026-12-02 03:14:08 +00:00
Vincent Koc 160df1cda3 refactor(elf): share unwind-header result assembly (#15735) 2026-12-02 02:16:45 +00:00
Vincent Koc 34548945c5 refactor(apple-ips): share lossless JSON container parsing (#15730) 2026-12-02 01:58:17 +00:00
Vincent Koc 86239c716b refactor(elf): reuse debug section location outcomes (#15655) 2026-12-01 22:50:54 +00:00
morluto 0f1bedc65a fix(packages): report the declared ZIP entry total in entry-count refusals (#15634)
* 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
2026-12-01 16:35:49 -05:00
Vincent Koc c3dbd0f1e4 test(fixtures): share unsigned LEB128 encoding (#15630) 2026-12-01 21:20:18 +00:00
Vincent Koc 7c02d53b1f test(dos): share padded MZ image fixture (#15575) 2026-12-01 18:27:39 +00:00
morluto a69837647b test: fix false-pass assertions, consolidate suites, and close coverage gaps (#15519)
* 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
2026-12-01 18:10:12 +00:00
morluto 9fabd0323f test(providers): assert the specific refusal behind each bare toThrow (#15528)
* 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
2026-12-01 12:49:19 -05:00
Vincent Koc c72115f803 refactor(kernel-module): share section admission (#15511)
* refactor(kernel-module): share section admission

* fix(kernel-module): preserve section report literal types
2026-12-01 15:55:11 +00:00
Vincent Koc 8535d82158 refactor(elf): share version table admission (#15514) 2026-12-01 15:53:40 +00:00
Vincent Koc 57167985fa refactor(shortcuts): share LinkInfo string reading (#15492) 2026-12-01 15:06:15 +00:00
Vincent Koc ee3f887967 refactor(elf): share note table scanning (#15488) 2026-12-01 14:51:07 +00:00
Vincent Koc 963024935e refactor(dates): share Gregorian calendar day validation (#15463) 2026-12-01 11:50:28 +00:00
morluto db9a030020 test(artifacts): assert exact refusal reasons, limits and cleanup reports (#15379)
* 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
2026-12-01 02:09:05 +00:00
2SinceJuly aea385cda1 feat(evtx): inventory Windows event log records offline
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.
2026-11-30 20:25:14 +08:00
a5aee4f9e9 feat(artifacts): inventory Android super image metadata (#14928)
* 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>
2026-11-30 06:15:43 -05:00
김준호 c552392248 fix(native): keep inspect_macho usable when dyld_info rejects the chained-fixups seg_count (#15147)
* 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
2026-11-30 13:05:50 +08:00
ShuaixinHuangandShuaixinHuang 5c11199c59 fix(native): keep MIPS64 relocated initializers unresolved (#15106)
Co-authored-by: ShuaixinHuang <197200901+ShuaixinHuang@users.noreply.github.com>
2026-11-29 20:39:10 -05:00
Adolanium 06761f2993 fix(xml): bound element depth at the XML syntax boundary (#14998)
* 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.
2026-11-29 13:08:39 -05:00
Akshat GuptaandAkshat 2a1a5e903f fix(macho): separate chained bind addends from import names (#14900)
* 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>
2026-11-29 13:07:40 -05:00
Lewis WangandClaude Opus 5.5 86c27a9b55 fix(native): report ivar layouts that a Swift initializer assigns at load as unknown (#15095)
* 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>
2026-11-29 13:06:25 -05:00
RRFZ 2c07552b64 fix(limits): report details.limit for KernelModuleProvider refusals (#14306)
* fix(limits): report details.limit for ELF dependency, unwind, and kernel reader refusals

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

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

Part of #14234

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

* fix(elf): report required_value for KernelModuleProvider max_file_bytes and add MCP recovery test
2026-11-28 22:58:31 +08:00
gensokyo-devandgensokyo-dev 27612481f0 fix(elf): leave the unwind GOT base unknown when DT_PLTGOT is not established
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>
2026-11-28 22:54:09 +08:00
gensokyo-devandgensokyo-dev a9180c0dfe test(elf): write caller-chosen dynamic rows in unwind fixtures
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>
2026-11-28 22:54:09 +08:00