Skip to content

Commit 1b92ca6

Browse files
authored
Add option to ignore certain advisories that have been manually worked around (#74)
* Add option to ignore certain advisories that have been manually worked around * Remove unnecesary curly braces * Add new config instructions on readme
1 parent 7e070aa commit 1b92ca6

File tree

6 files changed

+885
-1
lines changed

6 files changed

+885
-1
lines changed

Diff for: README.md

+14
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,20 @@ plugins:
2525
path: optional/path/to/Gemfile.lock
2626
```
2727
28+
In the same way you can ignore certain advisories that have been manually resolved:
29+
30+
```yml
31+
# .codeclimate.yml
32+
plugins:
33+
bunlder-audit:
34+
enabled: true
35+
config:
36+
ignore:
37+
- CVE-YYYY-XXXX
38+
```
39+
40+
* `ignore:` \[Array\<String\>\] - A list of advisory IDs to ignore.
41+
2842
### Updating the vulnerability database
2943

3044
If you want to update the vulnerability database, run

Diff for: lib/cc/engine/bundler_audit/analyzer.rb

+5-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def run
2525
FileUtils.cp(gemfile_path, File.join(dir, GEMFILE))
2626

2727
Dir.chdir(dir) do
28-
Bundler::Audit::Scanner.new.scan do |vulnerability|
28+
Bundler::Audit::Scanner.new.scan(ignore: ignored_advisories) do |vulnerability|
2929
if (issue = issue_for_vulerability(vulnerability))
3030
stdout.print("#{issue.to_json}\0")
3131
else
@@ -73,6 +73,10 @@ def engine_config
7373
end
7474
end
7575

76+
def ignored_advisories
77+
engine_config.fetch("config", {}).fetch("ignore", [])
78+
end
79+
7680
def gemfile_lock_path
7781
File.join(directory, gemfile_lock_relative_path)
7882
end

Diff for: spec/cc/engine/bundler_audit/analyzer_spec.rb

+8
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ module CC::Engine::BundlerAudit
1818
end
1919
end
2020

21+
it "ignores specified advisories" do
22+
with_written_config(config: { ignore: %w[CVE-2016-0751 CVE-2015-7576] }) do |path|
23+
directory = fixture_directory("ignore")
24+
issues = analyze_directory(directory, engine_config_path: path)
25+
expect(expected_issues("ignore")).to be_present_in(issues)
26+
end
27+
end
28+
2129
it "emits issues for unpatched gems in Gemfile.lock" do
2230
with_default_written_config do |path|
2331
directory = fixture_directory("unpatched_versions")

Diff for: spec/fixtures/ignore/Gemfile

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
source "https://rubygems.org"
2+
3+
gem "rails", "~> 4.2.5"
4+
gem "devise", "~> 3.4.0"
5+
gem "jquery-rails", "~> 3.1.2"
6+
gem "uglifier", "~> 2.5.3"
7+
gem "simple_form", git: "git@github.com:plataformatec/simple_form.git"

Diff for: spec/fixtures/ignore/Gemfile.lock

+135
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
GIT
2+
remote: git@github.com:plataformatec/simple_form.git
3+
revision: ac63da0f0b38df82385493f25f649e320b0acb4a
4+
specs:
5+
simple_form (3.2.1)
6+
actionpack (> 4, < 5.1)
7+
activemodel (> 4, < 5.1)
8+
9+
GEM
10+
remote: https://rubygems.org/
11+
specs:
12+
actionmailer (4.2.5)
13+
actionpack (= 4.2.5)
14+
actionview (= 4.2.5)
15+
activejob (= 4.2.5)
16+
mail (~> 2.5, >= 2.5.4)
17+
rails-dom-testing (~> 1.0, >= 1.0.5)
18+
actionpack (4.2.5)
19+
actionview (= 4.2.5)
20+
activesupport (= 4.2.5)
21+
rack (~> 1.6)
22+
rack-test (~> 0.6.2)
23+
rails-dom-testing (~> 1.0, >= 1.0.5)
24+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
25+
actionview (4.2.5)
26+
activesupport (= 4.2.5)
27+
builder (~> 3.1)
28+
erubis (~> 2.7.0)
29+
rails-dom-testing (~> 1.0, >= 1.0.5)
30+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
31+
activejob (4.2.5)
32+
activesupport (= 4.2.5)
33+
globalid (>= 0.3.0)
34+
activemodel (4.2.5)
35+
activesupport (= 4.2.5)
36+
builder (~> 3.1)
37+
activerecord (4.2.5)
38+
activemodel (= 4.2.5)
39+
activesupport (= 4.2.5)
40+
arel (~> 6.0)
41+
activesupport (4.2.5)
42+
i18n (~> 0.7)
43+
json (~> 1.7, >= 1.7.7)
44+
minitest (~> 5.1)
45+
thread_safe (~> 0.3, >= 0.3.4)
46+
tzinfo (~> 1.1)
47+
arel (6.0.3)
48+
bcrypt (3.1.7)
49+
builder (3.2.2)
50+
concurrent-ruby (1.0.0)
51+
devise (3.4.0)
52+
bcrypt (~> 3.0)
53+
orm_adapter (~> 0.1)
54+
railties (>= 3.2.6, < 5)
55+
responders
56+
thread_safe (~> 0.1)
57+
warden (~> 1.2.3)
58+
erubis (2.7.0)
59+
execjs (2.2.1)
60+
globalid (0.3.6)
61+
activesupport (>= 4.1.0)
62+
i18n (0.7.0)
63+
jquery-rails (3.1.2)
64+
railties (>= 3.0, < 5.0)
65+
thor (>= 0.14, < 2.0)
66+
json (1.8.3)
67+
loofah (2.0.3)
68+
nokogiri (>= 1.5.9)
69+
mail (2.6.3)
70+
mime-types (>= 1.16, < 3)
71+
mime-types (2.99)
72+
mini_portile2 (2.0.0)
73+
minitest (5.8.3)
74+
nokogiri (1.6.7.1)
75+
mini_portile2 (~> 2.0.0.rc2)
76+
orm_adapter (0.5.0)
77+
rack (1.6.4)
78+
rack-test (0.6.3)
79+
rack (>= 1.0)
80+
rails (4.2.5)
81+
actionmailer (= 4.2.5)
82+
actionpack (= 4.2.5)
83+
actionview (= 4.2.5)
84+
activejob (= 4.2.5)
85+
activemodel (= 4.2.5)
86+
activerecord (= 4.2.5)
87+
activesupport (= 4.2.5)
88+
bundler (>= 1.3.0, < 2.0)
89+
railties (= 4.2.5)
90+
sprockets-rails
91+
rails-deprecated_sanitizer (1.0.3)
92+
activesupport (>= 4.2.0.alpha)
93+
rails-dom-testing (1.0.7)
94+
activesupport (>= 4.2.0.beta, < 5.0)
95+
nokogiri (~> 1.6.0)
96+
rails-deprecated_sanitizer (>= 1.0.1)
97+
rails-html-sanitizer (1.0.2)
98+
loofah (~> 2.0)
99+
railties (4.2.5)
100+
actionpack (= 4.2.5)
101+
activesupport (= 4.2.5)
102+
rake (>= 0.8.7)
103+
thor (>= 0.18.1, < 2.0)
104+
rake (10.4.2)
105+
responders (2.0.0)
106+
railties (>= 4.2.0.alpha, < 5)
107+
sprockets (3.5.2)
108+
concurrent-ruby (~> 1.0)
109+
rack (> 1, < 3)
110+
sprockets-rails (3.0.0)
111+
actionpack (>= 4.0)
112+
activesupport (>= 4.0)
113+
sprockets (>= 3.0.0)
114+
thor (0.19.1)
115+
thread_safe (0.3.5)
116+
tzinfo (1.2.2)
117+
thread_safe (~> 0.1)
118+
uglifier (2.5.3)
119+
execjs (>= 0.3.0)
120+
json (>= 1.8.0)
121+
warden (1.2.3)
122+
rack (>= 1.0)
123+
124+
PLATFORMS
125+
ruby
126+
127+
DEPENDENCIES
128+
devise (~> 3.4.0)
129+
jquery-rails (~> 3.1.2)
130+
rails (~> 4.2.5)
131+
simple_form!
132+
uglifier (~> 2.5.3)
133+
134+
BUNDLED WITH
135+
1.11.2

0 commit comments

Comments
 (0)