fix(platform): accept absolute paths for any host and stop blaming the ceiling for a missing grant (#552)
Addresses #548 and #545. #548: processScenarioSchema required a leading "/" for executable, working_directory and filesystem_roots, so no process scenario could be expressed on Windows at all. The report suggested node:path's isAbsolute, but that answers for the host running the check: on Linux `C:\tools` is not absolute, so a scenario captured on Windows would fail validation when it is replayed, compared, or asserted in a test on another host. A boundary schema must not vary with its evaluator, so the check accepts the POSIX form, a Windows drive path and a UNC share everywhere. The rejection message now names the constraint instead of leaving the caller to infer it from "invalid request". The HTTP `path` field inside `checkpoints` is an URL path and is deliberately left alone. I checked whether this merely moved the failure downstream: containment is enforced by isPathWithinRoot, which already uses host-aware path.relative, so validation really was the only blocker. #545: when a scope is inside the administrator ceiling but no grant was ever issued, the denial still pointed at widening the ceiling -- advice that cannot help, since the ceiling already permits the operation. The `missing` payload is computed against candidate *grants*, so it describes what a grant must cover, not a ceiling gap. `PermissionRemediation` gains a `grant` variant saying exactly that, and PermissionAuthority selects it when the denial is not a ceiling violation. An explicitly requested remediation is still honoured, and a genuine ceiling violation still says "configure".
This commit is contained in:
@@ -235,3 +235,64 @@ describe("process scenario large interaction inputs", () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("process scenario path portability", () => {
|
||||
const base = { arguments: [], environment: {}, filesystem_roots: [] };
|
||||
|
||||
it.each([
|
||||
["posix", "/usr/bin/node", "/tmp"],
|
||||
["windows drive with backslashes", "C:\\tools\\node.exe", "C:\\work"],
|
||||
["windows drive with forward slashes", "c:/tools/node.exe", "c:/work"],
|
||||
["unc share", "\\\\server\\share\\node.exe", "\\\\server\\share"],
|
||||
])(
|
||||
"accepts a %s path on any host",
|
||||
(_label, executable, working_directory) => {
|
||||
const parsed = processScenarioSchema.safeParse({
|
||||
...base,
|
||||
executable,
|
||||
working_directory,
|
||||
});
|
||||
expect(parsed.success).toBe(true);
|
||||
},
|
||||
);
|
||||
|
||||
it("accepts Windows filesystem roots", () => {
|
||||
const parsed = processScenarioSchema.safeParse({
|
||||
...base,
|
||||
executable: "C:\\tools\\node.exe",
|
||||
working_directory: "C:\\work",
|
||||
filesystem_roots: ["C:\\data", "D:\\more"],
|
||||
});
|
||||
expect(parsed.success).toBe(true);
|
||||
});
|
||||
|
||||
it.each([
|
||||
["relative", "tools/node.exe"],
|
||||
["dot relative", "./node.exe"],
|
||||
["parent relative", "../node.exe"],
|
||||
["bare filename", "node.exe"],
|
||||
["empty", ""],
|
||||
])("still rejects a %s path", (_label, executable) => {
|
||||
const parsed = processScenarioSchema.safeParse({
|
||||
...base,
|
||||
executable,
|
||||
working_directory: "/tmp",
|
||||
});
|
||||
expect(parsed.success).toBe(false);
|
||||
});
|
||||
|
||||
it("names the constraint so a rejected path is actionable", () => {
|
||||
const parsed = processScenarioSchema.safeParse({
|
||||
...base,
|
||||
executable: "tools/node.exe",
|
||||
working_directory: "/tmp",
|
||||
});
|
||||
expect(parsed.success).toBe(false);
|
||||
if (parsed.success) return;
|
||||
const messages = parsed.error.issues
|
||||
.map(({ message }) => message)
|
||||
.join("\n");
|
||||
expect(messages).toContain("must be absolute");
|
||||
expect(messages).toContain("C:\\tools\\node.exe");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user