Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 09bb300

Browse files
yofftausbn
andauthored
Apply suggestions from code review
Co-authored-by: Taus <[email protected]>
1 parent 4ff2c6d commit 09bb300

2 files changed

Lines changed: 10 additions & 12 deletions

File tree

python/ql/src/semmle/python/dataflow/new/internal/DataFlowPrivate.qll

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,7 +1027,7 @@ predicate subscriptReadStep(CfgNode nodeFrom, Content c, CfgNode nodeTo) {
10271027
* will need to change type if it should be transferred from the LHS to the RHS.
10281028
*
10291029
* Note that (CodeQL modeling of) content does not have to change type on data-flow
1030-
* path _inside_ the LHS, as the different allowed syntaxes here are merely a convenience.
1030+
* paths _inside_ the LHS, as the different allowed syntaxes here are merely a convenience.
10311031
* Consequently, we model all LHS sequences as tuples, which have the more precise content
10321032
* model, making flow to the elements more precise. If an element is a starred varibale,
10331033
* we will have to mutate the content type to be list content.
@@ -1085,8 +1085,8 @@ predicate subscriptReadStep(CfgNode nodeFrom, Content c, CfgNode nodeTo) {
10851085
* flow step.
10861086
*
10871087
* 3. [Read] Content is read from `TIterableSequence(sequence)` into `TIterableElement(sequence)`.
1088-
* As `sequence` is modelled as a tuple, we will not read tuple content as that would allow
1089-
* cross talk.
1088+
* As `sequence` is modeled as a tuple, we will not read tuple content as that would allow
1089+
* crosstalk.
10901090
*
10911091
* 4. [Store] Content is stored from `TIterableElement(sequence)` to `sequence`.
10921092
* Content type is `TupleElementContent` with indices taken from the syntax.
@@ -1096,7 +1096,7 @@ predicate subscriptReadStep(CfgNode nodeFrom, Content c, CfgNode nodeTo) {
10961096
* 5. [Read] Content is read from `sequence` to its elements.
10971097
* a) If the element is a plain variable, the target is the corresponding essa node.
10981098
*
1099-
* b) If the element is itelf a sequence, with control-flow node `seq`, the target is `TIterableSequence(seq)`.
1099+
* b) If the element is itself a sequence, with control-flow node `seq`, the target is `TIterableSequence(seq)`.
11001100
*
11011101
* c) If the element is a starred variable, with control-flow node `v`, the target is `TIterableElement(v)`.
11021102
*
@@ -1191,8 +1191,8 @@ module UnpackingAssignment {
11911191
/**
11921192
* Step 3
11931193
* Data flows from `TIterableSequence(sequence)` into `TIterableElement(sequence)`.
1194-
* As `sequence` is modelled as a tuple, we will not read tuple content as that would allow
1195-
* cross talk.
1194+
* As `sequence` is modeled as a tuple, we will not read tuple content as that would allow
1195+
* crosstalk.
11961196
*/
11971197
predicate unpackingAssignmentConvertingReadStep(Node nodeFrom, Content c, Node nodeTo) {
11981198
exists(UnpackingAssignmentSequenceTarget target |
@@ -1229,7 +1229,7 @@ module UnpackingAssignment {
12291229
* three cases for what `toNode` should be:
12301230
* a) If the element is a plain variable, `toNode` is the corresponding essa node.
12311231
*
1232-
* b) If the element is itelf a sequence, with control-flow node `seq`, `toNode` is `TIterableSequence(seq)`.
1232+
* b) If the element is itself a sequence, with control-flow node `seq`, `toNode` is `TIterableSequence(seq)`.
12331233
*
12341234
* c) If the element is a starred variable, with control-flow node `v`, `toNode` is `TIterableElement(v)`.
12351235
*/

python/ql/src/semmle/python/dataflow/new/internal/DataFlowPublic.qll

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -385,15 +385,13 @@ class IterableSequenceNode extends Node, TIterableSequenceNode {
385385
* read step from the list to IterableElement followed by a store step to the tuple.
386386
*/
387387
class IterableElementNode extends Node, TIterableElementNode {
388-
ControlFlowNode consumer;
388+
CfgNode consumer;
389389

390-
IterableElementNode() { this = TIterableElementNode(consumer) }
390+
IterableElementNode() { this = TIterableElementNode(consumer.getNode()) }
391391

392392
override string toString() { result = "IterableElement" }
393393

394-
override DataFlowCallable getEnclosingCallable() {
395-
result = any(CfgNode node | node = TCfgNode(consumer)).getEnclosingCallable()
396-
}
394+
override DataFlowCallable getEnclosingCallable() { result = consumer.getEnclosingCallable() }
397395

398396
override Location getLocation() { result = consumer.getLocation() }
399397
}

0 commit comments

Comments
 (0)