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
026f586d
Commit
026f586d
authored
Aug 19, 2020
by
saikat sarkar
Committed by
James Fargher
Aug 19, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set default for current_value in SAST config UI
parent
c5576ba6
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
15 deletions
+32
-15
ee/app/services/security/ci_configuration/sast_parser_service.rb
...services/security/ci_configuration/sast_parser_service.rb
+19
-9
ee/changelogs/unreleased/fix_default_value.yml
ee/changelogs/unreleased/fix_default_value.yml
+5
-0
ee/spec/graphql/types/project_type_spec.rb
ee/spec/graphql/types/project_type_spec.rb
+2
-2
ee/spec/services/security/ci_configuration/sast_parser_service_spec.rb
...ces/security/ci_configuration/sast_parser_service_spec.rb
+6
-4
No files found.
ee/app/services/security/ci_configuration/sast_parser_service.rb
View file @
026f586d
...
...
@@ -12,9 +12,14 @@ module Security
end
def
configuration
config
=
Gitlab
::
Json
.
parse
(
File
.
read
(
Rails
.
root
.
join
(
SAST_UI_SCHEMA_PATH
))).
with_indifferent_access
populate_values
(
config
)
config
result
=
Gitlab
::
Json
.
parse
(
File
.
read
(
Rails
.
root
.
join
(
SAST_UI_SCHEMA_PATH
))).
with_indifferent_access
populate_default_value_for
(
result
,
:global
)
populate_default_value_for
(
result
,
:pipeline
)
fill_current_value_with_default_for
(
result
,
:global
)
fill_current_value_with_default_for
(
result
,
:pipeline
)
populate_current_value_for
(
result
,
:global
)
populate_current_value_for
(
result
,
:pipeline
)
result
end
private
...
...
@@ -23,16 +28,21 @@ module Security
Gitlab
::
Template
::
GitlabCiYmlTemplate
.
find
(
'SAST'
).
content
end
def
populate_values
(
config
)
set_each
(
config
[
:global
],
key: :default_value
,
with:
sast_template_attributes
)
set_each
(
config
[
:global
],
key: :value
,
with:
gitlab_ci_yml_attributes
)
set_each
(
config
[
:pipeline
],
key: :default_value
,
with:
sast_template_attributes
)
set_each
(
config
[
:pipeline
],
key: :value
,
with:
gitlab_ci_yml_attributes
)
def
populate_default_value_for
(
config
,
level
)
set_each
(
config
[
level
],
key: :default_value
,
with:
sast_template_attributes
)
end
def
populate_current_value_for
(
config
,
level
)
set_each
(
config
[
level
],
key: :value
,
with:
gitlab_ci_yml_attributes
)
end
def
fill_current_value_with_default_for
(
config
,
level
)
set_each
(
config
[
level
],
key: :value
,
with:
sast_template_attributes
)
end
def
set_each
(
config_attributes
,
key
:,
with
:)
config_attributes
.
each
do
|
entity
|
entity
[
key
]
=
with
[
entity
[
:field
]]
entity
[
key
]
=
with
[
entity
[
:field
]]
if
with
[
entity
[
:field
]]
end
end
...
...
ee/changelogs/unreleased/fix_default_value.yml
0 → 100644
View file @
026f586d
---
title
:
Set default for current_value in SAST config UI
merge_request
:
39504
author
:
type
:
fixed
ee/spec/graphql/types/project_type_spec.rb
View file @
026f586d
...
...
@@ -87,7 +87,7 @@ RSpec.describe GitlabSchema.types['Project'] do
expect
(
secure_analyzers_prefix
[
'field'
]).
to
eq
(
'SECURE_ANALYZERS_PREFIX'
)
expect
(
secure_analyzers_prefix
[
'label'
]).
to
eq
(
'Image prefix'
)
expect
(
secure_analyzers_prefix
[
'defaultValue'
]).
to
eq
(
'registry.gitlab.com/gitlab-org/security-products/analyzers'
)
expect
(
secure_analyzers_prefix
[
'value'
]).
to
be_nil
expect
(
secure_analyzers_prefix
[
'value'
]).
to
eq
(
'registry.gitlab.com/gitlab-org/security-products/analyzers'
)
expect
(
secure_analyzers_prefix
[
'options'
]).
to
be_nil
end
...
...
@@ -97,7 +97,7 @@ RSpec.describe GitlabSchema.types['Project'] do
expect
(
pipeline_stage
[
'field'
]).
to
eq
(
'stage'
)
expect
(
pipeline_stage
[
'label'
]).
to
eq
(
'Stage'
)
expect
(
pipeline_stage
[
'defaultValue'
]).
to
eq
(
'test'
)
expect
(
pipeline_stage
[
'value'
]).
to
be_nil
expect
(
pipeline_stage
[
'value'
]).
to
eq
(
'test'
)
end
it
"returns the project's sast configuration for analyzer variables"
do
...
...
ee/spec/services/security/ci_configuration/sast_parser_service_spec.rb
View file @
026f586d
...
...
@@ -34,11 +34,13 @@ RSpec.describe Security::CiConfiguration::SastParserService do
end
context
'when .gitlab-ci.yml is absent'
do
it
'
assigns current values to nil
'
do
it
'
populates the current values with the default values
'
do
allow
(
project
.
repository
).
to
receive
(
:blob_data_at
).
and_return
(
nil
)
expect
(
secure_analyzers_prefix
[
'value'
]).
to
be_nil
expect
(
sast_excluded_paths
[
'value'
]).
to
be_nil
expect
(
sast_analyzer_image_tag
[
'value'
]).
to
be_nil
expect
(
secure_analyzers_prefix
[
'value'
]).
to
eql
(
'registry.gitlab.com/gitlab-org/security-products/analyzers'
)
expect
(
sast_excluded_paths
[
'value'
]).
to
eql
(
'spec, test, tests, tmp'
)
expect
(
sast_analyzer_image_tag
[
'value'
]).
to
eql
(
'2'
)
expect
(
sast_pipeline_stage
[
'value'
]).
to
eql
(
'test'
)
expect
(
sast_search_max_depth
[
'value'
]).
to
eql
(
'4'
)
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