mirror of
https://github.com/github/codeql.git
synced 2026-07-21 11:18:20 +02:00
should perhaps move `LocalFlowStepTest` and `MaximalFlowStep` into where they are referenced (they did not seem too reusable after all). Should also add argument tests in the same way.
32 lines
1.1 KiB
Plaintext
32 lines
1.1 KiB
Plaintext
import python
|
|
import semmle.python.dataflow.new.DataFlow
|
|
import TestUtilities.InlineExpectationsTest
|
|
|
|
abstract class FlowTest extends InlineExpectationsTest {
|
|
bindingset[this]
|
|
FlowTest() { any() }
|
|
|
|
abstract string flowTag();
|
|
|
|
abstract predicate relevantFlow(DataFlow::Node fromNode, DataFlow::Node toNode);
|
|
|
|
override string getARelevantTag() { result = this.flowTag() }
|
|
|
|
override predicate hasActualResult(Location location, string element, string tag, string value) {
|
|
exists(DataFlow::Node fromNode, DataFlow::Node toNode | this.relevantFlow(fromNode, toNode) |
|
|
location = toNode.getLocation() and
|
|
tag = this.flowTag() and
|
|
value =
|
|
"\"" + fromNode.toString() + lineStr(fromNode, toNode) + " -> " + toNode.toString() + "\"" and
|
|
element = toNode.toString()
|
|
)
|
|
}
|
|
|
|
pragma[inline]
|
|
private string lineStr(DataFlow::Node fromNode, DataFlow::Node toNode) {
|
|
if fromNode.getLocation().getStartLine() = toNode.getLocation().getStartLine()
|
|
then result = ""
|
|
else result = ", l:" + fromNode.getLocation().getStartLine()
|
|
}
|
|
}
|