fix(sandbox-lint): normalise every trailing slash, not just one - #1149
Open
AmirF194 wants to merge 1 commit into
Open
fix(sandbox-lint): normalise every trailing slash, not just one#1149AmirF194 wants to merge 1 commit into
AmirF194 wants to merge 1 commit into
Conversation
_normalise() stripped a single trailing slash so a config path and its
slash variant compare equal against FORBIDDEN_ALLOW_READ /
FORBIDDEN_ALLOW_WRITE. A path with two or more trailing slashes (e.g.
"~/.ssh//") only lost one, so it never matched the forbidden entry and
check_invariants() reported no violation for a config that grants read
or write access into a credential directory.
Strip all trailing slashes instead, keeping the bare-root case ("/")
intact. Added a double-slash case to the existing parametrized
allowRead/allowWrite tests; both fail on main and pass with this
change.
Generated-by: Claude Code (Sonnet 5)
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
_normalise()only stripped one trailing slash, so~/.ssh//(two slashes) never matched the normalised~/.sshforbidden entry andcheck_invariants()passed a config it should have rejected.Type of change
tools/*/withpyproject.toml)Test plan
allowRead/allowWriteparametrized tests; both are red on main, green on this branch.ruff check,ruff format --checkandmypyontools/sandbox-lintare clean (mypy needspytestinstalled to resolve the test-file imports; not a change this PR introduces).tools/sandbox-lintsuite: 55 passed, in a cleanpython:3.11-slimcontainer. Did not runprekitself (not available in this sandbox), ran the underlying ruff/mypy/pytest commands by hand instead.RFC-AI-0004 compliance
Linked issues
Fixes #1148.