@@ -15,7 +15,6 @@ import java
15
15
import semmle.code.java.security.Encryption
16
16
import semmle.code.java.dataflow.TaintTracking
17
17
import DataFlow
18
- import PathGraph
19
18
20
19
private class ShortStringLiteral extends StringLiteral {
21
20
ShortStringLiteral ( ) { getValue ( ) .length ( ) < 100 }
@@ -29,24 +28,26 @@ class BrokenAlgoLiteral extends ShortStringLiteral {
29
28
}
30
29
}
31
30
32
- class InsecureCryptoConfiguration extends TaintTracking :: Configuration {
33
- InsecureCryptoConfiguration ( ) { this = "BrokenCryptoAlgortihm::InsecureCryptoConfiguration" }
31
+ module InsecureCryptoConfiguration implements ConfigSig {
32
+ predicate isSource ( Node n ) { n . asExpr ( ) instanceof BrokenAlgoLiteral }
34
33
35
- override predicate isSource ( Node n ) { n .asExpr ( ) instanceof BrokenAlgoLiteral }
34
+ predicate isSink ( Node n ) { exists ( CryptoAlgoSpec c | n .asExpr ( ) = c . getAlgoSpec ( ) ) }
36
35
37
- override predicate isSink ( Node n ) { exists ( CryptoAlgoSpec c | n .asExpr ( ) = c .getAlgoSpec ( ) ) }
38
-
39
- override predicate isSanitizer ( DataFlow:: Node node ) {
36
+ predicate isBarrier ( DataFlow:: Node node ) {
40
37
node .getType ( ) instanceof PrimitiveType or node .getType ( ) instanceof BoxedType
41
38
}
42
39
}
43
40
41
+ module InsecureCryptoFlow = TaintTracking:: Make< InsecureCryptoConfiguration > ;
42
+
43
+ import InsecureCryptoFlow:: PathGraph
44
+
44
45
from
45
- PathNode source , PathNode sink , CryptoAlgoSpec c , BrokenAlgoLiteral s ,
46
- InsecureCryptoConfiguration conf
46
+ InsecureCryptoFlow :: PathNode source , InsecureCryptoFlow :: PathNode sink , CryptoAlgoSpec c ,
47
+ BrokenAlgoLiteral s
47
48
where
48
49
sink .getNode ( ) .asExpr ( ) = c .getAlgoSpec ( ) and
49
50
source .getNode ( ) .asExpr ( ) = s and
50
- conf . hasFlowPath ( source , sink )
51
+ InsecureCryptoFlow :: hasFlowPath ( source , sink )
51
52
select c , source , sink , "Cryptographic algorithm $@ is weak and should not be used." , s ,
52
53
s .getValue ( )
0 commit comments