@@ -153,17 +153,18 @@ class ExpressionImpl extends AstNodeImpl, TExpressionNode {
153
153
YamlNode key ;
154
154
YamlString value ;
155
155
string rawExpression ;
156
- string expression ;
156
+ string fullExpression ;
157
157
int exprOffset ;
158
158
159
159
ExpressionImpl ( ) {
160
160
this = TExpressionNode ( key , value , rawExpression , exprOffset - 1 ) and
161
161
if rawExpression .trim ( ) .regexpMatch ( "\\$\\{\\{.*\\}\\}" )
162
- then expression = rawExpression .trim ( ) .regexpCapture ( "\\$\\{\\{\\s*(.*)\\s*\\}\\}" , 1 ) .trim ( )
163
- else expression = rawExpression .trim ( )
162
+ then
163
+ fullExpression = rawExpression .trim ( ) .regexpCapture ( "\\$\\{\\{\\s*(.*)\\s*\\}\\}" , 1 ) .trim ( )
164
+ else fullExpression = rawExpression .trim ( )
164
165
}
165
166
166
- override string toString ( ) { result = expression }
167
+ override string toString ( ) { result = fullExpression }
167
168
168
169
override AstNodeImpl getAChildNode ( ) { none ( ) }
169
170
@@ -173,7 +174,9 @@ class ExpressionImpl extends AstNodeImpl, TExpressionNode {
173
174
174
175
override YamlNode getNode ( ) { none ( ) }
175
176
176
- string getExpression ( ) { result = expression }
177
+ string getExpression ( ) { result = fullExpression }
178
+
179
+ string getFullExpression ( ) { result = fullExpression }
177
180
178
181
string getRawExpression ( ) { result = rawExpression }
179
182
@@ -1262,12 +1265,15 @@ class RunImpl extends StepImpl {
1262
1265
*/
1263
1266
bindingset [ s]
1264
1267
string getASimpleReferenceExpression ( string s , int offset ) {
1268
+ // If the expression is ${{ inputs.foo == "foo" }} we should not consider it as a simple reference
1269
+ // check that expression matches a simple reference or several simple references ORed with ||
1270
+ s .regexpMatch ( "([A-Za-z0-9'\\\"_\\[\\]\\*\\(\\)\\.\\-]+)(\\s*\\|\\|\\s*[A-Za-z0-9'\\\"_\\[\\]\\*\\(\\)\\.\\-]+)*" ) and
1265
1271
// We use `regexpFind` to obtain *all* matches of `${{...}}`,
1266
1272
// not just the last (greedy match) or first (reluctant match).
1267
1273
result =
1268
1274
s .trim ( )
1269
1275
.regexpFind ( "[A-Za-z0-9'\"_\\[\\]\\*\\(\\)\\.\\-]+" , _, offset )
1270
- .regexpCapture ( "([A-Za-z0-9'\"_\\[\\]\\*\\(\\)\\.\\-]+)" , 1 )
1276
+ .regexpCapture ( "([A-Za-z0-9'\"_\\[\\]\\*\\(\\)\\.\\-]+)" , _ )
1271
1277
}
1272
1278
1273
1279
bindingset [ s]
@@ -1319,27 +1325,37 @@ string getAJsonReferenceAccessPath(string s, int offset) {
1319
1325
}
1320
1326
1321
1327
/**
1322
- * A ${{}} expression accessing a context variable such as steps, needs, jobs, env, inputs, or matrix.
1328
+ * A ${{}} expression accessing a sigcle context variable such as steps, needs, jobs, env, inputs, or matrix.
1323
1329
* https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability
1324
1330
*/
1325
1331
abstract class SimpleReferenceExpressionImpl extends ExpressionImpl {
1332
+ string expression ;
1333
+
1326
1334
SimpleReferenceExpressionImpl ( ) {
1327
- exists ( getASimpleReferenceExpression ( expression , _) ) or
1328
- exists ( getAJsonReferenceExpression ( expression , _) )
1335
+ (
1336
+ expression = getASimpleReferenceExpression ( this .getFullExpression ( ) , _)
1337
+ or
1338
+ exists ( getAJsonReferenceExpression ( this .getFullExpression ( ) , _) ) and
1339
+ expression = this .getFullExpression ( )
1340
+ )
1329
1341
}
1330
1342
1343
+ override string getExpression ( ) { result = expression }
1344
+
1331
1345
abstract string getFieldName ( ) ;
1332
1346
1333
1347
abstract AstNodeImpl getTarget ( ) ;
1348
+
1349
+ override string toString ( ) { result = expression }
1334
1350
}
1335
1351
1336
1352
class JsonReferenceExpressionImpl extends ExpressionImpl {
1337
1353
string innerExpression ;
1338
1354
string accessPath ;
1339
1355
1340
1356
JsonReferenceExpressionImpl ( ) {
1341
- innerExpression = getAJsonReferenceExpression ( expression , _) and
1342
- accessPath = getAJsonReferenceAccessPath ( expression , _)
1357
+ innerExpression = getAJsonReferenceExpression ( this . getExpression ( ) , _) and
1358
+ accessPath = getAJsonReferenceAccessPath ( this . getExpression ( ) , _)
1343
1359
}
1344
1360
1345
1361
string getInnerExpression ( ) { result = innerExpression }
0 commit comments