Skip to content

Commit 0704946

Browse files
committed
Factor out matching sensitive variable name FPs
1 parent bdff0fd commit 0704946

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,23 @@ private string nonSuspicious() {
2828
}
2929

3030
/**
31-
* Gets a regular expression for matching common names of variables that indicate the value being held contains sensitive information.
31+
* Gets a regular expression for matching common names of variables that
32+
* indicate the value being held contains sensitive information.
3233
*/
3334
string getCommonSensitiveInfoRegex() {
3435
result = "(?i).*(challenge|pass(wd|word|code|phrase))(?!.*question).*" or
3536
result = "(?i).*(token|secret).*"
3637
}
3738

39+
/**
40+
* Gets a regular expression for matching common names of variables that
41+
* indicate the value being held does not contains sensitive information,
42+
* but is a false positive for `getCommonSensitiveInfoRegex`.
43+
*
44+
* - "tokenImage" appears in parser code generated by JavaCC.
45+
*/
46+
string getCommonSensitiveInfoFPRegex() { result = "(?i).*(null).*" or result = "tokenImage" }
47+
3848
/** An expression that might contain sensitive data. */
3949
abstract class SensitiveExpr extends Expr { }
4050

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ class VariableWithSensitiveName extends Variable {
1515
VariableWithSensitiveName() {
1616
exists(string name | name = this.getName() |
1717
name.regexpMatch(getCommonSensitiveInfoRegex()) and
18-
not name.regexpMatch("(?i).*null.*") and
19-
name != "tokenImage" // appears in parser code generated by JavaCC
18+
not name.regexpMatch(getCommonSensitiveInfoFPRegex())
2019
)
2120
}
2221
}

0 commit comments

Comments
 (0)