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
4e5165e4
Commit
4e5165e4
authored
Jun 19, 2020
by
Jonathan Schafer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changes from MR review
parent
fc678af7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
23 deletions
+7
-23
ee/lib/ee/gitlab/background_migration/update_vulnerabilities_from_dismissal_feedback.rb
...gration/update_vulnerabilities_from_dismissal_feedback.rb
+5
-5
ee/spec/lib/ee/gitlab/background_migration/update_vulnerabilities_from_dismissal_feedback_spec.rb
...on/update_vulnerabilities_from_dismissal_feedback_spec.rb
+1
-17
ee/spec/migrations/migrate_vulnerability_dismissal_feedback_spec.rb
...grations/migrate_vulnerability_dismissal_feedback_spec.rb
+1
-1
No files found.
ee/lib/ee/gitlab/background_migration/update_vulnerabilities_from_dismissal_feedback.rb
View file @
4e5165e4
...
...
@@ -8,8 +8,8 @@ module EE
module
UpdateVulnerabilitiesFromDismissalFeedback
extend
::
Gitlab
::
Utils
::
Override
VULNERABILITY_DISMISSED
=
2
VULNERABILITY_FEEDBACK_DISMISSAL
=
0
VULNERABILITY_DISMISSED
_STATE
=
2
VULNERABILITY_FEEDBACK_DISMISSAL
_TYPE
=
0
class
Project
<
ActiveRecord
::
Base
self
.
table_name
=
'projects'
...
...
@@ -21,7 +21,7 @@ module EE
project
=
Project
.
find_by
(
id:
project_id
)
return
unless
project
return
if
project
.
archived?
||
project
.
pending_delete?
return
if
project
.
pending_delete?
update_vulnerability_from_dismissal_feedback
(
project
.
id
)
end
...
...
@@ -34,12 +34,12 @@ module EE
SET dismissed_by_id = vf.author_id, dismissed_at = vf.created_at
FROM vulnerability_occurrences AS vo, vulnerability_feedback AS vf
WHERE vo.vulnerability_id = v.id
AND v.state =
#{
VULNERABILITY_DISMISSED
}
AND v.state =
#{
VULNERABILITY_DISMISSED
_STATE
}
AND vo.project_id = vf.project_id
AND ENCODE(vo.project_fingerprint, 'HEX') = vf.project_fingerprint
AND vo.project_id =
#{
project_id
}
AND vo.report_type = vf.category
AND vf.feedback_type =
#{
VULNERABILITY_FEEDBACK_DISMISSAL
}
;
AND vf.feedback_type =
#{
VULNERABILITY_FEEDBACK_DISMISSAL
_TYPE
}
;
SQL
connection
.
execute
(
update_vulnerability_from_dismissal_feedback_sql
)
rescue
=>
e
...
...
ee/spec/lib/ee/gitlab/background_migration/update_vulnerabilities_from_dismissal_feedback_spec.rb
View file @
4e5165e4
...
...
@@ -72,22 +72,6 @@ describe Gitlab::BackgroundMigration::UpdateVulnerabilitiesFromDismissalFeedback
.
to
(
dismiss_feedback
.
created_at
)
end
context
'project is archived'
do
let!
(
:project
)
{
projects
.
create!
(
namespace_id:
namespace
.
id
,
name:
'gitlab'
,
path:
'gitlab'
,
archived:
true
)
}
it
'vulnerability dismissed_by_id should remain nil'
do
expect
(
vulnerability
.
dismissed_by_id
).
to
eq
(
nil
)
expect
{
described_class
.
new
.
perform
(
project
.
id
)
}.
not_to
change
{
vulnerability
.
reload
.
dismissed_by_id
}.
from
(
nil
)
end
it
'vulnerability dismissed_at should remain nil'
do
expect
(
vulnerability
.
dismissed_at
).
to
eq
(
nil
)
expect
{
described_class
.
new
.
perform
(
project
.
id
)
}.
not_to
change
{
vulnerability
.
reload
.
dismissed_at
}.
from
(
nil
)
end
end
context
'project is set to be deleted'
do
let!
(
:project
)
{
projects
.
create!
(
namespace_id:
namespace
.
id
,
name:
'gitlab'
,
path:
'gitlab'
,
pending_delete:
true
)
}
...
...
@@ -124,7 +108,7 @@ describe Gitlab::BackgroundMigration::UpdateVulnerabilitiesFromDismissalFeedback
def
vuln_params
{
title:
'title'
,
state:
described_class
::
VULNERABILITY_DISMISSED
,
state:
described_class
::
VULNERABILITY_DISMISSED
_STATE
,
severity:
severity
,
confidence:
confidence
,
report_type:
report_type
,
...
...
ee/spec/migrations/migrate_vulnerability_dismissal_feedback_spec.rb
View file @
4e5165e4
...
...
@@ -15,7 +15,7 @@ describe MigrateVulnerabilityDismissalFeedback, :migration, :sidekiq do
let
(
:vulnerabilities
)
{
table
(
:vulnerabilities
)
}
let
(
:dismissed_state
)
{
Gitlab
::
BackgroundMigration
::
UpdateVulnerabilitiesFromDismissalFeedback
::
VULNERABILITY_DISMISSED
}
let
(
:dismissed_state
)
{
Gitlab
::
BackgroundMigration
::
UpdateVulnerabilitiesFromDismissalFeedback
::
VULNERABILITY_DISMISSED
_STATE
}
let
(
:severity
)
{
Vulnerabilities
::
Occurrence
::
SEVERITY_LEVELS
[
:unknown
]
}
let
(
:confidence
)
{
Vulnerabilities
::
Occurrence
::
CONFIDENCE_LEVELS
[
:medium
]
}
let
(
:report_type
)
{
Vulnerabilities
::
Occurrence
::
REPORT_TYPES
[
:sast
]
}
...
...
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