Skip to content

Commit 1435ef1

Browse files
committed
CryptoAlgorithms: make CryptographicAlgorithm#matchesName split on underscores
1 parent 983055b commit 1435ef1

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

javascript/ql/lib/semmle/javascript/security/CryptoAlgorithms.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ abstract class CryptographicAlgorithm extends TCryptographicAlgorithm {
4040

4141
/**
4242
* Holds if the name of this algorithm matches `name` modulo case,
43-
* white space, dashes, underscores, and anything after a dash in the name
43+
* white space, dashes, underscores, and anything after a dash or underscore in the name
4444
* (to ignore modes of operation, such as CBC or ECB).
4545
*/
4646
bindingset[name]
4747
predicate matchesName(string name) {
48-
[name.toUpperCase(), name.toUpperCase().regexpCapture("^(\\w+)(?:-.*)?$", 1)]
48+
[name.toUpperCase(), name.toUpperCase().regexpCapture("^([A-Z0-9]+)(?:(-|_).*)?$", 1)]
4949
.regexpReplaceAll("[-_ ]", "") = getName()
5050
}
5151

python/ql/lib/semmle/python/concepts/CryptoAlgorithms.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ abstract class CryptographicAlgorithm extends TCryptographicAlgorithm {
4040

4141
/**
4242
* Holds if the name of this algorithm matches `name` modulo case,
43-
* white space, dashes, underscores, and anything after a dash in the name
43+
* white space, dashes, underscores, and anything after a dash or underscore in the name
4444
* (to ignore modes of operation, such as CBC or ECB).
4545
*/
4646
bindingset[name]
4747
predicate matchesName(string name) {
48-
[name.toUpperCase(), name.toUpperCase().regexpCapture("^(\\w+)(?:-.*)?$", 1)]
48+
[name.toUpperCase(), name.toUpperCase().regexpCapture("^([A-Z0-9]+)(?:(-|_).*)?$", 1)]
4949
.regexpReplaceAll("[-_ ]", "") = getName()
5050
}
5151

ruby/ql/lib/codeql/ruby/security/CryptoAlgorithms.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ abstract class CryptographicAlgorithm extends TCryptographicAlgorithm {
4040

4141
/**
4242
* Holds if the name of this algorithm matches `name` modulo case,
43-
* white space, dashes, underscores, and anything after a dash in the name
43+
* white space, dashes, underscores, and anything after a dash or underscore in the name
4444
* (to ignore modes of operation, such as CBC or ECB).
4545
*/
4646
bindingset[name]
4747
predicate matchesName(string name) {
48-
[name.toUpperCase(), name.toUpperCase().regexpCapture("^(\\w+)(?:-.*)?$", 1)]
48+
[name.toUpperCase(), name.toUpperCase().regexpCapture("^([A-Z0-9]+)(?:(-|_).*)?$", 1)]
4949
.regexpReplaceAll("[-_ ]", "") = getName()
5050
}
5151

0 commit comments

Comments
 (0)