Module InlineFlowTest
Provides a simple base test for flow-related tests using inline expectations.
Example for a test.ql:
import swift
import utils.test.InlineFlowTest
import DefaultFlowTest
import PathGraph
from PathNode source, PathNode sink
where flowPath(source, sink)
select sink, source, sink, "$@", source, source.toString()
To declare expectations, you can use the $hasTaintFlow or $hasValueFlow comments within the test source files. Example of the corresponding test file, e.g. Test.java
func source(_ label: String) -> Any { return nil }
func taint(_ label: String) -> Any { return nil }
func sink(_ o: Any) { }
func test() {
let s = source("mySource")
sink(s) // $ hasValueFlow=mySource
let t = "foo" + taint("myTaint")
sink(t); // $ hasTaintFlow=myTaint
}
If you are only interested in value flow, then instead of importing DefaultFlowTest
, you can import
ValueFlowTest<DefaultFlowConfig>
. Similarly, if you are only interested in taint flow, then instead of
importing DefaultFlowTest
, you can import TaintFlowTest<DefaultFlowConfig>
. In both cases
DefaultFlowConfig
can be replaced by another implementation of DataFlow::ConfigSig
.
If you need more fine-grained tuning, consider implementing a test using InlineExpectationsTest
.
Import path
import utils.test.InlineFlowTest
Imports
DataFlow | |
ExternalFlow | INTERNAL use only. This is an experimental API subject to change without notice. |
InlineExpectationsTest | Inline expectation tests for Swift. See |
TaintTracking |