Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(purl): use epoch in qualifier #3913

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions integration/sbom_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ func TestSBOM(t *testing.T) {
Target: "testdata/fixtures/sbom/centos-7-spdx.txt (centos 7.6.1810)",
Vulnerabilities: []types.DetectedVulnerability{
{Ref: "pkg:rpm/centos/[email protected]?arch=x86_64&distro=centos-7.6.1810"},
{Ref: "pkg:rpm/centos/openssl-libs@1:1.0.2k-16.el7?arch=x86_64&distro=centos-7.6.1810"},
{Ref: "pkg:rpm/centos/openssl-libs@1:1.0.2k-16.el7?arch=x86_64&distro=centos-7.6.1810"},
{Ref: "pkg:rpm/centos/[email protected]?arch=x86_64&epoch=1&distro=centos-7.6.1810"},
{Ref: "pkg:rpm/centos/[email protected]?arch=x86_64&epoch=1&distro=centos-7.6.1810"},
},
},
},
Expand All @@ -92,8 +92,8 @@ func TestSBOM(t *testing.T) {
Target: "testdata/fixtures/sbom/centos-7-spdx.json (centos 7.6.1810)",
Vulnerabilities: []types.DetectedVulnerability{
{Ref: "pkg:rpm/centos/[email protected]?arch=x86_64&distro=centos-7.6.1810"},
{Ref: "pkg:rpm/centos/openssl-libs@1:1.0.2k-16.el7?arch=x86_64&distro=centos-7.6.1810"},
{Ref: "pkg:rpm/centos/openssl-libs@1:1.0.2k-16.el7?arch=x86_64&distro=centos-7.6.1810"},
{Ref: "pkg:rpm/centos/[email protected]?arch=x86_64&epoch=1&distro=centos-7.6.1810"},
{Ref: "pkg:rpm/centos/[email protected]?arch=x86_64&epoch=1&distro=centos-7.6.1810"},
},
},
},
Expand Down
4 changes: 2 additions & 2 deletions integration/testdata/centos-7-cyclonedx.json.golden
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@
"updated": "2021-01-20T15:15:00+00:00",
"affects": [
{
"ref": "urn:cdx:1455c02d-64ca-453e-a5df-ddfb70a7c804/1#pkg:rpm/centos/openssl-libs@1:1.0.2k-16.el7?arch=x86_64\u0026distro=centos-7.6.1810",
"ref": "urn:cdx:1455c02d-64ca-453e-a5df-ddfb70a7c804/1#pkg:rpm/centos/[email protected]?arch=x86_64\u0026epoch=1\u0026distro=centos-7.6.1810",
"versions": [
{
"version": "1:1.0.2k-16.el7",
Expand Down Expand Up @@ -514,7 +514,7 @@
"updated": "2020-08-24T17:37:00+00:00",
"affects": [
{
"ref": "urn:cdx:1455c02d-64ca-453e-a5df-ddfb70a7c804/1#pkg:rpm/centos/openssl-libs@1:1.0.2k-16.el7?arch=x86_64\u0026distro=centos-7.6.1810",
"ref": "urn:cdx:1455c02d-64ca-453e-a5df-ddfb70a7c804/1#pkg:rpm/centos/[email protected]?arch=x86_64\u0026epoch=1\u0026distro=centos-7.6.1810",
"versions": [
{
"version": "1:1.0.2k-16.el7",
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"payloadType":"application/vnd.in-toto+json","payload":"eyJfdHlwZSI6Imh0dHBzOi8vaW4tdG90by5pby9TdGF0ZW1lbnQvdjAuMSIsInByZWRpY2F0ZVR5cGUiOiJodHRwczovL2N5Y2xvbmVkeC5vcmcvYm9tIiwic3ViamVjdCI6W3sibmFtZSI6ImdoY3IuaW8vYXF1YXNlY3VyaXR5L3RyaXZ5LXRlc3QtaW1hZ2VzIiwiZGlnZXN0Ijp7InNoYTI1NiI6IjYyZDllMWMyZGFhOTExNjYxMzliNTE1NzdmZTRmNGY2YjRjYzQxYTNhMmM3ZmMzNmJkODk1ZTJhMTdhM2U0ZTYifX1dLCJwcmVkaWNhdGUiOnsiRGF0YSI6eyJib21Gb3Jt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WM4NTljMzk1ODgyZWVjNDlkNTA2NTEyNDRlMzQyY2Q2YzY4YTVjNzgwOTc4NWY0MjcifSx7Im5hbWUiOiJhcXVhc2VjdXJpdHk6dHJpdnk6RGlmZklEIiwidmFsdWUiOiJzaGEyNTY6ODkxNjlkODdkYmUyYjcyYmE0MmJmYmIzNTc5Yzk1NzMyMmJhY2EyOGUwM2ExZTU1ODA3NjU0MmExYzFiMmI0YSJ9XSwidHlwZSI6ImNvbnRhaW5lciJ9LCJ0aW1lc3RhbXAiOiIyMDIyLTA2LTE0VDE1OjA4OjQ4KzAwOjAwIiwidG9vbHMiOlt7Im5hbWUiOiJ0cml2eSIsInZlbmRvciI6ImFxdWFzZWN1cml0eSIsInZlcnNpb24iOiJkZXYifV19LCJzZXJpYWxOdW1iZXIiOiJ1cm46dXVpZDoxNDU1YzAyZC02NGNhLTQ1M2UtYTVkZi1kZGZiNzBhN2M4MDQiLCJzcGVjVmVyc2lvbiI6IjEuNCIsInZlcnNpb24iOjF9fQ==","signatures":[{"keyid":"","sig":"MEUCIQCtj78dipe+yzdlIsmwjn9QeaBTAPQacwIJAWfnrtp7FwIgcViOUgPA0WFYjimrIl7vbygdSpduM+ZzY3cqrDciH1U="}]}
8 changes: 4 additions & 4 deletions integration/testdata/fixtures/sbom/centos-7-cyclonedx.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,16 @@
]
},
{
"bom-ref": "pkg:rpm/centos/openssl-libs@1:1.0.2k-16.el7?arch=x86_64&distro=centos-7.6.1810",
"bom-ref": "pkg:rpm/centos/[email protected]?arch=x86_64&epoch=1&distro=centos-7.6.1810",
"type": "library",
"name": "openssl-libs",
"version": "1:1.0.2k-16.el7",
"version": "1.0.2k-16.el7",
"licenses": [
{
"expression": "OpenSSL"
}
],
"purl": "pkg:rpm/centos/openssl-libs@1:1.0.2k-16.el7?arch=x86_64&distro=centos-7.6.1810",
"purl": "pkg:rpm/centos/[email protected]?arch=x86_64&epoch=1&distro=centos-7.6.1810",
"properties": [
{
"name": "aquasecurity:trivy:SrcName",
Expand Down Expand Up @@ -127,7 +127,7 @@
"ref": "0175f732-df9d-4bb8-9f56-870898e3ff89",
"dependsOn": [
"pkg:rpm/centos/[email protected]?arch=x86_64&distro=centos-7.6.1810",
"pkg:rpm/centos/openssl-libs@1:1.0.2k-16.el7?arch=x86_64&distro=centos-7.6.1810"
"pkg:rpm/centos/[email protected]?arch=x86_64&epoch=1&distro=centos-7.6.1810"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions integration/testdata/fixtures/sbom/centos-7-spdx.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"externalRefs": [
{
"referenceCategory": "PACKAGE-MANAGER",
"referenceLocator": "pkg:rpm/centos/openssl-libs@1:1.0.2k-16.el7?arch=x86_64\u0026distro=centos-7.6.1810",
"referenceLocator": "pkg:rpm/centos/[email protected]?arch=x86_64\u0026epoch=1\u0026distro=centos-7.6.1810",
"referenceType": "purl"
}
],
Expand All @@ -67,7 +67,7 @@
"licenseDeclared": "OpenSSL",
"name": "openssl-libs",
"sourceInfo": "built package from: openssl-libs 1:1.0.2k-16.el7",
"versionInfo": "1.0.2k"
"versionInfo": "1:1.0.2k-19.el7"
}
],
"relationships": [
Expand Down
2 changes: 1 addition & 1 deletion integration/testdata/fixtures/sbom/centos-7-spdx.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ FilesAnalyzed: false
PackageSourceInfo: built package from: openssl-libs 1:1.0.2k-16.el7
PackageLicenseConcluded: OpenSSL
PackageLicenseDeclared: OpenSSL
ExternalRef: PACKAGE-MANAGER purl pkg:rpm/centos/openssl-libs@1:1.0.2k-16.el7?arch=x86_64&distro=centos-7.6.1810
ExternalRef: PACKAGE-MANAGER purl pkg:rpm/centos/[email protected]?arch=x86_64&epoch=1&distro=centos-7.6.1810
PackageAttributionText: PkgID: [email protected]_64
PackageAttributionText: LayerDigest: sha256:ac9208207adaac3a48e54a4dc6b49c69e78c3072d2b3add7efdabf814db2133b
PackageAttributionText: LayerDiffID: sha256:89169d87dbe2b72ba42bfbb3579c957322baca28e03a1e558076542a1c1b2b4a
Expand Down
14 changes: 13 additions & 1 deletion pkg/purl/purl.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package purl

import (
"fmt"
"strconv"
"strings"

cn "github.com/google/go-containerregistry/pkg/name"
Expand Down Expand Up @@ -48,14 +49,18 @@ func (p *PackageURL) Package() *ftypes.Package {
pkg.Arch = q.Value
case "modularitylabel":
pkg.Modularitylabel = q.Value
case "epoch":
epoch, err := strconv.Atoi(q.Value)
if err == nil {
pkg.Epoch = epoch
}
}
}

if p.Type == packageurl.TypeRPM {
rpmVer := version.NewVersion(p.Version)
pkg.Release = rpmVer.Release()
pkg.Version = rpmVer.Version()
pkg.Epoch = rpmVer.Epoch()
}

// Return packages without namespace.
Expand Down Expand Up @@ -134,6 +139,7 @@ func NewPackageURL(t string, metadata types.Metadata, pkg ftypes.Package) (Packa
var qualifiers packageurl.Qualifiers
if metadata.OS != nil {
qualifiers = parseQualifier(pkg)
pkg.Epoch = 0 // we moved Epoch to qualifiers so we don't need it in version
}

ptype := purlType(t)
Expand Down Expand Up @@ -343,6 +349,12 @@ func parseQualifier(pkg ftypes.Package) packageurl.Qualifiers {
Value: pkg.Arch,
})
}
if pkg.Epoch != 0 {
qualifiers = append(qualifiers, packageurl.Qualifier{
Key: "epoch",
Value: strconv.Itoa(pkg.Epoch),
})
}
return qualifiers
}

Expand Down
14 changes: 11 additions & 3 deletions pkg/purl/purl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,12 @@ func TestNewPackageURL(t *testing.T) {
Name: "acl",
Version: "2.2.53",
Release: "1.el8",
Epoch: 0,
Epoch: 1,
Arch: "aarch64",
SrcName: "acl",
SrcVersion: "2.2.53",
SrcRelease: "1.el8",
SrcEpoch: 0,
SrcEpoch: 1,
Modularitylabel: "",
},

Expand All @@ -246,6 +246,10 @@ func TestNewPackageURL(t *testing.T) {
Key: "arch",
Value: "aarch64",
},
{
Key: "epoch",
Value: "1",
},
{
Key: "distro",
Value: "redhat-8",
Expand Down Expand Up @@ -437,7 +441,7 @@ func TestFromString(t *testing.T) {
},
{
name: "happy path for apk",
purl: "pkg:apk/alpine/[email protected]?distro=3.14.2",
purl: "pkg:apk/alpine/[email protected]?distro=3.14.2&epoch=1",
want: purl.PackageURL{
PackageURL: packageurl.PackageURL{
Type: string(analyzer.TypeApk),
Expand All @@ -449,6 +453,10 @@ func TestFromString(t *testing.T) {
Key: "distro",
Value: "3.14.2",
},
{
Key: "epoch",
Value: "1",
},
},
},
},
Expand Down
8 changes: 4 additions & 4 deletions pkg/sbom/cyclonedx/marshal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -681,14 +681,14 @@ func TestMarshaler_Marshal(t *testing.T) {
},
Components: &[]cdx.Component{
{
BOMRef: "pkg:rpm/centos/acl@1:2.2.53-1.el8?arch=aarch64&distro=centos-8.3.2011",
BOMRef: "pkg:rpm/centos/[email protected]?arch=aarch64&epoch=1&distro=centos-8.3.2011",
Type: cdx.ComponentTypeLibrary,
Name: "acl",
Version: "1:2.2.53-1.el8",
Version: "2.2.53-1.el8",
Licenses: &cdx.Licenses{
cdx.LicenseChoice{Expression: "GPLv2+"},
},
PackageURL: "pkg:rpm/centos/acl@1:2.2.53-1.el8?arch=aarch64&distro=centos-8.3.2011",
PackageURL: "pkg:rpm/centos/[email protected]?arch=aarch64&epoch=1&distro=centos-8.3.2011",
Properties: &[]cdx.Property{
{
Name: "aquasecurity:trivy:PkgType",
Expand Down Expand Up @@ -775,7 +775,7 @@ func TestMarshaler_Marshal(t *testing.T) {
{
Ref: "3ff14136-e09f-4df9-80ea-000000000003",
Dependencies: &[]string{
"pkg:rpm/centos/acl@1:2.2.53-1.el8?arch=aarch64&distro=centos-8.3.2011",
"pkg:rpm/centos/[email protected]?arch=aarch64&epoch=1&distro=centos-8.3.2011",
},
},
{
Expand Down
2 changes: 1 addition & 1 deletion pkg/sbom/spdx/marshal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ func TestMarshaler_Marshal(t *testing.T) {
{
Category: tspdx.CategoryPackageManager,
RefType: tspdx.RefTypePurl,
Locator: "pkg:rpm/centos/acl@1:2.2.53-1.el8?arch=aarch64&distro=centos-8.3.2011",
Locator: "pkg:rpm/centos/[email protected]?arch=aarch64&epoch=1&distro=centos-8.3.2011",
},
},
PackageSourceInfo: "built package from: acl 1:2.2.53-1.el8",
Expand Down