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
477b82f1
Commit
477b82f1
authored
Sep 25, 2019
by
Luke Duncalfe
Committed by
Stan Hu
Sep 25, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make post migration EE-specific
Fixes
https://gitlab.com/gitlab-org/gitlab/issues/32725
parent
ecb4d009
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
15 deletions
+16
-15
db/post_migrate/20190909141517_update_cs_vulnerability_confidence_column.rb
...190909141517_update_cs_vulnerability_confidence_column.rb
+3
-0
ee/lib/gitlab/background_migration/update_vulnerability_confidence.rb
...b/background_migration/update_vulnerability_confidence.rb
+1
-1
ee/spec/lib/gitlab/background_migration/update_vulnerability_confidence_spec.rb
...kground_migration/update_vulnerability_confidence_spec.rb
+12
-14
No files found.
db/post_migrate/20190909141517_update_cs_vulnerability_confidence_column.rb
View file @
477b82f1
...
...
@@ -14,6 +14,9 @@ class UpdateCsVulnerabilityConfidenceColumn < ActiveRecord::Migration[5.2]
# 137_424 records to be updated on GitLab.com,
# giving us an estimated runtime of 12 hours.
def
up
# no-op in CE
return
unless
Gitlab
.
ee?
migration
=
Gitlab
::
BackgroundMigration
::
UpdateVulnerabilityConfidence
migration_name
=
migration
.
to_s
.
demodulize
relation
=
migration
::
Occurrence
.
container_scanning_reports_with_medium_confidence
...
...
lib/gitlab/background_migration/update_vulnerability_confidence.rb
→
ee/
lib/gitlab/background_migration/update_vulnerability_confidence.rb
View file @
477b82f1
# frozen_string_literal: true
# rubocop:disable Style/Documentation
module
Gitlab
module
BackgroundMigration
class
UpdateVulnerabilityConfidence
...
...
spec/lib/gitlab/background_migration/update_vulnerability_confidence_spec.rb
→
ee/
spec/lib/gitlab/background_migration/update_vulnerability_confidence_spec.rb
View file @
477b82f1
...
...
@@ -7,9 +7,6 @@ describe Gitlab::BackgroundMigration::UpdateVulnerabilityConfidence, :migration,
let
(
:identifiers
)
{
table
(
:vulnerability_identifiers
)
}
let
(
:scanners
)
{
table
(
:vulnerability_scanners
)
}
let
(
:projects
)
{
table
(
:projects
)
}
let
(
:vul1
)
{
attributes_for
(
:vulnerabilities_occurrence
)
}
let
(
:vul2
)
{
attributes_for
(
:vulnerabilities_occurrence
)
}
let
(
:vul3
)
{
attributes_for
(
:vulnerabilities_occurrence
)
}
it
'updates confidence level for container scanning reports'
do
projects
.
create!
(
id:
123
,
namespace_id:
12
,
name:
'gitlab'
,
path:
'gitlab'
)
...
...
@@ -25,34 +22,35 @@ describe Gitlab::BackgroundMigration::UpdateVulnerabilityConfidence, :migration,
scanners
.
create!
(
id:
6
,
project_id:
123
,
external_id:
'clair'
,
name:
'Security Scanner'
)
vul
nerabilities
.
create!
(
container_scanning_vuln_params
(
vul1
,
1
))
vulnerabilities
.
create!
(
container_scanning_vuln_params
(
vul2
,
2
))
vul
nerabilities
.
create!
(
container_scanning_vuln_params
(
vul3
,
3
).
merge
(
report_type:
1
))
vul
1
=
vulnerabilities
.
create!
(
container_scanning_vuln_params
(
1
))
vulnerabilities
.
create!
(
container_scanning_vuln_params
(
2
))
vul
3
=
vulnerabilities
.
create!
(
container_scanning_vuln_params
(
3
).
merge
(
report_type:
1
))
expect
(
vulnerabilities
.
where
(
report_type:
2
,
confidence:
2
).
count
).
to
eq
(
0
)
expect
(
vulnerabilities
.
exists?
(
report_type:
2
,
confidence:
5
)).
to
be_truthy
described_class
.
new
.
perform
(
1
,
3
)
described_class
.
new
.
perform
(
vul1
.
id
,
vul3
.
id
)
expect
(
vulnerabilities
.
exists?
(
report_type:
2
,
confidence:
5
)).
to
be_falsy
expect
(
vulnerabilities
.
where
(
report_type:
2
,
confidence:
2
).
count
).
to
eq
(
2
)
end
def
container_scanning_vuln_params
(
vul
,
primary_identifier_id
)
def
container_scanning_vuln_params
(
primary_identifier_id
)
attrs
=
attributes_for
(
:vulnerabilities_occurrence
)
{
id:
vul
[
:id
],
severity:
2
,
confidence:
5
,
report_type:
2
,
project_id:
123
,
scanner_id:
6
,
primary_identifier_id:
primary_identifier_id
,
project_fingerprint:
vul
[
:project_fingerprint
],
location_fingerprint:
vul
[
:location_fingerprint
],
uuid:
vul
[
:uuid
],
name:
vul
[
:name
],
project_fingerprint:
attrs
[
:project_fingerprint
],
location_fingerprint:
attrs
[
:location_fingerprint
],
uuid:
attrs
[
:uuid
],
name:
attrs
[
:name
],
metadata_version:
'1.3'
,
raw_metadata:
vul3
[
:raw_metadata
]
raw_metadata:
attrs
[
:raw_metadata
]
}
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