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
2193c771
Commit
2193c771
authored
Aug 13, 2020
by
can eldem
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change location fingerprint calculation
Introduce temporary method to calculate location fingerprint
parent
7491f8b9
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
69 additions
and
0 deletions
+69
-0
ee/changelogs/unreleased/new-fingerprint-for-cs.yml
ee/changelogs/unreleased/new-fingerprint-for-cs.yml
+5
-0
ee/lib/gitlab/ci/reports/security/locations/container_scanning.rb
...itlab/ci/reports/security/locations/container_scanning.rb
+23
-0
ee/spec/lib/gitlab/ci/reports/security/locations/container_scanning_spec.rb
.../ci/reports/security/locations/container_scanning_spec.rb
+41
-0
No files found.
ee/changelogs/unreleased/new-fingerprint-for-cs.yml
0 → 100644
View file @
2193c771
---
title
:
Change location fingerprint calculation for container scanning
merge_request
:
39445
author
:
type
:
other
ee/lib/gitlab/ci/reports/security/locations/container_scanning.rb
View file @
2193c771
...
...
@@ -18,11 +18,34 @@ module Gitlab
@package_version
=
package_version
end
# temporary, untill existing data updated in DB
def
new_fingerprint
Digest
::
SHA1
.
hexdigest
(
"
#{
docker_image_name_without_tag
}
:
#{
package_name
}
"
)
end
private
def
fingerprint_data
"
#{
operating_system
}
:
#{
package_name
}
"
end
def
docker_image_name_without_tag
base_name
,
version
=
image
.
split
(
':'
)
return
image
if
version_semver_like?
(
version
)
base_name
end
def
version_semver_like?
(
version
)
hash_like
=
/\A[0-9a-f]{32,128}\z/i
if
Gem
::
Version
.
correct?
(
version
)
!
hash_like
.
match?
(
version
)
else
false
end
end
end
end
end
...
...
ee/spec/lib/gitlab/ci/reports/security/locations/container_scanning_spec.rb
View file @
2193c771
...
...
@@ -16,4 +16,45 @@ RSpec.describe Gitlab::Ci::Reports::Security::Locations::ContainerScanning do
let
(
:expected_fingerprint
)
{
Digest
::
SHA1
.
hexdigest
(
'debian:9:glibc'
)
}
it_behaves_like
'vulnerability location'
describe
'#new_fingerprint'
do
sha1_of
=
->
(
input
)
{
Digest
::
SHA1
.
hexdigest
(
input
)
}
subject
{
described_class
.
new
(
**
params
)
}
specify
do
params
[
:image
]
=
'alpine:3.7.3'
expect
(
subject
.
new_fingerprint
).
to
eq
(
sha1_of
.
call
(
'alpine:3.7.3:glibc'
))
end
specify
do
params
[
:image
]
=
'alpine:3.7'
expect
(
subject
.
new_fingerprint
).
to
eq
(
sha1_of
.
call
(
'alpine:3.7:glibc'
))
end
specify
do
params
[
:image
]
=
'alpine:8101518288111119448185914762536722131810'
expect
(
subject
.
new_fingerprint
).
to
eq
(
sha1_of
.
call
(
'alpine:glibc'
))
end
specify
do
params
[
:image
]
=
'alpine:1.0.0-beta'
expect
(
subject
.
new_fingerprint
).
to
eq
(
sha1_of
.
call
(
'alpine:1.0.0-beta:glibc'
))
end
specify
do
params
[
:image
]
=
'registry.gitlab.com/gitlab-org/security-products/analyzers/klar/tmp:af864bd61230d3d694eb01d6205b268b4ad63ac0'
expect
(
subject
.
new_fingerprint
).
to
eq
(
sha1_of
.
call
(
'registry.gitlab.com/gitlab-org/security-products/analyzers/klar/tmp:glibc'
))
end
specify
do
params
[
:image
]
=
'registry.gitlab.com/gitlab-org/security-products/tests/container-scanning/master:ec301f43f14a2b477806875e49cfc4d3fa0d22c3'
expect
(
subject
.
new_fingerprint
).
to
eq
(
sha1_of
.
call
(
'registry.gitlab.com/gitlab-org/security-products/tests/container-scanning/master:glibc'
))
end
specify
do
params
[
:image
]
=
'registry.gitlab.com/gitlab-org/security-products/dast/webgoat-8.0@sha256:bc09fe2e0721dfaeee79364115aeedf2174cce0947b9ae5fe7c33312ee019a4e'
expect
(
subject
.
new_fingerprint
).
to
eq
(
sha1_of
.
call
(
'registry.gitlab.com/gitlab-org/security-products/dast/webgoat-8.0@sha256:glibc'
))
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