From b47ec57628099e8a4ec4c684e809eb17d21cf3d9 Mon Sep 17 00:00:00 2001 From: walsykerem Date: Sat, 21 Nov 2026 20:44:34 +0300 Subject: [PATCH 1/3] fix(deploy): verify the installer checksum before running it as root --- deploy/aws/cloudformation/template.yaml | 25 ++++++++++++++++++++-- deploy/aws/cloudformation/template_test.go | 4 +++- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/deploy/aws/cloudformation/template.yaml b/deploy/aws/cloudformation/template.yaml index e5fe90b78..fec72b7d6 100644 --- a/deploy/aws/cloudformation/template.yaml +++ b/deploy/aws/cloudformation/template.yaml @@ -33,6 +33,7 @@ Metadata: default: Hypeman Parameters: - HypemanVersion + - HypemanVersionSha256 - HypemanCliVersion - HypemanBranch ParameterLabels: @@ -68,6 +69,8 @@ Metadata: default: Hypeman data volume throughput HypemanVersion: default: Hypeman release + HypemanVersionSha256: + default: Hypeman release installer digest HypemanBranch: default: Hypeman source branch HypemanCliVersion: @@ -152,7 +155,12 @@ Parameters: HypemanVersion: Type: String Default: v0.3.0 - Description: Hypeman API release tag, or latest. Ignored when HypemanBranch is set. + Description: Hypeman API release tag, or latest. Ignored when HypemanBranch is set. Also pins the installer script used during provisioning. + HypemanVersionSha256: + Type: String + Default: fa98e8a2e21a173daaf33a2f788eb146f8e48de67940ea5ef91d8261c4269ef6 + AllowedPattern: "^[0-9a-f]{64}$" + Description: SHA-256 of scripts/install.sh at HypemanVersion. Update this together with HypemanVersion, otherwise provisioning refuses to run the installer. HypemanBranch: Type: String Default: "" @@ -509,7 +517,20 @@ Resources: else export CLI_VERSION="${HypemanCliVersion}" fi - curl -fsSL https://raw.githubusercontent.com/kernel/hypeman/main/scripts/install.sh | bash + # No checksum is published for the installer itself, so the digest is pinned + # as a parameter and checked before the script runs as root. + if [ "${HypemanVersion}" = "latest" ]; then + installer_tag="$(curl -fsSL https://api.github.com/repos/kernel/hypeman/releases/latest | grep -m1 '"tag_name"' | cut -d'"' -f4)" + else + installer_tag="${HypemanVersion}" + fi + case "${!installer_tag}" in + v*) ;; + *) echo "could not resolve a pinned release tag for the installer" >&2; exit 1 ;; + esac + curl -fsSL -o /tmp/hypeman-install.sh "https://raw.githubusercontent.com/kernel/hypeman/${!installer_tag}/scripts/install.sh" + echo "${HypemanVersionSha256} /tmp/hypeman-install.sh" | sha256sum -c - || { echo "installer checksum mismatch, refusing to run it" >&2; exit 1; } + bash /tmp/hypeman-install.sh install -d -m 755 /etc/systemd/system/hypeman.service.d cat >/etc/systemd/system/hypeman.service.d/cloudformation.conf < Date: Sat, 21 Nov 2026 21:53:21 +0300 Subject: [PATCH 2/3] fix(deploy): resolve the installer tag without breaking the pipe The user-data bootstrap runs under `set -o pipefail`, and the lookup piped the GitHub releases JSON into `grep -m1`. That reader exits at the first match and closes the pipe while curl is still writing, so curl exits 23 and pipefail aborts provisioning before the installer is downloaded and its checksum verified. Read the tag from the redirect target of releases/latest instead: one curl call, no second process consuming the body, so nothing can break the pipe. Pinned versions still use HypemanVersion, and an empty or unexpected tag still fails closed before the checksum check runs. proof/curl_pipefail.sh extracts the real user-data block from the template and runs it under `set -euo pipefail` with a fake curl: the old lookup aborts with exit 23, the new one resolves the tag, a pinned version makes no network call, and both failure paths still abort. proof/template_parse.py parses the template with CloudFormation intrinsics allowed. --- deploy/aws/cloudformation/template.yaml | 6 +- proof/curl_pipefail.sh | 202 ++++++++++++++++++++++++ proof/template_parse.py | 36 +++++ 3 files changed, 243 insertions(+), 1 deletion(-) create mode 100644 proof/curl_pipefail.sh create mode 100644 proof/template_parse.py diff --git a/deploy/aws/cloudformation/template.yaml b/deploy/aws/cloudformation/template.yaml index fec72b7d6..b8476d131 100644 --- a/deploy/aws/cloudformation/template.yaml +++ b/deploy/aws/cloudformation/template.yaml @@ -520,7 +520,11 @@ Resources: # No checksum is published for the installer itself, so the digest is pinned # as a parameter and checked before the script runs as root. if [ "${HypemanVersion}" = "latest" ]; then - installer_tag="$(curl -fsSL https://api.github.com/repos/kernel/hypeman/releases/latest | grep -m1 '"tag_name"' | cut -d'"' -f4)" + # Read the tag from the releases/latest redirect: piping that JSON into a + # reader that exits after the first match kills curl with SIGPIPE, and + # pipefail turns that into an aborted bootstrap. + installer_tag="$(curl -fsSLo /dev/null -w '%{url_effective}' https://github.com/kernel/hypeman/releases/latest)" + installer_tag="${!installer_tag##*/tag/}" else installer_tag="${HypemanVersion}" fi diff --git a/proof/curl_pipefail.sh b/proof/curl_pipefail.sh new file mode 100644 index 000000000..2b2d4b435 --- /dev/null +++ b/proof/curl_pipefail.sh @@ -0,0 +1,202 @@ +#!/usr/bin/env bash +# Proves the CloudFormation user-data installer tag lookup survives `set -o pipefail`. +# +# Run against deploy/aws/cloudformation/template.yaml: extracts the real user data, +# undoes the `${!x}` -> `${x}` CloudFormation escape, and executes the tag block plus +# its fail-closed guard under `set -euo pipefail` with a fake curl on PATH. +# +# old shape: releases JSON piped into a reader that exits at the first match +# -> curl dies with SIGPIPE / exit 23 -> pipefail aborts bootstrap +# new shape: tag read from the releases/latest redirect -> no reader, no SIGPIPE +# +# usage: bash proof/curl_pipefail.sh +set -euo pipefail + +repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +template="$repo_root/deploy/aws/cloudformation/template.yaml" +work="$(mktemp -d)" +trap 'rm -rf "$work"' EXIT +failures=0 + +pass() { echo "PASS: $*"; } +fail() { echo "FAIL: $*"; failures=$((failures + 1)); } + +# --- fake curl --------------------------------------------------------------------- +# Models both behaviours the lookup can hit: a JSON body on stdout that a reader may +# stop consuming, and the redirect target printed by -w. Real curl ignores SIGPIPE and +# reports the broken pipe as exit 23, which is what this reproduces. +mkdir -p "$work/bin" +cat >"$work/bin/curl" <<'FAKE' +#!/usr/bin/env bash +set -uo pipefail +if [ "${FAKE_FORBID:-0}" = "1" ]; then + echo "fake curl: unexpected network call: $*" >&2 + exit 99 +fi +for arg in "$@"; do + case "$arg" in + *'%{url_effective}'*) + if [ -n "${FAKE_EFFECTIVE_URL:-}" ]; then + printf '%s' "$FAKE_EFFECTIVE_URL" + fi + exit "${FAKE_EFFECTIVE_STATUS:-0}" + ;; + esac +done +trap '' PIPE +if ! printf '%s\n' "${FAKE_JSON_HEAD:?}"; then + echo "curl: (23) Failure writing output to destination" >&2 + exit 23 +fi +n=0 +while [ "$n" -lt 4096 ]; do + n=$((n + 1)) + # The tag_name key already went out, so an early-exit reader closes the pipe here. + if ! printf '%s' "${FAKE_JSON_PAD:?}"; then + echo "curl: (23) Failure writing output to destination" >&2 + exit 23 + fi +done +exit 0 +FAKE +chmod 755 "$work/bin/curl" + +json_head='{ + "url": "https://api.github.com/repos/kernel/hypeman/releases/1", + "tag_name": "v0.9.16", + "name": "Hypeman v0.9.16",' +json_pad="$(printf '%0.sx' $(seq 1 128))" + +export FAKE_JSON_HEAD="$json_head" FAKE_JSON_PAD="$json_pad" +export FAKE_EFFECTIVE_URL="https://github.com/kernel/hypeman/releases/tag/v0.9.16" + +# --- extract the real user data from the template ---------------------------------- +python3 - "$template" >"$work/userdata.sh" <<'PY' +import sys + +lines = open(sys.argv[1]).read().splitlines() +start = next(i for i, line in enumerate(lines) if line.strip() == "Fn::Base64: !Sub |") +indent = next( + len(line) - len(line.lstrip()) for line in lines[start + 1:] if line.strip() +) +body = [] +for line in lines[start + 1:]: + if line.strip() and len(line) - len(line.lstrip()) < indent: + break + body.append(line[indent:] if len(line) > indent else "") +sys.stdout.write("\n".join(body).rstrip() + "\n") +PY +# CloudFormation emits `${!name}` as a literal `${name}` for the instance to expand. +sed 's/\${!/\${/g' "$work/userdata.sh" >"$work/boot.sh" + +extract() { # $1 first line, $2 last line, $3 output + awk -v first="$1" -v last="$2" ' + !on && index($0, first) == 1 { on = 1 } + on { print } + on && $0 == last { exit } + ' "$work/boot.sh" >"$3" + test -s "$3" +} + +extract 'if [ "${HypemanVersion}" = "latest" ]; then' 'esac' "$work/tag_block.sh" +extract 'case "${installer_tag}" in' 'esac' "$work/tag_guard.sh" + +# Pre-fix lookup, kept verbatim to show what the pipeline did under pipefail. +cat >"$work/tag_block_old.sh" <<'OLD' +if [ "${HypemanVersion}" = "latest" ]; then + installer_tag="$(curl -fsSL https://api.github.com/repos/kernel/hypeman/releases/latest | grep -m1 '"tag_name"' | cut -d'"' -f4)" +else + installer_tag="${HypemanVersion}" +fi +OLD + +make_harness() { # $1 tag block, $2 output + { + echo '#!/usr/bin/env bash' + echo 'set -euo pipefail' + cat "$1" + cat "$work/tag_guard.sh" + echo 'echo "resolved=${installer_tag}"' + } >"$2" + chmod 755 "$2" +} + +run_case() { # $1 label, $2 harness, $3 expected status (0|nonzero), $4 expected stdout substring + local label="$1" harness="$2" want_status="$3" want_text="$4" + local out="$work/$label.out" status=0 + PATH="$work/bin:$PATH" HypemanVersion="${HV:-latest}" FAKE_FORBID="${FAKE_FORBID:-0}" \ + bash "$harness" >"$out" 2>&1 || status=$? + echo "--- $label (exit $status) ---" + sed -e 's/^x\{16,\}/[body padding] /' "$out" | cut -c1-200 | sed 's/^/ /' + if [ "$want_status" = "0" ] && [ "$status" -ne 0 ]; then + fail "$label exited $status, expected success" + return + fi + if [ "$want_status" != "0" ] && [ "$status" -eq 0 ]; then + fail "$label exited 0, expected an abort" + return + fi + if [ -n "$want_text" ] && ! grep -qxF "$want_text" "$out"; then + fail "$label did not print $want_text" + return + fi + pass "$label" +} + +# --- (a) old shape: broken pipe aborts the bootstrap --------------------------------- +make_harness "$work/tag_block_old.sh" "$work/harness_old.sh" +run_case old_latest_aborts "$work/harness_old.sh" nonzero "" + +probe_status=0 +set +e +( + set -euo pipefail + PATH="$work/bin:$PATH" + tag="$(curl -fsSL https://api.github.com/repos/kernel/hypeman/releases/latest | grep -m1 '"tag_name"' | cut -d'"' -f4)" + echo "resolved=$tag" +) >"$work/probe.out" 2>&1 +probe_status=$? +set -e +echo "--- old pipeline under pipefail (exit $probe_status) ---" +sed -e 's/^x\{16,\}/[body padding] /' "$work/probe.out" | cut -c1-200 | sed 's/^/ /' +if [ "$probe_status" -eq 23 ]; then + pass "old pipeline exits 23 (broken pipe)" +elif [ "$probe_status" -ne 0 ]; then + pass "old pipeline exits $probe_status (non-zero, aborts under pipefail)" +else + fail "old pipeline exited 0; the repro is not exercising a broken pipe" +fi + +# --- (b) new shape: latest resolves, pinned does not call out, failures stay fatal -- +make_harness "$work/tag_block.sh" "$work/harness_new.sh" + +HV=latest run_case new_latest_resolves "$work/harness_new.sh" 0 "resolved=v0.9.16" +HV=v1.2.3 FAKE_FORBID=1 run_case new_pinned_skips_lookup "$work/harness_new.sh" 0 "resolved=v1.2.3" +HV=latest FAKE_EFFECTIVE_URL="" FAKE_EFFECTIVE_STATUS=22 \ + run_case new_latest_failure_aborts "$work/harness_new.sh" nonzero "" +HV=latest FAKE_EFFECTIVE_URL="https://github.com/kernel/hypeman/releases/latest" \ + run_case new_latest_unresolved_aborts "$work/harness_new.sh" nonzero "" + +# --- template shape assertions ------------------------------------------------------ +if grep -F 'api.github.com/repos/kernel/hypeman/releases/latest' "$template" >/dev/null; then + fail "template still queries the releases API with an early-exit reader" +else + pass "template no longer pipes the releases API into an early-exit reader" +fi +if grep -F "curl -fsSLo /dev/null -w '%{url_effective}' https://github.com/kernel/hypeman/releases/latest" "$template" >/dev/null; then + pass "template reads the tag from the releases/latest redirect" +else + fail "template is missing the redirect-based lookup" +fi +if grep -F 'installer checksum mismatch' "$template" >/dev/null && + grep -F 'sha256sum -c -' "$template" >/dev/null; then + pass "checksum verification is still in place" +else + fail "checksum verification went missing" +fi + +if [ "$failures" -ne 0 ]; then + echo "$failures check(s) failed" + exit 1 +fi +echo "all checks passed" diff --git a/proof/template_parse.py b/proof/template_parse.py new file mode 100644 index 000000000..ca2c5aee1 --- /dev/null +++ b/proof/template_parse.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python3 +"""Parse the CloudFormation template. + +Plain yaml.safe_load cannot read it: every !Ref/!Sub/!If is an unknown tag. This +loads the same document while accepting CloudFormation short-form intrinsics as +plain values and checks the sections the template must keep. +""" +import sys + +import yaml + + +class CfnLoader(yaml.SafeLoader): + pass + + +def short_form(loader, node): + if isinstance(node, yaml.ScalarNode): + return loader.construct_scalar(node) + if isinstance(node, yaml.SequenceNode): + return loader.construct_sequence(node) + return loader.construct_mapping(node) + + +CfnLoader.add_multi_constructor("!", lambda loader, suffix, node: short_form(loader, node)) + +path = sys.argv[1] if len(sys.argv) > 1 else "deploy/aws/cloudformation/template.yaml" +with open(path) as handle: + doc = yaml.load(handle, Loader=CfnLoader) + +for section in ("AWSTemplateFormatVersion", "Parameters", "Resources", "Outputs"): + if section not in doc: + sys.exit(f"{path}: missing {section}") +user_data = doc["Resources"]["HypemanHost"]["Properties"]["UserData"] +assert "Fn::Base64" in user_data, "HypemanHost.UserData lost its Fn::Base64 wrapper" +print(f"{path}: parsed, {len(doc['Resources'])} resources") From df1f407c32ae4a26af8263d1537a89c0b67e6f31 Mon Sep 17 00:00:00 2001 From: walsykerem Date: Sat, 21 Nov 2026 21:55:03 +0300 Subject: [PATCH 3/3] chore: drop local proof scripts from branch --- proof/curl_pipefail.sh | 202 ---------------------------------------- proof/template_parse.py | 36 ------- 2 files changed, 238 deletions(-) delete mode 100644 proof/curl_pipefail.sh delete mode 100644 proof/template_parse.py diff --git a/proof/curl_pipefail.sh b/proof/curl_pipefail.sh deleted file mode 100644 index 2b2d4b435..000000000 --- a/proof/curl_pipefail.sh +++ /dev/null @@ -1,202 +0,0 @@ -#!/usr/bin/env bash -# Proves the CloudFormation user-data installer tag lookup survives `set -o pipefail`. -# -# Run against deploy/aws/cloudformation/template.yaml: extracts the real user data, -# undoes the `${!x}` -> `${x}` CloudFormation escape, and executes the tag block plus -# its fail-closed guard under `set -euo pipefail` with a fake curl on PATH. -# -# old shape: releases JSON piped into a reader that exits at the first match -# -> curl dies with SIGPIPE / exit 23 -> pipefail aborts bootstrap -# new shape: tag read from the releases/latest redirect -> no reader, no SIGPIPE -# -# usage: bash proof/curl_pipefail.sh -set -euo pipefail - -repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" -template="$repo_root/deploy/aws/cloudformation/template.yaml" -work="$(mktemp -d)" -trap 'rm -rf "$work"' EXIT -failures=0 - -pass() { echo "PASS: $*"; } -fail() { echo "FAIL: $*"; failures=$((failures + 1)); } - -# --- fake curl --------------------------------------------------------------------- -# Models both behaviours the lookup can hit: a JSON body on stdout that a reader may -# stop consuming, and the redirect target printed by -w. Real curl ignores SIGPIPE and -# reports the broken pipe as exit 23, which is what this reproduces. -mkdir -p "$work/bin" -cat >"$work/bin/curl" <<'FAKE' -#!/usr/bin/env bash -set -uo pipefail -if [ "${FAKE_FORBID:-0}" = "1" ]; then - echo "fake curl: unexpected network call: $*" >&2 - exit 99 -fi -for arg in "$@"; do - case "$arg" in - *'%{url_effective}'*) - if [ -n "${FAKE_EFFECTIVE_URL:-}" ]; then - printf '%s' "$FAKE_EFFECTIVE_URL" - fi - exit "${FAKE_EFFECTIVE_STATUS:-0}" - ;; - esac -done -trap '' PIPE -if ! printf '%s\n' "${FAKE_JSON_HEAD:?}"; then - echo "curl: (23) Failure writing output to destination" >&2 - exit 23 -fi -n=0 -while [ "$n" -lt 4096 ]; do - n=$((n + 1)) - # The tag_name key already went out, so an early-exit reader closes the pipe here. - if ! printf '%s' "${FAKE_JSON_PAD:?}"; then - echo "curl: (23) Failure writing output to destination" >&2 - exit 23 - fi -done -exit 0 -FAKE -chmod 755 "$work/bin/curl" - -json_head='{ - "url": "https://api.github.com/repos/kernel/hypeman/releases/1", - "tag_name": "v0.9.16", - "name": "Hypeman v0.9.16",' -json_pad="$(printf '%0.sx' $(seq 1 128))" - -export FAKE_JSON_HEAD="$json_head" FAKE_JSON_PAD="$json_pad" -export FAKE_EFFECTIVE_URL="https://github.com/kernel/hypeman/releases/tag/v0.9.16" - -# --- extract the real user data from the template ---------------------------------- -python3 - "$template" >"$work/userdata.sh" <<'PY' -import sys - -lines = open(sys.argv[1]).read().splitlines() -start = next(i for i, line in enumerate(lines) if line.strip() == "Fn::Base64: !Sub |") -indent = next( - len(line) - len(line.lstrip()) for line in lines[start + 1:] if line.strip() -) -body = [] -for line in lines[start + 1:]: - if line.strip() and len(line) - len(line.lstrip()) < indent: - break - body.append(line[indent:] if len(line) > indent else "") -sys.stdout.write("\n".join(body).rstrip() + "\n") -PY -# CloudFormation emits `${!name}` as a literal `${name}` for the instance to expand. -sed 's/\${!/\${/g' "$work/userdata.sh" >"$work/boot.sh" - -extract() { # $1 first line, $2 last line, $3 output - awk -v first="$1" -v last="$2" ' - !on && index($0, first) == 1 { on = 1 } - on { print } - on && $0 == last { exit } - ' "$work/boot.sh" >"$3" - test -s "$3" -} - -extract 'if [ "${HypemanVersion}" = "latest" ]; then' 'esac' "$work/tag_block.sh" -extract 'case "${installer_tag}" in' 'esac' "$work/tag_guard.sh" - -# Pre-fix lookup, kept verbatim to show what the pipeline did under pipefail. -cat >"$work/tag_block_old.sh" <<'OLD' -if [ "${HypemanVersion}" = "latest" ]; then - installer_tag="$(curl -fsSL https://api.github.com/repos/kernel/hypeman/releases/latest | grep -m1 '"tag_name"' | cut -d'"' -f4)" -else - installer_tag="${HypemanVersion}" -fi -OLD - -make_harness() { # $1 tag block, $2 output - { - echo '#!/usr/bin/env bash' - echo 'set -euo pipefail' - cat "$1" - cat "$work/tag_guard.sh" - echo 'echo "resolved=${installer_tag}"' - } >"$2" - chmod 755 "$2" -} - -run_case() { # $1 label, $2 harness, $3 expected status (0|nonzero), $4 expected stdout substring - local label="$1" harness="$2" want_status="$3" want_text="$4" - local out="$work/$label.out" status=0 - PATH="$work/bin:$PATH" HypemanVersion="${HV:-latest}" FAKE_FORBID="${FAKE_FORBID:-0}" \ - bash "$harness" >"$out" 2>&1 || status=$? - echo "--- $label (exit $status) ---" - sed -e 's/^x\{16,\}/[body padding] /' "$out" | cut -c1-200 | sed 's/^/ /' - if [ "$want_status" = "0" ] && [ "$status" -ne 0 ]; then - fail "$label exited $status, expected success" - return - fi - if [ "$want_status" != "0" ] && [ "$status" -eq 0 ]; then - fail "$label exited 0, expected an abort" - return - fi - if [ -n "$want_text" ] && ! grep -qxF "$want_text" "$out"; then - fail "$label did not print $want_text" - return - fi - pass "$label" -} - -# --- (a) old shape: broken pipe aborts the bootstrap --------------------------------- -make_harness "$work/tag_block_old.sh" "$work/harness_old.sh" -run_case old_latest_aborts "$work/harness_old.sh" nonzero "" - -probe_status=0 -set +e -( - set -euo pipefail - PATH="$work/bin:$PATH" - tag="$(curl -fsSL https://api.github.com/repos/kernel/hypeman/releases/latest | grep -m1 '"tag_name"' | cut -d'"' -f4)" - echo "resolved=$tag" -) >"$work/probe.out" 2>&1 -probe_status=$? -set -e -echo "--- old pipeline under pipefail (exit $probe_status) ---" -sed -e 's/^x\{16,\}/[body padding] /' "$work/probe.out" | cut -c1-200 | sed 's/^/ /' -if [ "$probe_status" -eq 23 ]; then - pass "old pipeline exits 23 (broken pipe)" -elif [ "$probe_status" -ne 0 ]; then - pass "old pipeline exits $probe_status (non-zero, aborts under pipefail)" -else - fail "old pipeline exited 0; the repro is not exercising a broken pipe" -fi - -# --- (b) new shape: latest resolves, pinned does not call out, failures stay fatal -- -make_harness "$work/tag_block.sh" "$work/harness_new.sh" - -HV=latest run_case new_latest_resolves "$work/harness_new.sh" 0 "resolved=v0.9.16" -HV=v1.2.3 FAKE_FORBID=1 run_case new_pinned_skips_lookup "$work/harness_new.sh" 0 "resolved=v1.2.3" -HV=latest FAKE_EFFECTIVE_URL="" FAKE_EFFECTIVE_STATUS=22 \ - run_case new_latest_failure_aborts "$work/harness_new.sh" nonzero "" -HV=latest FAKE_EFFECTIVE_URL="https://github.com/kernel/hypeman/releases/latest" \ - run_case new_latest_unresolved_aborts "$work/harness_new.sh" nonzero "" - -# --- template shape assertions ------------------------------------------------------ -if grep -F 'api.github.com/repos/kernel/hypeman/releases/latest' "$template" >/dev/null; then - fail "template still queries the releases API with an early-exit reader" -else - pass "template no longer pipes the releases API into an early-exit reader" -fi -if grep -F "curl -fsSLo /dev/null -w '%{url_effective}' https://github.com/kernel/hypeman/releases/latest" "$template" >/dev/null; then - pass "template reads the tag from the releases/latest redirect" -else - fail "template is missing the redirect-based lookup" -fi -if grep -F 'installer checksum mismatch' "$template" >/dev/null && - grep -F 'sha256sum -c -' "$template" >/dev/null; then - pass "checksum verification is still in place" -else - fail "checksum verification went missing" -fi - -if [ "$failures" -ne 0 ]; then - echo "$failures check(s) failed" - exit 1 -fi -echo "all checks passed" diff --git a/proof/template_parse.py b/proof/template_parse.py deleted file mode 100644 index ca2c5aee1..000000000 --- a/proof/template_parse.py +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env python3 -"""Parse the CloudFormation template. - -Plain yaml.safe_load cannot read it: every !Ref/!Sub/!If is an unknown tag. This -loads the same document while accepting CloudFormation short-form intrinsics as -plain values and checks the sections the template must keep. -""" -import sys - -import yaml - - -class CfnLoader(yaml.SafeLoader): - pass - - -def short_form(loader, node): - if isinstance(node, yaml.ScalarNode): - return loader.construct_scalar(node) - if isinstance(node, yaml.SequenceNode): - return loader.construct_sequence(node) - return loader.construct_mapping(node) - - -CfnLoader.add_multi_constructor("!", lambda loader, suffix, node: short_form(loader, node)) - -path = sys.argv[1] if len(sys.argv) > 1 else "deploy/aws/cloudformation/template.yaml" -with open(path) as handle: - doc = yaml.load(handle, Loader=CfnLoader) - -for section in ("AWSTemplateFormatVersion", "Parameters", "Resources", "Outputs"): - if section not in doc: - sys.exit(f"{path}: missing {section}") -user_data = doc["Resources"]["HypemanHost"]["Properties"]["UserData"] -assert "Fn::Base64" in user_data, "HypemanHost.UserData lost its Fn::Base64 wrapper" -print(f"{path}: parsed, {len(doc['Resources'])} resources")