1111 */
1212
1313import go
14- import DataFlow:: PathGraph
1514
16- /**
17- * A data flow tracking configuration for tracking flow from RSA key length to
18- * calls to RSA key generation functions.
19- */
20- class RsaKeyTrackingConfiguration extends DataFlow:: Configuration {
21- RsaKeyTrackingConfiguration ( ) { this = "RsaKeyTrackingConfiguration" }
22-
23- override predicate isSource ( DataFlow:: Node source ) { source .getIntValue ( ) < 2048 }
15+ module Config implements DataFlow:: ConfigSig {
16+ predicate isSource ( DataFlow:: Node source ) { source .getIntValue ( ) < 2048 }
2417
25- override predicate isSink ( DataFlow:: Node sink ) {
18+ predicate isSink ( DataFlow:: Node sink ) {
2619 exists ( DataFlow:: CallNode c |
2720 sink = c .getArgument ( 1 ) and
2821 c .getTarget ( ) .hasQualifiedName ( "crypto/rsa" , "GenerateKey" )
2922 )
3023 }
3124
32- override predicate isBarrier ( DataFlow:: Node node ) {
25+ predicate isBarrier ( DataFlow:: Node node ) {
3326 node = DataFlow:: BarrierGuard< comparisonBarrierGuard / 3 > :: getABarrierNode ( )
3427 }
3528}
3629
30+ module Flow = DataFlow:: Global< Config > ;
31+
32+ import Flow:: PathGraph
33+
3734/**
3835 * Holds if `g` is a comparison which guarantees that `e` is at least 2048 on `branch`,
3936 * considered as a barrier guard for key sizes.
@@ -50,6 +47,6 @@ predicate comparisonBarrierGuard(DataFlow::Node g, Expr e, boolean branch) {
5047 )
5148}
5249
53- from RsaKeyTrackingConfiguration cfg , DataFlow :: PathNode source , DataFlow :: PathNode sink
54- where cfg . hasFlowPath ( source , sink )
50+ from Flow :: PathNode source , Flow :: PathNode sink
51+ where Flow :: flowPath ( source , sink )
5552select sink , source , sink , "The size of this RSA key should be at least 2048 bits."
0 commit comments