Commit 4fd296e9 authored by rossfuhrman's avatar rossfuhrman Committed by Nick Thomas

Protect against empty location attribute

Not all scanners populate the location attribute, which causes an error
that will prevent the security dashboard from loading.
parent 16a6c262
......@@ -6,6 +6,7 @@ module Vulnerabilities
def blob_path
return '' unless respond_to?(:sha)
return '' unless location.present?
add_line_numbers(location['start_line'], location['end_line'])
end
......
......@@ -45,6 +45,15 @@ describe Vulnerabilities::OccurrencePresenter do
it { is_expected.to end_with('#L1-2') }
end
context 'without location' do
before do
allow(presenter).to receive(:location)
.and_return({})
end
it { is_expected.to be_blank }
end
end
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