Skip to content

release: the image scan gates through expiry-bounded image exceptions (060 3.2) - #491

Merged
bartekus merged 1 commit into
mainfrom
impl/060-image-scan
Nov 4, 2026
Merged

bartekus merged 1 commit into
mainfrom
impl/060-image-scan

Conversation

@bartekus

@bartekus bartekus commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Spec 060 increment 3 (3.2, the scan gate).

  • tools/rustev-release/image-exceptions.json (rustev.image-exceptions/1), committed empty. An entry: id and package as grype reports them, the owner's decision row, expires (last day, UTC) and reason. The row's date comes from docs/decisions/00-founding-decisions.md (embedded at build time); expires may be at most 90 days after it.
  • rustev-release image-scan <today> <platform>=<grype.json>... (image_scan::check) fails on an uncovered finding, an expired entry, an unused entry, and on an entry with no decision row, more than 90 days, a malformed date, an empty field or a duplicate. <today> must be today's UTC date (as for exceptions). It prints each report's scanner database build date (060 3.2.3).
  • artifacts.sh scan-image runs it in place of its own count. With the image absent from the release set (as now), a failing verdict is recorded and does not gate, as before; once the image is a member it fails image-checks.
  • No exception is added: the exceptions for the remaining "won't fix" findings are decided with the base refresh (060 decision 2).

