feat(parsers): wire up cargo, gem, and go shims#28
Open
gok03 wants to merge 1 commit into
Open
Conversation
The README advertised cargo / gem / go support and KnownManagers listed
them, but they had no argv parser (ForName returned nil → passthrough)
and weren't in DefaultShims. So `refuse install` never dropped shims for
them, and even if invoked directly they'd pass through ungated. The gate
worked for those ecosystems only via the explicit `refuse check <eco>`
path.
This closes the gap:
internal/parsers/cargo.go — `cargo add` / `cargo install`. Handles the
`serde@1.0` form and the `--vers` / `--version` flag form. Skips
--path / --git local installs.
internal/parsers/gem.go — `gem install` / `gem i`. Handles `-v` /
`--version` and the `rails:6.1.0` colon form. Skips local .gem files.
internal/parsers/gomod.go — `go get` / `go install`. module@version,
with @latest/@upgrade/@patch/@none treated as unpinned. Skips
./... , all, and local paths.
Each registered in registry.go and added to DefaultShims so
`refuse install` lays down all 9 shims (npm, pnpm, yarn, bun, pip, pip3,
cargo, gem, go). 27 new table-driven test cases.
Verified end-to-end against the live server:
- gem install rack:2.0.0 → blocked (high)
- go get …/jwt-go@v3.2.0 → blocked (high)
- cargo add smallvec@0.6.13 → blocked (critical), both @ and
--vers forms
- cargo add time@0.1.43 → allowed (only medium, below the
default high threshold) — correct
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.
Why
While testing all platforms, found that `cargo`, `gem`, and `go` were advertised in the README and listed in `KnownManagers`, but:
The gate worked for those ecosystems only via the explicit `refuse check ` path — a real `cargo add ` at the terminal sailed through.
What
Three new parsers, registered + added to the default install set:
`DefaultShims` now installs all 9: npm, pnpm, yarn, bun, pip, pip3, cargo, gem, go. 27 new table-driven test cases.
Verified end-to-end (live server)
Note for existing installs
Anyone who ran `refuse install` before this ships only has the 6 npm/pip shims. After upgrading they'll need to re-run `refuse install` to pick up the cargo/gem/go shims.
Test plan