codexqa-defect-analyzer · Incremental

缺陷扫描报告 7 条 findings

目标 inventory-service@reservation-v2

生成时间: 2026-09-21T14:34:12.651036 扫描文件: 6 Policy: codexqa-defect-analyzer-default v1.1.0 Tooling: Ready: semgrep, gitleaks, bandit, ruff, eslint, osv-api

按严重级别

扫描覆盖

DET
0%
LLM
100%
0sast confirmed
0sast only
7llm judged

规则命中

Active rules: 27

CONC-001
1
LOGIC-002
1
LOGIC-003
1
LOGIC-001
1
RES-001
1
LOGIC-004
1
LOGIC-005
1

P0 发现项 4

点击卡片展开证据与修复建议

分类
concurrency
ID
fr-20260921-002
位置
src/inventory.js:49
置信度
87%

证据

readStock to available then putStock with no lock. Two concurrent quantity=1 holds when available=1 both pass the check.

修复建议

Make the availability check and reserved increment one atomic update under withLock.

分类
logic
ID
fr-20260921-004
位置
src/refund.js:27
置信度
93%

证据

remaining is computed then unused. When requested is set, the function returns roundMoney(requested) with no min(requested, remaining).

修复建议

return min(amount, remaining) after the <=0 guard; never exceed remaining.

分类
logic
ID
fr-20260921-005
位置
src/refund.js:72
置信度
91%

证据

catch of gateway.refund writes a localOnly receipt and continues. Callers see a settled refund while the provider did not capture it.

修复建议

Return { ok: false } on gateway failure; do not invent a receipt or increment refundedTotal.

分类
logic
ID
fr-20260921-007
位置
src/reservation.js:166
置信度
89%

证据

expireStaleReservations adjusts reserved then saves EXPIRED, but never availabilityCache.invalidate.

修复建议

Invalidate the same cache key holdStock / releaseStock already invalidate after adjustReserved.

P1 发现项 3

点击卡片展开证据与修复建议

分类
resource_leak
ID
fr-20260921-001
位置
src/db.js:191
置信度
88%

证据

If fn() throws, releaseLock never runs and the key stays held.

修复建议

Wrap fn() in try/finally and always releaseLock(key).

分类
logic
ID
fr-20260921-003
位置
src/pricing.js:33
置信度
95%

证据

volumeDiscountRate uses units > 50 and units > 10. Spec is inclusive lower bounds.

修复建议

Use units >= VOLUME_TIER_LARGE and units >= VOLUME_TIER_SMALL.

分类
logic
ID
fr-20260921-006
位置
src/reservation.js:95
置信度
83%

证据

committedAt is written but status stays HELD. A second commit can pass the NOT_HELD guard.

修复建议

Set reservation.status = COMMITTED before saveReservation returns.