1414import java
1515import semmle.code.java.dataflow.FlowSources
1616import XQueryInjectionLib
17- import DataFlow :: PathGraph
17+ import XQueryInjectionFlow :: PathGraph
1818
1919/**
2020 * A taint-tracking configuration tracing flow from remote sources, through an XQuery parser, to its eventual execution.
2121 */
22- class XQueryInjectionConfig extends TaintTracking :: Configuration {
23- XQueryInjectionConfig ( ) { this = "XQueryInjectionConfig" }
22+ module XQueryInjectionConfig implements DataFlow :: ConfigSig {
23+ predicate isSource ( DataFlow :: Node source ) { source instanceof RemoteFlowSource }
2424
25- override predicate isSource ( DataFlow:: Node source ) { source instanceof RemoteFlowSource }
26-
27- override predicate isSink ( DataFlow:: Node sink ) {
25+ predicate isSink ( DataFlow:: Node sink ) {
2826 sink .asExpr ( ) = any ( XQueryPreparedExecuteCall xpec ) .getPreparedExpression ( ) or
2927 sink .asExpr ( ) = any ( XQueryExecuteCall xec ) .getExecuteQueryArgument ( ) or
3028 sink .asExpr ( ) = any ( XQueryExecuteCommandCall xecc ) .getExecuteCommandArgument ( )
@@ -33,12 +31,17 @@ class XQueryInjectionConfig extends TaintTracking::Configuration {
3331 /**
3432 * Holds if taint from the input `pred` to a `prepareExpression` call flows to the returned prepared expression `succ`.
3533 */
36- override predicate isAdditionalTaintStep ( DataFlow:: Node pred , DataFlow:: Node succ ) {
34+ predicate isAdditionalFlowStep ( DataFlow:: Node pred , DataFlow:: Node succ ) {
3735 exists ( XQueryParserCall parser | pred .asExpr ( ) = parser .getInput ( ) and succ .asExpr ( ) = parser )
3836 }
3937}
4038
41- from DataFlow:: PathNode source , DataFlow:: PathNode sink , XQueryInjectionConfig conf
42- where conf .hasFlowPath ( source , sink )
39+ /**
40+ * Taint-tracking flow from remote sources, through an XQuery parser, to its eventual execution.
41+ */
42+ module XQueryInjectionFlow = TaintTracking:: Global< XQueryInjectionConfig > ;
43+
44+ from XQueryInjectionFlow:: PathNode source , XQueryInjectionFlow:: PathNode sink
45+ where XQueryInjectionFlow:: flowPath ( source , sink )
4346select sink .getNode ( ) , source , sink , "XQuery query might include code from $@." , source .getNode ( ) ,
4447 "this user input"
0 commit comments