diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8e089d4..17147e7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Lint GitHub Actions workflows env: @@ -30,7 +30,7 @@ jobs: tar -xzf "${ARCHIVE}" -C "${RUNNER_TEMP}" actionlint "${RUNNER_TEMP}/actionlint" .github/workflows/*.yml - - uses: oven-sh/setup-bun@v2 + - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 with: bun-version: 1.3.11 @@ -63,13 +63,13 @@ jobs: - "3.13" steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - - uses: oven-sh/setup-bun@v2 + - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 with: bun-version: 1.3.11 - - uses: actions/setup-python@v5 + - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 with: python-version: ${{ matrix.python-version }} @@ -146,9 +146,9 @@ jobs: working-directory: plugins/crabcode-html-video steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - - uses: oven-sh/setup-bun@v2 + - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 with: bun-version: 1.3.11 @@ -173,17 +173,17 @@ jobs: working-directory: plugins/crabcode-media-ops steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 # The Playwright container image ships without unzip, which oven-sh/setup-bun # needs to unpack the bun release archive. Without it setup-bun fails and the # whole job (check:distribution + QA) never runs on Linux. Install it first. # Verified against the pinned image by local container reproduction (audit 2026-07-18). - name: Install unzip (Playwright image lacks it; required by setup-bun) run: apt-get update && apt-get install -y --no-install-recommends unzip - - uses: oven-sh/setup-bun@v2 + - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 with: bun-version: 1.3.11 - - uses: actions/setup-java@v4 + - uses: actions/setup-java@b6effb05e454b25005698d916606bdc6ffcbf961 # v5.7.0 with: distribution: temurin java-version: '21' @@ -199,7 +199,7 @@ jobs: - run: bun run validate - name: Upload media QA evidence on failure if: failure() - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 with: name: media-ops-qa-evidence path: plugins/crabcode-media-ops/test-results @@ -216,13 +216,13 @@ jobs: working-directory: plugins/crabcode-media-publisher steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Install unzip (required by setup-bun) run: apt-get update && apt-get install -y --no-install-recommends unzip - - uses: oven-sh/setup-bun@v2 + - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 with: bun-version: 1.3.11 - - uses: actions/setup-java@v4 + - uses: actions/setup-java@b6effb05e454b25005698d916606bdc6ffcbf961 # v5.7.0 with: distribution: temurin java-version: '21' @@ -237,7 +237,7 @@ jobs: run: bun run test:browser - name: Upload publisher browser evidence on failure if: failure() - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 with: name: media-publisher-browser-evidence path: plugins/crabcode-media-publisher/test-results diff --git a/.github/workflows/notify-mirror.yml b/.github/workflows/notify-mirror.yml index 0862af7..ff13464 100644 --- a/.github/workflows/notify-mirror.yml +++ b/.github/workflows/notify-mirror.yml @@ -134,7 +134,7 @@ jobs: fi - name: Check out the exact release for byte-level comparison - uses: actions/checkout@v4 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: ref: ${{ steps.target.outputs.sha }} path: expected-source @@ -267,6 +267,64 @@ jobs: print(f"verified archive files={len(local)} prefix={prefix}") PY + fetch -D "${WORK}/marketplace.final.headers" \ + -o "${WORK}/marketplace.final.json" \ + "${MIRROR_BASE}/marketplace.json" \ + || fail "mirror marketplace.json became unreachable during the audit" + fetch -D "${WORK}/marketplace-checksum.final.headers" \ + -o "${WORK}/marketplace.final.json.sha256" \ + "${MIRROR_BASE}/marketplace.json.sha256" \ + || fail "mirror marketplace checksum became unreachable during the audit" + cmp -s expected-source/.crabcode-plugin/marketplace.json "${WORK}/marketplace.final.json" \ + || fail "mirror marketplace.json changed during the audit" + python3 - "${WORK}/marketplace.final.json" "${WORK}/marketplace.final.json.sha256" <<'PY' \ + || fail "mirror marketplace checksum changed during the audit" + import hashlib, pathlib, re, sys + payload = pathlib.Path(sys.argv[1]) + checksum = pathlib.Path(sys.argv[2]).read_text(encoding="ascii") + match = re.fullmatch(r"([0-9a-f]{64}) marketplace\.json\n?", checksum) + if match is None or match.group(1) != hashlib.sha256(payload.read_bytes()).hexdigest(): + raise SystemExit("final marketplace checksum mismatch") + PY + fetch -H 'Cache-Control: no-cache' \ + -D "${WORK}/latest.final.headers" \ + -o "${WORK}/latest.final" \ + "${MIRROR_BASE}/latest" \ + || fail "mirror latest became unreachable during the audit" + python3 - \ + "${WORK}/latest.final" \ + "${WORK}/latest.final.headers" \ + "${WORK}/marketplace.final.headers" \ + "${WORK}/marketplace-checksum.final.headers" \ + "${SHA}" <<'PY' \ + || fail "mutable mirror state or cache policy changed during the audit" + import pathlib, re, sys + pointer_path = pathlib.Path(sys.argv[1]) + latest_headers_path = pathlib.Path(sys.argv[2]) + mutable_headers = [pathlib.Path(value) for value in sys.argv[2:5]] + expected = sys.argv[5] + raw = pointer_path.read_bytes() + if raw != expected.encode("ascii"): + raise SystemExit(f"mirror latest changed during audit: {raw!r}") + for headers_path in mutable_headers: + headers = headers_path.read_text(encoding="iso-8859-1").lower() + cache_lines = re.findall(r"^cache-control:\s*(.+)$", headers, flags=re.MULTILINE) + directives = ",".join(cache_lines) + parts = {part.strip() for part in directives.split(",")} + ages = [ + int(value) + for value in re.findall(r"(?:s-maxage|max-age)\s*=\s*\"?(\d+)\"?", directives) + ] + if "immutable" in directives: + raise SystemExit(f"mutable response became immutable: {headers_path.name}") + if not ({"no-store", "no-cache"} & parts) and not ages: + raise SystemExit(f"mutable response lost explicit freshness: {headers_path.name}") + if ages and max(ages) > 300: + raise SystemExit(f"mutable response cache lifetime exceeds 300s: {headers_path.name}") + if headers_path == latest_headers_path and not ({"no-store", "no-cache"} & parts): + raise SystemExit("mirror latest no longer requires revalidation") + PY + ZIP_SHA256="$(sha256sum "${WORK}/${SHA}.zip" | cut -d' ' -f1)" INDEX_SHA256="$(sha256sum "${WORK}/marketplace.json" | cut -d' ' -f1)" PLUGINS="$(python3 -c 'import json,sys; print(len(json.load(open(sys.argv[1]))["plugins"]))' "${WORK}/marketplace.json")"