Auditing dependencies

What is outdated

Two different questions hide behind "dependencies are fine". The first is age: is a newer version available? The second is safety: is the version you have known to be broken? Bundler answers the first with bundle outdated:

bundle outdated

Gem Current Latest Requested Groups Release Date
minitest 5.27.0 6.0.6 ~> 5.20 default

The line says everything at once: the Ruby project has 5.27.0, the newest release is 6.0.6, and the Gemfile asks for 5.x. That is not a bug; it is a decision to stay on the 5 line, and the report makes the decision visible. A major version is not a free upgrade, so read the release notes before changing the constraint.

The advisory check

The second question has its own tool. bundler-audit compares Gemfile.lock with the ruby-advisory-db and reports gems with a known vulnerability:

gem install bundler-audit

2 gems installed

Update the advisory database and check the lock file

bundler-audit check --update

Cloning into '/root/.local/share/ruby-advisory-db'... ruby-advisory-db: advisories: 1351 advisories last updated: 2026-11-04 09:42:55 -0500 commit: 516ea4757d5eec778c49af8371c23309c4b70f42 No vulnerabilities found

--update clones or refreshes the newest list before the check; without it the result depends on when the list was last refreshed. On a dependency that has no advisory it prints No vulnerabilities found and exits zero; any finding prints the gem, the advisory id and the fixed version, and makes the command exit nonzero.

The step in the pipeline

Like the linter, the audit gets a Rake task and a place in the pipeline task:

desc "Check the lock file for known advisories" task :audit do sh "bundler-audit check --update" end desc "Run the whole pipeline" task ci: %i[test lint audit]

Put the audit last in the list: it downloads a database, so it is slower than the tests and it should not delay a failure that a test would catch. The pipeline fails on the first red step, and the order decides which red step a reader sees.

What to watch for

An audit is a snapshot, not a certificate. The advisory database grows every week, so a pipeline that was green last month can be red today with no change of your own; that is the tool working, not breaking.

Do not silence a finding with a version pin. Update the gem, or, when the update is impossible yet, record the exception in one place with a date and a reason, so the next reader knows it was a decision.

Questions

A new set of questions in a new order every time. Choose one answer for each, then check.

  1. What do bundle outdated and bundler-audit check answer?

    Answer

    The first asks whether a newer version exists, the second whether the installed version has a known advisory

    Age and safety are two questions, and a project can be current and vulnerable or old and safe.

  2. What does this program print? lock = <<~LOCK GEM specs: rake (13.4.2) minitest (5.27.0) LOCK p lock.scan(/\((\d[\d.]*)\)/).flatten

    Answer

    ["13.4.2", "5.27.0"]

    The capture group takes the version inside the parentheses of each spec line, which is how a script reads a lock file.

  3. What does this program print? req = Gem::Requirement.new("~> 5.20") p req.satisfied_by?(Gem::Version.new("5.27.0")) p req.satisfied_by?(Gem::Version.new("6.0.6"))

    Answer

    true / false

    The ~> constraint stays inside the 5.x line, so 5.27 is allowed and the 6.0 release is not.

  4. What does this program print? p Gem::Version.new("5.27.0").segments

    Answer

    [5, 27, 0]

    A version is a list of numbers, which is why 5.27 is newer than 5.9 and a string sort gets it wrong.

  5. What does bundler-audit check print and exit with when it finds an advisory?

    Answer

    The gem, the advisory id and the fixed version, and a nonzero status

    The nonzero status is what makes the pipeline red, and the fixed version is what the reader needs to act on.

  6. What does this program print? advisories = { "CVE-1" => "actionpack", "CVE-2" => "rake", "CVE-3" => "rake" } p advisories.values.uniq.size

    Answer

    2

    uniq keeps one name per gem, which is how a report groups several advisories of the same package.

  7. Why is the audit the last prerequisite of the ci task?

    Answer

    It downloads a database, so it is slow and should not delay a failure the tests would catch

    The pipeline stops at the first red step, so the cheap checks go first and the network-bound one goes last.

  8. What does this program print? req = Gem::Requirement.new(">= 6.0") p req.satisfied_by?(Gem::Version.new("5.27.0"))

    Answer

    false

    A major-version floor is not met by a 5.x release, which is why a constraint change is a decision and not a free upgrade.

  9. A finding is real but the update is not possible yet. What does the page advise?

    Answer

    Record the exception in one place with a date and a reason

    A written exception is a decision a reader can review, while a silent pin or a skipped audit hides the risk.

  10. What does this program print? lock = " rake (13.4.2)" p lock[/\((\d[\d.]*)\)/, 1]

    Answer

    "13.4.2"

    The first capture group returns the text inside the parentheses, without them.

Article author: Arthur Isaev