Skip to content

Commit 5db8306

Browse files
committed
Stop considering usernames sensitive info
Require variables to be static to be considered constants
1 parent e8972b8 commit 5db8306

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import semmle.code.java.dataflow.TaintTracking
66
import semmle.code.java.security.SensitiveActions
77
import DataFlow
88

9-
/** A variable that may hold sensitive information, judging by its name. * */
9+
/** A variable that may hold sensitive information, judging by its name. */
1010
class CredentialExpr extends Expr {
1111
CredentialExpr() {
1212
exists(Variable v | this = v.getAnAccess() |
13-
v.getName().regexpMatch([getCommonSensitiveInfoRegex(), "(?i).*(username).*"]) and
14-
not v.isFinal()
13+
v.getName().regexpMatch(getCommonSensitiveInfoRegex()) and
14+
not (v.isFinal() and v.isStatic())
1515
)
1616
}
1717
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* Query `java/sensitive-log` no longer considers usernames as sensitive information. Also, the conditions to consider a variable a constant (and therefore exclude it as user-provided sensitive information) have been tightened.

java/ql/test/query-tests/security/CWE-532/Test.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,18 @@ void test(String password) {
55
Logger logger = null;
66

77
logger.info("User's password is: " + password); // $ hasTaintFlow
8-
}
8+
}
99

1010
void test2(String authToken) {
1111
Logger logger = null;
1212

13-
logger.error("Auth failed for: " + authToken); // $ hasTaintFlow
13+
logger.error("Auth failed for: " + authToken); // $ hasTaintFlow
14+
}
15+
16+
void test3(String username) {
17+
Logger logger = null;
18+
19+
logger.error("Auth failed for: " + username); // Safe
1420
}
1521

16-
}
22+
}

0 commit comments

Comments
 (0)