Align SPDX export more with SPDX 2.2 specification (#743)

This commit is contained in:
Keith Zantow
2022-01-13 15:27:06 -05:00
committed by GitHub
parent 706f291679
commit f59af255e3
4 changed files with 28 additions and 26 deletions
+1 -1
View File
@@ -3,7 +3,7 @@ package model
type Element struct {
SPDXID string `json:"SPDXID"`
// Identify name of this SpdxElement.
Name string `json:"name"`
Name string `json:"name,omitempty"`
// Relationships referenced in the SPDX document
Relationships []Relationship `json:"relationships,omitempty"`
// Provide additional information about an SpdxElement.
@@ -2,7 +2,6 @@ package spdx22json
import (
"fmt"
"path/filepath"
"sort"
"strings"
"time"
@@ -131,8 +130,7 @@ func toFiles(s sbom.SBOM) []model.File {
results = append(results, model.File{
Item: model.Item{
Element: model.Element{
SPDXID: string(coordinates.ID()),
Name: filepath.Base(coordinates.RealPath),
SPDXID: model.ElementID(coordinates.ID()).String(),
Comment: comment,
},
// required, no attempt made to determine license information
@@ -206,9 +204,9 @@ func toRelationships(relationships []artifact.Relationship) (result []model.Rela
}
result = append(result, model.Relationship{
SpdxElementID: string(r.From.ID()),
SpdxElementID: model.ElementID(r.From.ID()).String(),
RelationshipType: relationshipType,
RelatedSpdxElement: string(r.To.ID()),
RelatedSpdxElement: model.ElementID(r.To.ID()).String(),
Comment: comment,
})
}