Skip to content

Commit b52ed30

Browse files
authored
fix: Add missing relationship and pkg external info for SBOMs (#3582)
1 parent cc0e642 commit b52ed30

File tree

1 file changed

+49
-6
lines changed

1 file changed

+49
-6
lines changed

github/dependency_graph.go

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,52 @@ type CreationInfo struct {
2828
type RepoDependencies struct {
2929
SPDXID *string `json:"SPDXID,omitempty"`
3030
// Package name
31-
Name *string `json:"name,omitempty"`
32-
VersionInfo *string `json:"versionInfo,omitempty"`
33-
DownloadLocation *string `json:"downloadLocation,omitempty"`
34-
FilesAnalyzed *bool `json:"filesAnalyzed,omitempty"`
35-
LicenseConcluded *string `json:"licenseConcluded,omitempty"`
36-
LicenseDeclared *string `json:"licenseDeclared,omitempty"`
31+
Name *string `json:"name,omitempty"`
32+
VersionInfo *string `json:"versionInfo,omitempty"`
33+
DownloadLocation *string `json:"downloadLocation,omitempty"`
34+
FilesAnalyzed *bool `json:"filesAnalyzed,omitempty"`
35+
LicenseConcluded *string `json:"licenseConcluded,omitempty"`
36+
LicenseDeclared *string `json:"licenseDeclared,omitempty"`
37+
ExternalRefs []*PackageExternalRef `json:"externalRefs,omitempty"`
38+
}
39+
40+
// PackageExternalRef allows an Package to reference an external sources of additional information,
41+
// like asset identifiers, or downloadable content that are relevant to the package,
42+
// Example for identifiers (e.g., PURL/SWID/CPE) for a package in the SBOM.
43+
// https://spdx.github.io/spdx-spec/v2.3/package-information/#721-external-reference-field
44+
type PackageExternalRef struct {
45+
// ReferenceCategory specifies the external reference categories such
46+
// SECURITY", "PACKAGE-MANAGER", "PERSISTENT-ID", or "OTHER"
47+
// Example: "PACKAGE-MANAGER"
48+
ReferenceCategory string `json:"referenceCategory"`
49+
50+
// ReferenceType specifies the type of external reference.
51+
// For PACKAGE-MANAGER, it could be "purl"; other types include "cpe22Type", "swid", etc.
52+
ReferenceType string `json:"referenceType"`
53+
54+
// ReferenceLocator is the actual unique identifier or URI for the external reference.
55+
// Example: "pkg:golang/github.com/spf13/[email protected]"
56+
ReferenceLocator string `json:"referenceLocator"`
57+
}
58+
59+
// SBOMRelationship provides information about the relationship between two SPDX elements.
60+
// Element could be packages or files in the SBOM.
61+
// For example, to represent a relationship between two different Files, between a Package and a File,
62+
// between two Packages, or between one SPDXDocument and another SPDXDocument.
63+
// https://spdx.github.io/spdx-spec/v2.3/relationships-between-SPDX-elements/
64+
type SBOMRelationship struct {
65+
// SPDXElementID is the identifier of the SPDX element that has a relationship.
66+
// Example: "SPDXRef-github-interlynk-io-sbomqs-main-f43c98"
67+
SPDXElementID string `json:"spdxElementId"`
68+
69+
// RelatedSpdxElement is the identifier of the related SPDX element.
70+
// Example: "SPDXRef-golang-github.comspf13-cobra-1.8.1-75c946"
71+
RelatedSPDXElement string `json:"relatedSpdxElement"`
72+
73+
// RelationshipType describes the type of relationship between the two elements.
74+
// Such as "DEPENDS_ON", "DESCRIBES", "CONTAINS", etc., as defined by SPDX 2.3.
75+
// Example: "DEPENDS_ON", "CONTAINS", "DESCRIBES", etc.
76+
RelationshipType string `json:"relationshipType"`
3777
}
3878

3979
// SBOMInfo represents a software bill of materials (SBOM) using SPDX.
@@ -53,6 +93,9 @@ type SBOMInfo struct {
5393

5494
// List of packages dependencies
5595
Packages []*RepoDependencies `json:"packages,omitempty"`
96+
97+
// List of relationships between packages
98+
Relationships []*SBOMRelationship `json:"relationships,omitempty"`
5699
}
57100

58101
func (s SBOM) String() string {

0 commit comments

Comments
 (0)