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
39044dd4
Commit
39044dd4
authored
Mar 31, 2021
by
Jonathan Schafer
Committed by
Igor Drozdov
Mar 31, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GraphQL field for vulnerability scanner ID
Update documentation as well
parent
05ef4806
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
25 additions
and
5 deletions
+25
-5
doc/api/graphql/reference/index.md
doc/api/graphql/reference/index.md
+1
-0
ee/app/assets/javascripts/security_dashboard/graphql/queries/instance_vulnerabilities.query.graphql
...rd/graphql/queries/instance_vulnerabilities.query.graphql
+2
-0
ee/app/finders/security/vulnerabilities_finder.rb
ee/app/finders/security/vulnerabilities_finder.rb
+2
-2
ee/app/graphql/resolvers/vulnerabilities_resolver.rb
ee/app/graphql/resolvers/vulnerabilities_resolver.rb
+4
-0
ee/changelogs/unreleased/293843-expand-filtering-functionality-of-vulnerabilities-graphql-end-1.yml
...tering-functionality-of-vulnerabilities-graphql-end-1.yml
+5
-0
ee/spec/finders/security/vulnerabilities_finder_spec.rb
ee/spec/finders/security/vulnerabilities_finder_spec.rb
+1
-1
ee/spec/graphql/resolvers/vulnerabilities_resolver_spec.rb
ee/spec/graphql/resolvers/vulnerabilities_resolver_spec.rb
+10
-2
No files found.
doc/api/graphql/reference/index.md
View file @
39044dd4
...
...
@@ -375,6 +375,7 @@ Returns [`VulnerabilityConnection`](#vulnerabilityconnection).
|
`projectId`
|
[
`[ID!]`
](
#id
)
| Filter vulnerabilities by project. |
|
`reportType`
|
[
`[VulnerabilityReportType!]`
](
#vulnerabilityreporttype
)
| Filter vulnerabilities by report type. |
|
`scanner`
|
[
`[String!]`
](
#string
)
| Filter vulnerabilities by VulnerabilityScanner.externalId. |
|
`scannerId`
|
[
`[Int!]`
](
#int
)
| Filter vulnerabilities by scanner ID. |
|
`severity`
|
[
`[VulnerabilitySeverity!]`
](
#vulnerabilityseverity
)
| Filter vulnerabilities by severity. |
|
`sort`
|
[
`VulnerabilitySort`
](
#vulnerabilitysort
)
| List vulnerabilities by sort order. |
|
`state`
|
[
`[VulnerabilityState!]`
](
#vulnerabilitystate
)
| Filter vulnerabilities by state. |
...
...
ee/app/assets/javascripts/security_dashboard/graphql/queries/instance_vulnerabilities.query.graphql
View file @
39044dd4
...
...
@@ -8,6 +8,7 @@ query instance(
$severity
:
[
VulnerabilitySeverity
!]
$reportType
:
[
VulnerabilityReportType
!]
$scanner
:
[
String
!]
$scannerId
:
[
Int
!]
$state
:
[
VulnerabilityState
!]
$sort
:
VulnerabilitySort
$hasIssues
:
Boolean
...
...
@@ -21,6 +22,7 @@ query instance(
state
:
$state
projectId
:
$projectId
scanner
:
$scanner
scannerId
:
$scannerId
sort
:
$sort
hasIssues
:
$hasIssues
hasResolution
:
$hasResolution
...
...
ee/app/finders/security/vulnerabilities_finder.rb
View file @
39044dd4
...
...
@@ -67,8 +67,8 @@ module Security
end
def
filter_by_scanner_ids
if
params
[
:scanner_id
s
].
present?
@vulnerabilities
=
vulnerabilities
.
by_scanner_ids
(
params
[
:scanner_id
s
])
if
params
[
:scanner_id
].
present?
@vulnerabilities
=
vulnerabilities
.
by_scanner_ids
(
params
[
:scanner_id
])
end
end
...
...
ee/app/graphql/resolvers/vulnerabilities_resolver.rb
View file @
39044dd4
...
...
@@ -26,6 +26,10 @@ module Resolvers
required:
false
,
description:
'Filter vulnerabilities by VulnerabilityScanner.externalId.'
argument
:scanner_id
,
[
GraphQL
::
INT_TYPE
],
required:
false
,
description:
'Filter vulnerabilities by scanner ID.'
argument
:sort
,
Types
::
VulnerabilitySortEnum
,
required:
false
,
default_value:
'severity_desc'
,
...
...
ee/changelogs/unreleased/293843-expand-filtering-functionality-of-vulnerabilities-graphql-end-1.yml
0 → 100644
View file @
39044dd4
---
title
:
Add GraphQL field for vulnerability scanner ID
merge_request
:
56041
author
:
type
:
changed
ee/spec/finders/security/vulnerabilities_finder_spec.rb
View file @
39044dd4
...
...
@@ -67,7 +67,7 @@ RSpec.describe Security::VulnerabilitiesFinder do
end
context
'when filtered by scanner_id'
do
let
(
:filters
)
{
{
scanner_id
s
:
[
vulnerability1
.
finding_scanner_id
,
vulnerability3
.
finding_scanner_id
]
}
}
let
(
:filters
)
{
{
scanner_id:
[
vulnerability1
.
finding_scanner_id
,
vulnerability3
.
finding_scanner_id
]
}
}
it
'only returns vulnerabilities matching the given scanner IDs'
do
is_expected
.
to
contain_exactly
(
vulnerability1
,
vulnerability3
)
...
...
ee/spec/graphql/resolvers/vulnerabilities_resolver_spec.rb
View file @
39044dd4
...
...
@@ -69,10 +69,18 @@ RSpec.describe Resolvers::VulnerabilitiesResolver do
end
end
context
'when given scanner'
do
context
'when given scanner
external IDs
'
do
let
(
:params
)
{
{
scanner:
[
high_vulnerability
.
finding_scanner_external_id
]
}
}
it
'only returns vulnerabilities of the given scanner'
do
it
'only returns vulnerabilities of the given scanner external IDs'
do
is_expected
.
to
contain_exactly
(
high_vulnerability
)
end
end
context
'when given scanner ID'
do
let
(
:params
)
{
{
scanner_id:
[
high_vulnerability
.
finding_scanner_id
]
}
}
it
'only returns vulnerabilities of the given scanner IDs'
do
is_expected
.
to
contain_exactly
(
high_vulnerability
)
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