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
238356ad
Commit
238356ad
authored
Jul 30, 2020
by
Mehmet Emin INAC
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Utilize Vulnerabilities::Statistic model for stats on GraphQL API
parent
dc6fa046
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
10 deletions
+3
-10
ee/app/graphql/ee/types/project_type.rb
ee/app/graphql/ee/types/project_type.rb
+1
-5
ee/spec/requests/api/graphql/project/vulnerability_severities_count_spec.rb
...pi/graphql/project/vulnerability_severities_count_spec.rb
+2
-5
No files found.
ee/app/graphql/ee/types/project_type.rb
View file @
238356ad
...
...
@@ -26,11 +26,7 @@ module EE
field
:vulnerability_severities_count
,
::
Types
::
VulnerabilitySeveritiesCountType
,
null:
true
,
description:
'Counts for each severity of vulnerability of the project'
,
resolve:
->
(
obj
,
_args
,
ctx
)
do
Hash
.
new
(
0
).
merge
(
obj
.
vulnerabilities
.
with_states
([
:detected
,
:confirmed
]).
counts_by_severity
)
end
resolve:
->
(
obj
,
*
)
{
obj
.
vulnerability_statistic
||
Hash
.
new
(
0
)
}
field
:requirement
,
::
Types
::
RequirementsManagement
::
RequirementType
,
null:
true
,
description:
'Find a single requirement. Available only when feature flag `requirements_management` is enabled.'
,
...
...
ee/spec/requests/api/graphql/project/vulnerability_severities_count_spec.rb
View file @
238356ad
...
...
@@ -5,10 +5,7 @@ require 'spec_helper'
RSpec
.
describe
'Query.project(fullPath).vulnerabilitySeveritiesCount'
do
let_it_be
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:confirmed_vulnerability
)
{
create
(
:vulnerability
,
:confirmed
,
:high
,
project:
project
)
}
let_it_be
(
:detected_vulnerability
)
{
create
(
:vulnerability
,
:detected
,
:high
,
project:
project
)
}
let_it_be
(
:resolved_vulnerability
)
{
create
(
:vulnerability
,
:resolved
,
:high
,
project:
project
)
}
let_it_be
(
:dismissed_vulnerabilities
)
{
create
(
:vulnerability
,
:dismissed
,
:high
,
project:
project
)
}
let_it_be
(
:statistic
)
{
create
(
:vulnerability_statistic
,
:d
,
project:
project
)
}
let_it_be
(
:query
)
do
%(
...
...
@@ -33,6 +30,6 @@ RSpec.describe 'Query.project(fullPath).vulnerabilitySeveritiesCount' do
it
"returns counts for each severity of the project's detected or confirmed vulnerabilities"
do
high_count
=
subject
.
dig
(
'data'
,
'project'
,
'vulnerabilitySeveritiesCount'
,
'high'
)
expect
(
high_count
).
to
be
(
2
)
expect
(
high_count
).
to
be
(
statistic
.
high
)
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