diff --git a/docs/guides/wasm/wasm-artifacts.md b/docs/guides/wasm/wasm-artifacts.md index e723e31114d..261d75202c6 100644 --- a/docs/guides/wasm/wasm-artifacts.md +++ b/docs/guides/wasm/wasm-artifacts.md @@ -1,8 +1,8 @@ # Offline WebAssembly artifacts `inspect_wasm_artifact` / `inspect-wasm-artifact` inspects explicitly selected -local WASM bytes using caller-supplied WABT 1.0.42 or a later 1.0.x release -(verified with 1.0.42). No active binary target is required. REA does not install tools or fetch artifacts and does not execute WASM. +local WASM bytes using caller-supplied WABT tools +([accepted releases](#configure-wabt)). No active binary target is required. REA does not install tools or fetch artifacts and does not execute WASM. `open_binary` is not the WASM inspection route. A recognized WASM v1 header returns `target_unavailable` with category `unsupported_target` and constraint @@ -18,6 +18,8 @@ The recognized WASM header is checked before automatic database routing from a diagnostic. An explicit database selection or raw/COM format selection retains the caller's requested interpretation; ordinary .hop database routing is unchanged. +## Configure WABT + Set `REA_WABT_BIN_DIRECTORY` to an absolute directory containing executable `wasm-validate`, `wasm-objdump` and `wasm2wat` (with `.exe` on Windows). Missing executables, unsupported banners and inaccessible tools produce actionable @@ -42,6 +44,8 @@ MCP, change the server's launch environment and restart/reconnect that server; exporting a variable in a different shell does not update a running server. REA never installs tools or relaxes version admission to recover. +## Inspect a module + ```bash REA_WABT_BIN_DIRECTORY=/absolute/wabt/bin rea inspect-wasm-artifact \ /artifacts/module.wasm --glue_paths /artifacts/glue.js \ diff --git a/docs/reference/supported-targets.md b/docs/reference/supported-targets.md index 53c1103ebdf..5d6f987fbd2 100644 --- a/docs/reference/supported-targets.md +++ b/docs/reference/supported-targets.md @@ -25,7 +25,7 @@ The table lists what REA returns for each target and which tools or host it requ | Linux kernel modules | .modinfo keys, __versions CRCs, this_module presence, and signature trailer | Built-in static ELF inspection; [kernel modules](../kernel-modules.md) | | Erlang BEAM | IFF chunks, atoms, exports, imports, lambdas and the Code header | Built-in static BEAM inspection; [Erlang BEAM](../erlang-beam.md) | | NuGet packages | Package identity, dependency groups, license, repository and ZIP contents | Built-in static .nupkg inspection; [NuGet packages](../guides/managed/nuget-nupkg.md) | -| WASM artifact | Validation, sections, exact import/export WAT forms and decoded WAT | Caller-supplied WABT 1.0.42; `inspect_wasm_artifact` | +| WASM artifact | Validation, sections, exact import/export WAT forms and decoded WAT | Caller-supplied [WABT](../guides/wasm/wasm-artifacts.md#configure-wabt); `inspect_wasm_artifact` | | EVM bytecode | Dispatch selectors, byte offsets, inferred arguments and mutability | Local raw/hex carrier on Linux x64; [offline EVM guide](../guides/evm/evm-bytecode.md) | | SQLite databases | Tables, columns, indexes, views, triggers and selected ordinary-table rows | Local database/WAL snapshot; Node.js 24.x >=24.15 or 26+ with native SQLite limits | | Recorded Linux crashes | Raw notes, every recorded thread's registers/signals and optional mapping candidates | Caller-supplied pwntools on Linux x64; optional GDB/pwndbg; [recorded crashes](../guides/native/recorded-crashes.md) | diff --git a/src/application/CapabilityInventory.ts b/src/application/CapabilityInventory.ts index 6d5fd93c8ec..d8d2adb0002 100644 --- a/src/application/CapabilityInventory.ts +++ b/src/application/CapabilityInventory.ts @@ -1,4 +1,5 @@ import { PCAP_CAPTURE_UNSUPPORTED_HOST_REASON } from "../domain/pcap/pcapAnalysis.js"; +import { WABT_RELEASE_LINE } from "../domain/wasm/wasmArtifact.js"; import { DEFAULT_CALL_RELATIONSHIP_DIRECTION } from "../contracts/enhancedInputs.js"; import { FIRMWARE_OPERATION_ENGINES, @@ -592,8 +593,7 @@ const workflowAvailabilityFor = ( ? { reason: "available", remediation: null } : { reason: "provider_missing", - remediation: - "Supply WABT 1.0.42 via absolute REA_WABT_BIN_DIRECTORY. No active binary target is required; tools are checked at execution.", + remediation: `Supply ${WABT_RELEASE_LINE} via absolute REA_WABT_BIN_DIRECTORY. No active binary target is required; tools are checked at execution.`, }; if (kind === "android-provider") return policy.androidAnalysisAvailability?.status === "available" diff --git a/src/contracts/wasm/wasmToolContracts.ts b/src/contracts/wasm/wasmToolContracts.ts index aa3830aa576..d96f4f3807e 100644 --- a/src/contracts/wasm/wasmToolContracts.ts +++ b/src/contracts/wasm/wasmToolContracts.ts @@ -1,6 +1,7 @@ import { COMPARE_WASM_INTERFACES_CONTRACT } from "./wasmComparisonContracts.js"; import { inspectWasmArtifactInputSchema, + WABT_RELEASE_LINE, wasmArtifactSchema, } from "../../domain/wasm/wasmArtifact.js"; import type { ToolContract } from "../toolContractTypes.js"; @@ -30,8 +31,7 @@ export const INSPECT_WASM_ARTIFACT_CONTRACT = { ), kind: "artifact-provider", requiresActiveTarget: true, - description: - "Validate and inspect local WASM with caller-supplied WABT 1.0.42, without executing it or fetching dependencies. Returns artifact SHA-256, sections, import/export WAT forms and decoded WAT; custom-section interpretation warnings do not invalidate the core module. Default complete returns full Evidence; detail summary retains it for inspect_analysis_view kind wasm using normalized_result.parent_evidence_id, with import/export rows or UTF-16 WAT pages. Delivery does not change analysis. Optional JavaScript glue associations preserve ambiguous candidates. Configure absolute REA_WABT_BIN_DIRECTORY. Per-call command_timeout_ms, input/tool/output, interface-precision and auxiliary-path budgets are independent; reported limit errors identify the control to adjust. No installation or original-source claim.", + description: `Validate and inspect local WASM with caller-supplied ${WABT_RELEASE_LINE}, without executing it or fetching dependencies. Returns artifact SHA-256, sections, import/export WAT forms and decoded WAT; custom-section interpretation warnings do not invalidate the core module. Default complete returns full Evidence; detail summary retains it for inspect_analysis_view kind wasm using normalized_result.parent_evidence_id, with import/export rows or UTF-16 WAT pages. Delivery does not change analysis. Optional JavaScript glue associations preserve ambiguous candidates. Configure absolute REA_WABT_BIN_DIRECTORY. Per-call command_timeout_ms, input/tool/output, interface-precision and auxiliary-path budgets are independent; reported limit errors identify the control to adjust. No installation or original-source claim.`, inputSchema: wasmArtifactInspectionInputSchema, outputSchema: analysisDetailOutputSchemaOf( wasmArtifactSchema, diff --git a/src/domain/analysisErrorPresentation.ts b/src/domain/analysisErrorPresentation.ts index 6470e4a3ba7..7fae771611c 100644 --- a/src/domain/analysisErrorPresentation.ts +++ b/src/domain/analysisErrorPresentation.ts @@ -1,4 +1,5 @@ import { describeResidualUnknownGraphConstraint } from "./residualUnknownGraphError.js"; +import { WABT_RELEASE_LINE } from "./wasm/wasmArtifact.js"; import { knownArgumentMistakeRemediation } from "./inputArgumentGuidance.js"; import { AnalysisAccessDeniedError, @@ -219,7 +220,7 @@ export const analysisErrorRemediationAction = ( error instanceof BinaryTargetError && error.constraint === "wasm_requires_static_inspection" ) - return `For static inspection, call inspect_wasm_artifact with ${JSON.stringify({ path: error.path })}. This separate lane requires caller-supplied WABT 1.0.42 via absolute REA_WABT_BIN_DIRECTORY; check its availability in binary_session. REA does not execute WASM or install tools, and the header alone does not establish that the complete module is valid.`; + return `For static inspection, call inspect_wasm_artifact with ${JSON.stringify({ path: error.path })}. This separate lane requires caller-supplied ${WABT_RELEASE_LINE} via absolute REA_WABT_BIN_DIRECTORY; check its availability in binary_session. REA does not execute WASM or install tools, and the header alone does not establish that the complete module is valid.`; if ( error instanceof AnalysisAccessDeniedError || (error instanceof BinaryTargetError && error.systemCode !== undefined) diff --git a/src/domain/wasm/wasmArtifact.ts b/src/domain/wasm/wasmArtifact.ts index 919d1736784..502fabab039 100644 --- a/src/domain/wasm/wasmArtifact.ts +++ b/src/domain/wasm/wasmArtifact.ts @@ -11,6 +11,17 @@ import { absoluteLocalPathStringSchema } from "../localPath.js"; import { sha256Hex } from "../../kernel/sha256Hex.js"; /** Exact upstream release whose tool profile REA verified. */ export const WABT_VERSION = "1.0.42"; +/** + * Releases admitted for caller-configured tools; REA does not download WABT. + * WABT changes `wasm-validate`, `wasm-objdump` and `wasm2wat` output only by + * addition within a minor version. The upper bound is exclusive of 1.1.0 so + * admission matches the `1.0.x` banners `wasmArtifactSchema` accepts; letting + * 1.1.0 through would admit a tool profile whose report the schema then + * rejects after inspection ran. + */ +export const WABT_ACCEPTED_RANGE = `>=${WABT_VERSION} <1.1.0`; +/** Caller-facing accepted releases, naming the verified build. */ +export const WABT_RELEASE_LINE = `WABT ${WABT_ACCEPTED_RANGE} (verified with ${WABT_VERSION})`; const WABT_MINIMUM_PATCH = Number(WABT_VERSION.split(".")[2]); /** Upstream revision known for the verified release only. */ export const WABT_SOURCE_COMMIT = "ff0ef7e0009402740c805a9744c09b05be063e48"; diff --git a/src/wasm/WabtArtifactProvider.test.ts b/src/wasm/WabtArtifactProvider.test.ts index b523d3e5854..3256073fe8d 100644 --- a/src/wasm/WabtArtifactProvider.test.ts +++ b/src/wasm/WabtArtifactProvider.test.ts @@ -9,6 +9,7 @@ import { WasmArtifactService } from "../application/wasm/WasmArtifactService.js" import { wasmArtifactSchema, WASM_RESOURCE_DEFAULTS, + WABT_VERSION, } from "../domain/wasm/wasmArtifact.js"; import { PrivateRuntimeRoot } from "../process/PrivateRuntimeRoot.js"; import { PrivateRuntimeRootUnavailableError } from "../domain/privateRuntimeRootUnavailableError.js"; @@ -17,7 +18,7 @@ import { OwnedCommandFailure } from "../process/OwnedCommand.js"; import { projectAnalysisError } from "../domain/analysisErrorProjection.js"; import { primaryAnalysisError } from "../domain/analysisErrorBase.js"; import { AnalysisCancelledError } from "../domain/analysisErrorCore.js"; -import { admitWabtVersion, WABT_ACCEPTED_RANGE } from "./WabtRelease.js"; +import { admitWabtVersion } from "./WabtRelease.js"; /** Classify a raw failure the way the provider does, through WABT's dialect. */ const wabtFailure = ( @@ -27,9 +28,8 @@ const wabtFailure = ( // Admission must not outrun the `1.0.x` banners wasmArtifactSchema accepts. it("admits 1.0.x releases but not the 1.1.0 upper boundary", () => { - expect(WABT_ACCEPTED_RANGE).toBe(">=1.0.42 <1.1.0"); expect(admitWabtVersion("1.0.41").status).toBe("unsupported"); - expect(admitWabtVersion("1.0.42").status).toBe("verified"); + expect(admitWabtVersion(WABT_VERSION).status).toBe("verified"); expect(admitWabtVersion("1.0.99").status).toBe("compatible"); expect(admitWabtVersion("1.1.0").status).toBe("unsupported"); expect(admitWabtVersion("2.0.0").status).toBe("unsupported"); diff --git a/src/wasm/WabtArtifactProvider.ts b/src/wasm/WabtArtifactProvider.ts index c01f1e7ba4c..2cbebd3bd8a 100644 --- a/src/wasm/WabtArtifactProvider.ts +++ b/src/wasm/WabtArtifactProvider.ts @@ -50,6 +50,7 @@ import { projectAnalysisError } from "../domain/analysisErrorProjection.js"; import { wasmArtifactSchema, WABT_SOURCE_COMMIT, + WABT_RELEASE_LINE, WABT_VERSION, DEFAULT_WASM_COMMAND_TIMEOUT_MS, wasmResourceLimits, @@ -66,11 +67,7 @@ import { type ArtifactCommandPath, } from "../process/ArtifactCommandPath.js"; import { WabtRuntime } from "./WabtRuntime.js"; -import { - WABT_PROVIDER_IDENTITY, - admitWabtVersion, - wabtReleaseLine, -} from "./WabtRelease.js"; +import { WABT_PROVIDER_IDENTITY, admitWabtVersion } from "./WabtRelease.js"; import { wabtFailureDialect, wabtConfigurationRecoveryAction, @@ -438,7 +435,7 @@ export class WabtArtifactProvider implements WasmArtifactPort { executable_path: command.path, tool: command.tool, expected_version: WABT_VERSION, - accepted_releases: wabtReleaseLine(), + accepted_releases: WABT_RELEASE_LINE, }; const version = await execute(command, ["--version"]); const admission = @@ -459,13 +456,13 @@ export class WabtArtifactProvider implements WasmArtifactPort { ); } if (admission === undefined || admission.status === "unsupported") { - const reason = `${admission?.message ?? `Unsupported ${command.tool} version banner`}; expected stdout from ${wabtReleaseLine()} with empty stderr.`; + const reason = `${admission?.message ?? `Unsupported ${command.tool} version banner`}; expected stdout from ${WABT_RELEASE_LINE} with empty stderr.`; rejectVersion(reason); } // All three tools come from one directory, so admit only banners that agree. if (observedRelease === undefined) observedRelease = admission.version; if (observedRelease !== admission.version) { - const reason = `Configured WABT tools report different releases (${observedRelease} and ${admission.version}); select one complete ${wabtReleaseLine()} installation.`; + const reason = `Configured WABT tools report different releases (${observedRelease} and ${admission.version}); select one complete ${WABT_RELEASE_LINE} installation.`; rejectVersion(reason); } if (admission.status === "compatible") diff --git a/src/wasm/WabtFailures.test.ts b/src/wasm/WabtFailures.test.ts index 2524a99acf4..f2e1797da76 100644 --- a/src/wasm/WabtFailures.test.ts +++ b/src/wasm/WabtFailures.test.ts @@ -2,10 +2,14 @@ import { spawn } from "node:child_process"; import { expect, it } from "vitest"; import { ArtifactReaderFailure } from "../resources/ArtifactReader.js"; import { projectAnalysisError } from "../domain/analysisErrorProjection.js"; -import { wabtFailureDialect } from "./WabtFailures.js"; +import { wabtFailureDialect, type WabtVersionProbe } from "./WabtFailures.js"; import { classifyProviderFailure } from "../providers/classifyProviderFailure.js"; -import { WASM_RESOURCE_DEFAULTS } from "../domain/wasm/wasmArtifact.js"; +import { + WABT_RELEASE_LINE, + WABT_VERSION, + WASM_RESOURCE_DEFAULTS, +} from "../domain/wasm/wasmArtifact.js"; import { OwnedCommandFailure } from "../process/OwnedCommand.js"; import { UnclassifiedProviderFailure } from "../domain/unclassifiedProviderFailure.js"; @@ -174,12 +178,12 @@ it.each([ ? { cancellation: { reason: callerReason } } : undefined, ); - const probe = { - configuration_key: "REA_WABT_BIN_DIRECTORY" as const, + const probe: WabtVersionProbe = { + configuration_key: "REA_WABT_BIN_DIRECTORY", executable_path: "/tools/wasm2wat", tool: "wasm2wat", - expected_version: "1.0.42" as const, - accepted_releases: "WABT >=1.0.42 <1.1.0 (verified with 1.0.42)", + expected_version: WABT_VERSION, + accepted_releases: WABT_RELEASE_LINE, }; const failure = wabtFailure(cause, "configuration", "/selected.wasm", { commandTimeoutMs: 1234, diff --git a/src/wasm/WabtFailures.ts b/src/wasm/WabtFailures.ts index adf1a032e22..e1f13bc9136 100644 --- a/src/wasm/WabtFailures.ts +++ b/src/wasm/WabtFailures.ts @@ -28,12 +28,13 @@ import { WabtAdmissionError } from "./WabtAdmissionError.js"; import type { AnalysisControlLimit } from "../domain/analysisSettings.js"; import { DEFAULT_WASM_COMMAND_TIMEOUT_MS, + WABT_ACCEPTED_RANGE, WABT_VERSION, WASM_RESOURCE_DEFAULTS, WASM_RESOURCE_MAXIMUMS, type WasmResourceLimits, } from "../domain/wasm/wasmArtifact.js"; -import { WABT_ACCEPTED_RANGE, WABT_PROVIDER_IDENTITY } from "./WabtRelease.js"; +import { WABT_PROVIDER_IDENTITY } from "./WabtRelease.js"; import { errorMessage } from "../kernel/errorMessage.js"; const OUTPUT_LIMIT_EXCERPT_BYTES = 4096; const OPERATION = "inspect_wasm_artifact"; diff --git a/src/wasm/WabtRelease.ts b/src/wasm/WabtRelease.ts index 914280ebfe9..6003d0c5dbd 100644 --- a/src/wasm/WabtRelease.ts +++ b/src/wasm/WabtRelease.ts @@ -1,15 +1,10 @@ import { satisfies, valid } from "semver"; -import { WABT_VERSION } from "../domain/wasm/wasmArtifact.js"; +import { + WABT_ACCEPTED_RANGE, + WABT_RELEASE_LINE, + WABT_VERSION, +} from "../domain/wasm/wasmArtifact.js"; -/** - * Releases admitted for caller-configured tools. WABT changes `wasm-validate`, - * `wasm-objdump` and `wasm2wat` output only by addition within a minor version; - * 1.0.42 is the release this adapter verified. Managed downloads stay pinned. - * The upper bound is exclusive of 1.1.0 so admission matches the `1.0.x` - * banners `wasmArtifactSchema` accepts; letting 1.1.0 through would admit a - * tool profile whose report the schema then rejects after inspection ran. - */ -export const WABT_ACCEPTED_RANGE = `>=${WABT_VERSION} <1.1.0`; export const WABT_PROVIDER_IDENTITY = { id: "wabt-artifact", name: "REA WABT artifact adapter", @@ -26,10 +21,6 @@ export type WabtVersionAdmission = } | { readonly status: "unsupported"; readonly message: string }; -/** Caller-facing accepted releases, naming the verified build. */ -export const wabtReleaseLine = (): string => - `WABT ${WABT_ACCEPTED_RANGE} (verified with ${WABT_VERSION})`; - /** * Release warning for inspections that did not reach a report. Successful * reports carry the same text through the admission limitation, so a failure @@ -44,7 +35,7 @@ export const admitWabtVersion = (banner: string): WabtVersionAdmission => { if (valid(token) !== token || !satisfies(token, WABT_ACCEPTED_RANGE)) return { status: "unsupported", - message: `Unsupported WABT version ${token.length === 0 ? "banner" : token}; accepted releases are ${wabtReleaseLine()}`, + message: `Unsupported WABT version ${token.length === 0 ? "banner" : token}; accepted releases are ${WABT_RELEASE_LINE}`, }; if (token === WABT_VERSION) return { status: "verified", version: token }; return { diff --git a/tests/boundary/filesystem/targetDiagnostics.test.ts b/tests/boundary/filesystem/targetDiagnostics.test.ts index e341adcb561..6d335b22d4b 100644 --- a/tests/boundary/filesystem/targetDiagnostics.test.ts +++ b/tests/boundary/filesystem/targetDiagnostics.test.ts @@ -9,6 +9,7 @@ import { createDoctorHostFixture } from "../../../src/application/Doctor.fixture import { parseBinaryTarget } from "../../../src/application/BinaryTargetResolver.js"; import { projectAnalysisError } from "../../../src/domain/analysisErrorProjection.js"; import { pe } from "../../../src/domain/binaryTarget.fixture.js"; +import { WABT_RELEASE_LINE } from "../../../src/domain/wasm/wasmArtifact.js"; import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js"; describe("executable format refusal diagnostics", () => { @@ -176,7 +177,7 @@ describe("target route diagnostics", () => { "rea inspect-wasm-artifact", ); expect(projected.remediation.action).toContain("REA_WABT_BIN_DIRECTORY"); - expect(projected.remediation.action).toContain("WABT 1.0.42"); + expect(projected.remediation.action).toContain(WABT_RELEASE_LINE); expect(await systemDoctorHost().inspectTarget(path)).toMatchObject({ ok: false, classification: "unsupported_target", diff --git a/third_party/wabt/README.md b/third_party/wabt/README.md index c9875e0e010..e24c608e782 100644 --- a/third_party/wabt/README.md +++ b/third_party/wabt/README.md @@ -4,14 +4,16 @@ REA does not bundle, patch, install or download WABT executables. Operators sele an existing tool directory with `REA_WABT_BIN_DIRECTORY`. - Upstream: https://github.com/WebAssembly/wabt -- Admitted release: https://github.com/WebAssembly/wabt/releases/tag/1.0.42 +- Verified release: https://github.com/WebAssembly/wabt/releases/tag/1.0.42 - Source commit: `ff0ef7e0009402740c805a9744c09b05be063e48` - Upstream license: Apache-2.0, https://github.com/WebAssembly/wabt/blob/1.0.42/LICENSE - Runtime tools: `wasm-validate`, `wasm-objdump`, `wasm2wat`. - Verification fixture compiler: `wat2wasm` (not a runtime prerequisite). -The adapter requires every version banner to report `1.0.42` and records the -resolved executable path, SHA-256, exact banner and arguments for each tool. +The adapter admits the release range stated in the +[WASM guide](https://github.com/morluto/rea/blob/main/docs/guides/wasm/wasm-artifacts.md#configure-wabt); +1.0.42 is the only verified release. It records the resolved executable path, +SHA-256, exact banner and arguments for each tool. Version admission identifies the supported producer profile; it does not certify publisher authenticity. Operators remain responsible for trusted executable provenance. No `wasm-interp`, decompiler, replacement binary parser or target