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
db8844dc
Commit
db8844dc
authored
May 18, 2018
by
Olivier Gonzalez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support both new and old artifact name for container scanning
parent
2c88cd3d
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
68 additions
and
4 deletions
+68
-4
ee/app/models/ee/ci/build.rb
ee/app/models/ee/ci/build.rb
+8
-1
ee/app/models/ee/ci/pipeline.rb
ee/app/models/ee/ci/pipeline.rb
+16
-0
ee/app/models/ee/merge_request.rb
ee/app/models/ee/merge_request.rb
+5
-0
ee/app/serializers/ee/merge_request_widget_entity.rb
ee/app/serializers/ee/merge_request_widget_entity.rb
+16
-0
ee/spec/models/ci/build_spec.rb
ee/spec/models/ci/build_spec.rb
+2
-0
ee/spec/models/ci/pipeline_spec.rb
ee/spec/models/ci/pipeline_spec.rb
+2
-0
ee/spec/models/merge_request_spec.rb
ee/spec/models/merge_request_spec.rb
+1
-1
ee/spec/serializers/merge_request_widget_entity_spec.rb
ee/spec/serializers/merge_request_widget_entity_spec.rb
+18
-2
No files found.
ee/app/models/ee/ci/build.rb
View file @
db8844dc
...
...
@@ -12,7 +12,9 @@ module EE
LICENSE_MANAGEMENT_FILE
=
'gl-license-report.json'
.
freeze
SAST_FILE
=
'gl-sast-report.json'
.
freeze
PERFORMANCE_FILE
=
'performance.json'
.
freeze
SAST_CONTAINER_FILE
=
'gl-container-scanning-report.json'
.
freeze
# SAST_CONTAINER_FILE is deprecated and replaced with CONTAINER_SCANNING_FILE (#5778)
SAST_CONTAINER_FILE
=
'gl-sast-container-report.json'
.
freeze
CONTAINER_SCANNING_FILE
=
'gl-container-scanning-report.json'
.
freeze
DAST_FILE
=
'gl-dast-report.json'
.
freeze
included
do
...
...
@@ -64,10 +66,15 @@ module EE
has_artifact?
(
LICENSE_MANAGEMENT_FILE
)
end
# has_sast_container_json? is deprecated and replaced with has_container_scanning_json? (#5778)
def
has_sast_container_json?
has_artifact?
(
SAST_CONTAINER_FILE
)
end
def
has_container_scanning_json?
has_artifact?
(
CONTAINER_SCANNING_FILE
)
end
def
has_dast_json?
has_artifact?
(
DAST_FILE
)
end
...
...
ee/app/models/ee/ci/pipeline.rb
View file @
db8844dc
...
...
@@ -32,10 +32,15 @@ module EE
@license_management_artifact
||=
artifacts
.
license_management
.
find
(
&
:has_license_management_json?
)
end
# sast_container_artifact is deprecated and replaced with container_scanning_artifact (#5778)
def
sast_container_artifact
@sast_container_artifact
||=
artifacts
.
sast_container
.
find
(
&
:has_sast_container_json?
)
end
def
container_scanning_artifact
@container_scanning_artifact
||=
artifacts
.
sast_container
.
find
(
&
:has_container_scanning_json?
)
end
def
dast_artifact
@dast_artifact
||=
artifacts
.
dast
.
find
(
&
:has_dast_json?
)
end
...
...
@@ -56,10 +61,15 @@ module EE
license_management_artifact
&
.
success?
end
# has_sast_container_data? is deprecated and replaced with has_container_scanning_data? (#5778)
def
has_sast_container_data?
sast_container_artifact
&
.
success?
end
def
has_container_scanning_data?
container_scanning_artifact
&
.
success?
end
def
has_dast_data?
dast_artifact
&
.
success?
end
...
...
@@ -87,11 +97,17 @@ module EE
has_license_management_data?
end
# expose_sast_container_data? is deprecated and replaced with expose_container_scanning_data? (#5778)
def
expose_sast_container_data?
project
.
feature_available?
(
:sast_container
)
&&
has_sast_container_data?
end
def
expose_container_scanning_data?
project
.
feature_available?
(
:sast_container
)
&&
has_container_scanning_data?
end
def
expose_dast_data?
project
.
feature_available?
(
:dast
)
&&
has_dast_data?
...
...
ee/app/models/ee/merge_request.rb
View file @
db8844dc
...
...
@@ -20,8 +20,11 @@ module EE
delegate
:dependency_scanning_artifact
,
to: :base_pipeline
,
prefix: :base
,
allow_nil:
true
delegate
:license_management_artifact
,
to: :head_pipeline
,
prefix: :head
,
allow_nil:
true
delegate
:license_management_artifact
,
to: :base_pipeline
,
prefix: :base
,
allow_nil:
true
# sast_container_artifact is deprecated and replaced with container_scanning_artifact (#5778)
delegate
:sast_container_artifact
,
to: :head_pipeline
,
prefix: :head
,
allow_nil:
true
delegate
:sast_container_artifact
,
to: :base_pipeline
,
prefix: :base
,
allow_nil:
true
delegate
:container_scanning_artifact
,
to: :head_pipeline
,
prefix: :head
,
allow_nil:
true
delegate
:container_scanning_artifact
,
to: :base_pipeline
,
prefix: :base
,
allow_nil:
true
delegate
:dast_artifact
,
to: :head_pipeline
,
prefix: :head
,
allow_nil:
true
delegate
:dast_artifact
,
to: :base_pipeline
,
prefix: :base
,
allow_nil:
true
delegate
:sha
,
to: :head_pipeline
,
prefix: :head_pipeline
,
allow_nil:
true
...
...
@@ -34,7 +37,9 @@ module EE
delegate
:expose_sast_data?
,
to: :head_pipeline
,
allow_nil:
true
delegate
:expose_dependency_scanning_data?
,
to: :head_pipeline
,
allow_nil:
true
delegate
:expose_license_management_data?
,
to: :head_pipeline
,
allow_nil:
true
# expose_sast_container_data? is deprecated and replaced with expose_container_scanning_data? (#5778)
delegate
:expose_sast_container_data?
,
to: :head_pipeline
,
allow_nil:
true
delegate
:expose_container_scanning_data?
,
to: :head_pipeline
,
allow_nil:
true
delegate
:expose_dast_data?
,
to: :head_pipeline
,
allow_nil:
true
end
...
...
ee/app/serializers/ee/merge_request_widget_entity.rb
View file @
db8844dc
...
...
@@ -83,6 +83,7 @@ module EE
end
end
# expose_sast_container_data? is deprecated and replaced with expose_container_scanning_data? (#5778)
expose
:sast_container
,
if:
->
(
mr
,
_
)
{
mr
.
expose_sast_container_data?
}
do
expose
:head_path
,
if:
->
(
mr
,
_
)
{
can?
(
current_user
,
:read_build
,
mr
.
head_sast_container_artifact
)
}
do
|
merge_request
|
raw_project_build_artifacts_url
(
merge_request
.
source_project
,
...
...
@@ -97,6 +98,21 @@ module EE
end
end
# We still expose it as `sast_container` to keep compatibility with Frontend (#5778)
expose
:sast_container
,
if:
->
(
mr
,
_
)
{
mr
.
expose_container_scanning_data?
}
do
expose
:head_path
,
if:
->
(
mr
,
_
)
{
can?
(
current_user
,
:read_build
,
mr
.
head_container_scanning_artifact
)
}
do
|
merge_request
|
raw_project_build_artifacts_url
(
merge_request
.
source_project
,
merge_request
.
head_container_scanning_artifact
,
path:
Ci
::
Build
::
CONTAINER_SCANNING_FILE
)
end
expose
:base_path
,
if:
->
(
mr
,
_
)
{
mr
.
base_has_container_scanning_data?
&&
can?
(
current_user
,
:read_build
,
mr
.
base_container_scanning_artifact
)
}
do
|
merge_request
|
raw_project_build_artifacts_url
(
merge_request
.
target_project
,
merge_request
.
base_container_scanning_artifact
,
path:
Ci
::
Build
::
CONTAINER_SCANNING_FILE
)
end
end
expose
:dast
,
if:
->
(
mr
,
_
)
{
mr
.
expose_dast_data?
}
do
expose
:head_path
,
if:
->
(
mr
,
_
)
{
can?
(
current_user
,
:read_build
,
mr
.
head_dast_artifact
)
}
do
|
merge_request
|
raw_project_build_artifacts_url
(
merge_request
.
source_project
,
...
...
ee/spec/models/ci/build_spec.rb
View file @
db8844dc
...
...
@@ -143,7 +143,9 @@ describe Ci::Build do
has_sast_json?:
Ci
::
Build
::
SAST_FILE
,
has_dependency_scanning_json?:
Ci
::
Build
::
DEPENDENCY_SCANNING_FILE
,
has_license_management_json?:
Ci
::
Build
::
LICENSE_MANAGEMENT_FILE
,
# has_sast_container_json? is deprecated and replaced with has_container_scanning_json (#5778)
has_sast_container_json?:
Ci
::
Build
::
SAST_CONTAINER_FILE
,
has_container_scanning_json?:
Ci
::
Build
::
CONTAINER_SCANNING_FILE
,
has_dast_json?:
Ci
::
Build
::
DAST_FILE
}.
freeze
...
...
ee/spec/models/ci/pipeline_spec.rb
View file @
db8844dc
...
...
@@ -23,7 +23,9 @@ describe Ci::Pipeline do
sast_artifact:
[
Ci
::
Build
::
SAST_FILE
,
'sast'
],
dependency_scanning_artifact:
[
Ci
::
Build
::
DEPENDENCY_SCANNING_FILE
,
'dependency_scanning'
],
license_management_artifact:
[
Ci
::
Build
::
LICENSE_MANAGEMENT_FILE
,
'license_management'
],
# sast_container_artifact is deprecated and replaced with container_scanning_artifact (#5778)
sast_container_artifact:
[
Ci
::
Build
::
SAST_CONTAINER_FILE
,
'container_scanning'
],
container_scanning_artifact:
[
Ci
::
Build
::
CONTAINER_SCANNING_FILE
,
'container_scanning'
],
dast_artifact:
[
Ci
::
Build
::
DAST_FILE
,
'dast'
]
}.
freeze
...
...
ee/spec/models/merge_request_spec.rb
View file @
db8844dc
...
...
@@ -164,7 +164,7 @@ describe MergeRequest do
end
end
%w(sast dast sast_container)
.
each
do
|
type
|
%w(sast dast sast_container
container_scanning
)
.
each
do
|
type
|
it
{
is_expected
.
to
delegate_method
(
:"expose_
#{
type
}
_data?"
).
to
(
:head_pipeline
)
}
it
{
is_expected
.
to
delegate_method
(
:"has_
#{
type
}
_data?"
).
to
(
:base_pipeline
).
with_prefix
(
:base
)
}
it
{
is_expected
.
to
delegate_method
(
:"
#{
type
}
_artifact"
).
to
(
:head_pipeline
).
with_prefix
(
:head
)
}
...
...
ee/spec/serializers/merge_request_widget_entity_spec.rb
View file @
db8844dc
...
...
@@ -83,8 +83,9 @@ describe MergeRequestWidgetEntity do
expect
(
subject
.
as_json
[
:license_management
]).
to
include
(
:base_path
)
end
it
'has sast_container data'
do
build
=
create
(
:ci_build
,
name:
'sast:image'
,
pipeline:
pipeline
)
# methods for old artifact are deprecated and replaced with ones for the new name (#5779)
it
'has sast_container data (with old artifact name gl-sast-container-report.json)'
do
build
=
create
(
:ci_build
,
name:
'container_scanning'
,
pipeline:
pipeline
)
allow
(
merge_request
).
to
receive_messages
(
expose_sast_container_data?:
true
,
...
...
@@ -98,6 +99,21 @@ describe MergeRequestWidgetEntity do
expect
(
subject
.
as_json
[
:sast_container
]).
to
include
(
:base_path
)
end
it
'has sast_container data (with new artifact name gl-container-scanning-report.json)'
do
build
=
create
(
:ci_build
,
name:
'container_scanning'
,
pipeline:
pipeline
)
allow
(
merge_request
).
to
receive_messages
(
expose_container_scanning_data?:
true
,
base_has_container_scanning_data?:
true
,
base_container_scanning_artifact:
build
,
head_container_scanning_artifact:
build
)
expect
(
subject
.
as_json
).
to
include
(
:sast_container
)
expect
(
subject
.
as_json
[
:sast_container
]).
to
include
(
:head_path
)
expect
(
subject
.
as_json
[
:sast_container
]).
to
include
(
:base_path
)
end
it
'has dast data'
do
build
=
create
(
:ci_build
,
name:
'dast'
,
pipeline:
pipeline
)
...
...
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