Commit ff2425a1 authored by Michał Zając's avatar Michał Zając

Apply reviewer suggestions

parent 7c5a5558
# frozen_string_literal: true
module VulnerabilitiesHelper
def vulnerability_data(vulnerability, pipeline, current_user: nil)
def vulnerability_data(vulnerability, pipeline)
return unless vulnerability
{
......@@ -10,8 +10,8 @@ module VulnerabilitiesHelper
create_issue_url: create_vulnerability_feedback_issue_path(vulnerability.finding.project),
pipeline_json: vulnerability_pipeline_data(pipeline).to_json,
has_mr: !!vulnerability.finding.merge_request_feedback.try(:merge_request_iid),
vulnerability_feedback_help_path: help_page_path("user/application_security/index", anchor: "interacting-with-the-vulnerabilities"),
finding_json: vulnerability_finding_data(vulnerability.finding, current_user: current_user).to_json
vulnerability_feedback_help_path: help_page_path('user/application_security/index', anchor: 'interacting-with-the-vulnerabilities'),
finding_json: vulnerability_finding_data(vulnerability.finding).to_json
}
end
......@@ -25,20 +25,20 @@ module VulnerabilitiesHelper
}
end
def vulnerability_finding_data(finding, current_user: nil)
def vulnerability_finding_data(finding)
occurrence = Vulnerabilities::OccurrenceSerializer.new(current_user: current_user).represent(finding)
remediation = occurrence[:remediations]&.first
{
description: occurrence[:description],
identifiers: occurrence[:identifiers],
links: occurrence[:links],
location: occurrence[:location],
name: occurrence[:name],
solution: occurrence[:solution],
remediation: remediation,
issue_feedback: occurrence[:issue_feedback],
project: occurrence[:project]
}
occurrence.slice(
:description,
:identifiers,
:links,
:location,
:name,
:issue_feedback,
:project
).merge(
solution: remediation ? remediation['summary'] : occurrence[:solution]
)
end
end
......@@ -4,7 +4,7 @@
- page_title @vulnerability.title
- page_description @vulnerability.description
#js-vulnerability-management-app{ data: vulnerability_data(@vulnerability, @pipeline, current_user: @current_user) }
#js-vulnerability-management-app{ data: vulnerability_data(@vulnerability, @pipeline) }
.issue-details.issuable-details
.detail-page-description
......@@ -38,4 +38,4 @@
%li
%a{ :href=>identifier.url, target: "_blank", rel: 'noopener noreferrer' }= identifier.name
#js-vulnerability-footer{ data: vulnerability_data(@vulnerability, @pipeline, current_user: @current_user) }
#js-vulnerability-footer{ data: vulnerability_data(@vulnerability, @pipeline) }
......@@ -8,7 +8,10 @@ describe VulnerabilitiesHelper do
expect(subject).to include(
vulnerability_json: vulnerability.to_json,
project_fingerprint: vulnerability.finding.project_fingerprint,
create_issue_url: be_present
create_issue_url: anything,
has_mr: anything,
vulnerability_feedback_help_path: anything,
finding_json: anything
)
end
end
......@@ -63,7 +66,9 @@ describe VulnerabilitiesHelper do
identifiers: finding.identifiers,
links: finding.links,
location: finding.location,
name: finding.name
name: finding.name,
issue_feedback: anything,
project: anything
)
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