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
11fdd444
Commit
11fdd444
authored
Nov 12, 2020
by
Mehmet Emin INAC
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove dismissal info fallback methods from the `Vulnerability` model
parent
50ea91ee
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
154 deletions
+0
-154
ee/app/models/ee/vulnerability.rb
ee/app/models/ee/vulnerability.rb
+0
-22
ee/spec/models/ee/vulnerability_spec.rb
ee/spec/models/ee/vulnerability_spec.rb
+0
-132
No files found.
ee/app/models/ee/vulnerability.rb
View file @
11fdd444
...
...
@@ -139,19 +139,6 @@ module EE
findings
.
first
end
# TODO: Remove this attribute reader overrides with #262112
def
dismissed_at
return
unless
dismissed?
super
||
fallback_dismissal_feedback
&
.
created_at
end
def
dismissed_by_id
return
unless
dismissed?
super
||
fallback_dismissal_feedback
&
.
author_id
end
def
resource_parent
project
end
...
...
@@ -179,15 +166,6 @@ module EE
def
user_notes_count_service
@user_notes_count_service
||=
::
Vulnerabilities
::
UserNotesCountService
.
new
(
self
)
# rubocop: disable CodeReuse/ServiceClass
end
# TODO: Remove this with #262112
def
fallback_dismissal_feedback
strong_memoize
(
:fallback_dismissal_feedback
)
do
::
Gitlab
::
AppJsonLogger
.
warn
(
message:
'Fallback dismissal_feedback has been called!'
,
vulnerability_id:
id
)
finding
&
.
dismissal_feedback
end
end
end
class_methods
do
...
...
ee/spec/models/ee/vulnerability_spec.rb
View file @
11fdd444
...
...
@@ -674,138 +674,6 @@ RSpec.describe Vulnerability do
end
end
describe
'#dismissed_at'
do
let_it_be
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:finding
)
do
create
(
:vulnerabilities_finding
,
report_type: :dependency_scanning
,
project:
project
)
end
let
(
:vulnerability
)
{
create
(
:vulnerability
,
findings:
[
finding
])
}
let
(
:feedback_created_at
)
{
-
2
.
days
.
from_now
}
let!
(
:dismissal_feedback
)
do
create
(
:vulnerability_feedback
,
:dependency_scanning
,
:dismissal
,
project:
project
,
project_fingerprint:
finding
.
project_fingerprint
,
created_at:
feedback_created_at
)
end
subject
(
:dismissed_at
)
{
vulnerability
.
dismissed_at
}
around
do
|
example
|
freeze_time
{
example
.
run
}
end
context
'when the vulnerability is not dismissed'
do
before
do
vulnerability
.
update_attribute
(
:dismissed_at
,
Time
.
current
)
end
it
{
is_expected
.
to
be_nil
}
end
context
'when the vulnerability is dismissed'
do
before
do
vulnerability
.
dismissed!
end
context
'when the `dismissed_at` exists'
do
let
(
:vulnerability_dismissed_at
)
{
-
1
.
day
.
from_now
}
before
do
vulnerability
.
update_attribute
(
:dismissed_at
,
vulnerability_dismissed_at
)
end
it
{
is_expected
.
to
eq
(
vulnerability_dismissed_at
)
}
end
context
'when the `dismissed_at` does not exist'
do
before
do
allow
(
::
Gitlab
::
AppJsonLogger
).
to
receive
(
:warn
)
end
it
{
is_expected
.
to
eq
(
feedback_created_at
)
}
it
'puts a warning log'
do
dismissed_at
expect
(
::
Gitlab
::
AppJsonLogger
).
to
have_received
(
:warn
)
end
end
end
end
describe
'#dismissed_by_id'
do
let_it_be
(
:user_1
)
{
create
(
:user
)
}
let_it_be
(
:user_2
)
{
create
(
:user
)
}
let_it_be
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:occurrence
)
do
create
(
:vulnerabilities_finding
,
report_type: :dependency_scanning
,
project:
project
)
end
let_it_be
(
:dismissal_feedback
)
do
create
(
:vulnerability_feedback
,
:dependency_scanning
,
:dismissal
,
project:
project
,
project_fingerprint:
occurrence
.
project_fingerprint
,
author:
user_1
)
end
let
(
:vulnerability
)
{
create
(
:vulnerability
,
findings:
[
occurrence
])
}
subject
(
:dismissed_by_id
)
{
vulnerability
.
dismissed_by_id
}
context
'when the vulnerability is not dismissed'
do
before
do
vulnerability
.
update_attribute
(
:dismissed_by_id
,
user_1
.
id
)
end
it
{
is_expected
.
to
be_nil
}
end
context
'when the vulnerability is dismissed'
do
before
do
vulnerability
.
dismissed!
end
context
'when the `dismissed_by_id` exists'
do
before
do
vulnerability
.
update_attribute
(
:dismissed_by_id
,
user_2
.
id
)
end
it
{
is_expected
.
to
eq
(
user_2
.
id
)
}
end
context
'when the `dismissed_by_id` does not exist'
do
before
do
allow
(
::
Gitlab
::
AppJsonLogger
).
to
receive
(
:warn
)
end
it
{
is_expected
.
to
eq
(
user_1
.
id
)
}
it
'puts a warning log'
do
dismissed_by_id
expect
(
::
Gitlab
::
AppJsonLogger
).
to
have_received
(
:warn
)
end
end
end
end
describe
'#user_notes_count'
do
let_it_be
(
:vulnerability
)
{
create
(
:vulnerability
)
}
...
...
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