From 3c33d9076daf7fba654065eaeca12d163b8d3a67 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Sat, 28 Nov 2026 12:17:03 +0000 Subject: [PATCH] fix(web-app-jitsi): store password digests in the realign test and drop the rejected comments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Review fixes on #3102: the test fixture and the stubbed prosodyctl now keep a SHA-256 digest of each account password instead of the password itself (CodeQL alert 1328, clear-text storage of sensitive information), and the two mid-code comment lines in realign_accounts.sh are gone because the repository comment lint rejects them (test-lint, job 140962063131); the root cause stays in the history of the previous commit. 🎯 Fix: 90 % 💥 Break: 2 % 💸 Tokens: – ⏱️ Velocity: – 🛡️ Security: 100 % 🏆 Score: 88 🚦 Gate: ✅ 90/5, tokens and velocity <= 100, security 100 % Created-with: https://s.veen.world/skills Co-Authored-By: Claude Opus 5.5 --- .../files/shell/realign_accounts.sh | 2 -- .../files/shell/test_realign_accounts.py | 24 ++++++++++++++----- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/roles/web-app-jitsi/files/shell/realign_accounts.sh b/roles/web-app-jitsi/files/shell/realign_accounts.sh index 897dfd6cda..f2db60b902 100644 --- a/roles/web-app-jitsi/files/shell/realign_accounts.sh +++ b/roles/web-app-jitsi/files/shell/realign_accounts.sh @@ -33,8 +33,6 @@ realign() { echo "[FAIL] ${jid}: no password supplied" >&2 return 1 fi - # Prosody 13 closes every session of an account whose password is set, even to the same value; - # a kicked focus session leaves focus. (mod_client_proxy) without a target, so conference requests get service-unavailable. if carries_password "$user" "$password"; then return 0 fi diff --git a/tests/unit/python/roles/web-app-jitsi/files/shell/test_realign_accounts.py b/tests/unit/python/roles/web-app-jitsi/files/shell/test_realign_accounts.py index a66f912204..0af6c504af 100644 --- a/tests/unit/python/roles/web-app-jitsi/files/shell/test_realign_accounts.py +++ b/tests/unit/python/roles/web-app-jitsi/files/shell/test_realign_accounts.py @@ -1,3 +1,4 @@ +import hashlib import os import subprocess import sys @@ -19,6 +20,7 @@ DECLARED = { } PROSODYCTL_STUB = """#!{python} +import hashlib import os import re import sys @@ -34,6 +36,10 @@ def record(entry): handle.write(entry + "\\n") +def digest(password): + return hashlib.sha256(password.encode("utf-8")).hexdigest() + + if len(args) == 1 and args[0].startswith(">"): host, user, password = ( bytes.fromhex(value).decode("utf-8") @@ -45,7 +51,7 @@ if len(args) == 1 and args[0].startswith(">"): ) account = store / f"{{user}}@{{host}}" record(f"test {{user}}@{{host}}") - if account.is_file() and account.read_text(encoding="utf-8") == password: + if account.is_file() and account.read_text(encoding="utf-8") == digest(password): print("Result: true") sys.exit(0) print("Error: Auth failed. Invalid username or password.", file=sys.stderr) @@ -58,20 +64,24 @@ if action == "password": if not account.is_file(): print("Error: No such user", file=sys.stderr) sys.exit(1) - account.write_text(password, encoding="utf-8") + account.write_text(digest(password), encoding="utf-8") print("OK: User password changed") sys.exit(0) if action == "create": if account.is_file(): print("Error: User exists", file=sys.stderr) sys.exit(1) - account.write_text(password, encoding="utf-8") + account.write_text(digest(password), encoding="utf-8") print("OK: User created") sys.exit(0) sys.exit(2) """ +def digest(password): + return hashlib.sha256(password.encode("utf-8")).hexdigest() + + class TestRealignAccounts(unittest.TestCase): def setUp(self): tmp = tempfile.TemporaryDirectory() @@ -100,7 +110,9 @@ class TestRealignAccounts(unittest.TestCase): def plant(self, **passwords): for user, password in passwords.items(): - (self.store / f"{user}@{DOMAIN}").write_text(password, encoding="utf-8") + (self.store / f"{user}@{DOMAIN}").write_text( + digest(password), encoding="utf-8" + ) def realign(self, **env): done = subprocess.run( @@ -132,13 +144,13 @@ class TestRealignAccounts(unittest.TestCase): self.plant(**{**DECLARED, "focus": "stale"}) done = self.realign() self.assertEqual(self.writes(), [f"password focus@{DOMAIN}"]) - self.assertEqual(self.stored("focus"), DECLARED["focus"]) + self.assertEqual(self.stored("focus"), digest(DECLARED["focus"])) self.assertEqual(done.stdout.count("[CHANGED]"), 1) def test_missing_accounts_are_registered_with_the_declared_password(self): done = self.realign() for user in ACCOUNTS: - self.assertEqual(self.stored(user), DECLARED[user]) + self.assertEqual(self.stored(user), digest(DECLARED[user])) self.assertEqual(done.stdout.count("[CHANGED]"), len(ACCOUNTS)) def test_a_password_with_lua_and_shell_metacharacters_verifies_unchanged(self):