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

Allow for ignoring insecure sources. #189

Open
wants to merge 1 commit 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/bundler/audit/scanner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,21 @@ def scan(options={},&block)
def scan_sources(options={})
return enum_for(__method__,options) unless block_given?

ignore = Set[]
ignore += options[:ignore] if options[:ignore]

@lockfile.sources.map do |source|
case source
when Source::Git
case source.uri
when /^git:/, /^http:/
unless internal_source?(source.uri)
unless internal_source?(source.uri) || ignore.include?(source.uri)
yield InsecureSource.new(source.uri)
end
end
when Source::Rubygems
source.remotes.each do |uri|
if (uri.scheme == 'http' && !internal_source?(uri))
if (uri.scheme == 'http' && !internal_source?(uri)) && !ignore.include?(uri.to_s)
yield InsecureSource.new(uri.to_s)
end
end
Expand Down
10 changes: 9 additions & 1 deletion spec/scanner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

it "should ignore the specified advisories" do
ids = subject.map { |result| result.advisory.id }

expect(ids).not_to include('OSVDB-89026')
end
end
Expand All @@ -58,6 +58,14 @@
expect(subject[0].source).to eq('git://github.com/rails/jquery-rails.git')
expect(subject[1].source).to eq('http://rubygems.org/')
end

context "when ignoring insecure sources" do
subject { scanner.scan(:ignore => ['http://rubygems.org/', 'git://github.com/rails/jquery-rails.git']).to_a }

it "should print nothing when otherwise fine" do
expect(subject).to be_empty
end
end
end

context "when auditing a secure bundle" do
Expand Down