Add exclude option to skip gems by name during audit#419
Conversation
46e148a to
4a34598
Compare
|
Rebased onto current |
flavorjones
left a comment
There was a problem hiding this comment.
This seems reasonable given Rails allows applications to opt out of using gems via options like --skip-active-storage but those gems are still hard dependencies in Gemfile.lock.
I'm open to merging this. But please take a look at the failing test, seems like there's a missing Gemfile.lock in one of the test fixtures.
Allow users to exclude entire gems from scanning via config file (`exclude:` key in .bundler-audit.yml) or CLI (`--exclude`/`-e` flag). Unlike `ignore` which skips specific advisory IDs after lookup, `exclude` skips gems entirely before any advisory database check. This is useful for Rails apps that bundle gems they don't actually use (e.g. activestorage, actiontext) where every new CVE triggers a false audit failure. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The new spec/bundle/unpatched_gems_with_exclude_configuration fixture was missing its Gemfile.lock, causing the scanner spec to raise Bundler::GemfileLockNotFound in CI across all Ruby versions. The lockfile is matched by .gitignore (Gemfile.lock is ignored globally), which is why a plain `git add` silently skipped it. Force-added to match the pattern used for every other fixture under spec/bundle/. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
4a34598 to
ab5b9b8
Compare
Thanks, looks like it needed a |
Description
Adds an
excludeconfiguration option (and--exclude/-eCLI flag) that skips entire gems by name during scanning, so they never hit the advisory database at all.This is semantically different from
ignore(which skips specific advisory IDs after lookup):excludeis a scoping decision — "this gem isn't part of my application" — whileignoreis a risk acceptance — "I know about this CVE and accept it."Useful for Rails apps that bundle gems they don't actually use (e.g.
activestorage,actiontext,actionmailbox) where every new CVE triggers a false audit failure. Currently the only workaround is adding each CVE ID to theignorelist, which is tedious and never-ending.Usage
Config file (
.bundler-audit.yml):CLI:
Changes
Configuration: newattr_reader :exclude(returnsSet<String>), YAML validation mirroringignoreScanner#scan_specs: resolvesexcludefrom options or config, skips gem before advisory lookup vianext if exclude.include?(gem.name)CLI#check: new--exclude/-earray option, passed through toscanner.reportTest plan
#initializetests (default empty Set, given:excludelist):excludeoption filters gems from results.bundler-audit.ymlconfig file works