|
3 | 3 | describe '#to_h' do |
4 | 4 | subject(:vulnerability) { described_class.new } |
5 | 5 |
|
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) } |
7 | 7 | end |
8 | 8 | end |
9 | 9 |
|
10 | 10 | describe Inquisition::Bundler::Audit::UnpatchedGem do |
11 | 11 | 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) } |
13 | 19 |
|
14 | 20 | context 'when advisory criticality is :high' do |
15 | 21 | let(:advisory) do |
|
21 | 27 | path: nil, |
22 | 28 | line: nil, |
23 | 29 | 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 |
25 | 33 | } |
26 | 34 | end |
27 | 35 |
|
28 | | - it { expect(insecure_source.to_h).to include(options) } |
| 36 | + it { expect(unpatched_gem.to_h).to eq(options) } |
29 | 37 | end |
30 | 38 |
|
31 | 39 | context 'when advisory criticality is :medium' do |
|
37 | 45 | path: nil, |
38 | 46 | line: nil, |
39 | 47 | severity: Inquisition::Severity::MEDIUM, |
40 | | - message: 'XSS vulnerability in bootstrap' |
| 48 | + message: 'XSS vulnerability in bootstrap', |
| 49 | + category: Inquisition::Category::SECURITY, |
| 50 | + context: gem |
41 | 51 | } |
42 | 52 | end |
43 | 53 |
|
44 | | - it { expect(insecure_source.to_h).to include(options) } |
| 54 | + it { expect(unpatched_gem.to_h).to eq(options) } |
45 | 55 | end |
46 | 56 |
|
47 | 57 | context 'when advisory criticality is :low' do |
|
54 | 64 | path: nil, |
55 | 65 | line: nil, |
56 | 66 | 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 |
58 | 70 | } |
59 | 71 | end |
60 | 72 |
|
61 | | - it { expect(insecure_source.to_h).to include(options) } |
| 73 | + it { expect(unpatched_gem.to_h).to eq(options) } |
62 | 74 | end |
63 | 75 |
|
64 | 76 | context 'when advisory criticality is absent' do |
|
71 | 83 | path: nil, |
72 | 84 | line: nil, |
73 | 85 | 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 |
75 | 89 | } |
76 | 90 | end |
77 | 91 |
|
78 | | - it { expect(insecure_source.to_h).to include(options) } |
| 92 | + it { expect(unpatched_gem.to_h).to eq(options) } |
79 | 93 | end |
80 | 94 | end |
81 | 95 | end |
|
90 | 104 | path: nil, |
91 | 105 | line: nil, |
92 | 106 | severity: Inquisition::Severity::MEDIUM, |
| 107 | + category: Inquisition::Category::SECURITY, |
93 | 108 | message: 'Insecure Source URI found: http://rubygems.org/' |
94 | 109 | } |
95 | 110 | end |
96 | 111 |
|
97 | | - it { expect(insecure_source.to_h).to include(options) } |
| 112 | + it { expect(insecure_source.to_h).to eq(options) } |
98 | 113 | end |
99 | 114 | end |
100 | 115 | end |
0 commit comments