mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-29 06:17:25 +00:00
Every shared Redis consumer authenticates as the default user with REDIS_PASSWORD (plugins/lookup/engine.py). The rotation gate between PASS 1 and PASS 2 changes that password, the engine restarts with only the new one, and every consumer deployed later in the pass keeps the old secret. In fork run 42305502796, Nextcloud#7 direct then crash-looped Nextcloud and Weblate from 02:50:31 until the deploy cap killed the job (about 2600-2700 WRONGPASS lines per node, host CPU pressure from 25 % to 80 %). 00_core now reads the password hashes a healthy engine accepts before the restart and adds the replaced ones back after it. Once every server role has redeployed, tasks/stages/02_server.yml retires them before the end-to-end tests: only the current password is left, the ACL log is reset and every client is disconnected. After the tests, a verify step in the test runtimes fails the pass on every authentication Redis refused since the retire, so a consumer that never picked up the new secret still fails loudly. The rotation gate is unchanged. The README no longer describes per-consumer ACL users that never existed. 🎯 Fix: 88 % 💥 Break: 6 % 💸 Cost: – ⏱️ Time: – 🛡️ Security: 100 % 🏆 Score: 83 🚦 Gate: ⛔ fix 88 % < 90, break 6 % > 5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
49 lines
1.7 KiB
Python
49 lines
1.7 KiB
Python
import shlex
|
|
import unittest
|
|
|
|
from ansible.parsing.dataloader import DataLoader
|
|
from ansible.template import Templar, trust_as_template
|
|
|
|
from utils.cache.files import PROJECT_ROOT
|
|
from utils.cache.yaml import load_yaml_any
|
|
|
|
_CORE = PROJECT_ROOT / "roles" / "svc-db-redis" / "tasks" / "00_core.yml"
|
|
_CARRY = "Keep accepting the replaced passwords"
|
|
_HASHES = ["a" * 64, "b" * 64]
|
|
|
|
|
|
def _carry_command() -> str:
|
|
tasks = load_yaml_any(str(_CORE))
|
|
task = next(task for task in tasks if _CARRY in str(task.get("name", "")))
|
|
return task["ansible.builtin.shell"]
|
|
|
|
|
|
class TestCarryCommand(unittest.TestCase):
|
|
def _inner_words(self, hashes: list[str]) -> list[str]:
|
|
variables = {
|
|
"REDIS_EXEC_SHELL": "container exec redis sh -lc",
|
|
"REDIS_CLI": 'REDISCLI_AUTH="$REDIS_PASSWORD" redis-cli',
|
|
"redis_retired_password_hashes": hashes,
|
|
}
|
|
rendered = Templar(loader=DataLoader(), variables=variables).template(
|
|
trust_as_template(_carry_command())
|
|
)
|
|
outer = shlex.split(rendered)
|
|
self.assertEqual(outer[:5], ["container", "exec", "redis", "sh", "-lc"])
|
|
self.assertEqual(len(outer), 6, "the in-container script must stay one word")
|
|
return shlex.split(outer[5], comments=True)
|
|
|
|
def test_every_replaced_hash_reaches_redis_as_its_own_argument(self):
|
|
words = self._inner_words(_HASHES)
|
|
self.assertEqual(
|
|
words[words.index("SETUSER") + 1 :],
|
|
["default", *(f"#{value}" for value in _HASHES)],
|
|
)
|
|
|
|
def test_a_single_hash_is_not_read_as_a_shell_comment(self):
|
|
self.assertEqual(self._inner_words(_HASHES[:1])[-1], f"#{_HASHES[0]}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|