Skip to content
This repository was archived by the owner on Apr 4, 2025. It is now read-only.

Commit 49fe169

Browse files
author
Keith Hoodlet
committed
Add CodeQL query
1 parent a95ac7d commit 49fe169

1 file changed

Lines changed: 14 additions & 11 deletions

File tree

java/CWE-532/SensitiveInformation.ql

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,26 @@ import java
1515
import semmle.code.java.dataflow.DataFlow
1616
import semmle.code.java.dataflow.FlowSources
1717
import semmle.code.java.dataflow.TaintTracking2
18-
import DataFlow::PathGraph
18+
//import DataFlow::PathGraph
1919
// Internal
2020
import github.Logging
2121
import github.SensitiveInformation
2222

23-
class SensitiveInformationLoggingConfig extends TaintTracking::Configuration {
24-
SensitiveInformationLoggingConfig() { this = "SensitiveInformationLoggingConfig" }
23+
module SensitiveInformationConfig implements DataFlow::ConfigSig {
24+
predicate isSource(DataFlow::Node source) { source instanceof SensitiveInformationSources }
2525

26-
override predicate isSource(DataFlow::Node source) {
27-
source instanceof SensitiveInformationSources
28-
}
26+
predicate isSink(DataFlow::Node sink) { sink instanceof LoggingMethodsSinks }
2927

30-
override predicate isSink(DataFlow::Node sink) { sink instanceof LoggingMethodsSinks }
28+
predicate isBarrier(DataFlow::Node node) {
29+
exists(Type t | t = node.getType() | t instanceof BoxedType or t instanceof PrimitiveType)
30+
}
3131
}
3232

33+
module SensitiveInformationFlow = TaintTracking::Global<SensitiveInformationConfig>;
34+
import SensitiveInformationFlow::PathGraph //importing the path graph from the module
35+
36+
3337
// ========== Query ==========
34-
from DataFlow::PathNode source, DataFlow::PathNode sink, SensitiveInformationLoggingConfig config
35-
where config.hasFlowPath(source, sink)
36-
select sink.getNode(), source, sink, "Sensative data is being logged $@.", source.getNode(),
37-
"user-provided value"
38+
from SensitiveInformationFlow::PathNode source, SensitiveInformationFlow::PathNode sink
39+
where SensitiveInformationFlow::flowPath(source, sink) //using flowPath instead of hasFlowPath
40+
select sink.getNode(), source, sink, "Sensative data is being logged $@.", source.getNode(), "user-provided value"

0 commit comments

Comments
 (0)