@@ -1540,25 +1540,27 @@ string getAJsonReferenceAccessPath(string s, int offset) {
1540
1540
* A ${{}} expression accessing a sigcle context variable such as steps, needs, jobs, env, inputs, or matrix.
1541
1541
* https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability
1542
1542
*/
1543
- abstract class SimpleReferenceExpressionImpl extends ExpressionImpl {
1544
- string expression ;
1545
-
1543
+ class SimpleReferenceExpressionImpl extends ExpressionImpl {
1546
1544
SimpleReferenceExpressionImpl ( ) {
1545
+ exists ( getASimpleReferenceExpression ( this .getFullExpression ( ) , _) )
1546
+ or
1547
+ exists ( getAJsonReferenceExpression ( this .getFullExpression ( ) , _) )
1548
+ }
1549
+
1550
+ override string getExpression ( ) {
1547
1551
(
1548
- expression = getASimpleReferenceExpression ( this .getFullExpression ( ) , _)
1552
+ result = getASimpleReferenceExpression ( this .getFullExpression ( ) , _)
1549
1553
or
1550
1554
exists ( getAJsonReferenceExpression ( this .getFullExpression ( ) , _) ) and
1551
- expression = this .getFullExpression ( )
1555
+ result = this .getFullExpression ( )
1552
1556
)
1553
1557
}
1554
1558
1555
- override string getExpression ( ) { result = expression }
1556
-
1557
1559
abstract string getFieldName ( ) ;
1558
1560
1559
1561
abstract AstNodeImpl getTarget ( ) ;
1560
1562
1561
- override string toString ( ) { result = expression }
1563
+ override string toString ( ) { result = this . getFullExpression ( ) }
1562
1564
}
1563
1565
1564
1566
class JsonReferenceExpressionImpl extends ExpressionImpl {
@@ -1597,6 +1599,44 @@ private string inputsCtxRegex() {
1597
1599
1598
1600
private string secretsCtxRegex ( ) { result = wrapRegexp ( "secrets\\.([A-Za-z0-9_-]+)" ) }
1599
1601
1602
+ private string githubCtxRegex ( ) {
1603
+ result = wrapRegexp ( "github\\.([A-Za-z0-9'\"_\\[\\]\\*\\(\\)\\.\\-]+)" )
1604
+ }
1605
+
1606
+ /**
1607
+ * Holds for an expression accesing the `github` context.
1608
+ * e.g. `${{ github.head_ref }}`
1609
+ */
1610
+ class GitHubExpressionImpl extends SimpleReferenceExpressionImpl {
1611
+ GitHubExpressionImpl ( ) {
1612
+ exists ( string expr |
1613
+ (
1614
+ exists ( getAJsonReferenceExpression ( this .getExpression ( ) , _) ) and
1615
+ expr = normalizeExpr ( this .getExpression ( ) ) .regexpCapture ( "(?i)fromjson\\((.*)\\).*" , 1 )
1616
+ or
1617
+ exists ( getASimpleReferenceExpression ( this .getExpression ( ) , _) ) and
1618
+ expr = normalizeExpr ( this .getExpression ( ) )
1619
+ ) and
1620
+ expr .regexpMatch ( githubCtxRegex ( ) )
1621
+ )
1622
+ }
1623
+
1624
+ override string getFieldName ( ) {
1625
+ exists ( string expr |
1626
+ (
1627
+ exists ( getAJsonReferenceExpression ( this .getExpression ( ) , _) ) and
1628
+ expr = normalizeExpr ( this .getExpression ( ) ) .regexpCapture ( "(?i)fromjson\\((.*)\\).*" , 1 )
1629
+ or
1630
+ exists ( getASimpleReferenceExpression ( this .getExpression ( ) , _) ) and
1631
+ expr = normalizeExpr ( this .getExpression ( ) )
1632
+ ) and
1633
+ result = expr .regexpCapture ( githubCtxRegex ( ) , 1 )
1634
+ )
1635
+ }
1636
+
1637
+ override AstNodeImpl getTarget ( ) { none ( ) }
1638
+ }
1639
+
1600
1640
/**
1601
1641
* Holds for an expression accesing the `secrets` context.
1602
1642
* e.g. `${{ secrets.FOO }}`
@@ -1607,11 +1647,11 @@ class SecretsExpressionImpl extends SimpleReferenceExpressionImpl {
1607
1647
SecretsExpressionImpl ( ) {
1608
1648
exists ( string expr |
1609
1649
(
1610
- exists ( getAJsonReferenceExpression ( expression , _) ) and
1611
- expr = normalizeExpr ( expression ) .regexpCapture ( "(?i)fromjson\\((.*)\\).*" , 1 )
1650
+ exists ( getAJsonReferenceExpression ( this . getExpression ( ) , _) ) and
1651
+ expr = normalizeExpr ( this . getExpression ( ) ) .regexpCapture ( "(?i)fromjson\\((.*)\\).*" , 1 )
1612
1652
or
1613
- exists ( getASimpleReferenceExpression ( expression , _) ) and
1614
- expr = normalizeExpr ( expression )
1653
+ exists ( getASimpleReferenceExpression ( this . getExpression ( ) , _) ) and
1654
+ expr = normalizeExpr ( this . getExpression ( ) )
1615
1655
) and
1616
1656
expr .regexpMatch ( secretsCtxRegex ( ) ) and
1617
1657
fieldName = expr .regexpCapture ( secretsCtxRegex ( ) , 1 )
@@ -1635,11 +1675,11 @@ class StepsExpressionImpl extends SimpleReferenceExpressionImpl {
1635
1675
StepsExpressionImpl ( ) {
1636
1676
exists ( string expr |
1637
1677
(
1638
- exists ( getAJsonReferenceExpression ( expression , _) ) and
1639
- expr = normalizeExpr ( expression ) .regexpCapture ( "(?i)(from|to)json\\((.*)\\).*" , 2 )
1678
+ exists ( getAJsonReferenceExpression ( this . getExpression ( ) , _) ) and
1679
+ expr = normalizeExpr ( this . getExpression ( ) ) .regexpCapture ( "(?i)(from|to)json\\((.*)\\).*" , 2 )
1640
1680
or
1641
- exists ( getASimpleReferenceExpression ( expression , _) ) and
1642
- expr = normalizeExpr ( expression )
1681
+ exists ( getASimpleReferenceExpression ( this . getExpression ( ) , _) ) and
1682
+ expr = normalizeExpr ( this . getExpression ( ) )
1643
1683
) and
1644
1684
expr .regexpMatch ( stepsCtxRegex ( ) ) and
1645
1685
stepId = expr .regexpCapture ( stepsCtxRegex ( ) , 1 ) and
@@ -1676,11 +1716,11 @@ class NeedsExpressionImpl extends SimpleReferenceExpressionImpl {
1676
1716
NeedsExpressionImpl ( ) {
1677
1717
exists ( string expr |
1678
1718
(
1679
- exists ( getAJsonReferenceExpression ( expression , _) ) and
1680
- expr = normalizeExpr ( expression ) .regexpCapture ( "(?i)(from|to)json\\((.*)\\).*" , 2 )
1719
+ exists ( getAJsonReferenceExpression ( this . getExpression ( ) , _) ) and
1720
+ expr = normalizeExpr ( this . getExpression ( ) ) .regexpCapture ( "(?i)(from|to)json\\((.*)\\).*" , 2 )
1681
1721
or
1682
- exists ( getASimpleReferenceExpression ( expression , _) ) and
1683
- expr = normalizeExpr ( expression )
1722
+ exists ( getASimpleReferenceExpression ( this . getExpression ( ) , _) ) and
1723
+ expr = normalizeExpr ( this . getExpression ( ) )
1684
1724
) and
1685
1725
expr .regexpMatch ( needsCtxRegex ( ) ) and
1686
1726
fieldName = expr .regexpCapture ( needsCtxRegex ( ) , 2 ) and
@@ -1720,11 +1760,11 @@ class JobsExpressionImpl extends SimpleReferenceExpressionImpl {
1720
1760
JobsExpressionImpl ( ) {
1721
1761
exists ( string expr |
1722
1762
(
1723
- exists ( getAJsonReferenceExpression ( expression , _) ) and
1724
- expr = normalizeExpr ( expression ) .regexpCapture ( "(?i)(from|to)json\\((.*)\\).*" , 2 )
1763
+ exists ( getAJsonReferenceExpression ( this . getExpression ( ) , _) ) and
1764
+ expr = normalizeExpr ( this . getExpression ( ) ) .regexpCapture ( "(?i)(from|to)json\\((.*)\\).*" , 2 )
1725
1765
or
1726
- exists ( getASimpleReferenceExpression ( expression , _) ) and
1727
- expr = normalizeExpr ( expression )
1766
+ exists ( getASimpleReferenceExpression ( this . getExpression ( ) , _) ) and
1767
+ expr = normalizeExpr ( this . getExpression ( ) )
1728
1768
) and
1729
1769
expr .regexpMatch ( jobsCtxRegex ( ) ) and
1730
1770
jobId = expr .regexpCapture ( jobsCtxRegex ( ) , 1 ) and
@@ -1752,8 +1792,8 @@ class InputsExpressionImpl extends SimpleReferenceExpressionImpl {
1752
1792
string fieldName ;
1753
1793
1754
1794
InputsExpressionImpl ( ) {
1755
- normalizeExpr ( expression ) .regexpMatch ( inputsCtxRegex ( ) ) and
1756
- fieldName = normalizeExpr ( expression ) .regexpCapture ( inputsCtxRegex ( ) , 1 )
1795
+ normalizeExpr ( this . getExpression ( ) ) .regexpMatch ( inputsCtxRegex ( ) ) and
1796
+ fieldName = normalizeExpr ( this . getExpression ( ) ) .regexpCapture ( inputsCtxRegex ( ) , 1 )
1757
1797
}
1758
1798
1759
1799
override string getFieldName ( ) { result = fieldName }
@@ -1779,11 +1819,11 @@ class EnvExpressionImpl extends SimpleReferenceExpressionImpl {
1779
1819
EnvExpressionImpl ( ) {
1780
1820
exists ( string expr |
1781
1821
(
1782
- exists ( getAJsonReferenceExpression ( expression , _) ) and
1783
- expr = normalizeExpr ( expression ) .regexpCapture ( "(?i)(from|to)json\\((.*)\\).*" , 2 )
1822
+ exists ( getAJsonReferenceExpression ( this . getExpression ( ) , _) ) and
1823
+ expr = normalizeExpr ( this . getExpression ( ) ) .regexpCapture ( "(?i)(from|to)json\\((.*)\\).*" , 2 )
1784
1824
or
1785
- exists ( getASimpleReferenceExpression ( expression , _) ) and
1786
- expr = normalizeExpr ( expression )
1825
+ exists ( getASimpleReferenceExpression ( this . getExpression ( ) , _) ) and
1826
+ expr = normalizeExpr ( this . getExpression ( ) )
1787
1827
) and
1788
1828
expr .regexpMatch ( envCtxRegex ( ) ) and
1789
1829
fieldName = expr .regexpCapture ( envCtxRegex ( ) , 1 )
@@ -1814,11 +1854,11 @@ class MatrixExpressionImpl extends SimpleReferenceExpressionImpl {
1814
1854
MatrixExpressionImpl ( ) {
1815
1855
exists ( string expr |
1816
1856
(
1817
- exists ( getAJsonReferenceExpression ( expression , _) ) and
1818
- expr = normalizeExpr ( expression ) .regexpCapture ( "(?i)(from|to)json\\((.*)\\).*" , 2 )
1857
+ exists ( getAJsonReferenceExpression ( this . getExpression ( ) , _) ) and
1858
+ expr = normalizeExpr ( this . getExpression ( ) ) .regexpCapture ( "(?i)(from|to)json\\((.*)\\).*" , 2 )
1819
1859
or
1820
- exists ( getASimpleReferenceExpression ( expression , _) ) and
1821
- expr = normalizeExpr ( expression )
1860
+ exists ( getASimpleReferenceExpression ( this . getExpression ( ) , _) ) and
1861
+ expr = normalizeExpr ( this . getExpression ( ) )
1822
1862
) and
1823
1863
expr .regexpMatch ( matrixCtxRegex ( ) ) and
1824
1864
fieldAccess = expr .regexpCapture ( matrixCtxRegex ( ) , 1 )
0 commit comments