summaryrefslogtreecommitdiff
path: root/pkg/sif/sif.go
diff options
context:
space:
mode:
authorReinhard Tartler <siretart@tauware.de>2022-11-26 11:30:56 -0500
committerReinhard Tartler <siretart@tauware.de>2022-11-26 11:30:56 -0500
commitd6caca7a938130982d713b6be0ca0823f46b0b4c (patch)
treedc35be0da27e89eb9208a44aabbd24b00df629db /pkg/sif/sif.go
parentdc1634f506b369be461ff65c77b2a804e06df87f (diff)
parentdab73e7c0f7576075e7f073f71cc3f32a656b161 (diff)
Update upstream source from tag 'upstream/2.8.3'
Update to upstream version '2.8.3' with Debian dir 7536ac56d7f18b29fd849f99100170df028e78fe
Diffstat (limited to 'pkg/sif/sif.go')
-rw-r--r--pkg/sif/sif.go168
1 files changed, 104 insertions, 64 deletions
diff --git a/pkg/sif/sif.go b/pkg/sif/sif.go
index 704acee..2d1c209 100644
--- a/pkg/sif/sif.go
+++ b/pkg/sif/sif.go
@@ -1,4 +1,4 @@
-// Copyright (c) 2018-2021, Sylabs Inc. All rights reserved.
+// Copyright (c) 2018-2022, Sylabs Inc. All rights reserved.
// Copyright (c) 2017, SingularityWare, LLC. All rights reserved.
// Copyright (c) 2017, Yannick Cote <yhcote@gmail.com> All rights reserved.
// This software is licensed under a 3-clause BSD license. Please consult the
@@ -10,69 +10,68 @@
//
// Layout of a SIF file (example):
//
-// .================================================.
-// | GLOBAL HEADER: Sifheader |
-// | - launch: "#!/usr/bin/env..." |
-// | - magic: "SIF_MAGIC" |
-// | - version: "1" |
-// | - arch: "4" |
-// | - uuid: b2659d4e-bd50-4ea5-bd17-eec5e54f918e |
-// | - ctime: 1504657553 |
-// | - mtime: 1504657653 |
-// | - ndescr: 3 |
-// | - descroff: 120 | --.
-// | - descrlen: 432 | |
-// | - dataoff: 4096 | |
-// | - datalen: 619362 | |
-// |------------------------------------------------| <-'
-// | DESCR[0]: Sifdeffile |
-// | - Sifcommon |
-// | - datatype: DATA_DEFFILE |
-// | - id: 1 |
-// | - groupid: 1 |
-// | - link: NONE |
-// | - fileoff: 4096 | --.
-// | - filelen: 222 | |
-// |------------------------------------------------| <-----.
-// | DESCR[1]: Sifpartition | | |
-// | - Sifcommon | | |
-// | - datatype: DATA_PARTITION | | |
-// | - id: 2 | | |
-// | - groupid: 1 | | |
-// | - link: NONE | | |
-// | - fileoff: 4318 | ----. |
-// | - filelen: 618496 | | | |
-// | - fstype: Squashfs | | | |
-// | - parttype: System | | | |
-// | - content: Linux | | | |
-// |------------------------------------------------| | | |
-// | DESCR[2]: Sifsignature | | | |
-// | - Sifcommon | | | |
-// | - datatype: DATA_SIGNATURE | | | |
-// | - id: 3 | | | |
-// | - groupid: NONE | | | |
-// | - link: 2 | ------'
-// | - fileoff: 622814 | ------.
-// | - filelen: 644 | | | |
-// | - hashtype: SHA384 | | | |
-// | - entity: @ | | | |
-// |------------------------------------------------| <-' | |
-// | Definition file data | | |
-// | . | | |
-// | . | | |
-// | . | | |
-// |------------------------------------------------| <---' |
-// | File system partition image | |
-// | . | |
-// | . | |
-// | . | |
-// |------------------------------------------------| <-----'
-// | Signed verification data |
-// | . |
-// | . |
-// | . |
-// `================================================'
-//
+// .================================================.
+// | GLOBAL HEADER: Sifheader |
+// | - launch: "#!/usr/bin/env..." |
+// | - magic: "SIF_MAGIC" |
+// | - version: "1" |
+// | - arch: "4" |
+// | - uuid: b2659d4e-bd50-4ea5-bd17-eec5e54f918e |
+// | - ctime: 1504657553 |
+// | - mtime: 1504657653 |
+// | - ndescr: 3 |
+// | - descroff: 120 | --.
+// | - descrlen: 432 | |
+// | - dataoff: 4096 | |
+// | - datalen: 619362 | |
+// |------------------------------------------------| <-'
+// | DESCR[0]: Sifdeffile |
+// | - Sifcommon |
+// | - datatype: DATA_DEFFILE |
+// | - id: 1 |
+// | - groupid: 1 |
+// | - link: NONE |
+// | - fileoff: 4096 | --.
+// | - filelen: 222 | |
+// |------------------------------------------------| <-----.
+// | DESCR[1]: Sifpartition | | |
+// | - Sifcommon | | |
+// | - datatype: DATA_PARTITION | | |
+// | - id: 2 | | |
+// | - groupid: 1 | | |
+// | - link: NONE | | |
+// | - fileoff: 4318 | ----. |
+// | - filelen: 618496 | | | |
+// | - fstype: Squashfs | | | |
+// | - parttype: System | | | |
+// | - content: Linux | | | |
+// |------------------------------------------------| | | |
+// | DESCR[2]: Sifsignature | | | |
+// | - Sifcommon | | | |
+// | - datatype: DATA_SIGNATURE | | | |
+// | - id: 3 | | | |
+// | - groupid: NONE | | | |
+// | - link: 2 | ------'
+// | - fileoff: 622814 | ------.
+// | - filelen: 644 | | | |
+// | - hashtype: SHA384 | | | |
+// | - entity: @ | | | |
+// |------------------------------------------------| <-' | |
+// | Definition file data | | |
+// | . | | |
+// | . | | |
+// | . | | |
+// |------------------------------------------------| <---' |
+// | File system partition image | |
+// | . | |
+// | . | |
+// | . | |
+// |------------------------------------------------| <-----'
+// | Signed verification data |
+// | . |
+// | . |
+// | . |
+// `================================================'
package sif
import (
@@ -133,6 +132,7 @@ const (
DataGenericJSON // generic JSON meta-data
DataGeneric // generic / raw data
DataCryptoMessage // cryptographic message data object
+ DataSBOM // software bill of materials
)
// String returns a human-readable representation of t.
@@ -154,6 +154,8 @@ func (t DataType) String() string {
return "Generic/Raw"
case DataCryptoMessage:
return "Cryptographic Message"
+ case DataSBOM:
+ return "SBOM"
}
return "Unknown"
}
@@ -268,6 +270,44 @@ func (t MessageType) String() string {
return "Unknown"
}
+// SBOMFormat represents the format used to store an SBOM object.
+type SBOMFormat int32
+
+// List of supported SBOM formats.
+const (
+ SBOMFormatCycloneDXJSON SBOMFormat = iota + 1 // CycloneDX (JSON)
+ SBOMFormatCycloneDXXML // CycloneDX (XML)
+ SBOMFormatGitHubJSON // GitHub dependency snapshot (JSON)
+ SBOMFormatSPDXJSON // SPDX (JSON)
+ SBOMFormatSPDXRDF // SPDX (RDF/xml)
+ SBOMFormatSPDXTagValue // SPDX (tag/value)
+ SBOMFormatSPDXYAML // SPDX (YAML)
+ SBOMFormatSyftJSON // Syft (JSON)
+)
+
+// String returns a human-readable representation of f.
+func (f SBOMFormat) String() string {
+ switch f {
+ case SBOMFormatCycloneDXJSON:
+ return "cyclonedx-json"
+ case SBOMFormatCycloneDXXML:
+ return "cyclonedx-xml"
+ case SBOMFormatGitHubJSON:
+ return "github-json"
+ case SBOMFormatSPDXJSON:
+ return "spdx-json"
+ case SBOMFormatSPDXRDF:
+ return "spdx-rdf"
+ case SBOMFormatSPDXTagValue:
+ return "spdx-tag-value"
+ case SBOMFormatSPDXYAML:
+ return "spdx-yaml"
+ case SBOMFormatSyftJSON:
+ return "syft-json"
+ }
+ return "unknown"
+}
+
// header describes a loaded SIF file.
type header struct {
LaunchScript [hdrLaunchLen]byte