Skip to content

Commit 1c383da

Browse files
authored
Merge branch 'main' into cleanup-database
2 parents e0beef1 + 7b2a8a6 commit 1c383da

File tree

6 files changed

+25
-20
lines changed

6 files changed

+25
-20
lines changed

CHANGELOG.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@ This project adheres to [Semantic Versioning](http://semver.org/).
77

88
### Removed
99

10-
* Removed check for stale database that no longer does anything
10+
* [#34](https://github.com/civisanalytics/ruby_audit/pull/34)
11+
Removed check for stale database that no longer does anything
12+
13+
### Fixed
14+
15+
* [#35](https://github.com/civisanalytics/ruby_audit/pull/35)
16+
Look for rubygems advisories in the correct directory of the ruby-advisory-db
1117

1218
## [2.3.0] - 2024-01-10
1319

lib/ruby_audit/database.rb

+3-4
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ def check_ruby(ruby, &block)
1414
check(ruby, 'rubies', &block)
1515
end
1616

17-
def check_library(library, &block)
18-
check(library, 'libraries', &block)
17+
def check_rubygems(rubygems, &block)
18+
check(rubygems, 'gems', &block)
1919
end
2020

2121
def check(object, type = 'gems')
@@ -29,8 +29,7 @@ def check(object, type = 'gems')
2929
protected
3030

3131
def each_advisory_path(&block)
32-
Dir.glob(File.join(@path, '{gems,libraries,rubies}', '*', '*.yml'),
33-
&block)
32+
Dir.glob(File.join(@path, '{gems,rubies}', '*', '*.yml'), &block)
3433
end
3534

3635
def each_advisory_path_for(name, type = 'gems', &block)

lib/ruby_audit/scanner.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ def scan_ruby(options = {}, &block)
3636
end
3737

3838
def scan_rubygems(options = {}, &block)
39-
specs = [Version.new('rubygems', rubygems_version)]
40-
scan_inner(specs, 'library', options, &block)
39+
specs = [Version.new('rubygems-update', rubygems_version)]
40+
scan_inner(specs, 'rubygems', options, &block)
4141
end
4242

4343
private

spec/database_spec.rb

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
require 'spec_helper'
22

33
describe RubyAudit::Database do
4-
describe '#check_library' do
5-
let(:library) { RubyAudit::Scanner::Version.new('rubygems', '2.4.5') }
4+
describe '#check_rubygems' do
5+
let(:rubygems) { RubyAudit::Scanner::Version.new('rubygems-update', '2.4.5') }
66

77
context 'when given a block' do
8-
it 'should yield every advisory affecting the library' do
8+
it 'should yield every advisory affecting the rubygems version' do
99
advisories = []
1010

11-
subject.check_library(library) do |advisory|
11+
subject.check_rubygems(rubygems) do |advisory|
1212
advisories << advisory
1313
end
1414

@@ -17,14 +17,14 @@
1717
advisory.is_a?(Bundler::Audit::Advisory)
1818
end).to be_truthy
1919
expect(advisories.map(&:id)).to include('CVE-2015-3900')
20-
expect(advisories.map(&:path).reject { |p| p =~ /libraries/ })
20+
expect(advisories.map(&:path).reject { |p| p =~ /rubygems-update/ })
2121
.to be_empty
2222
end
2323
end
2424

2525
context 'when given no block' do
2626
it 'should return an Enumerator' do
27-
expect(subject.check_library(library)).to be_kind_of(Enumerable)
27+
expect(subject.check_rubygems(rubygems)).to be_kind_of(Enumerable)
2828
end
2929
end
3030
end
@@ -44,7 +44,7 @@
4444
expect(advisories.all? do |advisory|
4545
advisory.is_a?(Bundler::Audit::Advisory)
4646
end).to be_truthy
47-
expect(advisories.map(&:id)).to include('OSVDB-120541')
47+
expect(advisories.map(&:id)).to include('CVE-2015-1855')
4848
expect(advisories.map(&:path).reject { |p| p =~ /rubies/ }).to be_empty
4949
end
5050
end

spec/scanner_spec.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,28 @@
1818
expect(subject.all? do |result|
1919
result.advisory.vulnerable?(result.gem.version)
2020
end).to be_truthy
21-
expect(subject.map { |r| r.advisory.id }).to include('OSVDB-120541')
21+
expect(subject.map { |r| r.advisory.id }).to include('CVE-2015-1855')
2222
end
2323

2424
it 'respects patch level' do
2525
stub_const('RUBY_VERSION', '1.9.3')
2626
stub_const('RUBY_PATCHLEVEL', 392)
27-
expect(subject.map { |r| r.advisory.id }).to include('OSVDB-113747')
27+
expect(subject.map { |r| r.advisory.id }).to include('CVE-2014-8080')
2828
end
2929

3030
it 'handles preview versions' do
3131
stub_const('RUBY_VERSION', '2.1.0')
3232
stub_const('RUBY_PATCHLEVEL', -1)
3333
allow_any_instance_of(RubyAudit::Scanner)
3434
.to receive(:ruby_version).and_return('2.1.0.dev')
35-
expect(subject.map { |r| r.advisory.id }).to include('OSVDB-100113')
35+
expect(subject.map { |r| r.advisory.id }).to include('CVE-2013-4164')
3636
end
3737

3838
context 'when the :ignore option is given' do
39-
subject { scanner.scan(ignore: ['OSVDB-120541']) }
39+
subject { scanner.scan(ignore: ['CVE-2015-1855']) }
4040

4141
it 'should ignore the specified advisories' do
42-
expect(subject.map { |r| r.advisory.id }).not_to include('OSVDB-120541')
42+
expect(subject.map { |r| r.advisory.id }).not_to include('CVE-2015-1855')
4343
end
4444
end
4545
end

vendor/ruby-advisory-db

Submodule ruby-advisory-db updated 1216 files

0 commit comments

Comments
 (0)