Skip to content

Commit

Permalink
Added topics to enrichment
Browse files Browse the repository at this point in the history
  • Loading branch information
garethr committed May 1, 2023
1 parent 17f2afd commit f6a19ff
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
| :heavy_check_mark: | RegistryUrl | ExternalReferences type=distribution |
| :heavy_check_mark: | RepositoryUrl | ExternalReferences type=vcs |
| :heavy_check_mark: | DocumentationUrl | ExternalReferences type=documentation |
| | RepoMetadata.topics | Properties |
| :heavy_check_mark: | RepoMetadata.topics | Properties |
| | RepoMetadata.metadata.files.license | Licenses |
| | RepoMetadata.metadata.files.license | ExternalReferences type=license |
| | RepoMetadata.metadata.files.code_of_conduct | ExternalReferences type=other |
Expand Down
15 changes: 15 additions & 0 deletions lib/enrich.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,20 @@ func enrichLocation(component cdx.Component, packageData packages.Package) cdx.C
return component
}

func enrichTopics(component cdx.Component, packageData packages.Package) cdx.Component {
if packageData.RepoMetadata != nil {
meta := *packageData.RepoMetadata

if topics, ok := meta["topics"].([]interface{}); ok {
for _, topic := range topics {
component = enrichProperty(component, "ecosystems:topic", topic.(string))
}
}
return component
}
return component
}

func enrichComponents(bom *cdx.BOM, enrichFuncs []func(cdx.Component, packages.Package) cdx.Component) {
wg := sizedwaitgroup.New(20)
newComponents := make([]cdx.Component, len(*bom.Components))
Expand Down Expand Up @@ -148,6 +162,7 @@ func EnrichSBOM(bom *cdx.BOM) *cdx.BOM {
enrichLatestReleasePublishedAt,
enrichRepoArchived,
enrichLocation,
enrichTopics,
}

enrichComponents(bom, enrichFuncs)
Expand Down

0 comments on commit f6a19ff

Please sign in to comment.