Skip to content

Conversation

@tausbn
Copy link
Contributor

@tausbn tausbn commented Oct 30, 2025

Should be reviewed commit-by-commit!

This is the first step towards hiding all of the existing hooks into the points-to API behind an explicit LegacyPointsTo module.

This PR in particular removes all ways to access points-to from ControlFlowNode, Expr, and Module.

The approach taken is roughly the same in each case: for each points-to-related predicate on, say, Expr, we transfer it to a subclass called ExprWithPointsTo that lives inside the LegacyPointsTo module. All existing uses of these predicates must then be updated to refer to ExprWithPointsTo instead, either by updating the type (in the case of a bound variable), or by inserting an inline cast to this class.

Note that for some of these classes we additionally override getAQlClass to not return any values. This is because a few tests were failing because they were seeing new (though really just duplicated) results for ExprWithPointsTo and ModuleWithPointsTo. Simply making the methods empty for these classes seemed like the easiest solution.


Finally, to head off a potential question:

  • Why put LegacyPointsto.qll at the top level?

It may seem a bit ugly to place this alongside python.qll in this otherwise (mostly) pristine spot in the module hierarchy, but I think this could be construed as a feature. It is an ugly wart, and having it present front and centre might encourage us to actually do something about this fact. 😈

not exists(ExprWithPointsTo left, ExprWithPointsTo right, Value val |
comp.compares(left, op, right) and
exists(ImmutableLiteral il | il.getLiteralValue() = val)
exists(ImmutableLiteral il | il = val.(ConstantObjectInternal).getLiteral())

Check warning

Code scanning / CodeQL

Expression can be replaced with a cast Warning

The assignment in the exists(..) is redundant.
Moves the existing points-to predicates to the newly added class
`ControlFlowNodeWithPointsTo` which resides in the `LegacyPointsTo`
module.

(Existing code that uses these predicates should import this module, and
references to `ControlFlowNode` should be changed to
`ControlFlowNodeWithPointsTo`.)

Also updates all existing points-to based code to do just this.
This had only two uses in our libraries, so I simply inlined the
predicate body in both places.
@tausbn tausbn force-pushed the tausbn/python-move-points-to-predicates-to-legacy-module branch from b2c9e72 to d7a6b3f Compare October 30, 2025 13:30
@tausbn tausbn force-pushed the tausbn/python-move-points-to-predicates-to-legacy-module branch from d7a6b3f to 820d8e7 Compare October 30, 2025 13:59
I wasn't entirely sure if this should be classified as `deprecated` or
`breaking`, but seeing as these changes technically _could_ break
existing queries (requiring a small rewrite), I opted for the latter.
@tausbn tausbn changed the title Python: Move points-to to legacy module Python: Move ControlFlowNode, Expr, and Module points-to to legacy module Oct 30, 2025
@tausbn tausbn marked this pull request as ready for review October 30, 2025 15:25
@tausbn tausbn requested a review from a team as a code owner October 30, 2025 15:25
Copilot AI review requested due to automatic review settings October 30, 2025 15:25
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request removes points-to analysis predicates from ControlFlowNode, Expr, and Module classes, moving them to a new LegacyPointsTo module. This change enforces explicit opt-in to legacy points-to functionality by requiring imports of LegacyPointsTo and use of specialized wrapper classes (ControlFlowNodeWithPointsTo, ExprWithPointsTo, ModuleWithPointsTo).

Key changes:

  • Created LegacyPointsTo.qll module with wrapper classes for accessing points-to predicates
  • Removed points-to predicates from ControlFlowNode, Expr, and Module base classes
  • Updated all existing usages across test files, library files, and queries to use the new wrapper classes

Reviewed Changes

Copilot reviewed 107 out of 107 changed files in this pull request and generated no comments.

Show a summary per file
File Description
python/ql/lib/LegacyPointsTo.qll New module defining ControlFlowNodeWithPointsTo, ExprWithPointsTo, and ModuleWithPointsTo wrapper classes
python/ql/lib/semmle/python/Flow.qll Removed points-to predicates from ControlFlowNode class
python/ql/lib/semmle/python/Exprs.qll Removed points-to predicates from Expr class
python/ql/lib/semmle/python/Module.qll Removed getAnExport() predicate from Module class
Test and library files (80+ files) Added LegacyPointsTo imports and casts to wrapper classes where points-to predicates are used

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants