Documentation
¶
Index ¶
- Constants
- type ContentResolver
- type CoordinateSet
- type Coordinates
- type Digest
- type ELFSecurityFeatures
- type Executable
- type ExecutableFormat
- type License
- type LicenseEvidence
- type Location
- func NewLocation(realPath string) Location
- func NewLocationFromCoordinates(coordinates Coordinates) Location
- func NewLocationFromDirectory(responsePath string, ref file.Reference) Location
- func NewLocationFromImage(accessPath string, ref file.Reference, img *image.Image) Location
- func NewVirtualLocation(realPath, accessPath string) Location
- func NewVirtualLocationFromCoordinates(coordinates Coordinates, accessPath string) Location
- func NewVirtualLocationFromDirectory(responsePath, responseAccessPath string, ref file.Reference) Location
- type LocationData
- type LocationMetadata
- type LocationReadCloser
- type LocationResolver
- type LocationSet
- func (s *LocationSet) Add(locations ...Location)
- func (s LocationSet) Contains(l Location) bool
- func (s *LocationSet) CoordinateSet() CoordinateSet
- func (s *LocationSet) Empty() bool
- func (s LocationSet) Hash() (uint64, error)
- func (s LocationSet) Remove(locations ...Location)
- func (s LocationSet) ToSlice() []Location
- type Locations
- type Metadata
- type MetadataResolver
- type MockResolver
- func (r MockResolver) AllLocations(ctx context.Context) <-chan Location
- func (r MockResolver) FileContentsByLocation(location Location) (io.ReadCloser, error)
- func (r MockResolver) FileMetadataByLocation(l Location) (Metadata, error)
- func (r MockResolver) FilesByBasename(filenames ...string) ([]Location, error)
- func (r MockResolver) FilesByBasenameGlob(_ ...string) ([]Location, error)
- func (r MockResolver) FilesByExtension(extensions ...string) ([]Location, error)
- func (r MockResolver) FilesByGlob(patterns ...string) ([]Location, error)
- func (r MockResolver) FilesByMIMEType(types ...string) ([]Location, error)
- func (r MockResolver) FilesByPath(paths ...string) ([]Location, error)
- func (r MockResolver) HasPath(path string) bool
- func (r MockResolver) RelativeFileByPath(_ Location, path string) *Location
- func (r MockResolver) String() string
- func (r MockResolver) Write(_ Location, _ io.Reader) error
- type PathResolver
- type RelocationReadOnly
- type Resolver
- type SearchResult
- type Selection
- type WritableResolver
Constants ¶
const ( ELF ExecutableFormat = "elf" MachO ExecutableFormat = "macho" PE ExecutableFormat = "pe" RelocationReadOnlyNone RelocationReadOnly = "none" RelocationReadOnlyPartial RelocationReadOnly = "partial" RelocationReadOnlyFull RelocationReadOnly = "full" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContentResolver ¶
type ContentResolver interface {
FileContentsByLocation(Location) (io.ReadCloser, error)
}
ContentResolver knows how to get file content for a given Location
type CoordinateSet ¶
type CoordinateSet struct {
// contains filtered or unexported fields
}
func NewCoordinateSet ¶
func NewCoordinateSet(coordinates ...Coordinates) (s CoordinateSet)
func (*CoordinateSet) Add ¶
func (s *CoordinateSet) Add(coordinates ...Coordinates)
func (CoordinateSet) Contains ¶
func (s CoordinateSet) Contains(l Coordinates) bool
func (CoordinateSet) Hash ¶
func (s CoordinateSet) Hash() (uint64, error)
func (CoordinateSet) Paths ¶
func (s CoordinateSet) Paths() []string
func (CoordinateSet) Remove ¶
func (s CoordinateSet) Remove(coordinates ...Coordinates)
func (CoordinateSet) ToSlice ¶
func (s CoordinateSet) ToSlice() []Coordinates
type Coordinates ¶
type Coordinates struct {
RealPath string `json:"path" cyclonedx:"path"` // The path where all path ancestors have no hardlinks / symlinks
FileSystemID string `json:"layerID,omitempty" cyclonedx:"layerID"` // An ID representing the filesystem. For container images, this is a layer digest. For directories or a root filesystem, this is blank.
}
Coordinates contains the minimal information needed to describe how to find a file within any possible source object (e.g. image and directory sources)
func NewCoordinates ¶
func NewCoordinates(realPath, fsID string) Coordinates
func (Coordinates) GetCoordinates ¶
func (c Coordinates) GetCoordinates() Coordinates
func (Coordinates) ID ¶
func (c Coordinates) ID() artifact.ID
func (Coordinates) String ¶
func (c Coordinates) String() string
type ELFSecurityFeatures ¶
type ELFSecurityFeatures struct {
SymbolTableStripped bool `json:"symbolTableStripped" yaml:"symbolTableStripped" mapstructure:"symbolTableStripped"`
StackCanary *bool `json:"stackCanary,omitempty" yaml:"stackCanary" mapstructure:"stackCanary"`
NoExecutable bool `json:"nx" yaml:"nx" mapstructure:"nx"`
RelocationReadOnly RelocationReadOnly `json:"relRO" yaml:"relRO" mapstructure:"relRO"`
PositionIndependentExecutable bool `json:"pie" yaml:"pie" mapstructure:"pie"`
// LlvmSafeStack represents a compiler-based security mechanism that separates the stack into a safe stack for storing return addresses and other critical data, and an unsafe stack for everything else, to mitigate stack-based memory corruption errors
// see https://clang.llvm.org/docs/SafeStack.html
LlvmSafeStack *bool `json:"safeStack,omitempty" yaml:"safeStack" mapstructure:"safeStack"`
// ControlFlowIntegrity represents runtime checks to ensure a program's control flow adheres to the legal paths determined at compile time, thus protecting against various types of control-flow hijacking attacks
// see https://clang.llvm.org/docs/ControlFlowIntegrity.html
LlvmControlFlowIntegrity *bool `json:"cfi,omitempty" yaml:"cfi" mapstructure:"cfi"`
// ClangFortifySource is a broad suite of extensions to libc aimed at catching misuses of common library functions
// see https://android.googlesource.com/platform//bionic/+/d192dbecf0b2a371eb127c0871f77a9caf81c4d2/docs/clang_fortify_anatomy.md
ClangFortifySource *bool `json:"fortify,omitempty" yaml:"fortify" mapstructure:"fortify"`
}
type Executable ¶
type Executable struct {
// Format denotes either ELF, Mach-O, or PE
Format ExecutableFormat `json:"format" yaml:"format" mapstructure:"format"`
HasExports bool `json:"hasExports" yaml:"hasExports" mapstructure:"hasExports"`
HasEntrypoint bool `json:"hasEntrypoint" yaml:"hasEntrypoint" mapstructure:"hasEntrypoint"`
ImportedLibraries []string `json:"importedLibraries" yaml:"importedLibraries" mapstructure:"importedLibraries"`
ELFSecurityFeatures *ELFSecurityFeatures `json:"elfSecurityFeatures,omitempty" yaml:"elfSecurityFeatures" mapstructure:"elfSecurityFeatures"`
}
type ExecutableFormat ¶
type ExecutableFormat string
type License ¶
type License struct {
Value string
SPDXExpression string
Type license.Type
LicenseEvidence *LicenseEvidence // evidence from license classifier
}
func NewLicense ¶
type LicenseEvidence ¶
type Location ¶
type Location struct {
LocationData `cyclonedx:""`
LocationMetadata `cyclonedx:""`
}
Location represents a path relative to a particular filesystem resolved to a specific file.Reference. This struct is used as a key in content fetching to uniquely identify a file relative to a request (the AccessPath).
func NewLocation ¶
NewLocation creates a new Location representing a path without denoting a filesystem or FileCatalog reference.
func NewLocationFromCoordinates ¶
func NewLocationFromCoordinates(coordinates Coordinates) Location
NewLocationFromCoordinates creates a new location for the given Coordinates.
func NewLocationFromDirectory ¶
NewLocationFromDirectory creates a new Location representing the given path (extracted from the Reference) relative to the given directory.
func NewLocationFromImage ¶
NewLocationFromImage creates a new Location representing the given path (extracted from the Reference) relative to the given image.
func NewVirtualLocation ¶
NewVirtualLocation creates a new location for a path accessed by a virtual path (a path with a symlink or hardlink somewhere in the path)
func NewVirtualLocationFromCoordinates ¶
func NewVirtualLocationFromCoordinates(coordinates Coordinates, accessPath string) Location
NewVirtualLocationFromCoordinates creates a new location for the given Coordinates via a virtual path.
func NewVirtualLocationFromDirectory ¶
func NewVirtualLocationFromDirectory(responsePath, responseAccessPath string, ref file.Reference) Location
NewVirtualLocationFromDirectory creates a new Location representing the given path (extracted from the Reference) relative to the given directory with a separate virtual access path.
func (Location) WithAnnotation ¶
func (Location) WithoutAnnotations ¶
type LocationData ¶
type LocationData struct {
Coordinates `cyclonedx:""` // Empty string here means there is no intermediate property name, e.g. syft:locations:0:path without "coordinates"
// note: it is IMPORTANT to ignore anything but the coordinates for a Location when considering the ID (hash value)
// since the coordinates are the minimally correct ID for a location (symlinks should not come into play)
AccessPath string `hash:"ignore" json:"accessPath"` // The path to the file which may or may not have hardlinks / symlinks
// contains filtered or unexported fields
}
func (LocationData) Reference ¶
func (l LocationData) Reference() file.Reference
type LocationMetadata ¶
type LocationReadCloser ¶
type LocationReadCloser struct {
Location
io.ReadCloser
}
func NewLocationReadCloser ¶
func NewLocationReadCloser(location Location, reader io.ReadCloser) LocationReadCloser
type LocationResolver ¶
type LocationResolver interface {
// AllLocations returns a channel of all file references from the underlying source.
// The implementation for this may vary, however, generally the following considerations should be made:
// - NO symlink resolution should be performed on results
// - returns locations for any file or directory
AllLocations(ctx context.Context) <-chan Location
}
type LocationSet ¶
type LocationSet struct {
// contains filtered or unexported fields
}
func NewLocationSet ¶
func NewLocationSet(locations ...Location) (s LocationSet)
func (*LocationSet) Add ¶
func (s *LocationSet) Add(locations ...Location)
func (LocationSet) Contains ¶
func (s LocationSet) Contains(l Location) bool
func (*LocationSet) CoordinateSet ¶
func (s *LocationSet) CoordinateSet() CoordinateSet
func (*LocationSet) Empty ¶
func (s *LocationSet) Empty() bool
func (LocationSet) Hash ¶
func (s LocationSet) Hash() (uint64, error)
func (LocationSet) Remove ¶
func (s LocationSet) Remove(locations ...Location)
func (LocationSet) ToSlice ¶
func (s LocationSet) ToSlice() []Location
type MetadataResolver ¶
type MockResolver ¶
type MockResolver struct {
// contains filtered or unexported fields
}
MockResolver implements the FileResolver interface and is intended for use *only in test code*. It provides an implementation that can resolve local filesystem paths using only a provided discrete list of file paths, which are typically paths to test fixtures.
func NewMockResolverForPaths ¶
func NewMockResolverForPaths(paths ...string) *MockResolver
NewMockResolverForPaths creates a new MockResolver, where the only resolvable files are those specified by the supplied paths.
func NewMockResolverForPathsWithMetadata ¶
func NewMockResolverForPathsWithMetadata(metadata map[Coordinates]Metadata) *MockResolver
func (MockResolver) AllLocations ¶
func (r MockResolver) AllLocations(ctx context.Context) <-chan Location
func (MockResolver) FileContentsByLocation ¶
func (r MockResolver) FileContentsByLocation(location Location) (io.ReadCloser, error)
FileContentsByLocation fetches file contents for a single location. If the path does not exist, an error is returned.
func (MockResolver) FileMetadataByLocation ¶
func (r MockResolver) FileMetadataByLocation(l Location) (Metadata, error)
func (MockResolver) FilesByBasename ¶
func (r MockResolver) FilesByBasename(filenames ...string) ([]Location, error)
func (MockResolver) FilesByBasenameGlob ¶
func (r MockResolver) FilesByBasenameGlob(_ ...string) ([]Location, error)
func (MockResolver) FilesByExtension ¶
func (r MockResolver) FilesByExtension(extensions ...string) ([]Location, error)
func (MockResolver) FilesByGlob ¶
func (r MockResolver) FilesByGlob(patterns ...string) ([]Location, error)
FilesByGlob returns all Locations that match the given path glob pattern.
func (MockResolver) FilesByMIMEType ¶
func (r MockResolver) FilesByMIMEType(types ...string) ([]Location, error)
func (MockResolver) FilesByPath ¶
func (r MockResolver) FilesByPath(paths ...string) ([]Location, error)
FilesByPath returns all Locations that match the given paths.
func (MockResolver) HasPath ¶
func (r MockResolver) HasPath(path string) bool
HasPath indicates if the given path exists in the underlying source.
func (MockResolver) RelativeFileByPath ¶
func (r MockResolver) RelativeFileByPath(_ Location, path string) *Location
RelativeFileByPath returns a single Location for the given path.
func (MockResolver) String ¶
func (r MockResolver) String() string
String returns the string representation of the MockResolver.
type PathResolver ¶
type PathResolver interface {
// HasPath indicates if the given path exists in the underlying source.
// The implementation for this may vary, however, generally the following considerations should be made:
// - full symlink resolution should be performed on all requests
// - returns locations for any file or directory
HasPath(string) bool
// FilesByPath fetches a set of file references which have the given path (for an image, there may be multiple matches).
// The implementation for this may vary, however, generally the following considerations should be made:
// - full symlink resolution should be performed on all requests
// - only returns locations to files (NOT directories)
FilesByPath(paths ...string) ([]Location, error)
// FilesByGlob fetches a set of file references for the given glob matches
// The implementation for this may vary, however, generally the following considerations should be made:
// - full symlink resolution should be performed on all requests
// - if multiple paths to the same file are found, the best single match should be returned
// - only returns locations to files (NOT directories)
FilesByGlob(patterns ...string) ([]Location, error)
// FilesByMIMEType fetches a set of file references which the contents have been classified as one of the given MIME Types.
FilesByMIMEType(types ...string) ([]Location, error)
// RelativeFileByPath fetches a single file at the given path relative to the layer squash of the given reference.
// This is helpful when attempting to find a file that is in the same layer or lower as another file.
RelativeFileByPath(_ Location, path string) *Location
}
PathResolver knows how to get a Location for given string paths and globs
type RelocationReadOnly ¶
type RelocationReadOnly string
type Resolver ¶
type Resolver interface {
ContentResolver
PathResolver
LocationResolver
MetadataResolver
}
Resolver is an interface that encompasses how to get specific file references and file contents for a generic data source.
type SearchResult ¶
type SearchResult struct {
Classification string `json:"classification"`
LineNumber int64 `json:"lineNumber"`
LineOffset int64 `json:"lineOffset"`
SeekPosition int64 `json:"seekPosition"`
Length int64 `json:"length"`
Value string `json:"value,omitempty"`
}
func (SearchResult) String ¶
func (s SearchResult) String() string