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
561d4f3a
Commit
561d4f3a
authored
Oct 30, 2020
by
Jonathan Schafer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve vuln issue/MR creation errors
parent
50353228
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
16 additions
and
11 deletions
+16
-11
ee/app/services/issues/create_from_vulnerability_data_service.rb
...services/issues/create_from_vulnerability_data_service.rb
+1
-1
ee/app/services/issues/create_from_vulnerability_service.rb
ee/app/services/issues/create_from_vulnerability_service.rb
+1
-1
ee/app/services/merge_requests/create_from_vulnerability_data_service.rb
.../merge_requests/create_from_vulnerability_data_service.rb
+2
-2
ee/changelogs/unreleased/better_vuln_issue_mr_creation_errors.yml
...elogs/unreleased/better_vuln_issue_mr_creation_errors.yml
+5
-0
ee/spec/services/ee/issues/create_from_vulnerability_data_service_spec.rb
.../ee/issues/create_from_vulnerability_data_service_spec.rb
+2
-2
ee/spec/services/ee/issues/create_from_vulnerability_service_spec.rb
...vices/ee/issues/create_from_vulnerability_service_spec.rb
+2
-2
ee/spec/services/ee/merge_requests/create_from_vulnerability_data_service_spec.rb
...e_requests/create_from_vulnerability_data_service_spec.rb
+3
-3
No files found.
ee/app/services/issues/create_from_vulnerability_data_service.rb
View file @
561d4f3a
...
...
@@ -3,7 +3,7 @@
module
Issues
class
CreateFromVulnerabilityDataService
<
::
BaseService
def
execute
return
error
(
"
Can't
create issue"
)
unless
can?
(
@current_user
,
:create_issue
,
@project
)
return
error
(
"
User not permitted to
create issue"
)
unless
can?
(
@current_user
,
:create_issue
,
@project
)
begin
vulnerability
=
Gitlab
::
Vulnerabilities
::
Parser
.
fabricate
(
@params
)
...
...
ee/app/services/issues/create_from_vulnerability_service.rb
View file @
561d4f3a
...
...
@@ -2,7 +2,7 @@
module
Issues
class
CreateFromVulnerabilityService
<
::
BaseContainerService
def
execute
return
error
(
"
Can't
create issue"
)
unless
can?
(
@current_user
,
:create_issue
,
@container
)
return
error
(
"
User not permitted to
create issue"
)
unless
can?
(
@current_user
,
:create_issue
,
@container
)
vulnerability
=
params
[
:vulnerability
].
present
link_type
=
params
[
:link_type
]
...
...
ee/app/services/merge_requests/create_from_vulnerability_data_service.rb
View file @
561d4f3a
...
...
@@ -16,8 +16,8 @@ module MergeRequests
]
target_branch
=
vulnerability
.
target_branch
||
@project
.
default_branch
return
error
(
"
Can't create merge_
request"
)
unless
can_create_merge_request?
(
source_branch
)
return
error
(
"
Can't create
merge request"
)
if
vulnerability
.
remediations
.
empty?
return
error
(
"
User not permitted to create merge
request"
)
unless
can_create_merge_request?
(
source_branch
)
return
error
(
"
No remdiations available for
merge request"
)
if
vulnerability
.
remediations
.
empty?
patch_result
=
create_patch
(
vulnerability
,
source_branch
,
target_branch
)
...
...
ee/changelogs/unreleased/better_vuln_issue_mr_creation_errors.yml
0 → 100644
View file @
561d4f3a
---
title
:
Improve error messages for Vulnerability Issue/MR creation
merge_request
:
46589
author
:
type
:
changed
ee/spec/services/ee/issues/create_from_vulnerability_data_service_spec.rb
View file @
561d4f3a
...
...
@@ -37,7 +37,7 @@ RSpec.describe Issues::CreateFromVulnerabilityDataService, '#execute' do
it
'returns expected error'
do
expect
(
result
[
:status
]).
to
eq
(
:error
)
expect
(
result
[
:message
]).
to
eq
(
"
Can't
create issue"
)
expect
(
result
[
:message
]).
to
eq
(
"
User not permitted to
create issue"
)
end
end
...
...
@@ -47,7 +47,7 @@ RSpec.describe Issues::CreateFromVulnerabilityDataService, '#execute' do
it
'returns expected error'
do
expect
(
result
[
:status
]).
to
eq
(
:error
)
expect
(
result
[
:message
]).
to
eq
(
"
Can't
create issue"
)
expect
(
result
[
:message
]).
to
eq
(
"
User not permitted to
create issue"
)
end
end
...
...
ee/spec/services/ee/issues/create_from_vulnerability_service_spec.rb
View file @
561d4f3a
...
...
@@ -80,7 +80,7 @@ RSpec.describe Issues::CreateFromVulnerabilityService, '#execute' do
it
'returns expected error'
do
expect
(
result
[
:status
]).
to
eq
(
:error
)
expect
(
result
[
:message
]).
to
eq
(
"
Can't
create issue"
)
expect
(
result
[
:message
]).
to
eq
(
"
User not permitted to
create issue"
)
end
end
...
...
@@ -89,7 +89,7 @@ RSpec.describe Issues::CreateFromVulnerabilityService, '#execute' do
it
'returns expected error'
do
expect
(
result
[
:status
]).
to
eq
(
:error
)
expect
(
result
[
:message
]).
to
eq
(
"
Can't
create issue"
)
expect
(
result
[
:message
]).
to
eq
(
"
User not permitted to
create issue"
)
end
end
...
...
ee/spec/services/ee/merge_requests/create_from_vulnerability_data_service_spec.rb
View file @
561d4f3a
...
...
@@ -43,7 +43,7 @@ RSpec.describe MergeRequests::CreateFromVulnerabilityDataService, '#execute' do
it
'returns expected error'
do
expect
(
result
[
:status
]).
to
eq
(
:error
)
expect
(
result
[
:message
]).
to
eq
(
"
Can't create merge_
request"
)
expect
(
result
[
:message
]).
to
eq
(
"
User not permitted to create merge
request"
)
end
end
...
...
@@ -53,7 +53,7 @@ RSpec.describe MergeRequests::CreateFromVulnerabilityDataService, '#execute' do
it
'returns expected error'
do
expect
(
result
[
:status
]).
to
eq
(
:error
)
expect
(
result
[
:message
]).
to
eq
(
"
Can't create merge_
request"
)
expect
(
result
[
:message
]).
to
eq
(
"
User not permitted to create merge
request"
)
end
end
...
...
@@ -213,7 +213,7 @@ RSpec.describe MergeRequests::CreateFromVulnerabilityDataService, '#execute' do
it
'return expected error'
do
expect
(
result
[
:status
]).
to
eq
(
:error
)
expect
(
result
[
:message
]).
to
eq
(
"
Can't create
merge request"
)
expect
(
result
[
:message
]).
to
eq
(
"
No remdiations available for
merge request"
)
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