|
1 | 1 | import python |
2 | | -private import semmle.python.pointsto.PointsTo |
3 | 2 | private import semmle.python.internal.CachedStages |
4 | 3 | private import codeql.controlflow.BasicBlock as BB |
5 | 4 |
|
@@ -144,56 +143,6 @@ class ControlFlowNode extends @py_flow_node { |
144 | 143 | /** Whether this flow node is the first in its scope */ |
145 | 144 | predicate isEntryNode() { py_scope_flow(this, _, -1) } |
146 | 145 |
|
147 | | - /** Gets the value that this ControlFlowNode points-to. */ |
148 | | - predicate pointsTo(Value value) { this.pointsTo(_, value, _) } |
149 | | - |
150 | | - /** Gets the value that this ControlFlowNode points-to. */ |
151 | | - Value pointsTo() { this.pointsTo(_, result, _) } |
152 | | - |
153 | | - /** Gets a value that this ControlFlowNode may points-to. */ |
154 | | - Value inferredValue() { this.pointsTo(_, result, _) } |
155 | | - |
156 | | - /** Gets the value and origin that this ControlFlowNode points-to. */ |
157 | | - predicate pointsTo(Value value, ControlFlowNode origin) { this.pointsTo(_, value, origin) } |
158 | | - |
159 | | - /** Gets the value and origin that this ControlFlowNode points-to, given the context. */ |
160 | | - predicate pointsTo(Context context, Value value, ControlFlowNode origin) { |
161 | | - PointsTo::pointsTo(this, context, value, origin) |
162 | | - } |
163 | | - |
164 | | - /** |
165 | | - * Gets what this flow node might "refer-to". Performs a combination of localized (intra-procedural) points-to |
166 | | - * analysis and global module-level analysis. This points-to analysis favours precision over recall. It is highly |
167 | | - * precise, but may not provide information for a significant number of flow-nodes. |
168 | | - * If the class is unimportant then use `refersTo(value)` or `refersTo(value, origin)` instead. |
169 | | - */ |
170 | | - pragma[nomagic] |
171 | | - predicate refersTo(Object obj, ClassObject cls, ControlFlowNode origin) { |
172 | | - this.refersTo(_, obj, cls, origin) |
173 | | - } |
174 | | - |
175 | | - /** Gets what this expression might "refer-to" in the given `context`. */ |
176 | | - pragma[nomagic] |
177 | | - predicate refersTo(Context context, Object obj, ClassObject cls, ControlFlowNode origin) { |
178 | | - not obj = unknownValue() and |
179 | | - not cls = theUnknownType() and |
180 | | - PointsTo::points_to(this, context, obj, cls, origin) |
181 | | - } |
182 | | - |
183 | | - /** |
184 | | - * Whether this flow node might "refer-to" to `value` which is from `origin` |
185 | | - * Unlike `this.refersTo(value, _, origin)` this predicate includes results |
186 | | - * where the class cannot be inferred. |
187 | | - */ |
188 | | - pragma[nomagic] |
189 | | - predicate refersTo(Object obj, ControlFlowNode origin) { |
190 | | - not obj = unknownValue() and |
191 | | - PointsTo::points_to(this, _, obj, _, origin) |
192 | | - } |
193 | | - |
194 | | - /** Equivalent to `this.refersTo(value, _)` */ |
195 | | - predicate refersTo(Object obj) { this.refersTo(obj, _) } |
196 | | - |
197 | 146 | /** Gets the basic block containing this flow node */ |
198 | 147 | BasicBlock getBasicBlock() { result.contains(this) } |
199 | 148 |
|
@@ -259,23 +208,6 @@ class ControlFlowNode extends @py_flow_node { |
259 | 208 | ) |
260 | 209 | } |
261 | 210 |
|
262 | | - /** |
263 | | - * Check whether this control-flow node has complete points-to information. |
264 | | - * This would mean that the analysis managed to infer an over approximation |
265 | | - * of possible values at runtime. |
266 | | - */ |
267 | | - predicate hasCompletePointsToSet() { |
268 | | - // If the tracking failed, then `this` will be its own "origin". In that |
269 | | - // case, we want to exclude nodes for which there is also a different |
270 | | - // origin, as that would indicate that some paths failed and some did not. |
271 | | - this.refersTo(_, _, this) and |
272 | | - not exists(ControlFlowNode other | other != this and this.refersTo(_, _, other)) |
273 | | - or |
274 | | - // If `this` is a use of a variable, then we must have complete points-to |
275 | | - // for that variable. |
276 | | - exists(SsaVariable v | v.getAUse() = this | varHasCompletePointsToSet(v)) |
277 | | - } |
278 | | - |
279 | 211 | /** Whether this strictly dominates other. */ |
280 | 212 | pragma[inline] |
281 | 213 | predicate strictlyDominates(ControlFlowNode other) { |
@@ -332,28 +264,6 @@ private class AnyNode extends ControlFlowNode { |
332 | 264 | override AstNode getNode() { result = super.getNode() } |
333 | 265 | } |
334 | 266 |
|
335 | | -/** |
336 | | - * Check whether a SSA variable has complete points-to information. |
337 | | - * This would mean that the analysis managed to infer an overapproximation |
338 | | - * of possible values at runtime. |
339 | | - */ |
340 | | -private predicate varHasCompletePointsToSet(SsaVariable var) { |
341 | | - // Global variables may be modified non-locally or concurrently. |
342 | | - not var.getVariable() instanceof GlobalVariable and |
343 | | - ( |
344 | | - // If we have complete points-to information on the definition of |
345 | | - // this variable, then the variable has complete information. |
346 | | - var.getDefinition().(DefinitionNode).getValue().hasCompletePointsToSet() |
347 | | - or |
348 | | - // If this variable is a phi output, then we have complete |
349 | | - // points-to information about it if all phi inputs had complete |
350 | | - // information. |
351 | | - forex(SsaVariable phiInput | phiInput = var.getAPhiInput() | |
352 | | - varHasCompletePointsToSet(phiInput) |
353 | | - ) |
354 | | - ) |
355 | | -} |
356 | | - |
357 | 267 | /** A control flow node corresponding to a call expression, such as `func(...)` */ |
358 | 268 | class CallNode extends ControlFlowNode { |
359 | 269 | CallNode() { toAst(this) instanceof Call } |
|
0 commit comments