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
8bc0ef86
Commit
8bc0ef86
authored
Jul 19, 2021
by
Adam Cohen
Committed by
Jan Provaznik
Jul 19, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ConfigureSecurityAnalyzer superclass [RUN AS-IF-FOSS]
parent
20659ba3
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
67 additions
and
90 deletions
+67
-90
app/graphql/mutations/security/ci_configuration/base_security_analyzer.rb
...tions/security/ci_configuration/base_security_analyzer.rb
+44
-0
app/graphql/mutations/security/ci_configuration/configure_sast.rb
...hql/mutations/security/ci_configuration/configure_sast.rb
+3
-30
app/graphql/mutations/security/ci_configuration/configure_secret_detection.rb
...s/security/ci_configuration/configure_secret_detection.rb
+3
-30
ee/app/graphql/mutations/security/ci_configuration/configure_dependency_scanning.rb
...ecurity/ci_configuration/configure_dependency_scanning.rb
+3
-30
spec/graphql/mutations/security/ci_configuration/base_security_analyzer_spec.rb
.../security/ci_configuration/base_security_analyzer_spec.rb
+14
-0
No files found.
app/graphql/mutations/security/ci_configuration/base_security_analyzer.rb
0 → 100644
View file @
8bc0ef86
# frozen_string_literal: true
module
Mutations
module
Security
module
CiConfiguration
class
BaseSecurityAnalyzer
<
BaseMutation
include
FindsProject
argument
:project_path
,
GraphQL
::
ID_TYPE
,
required:
true
,
description:
'Full path of the project.'
field
:success_path
,
GraphQL
::
STRING_TYPE
,
null:
true
,
description:
'Redirect path to use when the response is successful.'
field
:branch
,
GraphQL
::
STRING_TYPE
,
null:
true
,
description:
'Branch that has the new/modified `.gitlab-ci.yml` file.'
authorize
:push_code
def
resolve
(
project_path
:,
**
args
)
project
=
authorized_find!
(
project_path
)
result
=
configure_analyzer
(
project
,
**
args
)
prepare_response
(
result
)
end
private
def
configure_analyzer
(
project
,
**
args
)
raise
NotImplementedError
end
def
prepare_response
(
result
)
{
branch:
result
.
payload
[
:branch
],
success_path:
result
.
payload
[
:success_path
],
errors:
result
.
errors
}
end
end
end
end
end
app/graphql/mutations/security/ci_configuration/configure_sast.rb
View file @
8bc0ef86
...
...
@@ -3,9 +3,7 @@
module
Mutations
module
Security
module
CiConfiguration
class
ConfigureSast
<
BaseMutation
include
FindsProject
class
ConfigureSast
<
BaseSecurityAnalyzer
graphql_name
'ConfigureSast'
description
<<~
DESC
Configure SAST for a project by enabling SAST in a new or modified
...
...
@@ -13,37 +11,12 @@ module Mutations
create a Merge Request are a part of the response.
DESC
argument
:project_path
,
GraphQL
::
ID_TYPE
,
required:
true
,
description:
'Full path of the project.'
argument
:configuration
,
::
Types
::
CiConfiguration
::
Sast
::
InputType
,
required:
true
,
description:
'SAST CI configuration for the project.'
field
:success_path
,
GraphQL
::
STRING_TYPE
,
null:
true
,
description:
'Redirect path to use when the response is successful.'
field
:branch
,
GraphQL
::
STRING_TYPE
,
null:
true
,
description:
'Branch that has the new/modified `.gitlab-ci.yml` file.'
authorize
:push_code
def
resolve
(
project_path
:,
configuration
:)
project
=
authorized_find!
(
project_path
)
result
=
::
Security
::
CiConfiguration
::
SastCreateService
.
new
(
project
,
current_user
,
configuration
).
execute
prepare_response
(
result
)
end
private
def
prepare_response
(
result
)
{
branch:
result
.
payload
[
:branch
],
success_path:
result
.
payload
[
:success_path
],
errors:
result
.
errors
}
def
configure_analyzer
(
project
,
**
args
)
::
Security
::
CiConfiguration
::
SastCreateService
.
new
(
project
,
current_user
,
args
[
:configuration
]).
execute
end
end
end
...
...
app/graphql/mutations/security/ci_configuration/configure_secret_detection.rb
View file @
8bc0ef86
...
...
@@ -3,9 +3,7 @@
module
Mutations
module
Security
module
CiConfiguration
class
ConfigureSecretDetection
<
BaseMutation
include
FindsProject
class
ConfigureSecretDetection
<
BaseSecurityAnalyzer
graphql_name
'ConfigureSecretDetection'
description
<<~
DESC
Configure Secret Detection for a project by enabling Secret Detection
...
...
@@ -14,33 +12,8 @@ module Mutations
response.
DESC
argument
:project_path
,
GraphQL
::
ID_TYPE
,
required:
true
,
description:
'Full path of the project.'
field
:success_path
,
GraphQL
::
STRING_TYPE
,
null:
true
,
description:
'Redirect path to use when the response is successful.'
field
:branch
,
GraphQL
::
STRING_TYPE
,
null:
true
,
description:
'Branch that has the new/modified `.gitlab-ci.yml` file.'
authorize
:push_code
def
resolve
(
project_path
:)
project
=
authorized_find!
(
project_path
)
result
=
::
Security
::
CiConfiguration
::
SecretDetectionCreateService
.
new
(
project
,
current_user
).
execute
prepare_response
(
result
)
end
private
def
prepare_response
(
result
)
{
branch:
result
.
payload
[
:branch
],
success_path:
result
.
payload
[
:success_path
],
errors:
result
.
errors
}
def
configure_analyzer
(
project
,
**
_args
)
::
Security
::
CiConfiguration
::
SecretDetectionCreateService
.
new
(
project
,
current_user
).
execute
end
end
end
...
...
ee/app/graphql/mutations/security/ci_configuration/configure_dependency_scanning.rb
View file @
8bc0ef86
...
...
@@ -3,9 +3,7 @@
module
Mutations
module
Security
module
CiConfiguration
class
ConfigureDependencyScanning
<
BaseMutation
include
FindsProject
class
ConfigureDependencyScanning
<
BaseSecurityAnalyzer
graphql_name
'ConfigureDependencyScanning'
description
<<~
DESC
Configure Dependency Scanning for a project by enabling Dependency Scanning in a new or modified
...
...
@@ -13,33 +11,8 @@ module Mutations
create a Merge Request are a part of the response.
DESC
argument
:project_path
,
GraphQL
::
ID_TYPE
,
required:
true
,
description:
'Full path of the project.'
field
:success_path
,
GraphQL
::
STRING_TYPE
,
null:
true
,
description:
'Redirect path to use when the response is successful.'
field
:branch
,
GraphQL
::
STRING_TYPE
,
null:
true
,
description:
'Branch that has the new/modified `.gitlab-ci.yml` file.'
authorize
:push_code
def
resolve
(
project_path
:)
project
=
authorized_find!
(
project_path
)
result
=
::
Security
::
CiConfiguration
::
DependencyScanningCreateService
.
new
(
project
,
current_user
).
execute
prepare_response
(
result
)
end
private
def
prepare_response
(
result
)
{
branch:
result
.
payload
[
:branch
],
success_path:
result
.
payload
[
:success_path
],
errors:
result
.
errors
}
def
configure_analyzer
(
project
,
**
_args
)
::
Security
::
CiConfiguration
::
DependencyScanningCreateService
.
new
(
project
,
current_user
).
execute
end
end
end
...
...
spec/graphql/mutations/security/ci_configuration/base_security_analyzer_spec.rb
0 → 100644
View file @
8bc0ef86
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Mutations
::
Security
::
CiConfiguration
::
BaseSecurityAnalyzer
do
include
GraphqlHelpers
it
'raises a NotImplementedError error if the resolve method is called on the base class'
do
user
=
create
(
:user
)
project
=
create
(
:project
,
:public
,
:repository
)
project
.
add_developer
(
user
)
expect
{
resolve
(
described_class
,
args:
{
project_path:
project
.
full_path
},
ctx:
{
current_user:
user
})
}.
to
raise_error
(
NotImplementedError
)
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