@@ -142,23 +142,45 @@ predicate isScriptInjectable(Actions::GitHubScript script, string injection, str
142
142
)
143
143
}
144
144
145
+ /**
146
+ * Holds if the composite action contains untrusted expression interpolation `${{ e }}`.
147
+ */
148
+ YamlNode getInjectableCompositeActionNode ( Actions:: Runs runs , string injection , string context ) {
149
+ exists ( Actions:: Run run |
150
+ isRunInjectable ( run , injection , context ) and
151
+ result = run and
152
+ run .getStep ( ) .getRuns ( ) = runs
153
+ )
154
+ or
155
+ exists ( Actions:: GitHubScript script |
156
+ isScriptInjectable ( script , injection , context ) and
157
+ result = script and
158
+ script .getWith ( ) .getStep ( ) .getRuns ( ) = runs
159
+ )
160
+ }
161
+
162
+ /**
163
+ * Holds if the workflow contains untrusted expression interpolation `${{ e }}`.
164
+ */
165
+ YamlNode getInjectableWorkflowNode ( Actions:: On on , string injection , string context ) {
166
+ exists ( Actions:: Run run |
167
+ isRunInjectable ( run , injection , context ) and
168
+ result = run and
169
+ run .getStep ( ) .getJob ( ) .getWorkflow ( ) .getOn ( ) = on
170
+ )
171
+ or
172
+ exists ( Actions:: GitHubScript script |
173
+ isScriptInjectable ( script , injection , context ) and
174
+ result = script and
175
+ script .getWith ( ) .getStep ( ) .getJob ( ) .getWorkflow ( ) .getOn ( ) = on
176
+ )
177
+ }
178
+
145
179
from YamlNode node , string injection , string context
146
180
where
147
181
exists ( Actions:: CompositeAction action , Actions:: Runs runs |
148
182
action .getRuns ( ) = runs and
149
- (
150
- exists ( Actions:: Run run |
151
- isRunInjectable ( run , injection , context ) and
152
- node = run and
153
- run .getStep ( ) .getRuns ( ) = runs
154
- )
155
- or
156
- exists ( Actions:: GitHubScript script |
157
- node = script and
158
- script .getWith ( ) .getStep ( ) .getRuns ( ) = runs and
159
- isScriptInjectable ( script , injection , context )
160
- )
161
- ) and
183
+ node = getInjectableCompositeActionNode ( runs , injection , context ) and
162
184
(
163
185
isExternalUserControlledIssue ( context ) or
164
186
isExternalUserControlledPullRequest ( context ) or
@@ -172,19 +194,7 @@ where
172
194
)
173
195
or
174
196
exists ( Actions:: On on |
175
- (
176
- exists ( Actions:: Run run |
177
- isRunInjectable ( run , injection , context ) and
178
- node = run and
179
- run .getStep ( ) .getJob ( ) .getWorkflow ( ) .getOn ( ) = on
180
- )
181
- or
182
- exists ( Actions:: GitHubScript script |
183
- node = script and
184
- script .getWith ( ) .getStep ( ) .getJob ( ) .getWorkflow ( ) .getOn ( ) = on and
185
- isScriptInjectable ( script , injection , context )
186
- )
187
- ) and
197
+ node = getInjectableWorkflowNode ( on , injection , context ) and
188
198
(
189
199
exists ( on .getNode ( "issues" ) ) and
190
200
isExternalUserControlledIssue ( context )
0 commit comments