gemshttp

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Overview

Package gemshttp serves RubyGems and Bundler's native repository protocol on Artifactory's /artifactory/api/gems/{repo} prefix, on gems local, federated, remote and virtual repositories: gem push and yank, the gems themselves, the compact index Bundler reads, the legacy Marshal indexes gem reads, and the gem, versions and search JSON. The archive and index rules are the format package's (artifacts/ecosystem/gems); this package answers HTTP with them.

Role

artifacts module, ecosystem layer: the native RubyGems and Bundler protocol of the RubyGems slice. It is named gemshttp so that it does not shadow net/http. Outside tests, only its own http subtree, the module's http adapters and app may import it (decision 0044, dependency rule 9).

Inputs

  • Driving: the server, which mounts Protocol through the router kit (pkgroute) for repositories of package type gems. JFrog's reindex operation, /api/gems/{repoKey}/reindex, is served beside the protocol, not by it.
  • Driven: the router kit (pkgroute.Kit), whose store (pkgroute.Store) the handlers also reach through DB(), and which resolves the repository and the caller, checks permissions, stores a pushed gem through the item service, where the format's hooks admit it, deletes a yanked one, reads items and blobs, builds a virtual repository's member requests, serves items and writes errors; the remote source service, which fetches a remote's upstream compact index and gems into the remote cache; and the format package, whose rules read every gem and render and check every index.

Outputs

  • Protocol and Options: the routes, the source of each repository class, the reserved reindex and updateIndex paths and the Artifactory error profile.
  • Answers: a push's "Successfully registered gem" text, a yank's "Successfully deleted gem" text, a gem, the compact index (names, versions and info/<name>), the Marshal indexes (specs.4.8.gz, latest_specs.4.8.gz, prerelease_specs.4.8.gz and quick/Marshal.4.8/<file>.gemspec.rz), and JSON for a gem's latest version (api/v1/gems/<name>.json), its versions (api/v1/versions/<name>) and a name search (api/v1/search.json). The compact index and the Marshal indexes, which 7.x stores, answer as a stored file in the package download service's form (serveDocument, RTFACT-27459): X-Artifactory-Filename, Content-Disposition, the X-Checksum headers, Last-Modified, Accept-Ranges and Cache-Control: no-store, with the quoted MD5 as the compact index's ETag and the bare SHA-1 as a Marshal index's. The JSON answers are private and kept by no cache (Cache-Control: private, no-store), with an MD5 ETag. Every index answer carries a SHA-256 Repr-Digest.

Invariants

  • Only local and federated repositories take a push or a yank (405), with write or delete permission under gems/. A pushed gem of at most 256 MiB must read as valid (400) and is stored at the path its identity gives, never over a stored version (409). A yank's form, at most 4 KiB, or its query, names the gem, its version and its platform (ruby when none is given).
  • Only the api/v1/search paths take a query (400); any other path that is neither a gem nor an index answers 404.
  • Index answers list only the gems the caller may read. A local or federated repository renders them from its stored gems and fails closed when one cannot be read. A remote renders them from its upstream's compact index, whose info files must match the MD5 the versions file lists, and fetches a gem only when that index lists its version, delivering it only when it validates and matches the listed SHA-256. A virtual repository renders them from its members in order: the first member to list a path supplies it, the caller must be able to read it in both repositories, and a member cycle is refused (400).
  • The download policy, after read permission: a blacked-out local or federated repository refuses its spec index files, quick gemspecs and compact index with the blackout's 404, and a pattern on a spec index file's or gemspec's own path refuses it, as 7.x refuses those stored files; the JSON API and search keep their answers. A virtual repository's own patterns refuse a spec index file or gemspec, and its indexes leave out a blacked-out member and, for a spec index file or gemspec, a member whose patterns reject that path. A pattern on one gem leaves the gem listed. A virtual gem download passes over a member that is blacked out or refuses the gem. A remote's own index reads check only its blackout.
  • A listing is bounded: more than 10,000 stored files, or upstream gem names, fails as an invalid result.
  • Statuses and error texts stay byte-identical.

References

Status

Implemented P9c, which delivered the plan's P30 group (issues #762 to #768). Moved here in P9d.

Testing

  • gems_test.go: the gem and versions JSON documents, unknown index paths, and the virtual source's refusal of a single-item lookup.

The guard suite test/server/artifacts/gems drives the protocol through the whole server: local, federated and virtual reads, push and its permissions, refused requests, yank, token authentication, a virtual repository's member filtering and cycles, stored gems that fail closed, the remote's index checks, cache, offline reads and redirects, the download policy on local, virtual and remote reads, the stored index documents' file headers and revalidation (gems_index_headers_test.go), and the gem and Bundler clients installing a pinned rake (TestAccRubyClientsInstallPinnedRake, which skips unless gem and bundle are installed). The @gems acceptance scenarios drive gem and Bundler against all four classes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Protocol

func Protocol(o Options) pkgroute.Protocol

Protocol returns the RubyGems and Bundler protocol for the router kit, under /artifactory/api/gems/{repoKey}: POST of a gem to api/v1/gems to push it and DELETE of api/v1/yank or api/v1/gems/yank to yank one, on local and federated repositories; and GET and HEAD of a gem (gems/<file>.gem), the compact index (names, versions and info/<name>), the Marshal indexes (specs.4.8.gz, latest_specs.4.8.gz, prerelease_specs.4.8.gz and quick/Marshal.4.8/<file>.gemspec.rz) and the api/v1 gem, versions and search JSON. Local and federated repositories are served from their stored gems, virtual ones from their members in order, and remote ones through o.RemoteSources when it is set; a class without a source answers 501. The virtual class's source supports no single-item lookup, because the protocol reads a virtual repository's members itself. {repoKey}/reindex and {repoKey}/updateIndex are reserved, so neither is read as a package path; the server serves JFrog's reindex operation beside the protocol.

Types

type Options

type Options struct{ RemoteSources *source.Service }

Options configures the RubyGems protocol. RemoteSources serves remote repositories and fetches through them; nil leaves the remote class without a source, so a remote repository answers 501.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL