@@ -8,21 +8,61 @@ type Document struct {
88 Graph []spdx.Element `json:"-"` // Parsed elements from @graph
99
1010 // Parsed and categorized elements
11- SpdxDocument * spdx.SpdxDocument
12- Packages []* spdx.Package
13- Files []* spdx.File
14- Snippets []* spdx.Snippet
15- Relationships []* spdx.Relationship
16- Annotations []* spdx.Annotation
17- ExternalMaps []* spdx.ExternalMap
18- CreationInfo * spdx.CreationInfo
19- Organizations []* spdx.Organization
20- Persons []* spdx.Person
21- SoftwareAgents []* spdx.SoftwareAgent
22- Tools []* spdx.Tool
23- Licenses []* spdx.AnyLicenseInfo
24- IndividualElements []* spdx.IndividualElement
11+ SpdxDocument * spdx.SpdxDocument
12+ Packages []* spdx.Package
13+ Files []* spdx.File
14+ Snippets []* spdx.Snippet
15+ Relationships []* spdx.Relationship
16+ LifecycleScopedRelationships []* spdx.LifecycleScopedRelationship
17+ Annotations []* spdx.Annotation
18+ ExternalMaps []* spdx.ExternalMap
19+ CreationInfo * spdx.CreationInfo
20+ Organizations []* spdx.Organization
21+ Persons []* spdx.Person
22+ SoftwareAgents []* spdx.SoftwareAgent
23+ Tools []* spdx.Tool
24+ Bundles []* spdx.Bundle
25+ Boms []* spdx.Bom
26+ DictionaryEntries []* spdx.DictionaryEntry
27+ Hashes []* spdx.Hash
28+ PackageVerificationCodes []* spdx.PackageVerificationCode
29+ // Licensing-related elements
30+ AnyLicenseInfos []* spdx.AnyLicenseInfo
31+ ConjunctiveLicenseSets []* spdx.ConjunctiveLicenseSet
32+ CustomLicenses []* spdx.CustomLicense
33+ CustomLicenseAdditions []* spdx.CustomLicenseAddition
34+ DisjunctiveLicenseSets []* spdx.DisjunctiveLicenseSet
2535 IndividualLicensingInfos []* spdx.IndividualLicensingInfo
36+ ListedLicenses []* spdx.ListedLicense
37+ ListedLicenseExceptions []* spdx.ListedLicenseException
38+ LicenseExpressions []* spdx.LicenseExpression
39+ OrLaterOperators []* spdx.OrLaterOperator
40+ SimpleLicensingTexts []* spdx.SimpleLicensingText
41+ WithAdditionOperators []* spdx.WithAdditionOperator
42+
43+ // Security-related elements
44+ Vulnerabilities []* spdx.Vulnerability
45+ CvssV2VulnAssessments []* spdx.CvssV2VulnAssessmentRelationship
46+ CvssV3VulnAssessments []* spdx.CvssV3VulnAssessmentRelationship
47+ CvssV4VulnAssessments []* spdx.CvssV4VulnAssessmentRelationship
48+ EpssVulnAssessments []* spdx.EpssVulnAssessmentRelationship
49+ SsvcVulnAssessments []* spdx.SsvcVulnAssessmentRelationship
50+ ExploitCatalogVulnAssessments []* spdx.ExploitCatalogVulnAssessmentRelationship
51+ VexAffectedVulnAssessments []* spdx.VexAffectedVulnAssessmentRelationship
52+ VexFixedVulnAssessments []* spdx.VexFixedVulnAssessmentRelationship
53+ VexNotAffectedVulnAssessments []* spdx.VexNotAffectedVulnAssessmentRelationship
54+ VexUnderInvestigationVulnAssessments []* spdx.VexUnderInvestigationVulnAssessmentRelationship
55+
56+ // AI-related elements
57+ AiPackages []* spdx.AIPackage
58+ EnergyConsumptions []* spdx.EnergyConsumption
59+ EnergyConsumptionDescriptions []* spdx.EnergyConsumptionDescription
60+
61+ // Dataset-related elements
62+ DatasetPackages []* spdx.DatasetPackage
63+
64+ // Build-related elements
65+ Builds []* spdx.Build
2666
2767 // All elements indexed by SPDX ID
2868 ElementsByID map [string ]interface {}
@@ -32,13 +72,45 @@ type Document struct {
3272 RelationshipsToIndex map [string ][]* spdx.Relationship
3373
3474 // Element type indexes for O(1) lookups
35- PackagesByID map [string ]* spdx.Package
36- FilesByID map [string ]* spdx.File
37- OrganizationsByID map [string ]* spdx.Organization
38- PersonsByID map [string ]* spdx.Person
39- SoftwareAgentsByID map [string ]* spdx.SoftwareAgent
40- ToolsByID map [string ]* spdx.Tool
41- LicensesByID map [string ]* spdx.AnyLicenseInfo
75+ PackagesByID map [string ]* spdx.Package
76+ FilesByID map [string ]* spdx.File
77+ OrganizationsByID map [string ]* spdx.Organization
78+ PersonsByID map [string ]* spdx.Person
79+ SoftwareAgentsByID map [string ]* spdx.SoftwareAgent
80+ ToolsByID map [string ]* spdx.Tool
81+ AnyLicenseInfosByID map [string ]* spdx.AnyLicenseInfo
82+ ConjunctiveLicenseSetsByID map [string ]* spdx.ConjunctiveLicenseSet
83+ CustomLicensesByID map [string ]* spdx.CustomLicense
84+ CustomLicenseAdditionsByID map [string ]* spdx.CustomLicenseAddition
85+ DisjunctiveLicenseSetsByID map [string ]* spdx.DisjunctiveLicenseSet
86+ IndividualLicensingInfosByID map [string ]* spdx.IndividualLicensingInfo
87+ ListedLicensesByID map [string ]* spdx.ListedLicense
88+ ListedLicenseExceptionsByID map [string ]* spdx.ListedLicenseException
89+ LicenseExpressionsByID map [string ]* spdx.LicenseExpression
90+ OrLaterOperatorsByID map [string ]* spdx.OrLaterOperator
91+ SimpleLicensingTextsByID map [string ]* spdx.SimpleLicensingText
92+ WithAdditionOperatorsByID map [string ]* spdx.WithAdditionOperator
93+ VulnerabilitiesByID map [string ]* spdx.Vulnerability
94+ CvssV2VulnAssessmentsByID map [string ]* spdx.CvssV2VulnAssessmentRelationship
95+ CvssV3VulnAssessmentsByID map [string ]* spdx.CvssV3VulnAssessmentRelationship
96+ CvssV4VulnAssessmentsByID map [string ]* spdx.CvssV4VulnAssessmentRelationship
97+ EpssVulnAssessmentsByID map [string ]* spdx.EpssVulnAssessmentRelationship
98+ SsvcVulnAssessmentsByID map [string ]* spdx.SsvcVulnAssessmentRelationship
99+ ExploitCatalogVulnAssessmentsByID map [string ]* spdx.ExploitCatalogVulnAssessmentRelationship
100+ VexAffectedVulnAssessmentsByID map [string ]* spdx.VexAffectedVulnAssessmentRelationship
101+ VexFixedVulnAssessmentsByID map [string ]* spdx.VexFixedVulnAssessmentRelationship
102+ VexNotAffectedVulnAssessmentsByID map [string ]* spdx.VexNotAffectedVulnAssessmentRelationship
103+ VexUnderInvestigationVulnAssessmentsByID map [string ]* spdx.VexUnderInvestigationVulnAssessmentRelationship
104+ // AI-related maps
105+ AiPackagesByID map [string ]* spdx.AIPackage
106+ EnergyConsumptionsByID map [string ]* spdx.EnergyConsumption
107+ EnergyConsumptionDescriptionsByID map [string ]* spdx.EnergyConsumptionDescription
108+
109+ // Dataset-related maps
110+ DatasetPackagesByID map [string ]* spdx.DatasetPackage
111+
112+ // Build-related maps
113+ BuildsByID map [string ]* spdx.Build
42114}
43115
44116// GetName returns the document name
@@ -231,13 +303,13 @@ func (d *Document) GetLicensesFor(spdxID string) *LicenseInfo {
231303 for _ , rel := range d .GetRelationshipsFrom (spdxID ) {
232304 if rel .IsConcludedLicense () {
233305 for _ , to := range rel .To {
234- if lic := d .GetLicenseByID (to .GetSpdxID ()); lic != nil {
306+ if lic := d .GetAnyLicenseInfoByID (to .GetSpdxID ()); lic != nil {
235307 info .ConcludedLicenses = append (info .ConcludedLicenses , lic )
236308 }
237309 }
238310 } else if rel .IsDeclaredLicense () {
239311 for _ , to := range rel .To {
240- if lic := d .GetLicenseByID (to .GetSpdxID ()); lic != nil {
312+ if lic := d .GetAnyLicenseInfoByID (to .GetSpdxID ()); lic != nil {
241313 info .DeclaredLicenses = append (info .DeclaredLicenses , lic )
242314 }
243315 }
@@ -246,14 +318,14 @@ func (d *Document) GetLicensesFor(spdxID string) *LicenseInfo {
246318 return info
247319}
248320
249- // GetLicenseByID returns a license by its SPDX ID.
250- func (d * Document ) GetLicenseByID (spdxID string ) * spdx.AnyLicenseInfo {
251- if d .LicensesByID != nil {
252- if lic := d .LicensesByID [spdxID ]; lic != nil {
321+ // GetAnyLicenseInfoByID returns a license by its SPDX ID.
322+ func (d * Document ) GetAnyLicenseInfoByID (spdxID string ) * spdx.AnyLicenseInfo {
323+ if d .AnyLicenseInfosByID != nil {
324+ if lic := d .AnyLicenseInfosByID [spdxID ]; lic != nil {
253325 return lic
254326 }
255327 } else {
256- for _ , lic := range d .Licenses {
328+ for _ , lic := range d .AnyLicenseInfos {
257329 if lic .SpdxID == spdxID {
258330 return lic
259331 }
0 commit comments