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
4e7ac11c
Commit
4e7ac11c
authored
Aug 20, 2020
by
Philip Cunningham
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract and use AuthorizesProject concern
Observed common pattern and extracted general functionality.
parent
b3f5fa02
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
27 additions
and
36 deletions
+27
-36
app/graphql/mutations/concerns/mutations/authorizes_project.rb
...raphql/mutations/concerns/mutations/authorizes_project.rb
+17
-0
ee/app/graphql/mutations/dast_on_demand_scans/create.rb
ee/app/graphql/mutations/dast_on_demand_scans/create.rb
+2
-6
ee/app/graphql/mutations/dast_scanner_profiles/create.rb
ee/app/graphql/mutations/dast_scanner_profiles/create.rb
+2
-8
ee/app/graphql/mutations/dast_site_profiles/create.rb
ee/app/graphql/mutations/dast_site_profiles/create.rb
+2
-8
ee/app/graphql/mutations/dast_site_profiles/delete.rb
ee/app/graphql/mutations/dast_site_profiles/delete.rb
+2
-6
ee/app/graphql/mutations/dast_site_profiles/update.rb
ee/app/graphql/mutations/dast_site_profiles/update.rb
+2
-8
No files found.
app/graphql/mutations/concerns/mutations/authorizes_project.rb
0 → 100644
View file @
4e7ac11c
# frozen_string_literal: true
module
Mutations
module
AuthorizesProject
include
ResolvesProject
def
authorized_find_project!
(
full_path
:)
authorized_find!
(
full_path:
full_path
)
end
private
def
find_object
(
full_path
:)
resolve_project
(
full_path:
full_path
)
end
end
end
ee/app/graphql/mutations/dast_on_demand_scans/create.rb
View file @
4e7ac11c
...
...
@@ -5,7 +5,7 @@ module Mutations
class
Create
<
BaseMutation
InvalidGlobalID
=
Class
.
new
(
StandardError
)
include
Resolv
esProject
include
Authoriz
esProject
graphql_name
'DastOnDemandScanCreate'
...
...
@@ -24,7 +24,7 @@ module Mutations
authorize
:create_on_demand_dast_scan
def
resolve
(
full_path
:,
dast_site_profile_id
:)
project
=
authorized_find!
(
full_path:
full_path
)
project
=
authorized_find
_project
!
(
full_path:
full_path
)
dast_site_profile
=
find_dast_site_profile
(
project:
project
,
dast_site_profile_id:
dast_site_profile_id
)
dast_site
=
dast_site_profile
.
dast_site
...
...
@@ -41,10 +41,6 @@ module Mutations
private
def
find_object
(
full_path
:)
resolve_project
(
full_path:
full_path
)
end
def
find_dast_site_profile
(
project
:,
dast_site_profile_id
:)
project
.
dast_site_profiles
...
...
ee/app/graphql/mutations/dast_scanner_profiles/create.rb
View file @
4e7ac11c
...
...
@@ -3,7 +3,7 @@
module
Mutations
module
DastScannerProfiles
class
Create
<
BaseMutation
include
Resolv
esProject
include
Authoriz
esProject
graphql_name
'DastScannerProfileCreate'
...
...
@@ -30,7 +30,7 @@ module Mutations
authorize
:create_on_demand_dast_scan
def
resolve
(
full_path
:,
profile_name
:,
spider_timeout:
nil
,
target_timeout:
nil
)
project
=
authorized_find!
(
full_path:
full_path
)
project
=
authorized_find
_project
!
(
full_path:
full_path
)
service
=
::
DastScannerProfiles
::
CreateService
.
new
(
project
,
current_user
)
result
=
service
.
execute
(
name:
profile_name
,
spider_timeout:
spider_timeout
,
target_timeout:
target_timeout
)
...
...
@@ -41,12 +41,6 @@ module Mutations
{
errors:
result
.
errors
}
end
end
private
def
find_object
(
full_path
:)
resolve_project
(
full_path:
full_path
)
end
end
end
end
ee/app/graphql/mutations/dast_site_profiles/create.rb
View file @
4e7ac11c
...
...
@@ -3,7 +3,7 @@
module
Mutations
module
DastSiteProfiles
class
Create
<
BaseMutation
include
Resolv
esProject
include
Authoriz
esProject
graphql_name
'DastSiteProfileCreate'
...
...
@@ -26,7 +26,7 @@ module Mutations
authorize
:create_on_demand_dast_scan
def
resolve
(
full_path
:,
profile_name
:,
target_url:
nil
)
project
=
authorized_find!
(
full_path:
full_path
)
project
=
authorized_find
_project
!
(
full_path:
full_path
)
service
=
::
DastSiteProfiles
::
CreateService
.
new
(
project
,
current_user
)
result
=
service
.
execute
(
name:
profile_name
,
target_url:
target_url
)
...
...
@@ -37,12 +37,6 @@ module Mutations
{
errors:
result
.
errors
}
end
end
private
def
find_object
(
full_path
:)
resolve_project
(
full_path:
full_path
)
end
end
end
end
ee/app/graphql/mutations/dast_site_profiles/delete.rb
View file @
4e7ac11c
...
...
@@ -3,7 +3,7 @@
module
Mutations
module
DastSiteProfiles
class
Delete
<
BaseMutation
include
Resolv
esProject
include
Authoriz
esProject
graphql_name
'DastSiteProfileDelete'
...
...
@@ -18,7 +18,7 @@ module Mutations
authorize
:create_on_demand_dast_scan
def
resolve
(
full_path
:,
id
:)
project
=
authorized_find!
(
full_path:
full_path
)
project
=
authorized_find
_project
!
(
full_path:
full_path
)
dast_site_profile
=
find_dast_site_profile
(
project:
project
,
global_id:
id
)
return
{
errors:
dast_site_profile
.
errors
.
full_messages
}
unless
dast_site_profile
.
destroy
...
...
@@ -28,10 +28,6 @@ module Mutations
private
def
find_object
(
full_path
:)
resolve_project
(
full_path:
full_path
)
end
def
find_dast_site_profile
(
project
:,
global_id
:)
project
.
dast_site_profiles
.
find
(
global_id
.
model_id
)
end
...
...
ee/app/graphql/mutations/dast_site_profiles/update.rb
View file @
4e7ac11c
...
...
@@ -3,7 +3,7 @@
module
Mutations
module
DastSiteProfiles
class
Update
<
BaseMutation
include
Resolv
esProject
include
Authoriz
esProject
graphql_name
'DastSiteProfileUpdate'
...
...
@@ -30,7 +30,7 @@ module Mutations
authorize
:create_on_demand_dast_scan
def
resolve
(
full_path
:,
**
service_args
)
project
=
authorized_find!
(
full_path:
full_path
)
project
=
authorized_find
_project
!
(
full_path:
full_path
)
service
=
::
DastSiteProfiles
::
UpdateService
.
new
(
project
,
current_user
)
result
=
service
.
execute
(
service_args
)
...
...
@@ -41,12 +41,6 @@ module Mutations
{
errors:
result
.
errors
}
end
end
private
def
find_object
(
full_path
:)
resolve_project
(
full_path:
full_path
)
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