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
b0628cea
Commit
b0628cea
authored
Apr 29, 2020
by
Lucas Charles
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate DAST CI template to rules syntax
See
https://gitlab.com/gitlab-org/gitlab/-/issues/36546
parent
23fad217
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
138 additions
and
32 deletions
+138
-32
changelogs/unreleased/e2300-dast-template.yml
changelogs/unreleased/e2300-dast-template.yml
+5
-0
ee/spec/lib/gitlab/ci/templates/dast_gitlab_ci_yaml_spec.rb
ee/spec/lib/gitlab/ci/templates/dast_gitlab_ci_yaml_spec.rb
+101
-0
lib/gitlab/ci/templates/Jobs/DAST-Default-Branch-Deploy.gitlab-ci.yml
...i/templates/Jobs/DAST-Default-Branch-Deploy.gitlab-ci.yml
+20
-22
lib/gitlab/ci/templates/Security/DAST.gitlab-ci.yml
lib/gitlab/ci/templates/Security/DAST.gitlab-ci.yml
+12
-10
No files found.
changelogs/unreleased/e2300-dast-template.yml
0 → 100644
View file @
b0628cea
---
title
:
Migrate DAST CI template to rules syntax
merge_request
:
30776
author
:
type
:
changed
ee/spec/lib/gitlab/ci/templates/dast_gitlab_ci_yaml_spec.rb
0 → 100644
View file @
b0628cea
# frozen_string_literal: true
require
'spec_helper'
describe
'DAST.gitlab-ci.yml'
do
subject
(
:template
)
{
Gitlab
::
Template
::
GitlabCiYmlTemplate
.
find
(
'DAST'
)
}
describe
'the created pipeline'
do
let
(
:user
)
{
create
(
:admin
)
}
let
(
:default_branch
)
{
'master'
}
let
(
:pipeline_branch
)
{
default_branch
}
let
(
:project
)
{
create
(
:project
,
:custom_repo
,
files:
{
'README.txt'
=>
''
})
}
let
(
:service
)
{
Ci
::
CreatePipelineService
.
new
(
project
,
user
,
ref:
pipeline_branch
)
}
let
(
:pipeline
)
{
service
.
execute!
(
:push
)
}
let
(
:build_names
)
{
pipeline
.
builds
.
pluck
(
:name
)
}
before
do
stub_ci_pipeline_yaml_file
(
template
.
content
)
allow_any_instance_of
(
Ci
::
BuildScheduleWorker
).
to
receive
(
:perform
).
and_return
(
true
)
allow
(
project
).
to
receive
(
:default_branch
).
and_return
(
default_branch
)
end
context
'when project has no license'
do
it
'includes no jobs'
do
expect
{
pipeline
}.
to
raise_error
(
Ci
::
CreatePipelineService
::
CreateError
)
end
end
context
'when project has Ultimate license'
do
let
(
:license
)
{
create
(
:license
,
plan:
License
::
ULTIMATE_PLAN
)
}
before
do
allow
(
License
).
to
receive
(
:current
).
and_return
(
license
)
end
context
'by default'
do
it
'includes job'
do
expect
(
build_names
).
to
match_array
(
%w[dast]
)
end
end
context
'when DAST_DISABLED=1'
do
before
do
create
(
:ci_variable
,
project:
project
,
key:
'DAST_DISABLED'
,
value:
'1'
)
end
it
'includes no jobs'
do
expect
{
pipeline
}.
to
raise_error
(
Ci
::
CreatePipelineService
::
CreateError
)
end
end
context
'when DAST_DISABLED_FOR_DEFAULT_BRANCH=1'
do
before
do
create
(
:ci_variable
,
project:
project
,
key:
'DAST_DISABLED_FOR_DEFAULT_BRANCH'
,
value:
'1'
)
end
context
'when on default branch'
do
it
'includes no jobs'
do
expect
{
pipeline
}.
to
raise_error
(
Ci
::
CreatePipelineService
::
CreateError
)
end
end
context
'when on feature branch'
do
let
(
:pipeline_branch
)
{
'patch-1'
}
before
do
project
.
repository
.
create_branch
(
pipeline_branch
)
end
it
'includes job'
do
expect
(
build_names
).
to
match_array
(
%w[dast]
)
end
end
end
context
'when REVIEW_DISABLED=true'
do
before
do
create
(
:ci_variable
,
project:
project
,
key:
'REVIEW_DISABLED'
,
value:
'true'
)
end
context
'when on default branch'
do
it
'includes job'
do
expect
(
build_names
).
to
match_array
(
%w[dast]
)
end
end
context
'when on feature branch'
do
let
(
:pipeline_branch
)
{
'patch-1'
}
before
do
project
.
repository
.
create_branch
(
pipeline_branch
)
end
it
'includes no jobs'
do
expect
{
pipeline
}.
to
raise_error
(
Ci
::
CreatePipelineService
::
CreateError
)
end
end
end
end
end
end
lib/gitlab/ci/templates/Jobs/DAST-Default-Branch-Deploy.gitlab-ci.yml
View file @
b0628cea
...
@@ -18,17 +18,16 @@ dast_environment_deploy:
...
@@ -18,17 +18,16 @@ dast_environment_deploy:
on_stop
:
stop_dast_environment
on_stop
:
stop_dast_environment
artifacts
:
artifacts
:
paths
:
[
environment_url.txt
]
paths
:
[
environment_url.txt
]
only
:
rules
:
refs
:
-
if
:
$CI_DEFAULT_BRANCH != $CI_COMMIT_REF_NAME
-
branches
when
:
never
variables
:
-
if
:
$DAST_DISABLED || $DAST_DISABLED_FOR_DEFAULT_BRANCH
-
$GITLAB_FEATURES =~ /\bdast\b/
when
:
never
kubernetes
:
active
-
if
:
$DAST_WEBSITE
# we don't need to create a review app if a URL is already given
except
:
when
:
never
variables
:
-
if
:
$CI_COMMIT_BRANCH &&
-
$CI_DEFAULT_BRANCH != $CI_COMMIT_REF_NAME
$CI_KUBERNETES_ACTIVE &&
-
$DAST_DISABLED || $DAST_DISABLED_FOR_DEFAULT_BRANCH
$GITLAB_FEATURES =~ /\bdast\b/
-
$DAST_WEBSITE
# we don't need to create a review app if a URL is already given
stop_dast_environment
:
stop_dast_environment
:
extends
:
.dast-auto-deploy
extends
:
.dast-auto-deploy
...
@@ -42,14 +41,13 @@ stop_dast_environment:
...
@@ -42,14 +41,13 @@ stop_dast_environment:
name
:
dast-default
name
:
dast-default
action
:
stop
action
:
stop
needs
:
[
"
dast"
]
needs
:
[
"
dast"
]
only
:
rules
:
refs
:
-
if
:
$CI_DEFAULT_BRANCH != $CI_COMMIT_REF_NAME
-
branches
when
:
never
variables
:
-
if
:
$DAST_DISABLED || $DAST_DISABLED_FOR_DEFAULT_BRANCH
-
$GITLAB_FEATURES =~ /\bdast\b/
when
:
never
kubernetes
:
active
-
if
:
$DAST_WEBSITE
# we don't need to create a review app if a URL is already given
except
:
when
:
never
variables
:
-
if
:
$CI_COMMIT_BRANCH &&
-
$CI_DEFAULT_BRANCH != $CI_COMMIT_REF_NAME
$CI_KUBERNETES_ACTIVE &&
-
$DAST_DISABLED || $DAST_DISABLED_FOR_DEFAULT_BRANCH
$GITLAB_FEATURES =~ /\bdast\b/
-
$DAST_WEBSITE
lib/gitlab/ci/templates/Security/DAST.gitlab-ci.yml
View file @
b0628cea
...
@@ -27,13 +27,15 @@ dast:
...
@@ -27,13 +27,15 @@ dast:
artifacts
:
artifacts
:
reports
:
reports
:
dast
:
gl-dast-report.json
dast
:
gl-dast-report.json
only
:
rules
:
refs
:
-
if
:
$DAST_DISABLED
-
branches
when
:
never
variables
:
-
if
:
$DAST_DISABLED_FOR_DEFAULT_BRANCH &&
-
$GITLAB_FEATURES =~ /\bdast\b/
$CI_DEFAULT_BRANCH == $CI_COMMIT_REF_NAME
except
:
when
:
never
variables
:
-
if
:
$CI_DEFAULT_BRANCH != $CI_COMMIT_REF_NAME &&
-
$DAST_DISABLED
$REVIEW_DISABLED && $DAST_WEBSITE ==
null
&&
-
$DAST_DISABLED_FOR_DEFAULT_BRANCH && $CI_DEFAULT_BRANCH == $CI_COMMIT_REF_NAME
$DAST_API_SPECIFICATION ==
null
-
$CI_DEFAULT_BRANCH != $CI_COMMIT_REF_NAME && $REVIEW_DISABLED && $DAST_WEBSITE ==
null
&& $DAST_API_SPECIFICATION ==
null
when
:
never
-
if
:
$CI_COMMIT_BRANCH &&
$GITLAB_FEATURES =~ /\bdast\b/
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