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

Rename OccurrencePresenter to FindingPresenter

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