Commit 95ea0ba4 authored by rossfuhrman's avatar rossfuhrman Committed by Douglas Barbosa Alexandre

Guard against nil file key

Not all scanners populate the file key in the location hash, so we need
to guard against that.
parent 65d6b7e3
......@@ -6,7 +6,7 @@ module Vulnerabilities
def blob_path
return '' unless respond_to?(:sha)
return '' unless location.present?
return '' unless location.present? && location['file'].present?
add_line_numbers(location['start_line'], location['end_line'])
end
......
......@@ -46,6 +46,15 @@ describe Vulnerabilities::OccurrencePresenter do
it { is_expected.to end_with('#L1-2') }
end
context 'without file' do
before do
allow(presenter).to receive(:location)
.and_return({ 'foo' => 123 })
end
it { is_expected.to be_blank }
end
context 'without location' do
before do
allow(presenter).to receive(:location)
......
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