ci: release-images — advisory gates in a job without secrets, image job runs no third-party code before login, fresh config dir via GITHUB_ENV, run-id builder name, empty digest refused, cleanup order; docs: SAFETY markers consistent, iCCP fixture comment
This commit is contained in:
1 parent
3af2861be7
commit
47d84161f5
4 files changed
+54
-26
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
# CONTRACT — Rust R0 foundation (whole phase, for the fresh verifier)
|
# CONTRACT — Rust R0 foundation (whole phase, for the fresh verifier)
|
||||||
- date: 2026-10-13 | flow: ad-hoc phase (owner go 2026-10-12, BDR-045) | branch: feature/rust-r0-foundation (base develop = 5fec065)
|
- date: 2026-10-13 | flow: ad-hoc phase (owner go 2026-10-12, BDR-045) | branch: feature/rust-r0-foundation (base develop = 5fec065)
|
||||||
- status: active (amended 2026-10-13 after verifier pass 1: criteria 10 and 14 oracles counted comment lines; pass 2 CONFORME 16/16, criterion 16 oracle excludes the contract file itself; no code change)
|
- status: active (amended 2026-10-13 after verifier pass 1: criteria 10 and 14 oracles counted comment lines; pass 2 CONFORME 16/16, criterion 16 oracle excludes the contract file itself; pass 3 after the security fixes: criteria 10 and 11 oracles updated to the gated SAFETY form and the second refusal arm; no code change)
|
||||||
- spec: docs/development/RUST_ARCHITECTURE_REVIEW.md (Part III, Annex B, Annex C), docs/development/RUST.md (what was built and proven)
|
- spec: docs/development/RUST_ARCHITECTURE_REVIEW.md (Part III, Annex B, Annex C), docs/development/RUST.md (what was built and proven)
|
||||||
- evidence logs (runs made by the orchestrator on this host, readable): /tmp/claude-1000/-home-bchanot-Documents-faunosteo/2fbc125b-9811-4458-8ebc-489c2f9255be/scratchpad/{pnpm-check.log,worker-test-build-5.log,worker-image-build-2.log,builder-build-2.log}
|
- evidence logs (runs made by the orchestrator on this host, readable): /tmp/claude-1000/-home-bchanot-Documents-faunosteo/2fbc125b-9811-4458-8ebc-489c2f9255be/scratchpad/{pnpm-check.log,worker-test-build-5.log,worker-image-build-2.log,builder-build-2.log}
|
||||||
|
|
||||||
@@ -37,9 +37,9 @@ Implement R0 per Annex B: Cargo workspace with crates core, wasm, worker; pinned
|
|||||||
EXPECT: 7 ; 7 ; 0 ; both lines present
|
EXPECT: 7 ; 7 ; 0 ; both lines present
|
||||||
10. The keyed parent never decodes: spawn.rs and webp_check.rs use no image decoder; output capped at 512 KiB; the RIFF check allowlists four chunk types and refuses the rest.
|
10. The keyed parent never decodes: spawn.rs and webp_check.rs use no image decoder; output capped at 512 KiB; the RIFF check allowlists four chunk types and refuses the rest.
|
||||||
CHECK: grep -c "image::" crates/worker/src/spawn.rs crates/worker/src/webp_check.rs; grep -c "MAX_OUTPUT_BYTES: usize = 512 \* 1024" crates/worker/src/limits.rs; grep -c 'b"VP8X", b"VP8 ", b"VP8L", b"ALPH"' crates/worker/src/webp_check.rs; grep -c "return Err(WebpIssue::ForbiddenChunk(fourcc))" crates/worker/src/webp_check.rs
|
CHECK: grep -c "image::" crates/worker/src/spawn.rs crates/worker/src/webp_check.rs; grep -c "MAX_OUTPUT_BYTES: usize = 512 \* 1024" crates/worker/src/limits.rs; grep -c 'b"VP8X", b"VP8 ", b"VP8L", b"ALPH"' crates/worker/src/webp_check.rs; grep -c "return Err(WebpIssue::ForbiddenChunk(fourcc))" crates/worker/src/webp_check.rs
|
||||||
EXPECT: 0 for both files ; 1 ; 1 ; 1
|
EXPECT: 0 for both files ; 1 ; 1 ; 2 (the allowlist gate and the defensive arm of the structure match, since a8b644a)
|
||||||
11. libwebp confined to the child and its version controlled: FFI only in decode.rs with SAFETY comments, minimum 1.6.0 checked by a test and by `run --check`.
|
11. libwebp confined to the child and its version controlled: FFI only in decode.rs with SAFETY comments, minimum 1.6.0 checked by a test and by `run --check`.
|
||||||
CHECK: grep -l "libwebp_sys::" crates/worker/src/*.rs; grep -c "// SAFETY:" crates/worker/src/decode.rs; grep -c "MIN_LIBWEBP_VERSION: (u8, u8, u8) = (1, 6, 0)" crates/worker/src/limits.rs; grep -c "the_linked_libwebp_is_recent_enough" crates/worker/tests/sandbox.rs
|
CHECK: grep -l "libwebp_sys::" crates/worker/src/*.rs; grep -c "// SAFETY" crates/worker/src/decode.rs; grep -c "MIN_LIBWEBP_VERSION: (u8, u8, u8) = (1, 6, 0)" crates/worker/src/limits.rs; grep -c "the_linked_libwebp_is_recent_enough" crates/worker/tests/sandbox.rs
|
||||||
EXPECT: crates/worker/src/decode.rs only ; >= 4 ; 1 ; 1
|
EXPECT: crates/worker/src/decode.rs only ; >= 4 ; 1 ; 1
|
||||||
12. Test hooks never ship: release build without features; the runtime image is distroless static, non-root, with `run --check` as its command.
|
12. Test hooks never ship: release build without features; the runtime image is distroless static, non-root, with `run --check` as its command.
|
||||||
CHECK: grep -n "cargo build -p faunosteo-worker --release --locked" crates/worker/Dockerfile | grep -c "features"; grep -c "FROM gcr.io/distroless/static-debian12:nonroot" crates/worker/Dockerfile; grep -c "^USER nonroot" crates/worker/Dockerfile; grep -c 'CMD \["run", "--check"\]' crates/worker/Dockerfile; tail -1 /tmp/claude-1000/-home-bchanot-Documents-faunosteo/2fbc125b-9811-4458-8ebc-489c2f9255be/scratchpad/worker-image-build-6.log
|
CHECK: grep -n "cargo build -p faunosteo-worker --release --locked" crates/worker/Dockerfile | grep -c "features"; grep -c "FROM gcr.io/distroless/static-debian12:nonroot" crates/worker/Dockerfile; grep -c "^USER nonroot" crates/worker/Dockerfile; grep -c 'CMD \["run", "--check"\]' crates/worker/Dockerfile; tail -1 /tmp/claude-1000/-home-bchanot-Documents-faunosteo/2fbc125b-9811-4458-8ebc-489c2f9255be/scratchpad/worker-image-build-6.log
|
||||||
|
|||||||
@@ -5,16 +5,18 @@
|
|||||||
# yet applied)" is the runbook.
|
# yet applied)" is the runbook.
|
||||||
#
|
#
|
||||||
# Hardening (security audits of R0): the dispatch input is a typed choice re-validated in
|
# Hardening (security audits of R0): the dispatch input is a typed choice re-validated in
|
||||||
# the shell through an environment variable (never interpolated into a script); the registry
|
# the shell through an environment variable (never interpolated into a script); the
|
||||||
|
# advisory gates (RustSec, npm) run in a job that holds no secret, and the image job runs no
|
||||||
|
# third-party code before its login (no npm install, only the pinned checkout); the registry
|
||||||
# token reaches the login step only, through env, into a per-job DOCKER_CONFIG under
|
# token reaches the login step only, through env, into a per-job DOCKER_CONFIG under
|
||||||
# RUNNER_TEMP created before any step and removed by a literal path; the images are built by
|
# RUNNER_TEMP created fresh before the login and removed by a literal path; the images are
|
||||||
# a named ephemeral buildx builder (`--builder`, so a missing builder fails instead of
|
# built by a named ephemeral buildx builder (`--builder`, so a missing builder fails instead
|
||||||
# falling back to the daemon's shared BuildKit and its cache mounts); the RustSec and npm
|
# of falling back to the daemon's shared BuildKit and its cache mounts). The
|
||||||
# advisories gates run before any push; `actions/checkout` is pinned to a commit. The
|
|
||||||
# `if: github.ref` line keeps honest runs on main or develop: it is not a security boundary
|
# `if: github.ref` line keeps honest runs on main or develop: it is not a security boundary
|
||||||
# (whoever can push a branch can dispatch a copy of this file), push access and the token's
|
# (whoever can push a branch can dispatch a copy of this file), push access and the token's
|
||||||
# scope are. The real isolation from pull-request jobs is a dedicated release runner label
|
# scope are. The real isolation from pull-request jobs is a dedicated release runner label
|
||||||
# that never runs them (Step 27 operations).
|
# that never runs them (Step 27 operations). Known mutable references, to pin at Step 27:
|
||||||
|
# the buildkit engine image of the builder, the base images of the Dockerfiles.
|
||||||
#
|
#
|
||||||
# Secrets expected on the forge: REGISTRY (host, e.g. the Gitea container registry of this
|
# Secrets expected on the forge: REGISTRY (host, e.g. the Gitea container registry of this
|
||||||
# forge), REGISTRY_USER, REGISTRY_TOKEN (write:package scope). Images are pushed as
|
# forge), REGISTRY_USER, REGISTRY_TOKEN (write:package scope). Images are pushed as
|
||||||
@@ -34,21 +36,19 @@ on:
|
|||||||
- draft
|
- draft
|
||||||
default: none
|
default: none
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: release-images-${{ github.sha }}
|
||||||
|
cancel-in-progress: false
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
images:
|
# No secret here: this job runs third-party code (pnpm install for the audit, the
|
||||||
|
# builder image) and must never see the registry token.
|
||||||
|
gates:
|
||||||
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'
|
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
env:
|
||||||
SHEET_BUNDLE: ${{ inputs.sheet_bundle }}
|
SHEET_BUNDLE: ${{ inputs.sheet_bundle }}
|
||||||
REGISTRY: ${{ secrets.REGISTRY }}
|
|
||||||
NAMESPACE: ${{ github.repository_owner }}
|
|
||||||
GIT_SHA: ${{ github.sha }}
|
|
||||||
# Per-job Docker config, set before any step runs: the login and the builder live here.
|
|
||||||
DOCKER_CONFIG: ${{ runner.temp }}/faunosteo-release-docker
|
|
||||||
BUILDER: faunosteo_release_${{ github.sha }}
|
|
||||||
steps:
|
steps:
|
||||||
- name: Per-job Docker config directory
|
|
||||||
run: mkdir -m 700 -p "$DOCKER_CONFIG"
|
|
||||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||||
- name: Validate the dispatch input (the shell trusts the env value only after this)
|
- name: Validate the dispatch input (the shell trusts the env value only after this)
|
||||||
run: |
|
run: |
|
||||||
@@ -68,6 +68,28 @@ jobs:
|
|||||||
corepack enable && corepack prepare --activate
|
corepack enable && corepack prepare --activate
|
||||||
pnpm install --frozen-lockfile
|
pnpm install --frozen-lockfile
|
||||||
pnpm audit --prod --audit-level=high
|
pnpm audit --prod --audit-level=high
|
||||||
|
|
||||||
|
images:
|
||||||
|
needs: gates
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
SHEET_BUNDLE: ${{ inputs.sheet_bundle }}
|
||||||
|
REGISTRY: ${{ secrets.REGISTRY }}
|
||||||
|
NAMESPACE: ${{ github.repository_owner }}
|
||||||
|
GIT_SHA: ${{ github.sha }}
|
||||||
|
BUILDER: faunosteo_release_${{ github.run_id }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||||
|
- name: Re-validate the dispatch input in this job
|
||||||
|
run: |
|
||||||
|
case "$SHEET_BUNDLE" in
|
||||||
|
none|draft) ;;
|
||||||
|
*) echo "refused SHEET_BUNDLE value" >&2; exit 1 ;;
|
||||||
|
esac
|
||||||
|
- name: Fresh per-job Docker config (fails if the directory already exists)
|
||||||
|
run: |
|
||||||
|
mkdir -m 700 "$RUNNER_TEMP/faunosteo-release-docker"
|
||||||
|
echo "DOCKER_CONFIG=$RUNNER_TEMP/faunosteo-release-docker" >> "$GITHUB_ENV"
|
||||||
- name: Ephemeral builder with its own cache (named; every build names it explicitly)
|
- name: Ephemeral builder with its own cache (named; every build names it explicitly)
|
||||||
run: docker buildx create --name "$BUILDER" --driver docker-container
|
run: docker buildx create --name "$BUILDER" --driver docker-container
|
||||||
- name: Registry login (token in this step's env only, never on the command line)
|
- name: Registry login (token in this step's env only, never on the command line)
|
||||||
@@ -82,7 +104,8 @@ jobs:
|
|||||||
--metadata-file "$RUNNER_TEMP/app-metadata.json" \
|
--metadata-file "$RUNNER_TEMP/app-metadata.json" \
|
||||||
--build-arg "SHEET_BUNDLE=$SHEET_BUNDLE" -t "$image" .
|
--build-arg "SHEET_BUNDLE=$SHEET_BUNDLE" -t "$image" .
|
||||||
digest="$(sed -n 's/.*"containerimage.digest": *"\([^"]*\)".*/\1/p' "$RUNNER_TEMP/app-metadata.json")"
|
digest="$(sed -n 's/.*"containerimage.digest": *"\([^"]*\)".*/\1/p' "$RUNNER_TEMP/app-metadata.json")"
|
||||||
echo "app: $image@$digest" >> "$GITHUB_STEP_SUMMARY"
|
[ -n "$digest" ] || { echo "no digest in the build metadata" >&2; exit 1; }
|
||||||
|
echo "app: faunosteo_app:$GIT_SHA@$digest" >> "$GITHUB_STEP_SUMMARY"
|
||||||
- name: Build and push the worker image
|
- name: Build and push the worker image
|
||||||
run: |
|
run: |
|
||||||
image="$REGISTRY/$NAMESPACE/faunosteo_worker:$GIT_SHA"
|
image="$REGISTRY/$NAMESPACE/faunosteo_worker:$GIT_SHA"
|
||||||
@@ -90,10 +113,13 @@ jobs:
|
|||||||
--metadata-file "$RUNNER_TEMP/worker-metadata.json" \
|
--metadata-file "$RUNNER_TEMP/worker-metadata.json" \
|
||||||
-f crates/worker/Dockerfile -t "$image" .
|
-f crates/worker/Dockerfile -t "$image" .
|
||||||
digest="$(sed -n 's/.*"containerimage.digest": *"\([^"]*\)".*/\1/p' "$RUNNER_TEMP/worker-metadata.json")"
|
digest="$(sed -n 's/.*"containerimage.digest": *"\([^"]*\)".*/\1/p' "$RUNNER_TEMP/worker-metadata.json")"
|
||||||
echo "worker: $image@$digest" >> "$GITHUB_STEP_SUMMARY"
|
[ -n "$digest" ] || { echo "no digest in the build metadata" >&2; exit 1; }
|
||||||
|
echo "worker: faunosteo_worker:$GIT_SHA@$digest" >> "$GITHUB_STEP_SUMMARY"
|
||||||
- name: Logout, remove the builder and the per-job Docker config (literal path)
|
- name: Logout, remove the builder and the per-job Docker config (literal path)
|
||||||
if: always()
|
if: always()
|
||||||
run: |
|
run: |
|
||||||
|
rc=0
|
||||||
docker logout "$REGISTRY" || true
|
docker logout "$REGISTRY" || true
|
||||||
docker buildx rm "$BUILDER"
|
docker buildx rm "$BUILDER" || rc=$?
|
||||||
rm -rf -- "${RUNNER_TEMP:?}/faunosteo-release-docker"
|
rm -rf -- "${RUNNER_TEMP:?}/faunosteo-release-docker"
|
||||||
|
exit "$rc"
|
||||||
@@ -163,9 +163,9 @@ pub fn encode_webp(rgba: &[u8], width: u32, height: u32, quality: f32) -> Result
|
|||||||
if size == 0 || output.is_null() {
|
if size == 0 || output.is_null() {
|
||||||
return Err(Reject::EncodeFailed);
|
return Err(Reject::EncodeFailed);
|
||||||
}
|
}
|
||||||
// SAFETY: libwebp returned `size` initialised bytes at `output`.
|
// SAFETY [gated 2026-10-13]: libwebp returned `size` initialised bytes at `output`.
|
||||||
let encoded = unsafe { std::slice::from_raw_parts(output, size) }.to_vec();
|
let encoded = unsafe { std::slice::from_raw_parts(output, size) }.to_vec();
|
||||||
// SAFETY: `output` came from libwebp's allocator and is not read afterwards.
|
// SAFETY [gated 2026-10-13]: `output` came from libwebp's allocator and is not read afterwards.
|
||||||
unsafe { libwebp_sys::WebPFree(output.cast()) };
|
unsafe { libwebp_sys::WebPFree(output.cast()) };
|
||||||
Ok(encoded)
|
Ok(encoded)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,9 +62,11 @@ fn push_chunk(out: &mut Vec<u8>, kind: &[u8; 4], payload: &[u8]) {
|
|||||||
out.extend_from_slice(&hasher.finalize().to_be_bytes());
|
out.extend_from_slice(&hasher.finalize().to_be_bytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A small valid-looking PNG whose `iCCP` profile inflates to `inflated_bytes` (hundreds of
|
/// A small PNG header whose `iCCP` profile inflates to `inflated_bytes` (hundreds of
|
||||||
/// kilobytes of compressed zeros): the decoder's allocation budget must refuse it as content
|
/// kilobytes of compressed zeros) and that carries no image data: the decoder refuses it as
|
||||||
/// (`resource_limit`), never as a broken environment.
|
/// content (`decode_failed` or `resource_limit`, depending on which check fires first),
|
||||||
|
/// never as a broken environment. R1 adds a variant with image data so the budget itself
|
||||||
|
/// is seen firing.
|
||||||
pub fn png_iccp_bomb(inflated_bytes: usize) -> Vec<u8> {
|
pub fn png_iccp_bomb(inflated_bytes: usize) -> Vec<u8> {
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
let mut out = vec![0x89, b'P', b'N', b'G', 0x0d, 0x0a, 0x1a, 0x0a];
|
let mut out = vec![0x89, b'P', b'N', b'G', 0x0d, 0x0a, 0x1a, 0x0a];
|
||||||
|
|||||||
Reference in new issue
Block a user