Loading...
Loading...
Compare original and translation side by side
| 避免(命令式) | 推荐(建议式) |
|---|---|
| 你必须改成 X | 建议考虑用 X,因为 Y |
| 这里写错了 | 这里可能存在一个问题,是否考虑过 Z 的情况? |
| 不要用这个方法 | 这个方法在 A 场景下可能有性能问题,可以看看 B 方案 |
| 这段代码不行 | 这段逻辑我理解得对吗?如果输入为空的话会怎样? |
| Avoid (Imperative) | Recommended (Suggestive) |
|---|---|
| You must change this to X | It is recommended to consider using X because Y |
| This is wrong | There might be an issue here. Have you considered scenario Z? |
| Don't use this method | This method may have performance issues in scenario A. You can look into solution B |
| This code is not acceptable | Did I understand this logic correctly? What happens if the input is empty? |
undefinedundefinedundefinedundefined[必须修复] SQL 注入风险
第 42 行:用户输入直接拼接到 SQL 语句中。
原因:攻击者可以通过 name 参数注入 `'; DROP TABLE users; --`。
建议:使用参数化查询:
db.query('SELECT * FROM users WHERE name = $1', [name])
参考:https://cheatsheetseries.owasp.org/cheatsheets/SQL_Injection_Prevention_Cheat_Sheet.html[Must Fix] SQL Injection Risk
Line 42: User input is directly concatenated into the SQL statement.
Reason: Attackers can inject `'; DROP TABLE users; --` via the name parameter.
Suggestion: Use parameterized queries:
db.query('SELECT * FROM users WHERE name = $1', [name])
Reference: https://cheatsheetseries.owasp.org/cheatsheets/SQL_Injection_Prevention_Cheat_Sheet.html/**
* 计算用户的会员等级折扣
*
* 业务规则:
* - 普通会员 9.5 折
* - 银卡会员 9 折
* - 金卡会员 8.5 折
* - 钻石会员 8 折
*
* @param level - 会员等级(MemberLevel enum)
* @param amount - 原始金额(单位:分)
* @returns 折后金额(单位:分)
*/
function calculateDiscount(level: MemberLevel, amount: number): number {
// ...
}/**
* 计算用户的会员等级折扣
*
* 业务规则:
* - 普通会员 9.5 折
* - 银卡会员 9 折
* - 金卡会员 8.5 折
* - 钻石会员 8 折
*
* @param level - 会员等级(MemberLevel enum)
* @param amount - 原始金额(单位:分)
* @returns 折后金额(单位:分)
*/
function calculateDiscount(level: MemberLevel, amount: number): number {
// ...
}// 好:中英文之间加空格
// 使用 Redis 缓存来减少 MySQL 的查询压力
// 坏:中英文之间没有空格
// 使用Redis缓存来减少MySQL的查询压力
// 好:技术术语保留英文
// 这里用 debounce 防抖处理,避免频繁触发 API 请求
// 坏:强行翻译技术术语
// 这里用防抖动处理,避免频繁触发应用程序接口请求// Good: Add space between Chinese and English
// 使用 Redis 缓存来减少 MySQL 的查询压力
// Bad: No space between Chinese and English
// 使用Redis缓存来减少MySQL的查询压力
// Good: Keep technical terms in English
// 这里用 debounce 防抖处理,避免频繁触发 API 请求
// Bad: Forcibly translate technical terms
// 这里用防抖动处理,避免频繁触发应用程序接口请求<类型>(<范围>): <简要描述>
<详细说明(可选)>
<关联信息(可选)><类型>(<范围>): <简要描述>
<详细说明(可选)>
<关联信息(可选)>| 类型 | 含义 | 示例 |
|---|---|---|
| feat | 新功能 | feat(用户): 新增手机号登录功能 |
| fix | 修复 Bug | fix(支付): 修复微信支付回调重复处理的问题 |
| docs | 文档变更 | docs: 更新 API 接口文档 |
| style | 代码格式 | style: 统一缩进为 2 个空格 |
| refactor | 重构 | refactor(订单): 拆分订单服务,提取公共逻辑 |
| perf | 性能优化 | perf(列表): 虚拟滚动优化长列表渲染性能 |
| test | 测试 | test(auth): 补充登录模块单元测试 |
| chore | 构建/工具 | chore: 升级 Node.js 至 v20 |
| Type | Meaning | Example |
|---|---|---|
| feat | New Feature | feat(用户): 新增手机号登录功能 |
| fix | Bug Fix | fix(支付): 修复微信支付回调重复处理的问题 |
| docs | Document Changes | docs: 更新 API 接口文档 |
| style | Code Format | style: 统一缩进为 2 个空格 |
| refactor | Refactoring | refactor(订单): 拆分订单服务,提取公共逻辑 |
| perf | Performance Optimization | perf(列表): 虚拟滚动优化长列表渲染性能 |
| test | Testing | test(auth): 补充登录模块单元测试 |
| chore | Build/Tools | chore: 升级 Node.js 至 v20 |
fix(支付): 修复支付宝异步回调签名校验失败的问题
原因:升级 SDK 后签名算法从 RSA 变为 RSA2,但回调校验仍使用旧算法。
方案:回调处理中同时兼容 RSA 和 RSA2 签名校验。
Closes #1234fix(支付): 修复支付宝异步回调签名校验失败的问题
原因:升级 SDK 后签名算法从 RSA 变为 RSA2,但回调校验仍使用旧算法。
方案:回调处理中同时兼容 RSA 和 RSA2 签名校验。
Closes #1234fix(payment): fix Alipay async callback signature verification failure
The SDK upgrade changed the signature algorithm from RSA to RSA2,
but the callback handler still used the old algorithm.
Closes #1234fix(payment): fix Alipay async callback signature verification failure
The SDK upgrade changed the signature algorithm from RSA to RSA2,
but the callback handler still used the old algorithm.
Closes #1234undefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedLGTM
审查了以下方面:
- 并发安全:锁的粒度合理
- 错误处理:所有外部调用都有 error handling
- 向下兼容:新增字段都有默认值,不影响老版本
一个小建议 [仅供参考]:第 78 行的变量名 `d` 可以改成 `duration`,更易读。LGTM
Reviewed aspects:
- Concurrency safety: Lock granularity is reasonable
- Error handling: All external calls have error handling
- Backward compatibility: New fields have default values and do not affect old versions
A small suggestion [仅供参考]: The variable name `d` on line 78 can be changed to `duration` for better readability.总结:整体实现思路清晰,支付回调的幂等处理很到位。
主要问题:
1. [必须修复] 并发写 map 的问题(2 处)
2. [建议修改] 缺少对空值的校验(3 处)
3. [仅供参考] 几个变量命名可以更语义化
建议先修复并发问题,校验的部分可以本次一起改或者拆到下个迭代。Summary: The overall implementation logic is clear, and the idempotent processing of payment callbacks is well done.
Main Issues:
1. [Must Fix] Concurrent map write issues (2 places)
2. [Suggested Modification] Missing null value validations (3 places)
3. [For Reference Only] Several variable names can be more semantic
Suggestion: Fix the concurrency issues first; the validation part can be fixed in this iteration or split into the next iteration.