Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions java/ql/lib/semmle/code/java/security/Encryption.qll
Original file line number Diff line number Diff line change
Expand Up @@ -271,19 +271,15 @@ string getASecureAlgorithmName() {

private string rankedSecureAlgorithm(int i) { result = rank[i](getASecureAlgorithmName()) }

private string secureAlgorithmString(int i) {
i = 1 and result = rankedSecureAlgorithm(i)
or
result = rankedSecureAlgorithm(i) + "|" + secureAlgorithmString(i - 1)
private string secureAlgorithmString() {
result = concat(int i | | rankedSecureAlgorithm(i), "|" order by i desc)
}

/**
* Gets a regular expression for matching strings that look like they
* contain an algorithm that is known to be secure.
*/
string getSecureAlgorithmRegex() {
result = algorithmRegex(secureAlgorithmString(max(int i | exists(rankedSecureAlgorithm(i)))))
}
string getSecureAlgorithmRegex() { result = algorithmRegex(secureAlgorithmString()) }

/**
* Any use of a cryptographic element that specifies an encryption
Expand Down
10 changes: 3 additions & 7 deletions java/ql/src/experimental/quantum/Examples/BrokenCrypto.ql
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,15 @@ private string rankedInsecureAlgorithm(int i) {
result = rank[i](string s | s = getAnInsecureAlgorithmName())
}

private string insecureAlgorithmString(int i) {
i = 1 and result = rankedInsecureAlgorithm(i)
or
result = rankedInsecureAlgorithm(i) + "|" + insecureAlgorithmString(i - 1)
private string insecureAlgorithmString() {
result = concat(int i | | rankedInsecureAlgorithm(i), "|" order by i desc)
}

/**
* Gets the regular expression used for matching strings that look like they
* contain an algorithm that is known to be insecure.
*/
string getInsecureAlgorithmRegex() {
result = algorithmRegex(insecureAlgorithmString(max(int i | exists(rankedInsecureAlgorithm(i)))))
}
string getInsecureAlgorithmRegex() { result = algorithmRegex(insecureAlgorithmString()) }

bindingset[algorithmString]
private string algorithmRegex(string algorithmString) {
Expand Down
20 changes: 6 additions & 14 deletions ruby/ql/lib/codeql/ruby/security/OpenSSL.qll
Original file line number Diff line number Diff line change
Expand Up @@ -35,37 +35,29 @@ private string rankedInsecureAlgorithm(int i) {
)
}

private string insecureAlgorithmString(int i) {
i = 1 and result = rankedInsecureAlgorithm(i)
or
result = rankedInsecureAlgorithm(i) + "|" + insecureAlgorithmString(i - 1)
private string insecureAlgorithmString() {
result = concat(int i | | rankedInsecureAlgorithm(i), "|" order by i desc)
}

/**
* Gets the regular expression used for matching strings that look like they
* contain an algorithm that is known to be insecure.
*/
private string getInsecureAlgorithmRegex() {
result = algorithmRegex(insecureAlgorithmString(max(int i | exists(rankedInsecureAlgorithm(i)))))
}
private string getInsecureAlgorithmRegex() { result = algorithmRegex(insecureAlgorithmString()) }

private string rankedSecureAlgorithm(int i) {
result = rank[i](string s | isStrongEncryptionAlgorithm(s))
}

private string secureAlgorithmString(int i) {
i = 1 and result = rankedSecureAlgorithm(i)
or
result = rankedSecureAlgorithm(i) + "|" + secureAlgorithmString(i - 1)
private string secureAlgorithmString() {
result = concat(int i | | rankedSecureAlgorithm(i), "|" order by i desc)
}

/**
* Gets a regular expression for matching strings that look like they
* contain an algorithm that is known to be secure.
*/
string getSecureAlgorithmRegex() {
result = algorithmRegex(secureAlgorithmString(max(int i | exists(rankedSecureAlgorithm(i)))))
}
string getSecureAlgorithmRegex() { result = algorithmRegex(secureAlgorithmString()) }

/**
* Names of known ciphers supported by the Ruby `OpenSSL` library, and
Expand Down
Loading