chore(security): 凭据治理收口 — 清除硬编码DB账号/口令,脚本与API统一从 backend/.env 读取(无明文兜底);取消跟踪 .pyc 构建产物 (credential-governance-20260912)
This commit is contained in:
+10
-2
@@ -7,8 +7,16 @@ import logging
|
||||
|
||||
logger = logging.getLogger("cma")
|
||||
|
||||
DB_USER = os.getenv("CMA_DB_USER", "cma_user")
|
||||
DB_PASS = os.getenv("CMA_DB_PASS", "cma_pass_2026")
|
||||
# 2026-09-12 库访问治理(wecom-ops):统一从 backend/.env 读取凭据,
|
||||
# 定时任务/脚本与 8010 API 同源(此前脚本吃硬编码 fallback,与 .env 不一致)。
|
||||
try:
|
||||
from dotenv import load_dotenv as _load_dotenv
|
||||
_load_dotenv(os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), ".env"))
|
||||
except Exception: # dotenv 缺失/文件不可读时不影响启动,由下方环境变量兜底
|
||||
pass
|
||||
|
||||
DB_USER = os.getenv("CMA_DB_USER", "cma_reader") # 兜底=只读账号(最小权限)
|
||||
DB_PASS = os.getenv("CMA_DB_PASS", "") # 无明文兜底:缺失即连接失败并报错
|
||||
DB_HOST = os.getenv("CMA_DB_HOST", "127.0.0.1")
|
||||
DB_PORT = os.getenv("CMA_DB_PORT", "3306")
|
||||
DB_NAME = os.getenv("CMA_DB_NAME", "cma")
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user