Files
codeql/python/ql/test/library-tests/PointsTo/new/ImpliesDataflow.ql
yoff 04b130f57f Python: fix library-test compile errors and rebless after CFG migration
Library-test compile fixes after the shared-CFG migration:
- PointsTo/global, PointsTo/local: use `f.getNode() = s.getValue()`
  instead of `s.getValue().getAFlowNode() = f` (the new CFG does not
  surface getAFlowNode on AST nodes).
- PointsTo/new/ImpliesDataflow: bridge new Cfg::ControlFlowNode to the
  legacy ControlFlowNodeWithPointsTo via AST identity.
- frameworks/aiohttp + frameworks/modeling-example: qualify CallNode /
  NameNode / AttrNode casts with Cfg:: now that those names live in
  the new CFG facade.

Rebless 4 expected files for toString-only differences (renamed CFG
positions like 'CFG node for foo' vs 'foo' — no semantic change):
ImpliesDataflow, EnclosingCallable, NaiveModel, ProperModel.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-28 21:09:49 +00:00

33 lines
1.1 KiB
Plaintext

/**
* Test that the new data-flow analysis can connect any two
* data-flow nodes that the points-to analysis can.
*/
private import python
private import LegacyPointsTo
import semmle.python.dataflow.new.DataFlow
predicate pointsToOrigin(DataFlow::CfgNode pointer, DataFlow::CfgNode origin) {
exists(ControlFlowNodeWithPointsTo legacyPointer, ControlFlowNode legacyOrigin |
legacyPointer.getNode() = pointer.getNode().getNode() and
legacyOrigin = legacyPointer.pointsTo().getOrigin() and
legacyOrigin.getNode() = origin.getNode().getNode()
)
}
module PointsToConfig implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node node) { pointsToOrigin(_, node) }
predicate isSink(DataFlow::Node node) { pointsToOrigin(node, _) }
}
module PointsToFlow = DataFlow::Global<PointsToConfig>;
from DataFlow::Node pointer, DataFlow::Node origin
where
exists(pointer.getLocation().getFile().getRelativePath()) and
exists(origin.getLocation().getFile().getRelativePath()) and
pointsToOrigin(pointer, origin) and
not PointsToFlow::flow(origin, pointer)
select origin, pointer