Skip to content
Snippets Groups Projects
Commit d5cdb2f0 authored by alex pooley's avatar alex pooley
Browse files

Merge branch '362517_do_not_try_to_create_issue_links_without_issues' into 'master'

Do not try to create issue links without issues while ingesting reports

See merge request gitlab-org/gitlab!87702
parents fa0c5542 91eda372
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -22,7 +22,7 @@ module Security
def new_finding_maps_with_issue_feedback
finding_maps.select(&:new_record)
.each(&:issue_feedback) # This iteration is necessary to register BatchLoader.
.select { |finding_map| finding_map.issue_feedback.present? }
.select { |finding_map| finding_map.issue_feedback.try(:issue_id).present? }
end
end
end
Loading
Loading
Loading
Loading
@@ -7,9 +7,11 @@ RSpec.describe Security::Ingestion::Tasks::IngestIssueLinks do
let(:pipeline) { create(:ci_pipeline) }
let(:report_finding_1) { create(:ci_reports_security_finding) }
let(:report_finding_2) { create(:ci_reports_security_finding) }
let(:report_finding_3) { create(:ci_reports_security_finding) }
let(:finding_map_1) { create(:finding_map, :with_finding, report_finding: report_finding_1) }
let(:finding_map_2) { create(:finding_map, :new_record, report_finding: report_finding_2) }
let(:service_object) { described_class.new(pipeline, [finding_map_1, finding_map_2]) }
let(:finding_map_3) { create(:finding_map, :new_record, report_finding: report_finding_3) }
let(:service_object) { described_class.new(pipeline, [finding_map_1, finding_map_2, finding_map_3]) }
let(:feedback) do
create(:vulnerability_feedback,
:issue,
Loading
Loading
@@ -17,6 +19,13 @@ RSpec.describe Security::Ingestion::Tasks::IngestIssueLinks do
project_fingerprint: finding_map_2.report_finding.project_fingerprint)
end
 
let(:invalid_feedback) do
create(:vulnerability_feedback,
:issue,
project: finding_map_3.security_finding.scan.project,
project_fingerprint: finding_map_3.report_finding.project_fingerprint)
end
subject(:ingest_issue_links) { service_object.execute }
 
before do
Loading
Loading
@@ -27,6 +36,8 @@ RSpec.describe Security::Ingestion::Tasks::IngestIssueLinks do
:issue,
project: finding_map_1.security_finding.scan.project,
project_fingerprint: finding_map_1.report_finding.project_fingerprint)
invalid_feedback.update_column(:issue_id, nil)
end
 
it 'ingests the issue links only for the new records' do
Loading
Loading
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