Skip to content

Commit 9e6633e

Browse files
committed
chore(release): verify SHA512 against actual archive (#687)
Add an independent SHA512 verification step to the release sync workflow that re-downloads the GitHub release archive and recomputes the digest before the reusable sync workflow commits a new portfile to the vcpkg overlay registry. The reusable sync workflow at kcenon/common_system already performs this check internally (see kcenon/common_system#675, PR #676), but adding a caller-side verify-archive job in this repo guards against drift if the reusable workflow changes or is repointed in the future. Implementation notes: - File-based hashing (curl -o file, then sha512sum) instead of piping curl into sha512sum, so a 404 cannot silently produce the empty-input hash cf83e1357eefb8bdf... - Explicit empty-input SHA512 sentinel guard - Archive size sanity check (>= 1024 bytes) - sync job depends on verify-archive via needs:, so a failed verification halts the registry update before any commit Audit summary: - on-release-sync-registry.yml: hardened (this PR) - All other workflows in this repo (ci.yml, sanitizers.yml, benchmarks.yml, etc.): do not compute or write SHA512 to portfiles, no change needed. Closes #687 Part of kcenon/common_system#674
1 parent 41a0431 commit 9e6633e

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

.github/workflows/on-release-sync-registry.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,57 @@ on:
55
types: [published]
66

77
jobs:
8+
verify-archive:
9+
name: Verify release archive SHA512
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Verify SHA512 against actual GitHub archive
13+
env:
14+
TAG: ${{ github.event.release.tag_name }}
15+
REPO: ${{ github.repository }}
16+
run: |
17+
# Independent SHA512 verification against the released archive.
18+
# The reusable sync workflow at kcenon/common_system already performs
19+
# this check internally (see kcenon/common_system#675, PR #676), but
20+
# repeating it here on the caller side guards against drift if the
21+
# reusable workflow changes or is repointed in the future.
22+
# Reference: kcenon/monitoring_system#687, EPIC kcenon/common_system#674.
23+
set -euo pipefail
24+
ARCHIVE_URL="https://github.com/${REPO}/archive/refs/tags/${TAG}.tar.gz"
25+
VERIFY_FILE="$(mktemp)"
26+
27+
echo "Fetching ${ARCHIVE_URL} for SHA512 verification..."
28+
# Download to a file (not piped into sha512sum) so a fetch failure
29+
# cannot silently produce the empty-input hash cf83e1357eefb8bdf...
30+
if ! curl -fsSL --retry 3 --retry-delay 2 -o "${VERIFY_FILE}" "${ARCHIVE_URL}"; then
31+
echo "::error::Failed to download release archive: ${ARCHIVE_URL}"
32+
rm -f "${VERIFY_FILE}"
33+
exit 1
34+
fi
35+
36+
ARCHIVE_SIZE=$(stat -c %s "${VERIFY_FILE}" 2>/dev/null || stat -f %z "${VERIFY_FILE}")
37+
if [ "${ARCHIVE_SIZE}" -lt 1024 ]; then
38+
echo "::error::Downloaded archive is suspiciously small (${ARCHIVE_SIZE} bytes)"
39+
rm -f "${VERIFY_FILE}"
40+
exit 1
41+
fi
42+
43+
ACTUAL_SHA=$(sha512sum "${VERIFY_FILE}" | awk '{print $1}')
44+
rm -f "${VERIFY_FILE}"
45+
46+
# Empty-input SHA-512 sentinel guard.
47+
EMPTY_SHA="cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e"
48+
if [ "${ACTUAL_SHA}" = "${EMPTY_SHA}" ]; then
49+
echo "::error::Computed SHA512 matches the empty-input constant; download likely failed."
50+
exit 1
51+
fi
52+
53+
echo "SHA512 of ${ARCHIVE_URL}:"
54+
echo " ${ACTUAL_SHA}"
55+
echo "Archive size: ${ARCHIVE_SIZE} bytes"
56+
857
sync:
58+
needs: verify-archive
959
uses: kcenon/common_system/.github/workflows/sync-vcpkg-registry.yml@main
1060
with:
1161
port-name: kcenon-monitoring-system

0 commit comments

Comments
 (0)