fix(mcp): preserve investigation input policy
This commit is contained in:
@@ -278,6 +278,7 @@ const connectBrowser = async (browser: FakeCdpBrowser) => {
|
||||
availabilityPolicy: () => ({
|
||||
processCaptureEnabled: false,
|
||||
evidenceFileRoots: 0,
|
||||
investigationInputRoots: 0,
|
||||
browserObservationEnabled: true,
|
||||
}),
|
||||
});
|
||||
|
||||
@@ -72,6 +72,7 @@ describe("Electron MCP tools", () => {
|
||||
availabilityPolicy: () => ({
|
||||
processCaptureEnabled: false,
|
||||
evidenceFileRoots: 0,
|
||||
investigationInputRoots: 1,
|
||||
electronObservationEnabled: true,
|
||||
}),
|
||||
});
|
||||
@@ -204,6 +205,7 @@ describe("Electron MCP tools", () => {
|
||||
availabilityPolicy: () => ({
|
||||
processCaptureEnabled: false,
|
||||
evidenceFileRoots: 0,
|
||||
investigationInputRoots: 1,
|
||||
}),
|
||||
});
|
||||
const client = new Client({
|
||||
@@ -273,6 +275,82 @@ describe("Electron MCP tools", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("reports an unconfigured investigation ceiling before static analysis", async () => {
|
||||
const root = await mkdtemp(join(tmpdir(), "rea-electron-denied-mcp-"));
|
||||
temporary.push(root);
|
||||
await writeElectronBoundaryFixture(root);
|
||||
const config = parseConfig({});
|
||||
if (!config.ok) throw config.error;
|
||||
const authority = await loadConfiguredPermissionAuthority(config.value);
|
||||
if (!authority.ok) throw authority.error;
|
||||
const session = new BinarySession(() => ({
|
||||
execute: () => Promise.resolve(observed(null)),
|
||||
close: () => Promise.resolve(),
|
||||
}));
|
||||
const server = createServer(session, session, {
|
||||
permissionAuthority: authority.value,
|
||||
});
|
||||
const client = new Client({
|
||||
name: "electron-denied-mcp-test",
|
||||
version: "1",
|
||||
});
|
||||
const [clientTransport, serverTransport] =
|
||||
InMemoryTransport.createLinkedPair();
|
||||
resources.push(client, server, session);
|
||||
await server.connect(serverTransport);
|
||||
await client.connect(clientTransport);
|
||||
|
||||
const status = await client.callTool({
|
||||
name: "binary_session",
|
||||
arguments: {
|
||||
detail: "capabilities",
|
||||
capability_family: "electron-provider",
|
||||
limit: 100,
|
||||
},
|
||||
});
|
||||
expect(status.structuredContent).toMatchObject({
|
||||
result: {
|
||||
capabilities: {
|
||||
items: expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
name: "analyze_javascript_application",
|
||||
available: false,
|
||||
reason: "policy_disabled",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
name: "reconcile_javascript_runtime",
|
||||
available: true,
|
||||
reason: "available",
|
||||
}),
|
||||
]),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const denied = await client.callTool({
|
||||
name: "analyze_javascript_application",
|
||||
arguments: { input_path: root, approved: true },
|
||||
});
|
||||
expect(denied).toMatchObject({
|
||||
isError: true,
|
||||
structuredContent: {
|
||||
error: {
|
||||
code: "permission_required",
|
||||
remediation: {
|
||||
action: expect.stringContaining("administrator configuration"),
|
||||
elicitation_supported: false,
|
||||
restart_required: true,
|
||||
},
|
||||
details: {
|
||||
capability: "investigation_input",
|
||||
missing: { roots: [root] },
|
||||
ceiling: expect.objectContaining({ roots: [] }),
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
const evidenceFor = (session: BinarySession, value: unknown) => {
|
||||
if (
|
||||
typeof value !== "object" ||
|
||||
|
||||
@@ -65,6 +65,7 @@ describe("managed artifact MCP tools", () => {
|
||||
availabilityPolicy: () => ({
|
||||
processCaptureEnabled: false,
|
||||
evidenceFileRoots: 0,
|
||||
investigationInputRoots: 0,
|
||||
browserObservationEnabled: false,
|
||||
electronObservationEnabled: false,
|
||||
javascriptReplayEnabled: false,
|
||||
|
||||
@@ -18,6 +18,46 @@ import {
|
||||
} from "../src/domain/permissionPolicy.js";
|
||||
|
||||
describe("permission authority", () => {
|
||||
it("distinguishes an elicitable grant from administrator reconfiguration", async () => {
|
||||
const sandbox = await mkdtemp(
|
||||
join(tmpdir(), "rea-permission-remediation-"),
|
||||
);
|
||||
const allowedRoot = join(sandbox, "allowed");
|
||||
const outsideRoot = join(sandbox, "outside");
|
||||
await Promise.all([mkdir(allowedRoot), mkdir(outsideRoot)]);
|
||||
const authority = await createPermissionAuthority([
|
||||
evidenceScope(allowedRoot),
|
||||
]);
|
||||
expect(authority.ok).toBe(true);
|
||||
if (!authority.ok) return;
|
||||
|
||||
const inside = await authority.value.authorize(
|
||||
{
|
||||
...evidenceScope(allowedRoot),
|
||||
operation_identity: "read:inside-ceiling",
|
||||
},
|
||||
"read",
|
||||
{ elicitationSupported: true },
|
||||
);
|
||||
expect(inside).toMatchObject({
|
||||
ok: false,
|
||||
error: { elicitationSupported: true, restartRequired: false },
|
||||
});
|
||||
|
||||
const outside = await authority.value.createConnectionAuthority().authorize(
|
||||
{
|
||||
...evidenceScope(outsideRoot),
|
||||
operation_identity: "read:outside-ceiling",
|
||||
},
|
||||
"read",
|
||||
{ elicitationSupported: true },
|
||||
);
|
||||
expect(outside).toMatchObject({
|
||||
ok: false,
|
||||
error: { elicitationSupported: false, restartRequired: true },
|
||||
});
|
||||
});
|
||||
|
||||
it("accepts canonical aliases but rejects a symlink escape", async () => {
|
||||
const sandbox = await mkdtemp(join(tmpdir(), "rea-permission-"));
|
||||
const root = join(sandbox, "root");
|
||||
|
||||
@@ -47,7 +47,7 @@ describe("MCP permission preflight", () => {
|
||||
missing: { roots: [outputRoot] },
|
||||
},
|
||||
remediation: {
|
||||
restart_required: false,
|
||||
restart_required: true,
|
||||
elicitation_supported: false,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -66,7 +66,11 @@ describe("server and catalog identity", () => {
|
||||
});
|
||||
|
||||
it("reports composed, host, and target-specific availability truthfully", () => {
|
||||
const policy = { processCaptureEnabled: true, evidenceFileRoots: 1 };
|
||||
const policy = {
|
||||
processCaptureEnabled: true,
|
||||
evidenceFileRoots: 1,
|
||||
investigationInputRoots: 1,
|
||||
};
|
||||
const composed = buildCapabilityInventory(
|
||||
{
|
||||
open: true,
|
||||
@@ -201,6 +205,14 @@ describe("server and catalog identity", () => {
|
||||
available: false,
|
||||
reason: "policy_disabled",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
name: "analyze_javascript_application",
|
||||
available: false,
|
||||
reason: "policy_disabled",
|
||||
remediation: expect.stringContaining(
|
||||
"REA_INVESTIGATION_INPUT_ROOTS_JSON",
|
||||
),
|
||||
}),
|
||||
]),
|
||||
client_features: {
|
||||
elicitation_form: false,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
registrationPermissionEnvironment,
|
||||
runSetup,
|
||||
type ClientConfigurationInspection,
|
||||
type ClientConfigurationResult,
|
||||
@@ -153,6 +154,18 @@ const options = (approved: boolean, installHopper = false): SetupOptions => ({
|
||||
});
|
||||
|
||||
describe("setup workflow", () => {
|
||||
it("propagates only the explicit non-secret investigation root policy", () => {
|
||||
expect(
|
||||
registrationPermissionEnvironment({
|
||||
REA_INVESTIGATION_INPUT_ROOTS_JSON: '["/approved/apps"]',
|
||||
AUTHORIZATION: "secret",
|
||||
}),
|
||||
).toEqual({
|
||||
REA_INVESTIGATION_INPUT_ROOTS_JSON: '["/approved/apps"]',
|
||||
});
|
||||
expect(registrationPermissionEnvironment({})).toEqual({});
|
||||
});
|
||||
|
||||
it("returns a complete plan without mutation", async () => {
|
||||
const host = new FakeSetupHost();
|
||||
host.clients = [{ name: "cursor", configPath: "/cursor.json" }];
|
||||
|
||||
Reference in New Issue
Block a user