Commit 10736e4f authored by Rémy Coutable's avatar Rémy Coutable

Merge branch '284071-refactor-vulnerability-description-template' into 'master'

Resolve "Follow-up from "Remove safe navigation operator from Vulnerability description""

See merge request gitlab-org/gitlab!53192
parents e7397ee1 5945f702
......@@ -67,4 +67,8 @@ module VulnerabilitiesHelper
data[:location].merge!('blob_path' => vulnerability.blob_path).compact!
data
end
def vulnerability_scan_data?(vulnerability)
vulnerability.scanner.present? || vulnerability.scan.present?
end
end
......@@ -60,25 +60,26 @@
</details>
<% end %>
<% end %>
<% if vulnerability.scanner.present? || vulnerability.scan.present? %>
<% if vulnerability_scan_data?(vulnerability) %>
### <%= _("Scanner") %>:
<% if vulnerability.scanner.present? %>
* <%= _("Name") %>: <%= vulnerability.scanner[:name] %>
<% end %>
<% if vulnerability.scan.present? %>
<% if vulnerability.scan[:type].present? %>
* <%= _("Type") %>: <%= vulnerability.scan[:type] %>
<%- scan_data = vulnerability.scan -%>
<% if scan_data.present? %>
<% if scan_data[:type].present? %>
* <%= _("Type") %>: <%= scan_data[:type] %>
<% end %>
<% if vulnerability.scan[:status].present? %>
* <%= _("Status") %>: <%= vulnerability.scan[:status] %>
<% if scan_data[:status].present? %>
* <%= _("Status") %>: <%= scan_data[:status] %>
<% end %>
<% if vulnerability.scan[:start_time].present? %>
* <%= _("Start Time") %>: <%= vulnerability.scan[:start_time] %>
<% if scan_data[:start_time].present? %>
* <%= _("Start Time") %>: <%= scan_data[:start_time] %>
<% end %>
<% if vulnerability.scan[:end_time].present? %>
* <%= _("End Time") %>: <%= vulnerability.scan[:end_time] %>
<% if scan_data[:end_time].present? %>
* <%= _("End Time") %>: <%= scan_data[:end_time] %>
<% end %>
<% end %>
<% end %>
......@@ -52,24 +52,25 @@ h3. <%= _("Links") %>:
<%= _("See vulnerability %{vulnerability_link} for any Remediation details.".html_safe) % { vulnerability_link: "[#{vulnerability.id}|#{vulnerability_url(vulnerability)}]" } %>
<% end %>
<% if vulnerability.scanner.present? || vulnerability.scan.present? %>
<% if vulnerability_scan_data?(vulnerability) %>
h3. <%= _("Scanner") %>:
<% if vulnerability.scanner.present? %>
* <%= _("Name") %>: <%= vulnerability.scanner[:name] %>
<% end %>
<% if vulnerability.scan.present? %>
<% if vulnerability.scan.type.present? %>
* <%= _("Type") %>: <%= vulnerability.scan.type %>
<%- scan_data = vulnerability.scan -%>
<% if scan_data.present? %>
<% if scan_data.type.present? %>
* <%= _("Type") %>: <%= scan_data.type %>
<% end %>
<% if vulnerability.scan.status.present? %>
* <%= _("Status") %>: <%= vulnerability.scan.status %>
<% if scan_data.status.present? %>
* <%= _("Status") %>: <%= scan_data.status %>
<% end %>
<% if vulnerability.scan.start_time.present? %>
* <%= _("Start Time") %>: <%= vulnerability.scan.start_time %>
<% if scan_data.start_time.present? %>
* <%= _("Start Time") %>: <%= scan_data.start_time %>
<% end %>
<% if vulnerability.scan.end_time.present? %>
* <%= _("End Time") %>: <%= vulnerability.scan.end_time %>
<% if scan_data.end_time.present? %>
* <%= _("End Time") %>: <%= scan_data.end_time %>
<% end %>
<% end %>
<% end %>
......@@ -285,4 +285,34 @@ RSpec.describe VulnerabilitiesHelper do
end
end
end
describe '#vulnerability_scan_data?' do
subject { helper.vulnerability_scan_data?(vulnerability) }
context 'scanner present' do
before do
allow(vulnerability).to receive(:scanner).and_return(true)
end
it { is_expected.to be_truthy }
end
context 'scan present' do
before do
allow(vulnerability).to receive(:scanner).and_return(false)
allow(vulnerability).to receive(:scan).and_return(true)
end
it { is_expected.to be_truthy }
end
context 'neither scan nor scanner being present' do
before do
allow(vulnerability).to receive(:scanner).and_return(false)
allow(vulnerability).to receive(:scan).and_return(false)
end
it { is_expected.to be_falsey }
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