Skip to content

Commit 8414759

Browse files
edvraasmowton
authored andcommitted
Code review
1 parent 7e1c576 commit 8414759

File tree

4 files changed

+8
-15
lines changed

4 files changed

+8
-15
lines changed

ql/src/experimental/CWE-326/InsufficientKeySize.ql

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@
1111
import go
1212
import DataFlow::PathGraph
1313

14+
/**
15+
* RSA key length data flow tracking configuration.
16+
*/
1417
class RsaKeyTrackingConfiguration extends DataFlow::Configuration {
1518
RsaKeyTrackingConfiguration() { this = "RsaKeyTrackingConfiguration" }
1619

1720
override predicate isSource(DataFlow::Node source) {
18-
exists(ValueExpr c |
19-
source.asExpr() = c and
20-
c.getIntValue() < 2048
21-
)
21+
source.asExpr().(ValueExpr).getIntValue() < 2048
2222
}
2323

2424
override predicate isSink(DataFlow::Node sink) {
25-
exists(CallExpr c |
26-
sink.asExpr() = c.getArgument(1) and
25+
exists(DataFlow::CallNode c |
26+
sink = c.getArgument(1) and
2727
c.getTarget().hasQualifiedName("crypto/rsa", "GenerateKey")
2828
)
2929
}

ql/src/experimental/CWE-326/InsufficientKeySizeBad.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ func main() {
1313
fmt.Println(err)
1414
}
1515
fmt.Println(pvk)
16-
}
16+
}

ql/src/experimental/CWE-326/InsufficientKeySizeGood.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ func main() {
1313
fmt.Println(err)
1414
}
1515
fmt.Println(pvk)
16-
}
16+
}

ql/test/experimental/CWE-326/InsufficientKeySize.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,3 @@ func foo4() {
2525
func foo5(size int) {
2626
rsa.GenerateKey(rand.Reader, size)
2727
}
28-
29-
func main() {
30-
foo1()
31-
foo2()
32-
foo3()
33-
foo4()
34-
}

0 commit comments

Comments
 (0)