mirror of
https://github.com/ChromeDevTools/chrome-devtools-mcp.git
synced 2026-11-04 05:02:31 +00:00
Reject navigations to `devtools:` URLs. The rejection is unconditional: no flag or option enables `devtools:` navigations. The check is in `validateUrl` in `src/utils/url.ts`. These tools call `validateUrl` and reject `devtools:` URLs: - `navigate_page` (`src/tools/pages.ts`) - `new_page` (`src/tools/pages.ts`) - the slim `navigate` tool (`src/tools/slim/tools.ts`) The error message is `Navigating to devtools: URLs is not allowed.` Closes #2935 --------- Co-authored-by: Alex Rudenko <alexrudenko@chromium.org>
This commit is contained in:
1 parent
df14fcc1c7
commit
c94c03deda
2 files changed
+15
No files matched your search
@@ -264,6 +264,10 @@ export function validateUrl(url: string, options: ValidateUrlOptions): URL {
|
||||
);
|
||||
}
|
||||
|
||||
if (parsed.protocol === 'devtools:') {
|
||||
throw new Error(`Navigating to devtools: URLs is not allowed.`);
|
||||
}
|
||||
|
||||
if (!isAllowedUrl(url, {categoryExtensions})) {
|
||||
if (parsed.protocol === 'chrome-extension:') {
|
||||
throw new Error(
|
||||
|
||||
@@ -318,6 +318,17 @@ describe('validateUrl', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('should reject devtools: URLs', () => {
|
||||
assert.throws(
|
||||
() =>
|
||||
validateUrl(
|
||||
'devtools://devtools/bundled/devtools_app.html',
|
||||
defaultOptions,
|
||||
),
|
||||
/Navigating to devtools: URLs is not allowed\./,
|
||||
);
|
||||
});
|
||||
|
||||
it('should allow file URLs when fileNavigations is true or omitted', () => {
|
||||
assert.strictEqual(
|
||||
validateUrl('file:///tmp/example.txt', defaultOptions).protocol,
|
||||
|
||||
Reference in new issue
Block a user