mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-30 04:06:34 +09:00
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:
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"
|
||||
Reference in new issue
Block a user