Add delete-existing-comments option#57
Open
bertonjulian wants to merge 7 commits intoanthropics:mainfrom
Open
Conversation
Previously, the script would skip ALL new comments if it detected any existing security comments on the PR. This meant that when new commits introduced additional vulnerabilities, they would not be reported. This fix changes the deduplication logic to: 1. Check each new finding against existing comments 2. Skip only findings that are true duplicates (same file + same message) 3. Post the remaining genuinely new findings Includes test cases for the new behavior. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The description can vary between runs, so using it for deduplication caused false negatives. Changed to use stable fields: - file path - line number - category This ensures findings are only considered duplicates when they refer to the exact same location and type of vulnerability. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Instead of trying to deduplicate comments, post all findings fresh and let GitHub's native "outdated" marking handle stale comments. When code changes, GitHub automatically marks comments on affected lines as "outdated" and hides them from the main view. This is simpler and more reliable than custom deduplication logic. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Instead of trying to deduplicate or relying on GitHub's outdated marking, delete all existing security comments from the bot before posting new ones. This ensures: - No duplicate comments - No stale comments pointing to old line numbers - Clean slate on each run This is the same approach used by reviewdog. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add new `delete-existing-comments` input (default: false) to optionally delete existing security comments before posting new ones. This allows users to opt-in to the clean slate behavior rather than making it the default. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When using
run-every-commit: true, the security review runs on every commit pushed to a PR. However, the comment posting logic skips ALL new comments if any existing security comments are found on the PR:This means:
The action detects the new issues but refuses to post them because existing comments are present. New vulnerabilities introduced in subsequent commits are silently ignored.
Solution
Adds a new
delete-existing-commentsinput option that deletes existing security comments before posting new ones. This ensures all current findings are posted fresh on each run.New Input
delete-existing-commentsfalseUsage
Why Optional?
run-every-commitWhat It Does
When enabled:
🤖 **Security Issue:from bot usersOnly security comments from bots are deleted - regular review comments are preserved.
Test plan
🤖 Generated with Claude Code