types

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: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandExecutor

type CommandExecutor interface {
	// ExecuteCommand executes a command with the given name, arguments, and environment variables.
	// It returns the standard output, standard error, and any error that occurred during execution.
	ExecuteCommand(name string, args []string, env []string) (stdout string, stderr string, err error)
}

CommandExecutor is an interface for executing commands.

type HTTPClientInterface

type HTTPClientInterface interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPClientInterface is an abstraction that allows for easier testing by mocking HTTP responses. It defines a single method, Do, which takes an http.Request and returns an http.Response and an error.

type Logger

type Logger interface {
	// Debug logs a debug message with the given fields.
	Debug(msg string, fields ...interface{})
	// Info logs an info message with the given fields.
	Info(msg string, fields ...interface{})
	// Warn logs a warn message with the given fields.
	Warn(msg string, fields ...interface{})
	// Error logs an error message with the given fields.
	Error(msg string, fields ...interface{})
	// Fatalf logs a fatal message with the given fields.
	Fatalf(msg string, fields ...interface{})
}

Logger is the interface that the logger must implement.

type PackageScan added in v0.2.0

type PackageScan struct {
	ZarfPackage ZarfPackage
	Results     []PackageScannerResult
}

type PackageScanner added in v0.0.8

type PackageScanner interface {
	// Scan scans the package and returns the scan results.
	// Returns a slice of file paths containing the scan results in JSON format and an error if the scan operation fails.
	Scan(ctx context.Context) (*PackageScan, error)

	// ScanResultReader creates a new ScanResultReader from a JSON file.
	// 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.
	ScanResultReader(result PackageScannerResult) (ScanResultReader, error)
}

PackageScanner defines the methods required for scanning packages.

type PackageScannerResult added in v0.0.10

type PackageScannerResult struct {
	ArtifactNameOverride string
	JSONFilePath         string
}

type RealHTTPClient

type RealHTTPClient struct {
	Client *http.Client
}

RealHTTPClient is a concrete implementation of HTTPClientInterface that uses a real http.Client to make requests.

func NewRealHTTPClient

func NewRealHTTPClient() *RealHTTPClient

NewRealHTTPClient creates a new instance of RealHTTPClient with a default http.Client. The http.Client can be customized as needed, for example, by setting timeouts.

func (*RealHTTPClient) Do

func (c *RealHTTPClient) Do(req *http.Request) (*http.Response, error)

Do sends an HTTP request using the underlying http.Client and returns the response. It satisfies the HTTPClientInterface by implementing the Do method.

type RegistryCredentials added in v0.0.8

type RegistryCredentials struct {
	RegistryURL string
	Username    string
	Password    string
}

type ScanResult

type ScanResult struct {
	ArtifactName string `json:"ArtifactName"`
	Results      []struct {
		Vulnerabilities []VulnerabilityInfo `json:"Vulnerabilities"`
	} `json:"Results"`
}

ScanResult represents the result of scanning an artifact for vulnerabilities.

func (ScanResult) GetArtifactName added in v0.2.0

func (s ScanResult) GetArtifactName() string

func (ScanResult) GetVulnerabilities added in v0.2.0

func (s ScanResult) GetVulnerabilities() []VulnerabilityInfo

type ScanResultReader

type ScanResultReader interface {
	// GetArtifactName returns the name of the scanned artifact.
	GetArtifactName() string

	// GetVulnerabilities returns a slice of VulnerabilityInfo representing the vulnerabilities
	// found in the scanned artifact.
	GetVulnerabilities() []VulnerabilityInfo
}

ScanResultReader is an interface for reading scan results.

type ScannerFactory added in v0.0.8

type ScannerFactory interface {
	// CreateScanner creates a new PackageScanner based on the provided options.
	// Parameters:
	//   - ctx: The context for the scanner.
	//   - logger: The logger to use for logging.
	//   - dockerConfigPath: The path to the Docker config file.
	//   - org: The organization name (for remote scanner).
	//   - packageName: The package name (for remote scanner).
	//   - tag: The tag name (for remote scanner).
	//   - packagePath: The path to the local package (for local scanner).
	// Returns:
	//   - PackageScanner: The created PackageScanner.
	//   - error: An error if the scanner cannot be created.
	CreateScanner(
		ctx context.Context,
		logger Logger,
		dockerConfigPath,
		org,
		packageName,
		tag,
		packagePath string,
	) (PackageScanner, error)
}

ScannerFactory defines the method to create a PackageScanner.

type VulnerabilityInfo

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

VulnerabilityInfo represents information about a vulnerability found in a scanned artifact.

type ZarfPackage added in v0.2.0

type ZarfPackage v1beta1.ZarfPackage

Jump to

Keyboard shortcuts

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