Skip to content

Commit c331309

Browse files
committed
Diagnose protected TLS staging preconditions
1 parent 6e30aca commit c331309

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

.github/workflows/mainnet-origin-tls-install.yaml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,25 +100,33 @@ jobs:
100100
active=/etc/nginx/sites-enabled/lithoscan.ai.conf
101101
upload_dir="$deploy_dir/tls-staging"
102102
103-
[[ "$(sha256sum "$helper" | cut -d' ' -f1)" == "$EXPECTED_HELPER_SHA256" ]] || {
103+
actual_helper_sha="$(sha256sum "$helper" | cut -d' ' -f1)"
104+
echo "helper_sha256=$actual_helper_sha"
105+
[[ "$actual_helper_sha" == "$EXPECTED_HELPER_SHA256" ]] || {
104106
echo "Installed helper SHA-256 does not match the approved value" >&2; exit 1;
105107
}
106108
grep -q 'install-certificate)' "$helper" || { echo "Helper lacks install-certificate" >&2; exit 1; }
107-
grep -qx "GIT_SHA=$RELEASE_SHA" "$deploy_dir/.env"
109+
grep -qx "GIT_SHA=$RELEASE_SHA" "$deploy_dir/.env" || { echo "Production release marker differs" >&2; exit 1; }
110+
echo "release_marker=matched"
108111
test ! -e "$active" || { echo "Production vhost must remain inactive before certificate installation" >&2; exit 1; }
112+
echo "production_vhost=inactive"
109113
curl --fail --silent --show-error --max-time 10 http://127.0.0.1:3500/ >/dev/null
110114
curl --fail --silent --show-error --max-time 10 http://127.0.0.1:4400/health >/dev/null
115+
echo "backends=healthy"
111116
if sudo -n /usr/bin/install --version >/dev/null 2>&1; then
112117
echo "Generic root install unexpectedly allowed" >&2; exit 1
113118
fi
119+
echo "generic_root_install=denied"
114120
115121
if test -e "$upload_dir"; then
116-
test -d "$upload_dir" && test ! -L "$upload_dir"
117-
test "$(readlink -f "$upload_dir")" = "$upload_dir"
118-
test "$(stat -c %U "$upload_dir")" = "$USER"
119-
test "$(stat -c %a "$upload_dir")" = 700
122+
stat --format='tls_staging=%F owner=%U:%G mode=%a path=%n' "$upload_dir"
123+
test -d "$upload_dir" && test ! -L "$upload_dir" || { echo "TLS staging path is not a real directory" >&2; exit 1; }
124+
test "$(readlink -f "$upload_dir")" = "$upload_dir" || { echo "TLS staging path contains a symlink" >&2; exit 1; }
125+
test "$(stat -c %U "$upload_dir")" = "$USER" || { echo "TLS staging directory owner differs from deploy user" >&2; exit 1; }
126+
test "$(stat -c %a "$upload_dir")" = 700 || { echo "TLS staging directory must use mode 0700" >&2; exit 1; }
120127
else
121128
install -d -m 0700 "$upload_dir"
129+
echo "tls_staging=created owner=$USER mode=700 path=$upload_dir"
122130
fi
123131
rm -f -- "$upload_dir/fullchain.pem" "$upload_dir/privkey.pem"
124132
REMOTE

0 commit comments

Comments
 (0)