Commit f29ef4fa authored by Jan Provaznik's avatar Jan Provaznik

Merge branch 'rename_vulnerability_with_scanners' into 'master'

Rename with_scanners to with_scanner_external_ids

See merge request gitlab-org/gitlab!56283
parents 2f6a0588 64932d96
......@@ -30,7 +30,7 @@ module Security
filter_by_report_types
filter_by_severities
filter_by_states
filter_by_scanners
filter_by_scanner_external_id
filter_by_resolution
filter_by_issues
......@@ -65,9 +65,9 @@ module Security
end
end
def filter_by_scanners
def filter_by_scanner_external_id
if params[:scanner].present?
@vulnerabilities = vulnerabilities.with_scanners(params[:scanner])
@vulnerabilities = vulnerabilities.with_scanner_external_ids(params[:scanner])
end
end
......
......@@ -82,7 +82,7 @@ module EE
scope :with_report_types, -> (report_types) { where(report_type: report_types) }
scope :with_severities, -> (severities) { where(severity: severities) }
scope :with_states, -> (states) { where(state: states) }
scope :with_scanners, -> (scanners) { joins(findings: :scanner).merge(::Vulnerabilities::Scanner.with_external_id(scanners)) }
scope :with_scanner_external_ids, -> (scanners) { joins(findings: :scanner).merge(::Vulnerabilities::Scanner.with_external_id(scanners)) }
scope :grouped_by_severity, -> { reorder(severity: :desc).group(:severity) }
scope :by_project_fingerprints, -> (project_fingerprints) { joins(:findings).merge(Vulnerabilities::Finding.by_project_fingerprints(project_fingerprints)) }
......
......@@ -223,15 +223,15 @@ RSpec.describe Vulnerability do
end
end
describe '.with_scanners' do
describe '.with_scanner_external_ids' do
let!(:vulnerability_1) { create(:vulnerability, :with_findings) }
let!(:vulnerability_2) { create(:vulnerability, :with_findings) }
let(:vulnerability_3) { vulnerability }
let(:scanners) { [vulnerability_1.finding_scanner_external_id, vulnerability_3.finding_scanner_external_id] }
let(:scanner_external_ids) { [vulnerability_1.finding_scanner_external_id, vulnerability_3.finding_scanner_external_id] }
subject { described_class.with_scanners(scanners) }
subject { described_class.with_scanner_external_ids(scanner_external_ids) }
it 'returns vulnerabilities matching the given scanners' do
it 'returns vulnerabilities matching the given scanner external ids' do
is_expected.to contain_exactly(vulnerability_1, vulnerability_3)
end
end
......
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