@@ -15,7 +15,6 @@ import java
1515import semmle.code.java.security.Encryption
1616import semmle.code.java.dataflow.TaintTracking
1717import DataFlow
18- import PathGraph
1918
2019private class ShortStringLiteral extends StringLiteral {
2120 ShortStringLiteral ( ) { getValue ( ) .length ( ) < 100 }
@@ -29,24 +28,26 @@ class BrokenAlgoLiteral extends ShortStringLiteral {
2928 }
3029}
3130
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 }
3433
35- override predicate isSource ( Node n ) { n .asExpr ( ) instanceof BrokenAlgoLiteral }
34+ predicate isSink ( Node n ) { exists ( CryptoAlgoSpec c | n .asExpr ( ) = c . getAlgoSpec ( ) ) }
3635
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 ) {
4037 node .getType ( ) instanceof PrimitiveType or node .getType ( ) instanceof BoxedType
4138 }
4239}
4340
41+ module InsecureCryptoFlow = TaintTracking:: Make< InsecureCryptoConfiguration > ;
42+
43+ import InsecureCryptoFlow:: PathGraph
44+
4445from
45- PathNode source , PathNode sink , CryptoAlgoSpec c , BrokenAlgoLiteral s ,
46- InsecureCryptoConfiguration conf
46+ InsecureCryptoFlow :: PathNode source , InsecureCryptoFlow :: PathNode sink , CryptoAlgoSpec c ,
47+ BrokenAlgoLiteral s
4748where
4849 sink .getNode ( ) .asExpr ( ) = c .getAlgoSpec ( ) and
4950 source .getNode ( ) .asExpr ( ) = s and
50- conf . hasFlowPath ( source , sink )
51+ InsecureCryptoFlow :: hasFlowPath ( source , sink )
5152select c , source , sink , "Cryptographic algorithm $@ is weak and should not be used." , s ,
5253 s .getValue ( )
0 commit comments