github.com/anchore/syft@v1.4.2-0.20240516191711-1bec1fc5d397/internal/relationship/evident_by.go (about)

     1  package relationship
     2  
     3  import (
     4  	"github.com/anchore/syft/syft/artifact"
     5  	"github.com/anchore/syft/syft/pkg"
     6  )
     7  
     8  func evidentBy(catalog *pkg.Collection) []artifact.Relationship {
     9  	var edges []artifact.Relationship
    10  	for _, p := range catalog.Sorted() {
    11  		for _, l := range p.Locations.ToSlice() {
    12  			if v, exists := l.Annotations[pkg.EvidenceAnnotationKey]; !exists || v != pkg.PrimaryEvidenceAnnotation {
    13  				// skip non-primary evidence from being expressed as a relationship.
    14  				// note: this may be configurable in the future.
    15  				continue
    16  			}
    17  			edges = append(edges, artifact.Relationship{
    18  				From: p,
    19  				To:   l.Coordinates,
    20  				Type: artifact.EvidentByRelationship,
    21  			})
    22  		}
    23  	}
    24  
    25  	return edges
    26  }