2
2
3
3
import java
4
4
import semmle.code.java.dataflow.DefUse
5
- import semmle.code.java.dataflow.DataFlow6
5
+ import semmle.code.java.dataflow.DataFlow
6
6
import RandomDataSource
7
7
8
8
/**
@@ -29,20 +29,18 @@ private predicate isSeeded(RValue use) {
29
29
)
30
30
}
31
31
32
- private class PredictableSeedFlowConfiguration extends DataFlow6 :: Configuration {
33
- PredictableSeedFlowConfiguration ( ) { this = "Random::PredictableSeedFlowConfiguration" }
32
+ private module PredictableSeedFlowConfig implements DataFlow :: ConfigSig {
33
+ predicate isSource ( DataFlow :: Node source ) { source . asExpr ( ) instanceof PredictableSeedExpr }
34
34
35
- override predicate isSource ( DataFlow6:: Node source ) {
36
- source .asExpr ( ) instanceof PredictableSeedExpr
37
- }
38
-
39
- override predicate isSink ( DataFlow6:: Node sink ) { isSeeding ( sink .asExpr ( ) , _) }
35
+ predicate isSink ( DataFlow:: Node sink ) { isSeeding ( sink .asExpr ( ) , _) }
40
36
41
- override predicate isAdditionalFlowStep ( DataFlow6 :: Node node1 , DataFlow6 :: Node node2 ) {
37
+ predicate isAdditionalFlowStep ( DataFlow :: Node node1 , DataFlow :: Node node2 ) {
42
38
predictableCalcStep ( node1 .asExpr ( ) , node2 .asExpr ( ) )
43
39
}
44
40
}
45
41
42
+ private module PredictableSeedFlow = DataFlow:: Global< PredictableSeedFlowConfig > ;
43
+
46
44
private predicate predictableCalcStep ( Expr e1 , Expr e2 ) {
47
45
e2 .( BinaryExpr ) .hasOperands ( e1 , any ( PredictableSeedExpr p ) )
48
46
or
@@ -81,7 +79,7 @@ private predicate predictableCalcStep(Expr e1, Expr e2) {
81
79
private predicate safelySeeded ( RValue use ) {
82
80
exists ( Expr arg |
83
81
isSeeding ( arg , use ) and
84
- not exists ( PredictableSeedFlowConfiguration conf | conf . hasFlowToExpr ( arg ) )
82
+ not PredictableSeedFlow :: flowToExpr ( arg )
85
83
)
86
84
or
87
85
exists ( GetRandomData da , RValue seeduse |
@@ -118,9 +116,7 @@ private predicate isSeeding(Expr arg, RValue use) {
118
116
119
117
private predicate isSeedingSource ( Expr arg , RValue use , Expr source ) {
120
118
isSeeding ( arg , use ) and
121
- exists ( PredictableSeedFlowConfiguration conf |
122
- conf .hasFlow ( DataFlow6:: exprNode ( source ) , DataFlow6:: exprNode ( arg ) )
123
- )
119
+ PredictableSeedFlow:: flow ( DataFlow:: exprNode ( source ) , DataFlow:: exprNode ( arg ) )
124
120
}
125
121
126
122
private predicate isRandomSeeding ( MethodAccess m , Expr arg ) {
0 commit comments