fix(contracts)!: require absolute local paths for remaining caller-supplied file inputs (#1004)
* fix(contracts)!: require absolute local paths for remaining caller-supplied file inputs Follow-up to the session snapshot/export tightening: the same invisible server-cwd resolution applied to open_binary target paths (parseBinaryTarget(path, process.cwd())), import_evidence_bundle bundle reads, firmware input files (resolve(raw)), browser executable launch paths (resolve-then-spawn), Electron executable/application/root paths (realpath on raw input), and the expected server path check. Each field gains the shared isAbsoluteLocalPath refinement plus a catalog-visible description, since JSON Schema cannot express the rule. Examples, scenario fixtures, and contract tests updated to absolute paths; new schema cases cover rejection/acceptance/omission per field. Explicitly unchanged (verified rooted or out of scope): inspect_plist paths (resolved against the target bundle dir), firmware output_directory (already provider-enforced), filesystem observation paths (resolved against the caller-supplied working_directory), keyed-archive member paths (archive-relative), JS evidence member paths (evidence-relative under root_alias), provider-internal execution schemas, CLI-only doctor flows, and CLI options (own resolve against the operator cwd). * fix(cli): resolve operator-relative paths before shared absolute-path validation The contract tightening rejects relative paths, but three CLI commands forward operator-relative input into the shared schemas: firmware commands pass raw args to FirmwareAnalysisService, and the Electron/browser scenario commands validate parsed scenario JSON directly. CLI paths are relative to the operator shell, so resolve them against the working directory first: resolve() in firmwareCommands, and a shared resolveCliJsonPaths JSON key-path helper (cliJsonInput) applied in electronCommands and cliBrowserScenarioCommands. MCP behavior is unchanged — MCP callers must still send absolute paths. Covers the regression with a relative-path firmware CLI acceptance test (asserts provider-stage capability_unavailable, not a validation error) and unit tests for the helper.
This commit is contained in:
@@ -56,7 +56,7 @@ it("does not require duplicate origin scope declarations", () => {
|
||||
const scenario = browserScenarioSchema.parse({
|
||||
browser: {
|
||||
mode: "launch",
|
||||
executable_path: "chrome",
|
||||
executable_path: "/opt/chromium/chrome",
|
||||
},
|
||||
start_url: { url: "https://app.example.test/" },
|
||||
actions: [
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { z } from "zod";
|
||||
|
||||
import { isAbsoluteLocalPath } from "./localPath.js";
|
||||
import { browserNetworkContentSelectionSchema } from "./browserNetworkEvidence.js";
|
||||
|
||||
import {
|
||||
@@ -11,7 +12,14 @@ export const scenarioIdentifierSchema = z
|
||||
.string()
|
||||
.regex(/^[A-Za-z][A-Za-z0-9._-]*$/u);
|
||||
|
||||
const browserExecutablePathSchema = z.string().trim().min(1);
|
||||
const browserExecutablePathSchema = z
|
||||
.string()
|
||||
.trim()
|
||||
.min(1)
|
||||
.refine(isAbsoluteLocalPath, {
|
||||
message:
|
||||
"executable_path must be an absolute local filesystem path (for example /opt/chromium/chrome or C:\\chromium\\chrome.exe)",
|
||||
});
|
||||
|
||||
const browserScenarioBaseUrlSchema = z
|
||||
.string()
|
||||
@@ -67,7 +75,9 @@ export type BrowserScenarioUrl = z.infer<typeof browserScenarioUrlSchema>;
|
||||
export const browserScenarioBrowserSchema = z.discriminatedUnion("mode", [
|
||||
z.strictObject({
|
||||
mode: z.literal("launch"),
|
||||
executable_path: browserExecutablePathSchema,
|
||||
executable_path: browserExecutablePathSchema.describe(
|
||||
"Absolute local filesystem path for the browser executable; relative paths are rejected.",
|
||||
),
|
||||
headless: z
|
||||
.boolean()
|
||||
.default(true)
|
||||
|
||||
@@ -1,11 +1,21 @@
|
||||
import { z } from "zod";
|
||||
import { digestSchema } from "../digests.js";
|
||||
import { jsonValueSchema } from "../jsonValue.js";
|
||||
import { isAbsoluteLocalPath } from "../localPath.js";
|
||||
|
||||
const bytes = z.number().int().min(0).max(Number.MAX_SAFE_INTEGER);
|
||||
const range = z.strictObject({ offset: bytes, length: bytes.positive() });
|
||||
const target = {
|
||||
path: z.string().min(1).describe("Local firmware file; never executed"),
|
||||
path: z
|
||||
.string()
|
||||
.min(1)
|
||||
.refine(isAbsoluteLocalPath, {
|
||||
message:
|
||||
"path must be an absolute local filesystem path (for example /tmp/firmware.bin or C:\\firmware\\firmware.bin)",
|
||||
})
|
||||
.describe(
|
||||
"Absolute local firmware file; never executed. Relative paths are rejected.",
|
||||
),
|
||||
};
|
||||
|
||||
/** Explicit firmware inspection and extraction intent, independent of engines. */
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
import { z } from "zod";
|
||||
|
||||
const pathInputSchema = z.string().trim().min(1);
|
||||
import { isAbsoluteLocalPath } from "../localPath.js";
|
||||
|
||||
const pathInputSchema = z.string().trim().min(1).refine(isAbsoluteLocalPath, {
|
||||
message:
|
||||
"Electron executable, application, and root paths must be absolute local filesystem paths (for example /Applications/Electron.app/Contents/MacOS/Electron)",
|
||||
});
|
||||
const absolutePathSchema = z
|
||||
.string()
|
||||
.min(1)
|
||||
@@ -60,9 +65,17 @@ const actionSchema = z.discriminatedUnion("kind", [
|
||||
|
||||
/** Input for one explicit, provider-owned Electron runtime experiment. */
|
||||
export const electronActiveObservationInputSchema = z.strictObject({
|
||||
executable_path: pathInputSchema,
|
||||
application_path: pathInputSchema,
|
||||
application_root: pathInputSchema.optional(),
|
||||
executable_path: pathInputSchema.describe(
|
||||
"Absolute local filesystem path for the Electron executable; relative paths are rejected.",
|
||||
),
|
||||
application_path: pathInputSchema.describe(
|
||||
"Absolute local filesystem path for the Electron application; relative paths are rejected.",
|
||||
),
|
||||
application_root: pathInputSchema
|
||||
.optional()
|
||||
.describe(
|
||||
"Absolute local filesystem root for application-relative paths; omit to derive it from the application path. Relative paths are rejected.",
|
||||
),
|
||||
args: z.array(z.string()).default([]),
|
||||
actions: z.array(actionSchema).default([]),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user