Repository navigation
Conversation
ISV D-13:build_request/execute 新增 sub_mch_id,签名前写入 x-wop-sub-mch-id 并自动纳入 signedHeaders;不传/空白 = 应用自身身份,头缺席,头集合与签名与旧版逐字节一致(AC-20)。extra_headers 携带该头等价参数,双来源同传即拒。校验:可打印 ASCII、无内部空白、trim 后 ≤128 字符。补 test_submchid.py。 Co-Authored-By: Claude Code <noreply@anthropic.com>
审查 F1:extra_headers 分支 `str(value)` 把 None 强转成 "None" 并静默 入签错误子商户身份;参数路径对 int 等非 str 抛裸 TypeError。 - resolve_sub_mch_id 增 isinstance(str) 守卫(None 仍=未设置) - extra_headers 的 x-wop-sub-mch-id 原值进同一校验链,去掉 str() 强转 - 测试:非 str 参数/extra_headers 均 ConfigurationError;None → 头缺席、 签名与基线逐字节一致 验证:python -m pytest --cov=wop_sdk --cov-branch --cov-fail-under=98 → 全绿,覆盖率 98.89%。 Co-Authored-By: Claude Code <noreply@anthropic.com>
- README zh/en:前置改为「网关已部署 D-13」并删灰度措辞;trim 措辞精确化为 「仅首尾空格可 trim,控制字符即便在首尾也拒」;补充非字符串入参行为 - tests:新增入向不消费用例(响应额外携带未入签 x-wop-sub-mch-id 仍通过) 验证:pytest --cov 全绿(98.89%)。 Co-Authored-By: Claude Code <noreply@anthropic.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
评审者指南端到端实现 ISV D-13 子商户身份输入:经过验证的值会被规范化,并在签名前作为 ISV 子商户请求签名时序图sequenceDiagram
participant Caller
participant Client
participant Resolver as resolve_sub_mch_id
participant Signer
participant Gateway
Caller->>Client: build_request 或 execute,传入 sub_mch_id
Client->>Resolver: resolve_sub_mch_id(value)
alt 有效的非空白值
Resolver-->>Client: 去除首尾空白后的子商户 ID
Client->>Client: 在签名前添加 x-wop-sub-mch-id
Client->>Signer: 使用 signedHeaders 对请求签名
Signer-->>Client: 已签名的请求
Client->>Gateway: 发送带有请求头和签名的请求
else 省略或为空白
Resolver-->>Client: None
Client->>Signer: 对不包含子商户请求头的请求签名
else 输入无效
Resolver-->>Client: ConfigurationError
end
子商户输入来源解析流程图flowchart TD
A[子商户身份输入] --> B{是否同时提供参数和 extra_headers?}
B -->|是| C[ConfigurationError]
B -->|否| D[resolve_sub_mch_id]
D --> E{是否为有效的可打印 ASCII 值?}
E -->|否| C
E -->|去除首尾空白后为空| F[省略 x-wop-sub-mch-id]
E -->|有效| G[在签名前插入 x-wop-sub-mch-id]
G --> H[将请求头纳入 signedHeaders]
文件级变更
提示与命令与 Sourcery 交互
自定义使用体验访问你的控制面板,即可:
获取帮助Original review guide in EnglishReviewer's GuideImplements ISV D-13 sub-merchant identity input end to end: validated values are normalized, inserted as Sequence diagram for ISV sub-merchant request signingsequenceDiagram
participant Caller
participant Client
participant Resolver as resolve_sub_mch_id
participant Signer
participant Gateway
Caller->>Client: build_request or execute with sub_mch_id
Client->>Resolver: resolve_sub_mch_id(value)
alt valid nonblank value
Resolver-->>Client: trimmed sub-merchant ID
Client->>Client: add x-wop-sub-mch-id before signing
Client->>Signer: sign request with signedHeaders
Signer-->>Client: signed request
Client->>Gateway: send request with header and signature
else omitted or blank
Resolver-->>Client: None
Client->>Signer: sign request without sub-merchant header
else invalid input
Resolver-->>Client: ConfigurationError
end
Flow diagram for sub-merchant input source resolutionflowchart TD
A[Sub-merchant identity input] --> B{Both parameter and extra_headers provided?}
B -->|Yes| C[ConfigurationError]
B -->|No| D[resolve_sub_mch_id]
D --> E{Valid printable ASCII value?}
E -->|No| C
E -->|Blank after trimming| F[Omit x-wop-sub-mch-id]
E -->|Valid| G[Insert x-wop-sub-mch-id before signing]
G --> H[Include header in signedHeaders]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
There was a problem hiding this comment.
你好——我已审查你的更改,整体看起来很棒!
Sourcery 评估
需要人工审核。 已签名的 x-wop-sub-mch-id 用于为请求选择子商户上下文;如果发送了错误的 ID,网关可能会以错误的商户身份执行业务操作或持久化记录。回滚可以阻止此后继续使用该请求头,但无法撤销已经执行的操作或已创建的记录。
Original comment in English
Hey - I've reviewed your changes and they look great!
Sourcery assessment
Needs a human reviewer. The signed x-wop-sub-mch-id selects the sub-merchant context for a request; if the wrong ID is sent, the gateway may perform business actions or persist records under the wrong merchant. Reverting removes the header behavior going forward but cannot undo actions or records already created.
What does this PR do?
Spec compliance
Checklist
crypto-vectors.jsonis read-only)Sourcery 总结
支持经过验证的 ISV 子商户身份传递,同时在未指定子商户时保留现有请求行为。
新功能:
sub_mch_id请求参数和执行参数传入可选的 ISV 子商户身份,并在签名后的请求中包含x-wop-sub-mch-id请求头。extra_headers传入等效的子商户身份;如果多个来源提供了冲突的值,则拒绝请求。错误修复:
文档:
测试:
Original summary in English
Summary by Sourcery
Support validated ISV sub-merchant identity propagation while preserving existing request behavior when no sub-merchant is specified.
New Features:
sub_mch_idrequest and execute parameters, including signedx-wop-sub-mch-idheaders.extra_headerswhile rejecting conflicting duplicate sources.Bug Fixes:
Documentation:
Tests: