mirror of
https://github.com/anchore/syft.git
synced 2025-11-18 08:53:15 +01:00
add SBOM file path helper
Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
This commit is contained in:
parent
7bdd6e3ab0
commit
fc64a1a588
@ -23,3 +23,37 @@ type Artifacts struct {
|
|||||||
Secrets map[source.Coordinates][]file.SearchResult
|
Secrets map[source.Coordinates][]file.SearchResult
|
||||||
Distro *distro.Distro
|
Distro *distro.Distro
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func AllCoordinates(sbom SBOM) []source.Coordinates {
|
||||||
|
set := source.NewCoordinateSet()
|
||||||
|
for coordinates := range sbom.Artifacts.FileMetadata {
|
||||||
|
set.Add(coordinates)
|
||||||
|
}
|
||||||
|
for coordinates := range sbom.Artifacts.FileContents {
|
||||||
|
set.Add(coordinates)
|
||||||
|
}
|
||||||
|
for coordinates := range sbom.Artifacts.FileClassifications {
|
||||||
|
set.Add(coordinates)
|
||||||
|
}
|
||||||
|
for coordinates := range sbom.Artifacts.FileDigests {
|
||||||
|
set.Add(coordinates)
|
||||||
|
}
|
||||||
|
for _, relationship := range sbom.Relationships {
|
||||||
|
for _, coordinates := range extractCoordinates(relationship) {
|
||||||
|
set.Add(coordinates)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return set.ToSlice()
|
||||||
|
}
|
||||||
|
|
||||||
|
func extractCoordinates(relationship artifact.Relationship) (results []source.Coordinates) {
|
||||||
|
if coordinates, exists := relationship.From.(source.Coordinates); exists {
|
||||||
|
results = append(results, coordinates)
|
||||||
|
}
|
||||||
|
|
||||||
|
if coordinates, exists := relationship.To.(source.Coordinates); exists {
|
||||||
|
results = append(results, coordinates)
|
||||||
|
}
|
||||||
|
|
||||||
|
return results
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user