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
2cf572e7
Commit
2cf572e7
authored
Sep 28, 2021
by
Philip Cunningham
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move DAST scans services to AppSec namespace
- Renames services for scans - Updates specs and cleans up usages
parent
8ac59c7d
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
104 additions
and
96 deletions
+104
-96
.gitlab/CODEOWNERS
.gitlab/CODEOWNERS
+1
-1
ee/app/graphql/mutations/dast/profiles/run.rb
ee/app/graphql/mutations/dast/profiles/run.rb
+1
-1
ee/app/graphql/mutations/dast_on_demand_scans/create.rb
ee/app/graphql/mutations/dast_on_demand_scans/create.rb
+1
-1
ee/app/services/app_sec/dast/profiles/create_service.rb
ee/app/services/app_sec/dast/profiles/create_service.rb
+1
-1
ee/app/services/app_sec/dast/profiles/update_service.rb
ee/app/services/app_sec/dast/profiles/update_service.rb
+1
-1
ee/app/services/app_sec/dast/scans/create_service.rb
ee/app/services/app_sec/dast/scans/create_service.rb
+49
-0
ee/app/services/app_sec/dast/scans/run_service.rb
ee/app/services/app_sec/dast/scans/run_service.rb
+32
-0
ee/app/services/ci/run_dast_scan_service.rb
ee/app/services/ci/run_dast_scan_service.rb
+0
-28
ee/app/services/dast_on_demand_scans/create_service.rb
ee/app/services/dast_on_demand_scans/create_service.rb
+0
-45
ee/app/services/security/security_orchestration_policies/rule_schedule_service.rb
.../security_orchestration_policies/rule_schedule_service.rb
+1
-1
ee/app/workers/app_sec/dast/profile_schedule_worker.rb
ee/app/workers/app_sec/dast/profile_schedule_worker.rb
+1
-1
ee/spec/graphql/mutations/dast_on_demand_scans/create_spec.rb
...pec/graphql/mutations/dast_on_demand_scans/create_spec.rb
+1
-1
ee/spec/services/app_sec/dast/scans/create_service_spec.rb
ee/spec/services/app_sec/dast/scans/create_service_spec.rb
+7
-7
ee/spec/services/app_sec/dast/scans/run_service_spec.rb
ee/spec/services/app_sec/dast/scans/run_service_spec.rb
+1
-1
ee/spec/services/security/security_orchestration_policies/rule_schedule_service_spec.rb
...rity_orchestration_policies/rule_schedule_service_spec.rb
+2
-2
ee/spec/support/shared_examples/services/dast_on_demand_scans_shared_examples.rb
...examples/services/dast_on_demand_scans_shared_examples.rb
+2
-2
ee/spec/workers/app_sec/dast/profile_schedule_worker_spec.rb
ee/spec/workers/app_sec/dast/profile_schedule_worker_spec.rb
+3
-3
No files found.
.gitlab/CODEOWNERS
View file @
2cf572e7
...
...
@@ -241,7 +241,7 @@ Dangerfile @gl-quality/eng-prod
/ee/lib/gitlab/ci/reports/dependency_list/ @gitlab-org/secure/composition-analysis-be
/ee/lib/gitlab/ci/reports/license_scanning/ @gitlab-org/secure/composition-analysis-be
/ee/lib/gitlab/ci/reports/security/ @gitlab-org/secure/composition-analysis-be @gitlab-org/secure/dynamic-analysis-be @gitlab-org/secure/static-analysis-be @gitlab-org/secure/fuzzing-be
/ee/app/services/
ci/run_dast_scan_service.rb
@gitlab-org/secure/dynamic-analysis-be
/ee/app/services/
app_sec/dast/
@gitlab-org/secure/dynamic-analysis-be
[Container Security]
/ee/app/views/projects/threat_monitoring/** @gitlab-org/protect/container-security-frontend
...
...
ee/app/graphql/mutations/dast/profiles/run.rb
View file @
2cf572e7
...
...
@@ -55,7 +55,7 @@ module Mutations
end
def
create_on_demand_dast_scan
(
project
,
dast_profile
)
::
DastOnDemand
Scans
::
CreateService
.
new
(
::
AppSec
::
Dast
::
Scans
::
CreateService
.
new
(
container:
project
,
current_user:
current_user
,
params:
{
dast_profile:
dast_profile
}
...
...
ee/app/graphql/mutations/dast_on_demand_scans/create.rb
View file @
2cf572e7
...
...
@@ -71,7 +71,7 @@ module Mutations
# rubocop: enable CodeReuse/ActiveRecord
def
create_on_demand_dast_scan
(
project
,
dast_site_profile
,
dast_scanner_profile
)
::
DastOnDemand
Scans
::
CreateService
.
new
(
::
AppSec
::
Dast
::
Scans
::
CreateService
.
new
(
container:
project
,
current_user:
current_user
,
params:
{
...
...
ee/app/services/app_sec/dast/profiles/create_service.rb
View file @
2cf572e7
...
...
@@ -60,7 +60,7 @@ module AppSec
end
def
create_on_demand_scan
(
dast_profile
)
::
DastOnDemand
Scans
::
CreateService
.
new
(
::
AppSec
::
Dast
::
Scans
::
CreateService
.
new
(
container:
container
,
current_user:
current_user
,
params:
{
dast_profile:
dast_profile
}
...
...
ee/app/services/app_sec/dast/profiles/update_service.rb
View file @
2cf572e7
...
...
@@ -130,7 +130,7 @@ module AppSec
end
def
create_scan
(
dast_profile
)
::
DastOnDemand
Scans
::
CreateService
.
new
(
::
AppSec
::
Dast
::
Scans
::
CreateService
.
new
(
container:
container
,
current_user:
current_user
,
params:
{
dast_profile:
dast_profile
}
...
...
ee/app/services/app_sec/dast/scans/create_service.rb
0 → 100644
View file @
2cf572e7
# frozen_string_literal: true
module
AppSec
module
Dast
module
Scans
class
CreateService
<
BaseContainerService
def
execute
return
ServiceResponse
.
error
(
message:
'Insufficient permissions'
)
unless
allowed?
create_pipeline
rescue
KeyError
=>
err
ServiceResponse
.
error
(
message:
err
.
message
.
capitalize
)
end
private
def
allowed?
container
.
licensed_feature_available?
(
:security_on_demand_scans
)
end
def
success_response
(
pipeline
)
pipeline_url
=
Rails
.
application
.
routes
.
url_helpers
.
project_pipeline_url
(
container
,
pipeline
)
ServiceResponse
.
success
(
payload:
{
pipeline:
pipeline
,
pipeline_url:
pipeline_url
}
)
end
def
create_pipeline
config_result
=
AppSec
::
Dast
::
ScanConfigs
::
BuildService
.
new
(
container:
container
,
current_user:
current_user
,
params:
params
).
execute
return
config_result
unless
config_result
.
success?
result
=
::
AppSec
::
Dast
::
Scans
::
RunService
.
new
(
container
,
current_user
).
execute
(
**
config_result
.
payload
)
return
success_response
(
result
.
payload
)
if
result
.
success?
result
end
end
end
end
end
ee/app/services/app_sec/dast/scans/run_service.rb
0 → 100644
View file @
2cf572e7
# frozen_string_literal: true
module
AppSec
module
Dast
module
Scans
class
RunService
<
BaseService
def
execute
(
branch
:,
ci_configuration
:,
dast_profile:
nil
,
dast_site_profile:
nil
,
dast_scanner_profile:
nil
)
return
ServiceResponse
.
error
(
message:
'Insufficient permissions'
)
unless
allowed?
service
=
Ci
::
CreatePipelineService
.
new
(
project
,
current_user
,
ref:
branch
)
response
=
service
.
execute
(
:ondemand_dast_scan
,
content:
ci_configuration
)
do
|
pipeline
|
pipeline
.
dast_profile
=
dast_profile
end
pipeline
=
response
.
payload
if
pipeline
.
created_successfully?
ServiceResponse
.
success
(
payload:
pipeline
)
else
ServiceResponse
.
error
(
message:
pipeline
.
full_error_messages
)
end
end
private
def
allowed?
Ability
.
allowed?
(
current_user
,
:create_on_demand_dast_scan
,
project
)
end
end
end
end
end
ee/app/services/ci/run_dast_scan_service.rb
deleted
100644 → 0
View file @
8ac59c7d
# frozen_string_literal: true
module
Ci
class
RunDastScanService
<
BaseService
def
execute
(
branch
:,
ci_configuration
:,
dast_profile:
nil
,
dast_site_profile:
nil
,
dast_scanner_profile:
nil
)
return
ServiceResponse
.
error
(
message:
'Insufficient permissions'
)
unless
allowed?
service
=
Ci
::
CreatePipelineService
.
new
(
project
,
current_user
,
ref:
branch
)
response
=
service
.
execute
(
:ondemand_dast_scan
,
content:
ci_configuration
)
do
|
pipeline
|
pipeline
.
dast_profile
=
dast_profile
end
pipeline
=
response
.
payload
if
pipeline
.
created_successfully?
ServiceResponse
.
success
(
payload:
pipeline
)
else
ServiceResponse
.
error
(
message:
pipeline
.
full_error_messages
)
end
end
private
def
allowed?
Ability
.
allowed?
(
current_user
,
:create_on_demand_dast_scan
,
project
)
end
end
end
ee/app/services/dast_on_demand_scans/create_service.rb
deleted
100644 → 0
View file @
8ac59c7d
# frozen_string_literal: true
module
DastOnDemandScans
class
CreateService
<
BaseContainerService
def
execute
return
ServiceResponse
.
error
(
message:
'Insufficient permissions'
)
unless
allowed?
create_pipeline
rescue
KeyError
=>
err
ServiceResponse
.
error
(
message:
err
.
message
.
capitalize
)
end
private
def
allowed?
container
.
feature_available?
(
:security_on_demand_scans
)
end
def
success_response
(
pipeline
)
pipeline_url
=
Rails
.
application
.
routes
.
url_helpers
.
project_pipeline_url
(
container
,
pipeline
)
ServiceResponse
.
success
(
payload:
{
pipeline:
pipeline
,
pipeline_url:
pipeline_url
}
)
end
def
create_pipeline
config_result
=
AppSec
::
Dast
::
ScanConfigs
::
BuildService
.
new
(
container:
container
,
current_user:
current_user
,
params:
params
).
execute
return
config_result
unless
config_result
.
success?
result
=
::
Ci
::
RunDastScanService
.
new
(
container
,
current_user
).
execute
(
**
config_result
.
payload
)
return
success_response
(
result
.
payload
)
if
result
.
success?
result
end
end
end
ee/app/services/security/security_orchestration_policies/rule_schedule_service.rb
View file @
2cf572e7
...
...
@@ -53,7 +53,7 @@ module Security
dast_scanner_profile
=
find_dast_scanner_profile
(
container
,
action
[
:scanner_profile
])
branches
.
each
do
|
branch
|
::
DastOnDemand
Scans
::
CreateService
.
new
(
::
AppSec
::
Dast
::
Scans
::
CreateService
.
new
(
container:
container
,
current_user:
current_user
,
params:
{
...
...
ee/app/workers/app_sec/dast/profile_schedule_worker.rb
View file @
2cf572e7
...
...
@@ -37,7 +37,7 @@ module AppSec
end
def
service
(
schedule
)
::
DastOnDemand
Scans
::
CreateService
.
new
(
::
AppSec
::
Dast
::
Scans
::
CreateService
.
new
(
container:
schedule
.
project
,
current_user:
schedule
.
owner
,
params:
{
...
...
ee/spec/graphql/mutations/dast_on_demand_scans/create_spec.rb
View file @
2cf572e7
...
...
@@ -83,7 +83,7 @@ RSpec.describe Mutations::DastOnDemandScans::Create do
ci_configuration:
kind_of
(
String
)
)
expect_any_instance_of
(
::
Ci
::
RunDastSca
nService
).
to
receive
(
:execute
).
with
(
args
).
and_call_original
expect_any_instance_of
(
::
AppSec
::
Dast
::
Scans
::
Ru
nService
).
to
receive
(
:execute
).
with
(
args
).
and_call_original
subject
end
...
...
ee/spec/services/
dast_on_demand_
scans/create_service_spec.rb
→
ee/spec/services/
app_sec/dast/
scans/create_service_spec.rb
View file @
2cf572e7
...
...
@@ -2,7 +2,7 @@
require
'spec_helper'
RSpec
.
describe
DastOnDemand
Scans
::
CreateService
do
RSpec
.
describe
AppSec
::
Dast
::
Scans
::
CreateService
do
let_it_be
(
:project
)
{
create
(
:project
,
:repository
)
}
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:dast_site_profile
)
{
create
(
:dast_site_profile
,
project:
project
)
}
...
...
@@ -18,12 +18,12 @@ RSpec.describe DastOnDemandScans::CreateService do
).
execute
end
shared_examples
'a service that calls
Ci::RunDastSca
nService'
do
it
'delegates pipeline creation to
Ci::RunDastSca
nService'
,
:aggregate_failures
do
service
=
double
(
Ci
::
RunDastSca
nService
)
shared_examples
'a service that calls
AppSec::Dast::Scans::Ru
nService'
do
it
'delegates pipeline creation to
AppSec::Dast::Scans::Ru
nService'
,
:aggregate_failures
do
service
=
double
(
AppSec
::
Dast
::
Scans
::
Ru
nService
)
response
=
ServiceResponse
.
error
(
message:
'Stubbed response'
)
expect
(
Ci
::
RunDastSca
nService
).
to
receive
(
:new
).
and_return
(
service
)
expect
(
AppSec
::
Dast
::
Scans
::
Ru
nService
).
to
receive
(
:new
).
and_return
(
service
)
expect
(
service
).
to
receive
(
:execute
).
with
(
expected_params
).
and_return
(
response
)
subject
...
...
@@ -61,7 +61,7 @@ RSpec.describe DastOnDemandScans::CreateService do
expect
(
subject
.
payload
[
:pipeline_url
]).
to
be_a
(
String
)
end
it_behaves_like
'a service that calls
Ci::RunDastSca
nService'
do
it_behaves_like
'a service that calls
AppSec::Dast::Scans::Ru
nService'
do
let
(
:expected_params
)
do
hash_including
(
dast_profile:
nil
,
...
...
@@ -107,7 +107,7 @@ RSpec.describe DastOnDemandScans::CreateService do
expect
(
subject
.
status
).
to
eq
(
:success
)
end
it_behaves_like
'a service that calls
Ci::RunDastSca
nService'
do
it_behaves_like
'a service that calls
AppSec::Dast::Scans::Ru
nService'
do
let
(
:expected_params
)
{
hash_including
(
dast_profile:
dast_profile
)
}
end
end
...
...
ee/spec/services/
ci/run_dast_sca
n_service_spec.rb
→
ee/spec/services/
app_sec/dast/scans/ru
n_service_spec.rb
View file @
2cf572e7
...
...
@@ -2,7 +2,7 @@
require
'spec_helper'
RSpec
.
describe
Ci
::
RunDastSca
nService
do
RSpec
.
describe
AppSec
::
Dast
::
Scans
::
Ru
nService
do
include
Ci
::
TemplateHelpers
let_it_be
(
:user
)
{
create
(
:user
)
}
...
...
ee/spec/services/security/security_orchestration_policies/rule_schedule_service_spec.rb
View file @
2cf572e7
...
...
@@ -34,8 +34,8 @@ RSpec.describe Security::SecurityOrchestrationPolicies::RuleScheduleService do
end
context
'when scan type is dast'
do
it
'invokes
DastOnDemand
Scans::CreateService'
do
expect
(
::
DastOnDemand
Scans
::
CreateService
).
to
receive
(
:new
).
twice
.
and_call_original
it
'invokes
AppSec::Dast::
Scans::CreateService'
do
expect
(
::
AppSec
::
Dast
::
Scans
::
CreateService
).
to
receive
(
:new
).
twice
.
and_call_original
service
.
execute
(
schedule
)
end
...
...
ee/spec/support/shared_examples/services/dast_on_demand_scans_shared_examples.rb
View file @
2cf572e7
...
...
@@ -3,8 +3,8 @@
require
'spec_helper'
RSpec
.
shared_examples
'it delegates scan creation to another service'
do
it
'calls
DastOnDemand
Scans::CreateService'
do
expect
(
DastOnDemand
Scans
::
CreateService
).
to
receive
(
:new
).
with
(
hash_including
(
params:
delegated_params
)).
and_call_original
it
'calls
AppSec::Dast::
Scans::CreateService'
do
expect
(
AppSec
::
Dast
::
Scans
::
CreateService
).
to
receive
(
:new
).
with
(
hash_including
(
params:
delegated_params
)).
and_call_original
subject
end
...
...
ee/spec/workers/app_sec/dast/profile_schedule_worker_spec.rb
View file @
2cf572e7
...
...
@@ -9,11 +9,11 @@ RSpec.describe AppSec::Dast::ProfileScheduleWorker do
let
(
:worker
)
{
described_class
.
new
}
let
(
:logger
)
{
worker
.
send
(
:logger
)
}
let
(
:service
)
{
instance_double
(
::
DastOnDemand
Scans
::
CreateService
)
}
let
(
:service
)
{
instance_double
(
::
AppSec
::
Dast
::
Scans
::
CreateService
)
}
let
(
:service_result
)
{
ServiceResponse
.
success
}
before
do
allow
(
::
DastOnDemand
Scans
::
CreateService
)
allow
(
::
AppSec
::
Dast
::
Scans
::
CreateService
)
.
to
receive
(
:new
)
.
and_return
(
service
)
allow
(
service
).
to
receive
(
:execute
)
...
...
@@ -97,7 +97,7 @@ RSpec.describe AppSec::Dast::ProfileScheduleWorker do
end
it
'executes the rule schedule service'
do
expect
(
::
DastOnDemand
Scans
::
CreateService
).
not_to
receive
(
:new
)
expect
(
::
AppSec
::
Dast
::
Scans
::
CreateService
).
not_to
receive
(
:new
)
subject
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