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
5f9d7214
Commit
5f9d7214
authored
Jan 20, 2021
by
Mayra Cabrera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Merge branch..."
This reverts merge request !50283
parent
e12af2f3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
38 deletions
+13
-38
ee/app/services/security/store_report_service.rb
ee/app/services/security/store_report_service.rb
+6
-16
ee/spec/factories/ci/reports/security/findings.rb
ee/spec/factories/ci/reports/security/findings.rb
+1
-3
ee/spec/factories/vulnerabilities/findings.rb
ee/spec/factories/vulnerabilities/findings.rb
+6
-4
ee/spec/services/security/store_report_service_spec.rb
ee/spec/services/security/store_report_service_spec.rb
+0
-15
No files found.
ee/app/services/security/store_report_service.rb
View file @
5f9d7214
...
...
@@ -80,25 +80,15 @@ module Security
}
begin
# Look for existing Findings using UUID
vulnerability_finding
=
project
.
vulnerability_findings
.
find_by
(
uuid:
finding
.
uuid
)
# If there's no Finding then we're dealing with one of two cases:
# 1. The Finding is a new one
# 2. The Finding is already saved but has UUIDv4
unless
vulnerability_finding
vulnerability_finding
=
project
.
vulnerability_findings
.
create_with
(
create_params
)
.
find_or_initialize_by
(
find_params
)
vulnerability_finding
.
uuid
=
finding
.
uuid
end
vulnerability_finding
=
project
.
vulnerability_findings
.
create_with
(
create_params
)
.
find_or_initialize_by
(
find_params
)
vulnerability_finding
.
save!
vulnerability_finding
rescue
ActiveRecord
::
RecordNotUnique
=>
e
Gitlab
::
ErrorTracking
.
track_and_raise_exception
(
e
,
find_params:
find_params
,
uuid:
finding
.
uuid
)
vulnerability_finding
rescue
ActiveRecord
::
RecordNotUnique
project
.
vulnerability_findings
.
find_by!
(
find_params
)
rescue
ActiveRecord
::
RecordInvalid
=>
e
Gitlab
::
ErrorTracking
.
track_and_raise_exception
(
e
,
create_params:
create_params
&
.
dig
(
:raw_metadata
))
end
...
...
ee/spec/factories/ci/reports/security/findings.rb
View file @
5f9d7214
...
...
@@ -31,9 +31,7 @@ FactoryBot.define do
scanner
factory: :ci_reports_security_scanner
severity
{
:high
}
scan
factory: :ci_reports_security_scan
sequence
(
:uuid
)
do
|
n
|
Gitlab
::
UUID
.
v5
(
"
#{
report_type
}
-
#{
identifiers
.
first
&
.
fingerprint
}
-
#{
location
.
fingerprint
}
-
#{
n
}
"
)
end
sequence
(
:uuid
)
{
generate
(
:vulnerability_finding_uuid
)
}
skip_create
...
...
ee/spec/factories/vulnerabilities/findings.rb
View file @
5f9d7214
# frozen_string_literal: true
FactoryBot
.
define
do
sequence
:vulnerability_finding_uuid
do
|
n
|
SecureRandom
.
uuid
end
factory
:vulnerabilities_finding_with_remediation
,
parent: :vulnerabilities_finding
do
transient
do
summary
{
nil
}
...
...
@@ -43,13 +47,11 @@ FactoryBot.define do
factory
:vulnerabilities_finding
,
class:
'Vulnerabilities::Finding'
do
name
{
'Cipher with no integrity'
}
project
sequence
(
:uuid
)
{
generate
(
:vulnerability_finding_uuid
)
}
project_fingerprint
{
generate
(
:project_fingerprint
)
}
primary_identifier
factory: :vulnerabilities_identifier
location_fingerprint
{
SecureRandom
.
hex
(
20
)
}
location_fingerprint
{
'4e5b6966dd100170b4b1ad599c7058cce91b57b4'
}
report_type
{
:sast
}
sequence
(
:uuid
)
do
Gitlab
::
UUID
.
v5
(
"
#{
report_type
}
-
#{
primary_identifier
.
fingerprint
}
-
#{
location_fingerprint
}
-
#{
project_id
}
"
)
end
severity
{
:high
}
confidence
{
:medium
}
scanner
factory: :vulnerabilities_scanner
...
...
ee/spec/services/security/store_report_service_spec.rb
View file @
5f9d7214
...
...
@@ -124,16 +124,9 @@ RSpec.describe Security::StoreReportService, '#execute' do
primary_identifier:
identifier
,
scanner:
scanner
,
project:
project
,
uuid:
"80571acf-8660-4bc8-811a-1d8dec9ab6f4"
,
location_fingerprint:
'd869ba3f0b3347eb2749135a437dc07c8ae0f420'
)
end
let
(
:uuid_v5_components
)
do
"
#{
finding
.
report_type
}
-
#{
finding
.
primary_identifier
.
fingerprint
}
-
#{
finding
.
location_fingerprint
}
-
#{
finding
.
project_id
}
"
end
let
(
:desired_uuid
)
{
Gitlab
::
UUID
.
v5
(
uuid_v5_components
)
}
let!
(
:vulnerability
)
{
create
(
:vulnerability
,
findings:
[
finding
],
project:
project
)
}
before
do
...
...
@@ -143,12 +136,6 @@ RSpec.describe Security::StoreReportService, '#execute' do
subject
{
described_class
.
new
(
new_pipeline
,
new_report
).
execute
}
it
'updates UUIDv4 to UUIDv5'
do
subject
expect
(
finding
.
reload
.
uuid
).
to
eq
(
desired_uuid
)
end
it
'inserts only new scanners and reuse existing ones'
do
expect
{
subject
}.
to
change
{
Vulnerabilities
::
Scanner
.
count
}.
by
(
2
)
end
...
...
@@ -171,13 +158,11 @@ RSpec.describe Security::StoreReportService, '#execute' do
it
'updates existing findings with new data'
do
subject
expect
(
finding
.
reload
).
to
have_attributes
(
severity:
'medium'
,
name:
'Probable insecure usage of temp file/directory.'
)
end
it
'updates existing vulnerability with new data'
do
subject
expect
(
vulnerability
.
reload
).
to
have_attributes
(
severity:
'medium'
,
title:
'Probable insecure usage of temp file/directory.'
,
title_html:
'Probable insecure usage of temp file/directory.'
)
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