Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d385113

Browse files
committed
Make InsufficientKeySize use new API
1 parent 16ef11a commit d385113

1 file changed

Lines changed: 10 additions & 13 deletions

File tree

go/ql/src/Security/CWE-326/InsufficientKeySize.ql

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,26 @@
1111
*/
1212

1313
import 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)
5552
select sink, source, sink, "The size of this RSA key should be at least 2048 bits."

0 commit comments

Comments
 (0)