Rust: Allow implicit flow out of content at the test sinks, so that we see our results.

This commit is contained in:
Geoffrey White
2025-01-17 17:53:57 +00:00
parent a1980d4d08
commit 185a23b3c6
2 changed files with 8 additions and 2 deletions

View File

@@ -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>;

View File

@@ -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]