fix(capture): report scenario path search denial as access denied (#6244)

Electron and process scenario path admission caught every realpath or
stat failure as an invalid_value input issue, so a correct path beneath a
directory without search permission returned invalid_request with
schema-correction recovery instead of a host access denial.

Admission now classifies EACCES/EPERM from path resolution and metadata
reads as the existing AnalysisAccessDeniedError (selected path,
system_code, filesystem-read boundary). Missing, looping or otherwise
unresolvable paths and reachable files without execute permission keep
their input-error semantics. Electron reports invalid selections before a
denial on another field. Process PATH search still continues past a
denied directory; only an explicitly selected executable reports denial.

Fixes #6117

Co-authored-by: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Kaoru0822andClaude Opus 5.5 authored and GitHub committed 2026-10-21 22:22:15 -07:00
1 parent 7590b50801
commit 6f96d7a3fa
5 files changed
+506 -51

No files matched your search

@@ -1,3 +1,4 @@
import { chmod, mkdir, writeFile } from "node:fs/promises";
import { join } from "node:path";
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
import { describe, expect } from "vitest";
@@ -103,3 +104,43 @@ for (const field of [
expect(JSON.stringify(result.json)).toContain(missing);
});
}
cliTest.skipIf(process.platform === "win32" || process.getuid?.() === 0)(
"reports a search-denied Electron application_path as access denied",
async ({ cli }) => {
const root = await createTestTempDirectory("rea-electron-denied-");
const denied = join(root, "denied");
await mkdir(denied);
const application = join(denied, "main.js");
await writeFile(application, "module.exports = {};\n");
await chmod(denied, 0o000);
let result;
try {
result = await cli.run({
arguments: [
"capture-electron-scenario",
JSON.stringify({
executable_path: process.execPath,
application_path: application,
actions: [],
}),
"--json",
],
environment: { REA_LOG_LEVEL: "silent" },
});
} finally {
await chmod(denied, 0o700);
}
expect(result.exitCode).toBe(1);
expect(result.json).toMatchObject({
code: "access_denied",
category: "unavailable",
details: {
operation: "capture_electron_scenario",
path: application,
system_code: "EACCES",
boundary: "filesystem-read",
},
});
},
);