mirror of
https://github.com/github/codeql.git
synced 2026-07-20 10:48:17 +02:00
Rust: Allow implicit flow out of content at the test sinks, so that we see our results.
This commit is contained in:
@@ -14,6 +14,12 @@ module MyFlowConfig implements DataFlow::ConfigSig {
|
||||
.getArgList()
|
||||
.getAnArg() = sink.asExpr().getExpr()
|
||||
}
|
||||
|
||||
predicate allowImplicitRead(DataFlow::Node node, DataFlow::ContentSet c) {
|
||||
// flow out from any content at the sink.
|
||||
isSink(node) and
|
||||
exists(c)
|
||||
}
|
||||
}
|
||||
|
||||
module MyFlowTest = TaintFlowTest<MyFlowConfig>;
|
||||
|
||||
@@ -5,8 +5,8 @@ fn sink<T>(_: T) { }
|
||||
// --- tests ---
|
||||
|
||||
fn test_env_vars() {
|
||||
sink(std::env::var("HOME")); // $ Alert[rust/summary/taint-sources] MISSING: hasTaintFlow
|
||||
sink(std::env::var_os("PATH")); // $ Alert[rust/summary/taint-sources] MISSING: hasTaintFlow
|
||||
sink(std::env::var("HOME")); // $ Alert[rust/summary/taint-sources] hasTaintFlow="HOME"
|
||||
sink(std::env::var_os("PATH")); // $ Alert[rust/summary/taint-sources] hasTaintFlow="PATH"
|
||||
|
||||
let var1 = std::env::var("HOME").expect("HOME not set"); // $ Alert[rust/summary/taint-sources]
|
||||
let var2 = std::env::var_os("PATH").unwrap(); // $ Alert[rust/summary/taint-sources]
|
||||
|
||||
Reference in New Issue
Block a user