Repository navigation
Fix POSIX backslash anchor normalization - #9
Merged
Merged
Conversation
resolve_and_validate_anchors() looked up 'src\payment.py' literally on Linux and rejected it, while retrieve(anchor_files=...) already normalizes backslashes. Try the exact spelling first, then (POSIX only) the forward-slash spelling. All containment checks still apply to the resolved file. Add a test that '..\outside.py' is still rejected. Fixes test_resolve_and_validate_anchors_normalization on Linux CI. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 to the merged PR #8. It adds the fix commit (
8e19fde), which was pushed tofeat/cli-json-anchor-supportafter #8 had already merged. That commit therefore never reachedmainand never went through the pull-request CI checks. It is cherry-picked here unchanged onto currentmain.Problem
On Linux and macOS,
reponeedle --anchors 'src\payment.py'failed with "does not exist or is not a regular file".resolve_and_validate_anchors()looked for a file literally namedsrc\payment.py. The Python API (retrieve(anchor_files=...)) already converts backslashes to forward slashes, so the CLI and the API behaved differently.This caused the one failure in each
Production CImatrix job on PR #8 (test_resolve_and_validate_anchors_normalization, Python 3.10, 3.11 and 3.12). The same failure is therefore expected onmainnow.Fix (
reponeedle/cli.py)os.sep == "/"), and only if the anchor contains a backslash, the forward-slash spelling is tried next...traversal check;Tests (
tests/test_cli_anchors.py)test_resolve_and_validate_anchors_backslash_traversal_rejected...\outside_bs.py(a real file just outside the repository) must still be rejected with "resolves outside repository root".test_resolve_and_validate_anchors_normalizationcoverssrc\payment.py→src/payment.py.Verification
mainreponeedle/cli.pyandtests/test_cli_anchors.py(+24/−8)mcp-security-linux)main:src\payment.pyrejected (reproduces the CI failure). This branch: resolves tosrc/payment.py;..\outside.pyrejectedReal POSIX confirmation comes from this PR's Linux CI jobs.
No version bump, tag or publication.
🤖 Generated with Claude Code