Skip to content

code review 2026-07-25: 安全/正确性修复 (A1–A7) - #6

Merged
everbird merged 4 commits into
mainfrom
codereview-2026-07-25
Jul 25, 2026
Merged

code review 2026-07-25: 安全/正确性修复 (A1–A7)#6
everbird merged 4 commits into
mainfrom
codereview-2026-07-25

Conversation

@everbird

Copy link
Copy Markdown
Owner

三方 AI 评审(Claude 初评 + Codex/Antigravity 交叉评审)reconcile 成 final,双方已 stamp。本 PR 实现 final 的 Action Items。

评审文档:docs/codereview/2026-07-25-final.md

改动(按优先级)

🔴 必做

  • A1 路径逃逸:校验用户名/分类名为单一路径段(is_safe_path_segment)+ upload.py 落盘前 resolve() containment 兜底(DATA_DIR/UPLOAD_DIR 各查一次,显式 abort(400))。
  • A2 软删除生效view_report/view_category/readerstatus 收口;/raw 新增 DB 活跃校验(get_report_by_path,此前完全不查库)。
  • A3 上传清理finally 无条件删暂存 zip;BadZipFile→400;失败清理解压目录;同步改测试。

🟠 顺手

  • A4 open redirectis_safe_next_url 只放本站相对路径(含拒 ///\;Flask-Login 0.6.3 无对应 helper)。
  • A5 用户名大小写:注册查重改用 get_by_login(不区分大小写)。
  • A6 分页/解压上限clamped_page_args(下界 + offset 重算)+ 解压成员数/体积上限。
  • A7:删 report_reader 不可达 return。

测试

104 passed(原 67 + 新增 37 条回归测试 tests/test_review_fixes.py,覆盖 A1/A2/A3/A4/A5/A6)。

🤖 Generated with Claude Code

everbird and others added 4 commits July 24, 2026 12:13
Claude 初评 + Codex/Antigravity 交叉评审,reconcile 为 final(双方 stamp)。
Action Items 待实现。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
A1 path traversal: reject unsafe username/category names (is_safe_path_segment)
    + resolve()-based containment check before write in upload.py.
A2 soft delete: guard view_report/view_category/reader with status; add DB
    active-check to /raw (get_report_by_path), which never queried the DB.
A3 upload cleanup: always unlink staging zip (finally); handle BadZipFile -> 400;
    clean partial extract target on error. Tests updated to expect cleanup.
A4 open redirect: only follow local relative next (is_safe_next_url; Flask-Login
    0.6.3 has no url_has_allowed_host_and_scheme; also reject '/\').
A5 username casing: registration dup-check via case-insensitive get_by_login.
A6 pagination/extract bounds: clamped_page_args (lower bound + offset recompute);
    cap zip member count and total uncompressed size.
A7 remove unreachable return in report_reader.

Review: docs/codereview/2026-07-25-final.md (stamped by Codex + Antigravity).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@everbird
everbird merged commit 5a6a93f into main Jul 25, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant