Skip to content

Commit f167143

Browse files
committed
Python: Use real config in TestSensitiveDataSources
This will enable better tests in just one second
1 parent c341643 commit f167143

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

python/ql/test/experimental/dataflow/sensitive-data/TestSensitiveDataSources.ql

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// /**
2+
// * @kind path-problem
3+
// */
14
import python
25
import semmle.python.dataflow.new.DataFlow
36
import semmle.python.dataflow.new.TaintTracking
@@ -19,8 +22,7 @@ class SensitiveDataSourcesTest extends InlineExpectationsTest {
1922
tag = "SensitiveDataSource"
2023
or
2124
exists(DataFlow::Node use |
22-
use = API::builtin("print").getACall().getArg(_) and
23-
TaintTracking::localTaint(source, use) and
25+
any(SensitiveUseConfiguration config).hasFlow(source, use) and
2426
location = use.getLocation() and
2527
element = use.toString() and
2628
value = source.getClassification() and
@@ -29,3 +31,17 @@ class SensitiveDataSourcesTest extends InlineExpectationsTest {
2931
)
3032
}
3133
}
34+
35+
class SensitiveUseConfiguration extends TaintTracking::Configuration {
36+
SensitiveUseConfiguration() { this = "SensitiveUseConfiguration" }
37+
38+
override predicate isSource(DataFlow::Node node) { node instanceof SensitiveDataSource }
39+
40+
override predicate isSink(DataFlow::Node node) {
41+
node = API::builtin("print").getACall().getArg(_)
42+
}
43+
}
44+
// import DataFlow::PathGraph
45+
// from SensitiveUseConfiguration cfg, DataFlow::PathNode source, DataFlow::PathNode sink
46+
// where cfg.hasFlowPath(source, sink)
47+
// select sink, source, sink, "taint from $@", source.getNode(), "here"

0 commit comments

Comments
 (0)