Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
85c9f88
feat(rust): read cargo-auditable dependencies from WebAssembly modules
yu0809 Oct 18, 2026
9bac2e3
fix(rust): bound the WebAssembly section walk
yu0809 Oct 18, 2026
cda31a6
Merge morluto/rea main into feat/rust-wasm-auditable
yu0809 Oct 18, 2026
162590b
Merge origin/main into feat/rust-wasm-auditable
kaoru0822-kitauji Oct 21, 2026
345f0f4
Merge morluto/rea main into feat/rust-wasm-auditable
yu0809 Oct 21, 2026
d2fd725
fix(rust): accept WebAssembly Evidence in retained dependency views
yu0809 Oct 21, 2026
bdb41d2
fix(rust): name the WebAssembly section-walk allowance in recovery
yu0809 Oct 21, 2026
6ce932e
Merge morluto/rea main into feat/rust-wasm-auditable
yu0809 Oct 25, 2026
084ad35
fix(rust): require WebAssembly container facts in reports
yu0809 Oct 25, 2026
a86deb1
Merge morluto/rea main into feat/rust-wasm-auditable
yu0809 Nov 17, 2026
8865878
docs(rust): record the WebAssembly dependency-metadata feature
yu0809 Nov 17, 2026
e88658c
fix(rust): bind section names to containers and share the LEB128 reader
yu0809 Nov 17, 2026
bb745a3
fix(rust): classify a cut-off WebAssembly integer by its boundary
yu0809 Nov 17, 2026
3753f11
fix(rust): report a duplicate WebAssembly dependency section first
yu0809 Nov 17, 2026
fb270a2
Merge remote-tracking branch 'origin/main' into feat/rust-wasm-auditable
cursoragent Nov 18, 2026
b6510e5
test(rust): assert WebAssembly container facts instead of limitation …
cursoragent Nov 18, 2026
d8b8f22
fix(rust): state container word size as 32 | 64 | null
cursoragent Nov 18, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix(rust): state container word size as 32 | 64 | null
Output contract: inspect_rust_binary bits, including the summary view, is
32 | 64 | null. Null is valid only for WebAssembly and is not a number.
ELF, PE and Mach-O reports stay 32 or 64. The schema description, guide,
feature record and skill state that, and CLI renderers keep null instead
of substituting a word size.
  • Loading branch information
cursoragent committed Nov 18, 2026
commit d8b8f22c3fa751784c5e22e0e07264e8ef9a3c75
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ installation, or target execution is required. The CLI equivalent is
`inspect-rust-binary PATH`. Preserve artifact SHA-256, package order,
dependency indices, and the section file range. A missing section is null
metadata, not proof the binary has no dependencies. An omitted package kind
stays null. WebAssembly reports a null word size, and components such as
stays null. WebAssembly reports `bits: null` on a `32 | 64 | null` word size;
null means the container declares no word size and must not be coerced to a
number. ELF, PE and Mach-O stay 32 or 64. Components such as
`wasm32-wasip2` output are unsupported. A rustc commit hash is inferred from a
`/rustc/<40-hex>/` path in read-only data or a WebAssembly data section and
does not by itself identify the compiler. Project the retained parent with `inspect_analysis_view`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ installation, or target execution is required. The CLI equivalent is
`inspect-rust-binary PATH`. Preserve artifact SHA-256, package order,
dependency indices, and the section file range. A missing section is null
metadata, not proof the binary has no dependencies. An omitted package kind
stays null. WebAssembly reports a null word size, and components such as
stays null. WebAssembly reports `bits: null` on a `32 | 64 | null` word size;
null means the container declares no word size and must not be coerced to a
number. ELF, PE and Mach-O stay 32 or 64. Components such as
`wasm32-wasip2` output are unsupported. A rustc commit hash is inferred from a
`/rustc/<40-hex>/` path in read-only data or a WebAssembly data section and
does not by itself identify the compiler. Project the retained parent with `inspect_analysis_view`
Expand Down
11 changes: 8 additions & 3 deletions docs/rust-binaries.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ limitation and leaves `.dep-v0` presence unknown rather than reporting the
section absent.

The inline Evidence result contains the artifact path, SHA-256, byte length,
container format, architecture, word size, and byte order. When a `.dep-v0`
container format, architecture, word size, and byte order. `bits` is
`32 | 64 | null`. ELF, PE and Mach-O reports are 32 or 64. WebAssembly is
null: the container declares no word size, null is not a number, and
consumers must not coerce it. The summary view uses the same field. When a `.dep-v0`
section is present, `auditable_metadata` contains:

