Skip to content

Commit 9bd6507

Browse files
committed
Merge branch 'develop' into feature/PEO-899-update-active-record-doctor
2 parents c3d3c1e + 6a5e2ba commit 9bd6507

File tree

10 files changed

+49
-24
lines changed

10 files changed

+49
-24
lines changed

.rubocop.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ AllCops:
88
Style/Documentation:
99
Enabled: false
1010

11-
Metrics/LineLength:
11+
Layout/LineLength:
1212
Max: 120
1313

1414
Style/FrozenStringLiteralComment:

config/rubocop/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ AllCops:
1414
Style/Documentation:
1515
Enabled: false
1616

17-
Metrics/LineLength:
17+
Layout/LineLength:
1818
Max: 120
1919

2020
Style/FrozenStringLiteralComment:

lib/inquisition/brakeman/vulnerability.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ def to_h
1717
severity: MATCH_TABLE[warning.confidence],
1818
message: warning.message.to_s,
1919
path: warning.relative_path,
20-
line: warning.line
20+
line: warning.line,
21+
context: warning.warning_type
2122
}
2223
end
2324

lib/inquisition/bundler/audit/runner.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def issue_for(issue)
2828
when ::Bundler::Audit::Scanner::InsecureSource
2929
InsecureSource.new(issue.source).to_h.merge(runner: self)
3030
when ::Bundler::Audit::Scanner::UnpatchedGem
31-
UnpatchedGem.new(issue.advisory).to_h.merge(runner: self)
31+
UnpatchedGem.new(issue).to_h.merge(runner: self)
3232
else
3333
raise ArgumentError, "Unknown type: #{issue.class}"
3434
end

lib/inquisition/bundler/audit/vulnerability.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,22 @@ def to_h
88
end
99

1010
class UnpatchedGem < Vulnerability
11-
def initialize(advisory)
12-
@advisory = advisory
11+
def initialize(issue)
12+
@gem = issue.gem
13+
@advisory = issue.advisory
1314
end
1415

1516
def to_h
1617
super.merge(
1718
severity: advisory.criticality || Severity::LOW,
18-
message: advisory.title.strip
19+
message: advisory.title.strip,
20+
context: gem
1921
)
2022
end
2123

2224
private
2325

24-
attr_reader :advisory
26+
attr_reader :gem, :advisory
2527
end
2628

2729
class InsecureSource < Vulnerability

lib/inquisition/issue.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@ module Inquisition
22
class Issue
33
COMPARISON_ATTRIBUTES = %i[path line severity message category].freeze
44

5-
attr_reader :path, :line, :severity, :message, :category, :runner
5+
attr_reader :path, :line, :severity, :message, :category, :runner, :context
66

7-
def initialize(path:, line:, severity:, message:, category:, runner:)
7+
def initialize(path:, line:, severity:, message:, category:, runner:, context: nil)
88
@path = path
99
@line = line
1010
@runner = runner
1111
@message = message
1212
@severity = Severity.new(severity)
1313
@category = Category.new(category)
14+
@context = context
1415
end
1516

1617
def ==(other)

spec/fixtures/files/bundler_audit.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
- severity: :low
1717
category: :security
1818
message: 'Nokogiri gem, via libxslt, is affected by multiple vulnerabilities'
19+
- severity: :low
20+
message: 'Possible information leak / session hijack vulnerability'
21+
category: :security
1922
- severity: :high
2023
category: :security
2124
message: 'smart_proxy_dynflow gem authentication bypass in Foreman remote execution feature'

spec/inquisition/brakeman/runner_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
path: 'app/controllers/users_controller.rb',
1414
line: 42,
1515
severity: Inquisition::Severity::HIGH,
16-
message: 'Potentially dangerous key allowed for mass assignment'
16+
message: 'Potentially dangerous key allowed for mass assignment',
17+
context: 'Cross-Site Scripting'
1718
}
1819
end
1920

