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
aca3c900
Commit
aca3c900
authored
Oct 29, 2018
by
Olivier Gonzalez
Committed by
Grzegorz Bizon
Oct 29, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Project Security Dasbhoard
parent
c5f8a7df
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
50 additions
and
33 deletions
+50
-33
ee/app/controllers/projects/security/dashboard_controller.rb
ee/app/controllers/projects/security/dashboard_controller.rb
+2
-1
ee/app/models/ee/ci/pipeline.rb
ee/app/models/ee/ci/pipeline.rb
+1
-1
ee/app/models/ee/project.rb
ee/app/models/ee/project.rb
+2
-2
ee/spec/controllers/projects/security/dashboard_controller_spec.rb
...ontrollers/projects/security/dashboard_controller_spec.rb
+41
-25
ee/spec/models/ci/pipeline_spec.rb
ee/spec/models/ci/pipeline_spec.rb
+2
-2
ee/spec/models/project_spec.rb
ee/spec/models/project_spec.rb
+2
-2
No files found.
ee/app/controllers/projects/security/dashboard_controller.rb
View file @
aca3c900
...
...
@@ -5,7 +5,8 @@ module Projects
before_action
:authorize_read_project_security_dashboard!
def
show
@pipeline
=
@project
.
latest_pipeline_with_security_reports
@pipeline
=
@project
.
latest_pipeline_with_legacy_security_reports
&
.
present
(
current_user:
current_user
)
end
private
...
...
ee/app/models/ee/ci/pipeline.rb
View file @
aca3c900
...
...
@@ -16,7 +16,7 @@ module EE
has_many
:vulnerabilities
,
source: :occurrence
,
through: :vulnerabilities_occurrence_pipelines
,
class_name:
'Vulnerabilities::Occurrence'
# Legacy way to fetch security reports based on job name. This has been replaced by the reports feature.
scope
:with_security_reports
,
->
{
scope
:with_
legacy_
security_reports
,
->
{
joins
(
:artifacts
).
where
(
ci_builds:
{
name:
%w[sast dependency_scanning sast:container container_scanning dast]
})
}
...
...
ee/app/models/ee/project.rb
View file @
aca3c900
...
...
@@ -108,8 +108,8 @@ module EE
end
end
def
latest_pipeline_with_security_reports
pipelines
.
newest_first
(
default_branch
).
with_security_reports
.
first
def
latest_pipeline_with_
legacy_
security_reports
pipelines
.
newest_first
(
default_branch
).
with_
legacy_
security_reports
.
first
end
def
environments_for_scope
(
scope
)
...
...
ee/spec/controllers/projects/security/dashboard_controller_spec.rb
View file @
aca3c900
require
'spec_helper'
describe
Projects
::
Security
::
DashboardController
do
l
et
(
:group
)
{
create
(
:group
)
}
let
(
:project
)
{
create
(
:project
,
:public
,
namespace:
group
)
}
l
et
(
:user
)
{
create
(
:user
)
}
s
et
(
:group
)
{
create
(
:group
)
}
set
(
:project
)
{
create
(
:project
,
:repository
,
:public
,
namespace:
group
)
}
s
et
(
:user
)
{
create
(
:user
)
}
before
do
group
.
add_developer
(
user
)
end
describe
'GET #show'
do
let
(
:pipeline_1
)
{
create
(
:ci_pipeline_without_jobs
,
project:
project
)
}
let
(
:pipeline_2
)
{
create
(
:ci_pipeline_without_jobs
,
project:
project
)
}
let
(
:pipeline_3
)
{
create
(
:ci_pipeline_without_jobs
,
project:
project
)
}
before
do
create
(
:ci_build
,
:success
,
:artifacts
,
name:
'sast'
,
pipeline:
pipeline_1
,
options:
{
artifacts:
{
paths:
[
Ci
::
JobArtifact
::
DEFAULT_FILE_NAMES
[
:sast
]]
}
}
)
end
let
(
:pipeline
)
{
create
(
:ci_pipeline_without_jobs
,
sha:
project
.
commit
.
id
,
project:
project
,
user:
user
)
}
render_views
def
show_security_dashboard
(
current_user
=
user
)
sign_in
(
current_user
)
...
...
@@ -39,11 +24,42 @@ describe Projects::Security::DashboardController do
stub_licensed_features
(
security_dashboard:
true
)
end
it
'returns the latest pipeline with security reports for project'
do
show_security_dashboard
context
'when uses legacy reports syntax'
do
before
do
create
(
:ci_build
,
:artifacts
,
pipeline:
pipeline
,
name:
'sast'
)
end
it
'returns the latest pipeline with security reports for project'
do
show_security_dashboard
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
render_template
(
:show
)
expect
(
response
.
body
).
to
have_css
(
"div#js-security-report-app[data-has-pipeline-data=true]"
)
end
end
context
'when uses new reports syntax'
do
before
do
create
(
:ee_ci_build
,
:security_reports
,
pipeline:
pipeline
)
end
it
'renders empty state (not yet supported)'
do
show_security_dashboard
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
render_template
(
:show
)
expect
(
response
.
body
).
to
have_css
(
"div#js-security-report-app[data-has-pipeline-data=false]"
)
end
end
context
'when there is no matching pipeline'
do
it
'renders empty state'
do
show_security_dashboard
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
render_template
(
:show
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
render_template
(
:show
)
expect
(
response
.
body
).
to
have_css
(
"div#js-security-report-app[data-has-pipeline-data=false]"
)
end
end
end
...
...
ee/spec/models/ci/pipeline_spec.rb
View file @
aca3c900
...
...
@@ -85,7 +85,7 @@ describe Ci::Pipeline do
end
end
describe
'#with_security_reports scope'
do
describe
'#with_
legacy_
security_reports scope'
do
let
(
:pipeline_1
)
{
create
(
:ci_pipeline_without_jobs
,
project:
project
)
}
let
(
:pipeline_2
)
{
create
(
:ci_pipeline_without_jobs
,
project:
project
)
}
let
(
:pipeline_3
)
{
create
(
:ci_pipeline_without_jobs
,
project:
project
)
}
...
...
@@ -151,7 +151,7 @@ describe Ci::Pipeline do
end
it
"returns pipeline with security reports"
do
expect
(
described_class
.
with_security_reports
).
to
eq
([
pipeline_1
,
pipeline_2
,
pipeline_3
,
pipeline_4
])
expect
(
described_class
.
with_
legacy_
security_reports
).
to
eq
([
pipeline_1
,
pipeline_2
,
pipeline_3
,
pipeline_4
])
end
end
...
...
ee/spec/models/project_spec.rb
View file @
aca3c900
...
...
@@ -1496,7 +1496,7 @@ describe Project do
end
end
describe
'#latest_pipeline_with_security_reports'
do
describe
'#latest_pipeline_with_
legacy_
security_reports'
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:pipeline_1
)
{
create
(
:ci_pipeline_without_jobs
,
project:
project
)
}
let
(
:pipeline_2
)
{
create
(
:ci_pipeline_without_jobs
,
project:
project
)
}
...
...
@@ -1530,7 +1530,7 @@ describe Project do
end
it
"returns the latest pipeline with security reports"
do
expect
(
project
.
latest_pipeline_with_security_reports
).
to
eq
(
pipeline_2
)
expect
(
project
.
latest_pipeline_with_
legacy_
security_reports
).
to
eq
(
pipeline_2
)
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