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
0f400f7b
Commit
0f400f7b
authored
Jan 24, 2020
by
rossfuhrman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Align states of Vulnerability and Finding
Changes 'opened' to 'detected' and 'closed' to 'dismissed'
parent
6e0329ad
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
24 additions
and
24 deletions
+24
-24
ee/app/models/vulnerabilities/occurrence.rb
ee/app/models/vulnerabilities/occurrence.rb
+3
-3
ee/app/models/vulnerability.rb
ee/app/models/vulnerability.rb
+1
-1
ee/app/services/vulnerabilities/create_service.rb
ee/app/services/vulnerabilities/create_service.rb
+1
-1
ee/app/services/vulnerabilities/dismiss_service.rb
ee/app/services/vulnerabilities/dismiss_service.rb
+1
-1
ee/lib/api/vulnerabilities.rb
ee/lib/api/vulnerabilities.rb
+1
-1
ee/spec/factories/projects.rb
ee/spec/factories/projects.rb
+1
-1
ee/spec/factories/vulnerabilities.rb
ee/spec/factories/vulnerabilities.rb
+4
-4
ee/spec/factories/vulnerabilities/occurrences.rb
ee/spec/factories/vulnerabilities/occurrences.rb
+1
-1
ee/spec/finders/security/pipeline_vulnerabilities_finder_spec.rb
.../finders/security/pipeline_vulnerabilities_finder_spec.rb
+1
-1
ee/spec/fixtures/api/schemas/public_api/v4/vulnerability.json
...pec/fixtures/api/schemas/public_api/v4/vulnerability.json
+1
-1
ee/spec/fixtures/api/schemas/vulnerabilities/occurrence.json
ee/spec/fixtures/api/schemas/vulnerabilities/occurrence.json
+1
-1
ee/spec/models/vulnerabilities/occurrence_spec.rb
ee/spec/models/vulnerabilities/occurrence_spec.rb
+2
-2
ee/spec/models/vulnerability_spec.rb
ee/spec/models/vulnerability_spec.rb
+1
-1
ee/spec/requests/api/vulnerabilities_spec.rb
ee/spec/requests/api/vulnerabilities_spec.rb
+3
-3
ee/spec/services/vulnerabilities/create_service_spec.rb
ee/spec/services/vulnerabilities/create_service_spec.rb
+1
-1
ee/spec/services/vulnerabilities/dismiss_service_spec.rb
ee/spec/services/vulnerabilities/dismiss_service_spec.rb
+1
-1
No files found.
ee/app/models/vulnerabilities/occurrence.rb
View file @
0f400f7b
...
...
@@ -136,13 +136,13 @@ module Vulnerabilities
def
state
return
'dismissed'
if
dismissal_feedback
.
present?
return
'
open
ed'
unless
Feature
.
enabled?
(
:first_class_vulnerabilities
,
project
)
return
'
detect
ed'
unless
Feature
.
enabled?
(
:first_class_vulnerabilities
,
project
)
if
vulnerability
.
nil?
'
open
ed'
'
detect
ed'
elsif
vulnerability
.
resolved?
'resolved'
elsif
vulnerability
.
clo
sed?
# fail-safe check for cases when dismissal feedback was lost or was not created
elsif
vulnerability
.
dismis
sed?
# fail-safe check for cases when dismissal feedback was lost or was not created
'dismissed'
else
'confirmed'
...
...
ee/app/models/vulnerability.rb
View file @
0f400f7b
...
...
@@ -31,7 +31,7 @@ class Vulnerability < ApplicationRecord
end
end
enum
state:
{
opened:
1
,
clo
sed:
2
,
resolved:
3
}
enum
state:
{
detected:
1
,
dismis
sed:
2
,
resolved:
3
}
enum
severity:
Vulnerabilities
::
Occurrence
::
SEVERITY_LEVELS
,
_prefix: :severity
enum
confidence:
Vulnerabilities
::
Occurrence
::
CONFIDENCE_LEVELS
,
_prefix: :confidence
enum
report_type:
Vulnerabilities
::
Occurrence
::
REPORT_TYPES
...
...
ee/app/services/vulnerabilities/create_service.rb
View file @
0f400f7b
...
...
@@ -35,7 +35,7 @@ module Vulnerabilities
author:
@author
,
project:
@project
,
title:
finding
.
name
,
state: :
open
ed
,
state: :
detect
ed
,
severity:
finding
.
severity
,
severity_overridden:
false
,
confidence:
finding
.
confidence
,
...
...
ee/app/services/vulnerabilities/dismiss_service.rb
View file @
0f400f7b
...
...
@@ -23,7 +23,7 @@ module Vulnerabilities
raise
ActiveRecord
::
Rollback
end
@vulnerability
.
update
(
state: :
clo
sed
,
closed_by:
@user
,
closed_at:
Time
.
current
)
@vulnerability
.
update
(
state: :
dismis
sed
,
closed_by:
@user
,
closed_at:
Time
.
current
)
end
@vulnerability
...
...
ee/lib/api/vulnerabilities.rb
View file @
0f400f7b
...
...
@@ -54,7 +54,7 @@ module API
end
post
':id/dismiss'
do
vulnerability
=
find_and_authorize_vulnerability!
(
:admin_vulnerability
)
break
not_modified!
if
vulnerability
.
clo
sed?
break
not_modified!
if
vulnerability
.
dismis
sed?
vulnerability
=
::
Vulnerabilities
::
DismissService
.
new
(
current_user
,
vulnerability
).
execute
render_vulnerability
(
vulnerability
)
...
...
ee/spec/factories/projects.rb
View file @
0f400f7b
...
...
@@ -88,7 +88,7 @@ FactoryBot.modify do
trait
:with_vulnerabilities
do
after
(
:create
)
do
|
project
|
create_list
(
:vulnerability
,
2
,
:
open
ed
,
project:
project
)
create_list
(
:vulnerability
,
2
,
:
detect
ed
,
project:
project
)
end
end
end
...
...
ee/spec/factories/vulnerabilities.rb
View file @
0f400f7b
...
...
@@ -10,8 +10,8 @@ FactoryBot.define do
confidence
{
:medium
}
report_type
{
:sast
}
trait
:
open
ed
do
state
{
:
open
ed
}
trait
:
detect
ed
do
state
{
:
detect
ed
}
end
trait
:resolved
do
...
...
@@ -19,8 +19,8 @@ FactoryBot.define do
resolved_at
{
Time
.
current
}
end
trait
:
clo
sed
do
state
{
:
clo
sed
}
trait
:
dismis
sed
do
state
{
:
dismis
sed
}
closed_at
{
Time
.
current
}
end
...
...
ee/spec/factories/vulnerabilities/occurrences.rb
View file @
0f400f7b
...
...
@@ -39,7 +39,7 @@ FactoryBot.define do
trait
:confirmed
do
after
(
:create
)
do
|
finding
|
create
(
:vulnerability
,
:
open
ed
,
project:
finding
.
project
,
findings:
[
finding
])
create
(
:vulnerability
,
:
detect
ed
,
project:
finding
.
project
,
findings:
[
finding
])
end
end
...
...
ee/spec/finders/security/pipeline_vulnerabilities_finder_spec.rb
View file @
0f400f7b
...
...
@@ -289,7 +289,7 @@ describe Security::PipelineVulnerabilitiesFinder do
expect
(
confirmed
.
state
).
to
eq
'confirmed'
expect
(
resolved
.
state
).
to
eq
'resolved'
expect
(
dismissed
.
state
).
to
eq
'dismissed'
expect
(
subject
.
occurrences
-
[
confirmed
,
resolved
,
dismissed
]).
to
all
(
have_attributes
(
state:
'
open
ed'
))
expect
(
subject
.
occurrences
-
[
confirmed
,
resolved
,
dismissed
]).
to
all
(
have_attributes
(
state:
'
detect
ed'
))
end
end
...
...
ee/spec/fixtures/api/schemas/public_api/v4/vulnerability.json
View file @
0f400f7b
...
...
@@ -6,7 +6,7 @@
"type"
:
"string"
},
"description"
:
{
"type"
:
[
"string"
,
"null"
]
},
"state"
:
{
"type"
:
"string"
,
"enum"
:
[
"
opened"
,
"resolved"
,
"clo
sed"
]
},
"state"
:
{
"type"
:
"string"
,
"enum"
:
[
"
detected"
,
"resolved"
,
"dismis
sed"
]
},
"severity"
:
{
"type"
:
"string"
,
"enum"
:
[
"undefined"
,
"info"
,
"unknown"
,
"low"
,
"medium"
,
"high"
,
"critical"
]
...
...
ee/spec/fixtures/api/schemas/vulnerabilities/occurrence.json
View file @
0f400f7b
...
...
@@ -57,7 +57,7 @@
]},
"state"
:
{
"type"
:
"string"
,
"enum"
:
[
"
open
ed"
,
"confirmed"
,
"resolved"
,
"dismissed"
]
"enum"
:
[
"
detect
ed"
,
"confirmed"
,
"resolved"
,
"dismissed"
]
},
"description"
:
{
"type"
:
[
"string"
,
"null"
]
},
"solution"
:
{
"type"
:
[
"string"
,
"null"
]
},
...
...
ee/spec/models/vulnerabilities/occurrence_spec.rb
View file @
0f400f7b
...
...
@@ -497,7 +497,7 @@ describe Vulnerabilities::Occurrence do
describe
'#state'
do
before
do
create
(
:vulnerability
,
:
clo
sed
,
project:
finding_with_issue
.
project
,
findings:
[
finding_with_issue
])
create
(
:vulnerability
,
:
dismis
sed
,
project:
finding_with_issue
.
project
,
findings:
[
finding_with_issue
])
end
let
(
:unresolved_finding
)
{
create
(
:vulnerabilities_finding
)
}
...
...
@@ -507,7 +507,7 @@ describe Vulnerabilities::Occurrence do
let
(
:finding_with_issue
)
{
create
(
:vulnerabilities_finding
,
:with_issue_feedback
)
}
it
'returns the expected state for a unresolved finding'
do
expect
(
unresolved_finding
.
state
).
to
eq
'
open
ed'
expect
(
unresolved_finding
.
state
).
to
eq
'
detect
ed'
end
it
'returns the expected state for a confirmed finding'
do
...
...
ee/spec/models/vulnerability_spec.rb
View file @
0f400f7b
...
...
@@ -3,7 +3,7 @@
require
'spec_helper'
describe
Vulnerability
do
let
(
:state_values
)
{
{
opened:
1
,
clo
sed:
2
,
resolved:
3
}
}
let
(
:state_values
)
{
{
detected:
1
,
dismis
sed:
2
,
resolved:
3
}
}
let
(
:severity_values
)
{
{
undefined:
0
,
info:
1
,
unknown:
2
,
low:
4
,
medium:
5
,
high:
6
,
critical:
7
}
}
let
(
:confidence_values
)
do
...
...
ee/spec/requests/api/vulnerabilities_spec.rb
View file @
0f400f7b
...
...
@@ -123,7 +123,7 @@ describe API::Vulnerabilities do
have_attributes
(
author:
user
,
title:
finding
.
name
,
state:
'
open
ed'
,
state:
'
detect
ed'
,
severity:
finding
.
severity
,
severity_overridden:
false
,
confidence:
finding
.
confidence
,
...
...
@@ -199,7 +199,7 @@ describe API::Vulnerabilities do
expect
(
response
).
to
match_response_schema
(
'public_api/v4/vulnerability'
,
dir:
'ee'
)
expect
(
vulnerability
.
reload
).
to
(
have_attributes
(
state:
'
clo
sed'
,
closed_by:
user
,
closed_at:
be_like_time
(
Time
.
current
)))
have_attributes
(
state:
'
dismis
sed'
,
closed_by:
user
,
closed_at:
be_like_time
(
Time
.
current
)))
expect
(
vulnerability
.
findings
).
to
all
have_vulnerability_dismissal_feedback
end
end
...
...
@@ -237,7 +237,7 @@ describe API::Vulnerabilities do
end
context
'if a vulnerability is already dismissed'
do
let
(
:vulnerability
)
{
create
(
:vulnerability
,
:
clo
sed
,
project:
project
)
}
let
(
:vulnerability
)
{
create
(
:vulnerability
,
:
dismis
sed
,
project:
project
)
}
it
'responds with 304 Not Modified'
do
dismiss_vulnerability
...
...
ee/spec/services/vulnerabilities/create_service_spec.rb
View file @
0f400f7b
...
...
@@ -26,7 +26,7 @@ describe Vulnerabilities::CreateService do
have_attributes
(
author:
user
,
title:
finding
.
name
,
state:
'
open
ed'
,
state:
'
detect
ed'
,
severity:
finding
.
severity
,
severity_overridden:
false
,
confidence:
finding
.
confidence
,
...
...
ee/spec/services/vulnerabilities/dismiss_service_spec.rb
View file @
0f400f7b
...
...
@@ -26,7 +26,7 @@ describe Vulnerabilities::DismissService do
dismiss_vulnerability
expect
(
vulnerability
.
reload
).
to
(
have_attributes
(
state:
'
clo
sed'
,
closed_by:
user
,
closed_at:
be_like_time
(
Time
.
current
)))
have_attributes
(
state:
'
dismis
sed'
,
closed_by:
user
,
closed_at:
be_like_time
(
Time
.
current
)))
expect
(
vulnerability
.
findings
).
to
all
have_vulnerability_dismissal_feedback
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