Skip to content

Commit 09240e4

Browse files
committed
Refactor: use concat instead of hand-written version
This changes the order of the algorithms in the regex, but I don't think that makes any difference.
1 parent e6409e1 commit 09240e4

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

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

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -235,22 +235,12 @@ string getAnInsecureHashAlgorithmName() {
235235
result = "MD5"
236236
}
237237

238-
private string rankedInsecureAlgorithm(int i) {
239-
result = rank[i](string name | insecureAlgorithm(name, _))
240-
}
241-
242-
private string insecureAlgorithmString(int i) {
243-
i = 1 and result = rankedInsecureAlgorithm(i)
244-
or
245-
result = rankedInsecureAlgorithm(i) + "|" + insecureAlgorithmString(i - 1)
246-
}
247-
248238
/**
249239
* Gets the regular expression used for matching strings that look like they
250240
* contain an algorithm that is known to be insecure.
251241
*/
252242
string getInsecureAlgorithmRegex() {
253-
result = algorithmRegex(insecureAlgorithmString(max(int i | exists(rankedInsecureAlgorithm(i)))))
243+
result = algorithmRegex(concat(string name | insecureAlgorithm(name, _) | name, "|"))
254244
}
255245

256246
/** Gets the reason why `input` is an insecure algorithm, if any. */

0 commit comments

Comments
 (0)