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

     1  package dotnet
     2  
     3  import (
     4  	"github.com/anchore/syft/syft/file"
     5  	"github.com/anchore/syft/syft/pkg/cataloger/internal/pe"
     6  )
     7  
     8  // logicalPE represents a PE file within the context of a .NET project (considering the deps.json file).
     9  type logicalPE struct {
    10  	pe.File
    11  
    12  	// TargetPath is the path is the deps.json target entry. This is not present in the PE file
    13  	// but instead is used in downstream processing to track associations between the PE file and the deps.json file.
    14  	TargetPath string
    15  }
    16  
    17  func readLogicalPE(reader file.LocationReadCloser) (*logicalPE, error) {
    18  	peFile, err := pe.Read(reader)
    19  	if err != nil {
    20  		return nil, err
    21  	}
    22  
    23  	if peFile == nil {
    24  		return nil, nil
    25  	}
    26  
    27  	return &logicalPE{
    28  		File: *peFile,
    29  	}, nil
    30  }