Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove platform duplicates #356

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/bundler/audit/scanner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def scan_specs(options={})
config.ignore
end

@lockfile.specs.each do |gem|
@lockfile.specs.select { |gem| gem.platform == "ruby" }.each do |gem|
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would cause bundler-audit to ignore platform specific gems, potentially allowing vulnerabilities to slip by.

@database.check_gem(gem) do |advisory|
is_ignored = ignore.intersect?(advisory.identifiers.to_set)
next if is_ignored
Expand Down
2 changes: 1 addition & 1 deletion spec/bundle/secure/Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
source 'https://rubygems.org'

gem 'rails', '~> 5.2'
gem 'rails', '~> 7.0.4'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need after changing the fixed commit of the advisory db

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we need to bump the rails version and the ruby-advisory-db commit, that can be done in a separate PR which I can immediately merge.

gem 'rails-html-sanitizer', '~> 1.4.3'
161 changes: 94 additions & 67 deletions spec/bundle/secure/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,55 +1,78 @@
GEM
remote: https://rubygems.org/
specs:
actioncable (5.2.8)
actionpack (= 5.2.8)
actioncable (7.0.4)
actionpack (= 7.0.4)
activesupport (= 7.0.4)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailer (5.2.8)
actionpack (= 5.2.8)
actionview (= 5.2.8)
activejob (= 5.2.8)
actionmailbox (7.0.4)
actionpack (= 7.0.4)
activejob (= 7.0.4)
activerecord (= 7.0.4)
activestorage (= 7.0.4)
activesupport (= 7.0.4)
mail (>= 2.7.1)
net-imap
net-pop
net-smtp
actionmailer (7.0.4)
actionpack (= 7.0.4)
actionview (= 7.0.4)
activejob (= 7.0.4)
activesupport (= 7.0.4)
mail (~> 2.5, >= 2.5.4)
net-imap
net-pop
net-smtp
rails-dom-testing (~> 2.0)
actionpack (5.2.8)
actionview (= 5.2.8)
activesupport (= 5.2.8)
rack (~> 2.0, >= 2.0.8)
actionpack (7.0.4)
actionview (= 7.0.4)
activesupport (= 7.0.4)
rack (~> 2.0, >= 2.2.0)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.2.8)
activesupport (= 5.2.8)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (7.0.4)
actionpack (= 7.0.4)
activerecord (= 7.0.4)
activestorage (= 7.0.4)
activesupport (= 7.0.4)
globalid (>= 0.6.0)
nokogiri (>= 1.8.5)
actionview (7.0.4)
activesupport (= 7.0.4)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (5.2.8)
activesupport (= 5.2.8)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
activejob (7.0.4)
activesupport (= 7.0.4)
globalid (>= 0.3.6)
activemodel (5.2.8)
activesupport (= 5.2.8)
activerecord (5.2.8)
activemodel (= 5.2.8)
activesupport (= 5.2.8)
arel (>= 9.0)
activestorage (5.2.8)
actionpack (= 5.2.8)
activerecord (= 5.2.8)
marcel (~> 1.0.0)
activesupport (5.2.8)
activemodel (7.0.4)
activesupport (= 7.0.4)
activerecord (7.0.4)
activemodel (= 7.0.4)
activesupport (= 7.0.4)
activestorage (7.0.4)
actionpack (= 7.0.4)
activejob (= 7.0.4)
activerecord (= 7.0.4)
activesupport (= 7.0.4)
marcel (~> 1.0)
mini_mime (>= 1.1.0)
activesupport (7.0.4)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
arel (9.0.0)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
builder (3.2.4)
concurrent-ruby (1.1.10)
crass (1.0.6)
erubi (1.10.0)
erubi (1.11.0)
globalid (1.0.0)
activesupport (>= 5.0)
i18n (1.10.0)
i18n (1.12.0)
concurrent-ruby (~> 1.0)
loofah (2.18.0)
crass (~> 1.0.2)
Expand All @@ -60,63 +83,67 @@ GEM
method_source (1.0.0)
mini_mime (1.1.2)
mini_portile2 (2.8.0)
minitest (5.15.0)
minitest (5.16.3)
net-imap (0.3.1)
net-protocol
net-pop (0.1.2)
net-protocol
net-protocol (0.1.3)
timeout
net-smtp (0.3.2)
net-protocol
nio4r (2.5.8)
nokogiri (1.13.6)
nokogiri (1.13.9)
mini_portile2 (~> 2.8.0)
racc (~> 1.4)
nokogiri (1.13.6-x86_64-linux)
nokogiri (1.13.9-x86_64-linux)
racc (~> 1.4)
racc (1.6.0)
rack (2.2.4)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (5.2.8)
actioncable (= 5.2.8)
actionmailer (= 5.2.8)
actionpack (= 5.2.8)
actionview (= 5.2.8)
activejob (= 5.2.8)
activemodel (= 5.2.8)
activerecord (= 5.2.8)
activestorage (= 5.2.8)
activesupport (= 5.2.8)
bundler (>= 1.3.0)
railties (= 5.2.8)
sprockets-rails (>= 2.0.0)
rack-test (2.0.2)
rack (>= 1.3)
rails (7.0.4)
actioncable (= 7.0.4)
actionmailbox (= 7.0.4)
actionmailer (= 7.0.4)
actionpack (= 7.0.4)
actiontext (= 7.0.4)
actionview (= 7.0.4)
activejob (= 7.0.4)
activemodel (= 7.0.4)
activerecord (= 7.0.4)
activestorage (= 7.0.4)
activesupport (= 7.0.4)
bundler (>= 1.15.0)
railties (= 7.0.4)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.4.3)
loofah (~> 2.3)
railties (5.2.8)
actionpack (= 5.2.8)
activesupport (= 5.2.8)
railties (7.0.4)
actionpack (= 7.0.4)
activesupport (= 7.0.4)
method_source
rake (>= 0.8.7)
thor (>= 0.19.0, < 2.0)
rake (>= 12.2)
thor (~> 1.0)
zeitwerk (~> 2.5)
rake (13.0.6)
sprockets (4.0.3)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.4.2)
actionpack (>= 5.2)
activesupport (>= 5.2)
sprockets (>= 3.0.0)
thor (1.2.1)
thread_safe (0.3.6)
tzinfo (1.2.9)
thread_safe (~> 0.1)
timeout (0.3.0)
tzinfo (2.0.5)
concurrent-ruby (~> 1.0)
websocket-driver (0.7.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
zeitwerk (2.6.1)

PLATFORMS
ruby
x86_64-linux

DEPENDENCIES
rails (~> 5.2)
rails (~> 7.0.4)
rails-html-sanitizer (~> 1.4.3)

BUNDLED WITH
Expand Down
1 change: 1 addition & 0 deletions spec/bundle/unpatched_gems/Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
source 'https://rubygems.org'

gem 'activerecord', '3.2.10'
gem 'nokogiri', '1.13.6'
10 changes: 9 additions & 1 deletion spec/bundle/unpatched_gems/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@ GEM
concurrent-ruby (1.1.7)
i18n (0.9.5)
concurrent-ruby (~> 1.0)
mini_portile2 (2.8.0)
multi_json (1.15.0)
nokogiri (1.13.6)
mini_portile2 (~> 2.8.0)
racc (~> 1.4)
nokogiri (1.13.6-x86_64-linux)
racc (~> 1.4)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are going to test Gemfile.lock containing gems from multiple platforms or gems which explicit platforms set in the Gemfile, I think that should be a separate spec/bundle/ directory (ex: spec/bundle/unpatched_multi_platform/).

racc (1.6.0)
tzinfo (0.3.58)

PLATFORMS
Expand All @@ -26,6 +33,7 @@ PLATFORMS

DEPENDENCIES
activerecord (= 3.2.10)
nokogiri (= 1.13.6)

BUNDLED WITH
2.2.0
2.3.4
4 changes: 4 additions & 0 deletions spec/scanner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
result.advisory.vulnerable?(result.gem.version)
}).to be_truthy
end

it "should have duplicates due to platform" do
expect(subject.select { |advisory| advisory.gem.name == 'nokogiri' }.map { |advisory| "#{advisory.gem.name}##{advisory.gem.version}##{advisory.gem.platform}" }).to eq(["nokogiri#1.13.6#ruby"])
end
end

context "when the :ignore option is given" do
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module Fixtures
module Database
PATH = File.join(ROOT,'database')

COMMIT = '89cdde9a725bb6f8a483bca97c5da344e060ac61'
COMMIT = '137a425b9f4f30f895df8765b0e773400170803d'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed to get latest advisory for nokogiri


def self.clone
system 'git', 'clone', '--quiet', Bundler::Audit::Database::URL, PATH
Expand Down