Skip to content

Commit

Permalink
SPDX 2.3 support (ko-build#803)
Browse files Browse the repository at this point in the history
This commit modifies the ko SPDX SBOMs to generate documents
conformant to version 2.3 of the spec. It makes use of the new
primary package purpose field to hint the packages as container
images.

Signed-off-by: Adolfo García Veytia (Puerco) <puerco@chainguard.dev>

Signed-off-by: Adolfo García Veytia (Puerco) <puerco@chainguard.dev>
  • Loading branch information
puerco authored Aug 26, 2022
1 parent ad1de20 commit 7e9eb07
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion internal/sbom/spdx.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ func GenerateImageSPDX(koVersion string, mod []byte, img oci.SignedImage) ([]byt
LicenseConcluded: NOASSERTION,
LicenseDeclared: NOASSERTION,
CopyrightText: NOASSERTION,
PrimaryPurpose: "CONTAINER",
ExternalRefs: []ExternalRef{{
Category: "PACKAGE-MANAGER",
Type: "purl",
Expand Down Expand Up @@ -235,6 +236,7 @@ func GenerateIndexSPDX(koVersion string, sii oci.SignedImageIndex) ([]byte, erro
LicenseConcluded: NOASSERTION,
LicenseDeclared: NOASSERTION,
CopyrightText: NOASSERTION,
PrimaryPurpose: "CONTAINER",
Checksums: []Checksum{{
Algorithm: strings.ToUpper(indexDigest.Algorithm),
Value: indexDigest.Hex,
Expand Down Expand Up @@ -312,6 +314,7 @@ func GenerateIndexSPDX(koVersion string, sii oci.SignedImageIndex) ([]byte, erro
LicenseConcluded: NOASSERTION,
LicenseDeclared: NOASSERTION,
CopyrightText: NOASSERTION,
PrimaryPurpose: "CONTAINER",
ExternalRefs: []ExternalRef{{
Category: "PACKAGE-MANAGER",
Type: "purl",
Expand Down Expand Up @@ -443,7 +446,7 @@ limitations under the License.

const (
NOASSERTION = "NOASSERTION"
Version = "SPDX-2.2"
Version = "SPDX-2.3"
)

type Document struct {
Expand Down Expand Up @@ -478,6 +481,7 @@ type Package struct {
Originator string `json:"originator,omitempty"`
SourceInfo string `json:"sourceInfo,omitempty"`
CopyrightText string `json:"copyrightText"`
PrimaryPurpose string `json:"primaryPackagePurpose,omitempty"`
HasFiles []string `json:"hasFiles,omitempty"`
LicenseInfoFromFiles []string `json:"licenseInfoFromFiles,omitempty"`
Checksums []Checksum `json:"checksums,omitempty"`
Expand Down

0 comments on commit 7e9eb07

Please sign in to comment.