@@ -15,22 +15,21 @@ import actions
15
15
import codeql.actions.security.UntrustedCheckoutQuery
16
16
import codeql.actions.security.CachePoisoningQuery
17
17
18
- from Workflow w , PRHeadCheckoutStep checkout , LocalJob j
18
+ from LocalJob j
19
19
where
20
+ // The workflow runs in the context of the default branch
20
21
// TODO: (require to collect trigger types)
21
22
// - add push to default branch?
22
23
// - exclude pull_request_target when branches_ignore includes default branch or when branches does not include the default branch
23
- w .hasTriggerEvent ( [
24
- "check_run" , "check_suite" , "delete" , "discussion" , "discussion_comment" , "fork" , "gollum" ,
25
- "issue_comment" , "issues" , "label" , "milestone" , "project" , "project_card" , "project_column" ,
26
- "public" , "pull_request_comment" , "pull_request_target" , "repository_dispatch" , "schedule" ,
27
- "watch" , "workflow_run"
28
- ] ) and
29
- // Workflow is privileged
30
- w .isPrivileged ( ) and
31
- // The workflow checkouts untrusted code from a pull request
32
- j = w .getAJob ( ) and
33
- j .getAStep ( ) = checkout and
34
- // The checkout step is followed by a cache writing step
24
+ j .getEnclosingWorkflow ( )
25
+ .hasTriggerEvent ( [
26
+ "check_run" , "check_suite" , "delete" , "discussion" , "discussion_comment" , "fork" ,
27
+ "gollum" , "issue_comment" , "issues" , "label" , "milestone" , "project" , "project_card" ,
28
+ "project_column" , "public" , "pull_request_comment" , "pull_request_target" ,
29
+ "repository_dispatch" , "schedule" , "watch" , "workflow_run"
30
+ ] ) and
31
+ // The job checkouts untrusted code from a pull request
32
+ j .getAStep ( ) instanceof PRHeadCheckoutStep and
33
+ // The job writes to the cache
35
34
j .getAStep ( ) instanceof CacheWritingStep
36
- select checkout , "Potential cache poisoning on privileged workflow."
35
+ select j . getAStep ( ) . ( CacheWritingStep ) , "Potential cache poisoning on privileged workflow."
0 commit comments