fix: avoid logging env dashboard password#9135
Conversation
There was a problem hiding this comment.
Code Review
This pull request ensures that when the dashboard initial password is provided via an environment variable, the generated dashboard password attribute is set to None instead of exposing the password. The corresponding unit test has been updated to verify this behavior, ensuring that env-provided passwords are secure and not exposed. I have no feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
astrbot-docs | d5826a3 | Commit Preview URL Branch Preview URL |
Jul 04 2026, 09:02 AM |
|
This was also intentionally designed. |
|
It's best not to put passwords in the logs, but I don't think it matters that much. |
Motivation
ASTRBOT_DASHBOARD_INITIAL_PASSWORDin the transient_generated_dashboard_passwordattribute which was later included verbatim in logger output.Description
AstrBotConfig._reset_generated_dashboard_passwordto avoid settingself._generated_dashboard_passwordwhenASTRBOT_DASHBOARD_INITIAL_PASSWORDis present in the environment by writinggenerated_password if DASHBOARD_INITIAL_PASSWORD_ENV not in os.environ else Noneinto the attribute.conf['dashboard']['pbkdf2_password']and legacy MD5 field so authentication behavior is unchanged.test_empty_dashboard_password_uses_initial_password_envto assert that env-provided passwords are hashed into config but are not exposed viaconfig._generated_dashboard_password.Testing
uv run --no-sync ruff format astrbot/core/config/astrbot_config.py tests/unit/test_config.pyanduv run --no-sync ruff check astrbot/core/config/astrbot_config.py tests/unit/test_config.py, which passed.uv run --no-sync pytest tests/unit/test_config.py -q, but test execution was blocked due to missing test runtime dependencypytest_asyncioin the environment.astrbot/core/config/astrbot_config.pyandtests/unit/test_config.pywere updated to implement and assert the new non-logging behavior.Codex Task
Summary by Sourcery
Ensure environment-provided dashboard passwords are no longer stored in a runtime attribute that is later logged, while keeping authentication behavior unchanged.
Bug Fixes:
Tests: