Skip to content

Commit 1a12453

Browse files
Jami CogswellJami Cogswell
authored andcommitted
remove getNodeIntValue
1 parent c742a09 commit 1a12453

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

java/ql/lib/semmle/code/java/security/InsufficientKeySize.qll

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ abstract class InsufficientKeySizeSink extends DataFlow::Node {
1717

1818
/** A source for an insufficient key size used in RSA, DSA, and DH algorithms. */
1919
private class AsymmetricNonEcSource extends InsufficientKeySizeSource {
20-
AsymmetricNonEcSource() { getNodeIntValue(this) < getMinAsymNonEcKeySize() }
20+
AsymmetricNonEcSource() {
21+
this.asExpr().(IntegerLiteral).getIntValue() < getMinAsymNonEcKeySize()
22+
}
2123

2224
override predicate hasState(DataFlow::FlowState state) {
2325
state = getMinAsymNonEcKeySize().toString()
@@ -27,7 +29,7 @@ private class AsymmetricNonEcSource extends InsufficientKeySizeSource {
2729
/** A source for an insufficient key size used in elliptic curve (EC) algorithms. */
2830
private class AsymmetricEcSource extends InsufficientKeySizeSource {
2931
AsymmetricEcSource() {
30-
getNodeIntValue(this) < getMinAsymEcKeySize()
32+
this.asExpr().(IntegerLiteral).getIntValue() < getMinAsymEcKeySize()
3133
or
3234
// the below is needed for cases when the key size is embedded in the curve name
3335
getEcKeySize(this.asExpr().(StringLiteral).getValue()) < getMinAsymEcKeySize()
@@ -40,7 +42,7 @@ private class AsymmetricEcSource extends InsufficientKeySizeSource {
4042

4143
/** A source for an insufficient key size used in AES algorithms. */
4244
private class SymmetricSource extends InsufficientKeySizeSource {
43-
SymmetricSource() { getNodeIntValue(this) < getMinSymKeySize() }
45+
SymmetricSource() { this.asExpr().(IntegerLiteral).getIntValue() < getMinSymKeySize() }
4446

4547
override predicate hasState(DataFlow::FlowState state) { state = getMinSymKeySize().toString() }
4648
}
@@ -54,11 +56,6 @@ private int getMinAsymEcKeySize() { result = 256 }
5456
/** Returns the minimum recommended key size for AES algorithms. */
5557
private int getMinSymKeySize() { result = 128 }
5658

57-
/** Returns the integer value of a given DataFlow::Node. */
58-
private int getNodeIntValue(DataFlow::Node node) {
59-
result = node.asExpr().(IntegerLiteral).getIntValue()
60-
}
61-
6259
/** Returns the key size from an EC algorithm's curve name string */
6360
bindingset[algorithm]
6461
private int getEcKeySize(string algorithm) {

0 commit comments

Comments
 (0)