PDX-510: keep testCase id allocation inside the allowed roots (review follow-up)#219
Merged
Merged
Conversation
Req: Adversarial review of the PDX-510 id allocator found maxProjectTestCaseId read every .testcase under the project root without an allowed-path check, so a symlinked .testcase could pull an id from a file outside the configured --allowed-paths, breaking the containment the allocator documents. Fix: maxProjectTestCaseId now reads only real files (isFile and not a symlink) so an out-of-root symlinked .testcase is skipped, and readRootTestCaseId ignores ids beyond Number.isSafeInteger so the generator never emits a scientific-notation id like id="1e+22". Adds unit tests for both; the symlink test skips on hosts without symlink privileges. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Quality Orchestrator🟢 LOW · 🧪 Tests to Run · Running 1 of 57 tests
▶ Run commandnpx vitest run \
unit/mcp/testCaseId.test.ts⚡ quality-orchestrator · |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up hardening from the adversarial review of PDX-510 (the
provar_testcase_generateid allocator, merged in #217). Two findings, both insrc/mcp/utils/testCaseId.ts.Fixes
Path-policy containment (the substantive one).
maxProjectTestCaseIdwalked the project subtree and read every*.testcaseentry, with no allowed-path check on the files it read. A symlinked.testcaseinside the project could therefore pull a rootidout of a file outside the configured--allowed-paths— violating the containmentallocateTestCaseIddocuments ("the project scan never leaves [the allowed roots]") and the CLAUDE.md path-safety rule. The reviewer demonstrated a working escape. Fix: only read real files (entry.isFile() && !entry.isSymbolicLink()), so an out-of-root symlinked.testcaseis skipped. (Directory symlinks were already skipped —isDirectory()is false for them.)Unsafe-integer ids. A
.testcasewith a numeric id beyondNumber.MAX_SAFE_INTEGER(≥ ~16 digits) mademax + 1render in scientific notation, so the generator could emit a malformedid="1e+22". Fix:readRootTestCaseIdignores ids that aren'tNumber.isSafeInteger, falling back to the normal precedence.Tests
Added to
test/unit/mcp/testCaseId.test.ts:.testcasepointing outside the allowed roots is ignored (id stays in-root) — skipped automatically on hosts/CI without symlink privileges;Verification
Behavior on real projects is unchanged — normal files satisfy
isFile(), and real corpus ids are small. No public-doc impact;docs/mcp.mduntouched (no tool surface change).Reviewed adversarially (no Copilot review per current session policy).
🤖 Generated with Claude Code