feat(target): explain static WASM inspection after native rejection
Explain recognized WASM v1 native-admission rejection with an exact call to the existing static inspection tool and its caller-supplied WABT prerequisites. Preserve selected paths, explicit raw-binary choices, typed missing-tool outcomes and connection usability. Refs #1852 Co-authored-by: SII-YDD <38822679+SII-YDD@users.noreply.github.com> Co-authored-by: Ysopwnable <161784452+N0zoM1z0@users.noreply.github.com> Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> Co-authored-by: Kaoru0822 <208281322+kaoru0822-kitauji@users.noreply.github.com>
This commit is contained in:
co-authored by
Ysopwnable
factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
Kaoru0822
parent
89f5e489ad
commit
1f17ac8228
@@ -7,6 +7,81 @@ import { projectAnalysisError } from "../../../src/domain/analysisErrorProjectio
|
||||
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
||||
|
||||
describe("target route diagnostics", () => {
|
||||
it.each(["module.wasm", "module.bin", "misleading.js"])(
|
||||
"identifies a WASM v1 header in %s without suggesting native provider installation",
|
||||
async (name) => {
|
||||
const directory = await createTestTempDirectory("rea-wasm-target-");
|
||||
const path = join(directory, name);
|
||||
const bytes = Buffer.from([0, 0x61, 0x73, 0x6d, 1, 0, 0, 0]);
|
||||
await writeFile(path, bytes);
|
||||
const result = await parseBinaryTarget(path);
|
||||
if (result.ok) throw new Error("WASM was admitted to native opening");
|
||||
const projected = projectAnalysisError(result.error);
|
||||
expect(projected).toMatchObject({
|
||||
code: "target_unavailable",
|
||||
category: "unsupported_target",
|
||||
retryable: false,
|
||||
details: {
|
||||
path: await realpath(path),
|
||||
constraint: "wasm_requires_static_inspection",
|
||||
},
|
||||
});
|
||||
expect(projected.message).toContain("WebAssembly");
|
||||
expect(projected.remediation.action).toContain("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("does not execute");
|
||||
expect(await systemDoctorHost().inspectTarget?.(path)).toMatchObject({
|
||||
ok: false,
|
||||
classification: "unsupported_target",
|
||||
details: { constraint: "wasm_requires_static_inspection" },
|
||||
remediation: projected.remediation.action,
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
it.each([
|
||||
[0, 0x61, 0x73, 0x6d],
|
||||
[0, 0x61, 0x73, 0x6d, 2, 0, 0, 0],
|
||||
[1, 2, 3, 4, 5, 6, 7, 8],
|
||||
])(
|
||||
"does not infer supported WASM encoding from a suffix or incomplete header",
|
||||
async (...bytes) => {
|
||||
const directory = await createTestTempDirectory("rea-wasm-unknown-");
|
||||
const path = join(directory, "module.wasm");
|
||||
await writeFile(path, Buffer.from(bytes));
|
||||
const result = await parseBinaryTarget(path);
|
||||
if (result.ok) throw new Error("unknown header was admitted");
|
||||
const projected = projectAnalysisError(result.error);
|
||||
expect(projected.details).not.toHaveProperty("constraint");
|
||||
expect(projected.remediation.action).not.toContain(
|
||||
"inspect_wasm_artifact",
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
it("preserves an explicit raw-binary selection even when the bytes have a WASM header", async () => {
|
||||
const directory = await createTestTempDirectory("rea-wasm-explicit-raw-");
|
||||
const path = join(directory, "module.wasm");
|
||||
await writeFile(path, Buffer.from([0, 0x61, 0x73, 0x6d, 1, 0, 0, 0]));
|
||||
expect(
|
||||
await parseBinaryTarget(path, {
|
||||
formatHint: "raw-binary",
|
||||
architecture: "x86",
|
||||
entryPoint: "0x001000",
|
||||
}),
|
||||
).toMatchObject({
|
||||
ok: true,
|
||||
value: {
|
||||
path: await realpath(path),
|
||||
format: "raw-binary",
|
||||
architecture: "x86",
|
||||
entryPoint: "0x1000",
|
||||
entryPointSource: "0x001000",
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("identifies the directory opening constraint and gives the direct analysis route", async () => {
|
||||
const directory = await createTestTempDirectory("rea-js-target-");
|
||||
await writeFile(join(directory, "index.js"), "export const answer = 42;\n");
|
||||
|
||||
Reference in New Issue
Block a user