# 运维时区全局北京 — 定向审计(2026-06-09) ## 范围 本次 diff 约 8 文件 + 3 文档 + 1 新测。**非**全库 Phase-2 逐行 8 步;按变更面做逻辑/安全/一致性走读。 | 文件 | 行数 | 审计方式 | |------|------|----------| | `server/utils/display_time.py` | 65 | 全文 + 单测 | | `server/background/schedule_runner.py` | 293 | cron/next_run/last_run 路径 | | `server/infrastructure/database/audit_log_repo.py` | 84 | 筛选逻辑 | | `server/api/settings.py` | 告警 date 片段 | 与 audit 对齐 | | `frontend/src/utils/datetime.ts` | beijingWallParts | 与后端对齐 | | `frontend/src/utils/scheduleCycle.ts` | cronMatch/computeNext | 与 runner 对齐 | ## 规则命中与 Closure | ID | 规则 | 结论 | 说明 | |----|------|------|------| | H1 | PY-11 naive/aware 混用 | SAFE | `last_run_at` 改 `to_naive_utc`;匹配用 `ensure_utc` | | H2 | 调度双触发 | SAFE | 仍 60s 冷却 + `last_run_at` 防抖 | | H3 | 日期筛选静默吞错 | RISK-P3 | `ValueError: pass` 沿用旧模式;非法日期不报错 | | H4 | 存量 cron 语义变更 | RISK-P2 | 无 DB 迁移;用户确认生产几乎无启用调度,部署后人工核对 | | H5 | 前后端 cron 不一致 | SAFE | 均用北京墙钟;单测锚点 UTC 18:00 = 北京 02:00 | | H6 | 审计日界 | SAFE | `beijing_day_range_utc`;北京 00:00 = UTC 前日 16:00 | | H7 | SQL 注入 | SAFE | 日期仅 `fromisoformat` + 固定格式,无拼接 SQL | | H8 | ruff F401 | FIXED | `settings.py` 告警列表移除未用 `datetime` import | **命中 8 条,Closure 8 条。** ## 未覆盖 / 建议跟进 1. **无**审计 `date_from` 北京边界的集成测(仅 `test_operator_tz` 单元级);可补 `test_alerts_audit` 带日期参数。 2. **未**跑 `pre_deploy_check.sh` 全 7 道门控(仅 `local_verify` L2b)。 3. **未**浏览器手工验调度页 `next_run` 列(需登录 SPA)。 ## 验证证据 ```text bash scripts/local_verify.sh → All local checks passed pytest test_operator_tz + schedule_next_run + test_alerts_audit → passed npm run type-check → passed(前次会话) ``` ## 结论 **定向审计通过**,可进入部署前 `pre_deploy_check`;部署后请人工核对调度列表 `next_run`。