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
25278ccd
Commit
25278ccd
authored
Jun 15, 2020
by
Philip Cunningham
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Indicate pipeline was ondemand and rename build
parent
1d375778
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
24 deletions
+34
-24
app/models/ci/pipeline_enums.rb
app/models/ci/pipeline_enums.rb
+2
-1
ee/app/services/ci/run_dast_scan_service.rb
ee/app/services/ci/run_dast_scan_service.rb
+2
-2
ee/spec/services/ci/run_dast_scan_service_spec.rb
ee/spec/services/ci/run_dast_scan_service_spec.rb
+30
-21
No files found.
app/models/ci/pipeline_enums.rb
View file @
25278ccd
...
@@ -30,7 +30,8 @@ module Ci
...
@@ -30,7 +30,8 @@ module Ci
webide:
9
,
webide:
9
,
merge_request_event:
10
,
merge_request_event:
10
,
external_pull_request_event:
11
,
external_pull_request_event:
11
,
parent_pipeline:
12
parent_pipeline:
12
,
ondemand_scan:
13
}
}
end
end
...
...
ee/app/services/ci/run_dast_scan_service.rb
View file @
25278ccd
...
@@ -43,7 +43,7 @@ module Ci
...
@@ -43,7 +43,7 @@ module Ci
project:
project
,
project:
project
,
ref:
branch
,
ref:
branch
,
sha:
project
.
repository
.
commit
&
.
id
||
DEFAULT_SHA_FOR_PROJECTS_WITHOUT_COMMITS
,
sha:
project
.
repository
.
commit
&
.
id
||
DEFAULT_SHA_FOR_PROJECTS_WITHOUT_COMMITS
,
source: :
web
,
source: :
ondemand_scan
,
user:
user
user:
user
)
)
end
end
...
@@ -62,7 +62,7 @@ module Ci
...
@@ -62,7 +62,7 @@ module Ci
def
create_build!
(
pipeline
,
stage
,
branch
,
target_url
)
def
create_build!
(
pipeline
,
stage
,
branch
,
target_url
)
reraise!
(
with:
CreateBuildError
.
new
(
'Could not create build'
))
do
reraise!
(
with:
CreateBuildError
.
new
(
'Could not create build'
))
do
Ci
::
Build
.
create!
(
Ci
::
Build
.
create!
(
name:
'
On demand DAST s
can'
,
name:
'
DAST S
can'
,
pipeline:
pipeline
,
pipeline:
pipeline
,
project:
project
,
project:
project
,
ref:
branch
,
ref:
branch
,
...
...
ee/spec/services/ci/run_dast_scan_service_spec.rb
View file @
25278ccd
...
@@ -34,6 +34,10 @@ describe Ci::RunDastScanService do
...
@@ -34,6 +34,10 @@ describe Ci::RunDastScanService do
expect
(
subject
.
ref
).
to
eq
(
branch
)
expect
(
subject
.
ref
).
to
eq
(
branch
)
end
end
it
'sets the source to indicate an ondemand scan'
do
expect
(
subject
.
source
).
to
eq
(
'ondemand_scan'
)
end
it
'creates a stage'
do
it
'creates a stage'
do
expect
{
subject
}.
to
change
(
Ci
::
Stage
,
:count
).
by
(
1
)
expect
{
subject
}.
to
change
(
Ci
::
Stage
,
:count
).
by
(
1
)
end
end
...
@@ -42,19 +46,24 @@ describe Ci::RunDastScanService do
...
@@ -42,19 +46,24 @@ describe Ci::RunDastScanService do
expect
{
subject
}.
to
change
(
Ci
::
Build
,
:count
).
by
(
1
)
expect
{
subject
}.
to
change
(
Ci
::
Build
,
:count
).
by
(
1
)
end
end
it
'sets the build name to indicate a DAST scan'
do
build
=
subject
.
builds
.
first
expect
(
build
.
name
).
to
eq
(
'DAST Scan'
)
end
it
'creates a build with appropriate options'
do
it
'creates a build with appropriate options'
do
build
=
subject
.
builds
.
first
build
=
subject
.
builds
.
first
expected_options
=
{
expected_options
=
{
"image"
=>
{
'image'
=>
{
"name"
=>
"$SECURE_ANALYZERS_PREFIX/dast:$DAST_VERSION"
'name'
=>
'$SECURE_ANALYZERS_PREFIX/dast:$DAST_VERSION'
},
},
"script"
=>
[
'script'
=>
[
"export DAST_WEBSITE=${DAST_WEBSITE:-$(cat environment_url.txt)}"
,
'export DAST_WEBSITE=${DAST_WEBSITE:-$(cat environment_url.txt)}'
,
"/analyze"
'/analyze'
],
],
"artifacts"
=>
{
'artifacts'
=>
{
"reports"
=>
{
'reports'
=>
{
"dast"
=>
[
"gl-dast-report.json"
]
'dast'
=>
[
'gl-dast-report.json'
]
}
}
}
}
}
}
...
@@ -65,21 +74,21 @@ describe Ci::RunDastScanService do
...
@@ -65,21 +74,21 @@ describe Ci::RunDastScanService do
build
=
subject
.
builds
.
first
build
=
subject
.
builds
.
first
expected_variables
=
[
expected_variables
=
[
{
{
"key"
=>
"DAST_VERSION"
,
'key'
=>
'DAST_VERSION'
,
"value"
=>
"1"
,
'value'
=>
'1'
,
"public"
=>
true
'public'
=>
true
},
{
},
{
"key"
=>
"SECURE_ANALYZERS_PREFIX"
,
'key'
=>
'SECURE_ANALYZERS_PREFIX'
,
"value"
=>
"registry.gitlab.com/gitlab-org/security-products/analyzers"
,
'value'
=>
'registry.gitlab.com/gitlab-org/security-products/analyzers'
,
"public"
=>
true
'public'
=>
true
},
{
},
{
"key"
=>
"DAST_WEBSITE"
,
'key'
=>
'DAST_WEBSITE'
,
"value"
=>
target_url
,
'value'
=>
target_url
,
"public"
=>
true
'public'
=>
true
},
{
},
{
"key"
=>
"GIT_STRATEGY"
,
'key'
=>
'GIT_STRATEGY'
,
"value"
=>
"none"
,
'value'
=>
'none'
,
"public"
=>
true
'public'
=>
true
}
}
]
]
expect
(
build
.
yaml_variables
).
to
eq
(
expected_variables
)
expect
(
build
.
yaml_variables
).
to
eq
(
expected_variables
)
...
@@ -92,7 +101,7 @@ describe Ci::RunDastScanService do
...
@@ -92,7 +101,7 @@ describe Ci::RunDastScanService do
context
'when the repository has no commits'
do
context
'when the repository has no commits'
do
it
'uses a placeholder'
do
it
'uses a placeholder'
do
expect
(
subject
.
sha
).
to
eq
(
"placeholder"
)
expect
(
subject
.
sha
).
to
eq
(
'placeholder'
)
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