Documentation
¶
Index ¶
- Constants
- func ParseArtifactURI(uri string) (schemas.ArtifactReference, error)
- type AnalyzeRequest
- type Analyzer
- type ArtifactRegistryAnalyzer
- type Exporter
- type ImageResolver
- type ImageTarget
- type OutputFormat
- type Scanner
- type ScannerOption
- func WithAnalyzer(analyzer *ArtifactRegistryAnalyzer) ScannerOption
- func WithClientOptions(opts ...option.ClientOption) ScannerOption
- func WithConcurrency(concurrency uint8) ScannerOption
- func WithExporter(exporter Exporter) ScannerOption
- func WithOutputFormat(format OutputFormat, writer io.Writer) ScannerOption
- func WithProjectID(projectID string) ScannerOption
- func WithResolver(resolver *ImageResolver) ScannerOption
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 ¶
type ScannerOption ¶
ScannerOption defines a function type that can configure a Scanner
func WithAnalyzer ¶ added in v0.2.2
func WithAnalyzer(analyzer *ArtifactRegistryAnalyzer) ScannerOption
WithAnalyzer sets a custom Analyzer
func WithClientOptions ¶ added in v0.2.2
func WithClientOptions(opts ...option.ClientOption) ScannerOption
WithClientOptions sets client options for both resolver and analyzer
func WithConcurrency ¶
func WithConcurrency(concurrency uint8) ScannerOption
WithConcurrency sets the concurrency level for parallel scanning
func WithExporter ¶ added in v0.2.2
func WithExporter(exporter Exporter) ScannerOption
WithExporter sets a custom Exporter
func WithOutputFormat ¶ added in v0.2.2
func WithOutputFormat(format OutputFormat, writer io.Writer) ScannerOption
WithOutputFormat sets the output format and creates an appropriate exporter
func WithProjectID ¶
func WithProjectID(projectID string) ScannerOption
WithProjectID sets the GCP project ID for the scanner
func WithResolver ¶ added in v0.2.2
func WithResolver(resolver *ImageResolver) ScannerOption
WithResolver sets a custom ImageResolver