Docs restructure, code review, gatherer reliability, JWT key fail-closed
Documentation - Three levels: DOCS/General (overview, configuration), DOCS/Deployment (choose a method, first steps), details per method in Containers/ and System_Services/; new root README and DOCS/README map. - Remove superseded pages (Deployment.md, Deployment_Docker/Native.md, Index.md); split the two scenario guides by section. - Isolate the Timeweb/Hysteria2 records in DEPLOYMENTS/timeweb-hysteria2/ (not linked from DOCS, listed in .graphifyignore). - Add DOCS/code_review/ with a time-stamped analysis of the code base. Gatherer (BUG-02, BUG-03) - Session key (CN, address, connected_since_ts), baseline from the active_sessions snapshot, grace period for sessions missing from the status. - Status file integrity (TITLE/TIME/END) and freshness; a torn read skips the tick. - Cache applied after commit; main loop survives exceptions, backs off, and stops cleanly on SIGTERM/SIGINT; new client rows start with the first frame's totals; five tests. JWT signing key (SEC-01) - No built-in default: Core and Profiler refuse to start with a missing, placeholder or short (< 32) key; shipped config.ini has an empty value. - Same rule in install.sh, update.sh (issues a new key when missing or weak), docker lib/entrypoint; five tests, conftest.py for the test key. Each change has a plan and a summary under DOCS/Changes/. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f95a0b63e6
commit
ad6995bb63
85 files changed
+2805
-1280
No files matched your search
+25
-1
@@ -201,7 +201,7 @@ resolve_stack() {
|
||||
sv=$(state_get OVPMON_VARIANT)
|
||||
sp=$(state_get OVPMON_PROJECT)
|
||||
if [ -n "$sv" ]; then
|
||||
[ -z "${ARG_VARIANT:-}" ] || [ "$ARG_VARIANT" = "$sv" ] || die "--variant $ARG_VARIANT does not match the installed variant '$sv' (state file $STATE_FILE). Switching variants is described in DOCS/Deployment/Scenario1_Containers.md"
|
||||
[ -z "${ARG_VARIANT:-}" ] || [ "$ARG_VARIANT" = "$sv" ] || die "--variant $ARG_VARIANT does not match the installed variant '$sv' (state file $STATE_FILE). Switching variants is described in DOCS/Deployment/Containers/Operations.md"
|
||||
[ -z "${ARG_PROJECT:-}" ] || [ "$ARG_PROJECT" = "$sp" ] || die "--project $ARG_PROJECT does not match the installed project '$sp' (state file $STATE_FILE)"
|
||||
PROJECT="$sp"
|
||||
set_variant "$sv"
|
||||
@@ -251,9 +251,33 @@ env_remove_admin() {
|
||||
mv "$tmp" "$ENV_FILE"
|
||||
}
|
||||
|
||||
# secret_problem KEY: JWT key rule (same as APP_CORE/secret_key.py: not empty, no change-me/changeme,
|
||||
# at least 32 characters). Prints the reason (never the key) and returns 1 when the key is not acceptable.
|
||||
# Use it as: if reason=$(secret_problem "$key"); then ...ok...; else ...$reason...; fi (set -e safe)
|
||||
secret_problem() {
|
||||
local _lc
|
||||
case "$1" in
|
||||
*[![:space:]]*) ;;
|
||||
*) printf 'not set or empty'; return 1 ;;
|
||||
esac
|
||||
_lc=$(printf '%s' "$1" | tr '[:upper:]' '[:lower:]')
|
||||
case "$_lc" in
|
||||
*change-me*|*changeme*) printf 'a placeholder/default value (contains change-me)'; return 1 ;;
|
||||
esac
|
||||
if [ "${#1}" -lt 32 ]; then
|
||||
printf 'too short (%s characters, at least 32 required)' "${#1}"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
check_env_file() {
|
||||
local _reason
|
||||
[ -f "$ENV_FILE" ] || die ".env not found at $ENV_FILE (install.sh creates it)"
|
||||
[ -n "$(env_get JWT_SECRET)" ] || die "JWT_SECRET is empty in $ENV_FILE"
|
||||
if ! _reason=$(secret_problem "$(env_get JWT_SECRET)"); then
|
||||
die "JWT_SECRET in $ENV_FILE is $_reason: the API refuses to start with a weak signing key. Set a random value of at least 32 characters (for example: openssl rand -hex 32); note that a changed key signs out all users"
|
||||
fi
|
||||
if [ -n "$(find "$ENV_FILE" \( -perm -040 -o -perm -004 \) 2>/dev/null)" ]; then
|
||||
warn ".env is readable by other users; fix with: chmod 600 $ENV_FILE"
|
||||
fi
|
||||
|
||||
Reference in new issue
Block a user