Commit c146b7a3 authored by Vasilii Iakliushin's avatar Vasilii Iakliushin

Merge branch...

Merge branch '354082-vulnerability-report-ui-does-not-render-with-only-cluster-image-scanning-vulnerabilities' into 'master'

Don't reuse vulnerability scanners across projects

See merge request gitlab-org/gitlab!84160
parents a0856e61 ae38614c
......@@ -94,9 +94,8 @@ module Vulnerabilities
def initialize_scanner(scanner_hash)
name = scanner_hash[:name]
Vulnerabilities::Scanner.find_or_initialize_by(name: name) do |s|
s.project = @project
s.external_id = scanner_hash[:id]
Vulnerabilities::Scanner.find_or_initialize_by(project: @project, external_id: scanner_hash[:id]) do |s|
s.name = name
s.vendor = scanner_hash.dig(:vendor, :name)
end
end
......
......@@ -93,6 +93,20 @@ RSpec.describe Vulnerabilities::StarboardVulnerabilityCreateService do
expect(scanner.name).to eq(params.dig(:scanner, :name))
expect(scanner.vendor).to eq(params.dig(:scanner, :vendor, :name))
end
context 'when there is a scanner for a different project' do
let(:other_scanner) { create(:vulnerabilities_scanner, external_id: params.dig(:scanner, :id)) }
it "does not reuse another project's scanner" do
subject
expect(vulnerability.finding.scanner).not_to eq(other_scanner)
end
it 'creates a new scanner' do
expect { subject }.to change { Vulnerabilities::Scanner.count }.by(1)
end
end
end
context 'with feature disabled' do
......
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