GeezerVison is showing github.com — Guard single-segment name/version coordinates through one path_safety check (#748) by mikolalysenko · Pull Request #1153 · SocketDev/socket-patch
Conversation
LLM Description written by Claude Code:claude-opus-5-5
Refs #748 (the #630 item, crawler coordinate guards). #748 is a tracker, so this PR doesn't close it.
Summary
The cargo, gem and NuGet crawlers each had their own copy of one coordinate guard: both name and version must be a single safe path segment. The cargo/gem/nuget and PyPI purl builders also wrote the same check inline. This PR adds patch::path_safety::is_safe_name_version, routes all of those callers through it, and deletes the three copies along with their three duplicated test tables.
Why
- Register row E37 (register); living document
doc/06-discovery-vex.md, "The crawlers re-implement the validators".
- Leverage: B 0, U 0, D 3 (five implementations of one rule become one), R low. This was the best eligible item. Every higher-ranked candidate (Tracking: revert every vendored backend through one record-revert engine instead of nine hand-written mechanisms #989 finish blocks, Read and splice nuget.config through formats::nuget in hosted, vendored and restore #594/Locate hosted Maven pom edits and their upstream restore through the formats::maven element scanner #717, Agent-mode JVM crawl finds no Coursier cache for a scala-cli or sbt root that only SCALA_TOOL_MARKERS recognizes, because six marker lists disagree #1014, C69, pnpm node-linker=pnp with a modulesDir is refused as yarn Plug'n'Play, because the layout detector ignores the modulesDir the crawler honors #1129) changes files that open
arch-refactor/* or agent/fix-* PRs also change.
What changed
patch/path_safety.rs: new is_safe_name_version(name, version).
crawlers/{cargo,ruby,nuget}_crawler.rs (plus NuGet's test-only oracle): the find_by_purls paths call it.
utils/purl.rs: simple_purl and pypi_purl call it.
Deleted
is_safe_cargo_coordinate, is_safe_gem_coordinate, is_safe_nuget_coordinate and their doc blocks.
test_is_safe_{cargo,gem,nuget}_coordinate.
- Production lines: about +19 / −49. Test lines: about +78 / −92 (
git diff --stat: 6 files, +97 / −141).
Remaining in the #630 item
Behavior
None. The new function's body is the same expression the deleted copies had.
Tests
path_safety::name_version_accepts_real_coordinates_and_fails_closed: one table covering the union of the three crawler test cases (traversal, separators, NUL, empty, C: drive-relative).
path_safety::purl_builders_agree_with_the_name_version_guard: runs simple_purl for cargo, gem and nuget, and pypi_purl, over every row of that table. Each must build exactly the pairs the guard accepts.
- The crawlers' existing
find_by_purls traversal regressions still pass.
Evidence
cargo clippy --workspace --all-features -- -D warnings: clean.
cargo test -p socket-patch-core --lib: 5777 passed, 4 failed. The 4 failures are the known root-only sandbox tests (copy_tree::relax_loop_must_not_traverse_symlinked_root, vlt_heal::an_unremovable_hidden_lock_keeps_every_store_entry, pypi_poetry::wire_write_failure_maps_error_and_leaves_lock_untouched, pypi_requirements::wire_failure_rolls_back_already_written_files), and they fail on main too.
crawler_cargo_e2e 34/34, crawler_nuget_e2e 28/28, crawler_ruby_e2e 29/29.
Risk
Low. This is a mechanical change with the same predicate. The wrappers (npm/, pypi/, gem/) are unaffected.
🤖 Generated with Claude Code
https://claude.ai/code/session_01AycK5PbbP2GwCwLL4xsdFV
Note Low Risk
Mechanical deduplication of an existing path-traversal guard with no predicate change; security-sensitive call sites are unchanged in effect.
Overview
Introduces path_safety::is_safe_name_version as the single fail-closed check that both PURL name and version are safe single path segments (blocking traversal, separators, NUL, C:, etc.) before crawlers join them onto on-disk package roots.
Cargo, Ruby, and NuGet find_by_purls paths (including the NuGet test oracle) now call this helper instead of ecosystem-specific is_safe_*_coordinate wrappers; those three functions and their duplicated unit test tables are removed.
PURL builders simple_purl (cargo/gem/nuget) and pypi_purl use the same guard instead of inlining twin is_safe_single_segment checks. Consolidated tests in path_safety cover the former crawler cases and assert builders accept/reject the same coordinate pairs.
Behavior is unchanged — the new function is the same is_safe_single_segment conjunction the deleted copies used; existing crawler traversal security regressions remain.
Reviewed by Cursor Bugbot for commit 833c2e4. Configure here.
Generated by Claude Code
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Assisted-by: Claude Code:claude-opus-5-5
The cargo, gem and NuGet crawlers each kept a private copy of the
same coordinate guard, and the cargo/gem/nuget and PyPI purl
builders inlined it a fourth and fifth time. They now all call
path_safety::is_safe_name_version, so a tampered manifest purl is
refused by one rule. One table test replaces the three crawler test
copies, and a second pins the purl builders to the guard.
No behavior change.
Refs #748
Assisted-by: Claude Code:claude-opus-5-5
cursor[bot] reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 833c2e4. Configure here.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
[agent] sbt 1.13.0 e2e_sbt_vendor_build / windows-latest failed in scripts/sbt-warm-seed.sh, before any test ran. The sbt launcher couldn't download org.scala-sbt:sbt:1.13.0: both repo1.maven.org and repo.scala-sbt.org returned forbidden (log).
This isn't caused by this PR, which only changes the cargo/gem/NuGet crawler coordinate guards and the purl builders (no sbt, JVM or CI files). #1148 is working on Central blips for the sbt docker legs, but no fix covers this setup-step download yet. I'm re-running the failed jobs once.
Generated by Claude Code
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Burn-down agent: labeled Ready for review at head 833c2e4c42.
- CI: 324/324 non-skipped check runs green on this head (57 skipped), mergeable clean. The earlier
sbt 1.13.0 e2e_sbt_vendor_build / windows-latest setup-step download failure (Maven Central / scala-sbt 403) passed on re-run.
- Bugbot: reviewed
833c2e4, no findings, no open review threads.
- Already approved once.
- Reviewer focus:
patch::path_safety::is_safe_name_version now backs the cargo/gem/NuGet crawler guards and the purl builders; the three duplicated test tables were deleted in favour of one.
Generated by Claude Code
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Labels
arch-refactor
PR opened by the scheduled architecture refactor routine
Ready for review
Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review
refactor
Structural change: duplicated code or logic, missing abstraction, layering, dead code
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.
|