Repository navigation
Conversation
7aa9bef to
12b0626
Compare
JosephDoUrden
left a comment
There was a problem hiding this comment.
Ran go test -race -run RubyGems ./internal/validators/registries/: 14 tests and 7 live subtests pass, vet and gofmt clean. Mutated the validator 11 ways (ownership compare, yanked, probe method/deadline, 404 mapping, guards); tests caught 10, the miss was dropping PathEscape on the gem name, a no-op for valid names ([A-Za-z0-9._-]). One thing: since #1889, ecosystem() in internal/malware/osv.go skips unknown types, so rubygems publishes would bypass the OSV check. Mapping it to RubyGems after a rebase would cover it. LGTM otherwise.
## Motivation and Context Ruby MCP servers published to rubygems.org cannot be registered through their native package registry today; the only options are an OCI image or an MCPB download. This adds registryType "rubygems", following docs/contributing/add-package-registry.md and mirroring the cargo work (modelcontextprotocol#1207). Design decisions: - Ownership verification reads the gemspec metadata key "mcp_name" from the version-specific rubygems.org API (/api/v2/rubygems/{name}/versions/{version}.json), which covers existence, version, and ownership in a single call. This mirrors the npm validator's manifest-field approach (mcpName in package.json) rather than the README-token approach used for PyPI/NuGet/cargo: rubygems.org has no README API, and gemspec metadata is a first-class, author-controlled field. - The platform is left unspecified in that call so that versions published only as platform-specific builds can be registered. rubygems.org then chooses which build to return, so authors must set mcp_name in every platform build. - A 404 from the version endpoint is disambiguated with a HEAD probe of /api/v1/versions/{name}.json (gem missing vs version missing vs transient), following the npm validator. Yanked versions 404 on the version endpoint (verified against mimemagic 0.3.0); a 200 carrying yanked=true is still rejected defensively. - The documented client invocation is `gem exec --silent --conservative --gem NAME -v VERSION COMMAND`: `--silent` keeps install progress off stdout (required for the stdio transport), and `--conservative` runs offline when the version is already installed. gem exec ships with RubyGems 3.4.8+ (Ruby 3.2.2+), so runtimeHint "gem" is set, unlike cargo which has no single-shot runner. - rubygems packages are mapped to the OSV ecosystem "RubyGems", so the malware check (modelcontextprotocol#1889) covers them on publish and in the daily sweep. Names and versions are compared exactly: rubygems.org serves a release under one spelling only (13.2.1.0, v13.2.1, and 013.2.1 all 404 for rake 13.2.1), so unlike npm dist-tags there is no alternate version form that could slip past the check. - The sweep's missing-package check now skips registry types it has no probe for. It took its packages from the OSV coverage, so a rubygems package would have counted as rubygems.org giving no answer, marking every sweep incomplete and raising the warning alert daily. Asking rubygems.org whether a gem still exists needs its own decisions (how fully yanked gems should count, for example) and is left for a follow-up. Closes modelcontextprotocol#1582. ## How Has This Been Tested? - Validator tests are hermetic httptest mocks, including the positive path, plus live anchors against rubygems.org negative paths (missing mcp_name, missing gem, yanked version). The identifier is only checked for spaces before it reaches the request URLs, so a test also pins that a "/" or "?" in it stays escaped in both requests. - The OSV mapping is covered by the malware comparison tests and by a publish test in which a gem with a malware record is refused as malware; without the mapping the malware check never fires for it. Against live OSV, the batch query with ecosystem "RubyGems" returns MAL-2024-6715 for atlas-client 0.0.2 and nothing for 0.0.1. - A sweep test lists a rubygems package next to an npm one. Before the skip it failed with "rubygems gave no usable answer about 1 of its 1 packages" and an incomplete sweep; now only npm is asked and the sweep is complete. - `make validate`, `make test-unit`, and `make test-integration` pass, and golangci-lint v2.14.0 reports 0 issues. - The documented invocation was run on RubyGems 4.0.3 from an empty GEM_HOME against an existing MCP server gem (debug-mcp 0.4.0): the first line on stdout is the JSON-RPC initialize response. Without `--silent` the first line is install output instead. With `--conservative` an installed version starts with the network blocked; without it the start fails. A `--` before COMMAND makes gem exec fail, so the documentation tells clients not to insert one. - Not tested: a publish against a real gem carrying mcp_name. I know of no such gem yet (none among the latest versions of 489 MCP-related gems on rubygems.org), so a live positive-path anchor will be added once one is published. ## Breaking Changes None. The change is additive: existing registry types and their validation are untouched.
12b0626 to
b61a277
Compare
|
Thanks for the review. Rebased onto main and mapped The mapping also fed RubyGems packages into the sweep's missing-package check, which has no rubygems.org probe. Once any RubyGems server was listed, sweeps would have been marked I'd keep |
|
Re-ran on b61a277: RubyGems, malware and sweep tests green under -race. Dropping the |
Motivation and Context
Ruby MCP servers published to rubygems.org cannot be registered through their native package registry today; the only options are an OCI image or an MCPB download. This adds registryType "rubygems", following docs/contributing/add-package-registry.md and mirroring the cargo work (#1207).
Design decisions:
gem exec --silent --conservative --gem NAME -v VERSION COMMAND:--silentkeeps install progress off stdout (required for the stdio transport), and--conservativeruns offline when the version is already installed. gem exec ships with RubyGems 3.4.8+ (Ruby 3.2.2+), so runtimeHint "gem" is set, unlike cargo which has no single-shot runner.Closes #1582.
How Has This Been Tested?
make validate,make test-unit, andmake test-integrationpass, and golangci-lint v2.14.0 reports 0 issues.--silentthe first line is install output instead. With--conservativean installed version starts with the network blocked; without it the start fails. A--before COMMAND makes gem exec fail, so the documentation tells clients not to insert one.Breaking Changes
None. The change is additive: existing registry types and their validation are untouched.
Types of changes
Checklist