Skip to content
Snippets Groups Projects
Commit b2624086 authored by Sam Beckham's avatar Sam Beckham :red_circle:
Browse files

Adds changes from @tkuah review

- Adds a spec for filtering by confidence
- Updates the occourence spec to remove the magic number
parent e1bc0131
No related branches found
No related tags found
1 merge request!12805Adds a confidence filter to the GSD
Pipeline #62991437 failed
This commit is part of merge request !13248. Comments created here will be created in the context of that merge request.
......@@ -10,8 +10,8 @@
set(:pipeline1) { create(:ci_pipeline, :success, project: project1) }
set(:pipeline2) { create(:ci_pipeline, :success, project: project2) }
set(:vulnerability1) { create(:vulnerabilities_occurrence, report_type: :sast, severity: :high, pipelines: [pipeline1], project: project1) }
set(:vulnerability2) { create(:vulnerabilities_occurrence, report_type: :dependency_scanning, severity: :medium, pipelines: [pipeline2], project: project2) }
set(:vulnerability1) { create(:vulnerabilities_occurrence, report_type: :sast, severity: :high, confidence: :high, pipelines: [pipeline1], project: project1) }
set(:vulnerability2) { create(:vulnerabilities_occurrence, report_type: :dependency_scanning, severity: :medium, confidence: :low, pipelines: [pipeline2], project: project2) }
set(:vulnerability3) { create(:vulnerabilities_occurrence, report_type: :sast, severity: :low, pipelines: [pipeline2], project: project2) }
set(:vulnerability4) { create(:vulnerabilities_occurrence, report_type: :dast, severity: :medium, pipelines: [pipeline1], project: project1) }
......@@ -53,6 +53,24 @@
end
end
context 'by confidence' do
context 'when high' do
let(:params) { { confidence: %w[high] } }
it 'includes only high confidence vulnerabilities' do
is_expected.to contain_exactly(vulnerability1)
end
end
context 'when low' do
let(:params) { { confidence: %w[low] } }
it 'includes only low confidence vulnerabilities' do
is_expected.to contain_exactly(vulnerability2)
end
end
end
context 'by project' do
let(:params) { { project_id: [project2.id] } }
......
......@@ -218,7 +218,7 @@
subject { described_class.by_severities(param) }
context 'with one param' do
let(:param) { 4 }
let(:param) { described_class.severities[:low] }
it 'returns found record' do
is_expected.to contain_exactly(vulnerability_low)
......@@ -226,7 +226,7 @@
end
context 'without found record' do
let(:param) { 7 }
let(:param) { described_class.severities[:unknown] }
it 'returns empty collection' do
is_expected.to be_empty
......@@ -240,16 +240,16 @@
subject { described_class.by_confidences(param) }
context 'with one param' do
let(:param) { 4 }
context 'with matching param' do
let(:param) { described_class.confidences[:low] }
it 'returns found record' do
is_expected.to contain_exactly(vulnerability_low)
end
end
context 'without found record' do
let(:param) { 7 }
context 'with non-matching param' do
let(:param) { described_class.confidences[:unknown] }
it 'returns empty collection' do
is_expected.to be_empty
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment