Compare commits

...
5 changed files with 57 additions and 17 deletions

No files matched your search

@@ -325,3 +325,37 @@ it("replays imported rebound WASM Evidence in views and comparisons", async () =
).ok,
).toBe(true);
});
it.each([
{ release: "1.0.42", knownCommit: true, accepted: true },
{ release: "1.0.42", knownCommit: false, accepted: true },
{ release: "1.0.44", knownCommit: false, accepted: true },
{ release: "1.0.44", knownCommit: true, accepted: false },
])(
"admits only release-consistent WABT provenance ($release, known commit $knownCommit)",
async ({ release, knownCommit, accepted }) => {
const value = wasmArtifactFixture();
value.tool_profile.release = release;
if (!knownCommit) value.tool_profile.source_commit = null;
for (const command of value.tool_profile.commands)
command.version_banner = `${release}\n`;
const service = new WasmArtifactService({
close: async () => {},
inspect: async () => ok(wasmArtifactExecution(value)),
});
const result = await service.inspect({ path: value.artifact.path });
if (accepted) {
if (!result.ok) throw result.error;
expect(result.value.normalized_result).toMatchObject({
tool_profile: {
release,
source_commit: value.tool_profile.source_commit,
},
});
} else
expect(result).toMatchObject({
ok: false,
error: { _tag: "AnalysisOutputError" },
});
},
);
+17 -5
View File
@@ -8,14 +8,16 @@ import { constants as bufferConstants } from "node:buffer";
import type { EvidenceSubjectTarget } from "../evidence.js";
import { absoluteLocalPathStringSchema } from "../localPath.js";
/** Release banners of the admitted WABT range, owned here so this schema stays pure. */
const WABT_ACCEPTED_MINOR = 42;
const WABT_SOURCE_COMMIT = "ff0ef7e0009402740c805a9744c09b05be063e48";
/** Exact upstream release whose tool profile REA verified. */
export const WABT_VERSION = "1.0.42";
const WABT_MINIMUM_PATCH = Number(WABT_VERSION.split(".")[2]);
/** Upstream revision known for the verified release only. */
export const WABT_SOURCE_COMMIT = "ff0ef7e0009402740c805a9744c09b05be063e48";
const wabtReleaseBanner = z
.string()
.regex(/^1\.0\.\d+$/u)
.refine((release) => Number(release.split(".")[2]) >= WABT_ACCEPTED_MINOR, {
message: `Expected one admitted WABT banner (^1.0.${String(WABT_ACCEPTED_MINOR)})`,
.refine((release) => Number(release.split(".")[2]) >= WABT_MINIMUM_PATCH, {
message: `Expected one admitted WABT banner (^1.0.${String(WABT_MINIMUM_PATCH)})`,
});
const digest = z.string().regex(/^[a-f0-9]{64}$/);
@@ -226,6 +228,16 @@ export const wasmArtifactSchema = z
"--ignore-custom-section-errors",
);
const releaseVersion = value.tool_profile.release;
if (
value.tool_profile.source_commit !== null &&
releaseVersion !== WABT_VERSION
)
context.addIssue({
code: "custom",
path: ["tool_profile", "source_commit"],
message:
"The known WABT source revision applies only to its verified release; other releases require an unknown source commit.",
});
for (const [index, command] of value.tool_profile.commands.entries()) {
const expected = ["wasm-validate", "wasm-objdump", "wasm2wat"][index];
const argumentsExpected =
+2 -2
View File
@@ -40,6 +40,8 @@ import { createAnalysisExecutionEvidence } from "../domain/analysisObservation.j
import { projectAnalysisError } from "../domain/analysisErrorProjection.js";
import {
wasmArtifactSchema,
WABT_SOURCE_COMMIT,
WABT_VERSION,
DEFAULT_WASM_COMMAND_TIMEOUT_MS,
wasmResourceLimits,
type InspectWasmArtifactInput,
@@ -58,8 +60,6 @@ import {
import { WabtRuntime } from "./WabtRuntime.js";
import {
WABT_PROVIDER_IDENTITY,
WABT_SOURCE_COMMIT,
WABT_VERSION,
admitWabtVersion,
wabtReleaseLine,
} from "./WabtRelease.js";
+2 -5
View File
@@ -32,16 +32,13 @@ import {
import { WabtAdmissionError } from "./WabtAdmissionError.js";
import {
DEFAULT_WASM_COMMAND_TIMEOUT_MS,
WABT_VERSION,
MAX_WASM_COMMAND_TIMEOUT_MS,
WASM_RESOURCE_DEFAULTS,
WASM_RESOURCE_MAXIMUMS,
type WasmResourceLimits,
} from "../domain/wasm/wasmArtifact.js";
import {
WABT_ACCEPTED_RANGE,
WABT_PROVIDER_IDENTITY,
WABT_VERSION,
} from "./WabtRelease.js";
import { WABT_ACCEPTED_RANGE, WABT_PROVIDER_IDENTITY } from "./WabtRelease.js";
const OUTPUT_LIMIT_EXCERPT_BYTES = 4096;
/** Recovery names the exhausted per-call byte owner, independently of deadlines. */
+2 -5
View File
@@ -1,7 +1,6 @@
import { satisfies, valid } from "semver";
import { WABT_VERSION } from "../domain/wasm/wasmArtifact.js";
/** Exact upstream release whose producer output this adapter verified. */
export const WABT_VERSION = "1.0.42";
/**
* Releases admitted for caller-configured tools. WABT changes `wasm-validate`,
* `wasm-objdump` and `wasm2wat` output only by addition within a minor version;
@@ -10,9 +9,7 @@ export const WABT_VERSION = "1.0.42";
* 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 = ">=1.0.42 <1.1.0";
/** Upstream revision of the verified release. */
export const WABT_SOURCE_COMMIT = "ff0ef7e0009402740c805a9744c09b05be063e48";
export const WABT_ACCEPTED_RANGE = `>=${WABT_VERSION} <1.1.0`;
export const WABT_PROVIDER_IDENTITY = {
id: "wabt-artifact",
name: "REA WABT artifact adapter",