@@ -39,11 +39,13 @@ private class DefaultJexlInjectionAdditionalTaintStep extends JexlInjectionAddit
39
39
}
40
40
41
41
/**
42
+ * DEPRECATED: Use `JexlInjectionFlow` instead.
43
+ *
42
44
* A taint-tracking configuration for unsafe user input
43
45
* that is used to construct and evaluate a JEXL expression.
44
46
* It supports both JEXL 2 and 3.
45
47
*/
46
- class JexlInjectionConfig extends TaintTracking:: Configuration {
48
+ deprecated class JexlInjectionConfig extends TaintTracking:: Configuration {
47
49
JexlInjectionConfig ( ) { this = "JexlInjectionConfig" }
48
50
49
51
override predicate isSource ( DataFlow:: Node source ) { source instanceof RemoteFlowSource }
@@ -55,6 +57,27 @@ class JexlInjectionConfig extends TaintTracking::Configuration {
55
57
}
56
58
}
57
59
60
+ /**
61
+ * A taint-tracking configuration for unsafe user input
62
+ * that is used to construct and evaluate a JEXL expression.
63
+ * It supports both JEXL 2 and 3.
64
+ */
65
+ private module JexlInjectionConfig implements DataFlow:: ConfigSig {
66
+ predicate isSource ( DataFlow:: Node source ) { source instanceof RemoteFlowSource }
67
+
68
+ predicate isSink ( DataFlow:: Node sink ) { sink instanceof JexlEvaluationSink }
69
+
70
+ predicate isAdditionalFlowStep ( DataFlow:: Node node1 , DataFlow:: Node node2 ) {
71
+ any ( JexlInjectionAdditionalTaintStep c ) .step ( node1 , node2 )
72
+ }
73
+ }
74
+
75
+ /**
76
+ * Tracks unsafe user input that is used to construct and evaluate a JEXL expression.
77
+ * It supports both JEXL 2 and 3.
78
+ */
79
+ module JexlInjectionFlow = TaintTracking:: Make< JexlInjectionConfig > ;
80
+
58
81
/**
59
82
* Holds if `n1` to `n2` is a dataflow step that creates a JEXL script using an unsafe engine
60
83
* by calling `tainted.createScript(jexlExpr)`.
@@ -99,19 +122,15 @@ private predicate createJexlTemplateStep(DataFlow::Node n1, DataFlow::Node n2) {
99
122
/**
100
123
* Holds if `expr` is a JEXL engine that is configured with a sandbox.
101
124
*/
102
- private predicate isSafeEngine ( Expr expr ) {
103
- exists ( SandboxedJexlFlowConfig config | config .hasFlowTo ( DataFlow:: exprNode ( expr ) ) )
104
- }
125
+ private predicate isSafeEngine ( Expr expr ) { SandboxedJexlFlow:: hasFlowToExpr ( expr ) }
105
126
106
127
/**
107
128
* A configuration for tracking sandboxed JEXL engines.
108
129
*/
109
- private class SandboxedJexlFlowConfig extends DataFlow2 :: Configuration {
110
- SandboxedJexlFlowConfig ( ) { this = "JexlInjection::SandboxedJexlFlowConfig" }
130
+ private module SandboxedJexlFlowConfig implements DataFlow :: ConfigSig {
131
+ predicate isSource ( DataFlow :: Node node ) { node instanceof SandboxedJexlSource }
111
132
112
- override predicate isSource ( DataFlow:: Node node ) { node instanceof SandboxedJexlSource }
113
-
114
- override predicate isSink ( DataFlow:: Node node ) {
133
+ predicate isSink ( DataFlow:: Node node ) {
115
134
exists ( MethodAccess ma , Method m |
116
135
m instanceof CreateJexlScriptMethod or
117
136
m instanceof CreateJexlExpressionMethod or
@@ -121,11 +140,13 @@ private class SandboxedJexlFlowConfig extends DataFlow2::Configuration {
121
140
)
122
141
}
123
142
124
- override predicate isAdditionalFlowStep ( DataFlow:: Node fromNode , DataFlow:: Node toNode ) {
143
+ predicate isAdditionalFlowStep ( DataFlow:: Node fromNode , DataFlow:: Node toNode ) {
125
144
createJexlEngineStep ( fromNode , toNode )
126
145
}
127
146
}
128
147
148
+ private module SandboxedJexlFlow = DataFlow:: Make< SandboxedJexlFlowConfig > ;
149
+
129
150
/**
130
151
* Defines a data flow source for JEXL engines configured with a sandbox.
131
152
*/
0 commit comments