Commit 0adb8de0 authored by Stan Hu's avatar Stan Hu

Merge branch '210327-disable-parsing-empty-vendor' into 'master'

Change default Vendor name to GitLab when not defined in the report

See merge request gitlab-org/gitlab!36519
parents 756e9a8c 8b2546f1
---
title: Change default vendor name to GitLab if not defined in the security schema
merge_request: 36519
author:
type: fixed
...@@ -18,13 +18,11 @@ module Gitlab ...@@ -18,13 +18,11 @@ module Gitlab
end end
def to_hash def to_hash
%i[ {
external_id external_id: external_id.to_s,
name name: name.to_s,
vendor vendor: vendor.presence
].each_with_object({}) do |key, hash| }.compact
hash[key] = public_send(key).to_s # rubocop:disable GitlabSecurity/PublicSend
end
end end
def ==(other) def ==(other)
......
...@@ -61,6 +61,17 @@ RSpec.describe Gitlab::Ci::Reports::Security::Scanner do ...@@ -61,6 +61,17 @@ RSpec.describe Gitlab::Ci::Reports::Security::Scanner do
vendor: scanner.vendor vendor: scanner.vendor
}) })
end end
context 'when vendor is not defined' do
let(:scanner) { create(:ci_reports_security_scanner, vendor: nil) }
it 'returns expected hash' do
is_expected.to eq({
external_id: scanner.external_id,
name: scanner.name
})
end
end
end end
describe '#==' do describe '#==' 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