Skip to content

Commit 25fa8d5

Browse files
committed
Move some logic to class
1 parent 4ff6c1e commit 25fa8d5

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

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

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,19 @@ private import semmle.code.java.security.Encryption
88
private import semmle.code.java.frameworks.Properties
99
private import semmle.code.java.dataflow.RangeUtils
1010

11-
class GetPropertyMethodAccess extends MethodAccess {
11+
private class GetPropertyMethodAccess extends MethodAccess {
1212
GetPropertyMethodAccess() { this.getMethod() instanceof PropertiesGetPropertyMethod }
1313

1414
private ConfigPair getPair() {
1515
this.getArgument(0).(ConstantStringExpr).getStringValue() = result.getNameElement().getName()
1616
}
1717

18-
string getValue() {
18+
string getPropertyValue() {
1919
result = this.getPair().getValueElement().getValue() or
2020
result = this.getArgument(1).(ConstantStringExpr).getStringValue()
2121
}
2222
}
2323

24-
string getWeakHashingAlgorithm(DataFlow::Node node) {
2524
/**
2625
* Get the name of the weak cryptographic algorithm represented by `node`.
2726
*/
@@ -40,11 +39,9 @@ string getWeakHashingAlgorithmName(DataFlow::Node node) {
4039
*/
4140
module InsecureAlgorithmPropertyConfig implements DataFlow::ConfigSig {
4241
predicate isSource(DataFlow::Node n) {
43-
exists(MethodAccess ma, ConfigPair pair |
44-
n.asExpr() = ma and ma.getMethod() instanceof PropertiesGetPropertyMethod
45-
|
46-
ma.getArgument(0).(ConstantStringExpr).getStringValue() = pair.getNameElement().getName() and
47-
not pair.getValueElement().getValue().regexpMatch(getSecureAlgorithmRegex())
42+
exists(GetPropertyMethodAccess ma, string algo | n.asExpr() = ma |
43+
algo = ma.getPropertyValue() and
44+
not algo.regexpMatch(getSecureAlgorithmRegex())
4845
)
4946
}
5047

0 commit comments

Comments
 (0)