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
40fd6577
Commit
40fd6577
authored
Mar 16, 2018
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add head+base report for sast container and dast
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
de645911
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
27 deletions
+43
-27
ee/app/models/ee/merge_request.rb
ee/app/models/ee/merge_request.rb
+6
-2
ee/app/serializers/ee/merge_request_widget_entity.rb
ee/app/serializers/ee/merge_request_widget_entity.rb
+19
-24
ee/spec/serializers/merge_request_widget_entity_spec.rb
ee/spec/serializers/merge_request_widget_entity_spec.rb
+18
-1
No files found.
ee/app/models/ee/merge_request.rb
View file @
40fd6577
...
...
@@ -16,11 +16,15 @@ module EE
delegate
:performance_artifact
,
to: :base_pipeline
,
prefix: :base
,
allow_nil:
true
delegate
:sast_artifact
,
to: :head_pipeline
,
prefix: :head
,
allow_nil:
true
delegate
:sast_artifact
,
to: :base_pipeline
,
prefix: :base
,
allow_nil:
true
delegate
:sast_container_artifact
,
to: :head_pipeline
,
allow_nil:
true
delegate
:dast_artifact
,
to: :head_pipeline
,
allow_nil:
true
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
: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
delegate
:sha
,
to: :base_pipeline
,
prefix: :base_pipeline
,
allow_nil:
true
delegate
:has_sast_data?
,
to: :base_pipeline
,
prefix: :base
,
allow_nil:
true
delegate
:has_sast_container_data?
,
to: :base_pipeline
,
prefix: :base
,
allow_nil:
true
delegate
:has_dast_data?
,
to: :base_pipeline
,
prefix: :base
,
allow_nil:
true
delegate
:expose_sast_data?
,
to: :head_pipeline
,
allow_nil:
true
delegate
:expose_sast_container_data?
,
to: :head_pipeline
,
allow_nil:
true
delegate
:expose_dast_data?
,
to: :head_pipeline
,
allow_nil:
true
...
...
ee/app/serializers/ee/merge_request_widget_entity.rb
View file @
40fd6577
...
...
@@ -41,33 +41,28 @@ module EE
end
end
expose
:sast
,
if:
->
(
mr
,
_
)
{
mr
.
expose_sast_data?
}
do
expose
:head_path
,
if:
->
(
mr
,
_
)
{
can?
(
current_user
,
:read_build
,
mr
.
head_sast_artifact
)
}
do
|
merge_request
|
raw_project_build_artifacts_url
(
merge_request
.
source_project
,
merge_request
.
head_sast_artifact
,
path:
Ci
::
Build
::
SAST_FILE
)
end
expose_artifact
(
:sast
,
Ci
::
Build
::
SAST_FILE
)
expose_artifact
(
:sast_container
,
Ci
::
Build
::
SAST_CONTAINER_FILE
)
expose_artifact
(
:dast
,
Ci
::
Build
::
DAST_FILE
)
end
expose
:base_path
,
if:
->
(
mr
,
_
)
{
mr
.
base_has_sast_data?
&&
can?
(
current_user
,
:read_build
,
mr
.
base_sast_artifact
)}
do
|
merge_request
|
raw_project_build_artifacts_url
(
merge_request
.
target_project
,
merge_request
.
base_sast_artifact
,
path:
Ci
::
Build
::
SAST_FILE
)
end
end
class_methods
do
def
expose_artifact
(
name
,
file
)
expose
name
,
if:
->
(
mr
,
_
)
{
mr
.
send
(
:"expose_
#{
name
}
_data?"
)
}
do
base_artifact_method
=
:"base_
#{
name
}
_artifact"
head_artifact_method
=
:"head_
#{
name
}
_artifact"
expose
:sast_container
,
if:
->
(
mr
,
_
)
{
mr
.
expose_sast_container_data?
}
do
expose
:path
,
if:
->
(
mr
,
_
)
{
can?
(
current_user
,
:read_build
,
mr
.
sast_container_artifact
)
}
do
|
merge_request
|
raw_project_build_artifacts_url
(
merge_request
.
source_project
,
merge_request
.
sast_container_artifact
,
path:
Ci
::
Build
::
SAST_CONTAINER_FILE
)
end
end
expose
:head_path
,
if:
->
(
mr
,
_
)
{
can?
(
current_user
,
:read_build
,
mr
.
send
(
head_artifact_method
))
}
do
|
merge_request
|
raw_project_build_artifacts_url
(
merge_request
.
source_project
,
merge_request
.
send
(
head_artifact_method
),
path:
file
)
end
expose
:dast
,
if:
->
(
mr
,
_
)
{
mr
.
expose_dast_data?
}
do
expose
:path
,
if:
->
(
mr
,
_
)
{
can?
(
current_user
,
:read_build
,
mr
.
dast_artifact
)
}
do
|
merge_request
|
raw_project_build_artifacts_url
(
merge_request
.
source_project
,
merge_request
.
dast_artifact
,
path:
Ci
::
Build
::
DAST_FILE
)
expose
:base_path
,
if:
->
(
mr
,
_
)
{
mr
.
send
(
:"base_has_
#{
name
}
_data?"
)
&&
can?
(
current_user
,
:read_build
,
mr
.
send
(
base_artifact_method
))
}
do
|
merge_request
|
raw_project_build_artifacts_url
(
merge_request
.
target_project
,
merge_request
.
send
(
base_artifact_method
)
,
path:
file
)
end
end
end
end
...
...
ee/spec/serializers/merge_request_widget_entity_spec.rb
View file @
40fd6577
...
...
@@ -51,8 +51,25 @@ describe MergeRequestWidgetEntity do
build
=
create
(
:ci_build
,
name:
'sast:image'
,
pipeline:
pipeline
)
allow
(
merge_request
).
to
receive
(
:expose_sast_container_data?
).
and_return
(
true
)
allow
(
merge_request
).
to
receive
(
:sast_container_artifact
).
and_return
(
build
)
allow
(
merge_request
).
to
receive
(
:base_has_sast_container_data?
).
and_return
(
true
)
allow
(
merge_request
).
to
receive
(
:base_sast_container_artifact
).
and_return
(
build
)
allow
(
merge_request
).
to
receive
(
:head_sast_container_artifact
).
and_return
(
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
)
allow
(
merge_request
).
to
receive
(
:expose_dast_data?
).
and_return
(
true
)
allow
(
merge_request
).
to
receive
(
:base_has_dast_data?
).
and_return
(
true
)
allow
(
merge_request
).
to
receive
(
:base_dast_artifact
).
and_return
(
build
)
allow
(
merge_request
).
to
receive
(
:head_dast_artifact
).
and_return
(
build
)
expect
(
subject
.
as_json
).
to
include
(
:dast
)
expect
(
subject
.
as_json
[
:dast
]).
to
include
(
:head_path
)
expect
(
subject
.
as_json
[
:dast
]).
to
include
(
:base_path
)
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