Skip to content

Commit 35535ab

Browse files
authored
Update go modules and stabilize SBOM test assertions (#695)
* chore: update go-mod * fix: using regex to match uuids and versions * fix: pin go-containerregistry
1 parent 8044bea commit 35535ab

3 files changed

Lines changed: 297 additions & 281 deletions

File tree

build_test.go

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"io"
88
"os"
99
"path/filepath"
10+
"regexp"
1011
"testing"
1112

1213
"github.com/paketo-buildpacks/packit/v2"
@@ -173,34 +174,42 @@ func testBuild(t *testing.T, context spec.G, it spec.S) {
173174
Expect(spdx.Extension).To(Equal("spdx.json"))
174175
content, err = io.ReadAll(spdx.Content)
175176
Expect(err).NotTo(HaveOccurred())
176-
Expect(string(content)).To(MatchJSON(`{
177+
178+
versionPattern := regexp.MustCompile(`"licenseListVersion": "\d+\.\d+"`)
179+
contentReplaced := versionPattern.ReplaceAllString(string(content), `"licenseListVersion": "x.x"`)
180+
181+
uuidRegex := regexp.MustCompile(`[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}`)
182+
183+
contentReplaced = uuidRegex.ReplaceAllString(contentReplaced, "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")
184+
185+
Expect(string(contentReplaced)).To(MatchJSON(`{
177186
"SPDXID": "SPDXRef-DOCUMENT",
178187
"creationInfo": {
179188
"created": "0001-01-01T00:00:00Z",
180189
"creators": [
181190
"Organization: Anchore, Inc",
182191
"Tool: -"
183192
],
184-
"licenseListVersion": "3.27"
193+
"licenseListVersion": "x.x"
185194
},
186-
"packages": [
187-
{
188-
"SPDXID": "SPDXRef-DocumentRoot-Unknown-",
189-
"copyrightText": "NOASSERTION",
190-
"downloadLocation": "NOASSERTION",
191-
"filesAnalyzed": false,
192-
"licenseConcluded": "NOASSERTION",
193-
"licenseDeclared": "NOASSERTION",
194-
"name": "",
195-
"supplier": "NOASSERTION"
196-
}
197-
],
198195
"dataLicense": "CC0-1.0",
199-
"documentNamespace": "https://paketo.io/unknown-source-type/unknown-33ef57ff-45c2-53a8-8899-1c2b7e94d0dd",
196+
"documentNamespace": "https://paketo.io/unknown-source-type/unknown-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
200197
"name": "unknown",
198+
"packages": [
199+
{
200+
"SPDXID": "SPDXRef-DocumentRoot-Unknown-",
201+
"copyrightText": "NOASSERTION",
202+
"downloadLocation": "NOASSERTION",
203+
"filesAnalyzed": false,
204+
"licenseConcluded": "NOASSERTION",
205+
"licenseDeclared": "NOASSERTION",
206+
"name": "",
207+
"supplier": "NOASSERTION"
208+
}
209+
],
201210
"relationships": [
202211
{
203-
"relatedSpdxElement": "SPDXRef-DocumentRoot-Unknown-",
212+
"relatedSpdxElement": "SPDXRef-DocumentRoot-Unknown-",
204213
"relationshipType": "DESCRIBES",
205214
"spdxElementId": "SPDXRef-DOCUMENT"
206215
}

0 commit comments

Comments
 (0)