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
7775d54a
Commit
7775d54a
authored
Dec 02, 2020
by
Mehmet Emin INAC
Committed by
Mayra Cabrera
Dec 02, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Populate remaning dismissal information
The post-deployment migration is required for clean-up.
parent
1d6b538f
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
0 deletions
+58
-0
changelogs/unreleased/262112_populate_remaining_dismissal_information.yml
...eased/262112_populate_remaining_dismissal_information.yml
+5
-0
db/post_migrate/20201124122817_populate_remaining_missing_dismissal_information_for_vulnerabilities.rb
...ning_missing_dismissal_information_for_vulnerabilities.rb
+21
-0
db/schema_migrations/20201124122817
db/schema_migrations/20201124122817
+1
-0
spec/migrations/populate_remaining_missing_dismissal_information_for_vulnerabilities_spec.rb
...missing_dismissal_information_for_vulnerabilities_spec.rb
+31
-0
No files found.
changelogs/unreleased/262112_populate_remaining_dismissal_information.yml
0 → 100644
View file @
7775d54a
---
title
:
Add migration to populate remaining dismissal information for vulnerabilities
merge_request
:
48472
author
:
type
:
added
db/post_migrate/20201124122817_populate_remaining_missing_dismissal_information_for_vulnerabilities.rb
0 → 100644
View file @
7775d54a
# frozen_string_literal: true
class
PopulateRemainingMissingDismissalInformationForVulnerabilities
<
ActiveRecord
::
Migration
[
6.0
]
DOWNTIME
=
false
disable_ddl_transaction!
def
up
Gitlab
::
BackgroundMigration
.
steal
(
'PopulateMissingVulnerabilityDismissalInformation'
)
::
Gitlab
::
BackgroundMigration
::
PopulateMissingVulnerabilityDismissalInformation
::
Vulnerability
.
broken
.
each_batch
(
of:
100
)
do
|
batch
,
index
|
vulnerability_ids
=
batch
.
pluck
(
:id
)
::
Gitlab
::
BackgroundMigration
::
PopulateMissingVulnerabilityDismissalInformation
.
new
.
perform
(
*
vulnerability_ids
)
end
end
def
down
# no-op
end
end
db/schema_migrations/20201124122817
0 → 100644
View file @
7775d54a
1113642dfc9069dcea01ac12b1653dfcf67b3aea449538e9747d3bc857ce88d8
\ No newline at end of file
spec/migrations/populate_remaining_missing_dismissal_information_for_vulnerabilities_spec.rb
0 → 100644
View file @
7775d54a
# frozen_string_literal: true
require
'spec_helper'
require_migration!
RSpec
.
describe
PopulateRemainingMissingDismissalInformationForVulnerabilities
do
let
(
:users
)
{
table
(
:users
)
}
let
(
:namespaces
)
{
table
(
:namespaces
)
}
let
(
:projects
)
{
table
(
:projects
)
}
let
(
:vulnerabilities
)
{
table
(
:vulnerabilities
)
}
let
(
:user
)
{
users
.
create!
(
name:
'test'
,
email:
'test@example.com'
,
projects_limit:
5
)
}
let
(
:namespace
)
{
namespaces
.
create!
(
name:
'gitlab'
,
path:
'gitlab-org'
)
}
let
(
:project
)
{
projects
.
create!
(
namespace_id:
namespace
.
id
,
name:
'foo'
)
}
let
(
:states
)
{
{
detected:
1
,
dismissed:
2
,
resolved:
3
,
confirmed:
4
}
}
let!
(
:vulnerability_1
)
{
vulnerabilities
.
create!
(
title:
'title'
,
state:
states
[
:detected
],
severity:
0
,
confidence:
5
,
report_type:
2
,
project_id:
project
.
id
,
author_id:
user
.
id
)
}
let!
(
:vulnerability_2
)
{
vulnerabilities
.
create!
(
title:
'title'
,
state:
states
[
:dismissed
],
severity:
0
,
confidence:
5
,
report_type:
2
,
project_id:
project
.
id
,
author_id:
user
.
id
)
}
let!
(
:vulnerability_3
)
{
vulnerabilities
.
create!
(
title:
'title'
,
state:
states
[
:resolved
],
severity:
0
,
confidence:
5
,
report_type:
2
,
project_id:
project
.
id
,
author_id:
user
.
id
)
}
let!
(
:vulnerability_4
)
{
vulnerabilities
.
create!
(
title:
'title'
,
state:
states
[
:confirmed
],
severity:
0
,
confidence:
5
,
report_type:
2
,
project_id:
project
.
id
,
author_id:
user
.
id
)
}
describe
'#perform'
do
it
'calls the background migration class instance with broken vulnerability IDs'
do
expect_next_instance_of
(
::
Gitlab
::
BackgroundMigration
::
PopulateMissingVulnerabilityDismissalInformation
)
do
|
migrator
|
expect
(
migrator
).
to
receive
(
:perform
).
with
(
vulnerability_2
.
id
)
end
migrate!
end
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