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
9ea6756c
Commit
9ea6756c
authored
Sep 24, 2020
by
Alan (Maciej) Paruszewski
Committed by
Dylan Griffith
Sep 24, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ability to sort vulnerabilities by title
This change adds ability to sort vulnerabilities by title in GraphQL.
parent
d4dee59e
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
58 additions
and
1 deletion
+58
-1
doc/api/graphql/reference/gitlab_schema.graphql
doc/api/graphql/reference/gitlab_schema.graphql
+10
-0
doc/api/graphql/reference/gitlab_schema.json
doc/api/graphql/reference/gitlab_schema.json
+12
-0
doc/api/graphql/reference/index.md
doc/api/graphql/reference/index.md
+2
-0
ee/app/graphql/types/vulnerability_sort_enum.rb
ee/app/graphql/types/vulnerability_sort_enum.rb
+2
-0
ee/app/models/ee/vulnerability.rb
ee/app/models/ee/vulnerability.rb
+4
-0
ee/changelogs/unreleased/249245-add-sorting-vulnerabilities-by-title.yml
...nreleased/249245-add-sorting-vulnerabilities-by-title.yml
+5
-0
ee/spec/graphql/types/vulnerability_sort_enum_spec.rb
ee/spec/graphql/types/vulnerability_sort_enum_spec.rb
+1
-1
ee/spec/models/ee/vulnerability_spec.rb
ee/spec/models/ee/vulnerability_spec.rb
+22
-0
No files found.
doc/api/graphql/reference/gitlab_schema.graphql
View file @
9ea6756c
...
...
@@ -19478,6 +19478,16 @@ enum VulnerabilitySort {
Severity
in
descending
order
"""
severity_desc
"""
Title
in
ascending
order
"""
title_asc
"""
Title
in
descending
order
"""
title_desc
}
"""
...
...
doc/api/graphql/reference/gitlab_schema.json
View file @
9ea6756c
...
...
@@ -56960,6 +56960,18 @@
"description": "Severity in ascending order",
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "title_desc",
"description": "Title in descending order",
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "title_asc",
"description": "Title in ascending order",
"isDeprecated": false,
"deprecationReason": null
}
],
"possibleTypes": null
doc/api/graphql/reference/index.md
View file @
9ea6756c
...
...
@@ -3592,6 +3592,8 @@ Vulnerability sort values.
| ----- | ----------- |
|
`severity_asc`
| Severity in ascending order |
|
`severity_desc`
| Severity in descending order |
|
`title_asc`
| Title in ascending order |
|
`title_desc`
| Title in descending order |
### VulnerabilityState
...
...
ee/app/graphql/types/vulnerability_sort_enum.rb
View file @
9ea6756c
...
...
@@ -7,5 +7,7 @@ module Types
value
'severity_desc'
,
'Severity in descending order'
value
'severity_asc'
,
'Severity in ascending order'
value
'title_desc'
,
'Title in descending order'
value
'title_asc'
,
'Title in ascending order'
end
end
ee/app/models/ee/vulnerability.rb
View file @
9ea6756c
...
...
@@ -88,6 +88,8 @@ module EE
scope
:order_severity_asc
,
->
{
reorder
(
severity: :asc
,
id: :desc
)
}
scope
:order_severity_desc
,
->
{
reorder
(
severity: :desc
,
id: :desc
)
}
scope
:order_title_asc
,
->
{
reorder
(
title: :asc
,
id: :desc
)
}
scope
:order_title_desc
,
->
{
reorder
(
title: :desc
,
id: :desc
)
}
delegate
:scanner_name
,
:scanner_external_id
,
:metadata
,
:message
,
:cve
,
:description
,
to: :finding
,
prefix:
true
,
allow_nil:
true
...
...
@@ -190,6 +192,8 @@ module EE
case
method
.
to_s
when
'severity_desc'
then
order_severity_desc
when
'severity_asc'
then
order_severity_asc
when
'title_desc'
then
order_title_desc
when
'title_asc'
then
order_title_asc
else
order_severity_desc
end
...
...
ee/changelogs/unreleased/249245-add-sorting-vulnerabilities-by-title.yml
0 → 100644
View file @
9ea6756c
---
title
:
Add ability to sort vulnerabilities by title in GraphQL
merge_request
:
42953
author
:
type
:
added
ee/spec/graphql/types/vulnerability_sort_enum_spec.rb
View file @
9ea6756c
...
...
@@ -6,6 +6,6 @@ RSpec.describe GitlabSchema.types['VulnerabilitySort'] do
it
{
expect
(
described_class
.
graphql_name
).
to
eq
(
'VulnerabilitySort'
)
}
it
'exposes all the existing Vulnerability sort orders'
do
expect
(
described_class
.
values
.
keys
).
to
include
(
*
%w[severity_desc severity_asc]
)
expect
(
described_class
.
values
.
keys
).
to
include
(
*
%w[severity_desc severity_asc
title_desc title_asc
]
)
end
end
ee/spec/models/ee/vulnerability_spec.rb
View file @
9ea6756c
...
...
@@ -181,6 +181,28 @@ RSpec.describe Vulnerability do
end
end
describe
'.order_title_'
do
let_it_be
(
:vulnerability_b
)
{
create
(
:vulnerability
,
title:
'B Vulnerability'
)
}
let_it_be
(
:vulnerability_a
)
{
create
(
:vulnerability
,
title:
'A Vulnerability'
)
}
let_it_be
(
:vulnerability_c
)
{
create
(
:vulnerability
,
title:
'C Vulnerability'
)
}
describe
'asc'
do
subject
{
described_class
.
order_title_asc
}
it
'returns vulnerabilities ordered by title'
do
is_expected
.
to
eq
([
vulnerability_a
,
vulnerability_b
,
vulnerability_c
])
end
end
describe
'desc'
do
subject
{
described_class
.
order_title_desc
}
it
'returns vulnerabilities ordered by title'
do
is_expected
.
to
eq
([
vulnerability_c
,
vulnerability_b
,
vulnerability_a
])
end
end
end
describe
'.with_resolution'
do
let_it_be
(
:vulnerability_with_resolution
)
{
create
(
:vulnerability
,
resolved_on_default_branch:
true
)
}
let_it_be
(
:vulnerability_without_resolution
)
{
create
(
:vulnerability
,
resolved_on_default_branch:
false
)
}
...
...
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