Skip to content

Commit 4c8da54

Browse files
authored
Merge pull request #17036 from chmodxxx/sbaddou/fix
Java: Move SensitiveLoggerConfig source to extensible format
2 parents 67dac96 + 4f80ae2 commit 4c8da54

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ import semmle.code.java.security.SensitiveActions
77
import semmle.code.java.frameworks.android.Compose
88
private import semmle.code.java.security.Sanitizers
99

10+
/** A data flow source node for sensitive logging sources. */
11+
abstract class SensitiveLoggerSource extends DataFlow::Node { }
12+
1013
/** A variable that may hold sensitive information, judging by its name. */
1114
class VariableWithSensitiveName extends Variable {
1215
VariableWithSensitiveName() {
@@ -26,6 +29,10 @@ class CredentialExpr extends VarAccess {
2629
}
2730
}
2831

32+
private class CredentialExprSource extends SensitiveLoggerSource {
33+
CredentialExprSource() { this.asExpr() instanceof CredentialExpr }
34+
}
35+
2936
/** An instantiation of a (reflexive, transitive) subtype of `java.lang.reflect.Type`. */
3037
private class TypeType extends RefType {
3138
pragma[nomagic]
@@ -42,7 +49,7 @@ private class TypeType extends RefType {
4249
deprecated class SensitiveLoggerConfiguration extends TaintTracking::Configuration {
4350
SensitiveLoggerConfiguration() { this = "SensitiveLoggerConfiguration" }
4451

45-
override predicate isSource(DataFlow::Node source) { source.asExpr() instanceof CredentialExpr }
52+
override predicate isSource(DataFlow::Node source) { source instanceof SensitiveLoggerSource }
4653

4754
override predicate isSink(DataFlow::Node sink) { sinkNode(sink, "log-injection") }
4855

@@ -59,7 +66,7 @@ deprecated class SensitiveLoggerConfiguration extends TaintTracking::Configurati
5966

6067
/** A data-flow configuration for identifying potentially-sensitive data flowing to a log output. */
6168
module SensitiveLoggerConfig implements DataFlow::ConfigSig {
62-
predicate isSource(DataFlow::Node source) { source.asExpr() instanceof CredentialExpr }
69+
predicate isSource(DataFlow::Node source) { source instanceof SensitiveLoggerSource }
6370

6471
predicate isSink(DataFlow::Node sink) { sinkNode(sink, "log-injection") }
6572

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* Added the extensible abstract class `SensitiveLoggerSource`. Now this class can be extended to add more sources to the `java/sensitive-log` query or for customizations overrides.

0 commit comments

Comments
 (0)