spec/inquisition/brakeman/vulnerability_spec.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
confidence: confidence,
1414
line: 42,
1515
relative_path: 'app/controllers/users_controller.rb',
16-
message: message
16+
message: message,
17+
warning_type: 'Cross-Site Scripting'
1718
)
1819
end
1920
let(:options) do
@@ -22,7 +23,8 @@
2223
message: message.to_s,
2324
path: warning.relative_path,
2425
line: warning.line,
25-
category: Inquisition::Category::SECURITY
26+
category: Inquisition::Category::SECURITY,
27+
context: warning.warning_type
2628
}
2729
end
2830

spec/inquisition/bundler/audit/vulnerability_spec.rb

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,19 @@
33
describe '#to_h' do
44
subject(:vulnerability) { described_class.new }
55

6-
it { expect(vulnerability.to_h).to include(path: nil, line: nil) }
6+
it { expect(vulnerability.to_h).to eq(path: nil, line: nil, category: Inquisition::Category::SECURITY) }
77
end
88
end
99

1010
describe Inquisition::Bundler::Audit::UnpatchedGem do
1111
describe '#to_h' do
12-
subject(:insecure_source) { described_class.new(advisory) }
12+
subject(:unpatched_gem) do
13+
described_class.new(
14+
instance_double(Bundler::Audit::Scanner::UnpatchedGem, gem: gem, advisory: advisory)
15+
)
16+
end
17+
18+
let(:gem) { instance_double(Bundler::LazySpecification) }
1319

1420
context 'when advisory criticality is :high' do
1521
let(:advisory) do
@@ -21,11 +27,13 @@
2127
path: nil,
2228
line: nil,
2329
severity: Inquisition::Severity::HIGH,
24-
message: 'Cocaine Gem for Ruby contains a flaw'
30+
message: 'Cocaine Gem for Ruby contains a flaw',
31+
category: Inquisition::Category::SECURITY,
32+
context: gem
2533
}
2634
end
2735

28-
it { expect(insecure_source.to_h).to include(options) }
36+
it { expect(unpatched_gem.to_h).to eq(options) }
2937
end
3038

3139
context 'when advisory criticality is :medium' do
@@ -37,11 +45,13 @@
3745
path: nil,
3846
line: nil,
3947
severity: Inquisition::Severity::MEDIUM,
40-
message: 'XSS vulnerability in bootstrap'
48+
message: 'XSS vulnerability in bootstrap',
49+
category: Inquisition::Category::SECURITY,
50+
context: gem
4151
}
4252
end
4353

44-
it { expect(insecure_source.to_h).to include(options) }
54+
it { expect(unpatched_gem.to_h).to eq(options) }
4555
end
4656

4757
context 'when advisory criticality is :low' do
@@ -54,11 +64,13 @@
5464
path: nil,
5565
line: nil,
5666
severity: Inquisition::Severity::LOW,
57-
message: 'Multiple persistent XSS vulnerabilities in Radiant CMS'
67+
message: 'Multiple persistent XSS vulnerabilities in Radiant CMS',
68+
category: Inquisition::Category::SECURITY,
69+
context: gem
5870
}
5971
end
6072

61-
it { expect(insecure_source.to_h).to include(options) }
73+
it { expect(unpatched_gem.to_h).to eq(options) }
6274
end
6375

6476
context 'when advisory criticality is absent' do
@@ -71,11 +83,13 @@
7183
path: nil,
7284
line: nil,
7385
severity: Inquisition::Severity::LOW,
74-
message: 'Remote code execution in bootstrap-sass'
86+
message: 'Remote code execution in bootstrap-sass',
87+
category: Inquisition::Category::SECURITY,
88+
context: gem
7589
}
7690
end
7791

78-
it { expect(insecure_source.to_h).to include(options) }
92+
it { expect(unpatched_gem.to_h).to eq(options) }
7993
end
8094
end
8195
end
@@ -90,11 +104,12 @@
90104
path: nil,
91105
line: nil,
92106
severity: Inquisition::Severity::MEDIUM,
107+
category: Inquisition::Category::SECURITY,
93108
message: 'Insecure Source URI found: http://rubygems.org/'
94109
}
95110
end
96111

97-
it { expect(insecure_source.to_h).to include(options) }
112+
it { expect(insecure_source.to_h).to eq(options) }
98113
end
99114
end
100115
end

0 commit comments

Comments
 (0)