From 185a23b3c65dc6d5d1bf84d5631faee4e457d8a3 Mon Sep 17 00:00:00 2001 From: Geoffrey White <40627776+geoffw0@users.noreply.github.com> Date: Fri, 17 Jan 2025 17:53:57 +0000 Subject: [PATCH] Rust: Allow implicit flow out of content at the test sinks, so that we see our results. --- rust/ql/test/library-tests/dataflow/sources/InlineFlow.ql | 6 ++++++ rust/ql/test/library-tests/dataflow/sources/test.rs | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/rust/ql/test/library-tests/dataflow/sources/InlineFlow.ql b/rust/ql/test/library-tests/dataflow/sources/InlineFlow.ql index 92a41dc4681..7d5f4fb926f 100644 --- a/rust/ql/test/library-tests/dataflow/sources/InlineFlow.ql +++ b/rust/ql/test/library-tests/dataflow/sources/InlineFlow.ql @@ -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; diff --git a/rust/ql/test/library-tests/dataflow/sources/test.rs b/rust/ql/test/library-tests/dataflow/sources/test.rs index 9b92bb41b21..449828cb995 100644 --- a/rust/ql/test/library-tests/dataflow/sources/test.rs +++ b/rust/ql/test/library-tests/dataflow/sources/test.rs @@ -5,8 +5,8 @@ fn sink(_: 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]