imagepatch

package
v2.10.2 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2026 License: BSD-3-Clause Imports: 41 Imported by: 0

Documentation

Overview

Package imagepatch owns Copacetic-based image patching, persistence, and HTTP routes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterImagePatches

func RegisterImagePatches(api huma.API, imagePatchService *ImagePatchService, appCtx handlerutil.ActivityAppContext)

RegisterImagePatches registers image patching routes using Huma.

Types

type ImagePatchHandler

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

ImagePatchHandler provides Huma-based image patching endpoints.

func (*ImagePatchHandler) ListImagePatches

ListImagePatches returns the paginated patch history for the environment.

func (*ImagePatchHandler) ListPatchTargets

ListPatchTargets returns scanned images with fixable counts and latest patch runs.

func (*ImagePatchHandler) PatchImage

PatchImage starts a background patch run for an image.

type ImagePatchRecord

type ImagePatchRecord struct {
	database.BaseModel

	EnvironmentID   string  `json:"environmentId" gorm:"column:environment_id;index:idx_image_patches_env_image"`
	OriginalImageID string  `json:"originalImageId" gorm:"column:original_image_id;index:idx_image_patches_env_image"`
	OriginalRef     string  `json:"originalRef" gorm:"column:original_ref"`
	OriginalDigest  string  `json:"originalDigest,omitempty" gorm:"column:original_digest"`
	PatchedRef      string  `json:"patchedRef" gorm:"column:patched_ref"`
	Mode            string  `json:"mode" gorm:"column:mode"`
	Status          string  `json:"status" gorm:"column:status" sortable:"true"`
	PackagesUpdated *int    `json:"packagesUpdated,omitempty" gorm:"column:packages_updated"`
	Error           *string `json:"error,omitempty" gorm:"column:error"`
	ActivityID      *string `json:"activityId,omitempty" gorm:"column:activity_id"`
	DurationMs      *int64  `json:"durationMs,omitempty" gorm:"column:duration_ms"`
}

ImagePatchRecord stores one Copacetic image patch run.

func (*ImagePatchRecord) TableName

func (r *ImagePatchRecord) TableName() string

func (*ImagePatchRecord) ToDto

type ImagePatchService

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

ImagePatchService patches image OS packages in place using the Copacetic library and records each run in the image_patches table.

func NewImagePatchService

func NewImagePatchService(db *database.DB, dockerService *docker.DockerClientService, settingsService *settings.SettingsService, activityService *activity.ActivityService, registryService *registry.ContainerRegistryService, vulnerabilityService *vulnerability.VulnerabilityService) *ImagePatchService

func (*ImagePatchService) ListPatchTargets

ListPatchTargets returns scanned images with their fixable-vulnerability counts and latest patch run, for the security page's patching view. Images that are themselves patch outputs are folded into their original's row: they are excluded from the list and surface as that row's LastPatchScan instead.

func (*ImagePatchService) ListPatches

ListPatches returns the paginated patch history for an environment.

func (*ImagePatchService) PatchFlaggedImages

func (s *ImagePatchService) PatchFlaggedImages(ctx context.Context, envID string, user common.User) (patched, skipped int, err error)

PatchFlaggedImages patches every image whose latest completed vulnerability scan found fixable vulnerabilities and stored a raw report. Images that are themselves patch outputs are skipped (never patch a patched tag), as are images already patched since their latest scan. Used by the scheduled auto-patch job.

func (*ImagePatchService) PatchImage

func (s *ImagePatchService) PatchImage(ctx context.Context, envID, imageID string, opts imagepatch.PatchOptions, user common.User) (*imagepatch.PatchRecord, error)

PatchImage starts a background patch run for the given image and returns the pending record (carrying the activity ID) immediately.

func (*ImagePatchService) PatchedRefs

func (s *ImagePatchService) PatchedRefs(ctx context.Context, envID string) (map[string]struct{}, error)

PatchedRefs returns the set of patched image references recorded for an environment, used to keep patch outputs from being patched again.

type ListImagePatchesInput

type ListImagePatchesInput struct {
	EnvironmentID string `path:"id" doc:"Environment ID"`
	Search        string `query:"search" doc:"Search query"`
	Sort          string `query:"sort" doc:"Sort field"`
	Order         string `query:"order" doc:"Sort order"`
	Start         int    `query:"start" doc:"Start offset"`
	Limit         int    `query:"limit" doc:"Limit"`
	Status        string `query:"status" doc:"Filter by patch status"`
}

type ListPatchTargetsInput

type ListPatchTargetsInput struct {
	EnvironmentID string `path:"id" doc:"Environment ID"`
	Search        string `query:"search" doc:"Search query"`
	Sort          string `query:"sort" doc:"Column to sort by"`
	Order         string `query:"order" default:"desc" doc:"Sort direction"`
	Start         int    `query:"start" default:"0" doc:"Start offset"`
	Limit         int    `query:"limit" default:"20" doc:"Limit"`
}

type Module

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

func New

func New(service *ImagePatchService) *Module

func (*Module) RegisterRoutes

func (m *Module) RegisterRoutes(api huma.API, appCtx handlerutil.ActivityAppContext)

func (*Module) Service

func (m *Module) Service() *ImagePatchService

type PatchImageInput

type PatchImageInput struct {
	EnvironmentID string `path:"id" doc:"Environment ID"`
	ImageID       string `path:"imageId" doc:"Image ID to patch"`
	Body          imagepatch.PatchOptions
}

Jump to

Keyboard shortcuts

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