scan

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 21, 2024 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SbomFilename = "sboms.tar"
)

Variables

This section is empty.

Functions

func ExtractRootFsFromTarFilePath added in v0.0.11

func ExtractRootFsFromTarFilePath(outputDir, tarFilePath string) ([]trivyScannable, error)

func ExtractSBOMsFromZarfTarFile added in v0.0.11

func ExtractSBOMsFromZarfTarFile(outputDir, tarFilePath string) ([]trivyScannable, error)

ExtractSBOMsFromZarfTarFile extracts images from the tar archive and returns names of the container images. Parameters: - tarFilePath: the path to the tar archive to extract the images from. Returns: - []sbomImageRef: references to images and their sboms. - error: an error if the extraction fails.

func NewLocalPackageScanner added in v0.0.8

func NewLocalPackageScanner(logger types.Logger,
	packagePath, offlineDBPath string, scannerType ScannerType,
) (types.PackageScanner, error)

NewLocalPackageScanner creates a new LocalPackageScanner instance. Parameters: - logger: the logger to use for logging. - dockerConfigPath: the path to the docker configuration file. - packagePath: the path to the zarf package to scan. - offlineDBPath: the path to the offline DB for Trivy. Returns: - *LocalPackageScanner: the LocalPackageScanner instance. - error: an error if the instance cannot be created.

func NewRemotePackageScanner added in v0.0.8

func NewRemotePackageScanner(
	ctx context.Context,
	logger types.Logger,
	org,
	packageName,
	tag,
	offlineDBPath string,
	registryCredentials []types.RegistryCredentials,
	scannerType ScannerType,
) types.PackageScanner

NewRemotePackageScanner creates a new Scanner for remote packages.

func WriteToCSV added in v0.2.0

func WriteToCSV(w io.Writer, results []types.ScanResultReader) error

func WriteToJSON added in v0.0.11

func WriteToJSON(w io.Writer, results []types.ScanResultReader) error

Types

type ArtifactNameOverride added in v0.0.11

type ArtifactNameOverride interface {
	ArtifactNameOverride() string
}

type JSONOutputEntry added in v0.2.0

type JSONOutputEntry struct {
	ArtifactName     string `json:"ArtifactName"`
	VulnerabilityID  string `json:"VulnerabilityID"`
	PkgName          string `json:"PkgName"`
	InstalledVersion string `json:"InstalledVersion"`
	FixedVersion     string `json:"FixedVersion"`
	Severity         string `json:"Severity"`
	Description      string `json:"Description"`
}

type LocalPackageScanner added in v0.0.8

type LocalPackageScanner struct {
	// contains filtered or unexported fields
}

LocalPackageScanner is a struct that holds the logger and paths for docker configuration and package.

func (*LocalPackageScanner) Scan added in v0.0.8

Scan scans the package and returns the scan results which are trivy scan results in json format. Parameters: - ctx: the context to use for the scan. Returns: - []string: the scan results which are trivy scan results in json format. - error: an error if the scan fails.

func (*LocalPackageScanner) ScanResultReader added in v0.0.8

func (lps *LocalPackageScanner) ScanResultReader(result types.PackageScannerResult) (types.ScanResultReader, error)

ScanResultReader reads the scan result from the json file and returns the scan result. Parameters: - jsonFilePath: the path to the json file to read the scan result from. Returns: - types.ScanResultReader: the scan result. - error: an error if the reading fails.

type Scanner

type Scanner struct {
	// contains filtered or unexported fields
}

Scanner implements the PackageScanner interface for remote packages.

func (*Scanner) Scan added in v0.0.8

func (s *Scanner) Scan(ctx context.Context) (*types.PackageScan, error)

Scan scans the remote package and returns the scan results.

func (*Scanner) ScanResultReader

func (s *Scanner) ScanResultReader(result types.PackageScannerResult) (types.ScanResultReader, error)

ScanResultReader creates a new ScanResultReader from a JSON file. This takes a trivy scan result file and returns a ScanResultReader.

Parameters:

  • jsonFilePath: The path to the JSON file containing the scan results.

Returns:

  • types.ScanResultReader: An instance of ScanResultReader that can be used to access the scan results.
  • error: An error if the file cannot be opened or the JSON cannot be decoded.

func (*Scanner) ScanZarfPackage

func (s *Scanner) ScanZarfPackage(org, packageName, tag string) (*types.PackageScan, error)

ScanZarfPackage scans a Zarf package and returns the scan results.

Parameters:

  • org: The organization that owns the package.
  • packageName: The name of the package to scan.
  • tag: The tag of the package to scan.

Returns:

  • []string: A slice of file paths containing the scan results in JSON format.
  • error: An error if the scan operation fails.

type ScannerFactoryImpl added in v0.0.8

type ScannerFactoryImpl struct{}

ScannerFactoryImpl is the implementation of the ScannerFactory interface.

func (*ScannerFactoryImpl) CreateScanner added in v0.0.8

func (sf *ScannerFactoryImpl) CreateScanner(
	ctx context.Context,
	logger types.Logger,
	org, packageName, tag, packagePath, offlineDBPath string,
	registryCredentials []types.RegistryCredentials,
	scannerType ScannerType,
) (types.PackageScanner, error)

CreateScanner creates a new PackageScanner based on the provided options.

type ScannerType added in v0.1.0

type ScannerType string
const (
	SBOMScannerType   ScannerType = "sbom"
	RootFSScannerType ScannerType = "rootfs"
)

func (*ScannerType) Set added in v0.1.0

func (s *ScannerType) Set(v string) error

func (*ScannerType) String added in v0.1.0

func (s *ScannerType) String() string

func (*ScannerType) Type added in v0.1.0

func (s *ScannerType) Type() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL