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
df1aee14
Commit
df1aee14
authored
Jul 08, 2020
by
Jonathan Schafer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DRY up Vulnerability API code
parent
bdefe8a7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
14 deletions
+15
-14
ee/lib/api/vulnerabilities.rb
ee/lib/api/vulnerabilities.rb
+15
-14
No files found.
ee/lib/api/vulnerabilities.rb
View file @
df1aee14
...
...
@@ -29,45 +29,46 @@ module API
requires
:id
,
type:
String
,
desc:
'The ID of a vulnerability'
end
resource
:vulnerabilities
do
before
do
@vulnerability
=
find_and_authorize_vulnerability!
(
:read_vulnerability
)
end
after
do
render_vulnerability
(
@vulnerability
)
end
desc
'Get a vulnerability'
do
success
EE
::
API
::
Entities
::
Vulnerability
end
get
':id'
do
vulnerability
=
find_and_authorize_vulnerability!
(
:read_vulnerability
)
render_vulnerability
(
vulnerability
)
# do nothing
end
desc
'Resolve a vulnerability'
do
success
EE
::
API
::
Entities
::
Vulnerability
end
post
':id/resolve'
do
vulnerability
=
find_and_authorize_vulnerability!
(
:admin_vulnerability
)
not_modified!
if
vulnerability
.
resolved?
not_modified!
if
@vulnerability
.
resolved?
vulnerability
=
::
Vulnerabilities
::
ResolveService
.
new
(
current_user
,
vulnerability
).
execute
render_vulnerability
(
vulnerability
)
@vulnerability
=
::
Vulnerabilities
::
ResolveService
.
new
(
current_user
,
@vulnerability
).
execute
end
desc
'Dismiss a vulnerability'
do
success
EE
::
API
::
Entities
::
Vulnerability
end
post
':id/dismiss'
do
vulnerability
=
find_and_authorize_vulnerability!
(
:admin_vulnerability
)
not_modified!
if
vulnerability
.
dismissed?
not_modified!
if
@vulnerability
.
dismissed?
vulnerability
=
::
Vulnerabilities
::
DismissService
.
new
(
current_user
,
vulnerability
).
execute
render_vulnerability
(
vulnerability
)
@vulnerability
=
::
Vulnerabilities
::
DismissService
.
new
(
current_user
,
@vulnerability
).
execute
end
desc
'Confirm a vulnerability'
do
success
EE
::
API
::
Entities
::
Vulnerability
end
post
':id/confirm'
do
vulnerability
=
find_and_authorize_vulnerability!
(
:admin_vulnerability
)
not_modified!
if
vulnerability
.
confirmed?
not_modified!
if
@vulnerability
.
confirmed?
vulnerability
=
::
Vulnerabilities
::
ConfirmService
.
new
(
current_user
,
vulnerability
).
execute
render_vulnerability
(
vulnerability
)
@vulnerability
=
::
Vulnerabilities
::
ConfirmService
.
new
(
current_user
,
@vulnerability
).
execute
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