File tree Expand file tree Collapse file tree 4 files changed +22
-1
lines changed
test/query-tests/Security/CWE-829 Expand file tree Collapse file tree 4 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -232,7 +232,9 @@ abstract class SimpleReferenceExpression extends AstNode instanceof SimpleRefere
232
232
AstNode getTarget ( ) { result = super .getTarget ( ) }
233
233
}
234
234
235
- class StepsExpression extends SimpleReferenceExpression instanceof StepsExpressionImpl { }
235
+ class StepsExpression extends SimpleReferenceExpression instanceof StepsExpressionImpl {
236
+ string getStepId ( ) { result = super .getStepId ( ) }
237
+ }
236
238
237
239
class NeedsExpression extends SimpleReferenceExpression instanceof NeedsExpressionImpl { }
238
240
Original file line number Diff line number Diff line change @@ -858,6 +858,8 @@ class StepsExpressionImpl extends SimpleReferenceExpressionImpl {
858
858
this .getEnclosingJob ( ) = result .getEnclosingJob ( ) and
859
859
result .( StepImpl ) .getId ( ) = stepId
860
860
}
861
+
862
+ string getStepId ( ) { result = stepId }
861
863
}
862
864
863
865
/**
Original file line number Diff line number Diff line change @@ -66,6 +66,7 @@ predicate containsHeadRef(string s) {
66
66
"\\bgithub\\.event\\.check_run\\.pull_requests\\[\\d+\\]\\.head\\.sha\\b" ,
67
67
"\\bgithub\\.event\\.check_run\\.pull_requests\\[\\d+\\]\\.id\\b" ,
68
68
"\\bgithub\\.event\\.check_run\\.pull_requests\\[\\d+\\]\\.number\\b" ,
69
+ "\\bhead\\.sha\\b" , "\\bhead\\.ref\\b"
69
70
] , _, _)
70
71
)
71
72
}
@@ -80,6 +81,14 @@ class ActionsCheckout extends PRHeadCheckoutStep instanceof UsesStep {
80
81
(
81
82
containsHeadRef ( this .getArgumentExpr ( "ref" ) .getExpression ( ) )
82
83
or
84
+ exists ( StepsExpression e |
85
+ this .getArgumentExpr ( "ref" ) = e and
86
+ (
87
+ e .getStepId ( ) .matches ( [ "%sha%" , "%head%" , "branch" ] ) or
88
+ e .getFieldName ( ) .matches ( [ "%sha%" , "%head%" , "branch" ] )
89
+ )
90
+ )
91
+ or
83
92
exists ( UsesStep head |
84
93
head .getCallee ( ) = [ "eficode/resolve-pr-refs" , "xt0rted/pull-request-comment-branch" ] and
85
94
DataFlow:: hasLocalFlowExpr ( head , this .getArgumentExpr ( "ref" ) )
Original file line number Diff line number Diff line change 10
10
| .github/workflows/issue_comment_direct.yml:28:9:32:2 | Uses Step | Potential unsafe checkout of untrusted pull request on privileged workflow. |
11
11
| .github/workflows/issue_comment_direct.yml:35:9:40:2 | Uses Step | Potential unsafe checkout of untrusted pull request on privileged workflow. |
12
12
| .github/workflows/issue_comment_direct.yml:43:9:46:126 | Uses Step | Potential unsafe checkout of untrusted pull request on privileged workflow. |
13
+ | .github/workflows/issue_comment_heuristic.yml:28:9:33:2 | Uses Step | Potential unsafe checkout of untrusted pull request on privileged workflow. |
14
+ | .github/workflows/issue_comment_heuristic.yml:48:7:50:46 | Uses Step | Potential unsafe checkout of untrusted pull request on privileged workflow. |
15
+ | .github/workflows/issue_comment_octokit.yml:26:9:30:6 | Uses Step | Potential unsafe checkout of untrusted pull request on privileged workflow. |
16
+ | .github/workflows/issue_comment_octokit.yml:30:9:35:2 | Uses Step | Potential unsafe checkout of untrusted pull request on privileged workflow. |
17
+ | .github/workflows/issue_comment_octokit.yml:57:9:62:2 | Uses Step | Potential unsafe checkout of untrusted pull request on privileged workflow. |
18
+ | .github/workflows/issue_comment_octokit.yml:79:9:83:2 | Uses Step | Potential unsafe checkout of untrusted pull request on privileged workflow. |
19
+ | .github/workflows/issue_comment_octokit.yml:95:9:100:2 | Uses Step | Potential unsafe checkout of untrusted pull request on privileged workflow. |
20
+ | .github/workflows/issue_comment_octokit.yml:109:9:114:66 | Uses Step | Potential unsafe checkout of untrusted pull request on privileged workflow. |
13
21
| .github/workflows/untrusted_checkout.yml:9:7:13:4 | Uses Step | Potential unsafe checkout of untrusted pull request on privileged workflow. |
You can’t perform that action at this time.
0 commit comments