An open source, non-profit web search engine
Keep a review trigger from being fired by a bot too
Daoud Clarkefa224e52423c
diff --git a/.github/workflows/claude-issues.yml b/.github/workflows/claude-issues.ymlindex 5ac21cc..e3ac71d 100644--- a/.github/workflows/claude-issues.yml+++ b/.github/workflows/claude-issues.yml@@ -83,7 +83,10 @@ jobs:# The author checks matter for more than noise. Feedback from someone without write# access must never be able to start a run on a public repository, so a comment or# review only counts from an OWNER, MEMBER or COLLABORATOR, and never from a bot —- # which is also what stops the automation waking itself with its own comments.+ # which is also what stops the automation waking itself with its own comments. The+ # login test belongs on all three: a run that answers a question posts as the Claude+ # app rather than with GITHUB_TOKEN, so unlike a GITHUB_TOKEN comment it does raise an+ # event, and author_association is not a reliable way to recognise an app.## A pull request from a fork is out of scope for the same reason, and for a practical# one: GitHub gives a fork's pull_request event no secrets and a read-only token@@ -102,11 +105,13 @@ jobs:&& (github.event_name != 'pull_request_review'|| (startsWith(github.event.pull_request.head.ref, 'claude/')&& github.event.pull_request.head.repo.full_name == github.repository- && contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.review.author_association)))+ && contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.review.author_association)+ && !endsWith(github.event.review.user.login, '[bot]')))&& (github.event_name != 'pull_request_review_comment'|| (startsWith(github.event.pull_request.head.ref, 'claude/')&& github.event.pull_request.head.repo.full_name == github.repository- && contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association)))+ && contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association)+ && !endsWith(github.event.comment.user.login, '[bot]')))&& (github.event_name != 'workflow_run'|| (github.event.workflow_run.conclusion == 'failure'&& startsWith(github.event.workflow_run.head_branch, 'claude/')))diff --git a/test/test_claude_automation_workflow.py b/test/test_claude_automation_workflow.pyindex ff0c304..4f6380f 100644--- a/test/test_claude_automation_workflow.py+++ b/test/test_claude_automation_workflow.py@@ -161,6 +161,20 @@ def test_comment_and_review_triggers_require_write_access(workflow: dict) -> Nonassert '"OWNER","MEMBER","COLLABORATOR"' in clause.split("&& (github.event_name")[0]+def test_no_feedback_trigger_can_be_fired_by_a_bot(workflow: dict) -> None:+ """A run answering a question comments as the Claude app, which — unlike a comment made+ with GITHUB_TOKEN — does raise an event. author_association does not reliably identify+ an app, so every clause tests the login too."""+ guard = workflow["jobs"]["select"]["if"]+ for event, field in [+ ("issue_comment", "comment"),+ ("pull_request_review", "review"),+ ("pull_request_review_comment", "comment"),+ ]:+ clause = guard.split(f"github.event_name != '{event}'")[1].split("&& (github.event_name")[0]+ assert f"!endsWith(github.event.{field}.user.login, '[bot]')" in clause, event++def test_nothing_the_runs_write_lands_inside_the_checkout(workflow: dict) -> None:"""The review and finalise steps run git with an unrestricted Bash tool and are askedto commit; an untracked file in the working tree is one `git add -A` from the diff."""