Skip to content

Chrome DevTools for coding agents

fix: reject unrestricted paths with an explicit workspace (#2858)

Langning Zhang45c1c6cc2581
diff --git a/src/config/mcp-options.ts b/src/config/mcp-options.ts
index 671cbeba..a5c3b385 100644
--- a/src/config/mcp-options.ts
+++ b/src/config/mcp-options.ts
@@ -459,6 +459,7 @@ const CONFLICTING_ARGS: Array<Array<keyof typeof mcpOptions>> = [
['autoConnect', 'isolated'],
['autoConnect', 'executablePath'],
['blockedUrlPattern', 'allowedUrlPattern'],
+ ['allowUnrestrictedPaths', 'filesystemRoot'],
['categoryPwa', 'autoConnect'],
['categoryPwa', 'browserUrl', 'wsEndpoint'],
['categoryExtensions', 'autoConnect'],
diff --git a/tests/cli.test.ts b/tests/cli.test.ts
index 41e96033..ab31aa9b 100644
--- a/tests/cli.test.ts
+++ b/tests/cli.test.ts
@@ -180,6 +180,83 @@ describe('cli args parsing', () => {
assert.strictEqual(args.allowUnrestrictedPaths, true);
});
+ it('accepts an explicit unrestricted flag in CLI mode', async () => {
+ const args = parseArguments(['--viaCli', '--allow-unrestricted-paths']);
+ assert.strictEqual(args.allowUnrestrictedPaths, true);
+ assert.strictEqual(args.filesystemRoot, undefined);
+ });
+
+ it('rejects unrestricted paths with a CLI workspace', async () => {
+ assert.throws(
+ () =>
+ parseArguments([
+ '--viaCli',
+ '--allow-unrestricted-paths',
+ '--workspace=/tmp/one',
+ ]),
+ /Arguments allowUnrestrictedPaths and filesystemRoot are mutually exclusive/,
+ );
+ });
+
+ it('rejects unrestricted paths with a direct filesystem root', async () => {
+ assert.throws(
+ () =>
+ parseArguments([
+ '--allow-unrestricted-paths',
+ '--filesystem-root=/tmp/one',
+ ]),
+ /Arguments allowUnrestrictedPaths and filesystemRoot are mutually exclusive/,
+ );
+ });
+
+ it('rejects a config unrestricted flag with a CLI workspace', async () => {
+ using testConfig = createTempFile(
+ JSON.stringify({allowUnrestrictedPaths: true}),
+ 'cd4a.test.config.unrestricted-workspace.json',
+ );
+ assert.throws(
+ () =>
+ parseArguments([
+ '--viaCli',
+ '--config',
+ testConfig.path,
+ '--workspace=/tmp/one',
+ ]),
+ /Arguments allowUnrestrictedPaths and filesystemRoot are mutually exclusive/,
+ );
+ });
+
+ it('rejects a config filesystem root with a CLI unrestricted flag', async () => {
+ using testConfig = createTempFile(
+ JSON.stringify({filesystemRoot: ['/tmp/one']}),
+ 'cd4a.test.config.root-unrestricted.json',
+ );
+ assert.throws(
+ () =>
+ parseArguments([
+ '--config',
+ testConfig.path,
+ '--allow-unrestricted-paths',
+ ]),
+ /Arguments allowUnrestrictedPaths and filesystemRoot are mutually exclusive/,
+ );
+ });
+
+ it('lets an explicit false override config unrestricted with a workspace', async () => {
+ using testConfig = createTempFile(
+ JSON.stringify({allowUnrestrictedPaths: true}),
+ 'cd4a.test.config.unrestricted-false.json',
+ );
+ const args = parseArguments([
+ '--config',
+ testConfig.path,
+ '--no-allow-unrestricted-paths',
+ '--workspace=/tmp/one',
+ ]);
+ assert.strictEqual(args.allowUnrestrictedPaths, false);
+ assert.deepStrictEqual(args.filesystemRoot, ['/tmp/one']);
+ });
+
it('lets an explicit workspace override the CLI unrestricted default', async () => {
const args = parseArguments(['--viaCli', '--workspace=/tmp/one']);
assert.strictEqual(args.allowUnrestrictedPaths, false);