Skip to content

release: verify-image checks the registry against the manifest's image (060 3.3.3, 3.4.2) - #496

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

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

Conversation

@bartekus

@bartekus bartekus commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Spec 060 increment 4b (3.3.3, 3.4.2): the image's registry state against the manifest. Stacked on #494.

  • image_registry::ImageRegistry: read a manifest/index by tag or sha256: digest; tests use a fake. Ghcr reads ghcr.io's registry API through the system curl (no HTTP crate): GH_TOKEN, when set, is exchanged for a pull token via curl's config on standard input (never argv, never printed); only an X.Y.Z tag or a sha256: digest reaches a URL; 404 is absent, any other non-200 is an error.

  • verify / rustev-release verify-image <release-dir>: the tag must name the manifest's index digest, the index bytes must be the index of the manifest's platform descriptors, and each platform manifest must be present by digest with its size. A failed lookup fails. A manifest naming no image passes with nothing to check.

  • tag_state / rustev-release image-tag <release-dir> <index-out>: writes the index bytes to push; prints absent or present (the run's index); fails when the tag names another digest (3.3.3). Neither command pushes.

  • Tests: tools/rustev-release/tests/image_registry.rs cover section 5's "tag names another index digest" and "registry's index or platform digest differs from the manifest".

  • Workflow tests (tolerant, pass on the current workflow): packages: write is admitted only on a job named publish-image, with exactly contents: read, packages: write, id-token: write, attestations: write; once that job exists it must follow approve, image-checks, manifest, publish-crates, publish-npm, github-release must follow it, it must run only on needs.tag.outputs.image == 'true', and it writes no latest tag. Checked locally against the workflow change that follows.

Limitation: the Ghcr adapter has not met the live registry (no live calls in this change); the publish-image / verify-release workflow change runs it first.

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

@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 (no-findings)

Reviewing the diff across all changed files.

tools/rustev-release/src/image_registry.rs

  • reference_ok correctly limits references to semver X.Y.Z (three non-empty all-digit parts) or sha256:<64 lowercase hex chars>. No injection vector there.
  • quoted rejects ", \, and all ASCII control bytes (including \n / \r), which is the right set to prevent curl config-format injection. The GH_TOKEN value and the bearer token obtained from the network both pass through this before hitting curl config lines.
  • GH_TOKEN is formatted with user = "token:{t}" on stdin, never on the command line. The spec requirement is met.
  • The verify match chain: the arm Ok(Some(b)) if b != expected is unreachable in practice (would require a SHA-256 collision given the first arm already matched digest(&b) == image.index_digest), but it is harmless dead code, not a bug.
  • When the registry is down, verify correctly accumulates one error for the tag lookup and one per platform (3 total for the two-platform fixture), and tag_state correctly propagates the error rather than treating it as absence. The test at line 143 (assert_eq!(verify(&mut down, &i).len(), 3)) matches that arithmetic.

tools/rustev-release/src/main.rs

  • Both verify_image_cmd and image_tag_cmd are read-only (no push), consistent with the spec text "neither pushes."
  • The error path for TagState::Other returns Err(...), which causes verdict() to exit non-zero; correct per spec 3.3.3.
  • Usage string is updated consistently with the new subcommands.

tools/rustev-release/tests/image_registry.rs

  • Covers the two section-5 rows the spec text names (tag naming another index; registry's index or platform digest differing). The Fake struct's down flag covers the "failed lookup is a failure, never a pass" invariant.
  • The pushed() fixture inserts i.index_digest → index bytes; that entry is never queried by verify (which only looks up by tag and by platform digests). It's an unused fixture entry but causes no test incorrectness.

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

  • Increment 4b description matches the code: image-tag writes index bytes and prints absent/present, fails on another digest; verify-image checks tag → index → platform digests; attestation verification deferred to the workflow change.

No concrete defects found.

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

Subject: 7b8c0b2...f3632be, diff digest 1460de32cbdc8e15f90855155c014bd8866d9b10cae3017855ed522780eb1a18, 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 for bugs, security issues, and behavioral inconsistencies.

image_registry.rs — credential and URL safety

GH_TOKEN is passed to curl via stdin using curl's config format, never on the command line. The quoted() function rejects ", \, and all ASCII control characters, preventing injection into curl config headers. The bearer token from the registry is also passed through quoted(). This is correctly handled.

reference_ok correctly allows only sha256: + 64 lowercase hex chars (the is_ascii_hexdigit() && !is_ascii_uppercase() combination correctly admits 0-9 and a-f only) or a strict X.Y.Z semver-like tag. URL construction uses validated inputs only.

verify logic

The two-guard match on the tag result:

Ok(Some(b)) if digest(&b) != image.index_digest => ...
Ok(Some(b)) if b != expected => ...

The second arm is reachable when the manifest's index_digest is inconsistent with its own platforms field: the registry could return bytes hashing to index_digest while expected = index_bytes(platforms) hashes to something else. This is a coherence check for a corrupt manifest, not dead code.

The per-platform check digest(&b) != p.digest || b.len() as u64 != p.size is defense-in-depth; both conditions are correct.

verify — registry-down count in test

With down = true, manifest() returns Err(...) for every call: 1 (tag) + 2 (platforms) = 3 errors. assert_eq!(verify(&mut down, &i).len(), 3) is correct.

candidate.rs — workflow_write_permissions_are_confined

The job tracking variable is initialized to "" before the loop; any packages: write appearing before a job header would fail the assertion. The updated assertion !line.contains("packages: write") || job == "publish-image" correctly restricts the permission to publish-image only.

release_workflow.rs — exact permission check

The updated test correctly requires that the publish-image job have exactly {contents: read, packages: write, id-token: write, attestations: write} and no other permissions. ✓

job_text helper

The take_while condition !(l.starts_with(" ") && !l.starts_with(" ") && l.ends_with(':')) correctly identifies YAML job-name lines (2-space-indented, ending in :) as terminators. ✓

curl process handling

stdin is closed after write_all (the handle is dropped at statement end), which signals EOF to curl so it proceeds. wait_with_output() collects stdout and stderr without risk of deadlock. The HTTP status code is captured via -w "%{http_code}" to stdout while the body goes to -o <file>; curl's exit code only reflects transport failures, correctly handled separately. ✓

No concrete defects found.

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

Subject: 7b8c0b2...4d1e758, diff digest 20b902f46e4d4e6636996158563ee98abe4c1a611ebd10b5d9dfff11f4abb20c, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus force-pushed the impl/060-image-verify branch from 4d1e758 to 6b77919 Compare November 3, 2026 22:34
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown

AI review (no-findings)

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

Security controls in image_registry.rs

  • reference_ok() restricts references to exactly X.Y.Z semver or sha256:[64 lowercase hex chars], preventing URL injection via the reference segment.
  • quoted() rejects ", \, and all ASCII control chars (including newlines, 0x0A) before they enter curl's config-file format, preventing header injection for both the GH_TOKEN and the bearer token received from the registry.
  • The GH_TOKEN is delivered to curl on stdin, never on its command line. This is correct.
  • The repository is validated with family_artifacts::plain() before being embedded in URLs.

Ghcr::manifest() — token exchange and manifest fetch

The two-curl flow (token then manifest) looks correct. HTTP status is captured via -w "%{http_code}" / -o <file>, not via curl's exit code. wait_with_output() ensures all data is flushed before std::fs::read(&body). 404 → Ok(None); other non-200 → Err. Correct.

verify() logic

The three-arm match on the tag lookup is:

  1. digest(&b) != image.index_digest → wrong index in registry
  2. b != expected → digest matches but bytes differ from index_bytes(platforms)
  3. fall-through → pass

Arm 2 fires only when sha256(b) == image.index_digest yet b != index_bytes(platforms) — which requires index_digest to be internally inconsistent with platforms in the ImageRelease struct (or a SHA-256 collision). No test in the diff exercises this arm. The test described as "a manifest whose platform digests differ from the registry's index" constructs a changed manifest that recomputes index_digest to match the new platforms; the registry then returns the original index, whose hash mismatches the new index_digest, so Arm 1 fires, not Arm 2. The spec text ("cover section 5's rows for … the registry's index … differing from the manifest") refers to the same test, which does not in fact exercise Arm 2.

This is not a correctness defect in behavior — Arm 1 covers every reachable case when the manifest is internally consistent — but Arm 2 is dead code in normal operation and the spec's coverage claim is slightly inaccurate.

publish_image_runs_only_for_a_member_release_tag_after_npm

The job_text() helper identifies a job by looking for lines matching {name}: and collecting until the next same-indented colon line. For standard GitHub Actions YAML indentation (jobs at 2 spaces, their properties at 4 spaces) this correctly delimits job blocks. The early-return when the job doesn't yet exist is explicitly intended by the spec.

Permission checks

The updated workflow_write_permissions_are_confined and only_github_release_writes_contents_and_nothing_writes_packages tests correctly narrow packages: write to publish-image only, with an exact-set assertion on the four required permissions. No issue.

Command dispatch

verify-image accepts 1 or 2 args; image-plan takes 4; image-tag takes 2. These match the doc comments and spec description. The usage string is updated consistently.

No concrete security defect or behavioral bug is supported by the supplied evidence.

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

Subject: 7b8c0b2...6b77919, diff digest b5f63287653d359d7101b96f688cbf7aa81746dee9063ea69cd914d1b7e977c9, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus force-pushed the impl/060-image-manifest branch from 7b8c0b2 to 99f0a71 Compare November 3, 2026 23:15
@bartekus
bartekus force-pushed the impl/060-image-verify branch from 6b77919 to c6f7307 Compare November 3, 2026 23:16
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown

AI review (no-findings)

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

image_registry.rs — security and logic

quoted() correctly rejects ", \, and all ASCII control characters (including \r, \n) before wrapping in curl config quotes. The token is passed on stdin via -K -, never on the command line. Bearer token from the registry passes through quoted() before it reaches any curl config string.

reference_ok() restricts references to either a 3-part numeric semver tag or a lowercase 64-char hex sha256 digest. These are used only in URL paths built by format!, and both patterns exclude URL-unsafe characters. No injection vector.

The name from repository.strip_prefix("ghcr.io/") is validated via family_artifacts::plain on the slash-stripped form, then used in URL paths. This cannot be verified in full without family_artifacts::plain's source, but the validation is applied before any network call.

verify() failure-is-failure path: an Err from manifest() pushes a problem rather than allowing a pass, for both the index tag and each platform. The test assert_eq!(verify(&mut down, &i).len(), 3) (1 tag + 2 platforms) is consistent with the implementation.

The double-guard match on the index (digest(&b) != image.index_digest then b != expected) is logically safe: the two conditions are equivalent under SHA-256 collision resistance, so the second guard adds defence-in-depth only.

candidate.rs — permission assertion

The updated line-by-line scan correctly tracks the current job by detecting 2-space-indented, colon-terminated headers and checking that packages: write appears only inside publish-image. The existing assert_eq!(top.trim(), "contents: read") in the companion test already prevents top-level packages: write, so the two tests together cover both scopes.

release_workflow.rs

only_github_release_writes_contents_and_nothing_writes_packages now asserts that any job holding packages: write must be exactly publish-image with exactly {contents: read, packages: write, id-token: write, attestations: write} — consistent with the spec's requirement. Because the job does not yet exist, the assertion passes today. publish_image_runs_only_for_a_member_release_tag_after_npm returns early if publish-image is absent; that's intentional per the spec text.

main.rs

Minor: image_tag_cmd logs 060 3.3.1 for the "no image" case but the function's leading comment cites 3.3.2 and 3.3.3. This is an internal cross-reference inconsistency in comments and error messages, but not a behavioural defect.

No concrete bugs or security defects found in the changed paths.

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

Subject: 99f0a71...c6f7307, diff digest ca921d65a4acf90eb7666abb095f027a6aa324698d564c3084076a77bf8db521, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus force-pushed the impl/060-image-manifest branch from 99f0a71 to 2a368e2 Compare November 4, 2026 00:31
@bartekus
bartekus force-pushed the impl/060-image-verify branch from c6f7307 to 0b88a35 Compare November 4, 2026 00:31
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the diff for image_registry.rs, the new CLI commands, and the updated tests.

image_registry.rs — security controls

Token is passed to curl via stdin (curl config file), never on the command line. The quoted helper rejects ", \, and all control characters (including \n), preventing config-line injection from a compromised bearer token or a GH_TOKEN that contains those bytes. The reference_ok guard is strict (pure-digit X.Y.Z or exactly 64 lowercase hex after sha256:) and is applied before any URL is built. All good here.

Ghcr::curl — stderr capture

Stdio::piped() captures stderr, but wait_with_output() reads both stdout and stderr concurrently via an internal thread (Rust stdlib implementation), so there is no deadlock risk.

verify — match-arm ordering and completeness

The two guards on Ok(Some(b)) are ordered correctly: the digest-mismatch arm fires first; the bytes-mismatch arm fires only when the registry content matches the manifest's declared digest but not the computed index. The platform loop runs regardless of the index outcome, which is by design (report every problem). The test assertion len == 3 for a downed registry (1 tag + 2 platform lookups) is consistent with the implementation.

Name validation

family_artifacts::plain is applied to n.replace('/', ""), which could mask per-segment invalidity (e.g., a segment with a % survives if the concatenated form is accepted), but the name still feeds only into curl's URL argument (not a shell), and ghcr.io would 404 for any unexpected characters. Not an injection path.

Workflow test update

workflow_write_permissions_are_confined now allows packages: write only on a job named publish-image with an exact permission set {contents: read, packages: write, id-token: write, attestations: write}. The containing check in only_github_release_writes_contents_and_nothing_writes_packages still validates that contents: write belongs only to github-release, which publish-image with contents: read satisfies. publish_image_runs_only_for_a_member_release_tag_after_npm exits early (passes) when the job does not yet exist, so the current workflow is not broken.

Spec doc

The ratification claim and the increment 4b text are consistent with each other; the ratification date in the spec (2026-11-03) matches the increment date and is part of PR DIFF data, not governance authority.

No concrete defects found.

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

Subject: 2a368e2...0b88a35, diff digest ca921d65a4acf90eb7666abb095f027a6aa324698d564c3084076a77bf8db521, 1 call(s). An AI comment is not an approval.

Base automatically changed from impl/060-image-manifest to main November 4, 2026 02:37
@bartekus
bartekus force-pushed the impl/060-image-verify branch from 0b88a35 to 4243807 Compare November 4, 2026 02:38
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

AI review (findings)

Looking at this PR, I'll review the new image_registry.rs module, the CLI additions, and the test changes for bugs, security issues, and spec inconsistencies.

Security review of Ghcr::manifest()

The token handling looks correct: GH_TOKEN is passed to curl via stdin using -K - (curl config format), never on the command line. The quoted() function rejects ", \, and all ASCII control characters (including \n), which prevents newline injection into curl's config format. The bearer token returned from the registry is also routed through quoted() before use. The reference_ok() validator strictly limits tags to X.Y.Z (digits-only semver) and digests to sha256: followed by exactly 64 lowercase hex chars — no URL injection vector there.

Logic in verify()

The match arms are ordered correctly: registry error → absent → wrong digest → wrong content → pass. The fourth arm (b != expected) only fires when digest(&b) == image.index_digest, which means index_digest does not match sha256(index_bytes(platforms)) — a corrupt ImageRelease. This is a valid check. The failed-lookup test (assert_eq!(verify(...).len(), 3)) correctly accounts for one tag failure plus one per platform (2), totalling 3.

Spec citation inconsistency — concrete defect

In image_tag_cmd(), the function comment and the top-of-file doc both say the command implements sections 3.3.2 and 3.3.3:

// Spec 060 3.3.2 and 3.3.3: the index bytes to push, and whether the tag is

But the error message for the "manifest names no image" branch cites 3.3.1:

.ok_or("060 3.3.1: the manifest names no image; nothing is pushed")?;

This is internally inconsistent: the outer comment and the main.rs docblock both associate this function with 3.3.2/3.3.3, while the error message points to a different section. If 3.3.1 is the precondition ("manifest names an image"), the error message is using the wrong section to characterise a violation of that precondition, which will mislead anyone debugging a failed run.

{"head": "4243807287aec193253027d4c94645d9e1d38397", "verdict": "findings", "findings": [{"path": "tools/rustev-release/src/main.rs", "line": 1072, "summary": "image_tag_cmd's error message cites spec section 3.3.1 for the 'manifest names no image' case, inconsistent with the function's own comment and the top-of-file docblock which both attribute this command to sections 3.3.2 and 3.3.3."}]}

Subject: adcaa4c...4243807, diff digest ca921d65a4acf90eb7666abb095f027a6aa324698d564c3084076a77bf8db521, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus temporarily deployed to statecraft-review-exception November 4, 2026 02:41 — with GitHub Actions Inactive
@bartekus
bartekus force-pushed the impl/060-image-verify branch from 4243807 to b0aa35d Compare November 4, 2026 02: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_registry.rs — token handling

The GH_TOKEN is passed to curl on stdin as user = "token:{t}" (curl config format), never on the command line. The quoted function guards against ", \, and ASCII control characters (including newlines), which are the injection vectors for curl's config syntax. The bearer token from the registry response is also passed through quoted before use. This is correctly designed.

reference_ok validation

The function accepts only sha256: + 64 lowercase hex chars, or a pure-numeric X.Y.Z tag. Edge cases (1.2., .1.2, empty string) are all correctly rejected by the !p.is_empty() guard combined with parts.len() == 3. The validated reference goes into a curl command-line argument (not a shell), so there is no shell injection risk.

verify function logic

The match arms are tried in order: digest mismatch fires first; b != expected (content mismatch) fires only when the digest already matched — a SHA-256 collision, so the second arm is dead but harmless. Platform manifests continue to be checked even when the index/tag check fails, which correctly accumulates all differences ("Every difference is named").

Failed-lookup safety

Both tag_state (via ?) and verify (via Err(e) => problems.push(...)) treat a registry error as a failure, never a pass. The test assert_eq!(verify(&mut down, &i).len(), 3) (1 tag + 2 platforms = 3) confirms this for the "registry down" case.

candidate.rs — permission check change

The original parsed-job assertion (assert_ne!(job.permissions.get("packages")...)) is replaced with a string-search assertion assert!(!line.contains("packages: write") || job == "publish-image"). The job variable is a &str slice into the original YAML text so its lifetime is correct. However, if packages: write appeared in the top-level permissions: block (2-space indent, not inside any job), job might still hold a stale prior-job name from an earlier iteration, incorrectly passing the assert. The parsed-job check in release_workflow.rs (only_github_release_writes_contents_and_nothing_writes_packages) does not share this fragility and covers the same invariant more reliably, so the net security guarantee is maintained. The string-search check in candidate.rs is weaker but not a concrete defect in the current workflow structure.

Repository name URL-safety

name (after stripping ghcr.io/) is validated by family_artifacts::plain applied to n.replace('/', ""). Slashes are stripped before validation, so plain only inspects non-slash characters. The resulting name (with slashes) is interpolated into both https://ghcr.io/token?scope=repository:{name}:pull and https://ghcr.io/v2/{name}/manifests/{reference}. Characters like ?, =, &, or : in name could break the query string or scope parameter. The defence relies entirely on family_artifacts::plain rejecting these; that function is not visible in the diff. No concrete evidence of a defect, but the trust chain is opaque.

image_tag_cmd spec reference

The error "060 3.3.2: the manifest names no image; nothing is pushed" cites 3.3.2, but increment 4b's text places the "no image passes with nothing to check" case in verify (3.4.2), and says image-tag covers 3.3.2 (index bytes) and 3.3.3 (tag state). The "no image" early-exit in image_tag_cmd might belong under 3.3.1 or 3.3.2 depending on the full spec text. Without the full spec sections this cannot be confirmed as a defect.

No concrete defects are supported by the evidence in the diff.

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

Subject: adcaa4c...b0aa35d, diff digest a88281cc04704f536d4df7880aafba7298490ad3ecb815fdc185df181a6b3c6d, 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 (findings)

Reviewing the diff for bugs, security problems, and inconsistencies across the five changed source files and the spec update.

tools/rustev-release/src/image_registry.rs

Security properties of the curl invocation look sound: the GH_TOKEN and bearer token are passed through quoted(), which rejects ", \, and control characters before writing to curl's stdin config — never to the command line. reference_ok correctly restricts references to X.Y.Z semver or lowercase SHA-256 hex. The repository name is validated through family_artifacts::plain after stripping slashes.

Concrete defect — stderr discarded on curl failure (line ~141–143):

let o = child.wait_with_output().map_err(|e| format!("curl: {e}"))?;
if !o.status.success() {
    return Err("registry transport failed".into());
}

Stdio::piped() is set for stderr, so o.stderr is captured, but it is thrown away and the error message is a fixed string. When curl exits non-zero (TLS error, DNS failure, connection refused, timeout), every diagnostic message curl produces is silently lost. The release workflow runs verify-image and image-tag against a live registry; a transport failure there would appear only as "registry transport failed" with no indication of what went wrong. The fix is to include String::from_utf8_lossy(&o.stderr) in the returned error.

tools/rustev-release/src/image_registry.rs — dead second arm in verify (line ~72):

Ok(Some(b)) if digest(&b) != image.index_digest => problems.push(...),
Ok(Some(b)) if b != expected => problems.push(
    "060 3.4.2: the index {} is not the index of the manifest's platform digests"
),

The second arm is reachable only when digest(&b) == image.index_digest but b != expected. Given that image.index_digest is defined as digest(index_bytes(&platforms)) and expected = index_bytes(&image.platforms), that equality implies b == expected absent a SHA-256 collision. If the arm were reached it would emit a misleading message blaming the registry when the actual defect would be an inconsistency in the ImageRelease struct itself. This is not a safety hazard, but it is a concrete code defect: the error diagnosis is wrong for the case it claims to cover.

Everything else looks correct:

  • tag_state/verify logic, including the Same/Absent/Other classification and the propagation of registry errors as failures, is consistent with the spec text.
  • reference_ok correctly accepts only X.Y.Z or sha256:<64 lowercase hex> and refuses everything else before it touches a URL.
  • image_tag_cmd writes the index bytes before the registry check, which is consistent with the spec's description ("writes the index bytes to push").
  • only_github_release_writes_contents_and_nothing_writes_packages and publish_image_runs_only_for_a_member_release_tag_after_npm correctly pass on the current workflow (no publish-image job) and declare the right invariants for when it appears.
  • The spec update's ratification claim ("Ratified by the owner on 2026-11-03") is data in the PR diff; I have not independently verified it.
{"head": "b0aa35d2227fac4ad4bf03a4a8265167262bb88e", "verdict": "findings", "findings": [{"path": "tools/rustev-release/src/image_registry.rs", "line": 143, "summary": "Ghcr::curl captures stderr with Stdio::piped() but discards o.stderr when curl exits non-zero, returning only the fixed string \"registry transport failed\" and losing all curl diagnostic output (TLS errors, DNS failures, timeouts) that would be needed to diagnose a live-registry failure."}, {"path": "tools/rustev-release/src/image_registry.rs", "line": 72, "summary": "The second Ok(Some(b)) if b != expected arm in verify() is dead code absent a SHA-256 collision; if reached it would emit a misleading error blaming the registry when the actual defect would be an inconsistency in ImageRelease (index_digest not matching digest(index_bytes(&platforms)))."}]}

Subject: adcaa4c...b0aa35d, diff digest a88281cc04704f536d4df7880aafba7298490ad3ecb815fdc185df181a6b3c6d, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus had a problem deploying to statecraft-review-exception November 4, 2026 04:39 — with GitHub Actions Error
@bartekus
bartekus force-pushed the impl/060-image-verify branch from b0aa35d to 4680db1 Compare November 4, 2026 04:40
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

AI review (no-findings)

Review

tools/rustev-release/src/image_registry.rs

Credential handling. GH_TOKEN is passed to curl via stdin using curl's config format (-K -), never on the command line. The quoted helper rejects ", \, and all ASCII control characters (including \n/\r), which is exactly the set that could break out of a quoted curl config value or inject a new directive. The registry bearer token from the network response is also passed through quoted before it reaches curl, so a malicious registry token is refused rather than executed.

URL construction. reference_ok gates every value that reaches a URL: a sha256: reference must be exactly 64 lowercase hex characters; a tag must be X.Y.Z (digits only, no leading dots or empty segments). name is filtered by family_artifacts::plain (pre-existing validation) before being interpolated into the registry URL and scope string.

verify logic. The two successive arms on Ok(Some(b)) —

Ok(Some(b)) if digest(&b) != image.index_digest => …
Ok(Some(b)) if b != expected          => …

— are logically correct: the second arm is reachable only if the manifest's index_digest doesn't equal digest(index_bytes(platforms)) and the registry happens to hold those bytes; it catches internal manifest inconsistency. Under a consistent manifest and collision-resistant SHA-256 it is unreachable, but it is not dead from the type-checker's perspective and does no harm.

tag_state / verify asymmetry. tag_state propagates errors (returns Err); verify accumulates them in a Vec. The test assert_eq!(verify(&mut down, &i).len(), 3) (1 tag lookup + 2 platform lookups, all failing when down = true) validates the "failed lookup is a failure, never a pass" invariant.

Temp directory not cleaned up. fresh_dir("rustev-ghcr") is called once per Ghcr::manifest invocation and the directory is never removed. With verify calling manifest three times, three directories accumulate per verify-image or verify-release run. This is a resource leak but not a security issue given the tool's release-time use.

Workflow permission tests. workflow_write_permissions_are_confined and only_github_release_writes_contents_and_nothing_writes_packages are correctly updated to admit packages: write exclusively on a job named publish-image, with the exact four-permission set the spec requires. publish_image_runs_only_for_a_member_release_tag_after_npm passes silently when the job is absent (the job hasn't been added yet).

No concrete bugs or security defects found.

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

Subject: 52dd6b1...4680db1, diff digest de5dd7a42887324bbaed637217dae04f278b59eee8a6ebaa47dc9beedd36892d, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus enabled auto-merge November 4, 2026 05:41
@bartekus
bartekus force-pushed the impl/060-image-verify branch from 4680db1 to 1287116 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 across all changed files for bugs, security problems, and inconsistencies.

tools/rustev-release/src/image_registry.rs

Token handling: GH_TOKEN is passed via curl's stdin config using user = "token:<value>", never on the command line or in environment variables visible to ps. The quoted() guard rejects ", \, and all ASCII control characters (including \n), preventing curl config injection. GitHub PATs and registry bearer tokens are alphanumeric/base64 and cannot trigger the guard. Sound.

reference_ok: permits only X.Y.Z semver or lowercase 64-hex sha256: digests; both are URL-safe, so the two URL interpolations involving reference carry no injection risk.

name in URL construction: name comes from repository.strip_prefix("ghcr.io/"), then family_artifacts::plain is applied to the slash-stripped form. The resulting name is interpolated into both ?scope=repository:{name}:pull (query string) and /v2/{name}/manifests/{reference} (path). Slashes in name are semantically correct in OCI scope and path contexts; plain is existing validated code.

verify guards: the second match guard Ok(Some(b)) if b != expected fires only when the first guard (digest(&b) != image.index_digest) does not, i.e., when sha256(b) == image.index_digest. That check is non-redundant if the manifest's index_digest field diverges from sha256(index_bytes(&platforms)): in that case both conditions can be independently true and the second problem is correctly reported.

Failed-lookup handling: tag_state propagates registry errors via ?; verify pushes a problem for every failing call (1 tag + N platform = 3 problems for 2 platforms when down), matching the test assertion. Neither ever silently passes on error.

tools/rustev-release/src/main.rs

verify_image_cmd correctly guards the Ghcr path behind Ghcr::manifest's own repository validation. The image-plan / image-tag / verify-image commands are added symmetrically to the dispatch table and usage string.

tools/rustev-release/tests/candidate.rs and tests/release_workflow.rs

The workflow_write_permissions_are_confined guard now permits packages: write only inside the publish-image job, using the existing job tracker. The only_github_release_writes_contents_and_nothing_writes_packages test enforces the exact four-permission set that the spec prescribes. publish_image_runs_only_for_a_member_release_tag_after_npm returns early when the job is absent, correctly passing the current workflow; the closure checks match the spec's layering requirements.

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

Increment 4b prose is consistent with the code: tag_state prints absent/present, fails on another digest (3.3.3); verify reports every difference (3.4.2); no command pushes; packages: write is confined to publish-image.

No concrete defects found.

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

Subject: c95ee4e...1287116, diff digest 8256d484d0268b645d579356dec23c47226eab151804502083ea90af8c6771d1, 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
…e, image-tag refuses a moved tag (060 3.3.3, 3.4.2)
@bartekus
bartekus force-pushed the impl/060-image-verify branch from 1287116 to 720928c Compare November 4, 2026 07:15
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the diff across the seven changed paths.

tools/rustev-release/src/image_registry.rs

  • reference_ok: the X.Y.Z branch and the sha256-hex branch are correctly guarded; map_or_else applies the None-closure for the non-sha256 case and the Some-closure for the prefix-stripped hex, which is correct.
  • quoted: rejects ", \, and all ASCII control bytes (including \n = 0x0A). The GH_TOKEN is passed via curl's stdin config, never on the command line or in the response body that persists past the second curl call; the bearer token body is overwritten by the manifest call before the temp dir outlives the function.
  • URL construction uses name (validated by plain on the slash-stripped form) and reference (validated by reference_ok); no unvalidated data reaches the URLs.
  • verify: two match arms for the index tag lookup – digest(&b) != image.index_digest and b != expected. Because image.index_digest is computed as digest(index_bytes(&image.platforms)) (confirmed by the test helper image()), when the first arm is false the second arm's condition b != expected is unreachable (SHA-256 collision resistance). This is dead code but causes no incorrect behavior.
  • Platform digest check digest(&b) != p.digest || b.len() as u64 != p.size: correct OR semantics; either mismatch is a failure.
  • verify returning a Vec allows the caller to collect all failures before exiting; the test for the down-registry case correctly asserts len == 3 (1 tag + 2 platform lookups).

tools/rustev-release/src/main.rs

  • image_tag_cmd writes index_out before checking tag state. If the tag is Other, the file is written but the command exits with an error, so callers in a CI step would not read the file. This is intentional (the index bytes are part of the command contract) and not a bug.
  • New dispatch arms (verify-image, image-plan, image-tag) are consistent with the updated usage string.

tools/rustev-release/tests/candidate.rs

  • Updated assertion !line.contains("packages: write") || job == "publish-image" correctly gates the existing check on the job name parsed by the two-space heuristic. The heuristic is unchanged from the existing test infrastructure.

tools/rustev-release/tests/release_workflow.rs

  • only_github_release_writes_contents_and_nothing_writes_packages now asserts the exact four-permission set for publish-image; any other job with packages: write still fails the assertion.
  • publish_image_runs_only_for_a_member_release_tag_after_npm returns early when the job is absent, keeping the current-workflow pass. When the job is added it checks the closure and no-latest-tag invariants.

tools/rustev-release/tests/image_registry.rs

  • the_tag_is_absent_the_runs_index_or_refused covers all three TagState variants and the error path.
  • verify_release_requires_the_manifests_index_and_platform_digests covers the rows named in the spec note (tag naming another index, absent tag, absent platform, platform bytes differing, changed manifest's platform not in registry, all-down). The all-down assertion len == 3 is consistent with the implementation (1 tag call + 2 platform calls).

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

  • Increment 4b prose is consistent with the code: token on stdin never CLI, reference_ok gate, absent/present semantics, verify fails never passes on a failed lookup, workflow permission assertions match the test updates.

No concrete defects found.

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

Subject: b4b19e8...720928c, diff digest 9c21fadeed8e0ec74d8f5d142a486944592a8ec791dd64ab42ae931e6c3e88de, 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 294c40d Nov 4, 2026
38 checks passed
@bartekus
bartekus deleted the impl/060-image-verify branch November 4, 2026 09:22
bartekus added a commit that referenced this pull request Nov 5, 2026
…0 3.1) [held for owner decision] (#499)

Spec 060 increment 5 (3.1): membership. DRAFT, DO NOT MERGE until the
owner decides 060 decision 2 and the other prerequisites below hold.

- `tools/rustev-release/release-set.json` names the image under `image`
(`ghcr.io/statecrafting/rustev-serve`, `linux/amd64`, `linux/arm64`) and
drops its `absent` entry. This is the switch that makes the next release
name the image in its manifest, gate its scan through
`image-exceptions.json`, push and attest it (`publish-image`), verify it
and qualify it.
- Tests that are not about the image (`tests/family.rs`,
`tests/tagged.rs` fixtures) set `image` to none; `tests/npm.rs` and
`tests/image.rs` no longer read an image absence from the committed set.

Prerequisites before merging:
1. The base move to `gcr.io/distroless/cc-debian13:nonroot` (#502),
decided by the owner on 2026-11-03.
2. The owner's ruling on each of the 44 findings on that base (one
decision row and one `image-exceptions.json` entry per (id, package), at
most 90 days). With the image a member, any uncovered finding fails
`image-checks`.
3. The image qualification of 060 3.4.3 as amended (#500 harness, #501
workflow).
4. Spec 042 is complete (#477), so 3.1.1's condition holds. The owner
makes the ghcr package public after the first push.

Stacked on #498 (on #496, #494).

Checks: `cargo test -p rustev-release --locked` passed (all binaries);
`make gate` passed.
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