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
61293c61
Commit
61293c61
authored
Jul 14, 2021
by
Marius Bobin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable writes to CI builds metadata table by default
Changelog: changed
parent
9af258ae
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
23 additions
and
177 deletions
+23
-177
app/finders/security/jobs_finder.rb
app/finders/security/jobs_finder.rb
+1
-18
app/models/concerns/ci/metadatable.rb
app/models/concerns/ci/metadatable.rb
+2
-8
config/feature_flags/development/ci_build_metadata_config.yml
...ig/feature_flags/development/ci_build_metadata_config.yml
+0
-8
ee/spec/presenters/projects/security/configuration_presenter_spec.rb
...senters/projects/security/configuration_presenter_spec.rb
+0
-19
spec/lib/gitlab/ci/build/auto_retry_spec.rb
spec/lib/gitlab/ci/build/auto_retry_spec.rb
+2
-18
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+17
-91
spec/support/shared_examples/finders/security/jobs_finder_shared_examples.rb
..._examples/finders/security/jobs_finder_shared_examples.rb
+1
-15
No files found.
app/finders/security/jobs_finder.rb
View file @
61293c61
...
...
@@ -38,11 +38,7 @@ module Security
def
execute
return
[]
if
@job_types
.
empty?
if
Feature
.
enabled?
(
:ci_build_metadata_config
,
pipeline
.
project
,
default_enabled: :yaml
)
find_jobs
else
find_jobs_legacy
end
find_jobs
end
private
...
...
@@ -51,19 +47,6 @@ module Security
@pipeline
.
builds
.
with_secure_reports_from_config_options
(
@job_types
)
end
def
find_jobs_legacy
# the query doesn't guarantee accuracy, so we verify it here
legacy_jobs_query
.
select
do
|
job
|
@job_types
.
find
{
|
job_type
|
job
.
options
.
dig
(
:artifacts
,
:reports
,
job_type
)
}
end
end
def
legacy_jobs_query
@job_types
.
map
do
|
job_type
|
@pipeline
.
builds
.
with_secure_reports_from_options
(
job_type
)
end
.
reduce
(
&
:or
)
end
def
valid_job_types?
(
job_types
)
(
job_types
-
self
.
class
.
allowed_job_types
).
empty?
end
...
...
app/models/concerns/ci/metadatable.rb
View file @
61293c61
...
...
@@ -76,14 +76,8 @@ module Ci
end
def
write_metadata_attribute
(
legacy_key
,
metadata_key
,
value
)
# save to metadata or this model depending on the state of feature flag
if
Feature
.
enabled?
(
:ci_build_metadata_config
,
project
,
default_enabled: :yaml
)
ensure_metadata
.
write_attribute
(
metadata_key
,
value
)
write_attribute
(
legacy_key
,
nil
)
else
write_attribute
(
legacy_key
,
value
)
metadata
&
.
write_attribute
(
metadata_key
,
nil
)
end
ensure_metadata
.
write_attribute
(
metadata_key
,
value
)
write_attribute
(
legacy_key
,
nil
)
end
end
end
...
...
config/feature_flags/development/ci_build_metadata_config.yml
deleted
100644 → 0
View file @
9af258ae
---
name
:
ci_build_metadata_config
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/7238
rollout_issue_url
:
https://gitlab.com/gitlab-org/gitlab/-/issues/330954
milestone
:
'
11.7'
type
:
development
group
:
group::pipeline execution
default_enabled
:
false
ee/spec/presenters/projects/security/configuration_presenter_spec.rb
View file @
61293c61
...
...
@@ -151,25 +151,6 @@ RSpec.describe Projects::Security::ConfigurationPresenter do
)
end
it
'works with both legacy and current job formats'
do
stub_feature_flags
(
ci_build_metadata_config:
false
)
create
(
:ci_build
,
:sast
,
pipeline:
pipeline
)
expect
(
Gitlab
::
Json
.
parse
(
subject
[
:features
])).
to
contain_exactly
(
security_scan
(
:dast
,
configured:
false
),
security_scan
(
:dast_profiles
,
configured:
true
),
security_scan
(
:sast
,
configured:
true
),
security_scan
(
:container_scanning
,
configured:
false
),
security_scan
(
:cluster_image_scanning
,
configured:
false
),
security_scan
(
:dependency_scanning
,
configured:
false
),
security_scan
(
:license_scanning
,
configured:
false
),
security_scan
(
:secret_detection
,
configured:
false
),
security_scan
(
:coverage_fuzzing
,
configured:
false
),
security_scan
(
:api_fuzzing
,
configured:
false
)
)
end
it
'detects security jobs even when the job has more than one report'
do
config
=
{
artifacts:
{
reports:
{
other_job:
[
'gl-other-report.json'
],
sast:
[
'gl-sast-report.json'
]
}
}
}
complicated_job
=
build_stubbed
(
:ci_build
,
options:
config
)
...
...
spec/lib/gitlab/ci/build/auto_retry_spec.rb
View file @
61293c61
...
...
@@ -53,24 +53,8 @@ RSpec.describe Gitlab::Ci::Build::AutoRetry do
context
'with retries max config option'
do
let
(
:build
)
{
create
(
:ci_build
,
options:
{
retry:
{
max:
1
}
})
}
context
'when build_metadata_config is set'
do
before
do
stub_feature_flags
(
ci_build_metadata_config:
true
)
end
it
'returns the number of configured max retries'
do
expect
(
result
).
to
eq
1
end
end
context
'when build_metadata_config is not set'
do
before
do
stub_feature_flags
(
ci_build_metadata_config:
false
)
end
it
'returns the number of configured max retries'
do
expect
(
result
).
to
eq
1
end
it
'returns the number of configured max retries'
do
expect
(
result
).
to
eq
1
end
end
...
...
spec/models/ci/build_spec.rb
View file @
61293c61
...
...
@@ -2214,34 +2214,12 @@ RSpec.describe Ci::Build do
expect
(
build
.
options
[
'image'
]).
to
be_nil
end
context
'when ci_build_metadata_config is set'
do
before
do
stub_feature_flags
(
ci_build_metadata_config:
true
)
end
it
'persist data in build metadata'
do
expect
(
build
.
metadata
.
read_attribute
(
:config_options
)).
to
eq
(
options
.
symbolize_keys
)
end
it
'does not persist data in build'
do
expect
(
build
.
read_attribute
(
:options
)).
to
be_nil
end
it
'persist data in build metadata'
do
expect
(
build
.
metadata
.
read_attribute
(
:config_options
)).
to
eq
(
options
.
symbolize_keys
)
end
context
'when ci_build_metadata_config is disabled'
do
let
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
before
do
stub_feature_flags
(
ci_build_metadata_config:
false
)
end
it
'persist data in build'
do
expect
(
build
.
read_attribute
(
:options
)).
to
eq
(
options
.
symbolize_keys
)
end
it
'does not persist data in build metadata'
do
expect
(
build
.
metadata
.
read_attribute
(
:config_options
)).
to
be_nil
end
it
'does not persist data in build'
do
expect
(
build
.
read_attribute
(
:options
)).
to
be_nil
end
context
'when options include artifacts:expose_as'
do
...
...
@@ -3613,36 +3591,14 @@ RSpec.describe Ci::Build do
end
end
context
'when ci_build_metadata_config is set'
do
before
do
stub_feature_flags
(
ci_build_metadata_config:
true
)
end
it_behaves_like
'having consistent representation'
it_behaves_like
'having consistent representation'
it
'persist data in build metadata'
do
expect
(
build
.
metadata
.
read_attribute
(
:config_variables
)).
not_to
be_nil
end
it
'does not persist data in build'
do
expect
(
build
.
read_attribute
(
:yaml_variables
)).
to
be_nil
end
it
'persist data in build metadata'
do
expect
(
build
.
metadata
.
read_attribute
(
:config_variables
)).
not_to
be_nil
end
context
'when ci_build_metadata_config is disabled'
do
before
do
stub_feature_flags
(
ci_build_metadata_config:
false
)
end
it_behaves_like
'having consistent representation'
it
'persist data in build'
do
expect
(
build
.
read_attribute
(
:yaml_variables
)).
not_to
be_nil
end
it
'does not persist data in build metadata'
do
expect
(
build
.
metadata
.
read_attribute
(
:config_variables
)).
to
be_nil
end
it
'does not persist data in build'
do
expect
(
build
.
read_attribute
(
:yaml_variables
)).
to
be_nil
end
end
...
...
@@ -4788,51 +4744,21 @@ RSpec.describe Ci::Build do
subject
{
build
.
send
(
:write_metadata_attribute
,
:options
,
:config_options
,
options
)
}
context
'when
ci_build_metadata_config is
set'
do
context
'when
data in build is already
set'
do
before
do
stub_feature_flags
(
ci_build_metadata_config:
true
)
build
.
write_attribute
(
:options
,
existing_options
)
end
context
'when data in build is already set'
do
before
do
build
.
write_attribute
(
:options
,
existing_options
)
end
it
'does set metadata options'
do
subject
expect
(
build
.
metadata
.
read_attribute
(
:config_options
)).
to
eq
(
options
)
end
it
'does reset build options'
do
subject
expect
(
build
.
read_attribute
(
:options
)).
to
be_nil
end
end
end
it
'does set metadata options'
do
subject
context
'when ci_build_metadata_config is disabled'
do
before
do
stub_feature_flags
(
ci_build_metadata_config:
false
)
expect
(
build
.
metadata
.
read_attribute
(
:config_options
)).
to
eq
(
options
)
end
context
'when data in build metadata is already set'
do
before
do
build
.
ensure_metadata
.
write_attribute
(
:config_options
,
existing_options
)
end
it
'does set metadata options'
do
subject
expect
(
build
.
read_attribute
(
:options
)).
to
eq
(
options
)
end
it
'does reset build options'
do
subject
it
'does reset build options'
do
subject
expect
(
build
.
metadata
.
read_attribute
(
:config_options
)).
to
be_nil
end
expect
(
build
.
read_attribute
(
:options
)).
to
be_nil
end
end
end
...
...
spec/support/shared_examples/finders/security/jobs_finder_shared_examples.rb
View file @
61293c61
...
...
@@ -68,20 +68,6 @@ RSpec.shared_examples ::Security::JobsFinder do |default_job_types|
end
end
context
'when using legacy CI build metadata config storage'
do
before
do
stub_feature_flags
(
ci_build_metadata_config:
false
)
end
it_behaves_like
'JobsFinder core functionality'
end
context
'when using the new CI build metadata config storage'
do
before
do
stub_feature_flags
(
ci_build_metadata_config:
true
)
end
it_behaves_like
'JobsFinder core functionality'
end
it_behaves_like
'JobsFinder core functionality'
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