Commit 84aabb40 authored by Michał Zając's avatar Michał Zając

Rename OccurrencePresenter to FindingPresenter

parent c1a794aa
# frozen_string_literal: true # frozen_string_literal: true
module Vulnerabilities module Vulnerabilities
class OccurrencePresenter < Gitlab::View::Presenter::Delegated class FindingPresenter < Gitlab::View::Presenter::Delegated
presents :occurrence presents :finding
def blob_path def blob_path
return '' unless sha.present? return '' unless sha.present?
......
...@@ -124,7 +124,7 @@ module Security ...@@ -124,7 +124,7 @@ module Security
deduplicate_findings! deduplicate_findings!
sort_findings! sort_findings!
@findings.each { |finding| @target_report.finding(finding) } @findings.each { |finding| @target_report.add_finding(finding) }
end end
def sort_by_ds_analyzers! def sort_by_ds_analyzers!
......
...@@ -54,7 +54,7 @@ module Gitlab ...@@ -54,7 +54,7 @@ module Gitlab
def create_vulnerability(report, data, version) def create_vulnerability(report, data, version)
scanner = create_scanner(report, data['scanner'] || mutate_scanner_tool(data['tool'])) scanner = create_scanner(report, data['scanner'] || mutate_scanner_tool(data['tool']))
identifiers = create_identifiers(report, data['identifiers']) identifiers = create_identifiers(report, data['identifiers'])
report.finding( report.add_finding(
::Gitlab::Ci::Reports::Security::Occurrence.new( ::Gitlab::Ci::Reports::Security::Occurrence.new(
uuid: SecureRandom.uuid, uuid: SecureRandom.uuid,
report_type: report.type, report_type: report.type,
......
...@@ -16,7 +16,7 @@ FactoryBot.define do ...@@ -16,7 +16,7 @@ FactoryBot.define do
after :build do |report, evaluator| after :build do |report, evaluator|
evaluator.scanners.each { |s| report.add_scanner(s) } evaluator.scanners.each { |s| report.add_scanner(s) }
evaluator.identifiers.each { |id| report.add_identifier(id) } evaluator.identifiers.each { |id| report.add_identifier(id) }
evaluator.findings.each { |o| report.finding(o) } evaluator.findings.each { |o| report.add_finding(o) }
end end
skip_create skip_create
......
...@@ -45,7 +45,7 @@ RSpec.describe Gitlab::Ci::Reports::Security::Report do ...@@ -45,7 +45,7 @@ RSpec.describe Gitlab::Ci::Reports::Security::Report do
let(:finding) { create(:ci_reports_security_finding) } let(:finding) { create(:ci_reports_security_finding) }
it 'enriches given finding and stores it in the collection' do it 'enriches given finding and stores it in the collection' do
report.finding(finding) report.add_finding(finding)
expect(report.findings).to eq([finding]) expect(report.findings).to eq([finding])
end end
...@@ -131,7 +131,7 @@ RSpec.describe Gitlab::Ci::Reports::Security::Report do ...@@ -131,7 +131,7 @@ RSpec.describe Gitlab::Ci::Reports::Security::Report do
let(:finding) { build(:ci_reports_security_finding, severity: severity) } let(:finding) { build(:ci_reports_security_finding, severity: severity) }
before do before do
subject.finding(finding) subject.add_finding(finding)
end end
it { expect(subject.unsafe_severity?).to be(true) } it { expect(subject.unsafe_severity?).to be(true) }
...@@ -145,7 +145,7 @@ RSpec.describe Gitlab::Ci::Reports::Security::Report do ...@@ -145,7 +145,7 @@ RSpec.describe Gitlab::Ci::Reports::Security::Report do
let(:finding) { build(:ci_reports_security_finding, severity: severity) } let(:finding) { build(:ci_reports_security_finding, severity: severity) }
before do before do
subject.finding(finding) subject.add_finding(finding)
end end
it { expect(subject.unsafe_severity?).to be(false) } it { expect(subject.unsafe_severity?).to be(false) }
...@@ -157,7 +157,7 @@ RSpec.describe Gitlab::Ci::Reports::Security::Report do ...@@ -157,7 +157,7 @@ RSpec.describe Gitlab::Ci::Reports::Security::Report do
let(:finding) { build(:ci_reports_security_finding, severity: nil) } let(:finding) { build(:ci_reports_security_finding, severity: nil) }
before do before do
subject.finding(finding) subject.add_finding(finding)
end end
it { expect(subject.unsafe_severity?).to be(false) } it { expect(subject.unsafe_severity?).to be(false) }
...@@ -168,7 +168,7 @@ RSpec.describe Gitlab::Ci::Reports::Security::Report do ...@@ -168,7 +168,7 @@ RSpec.describe Gitlab::Ci::Reports::Security::Report do
let(:finding) { build(:ci_reports_security_finding, severity: '') } let(:finding) { build(:ci_reports_security_finding, severity: '') }
before do before do
subject.finding(finding) subject.add_finding(finding)
end end
it { expect(subject.unsafe_severity?).to be(false) } it { expect(subject.unsafe_severity?).to be(false) }
......
...@@ -46,8 +46,8 @@ RSpec.describe Gitlab::Ci::Reports::Security::Reports do ...@@ -46,8 +46,8 @@ RSpec.describe Gitlab::Ci::Reports::Security::Reports do
context "when a report has a high severity vulnerability" do context "when a report has a high severity vulnerability" do
before do before do
subject.get_report('sast', artifact).finding(high_severity) subject.get_report('sast', artifact).add_finding(high_severity)
subject.get_report('dependency_scanning', artifact).finding(low_severity) subject.get_report('dependency_scanning', artifact).add_finding(low_severity)
end end
it { expect(subject.violates_default_policy?).to be(true) } it { expect(subject.violates_default_policy?).to be(true) }
...@@ -56,7 +56,8 @@ RSpec.describe Gitlab::Ci::Reports::Security::Reports do ...@@ -56,7 +56,8 @@ RSpec.describe Gitlab::Ci::Reports::Security::Reports do
context "when none of the reports have a high severity vulnerability" do context "when none of the reports have a high severity vulnerability" do
before do before do
subject.get_report('sast', artifact).finding(low_severity) subject.get_report('sast', artifact).finding(low_severity)
subject.get_report('dependency_scanning', artifact).finding(low_severity) subject.get_report('sast', artifact).add_finding(low_severity)
subject.get_report('dependency_scanning', artifact).add_finding(low_severity)
end end
it { expect(subject.violates_default_policy?).to be(false) } it { expect(subject.violates_default_policy?).to be(false) }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe Vulnerabilities::OccurrencePresenter do RSpec.describe Vulnerabilities::FindingPresenter do
let(:presenter) { described_class.new(occurrence) } let(:presenter) { described_class.new(occurrence) }
let(:occurrence) { build_stubbed(:vulnerabilities_occurrence) } let(:occurrence) { build_stubbed(:vulnerabilities_occurrence) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment