|
| 1 | +import go |
| 2 | +import TestUtilities.InlineExpectationsTest |
| 3 | + |
| 4 | +class DataConfiguration extends DataFlow::Configuration { |
| 5 | + DataConfiguration() { this = "data-configuration" } |
| 6 | + |
| 7 | + override predicate isSource(DataFlow::Node source) { |
| 8 | + source = any(DataFlow::CallNode c | c.getCalleeName() = "source").getResult(0) |
| 9 | + } |
| 10 | + |
| 11 | + override predicate isSink(DataFlow::Node sink) { |
| 12 | + sink = any(DataFlow::CallNode c | c.getCalleeName() = "sink").getArgument(0) |
| 13 | + } |
| 14 | +} |
| 15 | + |
| 16 | +class DataFlowTest extends InlineExpectationsTest { |
| 17 | + DataFlowTest() { this = "DataFlowTest" } |
| 18 | + |
| 19 | + override string getARelevantTag() { result = "dataflow" } |
| 20 | + |
| 21 | + override predicate hasActualResult(Location location, string element, string tag, string value) { |
| 22 | + tag = "dataflow" and |
| 23 | + exists(DataFlow::Node sink | any(DataConfiguration c).hasFlow(_, sink) | |
| 24 | + element = sink.toString() and |
| 25 | + value = "" and |
| 26 | + sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(), |
| 27 | + location.getStartColumn(), location.getEndLine(), location.getEndColumn()) |
| 28 | + ) |
| 29 | + } |
| 30 | +} |
| 31 | + |
| 32 | +class TaintConfiguration extends TaintTracking::Configuration { |
| 33 | + TaintConfiguration() { this = "taint-configuration" } |
| 34 | + |
| 35 | + override predicate isSource(DataFlow::Node source) { |
| 36 | + source = any(DataFlow::CallNode c | c.getCalleeName() = "source").getResult(0) |
| 37 | + } |
| 38 | + |
| 39 | + override predicate isSink(DataFlow::Node sink) { |
| 40 | + sink = any(DataFlow::CallNode c | c.getCalleeName() = "sink").getArgument(0) |
| 41 | + } |
| 42 | +} |
| 43 | + |
| 44 | +class TaintFlowTest extends InlineExpectationsTest { |
| 45 | + TaintFlowTest() { this = "TaintFlowTest" } |
| 46 | + |
| 47 | + override string getARelevantTag() { result = "taintflow" } |
| 48 | + |
| 49 | + override predicate hasActualResult(Location location, string element, string tag, string value) { |
| 50 | + tag = "taintflow" and |
| 51 | + exists(DataFlow::Node sink | any(TaintConfiguration c).hasFlow(_, sink) | |
| 52 | + element = sink.toString() and |
| 53 | + value = "" and |
| 54 | + sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(), |
| 55 | + location.getStartColumn(), location.getEndLine(), location.getEndColumn()) |
| 56 | + ) |
| 57 | + } |
| 58 | +} |
0 commit comments