Skip to content

Commit d151e21

Browse files
committed
Python: Move ControlFlowNode.toString() to AST cached stage
This means points-to is no longer evaluated for sql injection 🎉 Thanks @asgerf 💪
1 parent 69b43f1 commit d151e21

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

python/ql/lib/semmle/python/Flow.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ class ControlFlowNode extends @py_flow_node {
125125
/** Gets a textual representation of this element. */
126126
cached
127127
string toString() {
128-
Stages::PointsTo::ref() and
128+
Stages::AST::ref() and
129129
exists(Scope s | s.getEntryNode() = this | result = "Entry node for " + s.toString())
130130
or
131131
exists(Scope s | s.getANormalExit() = this | result = "Exit node for " + s.toString())

python/ql/lib/semmle/python/internal/CachedStages.qll

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ module Stages {
9393
exists(PyFlow::DefinitionNode b)
9494
or
9595
exists(any(PyFlow::SequenceNode n).getElement(_))
96+
or
97+
exists(any(PyFlow::ControlFlowNode c).toString())
9698
}
9799
}
98100

@@ -140,7 +142,6 @@ module Stages {
140142
private import semmle.python.pointsto.Base as PointsToBase
141143
private import semmle.python.types.Object as TypeObject
142144
private import semmle.python.objects.TObject as TObject
143-
private import semmle.python.Flow as Flow
144145
private import semmle.python.objects.ObjectInternal as ObjectInternal
145146
// have to alias since this module is also called PointsTo
146147
private import semmle.python.pointsto.PointsTo as RealPointsTo
@@ -159,8 +160,6 @@ module Stages {
159160
or
160161
exists(TObject::TObject f)
161162
or
162-
exists(any(Flow::ControlFlowNode c).toString())
163-
or
164163
exists(any(ObjectInternal::ObjectInternal o).toString())
165164
or
166165
RealPointsTo::AttributePointsTo::variableAttributePointsTo(_, _, _, _, _)

0 commit comments

Comments
 (0)