mirror of
https://github.com/github/codeql.git
synced 2026-08-03 17:03:02 +02:00
After the shared-CFG migration, DataFlow::Node.asCfgNode() returns Cfg::ControlFlowNode rather than the legacy Flow::ControlFlowNode, and funcValue.getACall() / dfCall.getNode() now return different CFG types (legacy vs new). Update the two remaining test queries that still cast to legacy NameNode/CallNode types to bridge through Cfg:: types or AST. * experimental/import-resolution-namespace-relative/test.ql: cast to Cfg::NameNode instead of legacy NameNode. * experimental/library-tests/CallGraph/InlineCallGraphTest.ql: change predicate signatures from CallNode to AST Call, and bridge to legacy CallNode (points-to) and Cfg::CallNode (type-tracking) via getNode() on each side. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
37 lines
1.0 KiB
Plaintext
37 lines
1.0 KiB
Plaintext
import python
|
|
import semmle.python.dataflow.new.DataFlow
|
|
import semmle.python.dataflow.new.TaintTracking
|
|
import utils.test.InlineExpectationsTest
|
|
private import semmle.python.controlflow.internal.Cfg as Cfg
|
|
|
|
private module TestConfig implements DataFlow::ConfigSig {
|
|
predicate isSource(DataFlow::Node node) {
|
|
node.(DataFlow::CallCfgNode).getFunction().asCfgNode().(Cfg::NameNode).getId() = "source"
|
|
}
|
|
|
|
predicate isSink(DataFlow::Node node) {
|
|
exists(DataFlow::CallCfgNode call |
|
|
call.getFunction().asCfgNode().(Cfg::NameNode).getId() = "sink" and
|
|
node = call.getArg(0)
|
|
)
|
|
}
|
|
}
|
|
|
|
private module TestFlow = TaintTracking::Global<TestConfig>;
|
|
|
|
module FlowTest implements TestSig {
|
|
string getARelevantTag() { result = "flow" }
|
|
|
|
predicate hasActualResult(Location location, string element, string tag, string value) {
|
|
exists(DataFlow::Node sink |
|
|
TestFlow::flow(_, sink) and
|
|
tag = "flow" and
|
|
location = sink.getLocation() and
|
|
value = "source" and
|
|
element = sink.toString()
|
|
)
|
|
}
|
|
}
|
|
|
|
import MakeTest<FlowTest>
|