# RubyGems and Bundler

Point gem and Bundler at the Package Firewall, including the Bundler mirror that makes bundle install go through it.

| | |
|---|---|
| Source URL | `https://packages.vulnes.is/gem/` |
| Ecosystem ID | `gem` |
| CLI command | `vulnetix package-firewall gem` |
| Plan | Add-on |
| Mode | filter: the compact index is filtered |
| Cooldown | yes |
| Default mirror | `https://rubygems.org` |

## Automatic setup

```bash
vulnetix package-firewall gem
```

| File | Read by |
|---|---|
| `~/.gemrc` | the `gem` command |
| `~/.bundle/config` | Bundler, which ignores `.gemrc` and uses the Gemfile's `source` |

`~/.gemrc` gets a managed block:

```yaml
:sources:
- https://YOUR_ORG_UUID:YOUR_API_KEY@packages.vulnes.is/gem/
```

`~/.bundle/config` gets:

```yaml
BUNDLE_MIRROR__ALL: "https://packages.vulnes.is/gem/"
BUNDLE_MIRROR__HTTPS://RUBYGEMS__ORG: "https://packages.vulnes.is/gem/"
BUNDLE_PACKAGES__VULNES__IS: "YOUR_ORG_UUID:YOUR_API_KEY"
```

`mirror.all` redirects every Gemfile source through the firewall. The `rubygems.org` key is for Bundler versions before `mirror.all`. Bundler keys credentials on the mirror host, not the URL.

## Manual equivalent for Bundler

```bash
bundle config set --global mirror.https://rubygems.org https://packages.vulnes.is/gem/
bundle config set --global packages.vulnes.is "$VULNESIS_ORG_ID:$VULNESIS_API_KEY"
```

## Use and verify

```bash
gem sources --list
bundle config
bundle install
```

## Notes

- Without the Bundler mirror, `bundle install` goes straight to the Gemfile source and never meets the firewall.
- `Gemfile.lock` pinned to a blocked version fails at download. Run `bundle update <gem>`.
