Documentation
¶
Index ¶
Constants ¶
const ( // MaxCandidates is the number of latest digests to consider per image during discovery. // Limiting this prevents scanning thousands of old tags, significantly improving performance. MaxCandidates = 5 )
Variables ¶
This section is empty.
Functions ¶
func ParseArtifactURI ¶
func ParseArtifactURI(uri string) (schemas.ArtifactReference, error)
ParseArtifactURI parses a raw GAR URI string into a structured ArtifactReference.
Types ¶
type AnalyzeRequest ¶
type AnalyzeRequest struct {
// Artifact is the image reference to analyze
Artifact schemas.ArtifactReference
// Location is the GCP location (required for resource URL generation)
Location string
// MinSeverity filters vulnerabilities by minimum severity
MinSeverity schemas.Severity
// FixableOnly filters for vulnerabilities that have a fix available
FixableOnly bool
}
AnalyzeRequest contains parameters for vulnerability analysis
type Analyzer ¶
type Analyzer interface {
// Analyze retrieves vulnerabilities for the specified image
Analyze(ctx context.Context, req AnalyzeRequest) (*schemas.AnalyzeResult, error)
}
Analyzer fetches and processes vulnerability data
type ArtifactRegistryAnalyzer ¶
type ArtifactRegistryAnalyzer struct {
// contains filtered or unexported fields
}
ArtifactRegistryAnalyzer implements the vulnerability analysis logic.
func NewArtifactRegistryAnalyzer ¶
func NewArtifactRegistryAnalyzer(ctx context.Context, opts ...option.ClientOption) (*ArtifactRegistryAnalyzer, error)
NewArtifactRegistryAnalyzer creates a new analyzer with ADC authentication.
func (*ArtifactRegistryAnalyzer) Analyze ¶
func (a *ArtifactRegistryAnalyzer) Analyze(ctx context.Context, req AnalyzeRequest) (*schemas.AnalyzeResult, error)
Analyze retrieves and filters vulnerabilities for the specified image digest.
func (*ArtifactRegistryAnalyzer) Close ¶
func (a *ArtifactRegistryAnalyzer) Close() error
Close closes the underlying API client.
type Exporter ¶
type Exporter interface {
// Export outputs the analysis results to the configured destination
Export(ctx context.Context, results []schemas.AnalyzeResult) error
}
Exporter defines the interface for exporting analysis results
func NewExporter ¶
func NewExporter(format OutputFormat, writer io.Writer) (Exporter, error)
type ImageResolver ¶
type ImageResolver struct {
// contains filtered or unexported fields
}
ImageResolver handles resolving Docker image tags to SHA256 digests.
func NewImageResolver ¶
func NewImageResolver(ctx context.Context, opts ...option.ClientOption) (*ImageResolver, error)
NewImageResolver creates a new resolver with ADC authentication.
func (*ImageResolver) AllLatestImages ¶
func (r *ImageResolver) AllLatestImages(ctx context.Context, projectID, location string) iter.Seq2[ImageTarget, error]
AllLatestImages returns an iterator that yields resolved image targets one by one. It scans all Docker repositories in the specified project and location. For each image found, it selects the best digest (preferring "latest" tag, otherwise newest).
func (*ImageResolver) Close ¶
func (r *ImageResolver) Close() error
Close closes the underlying API client.
type ImageTarget ¶
type ImageTarget struct {
Artifact schemas.ArtifactReference // Structured image reference
URI string // Original API response URI (for debugging)
Location string // GCP location (e.g., "us-central1")
}
ImageTarget represents a resolved target for scanning.
type OutputFormat ¶
type OutputFormat string
const ( OutputFormatJSON OutputFormat = "json" OutputFormatCSV OutputFormat = "csv" OutputFormatTSV OutputFormat = "tsv" )
func (*OutputFormat) Set ¶
func (f *OutputFormat) Set(value string) error
Set implements the flag.Value interface. ここでパース時にバリデーションが行われます。
func (*OutputFormat) String ¶
func (f *OutputFormat) String() string
String implements the flag.Value interface.
type Scanner ¶
type Scanner struct {
// contains filtered or unexported fields
}
Scanner handles the scanning of container images.
func NewScanner ¶
func NewScanner( ctx context.Context, location string, resolver *ImageResolver, analyzer *ArtifactRegistryAnalyzer, exporter Exporter, opts ...ScannerOption, ) (*Scanner, error)
type ScannerOption ¶
ScannerOption defines a function type that can configure a Scanner
func WithConcurrency ¶
func WithConcurrency(concurrency uint8) ScannerOption
WithConcurrency sets the concurrency level for parallel scanning
func WithProjectID ¶
func WithProjectID(projectID string) ScannerOption
WithProjectID sets the GCP project ID for the scanner