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
68d68a00
Commit
68d68a00
authored
Nov 30, 2021
by
Daniel Tian
Committed by
Kerri Miller
Nov 30, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new instance vulnerability report
parent
0d731566
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
88 additions
and
7 deletions
+88
-7
ee/app/assets/javascripts/security_dashboard/components/instance/instance_vulnerability_report.vue
...ard/components/instance/instance_vulnerability_report.vue
+23
-0
ee/app/assets/javascripts/security_dashboard/vulnerability_report_init.js
...vascripts/security_dashboard/vulnerability_report_init.js
+15
-4
ee/app/helpers/security_helper.rb
ee/app/helpers/security_helper.rb
+9
-2
ee/app/models/instance_security_dashboard.rb
ee/app/models/instance_security_dashboard.rb
+4
-0
ee/spec/frontend/security_dashboard/components/instance/instance_vulnerability_report_spec.js
...components/instance/instance_vulnerability_report_spec.js
+35
-0
ee/spec/helpers/security_helper_spec.rb
ee/spec/helpers/security_helper_spec.rb
+2
-1
No files found.
ee/app/assets/javascripts/security_dashboard/components/instance/instance_vulnerability_report.vue
0 → 100644
View file @
68d68a00
<
script
>
import
ReportNotConfiguredInstance
from
'
../shared/empty_states/report_not_configured_instance.vue
'
;
import
VulnerabilityReportTabs
from
'
../shared/vulnerability_report/vulnerability_report_tabs.vue
'
;
import
instanceVulnerabilitiesQuery
from
'
../../graphql/queries/instance_vulnerabilities.query.graphql
'
;
export
default
{
components
:
{
ReportNotConfiguredInstance
,
VulnerabilityReportTabs
,
},
inject
:
[
'
hasProjects
'
],
instanceVulnerabilitiesQuery
,
};
</
script
>
<
template
>
<report-not-configured-instance
v-if=
"!hasProjects"
/>
<vulnerability-report-tabs
v-else
:query=
"$options.instanceVulnerabilitiesQuery"
show-project-filter
/>
</
template
>
ee/app/assets/javascripts/security_dashboard/vulnerability_report_init.js
View file @
68d68a00
...
...
@@ -7,6 +7,18 @@ import apolloProvider from './graphql/provider';
import
createRouter
from
'
./router
'
;
import
createStore
from
'
./store
'
;
import
GroupVulnerabilityReport
from
'
./components/group/group_vulnerability_report.vue
'
;
import
InstanceVulnerabilityReport
from
'
./components/instance/instance_vulnerability_report.vue
'
;
const
getVulnerabilityComponent
=
(
dashboardType
)
=>
{
switch
(
dashboardType
)
{
case
DASHBOARD_TYPES
.
GROUP
:
return
GroupVulnerabilityReport
;
case
DASHBOARD_TYPES
.
INSTANCE
:
return
InstanceVulnerabilityReport
;
default
:
return
VulnerabilityReport
;
}
};
export
default
(
el
,
dashboardType
)
=>
{
if
(
!
el
)
{
...
...
@@ -104,9 +116,8 @@ export default (el, dashboardType) => {
const
router
=
createRouter
();
const
store
=
createStore
({
dashboardType
});
const
component
=
gon
.
features
?.
operationalVulnerabilities
&&
dashboardType
===
DASHBOARD_TYPES
.
GROUP
?
GroupVulnerabilityReport
const
component
=
gon
.
features
?.
operationalVulnerabilities
?
getVulnerabilityComponent
(
dashboardType
)
:
VulnerabilityReport
;
return
new
Vue
({
...
...
ee/app/helpers/security_helper.rb
View file @
68d68a00
...
...
@@ -14,9 +14,10 @@ module SecurityHelper
project_list_endpoint:
security_projects_path
,
instance_dashboard_settings_path:
settings_security_dashboard_path
,
vulnerabilities_export_endpoint:
expose_path
(
api_v4_security_vulnerability_exports_path
),
scanners:
VulnerabilityScanners
::
ListService
.
new
(
InstanceSecurityDashboard
.
new
(
current_user
)
).
execute
.
to_json
,
scanners:
VulnerabilityScanners
::
ListService
.
new
(
instance_security_dashboard
).
execute
.
to_json
,
false_positive_doc_url:
help_page_path
(
'user/application_security/vulnerabilities/index'
),
can_view_false_positive:
can_view_false_positive?
can_view_false_positive:
can_view_false_positive?
,
has_projects:
instance_security_dashboard
.
has_projects?
.
to_s
}
end
...
...
@@ -37,4 +38,10 @@ module SecurityHelper
is_auditor:
current_user
.
auditor?
.
to_s
}
end
private
def
instance_security_dashboard
@_instance_security_dashboard
||=
InstanceSecurityDashboard
.
new
(
current_user
)
end
end
ee/app/models/instance_security_dashboard.rb
View file @
68d68a00
...
...
@@ -41,6 +41,10 @@ class InstanceSecurityDashboard
Vulnerabilities
::
HistoricalStatistic
.
for_project
(
projects
)
end
def
has_projects?
projects
.
count
>
0
end
private
attr_reader
:project_ids
,
:user
...
...
ee/spec/frontend/security_dashboard/components/instance/instance_vulnerability_report_spec.js
0 → 100644
View file @
68d68a00
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
InstanceVulnerabilityReport
from
'
ee/security_dashboard/components/instance/instance_vulnerability_report.vue
'
;
import
VulnerabilityReportTabs
from
'
ee/security_dashboard/components/shared/vulnerability_report/vulnerability_report_tabs.vue
'
;
import
ReportNotConfiguredInstance
from
'
ee/security_dashboard/components/shared/empty_states/report_not_configured_instance.vue
'
;
describe
(
'
Instance vulnerabilities report component
'
,
()
=>
{
let
wrapper
;
const
createWrapper
=
({
hasProjects
=
true
}
=
{})
=>
{
wrapper
=
shallowMount
(
InstanceVulnerabilityReport
,
{
provide
:
{
hasProjects
},
});
};
const
findReportNotConfiguredInstance
=
()
=>
wrapper
.
findComponent
(
ReportNotConfiguredInstance
);
const
findVulnerabilityReportTabs
=
()
=>
wrapper
.
findComponent
(
VulnerabilityReportTabs
);
afterEach
(()
=>
{
wrapper
.
destroy
();
});
it
(
'
shows the report not configured component if there are no projects
'
,
()
=>
{
createWrapper
({
hasProjects
:
false
});
expect
(
findReportNotConfiguredInstance
().
exists
()).
toBe
(
true
);
expect
(
findVulnerabilityReportTabs
().
exists
()).
toBe
(
false
);
});
it
(
'
shows the vulnerability report tabs component if there are projects
'
,
()
=>
{
createWrapper
({
hasProjects
:
true
});
expect
(
findReportNotConfiguredInstance
().
exists
()).
toBe
(
false
);
expect
(
findVulnerabilityReportTabs
().
exists
()).
toBe
(
true
);
});
});
ee/spec/helpers/security_helper_spec.rb
View file @
68d68a00
...
...
@@ -23,7 +23,8 @@ RSpec.describe SecurityHelper do
instance_dashboard_settings_path:
settings_security_dashboard_path
,
vulnerabilities_export_endpoint:
api_v4_security_vulnerability_exports_path
,
scanners:
'[]'
,
can_view_false_positive:
'false'
can_view_false_positive:
'false'
,
has_projects:
'false'
})
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