mirror of
https://github.com/github/codeql.git
synced 2025-12-21 19:26:31 +01:00
Java: Replace incorrect usage of Literal.getLiteral()
This commit is contained in:
committed by
Chris Smowton
parent
1c1c46591e
commit
58d2d5d14e
@@ -17,14 +17,14 @@ import DataFlow
|
||||
import PathGraph
|
||||
|
||||
private class ShortStringLiteral extends StringLiteral {
|
||||
ShortStringLiteral() { getLiteral().length() < 100 }
|
||||
ShortStringLiteral() { getRepresentedString().length() < 100 }
|
||||
}
|
||||
|
||||
class BrokenAlgoLiteral extends ShortStringLiteral {
|
||||
BrokenAlgoLiteral() {
|
||||
getValue().regexpMatch(getInsecureAlgorithmRegex()) and
|
||||
getRepresentedString().regexpMatch(getInsecureAlgorithmRegex()) and
|
||||
// Exclude German and French sentences.
|
||||
not getValue().regexpMatch(".*\\p{IsLowercase} des \\p{IsLetter}.*")
|
||||
not getRepresentedString().regexpMatch(".*\\p{IsLowercase} des \\p{IsLetter}.*")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,4 +48,4 @@ where
|
||||
source.getNode().asExpr() = s and
|
||||
conf.hasFlowPath(source, sink)
|
||||
select c, source, sink, "Cryptographic algorithm $@ is weak and should not be used.", s,
|
||||
s.getLiteral()
|
||||
s.getRepresentedString()
|
||||
|
||||
@@ -18,14 +18,14 @@ import semmle.code.java.dispatch.VirtualDispatch
|
||||
import PathGraph
|
||||
|
||||
private class ShortStringLiteral extends StringLiteral {
|
||||
ShortStringLiteral() { getLiteral().length() < 100 }
|
||||
ShortStringLiteral() { getRepresentedString().length() < 100 }
|
||||
}
|
||||
|
||||
class InsecureAlgoLiteral extends ShortStringLiteral {
|
||||
InsecureAlgoLiteral() {
|
||||
// Algorithm identifiers should be at least two characters.
|
||||
getValue().length() > 1 and
|
||||
exists(string s | s = getLiteral() |
|
||||
getRepresentedString().length() > 1 and
|
||||
exists(string s | s = getRepresentedString() |
|
||||
not s.regexpMatch(getSecureAlgorithmRegex()) and
|
||||
// Exclude results covered by another query.
|
||||
not s.regexpMatch(getInsecureAlgorithmRegex())
|
||||
@@ -72,4 +72,4 @@ where
|
||||
conf.hasFlowPath(source, sink)
|
||||
select c, source, sink,
|
||||
"Cryptographic algorithm $@ may not be secure, consider using a different algorithm.", s,
|
||||
s.getLiteral()
|
||||
s.getRepresentedString()
|
||||
|
||||
Reference in New Issue
Block a user