File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed
java/ql/lib/semmle/code/java/security Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -28,13 +28,23 @@ private string nonSuspicious() {
28
28
}
29
29
30
30
/**
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.
32
33
*/
33
34
string getCommonSensitiveInfoRegex ( ) {
34
35
result = "(?i).*(challenge|pass(wd|word|code|phrase))(?!.*question).*" or
35
36
result = "(?i).*(token|secret).*"
36
37
}
37
38
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
+
38
48
/** An expression that might contain sensitive data. */
39
49
abstract class SensitiveExpr extends Expr { }
40
50
Original file line number Diff line number Diff line change @@ -15,8 +15,7 @@ class VariableWithSensitiveName extends Variable {
15
15
VariableWithSensitiveName ( ) {
16
16
exists ( string name | name = this .getName ( ) |
17
17
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 ( ) )
20
19
)
21
20
}
22
21
}
You can’t perform that action at this time.
0 commit comments