Actions: ActorIfCheck ControlCheck model fix for events that don't populate the checked field - #22368
Actions: ActorIfCheck ControlCheck model fix for events that don't populate the checked field#22368computersarebad wants to merge 4 commits into
ActorIfCheck ControlCheck model fix for events that don't populate the checked field#22368Conversation
…the checked field A condition like 'github.event.pull_request.user.login != ...' on a workflow triggered by issues events is always true since github.event.pull_request is not populated for issues events, but ActorIfCheck still treated it as a protective check, suppressing alerts such as actions/code-injection/critical. Override protectsCategoryAndEvent in ActorIfCheck so that checks on event payload fields only protect events whose payload contains the corresponding context, using contextTriggerDataModel as the mapping. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4084febb-f9c7-44df-baf3-c8be8e9932a7
There was a problem hiding this comment.
Pull request overview
Updates ActorIfCheck to consider whether event payload actor fields exist for the triggering event.
Changes:
- Maps payload actor checks to compatible events.
- Adds valid and vacuous actor-check fixtures.
- Updates expected query results and release notes.
Show a summary per file
| File | Description |
|---|---|
ControlChecks.qll |
Adds event-aware actor-check protection logic. |
actor_check_wrong_event.yml |
Tests a vacuous payload check and valid global actor check. |
actor_check_valid_event.yml |
Tests a valid pull-request payload check. |
CodeInjectionMedium.expected |
Updates generated medium-query results. |
CodeInjectionCritical.expected |
Updates generated critical-query results. |
2026-08-17-actor-if-check-event-validity.md |
Documents the analysis change. |
Review details
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- Files reviewed: 6/6 changed files
- Comments generated: 1
- Review effort level: Balanced
jketema
left a comment
There was a problem hiding this comment.
I'm not too familiar with actions and the actions queries, so I question below.
Design-wise, I wonder whether the ActorIfCheck should be split into two classes:
- The current class, just covering
github.triggering_actorandgithub.actor - A new class
EventIfCheckthat covers the fourgithub.event.cases.
That would significantly simplify the logic, and also seems to better match the github. naming.
Looking at the code again, that might need a better name. |
Per review, ActorIfCheck now only covers github.actor and github.triggering_actor, which are populated for every event and need no event-validity override. Checks on actor fields read from the event payload move to the new EventActorIfCheck class, which only protects events whose payload populates the checked field. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4084febb-f9c7-44df-baf3-c8be8e9932a7
Per review, fold the sender case into eventPayloadActorFieldRegex and keep the matched context_prefix on the class instead of re-matching in the override. Also move the helper next to the class that uses it. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4084febb-f9c7-44df-baf3-c8be8e9932a7
Pins the sender.login special case (protects every event) and that head_commit/commits checks do not protect issues events, where those fields are not populated. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4084febb-f9c7-44df-baf3-c8be8e9932a7
computersarebad
left a comment
There was a problem hiding this comment.
Added a few more testcases in dc6ee11 to pin down the behavior @jketema raised. There's now a job for each case in the issues-triggered workflow, so the sender.login check suppressing the critical alert and the head_commit/commits checks not protecting are both captured in the expected output. I looked at pinning the push side too but push flows only ever show up in the medium query, which doesn't consult control checks, so there's nothing observable to test there.
Fixes #22367
Currently
ActorIfChecktreats a condition as an actor check if it mentions a field likegithub.event.pull_request.user.loginanywhere in theif:expression, and the check then counts as protection for all the events ActorCheck covers. It never looks at whether that field is even populated for the event triggering the workflow. On anissueseventgithub.event.pull_requestis null, so something likeif: github.event.pull_request.user.login != 'some-bot[bot]'is always true and gates nothing, but it still suppressedactions/code-injection/critical(repro in the linked issue).This change overrides
protectsCategoryAndEventin ActorIfCheck so payload field checks only protect events whose payload actually contains that context, reusing the existingcontextTriggerDataModelextension for the mapping. Checks ongithub.actor,github.triggering_actorandgithub.event.sender.loginstill protect every event since those are always populated. The characteristic predicate is unchanged, including the%[bot]%exclusion.This is the same kind of fix as #22154 did for EnvironmentCheck, which suggested reviewing if other check types have this issue. Added two testcases:
actor_check_wrong_event.ymlwith the vacuous check (now detected as critical) next to a validgithub.actorcheck (still medium), andactor_check_valid_event.ymlwith agithub.event.pull_request.user.logincheck on apull_request_targetevent, which is populated there and still suppresses the critical alert. No existing test results change.Edit: per review feedback, the payload-field checks were split out of
ActorIfCheckinto a newEventActorIfCheckclass, soActorIfChecknow only coversgithub.actorandgithub.triggering_actor.