Skip to content

Fix #403: exit with error when --gemfile-lock is not a valid lock file#414

Open
kallal79 wants to merge 1 commit intorubysec:masterfrom
kallal79:fix/issue-403-invalid-gemfile-lock
Open

Fix #403: exit with error when --gemfile-lock is not a valid lock file#414
kallal79 wants to merge 1 commit intorubysec:masterfrom
kallal79:fix/issue-403-invalid-gemfile-lock

Conversation

@kallal79
Copy link

Bundler::LockfileParser silently accepts any file (Gemfile, README.md, etc.) and returns empty results, causing bundle-audit to exit 0 with 'No vulnerabilities found' even when given the wrong file.

Changes:

  • Add Scanner::InvalidGemfileLock exception class
  • Add LOCKFILE_HEADER_RE regexp to validate lock file content before parsing
  • Raise InvalidGemfileLock in Scanner#initialize when file does not start with a recognised Bundler lockfile section header
  • Rescue InvalidGemfileLock in CLI#check and exit with status 1 plus a descriptive stderr message
  • Add spec for Scanner#initialize raising InvalidGemfileLock
  • Add specs for CLI#check printing error to stderr and exiting with 1

Fixes #403

…ock file

Bundler::LockfileParser silently accepts any file (Gemfile, README.md,
etc.) and returns empty results, causing bundle-audit to exit 0 with
'No vulnerabilities found' even when given the wrong file.

Changes:
- Add Scanner::InvalidGemfileLock exception class
- Add LOCKFILE_HEADER_RE regexp to validate lock file content before parsing
- Raise InvalidGemfileLock in Scanner#initialize when file does not start
  with a recognised Bundler lockfile section header
- Rescue InvalidGemfileLock in CLI#check and exit with status 1 plus a
  descriptive stderr message
- Add spec for Scanner#initialize raising InvalidGemfileLock
- Add specs for CLI#check printing error to stderr and exiting with 1

Fixes rubysec#403
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Exits normally when --gemfile-lock is not a lock file, should exit with error

1 participant