Skip to content

Commit 821eb7d

Browse files
authored
feat: add support for CycloneDX 1.5 (#480)
Signed-off-by: Miguel Martinez Trivino <[email protected]>
1 parent 776feea commit 821eb7d

File tree

4 files changed

+9883
-15
lines changed

4 files changed

+9883
-15
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ require (
77
code.cloudfoundry.org/bytefmt v0.0.0-20230612151507-41ef4d1f67a4
88
cuelang.org/go v0.6.0
99
entgo.io/ent v0.12.3
10-
github.com/CycloneDX/cyclonedx-go v0.7.2
10+
github.com/CycloneDX/cyclonedx-go v0.8.0
1111
github.com/adrg/xdg v0.4.0
1212
github.com/aws/aws-sdk-go-v2 v1.21.2
1313
github.com/aws/aws-sdk-go-v2/config v1.19.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ github.com/AzureAD/microsoft-authentication-library-for-go v1.2.0 h1:hVeq+yCyUi+
108108
github.com/AzureAD/microsoft-authentication-library-for-go v1.2.0/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI=
109109
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
110110
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
111-
github.com/CycloneDX/cyclonedx-go v0.7.2 h1:kKQ0t1dPOlugSIYVOMiMtFqeXI2wp/f5DBIdfux8gnQ=
112-
github.com/CycloneDX/cyclonedx-go v0.7.2/go.mod h1:K2bA+324+Og0X84fA8HhN2X066K7Bxz4rpMQ4ZhjtSk=
111+
github.com/CycloneDX/cyclonedx-go v0.8.0 h1:FyWVj6x6hoJrui5uRQdYZcSievw3Z32Z88uYzG/0D6M=
112+
github.com/CycloneDX/cyclonedx-go v0.8.0/go.mod h1:K2bA+324+Og0X84fA8HhN2X066K7Bxz4rpMQ4ZhjtSk=
113113
github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60=
114114
github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
115115
github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=

internal/attestation/crafter/materials/cyclonedxjson_test.go

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,11 @@ func TestNewCyclonedxJSONCrafter(t *testing.T) {
6565

6666
func TestCyclonedxJSONCraft(t *testing.T) {
6767
testCases := []struct {
68-
name string
69-
filePath string
70-
wantErr string
68+
name string
69+
filePath string
70+
wantErr string
71+
wantFilename string
72+
wantDigest string
7173
}{
7274
{
7375
name: "invalid path",
@@ -85,8 +87,16 @@ func TestCyclonedxJSONCraft(t *testing.T) {
8587
wantErr: "unexpected material type",
8688
},
8789
{
88-
name: "valid artifact type",
89-
filePath: "./testdata/sbom.cyclonedx.json",
90+
name: "1.4 version",
91+
filePath: "./testdata/sbom.cyclonedx.json",
92+
wantDigest: "sha256:16159bb881eb4ab7eb5d8afc5350b0feeed1e31c0a268e355e74f9ccbe885e0c",
93+
wantFilename: "sbom.cyclonedx.json",
94+
},
95+
{
96+
name: "1.5 version",
97+
filePath: "./testdata/sbom.cyclonedx-1.5.json",
98+
wantDigest: "sha256:5ca3508f02893b0419b266927f66c7b9dd8b11dbea7faf7cdb9169df8f69d8e3",
99+
wantFilename: "sbom.cyclonedx-1.5.json",
90100
},
91101
}
92102

@@ -102,10 +112,7 @@ func TestCyclonedxJSONCraft(t *testing.T) {
102112
uploader := mUploader.NewUploader(t)
103113
if tc.wantErr == "" {
104114
uploader.On("UploadFile", context.TODO(), tc.filePath).
105-
Return(&casclient.UpDownStatus{
106-
Digest: "deadbeef",
107-
Filename: "sbom.cyclonedx.json",
108-
}, nil)
115+
Return(&casclient.UpDownStatus{}, nil)
109116
}
110117

111118
backend := &casclient.CASBackend{Uploader: uploader}
@@ -123,9 +130,9 @@ func TestCyclonedxJSONCraft(t *testing.T) {
123130
assert.True(got.UploadedToCas)
124131

125132
// The result includes the digest reference
126-
assert.Equal(got.GetArtifact(), &attestationApi.Attestation_Material_Artifact{
127-
Id: "test", Digest: "sha256:16159bb881eb4ab7eb5d8afc5350b0feeed1e31c0a268e355e74f9ccbe885e0c", Name: "sbom.cyclonedx.json",
128-
})
133+
assert.Equal(&attestationApi.Attestation_Material_Artifact{
134+
Id: "test", Digest: tc.wantDigest, Name: tc.wantFilename,
135+
}, got.GetArtifact())
129136
})
130137
}
131138
}

0 commit comments

Comments
 (0)