11
11
12
12
import java
13
13
import ThreadResourceAbuse
14
+ import semmle.code.java.dataflow.TaintTracking
14
15
import semmle.code.java.dataflow.FlowSources
15
- import DataFlow :: PathGraph
16
+ import ThreadResourceAbuseFlow :: PathGraph
16
17
17
18
/** The `getInitParameter` method of servlet or JSF. */
18
19
class GetInitParameter extends Method {
@@ -41,18 +42,16 @@ class InitParameterInput extends LocalUserInput {
41
42
}
42
43
43
44
/** Taint configuration of uncontrolled thread resource consumption from local user input. */
44
- class ThreadResourceAbuse extends TaintTracking :: Configuration {
45
- ThreadResourceAbuse ( ) { this = "ThreadResourceAbuse" }
45
+ module ThreadResourceAbuseConfig implements DataFlow :: ConfigSig {
46
+ predicate isSource ( DataFlow :: Node source ) { source instanceof LocalUserInput }
46
47
47
- override predicate isSource ( DataFlow:: Node source ) { source instanceof LocalUserInput }
48
+ predicate isSink ( DataFlow:: Node sink ) { sink instanceof PauseThreadSink }
48
49
49
- override predicate isSink ( DataFlow:: Node sink ) { sink instanceof PauseThreadSink }
50
-
51
- override predicate isAdditionalTaintStep ( DataFlow:: Node pred , DataFlow:: Node succ ) {
50
+ predicate isAdditionalFlowStep ( DataFlow:: Node pred , DataFlow:: Node succ ) {
52
51
any ( AdditionalValueStep r ) .step ( pred , succ )
53
52
}
54
53
55
- override predicate isSanitizer ( DataFlow:: Node node ) {
54
+ predicate isBarrier ( DataFlow:: Node node ) {
56
55
exists (
57
56
MethodAccess ma // Math.min(sleepTime, MAX_INTERVAL)
58
57
|
@@ -64,7 +63,9 @@ class ThreadResourceAbuse extends TaintTracking::Configuration {
64
63
}
65
64
}
66
65
67
- from DataFlow:: PathNode source , DataFlow:: PathNode sink , ThreadResourceAbuse conf
68
- where conf .hasFlowPath ( source , sink )
66
+ module ThreadResourceAbuseFlow = TaintTracking:: Global< ThreadResourceAbuseConfig > ;
67
+
68
+ from ThreadResourceAbuseFlow:: PathNode source , ThreadResourceAbuseFlow:: PathNode sink
69
+ where ThreadResourceAbuseFlow:: flowPath ( source , sink )
69
70
select sink .getNode ( ) , source , sink , "Possible uncontrolled resource consumption due to $@." ,
70
71
source .getNode ( ) , "local user-provided value"
0 commit comments