Documentation
¶
Overview ¶
Package fs provides a virtual filesystem interface for SCALIBR scans and related helper functions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetRealPath ¶ added in v0.3.1
GetRealPath returns the real absolute path of the file on the scanning host's filesystem. If the file is on a virtual filesystem (e.g. a remote container), it is first copied into a temporary directory on the scanning host's filesystem. It's up to the caller to delete the directory once they're done using it.
Sample code to delete the directory: ``` realPath := GetRealPath(...) dir := filepath.Dir(realPath)
if err := os.RemoveAll(dir); err != nil {
log.Errorf("os.RemoveAll(%q): %w", dir, err)
}
Types ¶
type FS ¶
FS is a filesystem interface that allows the opening of files, reading of directories, and performing stat on files.
FS implementations may return ErrNotImplemented for `Open`, `ReadDir` and `Stat`. Extractor implementations must decide whether the error is fatal or can be ignored.
FS implementations MUST implement io.ReaderAt for opened files to enable random access.
type ScanRoot ¶
type ScanRoot struct {
// A virtual filesystem for file access, rooted at the scan root.
FS FS
// The path of the scan root. Empty if this is a virtual filesystem and the
// scanning environment doesn't support the DirectFS requirement.
Path string
}
ScanRoot defines a root directory to start a scan from. mounted to a local dir.
func RealFSScanRoot ¶
RealFSScanRoot returns a ScanRoot array the given root path on the real filesystem SCALIBR is running on.
func RealFSScanRoots ¶
RealFSScanRoots returns a one-element ScanRoot array representing the given root path on the real filesystem SCALIBR is running on.
func (*ScanRoot) IsVirtual ¶
IsVirtual returns true if the scan root represents the root of a virtual filesystem, i.e. one with no real location on the disk of the scanned host.
func (*ScanRoot) WithAbsolutePath ¶
WithAbsolutePath returns a copy of the ScanRoot with the Path set an absolute path.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package diriterate provides a utility for iterating over the contents of a directory without loading all of it into memory at once.
|
Package diriterate provides a utility for iterating over the contents of a directory without loading all of it into memory at once. |