Skip to content

Harden security bot robustness#106

Merged
wesm merged 4 commits intomainfrom
fix-security-bot-robustness
Feb 8, 2026
Merged

Harden security bot robustness#106
wesm merged 4 commits intomainfrom
fix-security-bot-robustness

Conversation

@wesm
Copy link
Owner

@wesm wesm commented Feb 8, 2026

Summary

  • Comment size splitting: Split oversized comments (>60K chars) across multiple GitHub comments to avoid 422 errors when many findings are reported, with hard-wrap fallback for single large sections
  • Post-before-delete ordering: Post new bot comment before deleting old ones, so security context is never lost if posting fails (API error/rate limit/validation)
  • Self-deletion prevention: Track newly posted comment IDs via exclude_ids so the cleanup pass doesn't delete the comment it just posted
  • Stable bot marker: Embed <!-- msgvault-security-bot --> HTML comment in every bot comment (including split continuation chunks) for reliable cleanup matching
  • Unit tests: 22 tests covering size splitting, hard-wrap, post-then-delete ordering, self-deletion prevention, and integration tests with FakePR

Test plan

  • All 22 Python tests pass (pytest test_security_review.py)
  • All Go tests pass (make test)
  • Verify on a real PR that the bot still posts comments correctly

🤖 Generated with Claude Code

wesm and others added 4 commits February 7, 2026 19:30
…cy comments

Address robustness findings from security review:
- Split oversized comments to stay under GitHub's 65K char limit
- Post new comment before deleting old ones so context is never lost
- Clean up legacy inline review comments in addition to issue comments
- Add 15 unit tests covering size splitting, ordering, and edge cases

Co-Authored-By: Claude Opus 4.6 <[email protected]>
…urity bot

Address robustness review findings:
- Prevent self-deletion: track new comment IDs and pass exclude_ids to
  delete_old_bot_comments so freshly posted comments aren't removed
- Handle oversized single sections: add hard-wrap fallback with min_cut
  guarantee to split any chunk exceeding 60K, even without --- separators
- Add HTML bot marker (<!-- msgvault-security-bot -->) to all comments
  including split continuation chunks for reliable cleanup matching
- Add 24 tests including integration tests with FakePR verifying real
  post-then-delete behavior and self-deletion prevention

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Assert that every posted chunk is <= 60K chars in all split/hard-wrap
tests, closing a testing gap that could let off-by-one regressions
in chunk sizing slip through.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Drop the get_review_comments() cleanup logic — deleting old inline
review comments from a previous bot format is too aggressive. Only
clean up issue comments going forward.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@wesm wesm merged commit a6b5ca0 into main Feb 8, 2026
3 checks 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