- `section_name`, `.dep-v0` for ELF, PE, and WebAssembly or `__DATA,.dep-v0`
Expand Down Expand Up @@ -148,8 +151,10 @@ section named `.dep-v0`. For a version 1 core module, such as
`wasm32-unknown-unknown` or `wasm32-wasip1` output, the reader walks the
section framing without validating, instantiating, or executing the module.
The report's `format` and `architecture` are `wasm` and its `byte_order` is
`little`. `bits` is `null`: WebAssembly declares no container word size, and
memory address types are not inspected. The Evidence subject format is
`little`. `bits` is `null` on the `32 | 64 | null` word size: WebAssembly
declares no container word size, and memory address types are not inspected.
JSON output keeps that null. The shared CLI renderer does not substitute a
number. The Evidence subject format is
`file`, as for `inspect_wasm_artifact`.

A header, section or section size that ends past the file is truncated. A
Expand Down
11 changes: 7 additions & 4 deletions docs/specs/native/rust-wasm-auditable/plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ from `RustWasmImage`. The dependency decoder, PE alignment allowance and rustc
path retention are shared and unchanged.

`src/domain/rust/rustBinary.ts` owns the report contract: `format` gains
`wasm`, `bits` is nullable, and refinements bind `bits`, `architecture`,
`byte_order` and the dependency section name to the container.
`wasm`, and `bits` is explicitly `32 | 64 | null`. Null is valid only when
`format` is `wasm` and is not a number. Refinements bind `bits`,
`architecture`, `byte_order` and the dependency section name to the container.
`rustDependencySectionName` is the one owner of that name for the reader and
the schema. `metadataReportSubjectFormat` in
`src/domain/apple/machoTargetSelection.ts` maps a `wasm` report to the `file`
Expand All @@ -42,7 +43,9 @@ names the searched compiler-path source in limitations.

## Effects and compatibility

Output widening only: `format` gains `wasm` and `bits` admits `null` for
`wasm` reports, which were previously refused. No new tool, input, subprocess,
Output widening only: `format` gains `wasm` and `bits` is `32 | 64 | null`
on the report and its summary view. Null is admitted only for `wasm`
reports, which were previously refused. ELF, PE and Mach-O reports remain
32 or 64. No new tool, input, subprocess,
temporary file or network access. Native reports change only in limitation
wording.
8 changes: 5 additions & 3 deletions docs/specs/native/rust-wasm-auditable/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ implementation already had; no earlier plan is reconstructed.
4. A missing `.dep-v0` section is null metadata with a limitation. It is not
evidence that the module has no dependencies.
5. `format` and `architecture` are `wasm` and `byte_order` is `little`.
`bits` is `null`, because WebAssembly declares no container word size and
memory address types are not inspected. The report schema refuses any
report that combines these facts differently.
`bits` is `32 | 64 | null`, and is `null` for this container because
WebAssembly declares no container word size and memory address types are
not inspected. Null is not a number and must not be coerced. ELF, PE and
Mach-O reports stay 32 or 64. The report schema, its field description and
the summary view refuse any report that combines these facts differently.
6. The rustc commit is inferred from `/rustc/<40-hex>/` paths in the module's
data section. Limitations name that source. A second data section is
malformed.
Expand Down
12 changes: 11 additions & 1 deletion src/domain/analysisView/rustBinaryView.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,15 @@ it("refuses imported reports whose container facts contradict their format", ()
bits: null,
byte_order: "little",
};
expect(projectAnalysisView(parent(wasm), { kind: "summary" }).ok).toBe(true);
const accepted = projectAnalysisView(parent(wasm), { kind: "summary" });
if (!accepted.ok || accepted.value.kind !== "summary")
throw new Error("WebAssembly summary failed");
expect(accepted.value.summary).toMatchObject({
format: "wasm",
architecture: "wasm",
bits: null,
byte_order: "little",
});
for (const value of [
{ ...wasm, architecture: "x86_64" },
{ ...wasm, byte_order: "big" as const },
Expand All @@ -182,6 +190,8 @@ it("bounds inherited warnings and retains cycle counts without walking a cyclic
if (!result.ok) throw result.error;
expect(result.value).toMatchObject({
summary: {
format: "elf",
bits: 64,
auditable_metadata: {
format_version: null,
counts: { packages: 1, edges: 1, cyclic_packages: 1 },
Expand Down
18 changes: 16 additions & 2 deletions src/domain/rust/rustBinary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,21 @@ export const inspectRustBinaryInputSchema = z.strictObject({
),
});

/**
* Container word size on a Rust dependency report and its summary view.
* ELF, PE and Mach-O are 32 or 64. WebAssembly declares no container word
* size, so the value is null. Null is not a number and must not be coerced.
*/
export type RustContainerBits = 32 | 64 | null;

/** `32 | 64 | null`. Null is valid only for a WebAssembly report. */
export const rustContainerBitsSchema = z
.union([z.literal(32), z.literal(64)])
.nullable()
.describe(
"Container word size: 32 or 64 for ELF, PE and Mach-O. null for WebAssembly, which declares no container word size. null is not a number and must not be coerced to 32 or 64.",
) satisfies z.ZodType<RustContainerBits>;

/** Bounded cargo-auditable observation. A missing section is null, not an empty dependency list. */
export const rustBinarySchema = z
.strictObject({
Expand All @@ -158,8 +173,7 @@ export const rustBinarySchema = z
}),
format: z.enum(["elf", "pe", "macho", "wasm"]),
architecture: z.string(),
/** Native containers declare a word size; WebAssembly declares none. */
bits: z.union([z.literal(32), z.literal(64)]).nullable(),
bits: rustContainerBitsSchema,
byte_order: z.enum(["little", "big"]),
/** The universal slice that was read; file offsets stay inside it. */
selected_slice: machoTargetSelectionSchema.exactOptional(),
Expand Down
3 changes: 2 additions & 1 deletion src/rust/RustBinaryImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { readBinaryContainer } from "../domain/native/readBinaryContainer.js";
import type {
RustAuditableMetadata,
RustBinary,
RustContainerBits,
} from "../domain/rust/rustBinary.js";
import {
DEFAULT_RUSTC_HASH_LIMIT,
Expand All @@ -29,7 +30,7 @@ const HASH_BYTES = 40;
export interface RustBinaryImage {
readonly format: RustBinary["format"];
readonly architecture: string;
readonly bits: RustBinary["bits"];
readonly bits: RustContainerBits;
readonly byte_order: RustBinary["byte_order"];
readonly auditable_metadata: RustAuditableMetadata | null;
readonly rustc_commit: RustBinary["rustc_commit"];
Expand Down
31 changes: 31 additions & 0 deletions tests/boundary/cli/cliOutputFormatter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,37 @@ it.each([" =1+1", "+1", "-1", "@SUM(A1:A2)"])(
},
);

it("keeps a null word size null and a native word size numeric", () => {
const wasm = { format: "wasm", bits: null };
const native = { format: "elf", bits: 64 };
expect(formatCliOutput(wasm, "json")).toBe(
'{\n "format": "wasm",\n "bits": null\n}',
);
expect(formatCliOutput(native, "json")).toBe(
'{\n "format": "elf",\n "bits": 64\n}',
);
expect(formatCliOutput(wasm, "yaml")).toBe("format: wasm\nbits: null\n");
expect(formatCliOutput(native, "yaml")).toBe("format: elf\nbits: 64\n");
expect(formatCliOutput(wasm, "toon")).toBe("format: wasm\nbits: null");
expect(formatCliOutput(native, "toon")).toBe("format: elf\nbits: 64");
expect(formatCliOutput(wasm, "md")).toContain("| bits | null |");
expect(formatCliOutput(native, "md")).toContain("| bits | 64 |");
for (const format of ["csv", "tsv"] as const) {
const rows = formatCliOutput([wasm, native], format, {
fields: ["bits"],
metadata: {},
});
const lineEnding = format === "csv" ? "\r\n" : "\n";
const body = rows.slice(rows.indexOf(lineEnding) + lineEnding.length);
expect(
parseDelimited(
body.replace(/\r?\n$/u, ""),
format === "csv" ? "," : "\t",
),
).toEqual([["bits"], [""], ["64"]]);
}
});

it("refuses formula-leading column headers", () => {
expect(
prepareDelimitedOutput([{ value: "safe" }], "csv", {
Expand Down
Loading