fix 1.23.4: normalize taler:// :443/:80 + mon scan all landings
Shared lib.sh normalize_taler_uri for ladder/e2e/pay. urls phase checks public bank/exchange/merchant intros and bank mint JSON for residual default ports (ERROR on GOA/local). Unit test included.
This commit is contained in:
parent
a103eeab9d
commit
d420043863
10 changed files with 225 additions and 12 deletions
|
|
@ -1339,6 +1339,90 @@ if [ "${LOCAL_STACK:-1}" = "1" ] || [ -n "${BANK_PUBLIC:-}" ]; then
|
|||
fi
|
||||
fi
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# taler:// URIs must not carry default ports :443 / :80 (wallet / QR rule)
|
||||
# Scans public landings on this stack (bank + exchange + merchant intros,
|
||||
# bank mint JSON). Fail hard on GOA/local; soft warn elsewhere.
|
||||
# ---------------------------------------------------------------------------
|
||||
set_group landings
|
||||
section "www · taler:// default ports (:443/:80 must be absent)"
|
||||
_port_scan_fail=0
|
||||
_port_scan_ok=0
|
||||
_port_scan_one() {
|
||||
local label="$1" url="$2"
|
||||
local f code n detail
|
||||
f="$tmp/portscan-$$.body"
|
||||
code=$(http_body "$url" "$f")
|
||||
if [ "$code" != "200" ]; then
|
||||
if [ "${LOCAL_STACK:-1}" = "1" ] || [ "${EXPECT_CURRENCY:-}" = "GOA" ]; then
|
||||
# mint JSON is hard; HTML intros soft if missing
|
||||
case "$url" in
|
||||
*demo-withdraw.json|*auto-account.json)
|
||||
fail "taler-uri ports · $label" "HTTP $code · $url"
|
||||
_port_scan_fail=$((_port_scan_fail + 1))
|
||||
;;
|
||||
*)
|
||||
warn "taler-uri ports · $label" "HTTP $code · skip · $url"
|
||||
;;
|
||||
esac
|
||||
else
|
||||
info "taler-uri ports · $label" "HTTP $code · skip"
|
||||
fi
|
||||
rm -f "$f"
|
||||
return 0
|
||||
fi
|
||||
detail=$(python3 - "$f" <<'PY' 2>/dev/null || true
|
||||
import re, sys, json
|
||||
from pathlib import Path
|
||||
raw = Path(sys.argv[1]).read_text(errors="replace")
|
||||
# collect taler:// from JSON fields and raw HTML/JS
|
||||
uris = set(re.findall(r"taler://[A-Za-z0-9._~:/?#\[\]@!$&'()*+,;=%-]+", raw))
|
||||
# JSON-escaped sequences
|
||||
uris.update(re.findall(r"taler:\\/\\/[A-Za-z0-9._~:/?#\[\]@!$&'()*+,;=%\\-]+", raw))
|
||||
uris = {u.replace("\\/", "/") for u in uris}
|
||||
bad = []
|
||||
pat = re.compile(r"taler://\S+:(443|80)(/|$|\?|#)", re.I)
|
||||
for u in sorted(uris):
|
||||
if pat.search(u):
|
||||
bad.append(u[:120])
|
||||
if bad:
|
||||
print("BAD\t%d\t%s" % (len(bad), bad[0]))
|
||||
else:
|
||||
print("OK\t%d\t" % len(uris))
|
||||
PY
|
||||
)
|
||||
n_kind=${detail%%$'\t'*}
|
||||
rest=${detail#*$'\t'}
|
||||
n_count=${rest%%$'\t'*}
|
||||
sample=${rest#*$'\t'}
|
||||
if [ "$n_kind" = "BAD" ]; then
|
||||
if [ "${LOCAL_STACK:-1}" = "1" ] || [ "${EXPECT_CURRENCY:-}" = "GOA" ]; then
|
||||
fail "taler-uri ports · $label" "default :443/:80 still present · n=${n_count} e.g. ${sample}"
|
||||
_port_scan_fail=$((_port_scan_fail + 1))
|
||||
else
|
||||
warn "taler-uri ports · $label" "default port in URI · ${sample}"
|
||||
fi
|
||||
else
|
||||
ok "taler-uri ports · $label" "no default ports · taler_uris=${n_count:-0} · $url"
|
||||
_port_scan_ok=$((_port_scan_ok + 1))
|
||||
fi
|
||||
rm -f "$f"
|
||||
}
|
||||
if [ "${CHECK_LANDING:-1}" = "1" ]; then
|
||||
_port_scan_one "bank intro HTML" "${BANK_PUBLIC}/intro/"
|
||||
_port_scan_one "bank demo-withdraw.json" "${BANK_PUBLIC}/intro/demo-withdraw.json"
|
||||
_port_scan_one "bank auto-account.json" "${BANK_PUBLIC}/intro/auto-account.json"
|
||||
_port_scan_one "exchange intro HTML" "${EXCHANGE_PUBLIC}/intro/"
|
||||
_port_scan_one "merchant intro HTML" "${MERCHANT_PUBLIC}/intro/"
|
||||
# stats may embed demo withdraw URI
|
||||
_port_scan_one "bank stats.json" "${BANK_PUBLIC}/intro/stats.json"
|
||||
if [ "$_port_scan_fail" -eq 0 ]; then
|
||||
ok "taler-uri ports summary" "clean · ${_port_scan_ok} resource(s) checked (bank+exchange+merchant)"
|
||||
fi
|
||||
else
|
||||
info "taler-uri ports" "skipped (CHECK_LANDING=0)"
|
||||
fi
|
||||
|
||||
# Merchant shop assets — GOA: shop-pay.*; stage TESTPAYSAN: /assets/shop-ui.js +
|
||||
# shops.css + QR encoder (shop-ui modal needs /intro/qrcode.min.js or /qrcode.min.js).
|
||||
_ma=0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue