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
7baa1f32
Commit
7baa1f32
authored
Jun 02, 2021
by
Furkan Ayhan
Committed by
Fabio Pitino
Jun 02, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove the usage of yaml_variables in SastParser
parent
ec87f32f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
5 deletions
+60
-5
app/services/security/ci_configuration/sast_parser_service.rb
...services/security/ci_configuration/sast_parser_service.rb
+5
-5
lib/gitlab/ci/yaml_processor/result.rb
lib/gitlab/ci/yaml_processor/result.rb
+16
-0
spec/lib/gitlab/ci/yaml_processor/result_spec.rb
spec/lib/gitlab/ci/yaml_processor/result_spec.rb
+39
-0
No files found.
app/services/security/ci_configuration/sast_parser_service.rb
View file @
7baa1f32
...
...
@@ -109,17 +109,17 @@ module Security
yaml_result
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
content
,
options
).
execute
return
{}
unless
yaml_result
.
valid?
sast_attributes
=
yaml_result
.
build_attributes
(
:sast
)
extract_required_attributes
(
sast_attributes
)
extract_required_attributes
(
yaml_result
)
end
def
extract_required_attributes
(
attributes
)
def
extract_required_attributes
(
yaml_result
)
result
=
{}
attributes
[
:yaml_variables
].
each
do
|
variable
|
yaml_result
.
yaml_variables_for
(
:sast
).
each
do
|
variable
|
result
[
variable
[
:key
]]
=
variable
[
:value
]
end
result
[
:stage
]
=
attributes
[
:stage
]
result
[
:stage
]
=
yaml_result
.
stage_for
(
:sast
)
result
.
with_indifferent_access
end
end
...
...
lib/gitlab/ci/yaml_processor/result.rb
View file @
7baa1f32
...
...
@@ -111,6 +111,22 @@ module Gitlab
@ci_config
.
variables_with_data
end
def
yaml_variables_for
(
job_name
)
job
=
jobs
.
fetch
(
job_name
)
Gitlab
::
Ci
::
Variables
::
Helpers
.
inherit_yaml_variables
(
from:
root_variables
,
to:
transform_to_yaml_variables
(
job
[
:job_variables
]),
inheritance:
job
.
fetch
(
:root_variables_inheritance
,
true
)
)
end
def
stage_for
(
job_name
)
job
=
jobs
.
fetch
(
job_name
)
job
[
:stage
]
end
private
def
variables
...
...
spec/lib/gitlab/ci/yaml_processor/result_spec.rb
View file @
7baa1f32
...
...
@@ -39,6 +39,45 @@ module Gitlab
expect
(
expanded_config
).
to
include
(
*
included_config
.
keys
)
end
end
describe
'#yaml_variables_for'
do
let
(
:config_content
)
do
<<~
YAML
variables:
VAR1: value 1
VAR2: value 2
job:
script: echo 'hello'
variables:
VAR1: value 11
YAML
end
subject
(
:yaml_variables_for
)
{
result
.
yaml_variables_for
(
:job
)
}
it
do
is_expected
.
to
match_array
([
{
key:
'VAR1'
,
value:
'value 11'
,
public:
true
},
{
key:
'VAR2'
,
value:
'value 2'
,
public:
true
}
])
end
end
describe
'#stage_for'
do
let
(
:config_content
)
do
<<~
YAML
job:
script: echo 'hello'
YAML
end
subject
(
:stage_for
)
{
result
.
stage_for
(
:job
)
}
it
do
is_expected
.
to
eq
(
'test'
)
end
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