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
97d2e8b6
Commit
97d2e8b6
authored
Sep 15, 2020
by
can eldem
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Skip orphant findings for background migration
parent
722ae431
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
2 deletions
+7
-2
ee/lib/ee/gitlab/background_migration/remove_duplicate_cs_findings.rb
...tlab/background_migration/remove_duplicate_cs_findings.rb
+2
-0
ee/spec/lib/ee/gitlab/background_migration/remove_duplicate_cs_findings_spec.rb
...background_migration/remove_duplicate_cs_findings_spec.rb
+5
-2
No files found.
ee/lib/ee/gitlab/background_migration/remove_duplicate_cs_findings.rb
View file @
97d2e8b6
...
...
@@ -50,6 +50,8 @@ module EE
location_fingerprint:
colliding_fingerprint
).
first
next
if
duplicated_finding
.
blank?
# we have some findings without vulnerabilities
next
if
duplicated_finding
.
vulnerability
.
nil?
ActiveRecord
::
Base
.
transaction
do
duplicated_finding
.
vulnerability
.
delete_notes
...
...
ee/spec/lib/ee/gitlab/background_migration/remove_duplicate_cs_findings_spec.rb
View file @
97d2e8b6
...
...
@@ -36,6 +36,7 @@ RSpec.describe Gitlab::BackgroundMigration::RemoveDuplicateCsFindings, :migratio
9d1a47927875f1aee1e2b9f16c25a8ff7586f1a6
d7da2cc109c18d890ab239e833524d451cc45246
d7da2cc109c18d890ab239e833524d453cd45246
475f029c81fa0a944bc825a44e02617867a4256d
)
expected_fingerprints
=
%w(
...
...
@@ -43,6 +44,7 @@ RSpec.describe Gitlab::BackgroundMigration::RemoveDuplicateCsFindings, :migratio
9d1a47927875f1aee1e2b9f16c25a8ff7586f1a6
d7da2cc109c18d890ab239e833524d451cc45246
d7da2cc109c18d890ab239e833524d453cd45246
475f029c81fa0a944bc825a44e02617867a4256d
)
7
.
times
.
each
{
|
x
|
identifiers
.
create!
(
vulnerability_identifer_params
(
x
,
project
.
id
))
}
...
...
@@ -55,6 +57,7 @@ RSpec.describe Gitlab::BackgroundMigration::RemoveDuplicateCsFindings, :migratio
findings
.
create!
(
finding_params
(
1
,
project
.
id
).
merge
({
id:
ids
[
4
],
location_fingerprint:
Gitlab
::
Database
::
ShaAttribute
.
new
.
serialize
(
fingerprints
[
4
]).
to_s
,
vulnerability_id:
vulnerability_ids
[
4
]
}))
findings
.
create!
(
finding_params
(
2
,
project
.
id
).
merge
({
id:
ids
[
5
],
location_fingerprint:
Gitlab
::
Database
::
ShaAttribute
.
new
.
serialize
(
fingerprints
[
5
]).
to_s
,
vulnerability_id:
vulnerability_ids
[
5
]
}))
findings
.
create!
(
finding_params
(
3
,
project
.
id
).
merge
({
id:
ids
[
6
],
location_fingerprint:
Gitlab
::
Database
::
ShaAttribute
.
new
.
serialize
(
fingerprints
[
6
]).
to_s
,
vulnerability_id:
vulnerability_ids
[
6
]
}))
findings
.
create!
(
finding_params
(
3
,
project
.
id
).
merge
({
id:
100000
,
location_fingerprint:
Gitlab
::
Database
::
ShaAttribute
.
new
.
serialize
(
fingerprints
[
7
]).
to_s
,
vulnerability_id:
nil
}))
7
.
times
.
each
{
|
x
|
finding_identifiers
.
create!
(
occurrence_id:
ids
[
x
],
identifier_id:
x
)
}
1
.
upto
(
5
).
each
{
|
x
|
issues
.
create!
(
description:
'1234'
,
state_id:
1
,
project_id:
project
.
id
,
id:
x
)
}
...
...
@@ -67,8 +70,8 @@ RSpec.describe Gitlab::BackgroundMigration::RemoveDuplicateCsFindings, :migratio
described_class
.
new
.
perform
(
231411
,
231413
)
expect
(
findings
.
ids
).
to
match_array
([
231800
,
231412
,
231413
,
231411
])
expect
(
findings
.
where
(
report_type:
2
).
count
).
to
eq
(
4
)
expect
(
findings
.
ids
).
to
match_array
([
100000
,
231800
,
231412
,
231413
,
231411
])
expect
(
findings
.
where
(
report_type:
2
).
count
).
to
eq
(
5
)
expect
(
vulnerabilities
.
all
.
count
).
to
eq
(
4
)
expect
(
notes
.
all
.
count
).
to
eq
(
0
)
expect
(
finding_identifiers
.
all
.
count
).
to
eq
(
4
)
...
...
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