Skip to content

Commit 2ad70cb

Browse files
author
Salah Baddou
committed
Move SensitiveLoggerConfig source to extensible format
1 parent 38aac1f commit 2ad70cb

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

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

Lines changed: 11 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,12 @@ class CredentialExpr extends VarAccess {
2629
}
2730
}
2831

32+
class CredentialExprSource extends SensitiveLoggerSource {
33+
CredentialExprSource(){
34+
this.asExpr() instanceof CredentialExpr
35+
}
36+
}
37+
2938
/** An instantiation of a (reflexive, transitive) subtype of `java.lang.reflect.Type`. */
3039
private class TypeType extends RefType {
3140
pragma[nomagic]
@@ -42,7 +51,7 @@ private class TypeType extends RefType {
4251
deprecated class SensitiveLoggerConfiguration extends TaintTracking::Configuration {
4352
SensitiveLoggerConfiguration() { this = "SensitiveLoggerConfiguration" }
4453

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

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

@@ -59,7 +68,7 @@ deprecated class SensitiveLoggerConfiguration extends TaintTracking::Configurati
5968

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

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

0 commit comments

Comments
 (0)