Files
starRiverProperty/docs/testing/访客接口无鉴权调用评估与生产快测方案.md
反编译工作区 8b15445328 feat: add service config templates and extraction script
Former-commit-id: 1de24b7eb79676d1aba9d799a58c5a753290cf52
2026-05-01 19:38:01 +08:00

141 lines
4.3 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 访客接口无鉴权调用评估与生产快测方案
## 1. 目标
- 基于生产日志评估“无鉴权调用访客接口”的真实边界。
- 给出生产可执行的快测方案,验证访客楼层策略是否生效。
- 通过脚本同时支持:
- `auth`:标准鉴权验证(正式验收路径)
- `noauth-probe`:无鉴权探测(安全风险判定,不作业务通过依据)
## 2. 日志证据与边界结论
日志来源:
- `maven-cw-elevator-application/logs/访客相关接口日志分析/日志分析/访客调用楼层放开接口清单.md`
- `maven-cw-elevator-application/logs/访客相关接口日志分析/日志分析/10.0.22.209/202604301713/logs/elevator-app.log`
关键证据:
- 文档中同时存在“JWT 调用”和“无鉴权(username)调用”样本。
- 但同批日志中的 `PersonRuleServiceImpl:196` 记录可见 `CloudwalkCallContext` 已包含:
- `company.companyId`
- `user.callerName`
- 部分请求带 `ext.value.authorization`JWT 场景)
边界判定:
1. 观察到的“无 Authorization header”不能直接等价为“外部匿名可裸调”。
2. 更可能是平台或网关已注入上下文后触发的内部调用路径。
3. 生产对外验证必须以 `auth` 模式为准。
4. `noauth-probe` 仅用于探测当前网关/应用是否放开了不应放开的入口。
## 3. 快测脚本与模式
脚本路径:
- `maven-cw-elevator-application/tools/visitor_floor_verification/scripts/quick_verify_visitor_floor_policy.py`
### 3.1 auth 模式(正式)
三步调用:
1. `POST /component/person/detail`
2. `POST /elevator/person/add/visitor`
3. `POST /elevator/passRule/image`
请求头采用 `ELEVATOR_HEADER_*`authorization/loginid/platformuserid/applicationid+ `businessid`
### 3.2 noauth-probe 模式(探测)
- 仅发送 `Content-Type`,可选附加 `businessid`
- 不发送 Authorization、loginid、platformuserid、applicationid。
- 输出状态码/业务码用于判定“是否存在风险放开”。
## 4. 结果分级规则
### 4.1 auth 模式
- 通过:
- 三步 HTTP 均成功返回;
- `add/visitor` 业务成功,或返回 `76260532`(交集为空,预期失败);
- `passRule/image` 返回可解析数据。
- 失败:
- HTTP 4xx/5xx、超时、响应不可解析;
- 关键业务码异常且不属于 `76260532`
### 4.2 noauth-probe 模式
- 预期拦截(正常):
- 返回 401/403,或明确鉴权失败业务码。
- 安全异常(高风险):
- 返回 2xx 且业务成功(特别是 `add/visitor` 成功)。
- 待排查:
- 返回 2xx 但业务失败且错误语义不清晰,需要结合网关策略判断。
## 5. 运行方式
先准备头信息(auth 模式):
```bash
cd maven-cw-elevator-application/tools/visitor_floor_verification
python3 -m pip install -r requirements.txt
export ELEVATOR_HEADER_AUTHORIZATION='Bearer <TOKEN>'
export ELEVATOR_HEADER_LOGINID='<LOGIN_ID>'
export ELEVATOR_HEADER_PLATFORMUSERID='<PLATFORM_USER_ID>'
export ELEVATOR_HEADER_APPLICATIONID='<APPLICATION_ID>'
```
也可使用模板文件:
- `maven-cw-elevator-application/tools/visitor_floor_verification/.env.quick_verify.example`
例如:
```bash
set -a
source .env.quick_verify
set +a
```
auth 模式(正式验收):
```bash
python3 scripts/quick_verify_visitor_floor_policy.py \
--mode auth \
--org-base-url "http://<ORG_HOST>:<ORG_PORT>" \
--elevator-base-url "http://<ELEVATOR_HOST>:<ELEVATOR_PORT>" \
--meng-person-id "<MENG_HAI_WEN_PERSON_ID>" \
--visitor-person-id "<TEST_VISITOR_PERSON_ID>" \
--business-id "2524639890ba4f2cba9ba1a4eeaa4015" \
--strict-name-check
```
noauth-probe 模式(可选一次):
```bash
python3 scripts/quick_verify_visitor_floor_policy.py \
--mode noauth-probe \
--org-base-url "http://<ORG_HOST>:<ORG_PORT>" \
--elevator-base-url "http://<ELEVATOR_HOST>:<ELEVATOR_PORT>" \
--meng-person-id "<MENG_HAI_WEN_PERSON_ID>" \
--visitor-person-id "<TEST_VISITOR_PERSON_ID>" \
--business-id "2524639890ba4f2cba9ba1a4eeaa4015" \
--probe-with-businessid
```
## 6. 报告与留痕
脚本输出:
- 控制台摘要(模式、三步状态、业务码、风险级别)
- 报告文件:`report/quick-verify-<timestamp>.json`
建议归档:
- 本次执行命令
- 报告 JSON
- 对应时段接口日志摘录
- 最终分级(通过 / 预期拦截 / 高风险)