Repository navigation
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
2ee2e1f to
ef1b103
Compare
OrKoN
left a comment
There was a problem hiding this comment.
it looks like there are failures on Windows.
|
The Windows failures look like they come from the new test rather than the fix. On the Windows runners the checkout is under Taking the root from the path under test keeps both on the same drive: const outsidePath = path.resolve(
os.homedir(),
'a_very_unlikely_path_name_filesystem_root',
);
const filesystemRoot = path.parse(outsidePath).root;I checked the containment logic on a Windows machine (Node 25): with the root The macOS / Node 24 failure is |
`validatePath()` matched a path against a canonical root by testing `canonicalPath.startsWith(canonicalRoot + path.sep)`. When the root is the filesystem root, appending the separator turns `/` into `//` (`C:\` into `C:\\` on Windows), so no path below the root ever matched and every file-writing tool was denied. This affected `--workspace=/`, which the `--allow-unrestricted-paths` deprecation notice recommends as its replacement. Only append the separator when the root does not already end with one.
ef1b103 to
20de10f
Compare
|
@OrKoN, friendly reminder: this PR has new commits since your last review and has been waiting for 16 day(s) (automated reminder) |
OrKoN
left a comment
There was a problem hiding this comment.
please check the test failures
|
Closing as stale |
…ls#3277) Fixes ChromeDevTools#2808 `validatePath()` builds the allowed prefix as `canonicalRoot + path.sep`. A filesystem root (`/`, or `C:\` on Windows) already ends with the separator, so the prefix becomes `//` (or `C:\\`) and no path below it matches. This makes `--workspace=/`, which the `--allowUnrestrictedPaths` deprecation notice recommends, reject every file write with `Access denied`. The fix appends the separator only when the root doesn't already end with one. Narrower roots behave as before. The new test in `tests/roots.test.ts` sets the workspace root to the filesystem root of the path under test, so it is on the same drive on Windows (that drive mismatch is why the CI failed on the earlier, stale attempt in ChromeDevTools#2809). It fails on `main` with `Access denied` and passes with the fix. `tests/roots.test.ts` passes locally. --- AI-assistance note: I prepared this change with help from an AI coding assistant, then reviewed it and ran the tests myself.
Summary
Fixes #2808.
--workspace=/is the replacement the--allow-unrestricted-pathsdeprecation notice points to, but it currently denies every path.McpContext.validatePath()built its allowed prefix ascanonicalRoot + path.sep. For the filesystem root that doubles the separator —/becomes//on POSIX andC:\becomesC:\\on Windows — so no path below the root ever matched, and every file-writing tool failed withAccess denied: ... is not within any of the configured workspace roots.Change
src/McpContext.ts: append the separator only when the canonical root does not already end with one.tests/roots.test.ts: regression test that uses the filesystem root as the workspace root.The check keeps its existing semantics for narrower roots, and equality with the root itself still matches.
Verification
mainwithAccess deniedand passes with the change.npm run test tests/roots.test.ts— all tests pass.--workspace=/now saves a screenshot outside the temp directory, while--workspace=/tmpstill rejects the same path, so the guardrail is unchanged for non-root roots.npm run check-format— clean.npm run testreports only the failures that already exist onmainand are unrelated to this change (cli args parsingconfig expectations, and the "Page is too large" screenshot case). I ran the suite with and without this change and the results are identical.