Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
2227509d
Commit
2227509d
authored
Mar 26, 2020
by
Michał Zając
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add vulnerability_finding_data method
parent
c8de8e68
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
0 deletions
+27
-0
ee/app/helpers/vulnerabilities_helper.rb
ee/app/helpers/vulnerabilities_helper.rb
+15
-0
ee/spec/helpers/ee/vulnerabilities_helper_spec.rb
ee/spec/helpers/ee/vulnerabilities_helper_spec.rb
+12
-0
No files found.
ee/app/helpers/vulnerabilities_helper.rb
View file @
2227509d
...
@@ -12,6 +12,7 @@ module VulnerabilitiesHelper
...
@@ -12,6 +12,7 @@ module VulnerabilitiesHelper
finding:
Vulnerabilities
::
OccurrenceSerializer
.
new
({}).
represent
(
@vulnerability
.
finding
).
to_json
,
finding:
Vulnerabilities
::
OccurrenceSerializer
.
new
({}).
represent
(
@vulnerability
.
finding
).
to_json
,
has_mr:
!!
@vulnerability
.
finding
.
merge_request_feedback
.
try
(
:merge_request_iid
),
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"
),
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
end
...
@@ -24,4 +25,18 @@ module VulnerabilitiesHelper
...
@@ -24,4 +25,18 @@ module VulnerabilitiesHelper
url:
pipeline_path
(
pipeline
)
url:
pipeline_path
(
pipeline
)
}
}
end
end
def
vulnerability_finding_data
(
finding
,
current_user:
nil
)
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:
remediation
?
remediation
[
'summary'
]
:
occurrence
[
:solution
]
}
end
end
end
ee/spec/helpers/ee/vulnerabilities_helper_spec.rb
View file @
2227509d
...
@@ -50,4 +50,16 @@ describe VulnerabilitiesHelper do
...
@@ -50,4 +50,16 @@ describe VulnerabilitiesHelper do
end
end
end
end
end
end
describe
'#vulnerability_finding_data'
do
let
(
:vulnerability
)
{
create
(
:vulnerability
,
:with_findings
)
}
let
(
:finding
)
{
vulnerability
.
finding
}
subject
{
helper
.
vulnerability_finding_data
(
finding
)
}
it
"returns finding information"
do
expect
(
subject
[
:name
]).
not_to
be_nil
expect
(
subject
[
:description
]).
not_to
be_nil
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment