feat(crm): add deploy verification for BIT-881 profile sanitize and BIT-937 LIMIT binds

Add scripts/crm/verify_pmx_bet_profile_and_limit_deploy.sh (gitea + runtime) to assert
CRM_Project main contains the BIT-881 UserController/Sanitize fix and the DatabaseManager
LIMIT/OFFSET integer bind chain (c0afd0183). Document §6 in the Sanitize and SQL LIMIT
runbooks for operators closing the error loop after deploy.

Paperclip: BIT-881, BIT-937

Paperclip-Run-Id: b075f087-a1e8-47cd-aca7-fbfcec7a21bb
Paperclip-Agent: d706f4e6-5d05-4cec-b6e8-f8fb1f203aae
Made-with: Cursor
This commit is contained in:
Peter Spark committed 2026-04-05 16:21:39 +00:00
1 parent c610cb3bab
commit ee74d0447c
3 files changed
+97

No files matched your search

+52
View File
@@ -0,0 +1,52 @@
#!/usr/bin/env bash
# Gitea + runtime checks for CRM profile Sanitize (BIT-881) and LIMIT/OFFSET PDO int bind (BIT-937 / BIT-952).
# See docs/RUNBOOK_REPORTER_CRM_USERPROFILE_SANITIZE.md §6 and RUNBOOK_REPORTER_CRM_SQL_LIMIT_QUOTED_NUMERIC.md §6.
#
# Usage:
# ./scripts/crm/verify_pmx_bet_profile_and_limit_deploy.sh gitea
# [email protected] ./scripts/crm/verify_pmx_bet_profile_and_limit_deploy.sh runtime
set -euo pipefail
readonly CRM_REPO_URL="${CRM_REPO_URL:-https://git.bitreport.pt/BitReport.pt/CRM_Project.git}"
readonly SHA_BIT881="${BIT881_FIX_SHA:-3b5a9c96f5a8ad1ad5548b0eaa9d0b40bd7be250}"
readonly SHA_LIMIT="${LIMIT_INT_BIND_FIX_SHA:-c0afd0183d7e0727878364d116f8e2421d90b975}"
readonly RUNTIME_GIT_DIR="${CRM_PMX_RUNTIME_GIT_DIR:-/data/wwwroot/crm-repo}"
readonly FETCH_DEPTH="${CRM_GIT_FETCH_DEPTH:-500}"
cmd_gitea() {
local tip tmp_repo
tip="$(git ls-remote "$CRM_REPO_URL" refs/heads/main | awk '{print $1}')"
echo "verify_pmx_bet_profile_and_limit_deploy: gitea refs/heads/main -> ${tip}"
tmp_repo="$(mktemp -d)"
trap "rm -rf \"${tmp_repo}\"" RETURN
git clone --quiet --depth 1 --branch main "$CRM_REPO_URL" "$tmp_repo/repo"
git -C "$tmp_repo/repo" fetch --quiet --depth="$FETCH_DEPTH" origin main
git -C "$tmp_repo/repo" merge-base --is-ancestor "$SHA_BIT881" HEAD
git -C "$tmp_repo/repo" merge-base --is-ancestor "$SHA_LIMIT" HEAD
local head_local
head_local="$(git -C "$tmp_repo/repo" rev-parse HEAD)"
echo "verify_pmx_bet_profile_and_limit_deploy: gitea ancestor OK (${SHA_BIT881}, ${SHA_LIMIT} ⊆ HEAD ${head_local})"
if [[ "$head_local" != "$tip" ]]; then
echo "verify_pmx_bet_profile_and_limit_deploy: note: shallow HEAD ${head_local} may differ from ls-remote tip ${tip}; widen CRM_GIT_FETCH_DEPTH if ancestor check fails after a large fast-forward." >&2
fi
}
cmd_runtime() {
: "${CRM_PMX_SSH:?set CRM_PMX_SSH, e.g. [email protected] (VPN required from most lab runners)}"
ssh -o BatchMode=yes "$CRM_PMX_SSH" \
"set -euo pipefail; cd '${RUNTIME_GIT_DIR}' && git fetch -q origin && git rev-parse HEAD && git merge-base --is-ancestor ${SHA_BIT881} HEAD && git merge-base --is-ancestor ${SHA_LIMIT} HEAD && echo ancestors_ok"
}
case "${1:-}" in
gitea) cmd_gitea ;;
runtime) cmd_runtime ;;
*)
echo "usage: $0 gitea|runtime" >&2
exit 1
;;
esac