Stacked on release/bump-0.4.0 (#480). Independent of #487/#489 except that both append to 060's implementation record (keep both paragraphs on rebase).

Checks: cargo test -p rustev-release --locked passed; clippy -D warnings passed; spec-spine verify 031 passed (4 commands); make gate passed; shellcheck artifacts.sh clean; check-authored-content.sh clean.

Review round 1: an empty decision is now reported with the other empty fields ("lacks ... decision row ..."), tested.

@bartekus bartekus added the statecraft:stacked-ci Run the full CI matrix on a stacked pull request label Nov 3, 2026
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown

AI review (findings)

Reviewing the diff for the image scan gate (spec 060 increment 3).

tools/rustev-release/src/image_scan.rs — check(), empty-field validation

The spec states the check "fails on an entry with... an empty field" as a distinct condition. The validation at lines ~184–191 covers id, package, and reason only:

if [&e.id, &e.package, &e.reason]
    .iter()
    .any(|s| s.trim().is_empty())

The decision field is not included. An empty "decision": "" bypasses this guard and falls through to decisions.get(&e.decision) returning None, producing a "no owner decision row" error instead. The scan still fails, but the spec lists "empty field" and "no decision row" as separate failure causes, and the implementation does not distinguish them for decision. The test suite (image_scan.rs line 171–174) only exercises an empty reason; an empty decision is not tested.

The expires field is implicitly covered (empty string fails days()), so the gap is specific to decision.

No other concrete defects found. The civil-date round-trip validation in days(), the exception lifecycle logic in check(), the grype-report parsing, the artifacts.sh word-split pattern, and the today-must-match-UTC guard are all correct.

{"head": "e1072875c99c612fe24a4da10f380512313d1253", "verdict": "findings", "findings": [{"path": "tools/rustev-release/src/image_scan.rs", "line": 184, "summary": "The empty-field guard checks only id, package, and reason; an empty decision field is not caught as 'empty field' but falls through to the 'no owner decision row' error, inconsistent with the spec's separate taxonomy of failure causes."}]}

Subject: e3f6b9a...e107287, diff digest 5e015acc469496a7811367cf3fc9139dba9022c7e64419511bfc6f2724395231, 1 call(s). An AI comment is not an approval.

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the diff across the five changed source files and the spec increment.

image_scan.rs - days() function

The validation checks month ∈ [1, 12] and day ≥ 1, but not day ≤ 31. Values like day=99 rely on the round-trip through civil_date. The comment explains this, the round-trip is correct, and the test suite validates it (2027-02-30 → None). No bug.

check() - expired entry still generates two errors

An expired entry is not added to live, so the matching finding also fires "no unexpired exception". The test an_expired_entry_fails_and_no_longer_covers explicitly asserts both messages. This is the intended behaviour per the spec.

check() - empty-field guard does not cover expires

expires is not in the [&e.id, &e.package, &e.decision, &e.reason] slice. An empty expires reaches the days(&e.expires) call, which returns None (length ≠ 10), producing "has no expiry date". The error path is correct; the distinction in wording is cosmetic. No bug.

decision_dates() - picks last non-empty cell as the date

The heuristic works for the actual file format as long as the date is the rightmost populated column. The integration test the_committed_file_starts_empty_and_passes_a_clean_scan asserts A-76 is found with date 2026-11-03, directly validating the real document. If the format differs, the test fails at CI time.

artifacts.sh - unquoted $reports

# shellcheck disable=SC2086 is correct and intentional: word-splitting is the mechanism that separates the per-platform arguments. Glob expansion is not a concern for the controlled $dir paths in CI. No new vulnerability.

IMAGE_EXCEPTIONS and DECISIONS embedded at compile time

Both are include_str! constants. The binary enforces the exceptions file and decisions document from its own build, consistent with the spec's intent.

check() - until > row + MAX_DAYS boundary

MAX_DAYS = 90. The condition until > row + 90 allows exactly 90 days (until == row + 90 is accepted). The test asserts days("2026-12-01").unwrap() + 90 == days("2027-03-01").unwrap() and that "2027-03-01" passes while "2027-03-02" (91 days) is rejected. Correct.

Spec text vs. code alignment

The spec says <today> must be today's UTC date; image_scan() enforces this by comparing against utc_today(). The scan-image shell path constructs the date with $(date -u +%Y-%m-%d). Consistent.

No concrete defects found.

{"head": "a219790a26541a50c99a7d880281a2c142b3223f", "verdict": "no-findings", "findings": []}

Subject: e3f6b9a...a219790, diff digest ede2f743629d12daf83f6d2d8c1b002f10838b2a556eb630c8c3d08443bb75a0, 1 call(s). An AI comment is not an approval.

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the diff for bugs, security issues, and inconsistencies.

tools/rustev-release/src/image_scan.rs

  • days(): the upper-bound of d is not validated before the arithmetic, but the round-trip check civil_date((n * 86_400).try_into().ok()?) == date correctly rejects impossible days (e.g. 2027-02-29, 2026-11-31). The test suite confirms this. No bug.
  • decision_dates(): finds the last non-empty cell as the date. Separator rows like |---|---|---| produce "---", which days() rejects. Header/note rows that don't start with A-\d+ are skipped by strip_prefix("A-"). Correct.
  • check(): expired entries are excluded from live but remain in seen (duplicate guard), so an expired entry generates both "expired on…" and "no unexpired exception" for any matching finding. This is the intended dual-failure behavior and matches the test an_expired_entry_fails_and_no_longer_covers. Correct.
  • check() validates that expires ≤ row + MAX_DAYS with strict > and that the exception is still valid on its expiry day (until < now, not <=). Both match the spec's "at most 90 days" and "last day it holds". Correct.
  • Empty expires falls through the empty-field check (which covers id, package, decision, reason) and is caught as "no expiry date" by the days() call returning None. All empty-field cases are covered.

tools/rustev-release/src/main.rs

  • image_scan() enforces today == utc_today(), preventing a future date from extending exceptions. Correct.
  • IMAGE_EXCEPTIONS and DECISIONS are compile-time embeds; this matches the pattern of EXCEPTIONS, DENY, etc. already in the file. Correct.

tools/rustev-release/artifacts.sh

  • reports accumulates with a leading space (reports="$reports linux/$arch=..." starting from reports=). Used unquoted ($reports), word splitting discards the leading space; each platform=path token is a separate argument. The shellcheck suppression is accurate. Correct.
  • release image-scan is called after the per-arch grype runs and before the gating check. The $total variable is still populated and used only in the informational echo; release image-scan itself reports the precise failure reasons. No inconsistency.

tools/rustev-release/image-exceptions.json

  • Committed empty with the correct schema. Passes the_committed_file_starts_empty_and_passes_a_clean_scan. Correct.

specs/060-the-service-image-in-the-release/spec.md

  • Increment 3 is consistent with the implementation: schema name, 90-day limit, today-date enforcement, unused/expired/uncovered failure modes, and the gating behavior while the image is absent all match the code.

No concrete defects found.

{"head": "eb88a215fabcbdfa26f16444204238fc5d6f0064", "verdict": "no-findings", "findings": []}

Subject: 983b4ac...eb88a21, diff digest ede2f743629d12daf83f6d2d8c1b002f10838b2a556eb630c8c3d08443bb75a0, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus added this pull request to the merge queue Nov 4, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Nov 4, 2026
@bartekus
bartekus force-pushed the impl/060-image-scan branch from eb88a21 to 42d9427 Compare November 4, 2026 02:38
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the diff for image_scan.rs, main.rs, artifacts.sh, image-exceptions.json, and the spec update.

image_scan.rs — days() date validation
The upper bound on the day field (d) is never checked before the civil-date computation; only d < 1 is excluded. An out-of-range value such as 2027-02-30 does reach the round-trip check (civil_date(n * 86_400) == date), which rejects it correctly. The test for "2027-02-30" returns None as expected. No bug here.

decision_dates() parser
The function picks the last non-empty pipe-delimited cell as the date, then validates it with days(). The committed test the_committed_file_starts_empty_and_passes_a_clean_scan asserts rows.get("A-76") == Some("2026-11-03") against the real decisions file, confirming the column order assumption is correct.

check() — expiry boundary
Expired when until < now, so until == now (the last day) still passes. The spec says expires is "the last day it holds". Confirmed by the test that passes today == expires.

check() — 90-day cap
until > row + MAX_DAYS is strict, so exactly 90 days is allowed. days("2026-12-01") + 90 == days("2027-03-01") is verified in the test. Correct.

check() — double error on expired entry
An expired entry does not enter live, so the matching finding also fires "no unexpired exception". This double-reporting is intentional per the spec ("fails on a finding … on an expired entry") and covered by an_expired_entry_fails_and_no_longer_covers.

image_scan() in main.rs — date enforcement
The function requires the caller-supplied today to equal utc_today(). This prevents passing a stale date to bypass expiry.

artifacts.sh — word-split on $reports
The unquoted $reports intentionally word-splits into per-platform arguments; the shellcheck suppression is correctly scoped. Paths are constructed from $dir (a CI-controlled argument) and a fixed suffix; a space in $dir would already break prior unquoted uses of $sbom in the same script, making this a pre-existing assumption rather than a new defect.

Schema enforcement
deny_unknown_fields on ImageExceptions and ImageException rejects extra keys at the JSON layer; the check() schema string check gates on the version. Covered by the test that passes "extra": 1 or a different schema string.

No concrete defect found.

{"head": "42d9427f5012571832fa797add99db5f634773b8", "verdict": "no-findings", "findings": []}

Subject: adcaa4c...42d9427, diff digest c2b466507ec6eb273212a4048d173b06b2c75e037e88c404c562b63fea99d0e0, 1 call(s). An AI comment is not an approval.

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the diff for bugs, security problems, and inconsistencies.

image_scan.rs — days() date validation

The round-trip guard crate::audit::civil_date((n * 86_400).try_into().ok()?) == date correctly rejects impossible days (Feb 29 in non-leap years, day 0, day 31 in a 30-day month). The test dates_round_trip_and_refuse_impossible_days confirms 2027-02-29 → None. ✓

days() — 90-day boundary arithmetic

MAX_DAYS = 90. Check is until > row + MAX_DAYS, so exactly 90 days passes (until == row + MAX_DAYS). Test confirms: days("2026-12-01") + 90 == days("2027-03-01") and the entry expiring 2027-03-01 passes on 2027-03-01. ✓

check() — expiry boundary

until < now means the expiry day itself still holds (the spec says "last day it holds"). Test a_covered_finding_on_every_platform_passes_until_expiry verifies check(..., "2027-03-01") returns empty on an entry that expires 2027-03-01. ✓

check() — empty expires field not in the explicit empty-field list

expires is excluded from the [&e.id, &e.package, &e.decision, &e.reason] check, so an empty expires falls through to days("") → None → "has no expiry date" error rather than "lacks…" error. The spec requires "an empty field" to fail; it does fail — just with a different message path. Not a defect: the gate still rejects it.

check() — duplicate detection leaves first valid occurrence in live

A duplicate entry adds an error but the first occurrence remains in live and covers the finding. The gate still fails (non-empty v), which is correct per spec ("fails on a duplicate"). ✓

decision_dates() — takes last non-empty cell as date

The trailing | in a markdown row produces a final empty cell; .rev().find(|c| !c.is_empty()) correctly skips it and lands on the date column. The days(date).is_some() guard rejects non-date content. ✓

artifacts.sh — unquoted $reports

Intentionally unquoted for word splitting; the # shellcheck disable=SC2086 comment documents this. Paths in $dir could theoretically contain spaces, but release directories use simple paths in practice. The leading space in reports=" linux/$arch=..." does not produce a spurious empty argument under default IFS splitting.

image_scan() in main.rs — date must equal UTC today

today is validated against utc_today() before check() is called, preventing use of a past date to extend exceptions. Same pattern as the exceptions subcommand. ✓

DECISIONS embedded at build time

include_str!("../../../docs/decisions/00-founding-decisions.md") is consistent with the spec ("embedded at build time") and the existing EXCEPTIONS / DENY pattern in the same file. ✓

No concrete defects found.

{"head": "42d9427f5012571832fa797add99db5f634773b8", "verdict": "no-findings", "findings": []}

Subject: adcaa4c...42d9427, diff digest c2b466507ec6eb273212a4048d173b06b2c75e037e88c404c562b63fea99d0e0, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus added this pull request to the merge queue Nov 4, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Nov 4, 2026
@bartekus
bartekus force-pushed the impl/060-image-scan branch from 42d9427 to dc3e189 Compare November 4, 2026 05:44
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the diff for bugs, security problems, and inconsistencies.

image_scan.rs — days() function

The civil-date formula is a standard proleptic Gregorian calculation. The round-trip check (civil_date(n * 86_400) == date) correctly rejects impossible days (e.g., 2027-02-29, 2026-01-32). The try_into().ok()? correctly returns None for dates before 1970 (negative seconds), which is harmless since all relevant dates are recent. No issue.

check() — empty-field validation

The initial empty-field guard covers id, package, decision, and reason, but not expires. An empty expires falls through to the days() call, returns None, and generates "has no expiry date". The spec requires empty fields to fail — they do, with a slightly different message path. Not a correctness bug.

check() — expiry boundary

until > row + MAX_DAYS is strict-greater, so expires exactly 90 days after the decision row is permitted. until < now is strict-less, so the expiry day itself is still valid. Both are consistent with "at most 90 days" and "last day it holds". The test a_covered_finding_on_every_platform_passes_until_expiry verifies 2027-03-01 (90 days after 2026-12-01) passes on both counts. ✓

check() — expired entry still generates two errors

An expired entry pushes "expired" and then continues, so it is not added to live. Any finding it would have covered gets "no unexpired exception" as a second error. This is correct per the spec: a finding not covered by an unexpired entry fails, and an expired entry itself fails.

decision_dates() — rightmost non-empty cell as date

The function takes the last non-empty pipe-delimited cell, validated by days(). If the decisions table has a date in a non-last column (e.g., notes after the date), it would silently miss the row. The test the_committed_file_starts_empty_and_passes_a_clean_scan verifies A-76 → "2026-11-03" parses correctly from the actual document, so the current format is handled correctly. No concrete defect given the evidence.

artifacts.sh — unquoted $reports with leading space

reports is initialized to empty and prefixed with a space on each iteration, producing linux/amd64=... linux/arm64=.... The leading space is harmless under word-splitting. The SC2086 suppression is intentional (one token per platform). No issue.

main.rs — today must equal utc_today()

The command enforces that the caller's date argument matches the actual UTC clock, preventing use of a future date to avoid an expired exception. This is a correct security control per the spec.

findings() — missing matches array

v["matches"].as_array() returns None for Value::Null (absent key) and correctly returns an error. Zero-finding reports with "matches": [] return an empty Vec. ✓

No concrete defects found.

{"head": "dc3e1891532133036ffd12460f5eb5ef3cce764d", "verdict": "no-findings", "findings": []}

Subject: c95ee4e...dc3e189, diff digest d18c0d85ad24b956924fc4d392fc1dab5624ecc4fdff9b970102c126ebfbb6ef, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus added this pull request to the merge queue Nov 4, 2026
Merged via the queue into main with commit b4b19e8 Nov 4, 2026
38 checks passed
@bartekus
bartekus deleted the impl/060-image-scan branch November 4, 2026 07:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

statecraft:stacked-ci Run the full CI matrix on a stacked pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant