I wouldn't merge this yet. There are 3 bugs that will break things, 1 SQL injection, and 1 risk. The original code was correct before this change.
src/orders/service.ts
L15: 🔴 bug: the loop runs one step too far.i <= order.items.lengthreadsorder.items[length], which isundefined, so.pricethrows a TypeError on every call. Use<, or keep the originalreduce, which was correct and shorter.L22: 🔴 bug:awaitwas removed fromthis.coupons.find(code), socouponis now a Promise.coupon.expiresAtisundefinedandundefined < Date.now()isfalse, so the expiry check never fires and expired coupons are accepted.coupon.idis alsoundefined. Put theawaitback.L24: 🔴 bug: the update is fire-and-forget and.catch(() => {})hides any failure. Callers see success even when the coupon was never saved, and nothing is logged. Put backawait this.repo.update(...)and let errors reach the caller.L22-23: 🟡 risk: iffindreturns null for an unknown code,coupon.expiresAtthrows a TypeError instead of a clear error. Addif (!coupon) throw new Error("invalid coupon").
L28: 🔴 security: SQL injection in listOrders. userId is put straight into the SQL string. A value like ' OR '1'='1 returns every user's orders, and with stacked queries an attacker could change or delete data (CWE-89, OWASP A03). Even if userId comes from an auth token today, this function can't assume that, and a single caller passing a request param makes it exploitable. Use a parameterized query, e.g. this.db.query("SELECT * FROM orders WHERE user_id = $1", [userId]) (use whatever placeholder syntax your driver expects).
L28: 🔵 nit:SELECT *returns every column and will pick up any column added later. List the columns you need.L27: 🔵 nit: no return type, unlikegetOrderTotal. AddPromise<Order[]>.
Real run recorded with claude-code / claude-opus-5-5. Output is shown verbatim, unmodified.
它做什么
按 L<行号>: <问题>. <修法>. 的紧凑格式写代码审查意见,可以直接贴到 Pull Request 里。
工作方式
- 输入 /caveman-review,或说 "review this PR"、"review the diff" 时触发。
- 每个问题一行,写明准确行号、用反引号标出的符号名和具体修法,可加严重程度标记:🔴 bug、🟡 风险、🔵 小问题、❓ 疑问。
- 去掉含糊措辞和对 diff 的复述;遇到安全问题、架构分歧和新人上手的场景,则改写完整的一段说明。
适合场景
审查 diff 和 Pull Request,希望意见一眼就能扫完。
需要了解
它只写审查意见,不改代码、不点批准或要求修改,也不跑 lint。
纯指令文件:没有脚本、不联网、不写文件。 压缩包里另有原仓库的 README、LICENSE 和 NOTICE。 审查结论是模型生成的,发出去之前请自己核对。