|
11 | 11 | */
|
12 | 12 |
|
13 | 13 | import java
|
14 |
| -import semmle.code.java.dataflow.ExternalFlow |
15 |
| -import semmle.code.java.dataflow.TaintTracking |
16 |
| -import semmle.code.java.security.SensitiveActions |
17 |
| -import DataFlow |
| 14 | +import semmle.code.java.security.SensitiveLoggingQuery |
18 | 15 | import PathGraph
|
19 | 16 |
|
20 |
| -/** |
21 |
| - * Gets a regular expression for matching names of variables that indicate the value being held may contain sensitive information |
22 |
| - */ |
23 |
| -private string getACredentialRegex() { result = "(?i).*username.*" } |
24 |
| - |
25 |
| -/** Variable keeps sensitive information judging by its name * */ |
26 |
| -class CredentialExpr extends Expr { |
27 |
| - CredentialExpr() { |
28 |
| - exists(Variable v | this = v.getAnAccess() | |
29 |
| - v.getName().regexpMatch([getCommonSensitiveInfoRegex(), getACredentialRegex()]) |
30 |
| - ) |
31 |
| - } |
32 |
| -} |
33 |
| - |
34 |
| -class LoggerConfiguration extends DataFlow::Configuration { |
35 |
| - LoggerConfiguration() { this = "Logger Configuration" } |
36 |
| - |
37 |
| - override predicate isSource(DataFlow::Node source) { source.asExpr() instanceof CredentialExpr } |
38 |
| - |
39 |
| - override predicate isSink(DataFlow::Node sink) { sinkNode(sink, "logging") } |
40 |
| - |
41 |
| - override predicate isAdditionalFlowStep(DataFlow::Node node1, DataFlow::Node node2) { |
42 |
| - TaintTracking::localTaintStep(node1, node2) |
43 |
| - } |
44 |
| -} |
45 |
| - |
46 | 17 | from LoggerConfiguration cfg, DataFlow::PathNode source, DataFlow::PathNode sink
|
47 | 18 | where cfg.hasFlowPath(source, sink)
|
48 |
| -select sink.getNode(), source, sink, "Outputting $@ to log.", source.getNode(), |
| 19 | +select sink.getNode(), source, sink, "This $@ is written to a log file.", source.getNode(), |
49 | 20 | "sensitive information"
|
0 commit comments