github.com/anchore/syft@v1.38.2/syft/pkg/cataloger/dotnet/binary_cataloger.go (about)

     1  package dotnet
     2  
     3  import (
     4  	"context"
     5  
     6  	"github.com/anchore/syft/internal/unknown"
     7  	"github.com/anchore/syft/syft/artifact"
     8  	"github.com/anchore/syft/syft/file"
     9  	"github.com/anchore/syft/syft/pkg"
    10  )
    11  
    12  // binary cataloger will search for .dll and .exe files and create packages based off of the version resources embedded
    13  // as a resource directory within the executable. If there is no evidence of a .NET runtime (a CLR header) then no
    14  // package will be created.
    15  //
    16  // Deprecated: use depsBinaryCataloger instead which combines the PE and deps.json data which yields more accurate results (will be removed in syft v2.0).
    17  type binaryCataloger struct {
    18  }
    19  
    20  func (c binaryCataloger) Name() string {
    21  	return "dotnet-portable-executable-cataloger"
    22  }
    23  
    24  func (c binaryCataloger) Catalog(_ context.Context, resolver file.Resolver) ([]pkg.Package, []artifact.Relationship, error) {
    25  	var unknowns error
    26  	peFiles, ldpeUnknownErr, err := findPEFiles(resolver)
    27  	if err != nil {
    28  		return nil, nil, err
    29  	}
    30  	if ldpeUnknownErr != nil {
    31  		unknowns = unknown.Join(unknowns, ldpeUnknownErr)
    32  	}
    33  
    34  	var pkgs []pkg.Package
    35  	for _, pe := range peFiles {
    36  		pkgs = append(pkgs, newDotnetBinaryPackage(pe.VersionResources, pe.Location))
    37  	}
    38  
    39  	return pkgs, nil, unknowns
    40  }