@@ -40,9 +40,10 @@ class GitHubCtxSource extends RemoteFlowSource {
4040
4141class GitHubEventCtxSource extends RemoteFlowSource {
4242 string flag ;
43+ string context ;
4344
4445 GitHubEventCtxSource ( ) {
45- exists ( Expression e , string context , string regexp |
46+ exists ( Expression e , string regexp |
4647 this .asExpr ( ) = e and
4748 context = e .getExpression ( ) and
4849 (
@@ -62,6 +63,8 @@ class GitHubEventCtxSource extends RemoteFlowSource {
6263 }
6364
6465 override string getSourceType ( ) { result = flag }
66+
67+ string getContext ( ) { result = context }
6568}
6669
6770abstract class CommandSource extends RemoteFlowSource {
@@ -77,7 +80,7 @@ class GitCommandSource extends RemoteFlowSource, CommandSource {
7780
7881 GitCommandSource ( ) {
7982 exists ( Step checkout , string cmd_regex |
80- // This shoould be:
83+ // This should be:
8184 // source instanceof PRHeadCheckoutStep
8285 // but PRHeadCheckoutStep uses Taint Tracking anc causes a non-Monolitic Recursion error
8386 // so we list all the subclasses of PRHeadCheckoutStep here and use actions/checkout as a workaround
@@ -87,7 +90,8 @@ class GitCommandSource extends RemoteFlowSource, CommandSource {
8790 checkout = uses and
8891 uses .getCallee ( ) = "actions/checkout" and
8992 exists ( uses .getArgument ( "ref" ) ) and
90- not uses .getArgument ( "ref" ) .matches ( "%base%" )
93+ not uses .getArgument ( "ref" ) .matches ( "%base%" ) and
94+ uses .getATriggerEvent ( ) .getName ( ) = checkoutTriggers ( )
9195 )
9296 or
9397 checkout instanceof GitMutableRefCheckout
@@ -102,8 +106,8 @@ class GitCommandSource extends RemoteFlowSource, CommandSource {
102106 checkout .getAFollowingStep ( ) = run and
103107 run .getScript ( ) .getAStmt ( ) = cmd and
104108 cmd .indexOf ( "git" ) = 0 and
105- untrustedGitCommandsDataModel ( cmd_regex , flag ) and
106- cmd .regexpMatch ( ".*" + cmd_regex + ".*" )
109+ untrustedGitCommandDataModel ( cmd_regex , flag ) and
110+ cmd .regexpMatch ( cmd_regex + ".*" )
107111 )
108112 }
109113
@@ -114,6 +118,34 @@ class GitCommandSource extends RemoteFlowSource, CommandSource {
114118 override Run getEnclosingRun ( ) { result = run }
115119}
116120
121+ class GhCLICommandSource extends RemoteFlowSource , CommandSource {
122+ Run run ;
123+ string cmd ;
124+ string flag ;
125+
126+ GhCLICommandSource ( ) {
127+ exists ( string cmd_regex |
128+ this .asExpr ( ) = run .getScript ( ) and
129+ run .getScript ( ) .getAStmt ( ) = cmd and
130+ cmd .indexOf ( "gh " ) = 0 and
131+ untrustedGhCommandDataModel ( cmd_regex , flag ) and
132+ cmd .regexpMatch ( cmd_regex + ".*" ) and
133+ (
134+ cmd .regexpMatch ( ".*\\b(pr|pulls)\\b.*" ) and
135+ run .getATriggerEvent ( ) .getName ( ) = checkoutTriggers ( )
136+ or
137+ not cmd .regexpMatch ( ".*\\b(pr|pulls)\\b.*" )
138+ )
139+ )
140+ }
141+
142+ override string getSourceType ( ) { result = flag }
143+
144+ override Run getEnclosingRun ( ) { result = run }
145+
146+ override string getCommand ( ) { result = cmd }
147+ }
148+
117149class GitHubEventPathSource extends RemoteFlowSource , CommandSource {
118150 string cmd ;
119151 string flag ;
@@ -203,7 +235,7 @@ class ArtifactSource extends RemoteFlowSource, FileSource {
203235 */
204236private class CheckoutSource extends RemoteFlowSource , FileSource {
205237 CheckoutSource ( ) {
206- // This shoould be:
238+ // This should be:
207239 // source instanceof PRHeadCheckoutStep
208240 // but PRHeadCheckoutStep uses Taint Tracking anc causes a non-Monolitic Recursion error
209241 // so we list all the subclasses of PRHeadCheckoutStep here and use actions/checkout as a workaround
@@ -212,7 +244,8 @@ private class CheckoutSource extends RemoteFlowSource, FileSource {
212244 this .asExpr ( ) = uses and
213245 uses .getCallee ( ) = "actions/checkout" and
214246 exists ( uses .getArgument ( "ref" ) ) and
215- not uses .getArgument ( "ref" ) .matches ( "%base%" )
247+ not uses .getArgument ( "ref" ) .matches ( "%base%" ) and
248+ uses .getATriggerEvent ( ) .getName ( ) = checkoutTriggers ( )
216249 )
217250 or
218251 this .asExpr ( ) instanceof GitMutableRefCheckout
@@ -295,3 +328,24 @@ class Xt0rtedSlashCommandSource extends RemoteFlowSource {
295328
296329 override string getSourceType ( ) { result = "text" }
297330}
331+
332+ class OctokitRequestActionSource extends RemoteFlowSource {
333+ OctokitRequestActionSource ( ) {
334+ exists ( UsesStep u , string route |
335+ u .getCallee ( ) = "octokit/request-action" and
336+ route = u .getArgument ( "route" ) .trim ( ) and
337+ route .indexOf ( "GET" ) = 0 and
338+ (
339+ route .matches ( "%/commits%" ) or
340+ route .matches ( "%/comments%" ) or
341+ route .matches ( "%/pulls%" ) or
342+ route .matches ( "%/issues%" ) or
343+ route .matches ( "%/users%" ) or
344+ route .matches ( "%github.event.issue.pull_request.url%" )
345+ ) and
346+ this .asExpr ( ) = u
347+ )
348+ }
349+
350+ override string getSourceType ( ) { result = "text" }
351+ }
0 commit comments