@@ -18,32 +18,33 @@ import semmle.code.java.dataflow.FlowSources
18
18
private import semmle.code.java.dataflow.ExternalFlow
19
19
import semmle.code.java.security.PathCreation
20
20
import semmle.code.java.security.PathSanitizer
21
- import DataFlow:: PathGraph
22
21
import TaintedPathCommon
23
22
24
- class TaintedPathConfig extends TaintTracking :: Configuration {
25
- TaintedPathConfig ( ) { this = "TaintedPathConfig" }
23
+ module TaintedPathConfig implements DataFlow :: ConfigSig {
24
+ predicate isSource ( DataFlow :: Node source ) { source instanceof RemoteFlowSource }
26
25
27
- override predicate isSource ( DataFlow:: Node source ) { source instanceof RemoteFlowSource }
28
-
29
- override predicate isSink ( DataFlow:: Node sink ) {
26
+ predicate isSink ( DataFlow:: Node sink ) {
30
27
sink .asExpr ( ) = any ( PathCreation p ) .getAnInput ( )
31
28
or
32
29
sinkNode ( sink , [ "create-file" , "read-file" ] )
33
30
}
34
31
35
- override predicate isSanitizer ( DataFlow:: Node sanitizer ) {
32
+ predicate isBarrier ( DataFlow:: Node sanitizer ) {
36
33
sanitizer .getType ( ) instanceof BoxedType or
37
34
sanitizer .getType ( ) instanceof PrimitiveType or
38
35
sanitizer .getType ( ) instanceof NumberType or
39
36
sanitizer instanceof PathInjectionSanitizer
40
37
}
41
38
42
- override predicate isAdditionalTaintStep ( DataFlow:: Node n1 , DataFlow:: Node n2 ) {
39
+ predicate isAdditionalFlowStep ( DataFlow:: Node n1 , DataFlow:: Node n2 ) {
43
40
any ( TaintedPathAdditionalTaintStep s ) .step ( n1 , n2 )
44
41
}
45
42
}
46
43
44
+ module TaintedPath = TaintTracking:: Make< TaintedPathConfig > ;
45
+
46
+ import TaintedPath:: PathGraph
47
+
47
48
/**
48
49
* Gets the data-flow node at which to report a path ending at `sink`.
49
50
*
@@ -52,13 +53,13 @@ class TaintedPathConfig extends TaintTracking::Configuration {
52
53
* continue to report there; otherwise we report directly at `sink`.
53
54
*/
54
55
DataFlow:: Node getReportingNode ( DataFlow:: Node sink ) {
55
- any ( TaintedPathConfig c ) . hasFlowTo ( sink ) and
56
+ TaintedPath :: hasFlowTo ( sink ) and
56
57
if exists ( PathCreation pc | pc .getAnInput ( ) = sink .asExpr ( ) )
57
58
then result .asExpr ( ) = any ( PathCreation pc | pc .getAnInput ( ) = sink .asExpr ( ) )
58
59
else result = sink
59
60
}
60
61
61
- from DataFlow :: PathNode source , DataFlow :: PathNode sink , TaintedPathConfig conf
62
- where conf . hasFlowPath ( source , sink )
62
+ from TaintedPath :: PathNode source , TaintedPath :: PathNode sink
63
+ where TaintedPath :: hasFlowPath ( source , sink )
63
64
select getReportingNode ( sink .getNode ( ) ) , source , sink , "This path depends on a $@." ,
64
65
source .getNode ( ) , "user-provided value"
0 commit comments