Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

refactor(test): split MongoDB DSN fixture to avoid scanner FP (#4989)

LearningCircuit2a2c1f75c520
diff --git a/tests/security/test_sanitize_error_message.py b/tests/security/test_sanitize_error_message.py
index efcb70cf0c..726c69d145 100644
--- a/tests/security/test_sanitize_error_message.py
+++ b/tests/security/test_sanitize_error_message.py
@@ -111,16 +111,23 @@ class TestDatabaseDsnCredentials:
assert "[REDACTED]:[REDACTED]@db.internal" in result
def test_sqlalchemy_dialect_driver_scheme_redacted(self):
- # SQLAlchemy DSNs carry a `dialect+driver` scheme.
+ # SQLAlchemy DSNs carry a `dialect+driver` scheme. Each DSN is built
+ # by f-string concatenation so no literal "user:password@" pair
+ # appears in source — keeps regex-based secret scanners from flagging
+ # classic default-cred shapes like root:toor alongside the MongoDB
+ # fixture that originally triggered alert #2.
+ pg_user, pg_pw = "user", "pa55"
+ my_user, my_pw = "root", "toor"
+ mongo_user, mongo_pw = "appuser", "letmein"
for msg in (
- "postgresql+psycopg2://user:pa55@dbhost/appdb",
- "mysql+pymysql://root:toor@localhost:3306/db",
- "mongodb+srv://appuser:[email protected]/test", # gitleaks:allow
+ f"postgresql+psycopg2://{pg_user}:{pg_pw}@dbhost/appdb",
+ f"mysql+pymysql://{my_user}:{my_pw}@localhost:3306/db",
+ f"mongodb+srv://{mongo_user}:{mongo_pw}@cluster0.mongodb.net/test",
):
result = sanitize_error_message(msg)
assert "[REDACTED]:[REDACTED]@" in result, msg
- assert "toor" not in sanitize_error_message(
- "mysql+pymysql://root:toor@localhost:3306/db"
+ assert my_pw not in sanitize_error_message(
+ f"mysql+pymysql://{my_user}:{my_pw}@localhost:3306/db"
)
def test_password_only_redis_dsn_redacted(self):