feat: minimum image age gate for auto-updates#641
feat: minimum image age gate for auto-updates#641mgabor3141 wants to merge 2 commits intoFinsys:mainfrom
Conversation
91f55b4 to
e88de3c
Compare
There was a problem hiding this comment.
Pull request overview
Adds a configurable “minimum image age” gate to defer auto-updates until an image has aged past a threshold, with an optional security-fix bypass based on vulnerability scan deltas, plus per-container exclusion from environment-level scheduled updates.
Changes:
- Add environment + per-container configuration for minimum image age and (optionally) bypassing the age gate when the new image reduces critical/high CVEs.
- Implement registry lookup for image
createdtimestamp (getImageCreatedDate) and insert age-gate logic into env- and container-level update flows. - Extend auto-update settings schema/API/UI, including a per-container “exclude from environment auto-updates” toggle.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| src/routes/settings/environments/tabs/UpdatesTab.svelte | Adds environment-level controls for minimum image age + security bypass toggle. |
| src/routes/settings/environments/EnvironmentModal.svelte | Loads/saves new environment update-check settings fields. |
| src/routes/containers/EditContainerModal.svelte | Loads/saves new per-container override fields for auto-update settings. |
| src/routes/containers/ContainerSettingsTab.svelte | Wires new per-container auto-update props through settings UI. |
| src/routes/containers/AutoUpdateSettings.svelte | Adds per-container minimum age override UI, bypass toggle, and env-update exclusion toggle. |
| src/routes/api/environments/[id]/update-check/+server.ts | Extends env update-check settings API payload with new fields. |
| src/routes/api/auto-update/[containerName]/+server.ts | Extends per-container auto-update settings API + preserves rows when overrides exist. |
| src/lib/server/scheduler/tasks/update-utils.ts | Adds shouldDeferUpdate + shouldBypassAgeForSecurity helpers. |
| src/lib/server/scheduler/tasks/env-update-check.ts | Applies exclusion check and introduces min-age gate + security bypass into env auto-update job. |
| src/lib/server/scheduler/tasks/container-update.ts | Introduces min-age gate + security bypass into container auto-update task. |
| src/lib/server/docker.ts | Implements registry created timestamp lookup via manifest + config blob fetch. |
| src/lib/server/db/schema/index.ts | Adds new SQLite auto_update_settings columns to schema model. |
| src/lib/server/db/schema/pg-schema.ts | Adds new Postgres auto_update_settings columns to schema model. |
| src/lib/server/db.ts | Extends types and upsert logic for new auto-update/env update-check settings fields. |
| drizzle/meta/_journal.json | Adds migration journal entry for new settings columns (SQLite). |
| drizzle/0004_add_image_age_settings.sql | Adds SQLite migration for new auto_update_settings columns. |
| drizzle-pg/meta/_journal.json | Adds migration journal entry for new settings columns (Postgres). |
| drizzle-pg/0004_add_image_age_settings.sql | Adds Postgres migration for new auto_update_settings columns. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ced1746 to
1d2aab8
Compare
Add a configurable minimum image age requirement that defers auto-updates until images have been published for a specified number of days. This reduces risk from regressions, supply chain attacks, and quickly-retracted releases. Features: - Minimum image age (days) setting at environment and per-container level - Per-container settings override environment defaults (null = inherit) - Security fix bypass: when enabled, scans both current and new images; if the new image fixes critical/high CVEs, the age gate is bypassed - Per-container exclusion from environment-level auto-updates (update checks still report availability, but auto-update is skipped) Implementation: - New getImageCreatedDate() in docker.ts: fetches image creation timestamp from registry via manifest + config blob (handles multi-arch images) - shouldDeferUpdate() and shouldBypassAgeForSecurity() utilities - Age gate inserted in both env-update-check.ts and container-update.ts, between registry check and pull/scan phases - DB migration adds minimum_image_age_days, bypass_age_for_security_fixes, and excluded_from_env_update columns to auto_update_settings table - EnvUpdateCheckSettings extended with minimumImageAgeDays and bypassAgeForSecurityFixes (stored as JSON in settings table) UI: - Environment Settings > Updates tab: number input for minimum age, toggle for security fix bypass (shown when age > 0 and scanning enabled) - Per-container auto-update settings: age override (empty = inherit), bypass toggle, and exclusion toggle (always visible)
1d2aab8 to
d523a8c
Compare
Addressing review feedbackFixed (comments 1, 3, 4, 5, 6, 8, 9)Comment 1 — Excluded containers skip update checks too early: Comment 3 — Bypass toggle visibility when env age is 0: Comment 4 — Missing input validation on per-container API: Comment 5 — Hardcoded amd64 for multi-arch manifest resolution: Comments 6 & 9 — Tag safety in security bypass flow: Comment 8 — Missing validation on env update-check API: Acknowledged but deferred (comments 2, 7)Comment 2 — N+1 queries for Comment 7 — Duplicated pull/tag/scan flow: |
Summary
Add a configurable minimum image age requirement that defers auto-updates until images have been published for a specified number of days. This reduces risk from regressions, supply chain attacks, and quickly-retracted releases — similar to Renovate's
minimumReleaseAgefeature but adapted for Docker's mutable tag model.Features
Minimum image age (days)
null= inherit,0= disabledcreatedfield)Security fix bypass
finallyblocks that restore original tags on error pathsPer-container exclusion from environment auto-updates
Implementation
New function:
getImageCreatedDate(imageName)indocker.tsFetches the image creation timestamp from the registry via:
process.arch)createdfieldReuses existing
getRegistryBearerToken+parseImageReferenceauth flow. Tested against Docker Hub and GHCR with both OCI and Docker manifest formats.Age gate insertion points
env-update-check.ts: AftercheckImageUpdateAvailable()confirms an update, before the safe-pull flow. UsesimageAlreadyPulledflag to skip redundant pull/scan when bypass succeeds.container-update.ts: Same pattern, between registry check and pull/scan phases.New utilities in
update-utils.tsshouldDeferUpdate(createdDate, minAgeDays)— age comparison with safe handling of unparseable/suspicious dates (epoch zero, pre-2013, future)shouldBypassAgeForSecurity(currentScan, newScan)— compares critical+high CVE countsData model
EnvUpdateCheckSettings(JSON in settings table):minimumImageAgeDays,bypassAgeForSecurityFixesauto_update_settingstable: 3 new nullable columns —minimum_image_age_days,bypass_age_for_security_fixes,excluded_from_env_updateUI
Files changed (20 files)
docker.ts,update-utils.ts,env-update-check.ts,container-update.tsdb.ts,schema/index.ts,schema/pg-schema.tsdrizzle/0004_*,drizzle-pg/0004_*, journal + snapshot filesauto-update/[containerName]/+server.ts,environments/[id]/update-check/+server.tsUpdatesTab.svelte,AutoUpdateSettings.svelte,ContainerSettingsTab.svelte,EditContainerModal.svelte,EnvironmentModal.svelte