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 ...@@ -94,9 +94,8 @@ module Vulnerabilities
def initialize_scanner(scanner_hash) def initialize_scanner(scanner_hash)
name = scanner_hash[:name] name = scanner_hash[:name]
Vulnerabilities::Scanner.find_or_initialize_by(name: name) do |s| Vulnerabilities::Scanner.find_or_initialize_by(project: @project, external_id: scanner_hash[:id]) do |s|
s.project = @project s.name = name
s.external_id = scanner_hash[:id]
s.vendor = scanner_hash.dig(:vendor, :name) s.vendor = scanner_hash.dig(:vendor, :name)
end end
end end
......
...@@ -93,6 +93,20 @@ RSpec.describe Vulnerabilities::StarboardVulnerabilityCreateService do ...@@ -93,6 +93,20 @@ RSpec.describe Vulnerabilities::StarboardVulnerabilityCreateService do
expect(scanner.name).to eq(params.dig(:scanner, :name)) expect(scanner.name).to eq(params.dig(:scanner, :name))
expect(scanner.vendor).to eq(params.dig(:scanner, :vendor, :name)) expect(scanner.vendor).to eq(params.dig(:scanner, :vendor, :name))
end 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 end
context 'with feature disabled' do 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