Documentation
¶
Index ¶
- Variables
- func NewExcludingDecorator(delegate file.Resolver, excludeFn excludeFn) file.Resolver
- func NewFromRootedUnindexedDirectory(dir string, base string) file.WritableResolver
- func NewFromUnindexedDirectory(dir string) file.WritableResolver
- func NewFromUnindexedDirectoryFS(fs afero.Fs, dir string, base string) file.WritableResolver
- func NewMetadataFromPath(path string, info os.FileInfo) file.Metadata
- func NormalizeBaseDirectory(base string) (string, error)
- func NormalizeRootDirectory(root string) (string, error)
- type ChrootContext
- func (r ChrootContext) Base() string
- func (r *ChrootContext) ChangeDirectory(dir string) error
- func (r *ChrootContext) ChangeRoot(dir string) error
- func (r ChrootContext) Root() string
- func (r ChrootContext) ToChrootPath(nativePath string) string
- func (r ChrootContext) ToNativeGlob(chrootPath string) (string, error)
- func (r ChrootContext) ToNativePath(chrootPath string) (string, error)
- type ContainerImageAllLayers
- func (r *ContainerImageAllLayers) AllLocations(ctx context.Context) <-chan file.Location
- func (r *ContainerImageAllLayers) FileContentsByLocation(location file.Location) (io.ReadCloser, error)
- func (r *ContainerImageAllLayers) FileMetadataByLocation(location file.Location) (file.Metadata, error)
- func (r *ContainerImageAllLayers) FilesByGlob(patterns ...string) ([]file.Location, error)
- func (r *ContainerImageAllLayers) FilesByMIMEType(types ...string) ([]file.Location, error)
- func (r *ContainerImageAllLayers) FilesByPath(paths ...string) ([]file.Location, error)
- func (r *ContainerImageAllLayers) HasPath(path string) bool
- func (r *ContainerImageAllLayers) RelativeFileByPath(location file.Location, path string) *file.Location
- type ContainerImageDeepSquash
- func (i *ContainerImageDeepSquash) AllLocations(ctx context.Context) <-chan file.Location
- func (i *ContainerImageDeepSquash) FileContentsByLocation(location file.Location) (io.ReadCloser, error)
- func (i *ContainerImageDeepSquash) FileMetadataByLocation(location file.Location) (file.Metadata, error)
- func (i *ContainerImageDeepSquash) FilesByGlob(patterns ...string) ([]file.Location, error)
- func (i *ContainerImageDeepSquash) FilesByMIMEType(types ...string) ([]file.Location, error)
- func (i *ContainerImageDeepSquash) FilesByPath(paths ...string) ([]file.Location, error)
- func (i *ContainerImageDeepSquash) HasPath(path string) bool
- func (i *ContainerImageDeepSquash) RelativeFileByPath(location file.Location, path string) *file.Location
- type ContainerImageSquash
- func (r *ContainerImageSquash) AllLocations(ctx context.Context) <-chan file.Location
- func (r *ContainerImageSquash) FileContentsByLocation(location file.Location) (io.ReadCloser, error)
- func (r *ContainerImageSquash) FileMetadataByLocation(location file.Location) (file.Metadata, error)
- func (r *ContainerImageSquash) FilesByGlob(patterns ...string) ([]file.Location, error)
- func (r *ContainerImageSquash) FilesByMIMEType(types ...string) ([]file.Location, error)
- func (r *ContainerImageSquash) FilesByPath(paths ...string) ([]file.Location, error)
- func (r *ContainerImageSquash) HasPath(path string) bool
- func (r *ContainerImageSquash) RelativeFileByPath(_ file.Location, path string) *file.Location
- type Deferred
- func (d *Deferred) AllLocations(ctx context.Context) <-chan file.Location
- func (d *Deferred) FileContentsByLocation(location file.Location) (io.ReadCloser, error)
- func (d *Deferred) FileMetadataByLocation(location file.Location) (file.Metadata, error)
- func (d *Deferred) FilesByGlob(patterns ...string) ([]file.Location, error)
- func (d *Deferred) FilesByMIMEType(types ...string) ([]file.Location, error)
- func (d *Deferred) FilesByPath(paths ...string) ([]file.Location, error)
- func (d *Deferred) HasPath(s string) bool
- func (d *Deferred) RelativeFileByPath(location file.Location, path string) *file.Location
- type Directory
- type Empty
- func (e Empty) AllLocations(_ context.Context) <-chan file.Location
- func (e Empty) FileContentsByLocation(_ file.Location) (io.ReadCloser, error)
- func (e Empty) FileMetadataByLocation(_ file.Location) (file.Metadata, error)
- func (e Empty) FilesByGlob(_ ...string) ([]file.Location, error)
- func (e Empty) FilesByMIMEType(_ ...string) ([]file.Location, error)
- func (e Empty) FilesByPath(_ ...string) ([]file.Location, error)
- func (e Empty) HasPath(_ string) bool
- func (e Empty) RelativeFileByPath(_ file.Location, _ string) *file.Location
- func (e Empty) Write(_ file.Location, _ io.Reader) error
- type File
- type FiletreeResolver
- func (r *FiletreeResolver) AllLocations(ctx context.Context) <-chan file.Location
- func (r FiletreeResolver) FileContentsByLocation(location file.Location) (io.ReadCloser, error)
- func (r *FiletreeResolver) FileMetadataByLocation(location file.Location) (file.Metadata, error)
- func (r FiletreeResolver) FilesByGlob(patterns ...string) ([]file.Location, error)
- func (r *FiletreeResolver) FilesByMIMEType(types ...string) ([]file.Location, error)
- func (r FiletreeResolver) FilesByPath(userPaths ...string) ([]file.Location, error)
- func (r *FiletreeResolver) HasPath(userPath string) bool
- func (r *FiletreeResolver) RelativeFileByPath(_ file.Location, path string) *file.Location
- type PathIndexVisitor
- type UnindexedDirectory
- func (u UnindexedDirectory) AllLocations(ctx context.Context) <-chan file.Location
- func (u UnindexedDirectory) FileContentsByLocation(location file.Location) (io.ReadCloser, error)
- func (u UnindexedDirectory) FileMetadataByLocation(_ file.Location) (file.Metadata, error)
- func (u UnindexedDirectory) FilesByGlob(patterns ...string) (out []file.Location, _ error)
- func (u UnindexedDirectory) FilesByMIMEType(_ ...string) ([]file.Location, error)
- func (u UnindexedDirectory) FilesByPath(paths ...string) (out []file.Location, _ error)
- func (u UnindexedDirectory) HasPath(p string) bool
- func (u UnindexedDirectory) RelativeFileByPath(l file.Location, p string) *file.Location
- func (u UnindexedDirectory) Write(location file.Location, reader io.Reader) error
Constants ¶
This section is empty.
Variables ¶
var ErrSkipPath = errors.New("skip path")
Functions ¶
func NewExcludingDecorator ¶ added in v0.85.0
NewExcludingDecorator create a new resolver which wraps the provided delegate and excludes entries based on a provided path exclusion function
func NewFromRootedUnindexedDirectory ¶
func NewFromRootedUnindexedDirectory(dir string, base string) file.WritableResolver
func NewFromUnindexedDirectory ¶
func NewFromUnindexedDirectory(dir string) file.WritableResolver
func NewMetadataFromPath ¶ added in v1.35.0
func NormalizeBaseDirectory ¶ added in v0.85.0
func NormalizeRootDirectory ¶ added in v0.85.0
Types ¶
type ChrootContext ¶ added in v0.85.0
type ChrootContext struct {
// contains filtered or unexported fields
}
ChrootContext helps to modify path from a real filesystem to a chroot-like filesystem, taking into account the user given root, the base path (if any) to consider as the root, and the current working directory. Note: this only works on a real filesystem, not on a virtual filesystem (such as a stereoscope filetree).
func NewChrootContext ¶ added in v0.85.0
func NewChrootContext(root, base, cwd string) (*ChrootContext, error)
func NewChrootContextFromCWD ¶ added in v0.85.0
func NewChrootContextFromCWD(root, base string) (*ChrootContext, error)
func (ChrootContext) Base ¶ added in v0.85.0
func (r ChrootContext) Base() string
Base returns the absolute base path with all symlinks evaluated.
func (*ChrootContext) ChangeDirectory ¶ added in v0.85.0
func (r *ChrootContext) ChangeDirectory(dir string) error
ChangeDirectory changes the current working directory so that any relative paths passed into ToNativePath() and ToChrootPath() honor the new CWD. If the process changes the CWD in-flight, this should be called again to ensure correct functionality of ToNativePath() and ToChrootPath().
func (*ChrootContext) ChangeRoot ¶ added in v0.85.0
func (r *ChrootContext) ChangeRoot(dir string) error
ChangeRoot swaps the path for the chroot.
func (ChrootContext) Root ¶ added in v0.85.0
func (r ChrootContext) Root() string
Root returns the root path with all symlinks evaluated.
func (ChrootContext) ToChrootPath ¶ added in v0.85.0
func (r ChrootContext) ToChrootPath(nativePath string) string
ToChrootPath takes a path from the underlying fs domain and converts it to a path that is relative to the current root context.
func (ChrootContext) ToNativeGlob ¶ added in v1.13.0
func (r ChrootContext) ToNativeGlob(chrootPath string) (string, error)
func (ChrootContext) ToNativePath ¶ added in v0.85.0
func (r ChrootContext) ToNativePath(chrootPath string) (string, error)
ToNativePath takes a path in the context of the chroot-like filesystem and converts it to a path in the underlying fs domain.
type ContainerImageAllLayers ¶
type ContainerImageAllLayers struct {
// contains filtered or unexported fields
}
ContainerImageAllLayers implements path and content access for the AllLayers source option for container image data sources.
func NewFromContainerImageAllLayers ¶
func NewFromContainerImageAllLayers(img *image.Image) (*ContainerImageAllLayers, error)
NewFromContainerImageAllLayers returns a new resolver from the perspective of all image layers for the given image.
func (*ContainerImageAllLayers) AllLocations ¶
func (r *ContainerImageAllLayers) AllLocations(ctx context.Context) <-chan file.Location
func (*ContainerImageAllLayers) FileContentsByLocation ¶
func (r *ContainerImageAllLayers) FileContentsByLocation(location file.Location) (io.ReadCloser, error)
FileContentsByLocation fetches file contents for a single file reference, irregardless of the source layer. If the path does not exist an error is returned.
func (*ContainerImageAllLayers) FileMetadataByLocation ¶
func (*ContainerImageAllLayers) FilesByGlob ¶
func (r *ContainerImageAllLayers) FilesByGlob(patterns ...string) ([]file.Location, error)
FilesByGlob returns all file.References that match the given path glob pattern from any layer in the image.
func (*ContainerImageAllLayers) FilesByMIMEType ¶
func (r *ContainerImageAllLayers) FilesByMIMEType(types ...string) ([]file.Location, error)
func (*ContainerImageAllLayers) FilesByPath ¶
func (r *ContainerImageAllLayers) FilesByPath(paths ...string) ([]file.Location, error)
FilesByPath returns all file.References that match the given paths from any layer in the image.
func (*ContainerImageAllLayers) HasPath ¶
func (r *ContainerImageAllLayers) HasPath(path string) bool
HasPath indicates if the given path exists in the underlying source.
func (*ContainerImageAllLayers) RelativeFileByPath ¶
func (r *ContainerImageAllLayers) RelativeFileByPath(location file.Location, path string) *file.Location
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.
type ContainerImageDeepSquash ¶ added in v1.24.0
type ContainerImageDeepSquash struct {
// contains filtered or unexported fields
}
ContainerImageDeepSquash implements path and content access for the paths in the squashed tree, but with additional depth from all layers. The goal of this is to allow for producing results where the first layer which the material was added can be annotated in the SBOM (as opposed to the last [visible] layer for the path like with the squashed file resolver).
func NewFromContainerImageDeepSquash ¶ added in v1.24.0
func NewFromContainerImageDeepSquash(img *image.Image) (*ContainerImageDeepSquash, error)
NewFromContainerImageDeepSquash returns a new resolver from the perspective of all image layers for the given image.
func (*ContainerImageDeepSquash) AllLocations ¶ added in v1.24.0
func (i *ContainerImageDeepSquash) AllLocations(ctx context.Context) <-chan file.Location
func (*ContainerImageDeepSquash) FileContentsByLocation ¶ added in v1.24.0
func (i *ContainerImageDeepSquash) FileContentsByLocation(location file.Location) (io.ReadCloser, error)
FileContentsByLocation fetches file contents for a single file reference. If the path does not exist an error is returned.
func (*ContainerImageDeepSquash) FileMetadataByLocation ¶ added in v1.24.0
func (*ContainerImageDeepSquash) FilesByGlob ¶ added in v1.24.0
func (i *ContainerImageDeepSquash) FilesByGlob(patterns ...string) ([]file.Location, error)
FilesByGlob returns all file.References that match the given path glob pattern from any layer in the image.
func (*ContainerImageDeepSquash) FilesByMIMEType ¶ added in v1.24.0
func (i *ContainerImageDeepSquash) FilesByMIMEType(types ...string) ([]file.Location, error)
func (*ContainerImageDeepSquash) FilesByPath ¶ added in v1.24.0
func (i *ContainerImageDeepSquash) FilesByPath(paths ...string) ([]file.Location, error)
FilesByPath returns all file.References that match the given paths from any layer in the image.
func (*ContainerImageDeepSquash) HasPath ¶ added in v1.24.0
func (i *ContainerImageDeepSquash) HasPath(path string) bool
HasPath indicates if the given path exists in the underlying source.
func (*ContainerImageDeepSquash) RelativeFileByPath ¶ added in v1.24.0
func (i *ContainerImageDeepSquash) RelativeFileByPath(location file.Location, path string) *file.Location
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.
type ContainerImageSquash ¶
type ContainerImageSquash struct {
// contains filtered or unexported fields
}
ContainerImageSquash implements path and content access for the Squashed source option for container image data sources.
func NewFromContainerImageSquash ¶
func NewFromContainerImageSquash(img *image.Image) (*ContainerImageSquash, error)
NewFromContainerImageSquash returns a new resolver from the perspective of the squashed representation for the given image.
func (*ContainerImageSquash) AllLocations ¶
func (r *ContainerImageSquash) AllLocations(ctx context.Context) <-chan file.Location
func (*ContainerImageSquash) FileContentsByLocation ¶
func (r *ContainerImageSquash) FileContentsByLocation(location file.Location) (io.ReadCloser, error)
FileContentsByLocation fetches file contents for a single file reference, regardless of the source layer. If the path does not exist an error is returned.
func (*ContainerImageSquash) FileMetadataByLocation ¶
func (*ContainerImageSquash) FilesByGlob ¶
func (r *ContainerImageSquash) FilesByGlob(patterns ...string) ([]file.Location, error)
FilesByGlob returns all file.References that match the given path glob pattern within the squashed representation of the image.
func (*ContainerImageSquash) FilesByMIMEType ¶
func (r *ContainerImageSquash) FilesByMIMEType(types ...string) ([]file.Location, error)
func (*ContainerImageSquash) FilesByPath ¶
func (r *ContainerImageSquash) FilesByPath(paths ...string) ([]file.Location, error)
FilesByPath returns all file.References that match the given paths within the squashed representation of the image.
func (*ContainerImageSquash) HasPath ¶
func (r *ContainerImageSquash) HasPath(path string) bool
HasPath indicates if the given path exists in the underlying source.
func (*ContainerImageSquash) RelativeFileByPath ¶
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. For the ContainerImageSquash, this is a simple path lookup.
type Deferred ¶
type Deferred struct {
// contains filtered or unexported fields
}
func (*Deferred) AllLocations ¶
func (*Deferred) FileContentsByLocation ¶
func (*Deferred) FileMetadataByLocation ¶
func (*Deferred) FilesByGlob ¶
func (*Deferred) FilesByMIMEType ¶
func (*Deferred) FilesByPath ¶
type Directory ¶
type Directory struct {
FiletreeResolver
// contains filtered or unexported fields
}
Directory implements path and content access for the directory data source.
func NewFromDirectory ¶
func NewFromDirectory(root, base string, pathFilters ...PathIndexVisitor) (*Directory, error)
type Empty ¶
type Empty struct{}
func (Empty) FileContentsByLocation ¶
func (Empty) FileMetadataByLocation ¶
func (Empty) RelativeFileByPath ¶
type File ¶ added in v1.18.0
type File struct {
FiletreeResolver
// contains filtered or unexported fields
}
File implements path and content access for the file data source.
func NewFromFile ¶ added in v1.18.0
func NewFromFile(path string, pathFilters ...PathIndexVisitor) (*File, error)
NewFromFile single file analyser path is the filepath of the file we're creating content access for
type FiletreeResolver ¶ added in v1.28.0
type FiletreeResolver struct {
Chroot ChrootContext
Tree filetree.Reader
Index filetree.IndexReader
SearchContext filetree.Searcher
Opener func(stereoscopeFile.Reference) (io.ReadCloser, error)
}
TODO: consider making a constructor for this
func (*FiletreeResolver) AllLocations ¶ added in v1.28.0
func (r *FiletreeResolver) AllLocations(ctx context.Context) <-chan file.Location
func (FiletreeResolver) FileContentsByLocation ¶ added in v1.28.0
func (r FiletreeResolver) FileContentsByLocation(location file.Location) (io.ReadCloser, error)
FileContentsByLocation fetches file contents for a single file reference relative to a directory. If the path does not exist an error is returned.
func (*FiletreeResolver) FileMetadataByLocation ¶ added in v1.28.0
func (FiletreeResolver) FilesByGlob ¶ added in v1.28.0
func (r FiletreeResolver) FilesByGlob(patterns ...string) ([]file.Location, error)
FilesByGlob returns all file.References that match the given path glob pattern from any layer in the image.
func (*FiletreeResolver) FilesByMIMEType ¶ added in v1.28.0
func (r *FiletreeResolver) FilesByMIMEType(types ...string) ([]file.Location, error)
func (FiletreeResolver) FilesByPath ¶ added in v1.28.0
func (r FiletreeResolver) FilesByPath(userPaths ...string) ([]file.Location, error)
FilesByPath returns all file.References that match the given paths from the file index.
func (*FiletreeResolver) HasPath ¶ added in v1.28.0
func (r *FiletreeResolver) HasPath(userPath string) bool
HasPath indicates if the given path exists in the underlying source.
func (*FiletreeResolver) RelativeFileByPath ¶ added in v1.28.0
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.
type UnindexedDirectory ¶
type UnindexedDirectory struct {
// contains filtered or unexported fields
}
func (UnindexedDirectory) AllLocations ¶
func (u UnindexedDirectory) AllLocations(ctx context.Context) <-chan file.Location
- NO symlink resolution should be performed on results - returns locations for any file or directory
func (UnindexedDirectory) FileContentsByLocation ¶
func (u UnindexedDirectory) FileContentsByLocation(location file.Location) (io.ReadCloser, error)
func (UnindexedDirectory) FileMetadataByLocation ¶
func (UnindexedDirectory) FilesByGlob ¶
func (u UnindexedDirectory) FilesByGlob(patterns ...string) (out []file.Location, _ error)
- 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)
func (UnindexedDirectory) FilesByMIMEType ¶
func (u UnindexedDirectory) FilesByMIMEType(_ ...string) ([]file.Location, error)
func (UnindexedDirectory) FilesByPath ¶
func (u UnindexedDirectory) FilesByPath(paths ...string) (out []file.Location, _ error)
- full symlink resolution should be performed on all requests - only returns locations to files (NOT directories)
func (UnindexedDirectory) HasPath ¶
func (u UnindexedDirectory) HasPath(p string) bool
- full symlink resolution should be performed on all requests - returns locations for any file or directory
func (UnindexedDirectory) RelativeFileByPath ¶
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.