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
07c68983
Commit
07c68983
authored
Jun 07, 2021
by
Furkan Ayhan
Committed by
Fabio Pitino
Jun 07, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix SAST parser for no-sast pipelines
parent
4c75c7d2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
9 deletions
+40
-9
lib/gitlab/ci/yaml_processor/result.rb
lib/gitlab/ci/yaml_processor/result.rb
+4
-4
spec/lib/gitlab/ci/yaml_processor/result_spec.rb
spec/lib/gitlab/ci/yaml_processor/result_spec.rb
+19
-5
spec/services/security/ci_configuration/sast_parser_service_spec.rb
...ces/security/ci_configuration/sast_parser_service_spec.rb
+17
-0
No files found.
lib/gitlab/ci/yaml_processor/result.rb
View file @
07c68983
...
...
@@ -112,7 +112,9 @@ module Gitlab
end
def
yaml_variables_for
(
job_name
)
job
=
jobs
.
fetch
(
job_name
)
job
=
jobs
[
job_name
]
return
[]
unless
job
Gitlab
::
Ci
::
Variables
::
Helpers
.
inherit_yaml_variables
(
from:
root_variables
,
...
...
@@ -122,9 +124,7 @@ module Gitlab
end
def
stage_for
(
job_name
)
job
=
jobs
.
fetch
(
job_name
)
job
[
:stage
]
jobs
.
dig
(
job_name
,
:stage
)
end
private
...
...
spec/lib/gitlab/ci/yaml_processor/result_spec.rb
View file @
07c68983
...
...
@@ -54,14 +54,22 @@ module Gitlab
YAML
end
subject
(
:yaml_variables_for
)
{
result
.
yaml_variables_for
(
:job
)
}
let
(
:job_name
)
{
:job
}
it
do
subject
(
:yaml_variables_for
)
{
result
.
yaml_variables_for
(
job_name
)
}
it
'returns calculated variables with root and job variables'
do
is_expected
.
to
match_array
([
{
key:
'VAR1'
,
value:
'value 11'
,
public:
true
},
{
key:
'VAR2'
,
value:
'value 2'
,
public:
true
}
])
end
context
'when an absent job is sent'
do
let
(
:job_name
)
{
:invalid_job
}
it
{
is_expected
.
to
eq
([])
}
end
end
describe
'#stage_for'
do
...
...
@@ -72,10 +80,16 @@ module Gitlab
YAML
end
subject
(
:stage_for
)
{
result
.
stage_for
(
:job
)
}
let
(
:job_name
)
{
:job
}
subject
(
:stage_for
)
{
result
.
stage_for
(
job_name
)
}
it
{
is_expected
.
to
eq
(
'test'
)
}
context
'when an absent job is sent'
do
let
(
:job_name
)
{
:invalid_job
}
it
do
is_expected
.
to
eq
(
'test'
)
it
{
is_expected
.
to
be_nil
}
end
end
end
...
...
spec/services/security/ci_configuration/sast_parser_service_spec.rb
View file @
07c68983
...
...
@@ -67,6 +67,23 @@ RSpec.describe Security::CiConfiguration::SastParserService do
expect
(
sast_brakeman_level
[
'value'
]).
to
eql
(
'1'
)
end
end
context
'when .gitlab-ci.yml does not include the sast job'
do
before
do
allow
(
project
.
repository
).
to
receive
(
:blob_data_at
).
and_return
(
File
.
read
(
Rails
.
root
.
join
(
'spec/support/gitlab_stubs/gitlab_ci.yml'
))
)
end
it
'populates the current values with the default values'
do
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_pipeline_stage
[
'value'
]).
to
eql
(
'test'
)
expect
(
sast_search_max_depth
[
'value'
]).
to
eql
(
'4'
)
expect
(
brakeman
[
'enabled'
]).
to
be
(
true
)
expect
(
sast_brakeman_level
[
'value'
]).
to
eql
(
'1'
)
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