Documentation
¶
Overview ¶
Package postgres provides the PostgreSQL implementations of all domain boundary interfaces. This is the only package in the codebase that may import pgx directly.
Index ¶
- func NewPool(ctx context.Context, databaseURL string, cfg PoolConfig) (*pgxpool.Pool, error)
- func RunMigrations(pool *pgxpool.Pool) error
- type PoolConfig
- type ScanRepository
- func (r *ScanRepository) CVEAffectedImages(ctx context.Context, cveID string) ([]entities.AffectedImage, error)
- func (r *ScanRepository) Create(ctx context.Context, imageName, imageTag, imageDigest string, ...) (*entities.Scan, bool, error)
- func (r *ScanRepository) DeleteExcessAndOld(ctx context.Context, age time.Duration, keep int) (int64, error)
- func (r *ScanRepository) DeleteExcessPerImage(ctx context.Context, keep int) (int64, error)
- func (r *ScanRepository) DeleteOlderThan(ctx context.Context, age time.Duration) (int64, error)
- func (r *ScanRepository) FixableSummary(ctx context.Context, imageName string, from, to *time.Time) (*entities.FixableSummary, error)
- func (r *ScanRepository) GetByID(ctx context.Context, id string) (*entities.Scan, error)
- func (r *ScanRepository) LatestByImage(ctx context.Context, imageName string) (*entities.Scan, error)
- func (r *ScanRepository) ListAllPage(ctx context.Context, imageName, tag string, limit, offset int) ([]entities.Scan, error)
- func (r *ScanRepository) ListByImage(ctx context.Context, imageName string) ([]entities.Scan, error)
- func (r *ScanRepository) ListByImagePage(ctx context.Context, imageName string, limit, offset int) ([]entities.Scan, error)
- func (r *ScanRepository) ListByImageWithSeverity(ctx context.Context, imageName, severity string) ([]entities.Scan, error)
- func (r *ScanRepository) ListByImageWithSeverityPage(ctx context.Context, imageName, severity string, limit, offset int) ([]entities.Scan, error)
- func (r *ScanRepository) ListByTag(ctx context.Context, tag string) ([]entities.Scan, error)
- func (r *ScanRepository) ListByTagPage(ctx context.Context, tag string, limit, offset int) ([]entities.Scan, error)
- func (r *ScanRepository) TopCVEs(ctx context.Context, imageName, severity string, limit int, ...) ([]entities.TopCVE, error)
- func (r *ScanRepository) VulnerabilitySummary(ctx context.Context, imageName string, from, to *time.Time) (*entities.VulnerabilitySummary, error)
- func (r *ScanRepository) VulnerabilityTrends(ctx context.Context, imageName, bucket string, from, to *time.Time) ([]entities.VulnerabilityTrendPoint, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewPool ¶
NewPool creates and validates a new pgx connection pool. All pool tuning parameters are driven by PoolConfig, making them fully controllable via environment variables at the Container level.
func RunMigrations ¶
RunMigrations applies all pending SQL migrations to the database.
Types ¶
type PoolConfig ¶
type PoolConfig struct {
MaxConns int32
MinConns int32
MaxConnLifetime time.Duration
MaxConnIdleTime time.Duration
HealthCheckPeriod time.Duration
}
PoolConfig holds pgx connection pool tuning parameters.
type ScanRepository ¶
type ScanRepository struct {
// contains filtered or unexported fields
}
ScanRepository implements boundary.ScanPersister, boundary.ScanRetriever, boundary.ScanAnalytics, and boundary.ScanCleaner using PostgreSQL.
func NewScanRepository ¶
func NewScanRepository(pool *pgxpool.Pool) *ScanRepository
NewScanRepository creates a new ScanRepository.
func (*ScanRepository) CVEAffectedImages ¶
func (r *ScanRepository) CVEAffectedImages(ctx context.Context, cveID string) ([]entities.AffectedImage, error)
CVEAffectedImages returns all images currently exposed to a specific CVE.
func (*ScanRepository) Create ¶
func (r *ScanRepository) Create(ctx context.Context, imageName, imageTag, imageDigest string, scanResult json.RawMessage, vuln entities.VulnCounts, vulns []entities.Vulnerability) (*entities.Scan, bool, error)
Create inserts or updates a scan record and its vulnerability rows atomically.
func (*ScanRepository) DeleteExcessAndOld ¶
func (r *ScanRepository) DeleteExcessAndOld(ctx context.Context, age time.Duration, keep int) (int64, error)
DeleteExcessAndOld deletes scans that fail BOTH retention policies.
func (*ScanRepository) DeleteExcessPerImage ¶
DeleteExcessPerImage keeps only the <keep> most recent scans per image name.
func (*ScanRepository) DeleteOlderThan ¶
DeleteOlderThan removes all scans whose created_at is older than the given duration.
func (*ScanRepository) FixableSummary ¶
func (r *ScanRepository) FixableSummary(ctx context.Context, imageName string, from, to *time.Time) (*entities.FixableSummary, error)
FixableSummary returns how many current vulnerabilities have a known fix.
func (*ScanRepository) LatestByImage ¶
func (r *ScanRepository) LatestByImage(ctx context.Context, imageName string) (*entities.Scan, error)
LatestByImage returns the most recent scan for a given image name.
func (*ScanRepository) ListAllPage ¶
func (r *ScanRepository) ListAllPage(ctx context.Context, imageName, tag string, limit, offset int) ([]entities.Scan, error)
ListAllPage returns scans with optional image/tag filters and pagination.
func (*ScanRepository) ListByImage ¶
func (r *ScanRepository) ListByImage(ctx context.Context, imageName string) ([]entities.Scan, error)
ListByImage returns all scans for a given image name, newest first.
func (*ScanRepository) ListByImagePage ¶
func (r *ScanRepository) ListByImagePage(ctx context.Context, imageName string, limit, offset int) ([]entities.Scan, error)
ListByImagePage returns scans for an image with optional pagination.
func (*ScanRepository) ListByImageWithSeverity ¶
func (r *ScanRepository) ListByImageWithSeverity(ctx context.Context, imageName, severity string) ([]entities.Scan, error)
ListByImageWithSeverity returns scans with at least one vuln of the given severity.
func (*ScanRepository) ListByImageWithSeverityPage ¶
func (r *ScanRepository) ListByImageWithSeverityPage(ctx context.Context, imageName, severity string, limit, offset int) ([]entities.Scan, error)
ListByImageWithSeverityPage is the paginated variant of ListByImageWithSeverity.
func (*ScanRepository) ListByTagPage ¶
func (r *ScanRepository) ListByTagPage(ctx context.Context, tag string, limit, offset int) ([]entities.Scan, error)
ListByTagPage returns scans for a tag with optional pagination (limit=-1 = no limit).
func (*ScanRepository) TopCVEs ¶
func (r *ScanRepository) TopCVEs(ctx context.Context, imageName, severity string, limit int, from, to *time.Time) ([]entities.TopCVE, error)
TopCVEs returns the most common CVEs across the latest scan of each image:tag.
func (*ScanRepository) VulnerabilitySummary ¶
func (r *ScanRepository) VulnerabilitySummary(ctx context.Context, imageName string, from, to *time.Time) (*entities.VulnerabilitySummary, error)
VulnerabilitySummary returns aggregate vulnerability counts.
func (*ScanRepository) VulnerabilityTrends ¶
func (r *ScanRepository) VulnerabilityTrends(ctx context.Context, imageName, bucket string, from, to *time.Time) ([]entities.VulnerabilityTrendPoint, error)
VulnerabilityTrends returns vulnerability counts bucketed by day or week.