security(monitoring): reset the Alerta admin password on every start

The entrypoint creates admin users only when they are missing, so an
admin user created before Alerta had a password of its own keeps the
Grafana password, which stays valid after an operator rotates Grafana's.
The respin runs a step right after user creation that sets every admin
user's password to ADMIN_PASSWORD, and stops the container if it fails.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
This commit is contained in:
Andrei Kvapil committed 2026-11-27 05:39:18 +01:00
1 parent 68b0e80d17
commit bcba5d349a
4 files changed
+66 -15

No files matched your search

@@ -4,7 +4,7 @@ load test_helper
# The fixtures reproduce the lines of the upstream alerta-web 9.1.0
# docker-entrypoint.sh and nginx.conf.j2 that the respin edits.
SCRIPT="packages/system/monitoring/images/alerta/redact-secrets.sh"
SCRIPT="packages/system/monitoring/images/alerta/patch-upstream.sh"
write_fixtures() {
cat >"${BATS_TEST_TMPDIR}/docker-entrypoint.sh" <<'EOF'
@@ -55,6 +55,15 @@ EOF
[ -x "${BATS_TEST_TMPDIR}/docker-entrypoint.sh" ]
}
@test "the entrypoint syncs the admin password right after creating admin users" {
write_fixtures
sh "${SCRIPT}" "${BATS_TEST_TMPDIR}/docker-entrypoint.sh" "${BATS_TEST_TMPDIR}/nginx.conf.j2"
run grep -A1 -x ' alertad user --all --password "${ADMIN_PASSWORD}" || true' "${BATS_TEST_TMPDIR}/docker-entrypoint.sh"
[ "${status}" -eq 0 ]
[ "${lines[1]}" = ' /venv/bin/python /app/sync-admin-password.py' ]
}
@test "nginx logs the request line with the api-key parameter masked" {
write_fixtures
sh "${SCRIPT}" "${BATS_TEST_TMPDIR}/docker-entrypoint.sh" "${BATS_TEST_TMPDIR}/nginx.conf.j2"