mirror of
https://github.com/github/codeql.git
synced 2026-04-20 14:34:04 +02:00
Merge pull request #16028 from owen-mc/java/sensitive-log-whitelist-tokenimage
Java: whitelist variable name `tokenImage` for `java/sensitive-log` as it's used in code generated by JavaCC
This commit is contained in:
@@ -12,7 +12,8 @@ class VariableWithSensitiveName extends Variable {
|
||||
VariableWithSensitiveName() {
|
||||
exists(string name | name = this.getName() |
|
||||
name.regexpMatch(getCommonSensitiveInfoRegex()) and
|
||||
not name.regexpMatch("(?i).*null.*")
|
||||
not name.regexpMatch("(?i).*null.*") and
|
||||
name != "tokenImage" // appears in parser code generated by JavaCC
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
---
|
||||
category: minorAnalysis
|
||||
---
|
||||
* Variables named `tokenImage` are no longer sources for the `java/sensitive-log` query. This is because this variable name is used in parsing code generated by JavaCC, so it causes a large number of false positive alerts.
|
||||
@@ -0,0 +1,27 @@
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
interface TokenSequenceParserConstants {
|
||||
/** Literal token values. */
|
||||
String[] tokenImage = {
|
||||
"<EOF>",
|
||||
};
|
||||
}
|
||||
|
||||
public class TokenSequenceParserTest implements TokenSequenceParserConstants {
|
||||
void test(String password) {
|
||||
Logger logger = null;
|
||||
|
||||
logger.info("When parsing found this: " + tokenImage[0]); // Safe
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class ParseExceptionTest extends Exception {
|
||||
String[] tokenImage;
|
||||
|
||||
void test() {
|
||||
Logger logger = null;
|
||||
|
||||
logger.info("When parsing found this: " + tokenImage[0]); // Safe
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user