Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4297d05

Browse files
committed
Rust: Implement the query.
1 parent 173cfd5 commit 4297d05

2 files changed

Lines changed: 35 additions & 3 deletions

File tree

rust/ql/src/queries/security/CWE-312/CleartextLogging.ql

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,35 @@
1414
*/
1515

1616
import rust
17+
import codeql.rust.security.CleartextLoggingExtensions
18+
import codeql.rust.dataflow.DataFlow
19+
import codeql.rust.dataflow.TaintTracking
1720

18-
from Element e
19-
where none()
20-
select e, ""
21+
/**
22+
* A taint-tracking configuration for cleartext logging vulnerabilities.
23+
*/
24+
module CleartextLoggingConfig implements DataFlow::ConfigSig {
25+
import CleartextLogging
26+
27+
predicate isSource(DataFlow::Node source) { source instanceof Source }
28+
29+
predicate isSink(DataFlow::Node sink) { sink instanceof Sink }
30+
31+
predicate isBarrier(DataFlow::Node barrier) { barrier instanceof Barrier }
32+
33+
predicate isBarrierIn(DataFlow::Node node) {
34+
// make sources barriers so that we only report the closest instance
35+
isSource(node)
36+
}
37+
}
38+
39+
module CleartextLoggingFlow = TaintTracking::Global<CleartextLoggingConfig>;
40+
41+
import CleartextLoggingFlow::PathGraph
42+
43+
from CleartextLoggingFlow::PathNode source, CleartextLoggingFlow::PathNode sink
44+
where CleartextLoggingFlow::flowPath(source, sink)
45+
select sink.getNode(), source, sink,
46+
"This operation writes '" + sink.toString() +
47+
"' to a log file. It may contain unencrypted sensitive data from $@.", source,
48+
source.getNode().toString()
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#select
2+
edges
3+
nodes
4+
subpaths

0 commit comments

Comments
 (0)