Ruby
SlowShield serves rubygems.org at https://slowshield.example.com/rubygems. Bundler uses it
as a mirror of rubygems.org, so Gemfiles and Gemfile.lock keep naming rubygems.org; gem
uses it as its only source.
Set it up
Both settings live in your home directory and cover every project on the machine:
Bundler
Release age: Bundler 4.0.13 or later (older versions ignore it). It reads the created_at that SlowShield passes on
command (writes ~/.bundle/config; also for CI and Dockerfiles)
bundle config set --global mirror.https://rubygems.org https://slowshield.example.com/rubygemsrelease age
bundle config set --global cooldown 3gem
~/.gemrc: SlowShield as the only source
---
:sources:
- https://slowshield.example.com/rubygems/CI and Dockerfiles (replaces ~/.gemrc)
printf -- '---\n:sources:\n- %s\n' https://slowshield.example.com/rubygems/ > ~/.gemrc- A mirror, not a new
source. Gemfiles keepsource "https://rubygems.org", andGemfile.lockkeepsremote: https://rubygems.org/and its checksums, so a project builds the same with or without SlowShield. - No
fallback_timeout. Withmirror.https://rubygems.org.fallback_timeoutset, Bundler goes to rubygems.org when SlowShield doesn't answer in time. - The mirror covers
https://rubygems.orgonly. Other gem servers,git:andgithub:gems, and a Gemfile that sayssource "http://rubygems.org"go around it. - Leave rubygems.org out of
~/.gemrc.gemasks every source it lists.gem sourcesshows them.
What changes
- The publish time is the
created_atrubygems.org writes for every version in its index. The first one SlowShield sees is kept, so it can't move earlier. - Held versions are left out of the index Bundler and
gem installread, sobundle update,bundle addandgem installpick the newest version that is old enough. - Platform gems wait on their own. Every platform gem (
nokogiri-1.19.4-x86_64-linux-gnu) is pushed separately, with its own time. One pushed today for a version that is a year old waits like a new version, and Bundler installs the plain gem of that version, or an older version, meanwhile. - A
Gemfile.lockthat pins a held version fails, because Bundler can't find it in the index:Bundler says the author removed it; here it means the version is younger than the delay.Your bundle is locked to rubocop (1.92.1) from rubygems repository https://rubygems.org/ or installed locally, but that version can no longer be found in that source.bundle update rubocoppicks the newest version that is old enough. - Asking for the gem file itself gets
425 Too EarlywithRetry-After; Bundler andgemshow only the status line, curl the message. - Brand-new gems none of whose versions is old enough are held too: RubyGems doesn't fail open,
because brand-new gems are the realistic attack (typosquats). Bundler and
gemsay they can't find the gem. - Malware from OSV and GitHub is refused: left out of the index, and
451for the file. Every.gemis checked against the sha256 in rubygems.org's index and the fingerprint SlowShield recorded the first time, and never changed, soGemfile.lockCHECKSUMSkeep matching.
The second layer
Bundler 4.0.13 and later have a release age of their own, cooldown, in days. It reads the same
created_at, which SlowShield passes on unchanged. gem has none: there, SlowShield is the only
layer.
In Docker and CI
Run the commands in the build stage, before bundle install. With a build argument, the same Dockerfile
still builds without SlowShield when the argument is empty:
FROM ruby:3.4
ARG RUBYGEMS_MIRROR=https://slowshield.example.com/rubygems
RUN if [ -n "$RUBYGEMS_MIRROR" ]; then \
bundle config set --global mirror.https://rubygems.org "$RUBYGEMS_MIRROR" && \
printf -- '---\n:sources:\n- %s/\n' "$RUBYGEMS_MIRROR" > ~/.gemrc; fi
WORKDIR /app
COPY Gemfile Gemfile.lock ./
RUN bundle install
COPY . .In CI, run the Setup page's commands before bundle install. ruby/setup-ruby with
bundler-cache: true installs the gems within its own step, before any command of yours can run: leave
it off and run bundle install after the commands. Building images covers the base
image too, and how to check that nothing in a build goes around SlowShield.
Limits
gem search,gem list --remote,gem outdatedandgem updateneed rubygems.org's full index, which lists every gem without times and so can't be filtered: they find nothing through SlowShield, andgem update --systemfails.bundle outdatedandbundle updatework.- Checked with Bundler 2.4, 2.6 and 4.0 and RubyGems 3.6.
- Not served: publishing (
gem push,yankandownergo to rubygems.org), and other gem servers. - Gems already installed, or in Bundler's cache, are used without asking SlowShield.
- Block rubygems.org and index.rubygems.org at the firewall for machines that should only use SlowShield.
For agents: this page as Markdown · llms.txt · the SlowShield skill