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
5945f702
Commit
5945f702
authored
Feb 03, 2021
by
Dave Liu
Committed by
dave
Mar 10, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor issue vulnerability description template
add helper method vulnerability_scan_data? to reduce duplication
parent
158e768a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
20 deletions
+56
-20
ee/app/helpers/vulnerabilities_helper.rb
ee/app/helpers/vulnerabilities_helper.rb
+4
-0
ee/app/views/vulnerabilities/issue_description.md.erb
ee/app/views/vulnerabilities/issue_description.md.erb
+11
-10
ee/app/views/vulnerabilities/jira_issue_description.md.erb
ee/app/views/vulnerabilities/jira_issue_description.md.erb
+11
-10
ee/spec/helpers/vulnerabilities_helper_spec.rb
ee/spec/helpers/vulnerabilities_helper_spec.rb
+30
-0
No files found.
ee/app/helpers/vulnerabilities_helper.rb
View file @
5945f702
...
...
@@ -74,4 +74,8 @@ module VulnerabilitiesHelper
data
end
def
vulnerability_scan_data?
(
vulnerability
)
vulnerability
.
scanner
.
present?
||
vulnerability
.
scan
.
present?
end
end
ee/app/views/vulnerabilities/issue_description.md.erb
View file @
5945f702
...
...
@@ -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
%>
ee/app/views/vulnerabilities/jira_issue_description.md.erb
View file @
5945f702
...
...
@@ -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
%>
ee/spec/helpers/vulnerabilities_helper_spec.rb
View file @
5945f702
...
...
@@ -283,4 +283,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
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