Skip to content

Commit c56ff98

Browse files
yofftausbn
andauthored
Apply suggestions from code review
Co-authored-by: Taus <tausbn@github.com>
1 parent ef4461c commit c56ff98

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

python/ql/src/experimental/dataflow/internal/DataFlowPrivate.qll

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class DataFlowCfgNode extends ControlFlowNode {
1818

1919
/** A data flow node for which we should synthesise an associated pre-update node. */
2020
abstract class NeedsSyntheticPreUpdateNode extends Node {
21-
/** This will figure in the texttual representation of the synthesised pre-update node. */
21+
/** A label for this kind of node. This will figure in the textual representation of the synthesized pre-update node. */
2222
abstract string label();
2323
}
2424

@@ -39,7 +39,7 @@ class SyntheticPreUpdateNode extends Node, TSyntheticPreUpdateNode {
3939

4040
/** A data flow node for which we should synthesise an associated post-update node. */
4141
abstract class NeedsSyntheticPostUpdateNode extends Node {
42-
/** This will figure in the texttual representation of the synthesised post-update node. */
42+
/** A label for this kind of node. This will figure in the textual representation of the synthesized post-update node. */
4343
abstract string label();
4444
}
4545

@@ -83,7 +83,7 @@ class ReadPreUpdateNode extends NeedsSyntheticPostUpdateNode, CfgNode {
8383
override string label() { result = "read" }
8484
}
8585

86-
/** A post-update node is synthesised for all nodes which satisfy `NeedsSyntheticPostUpdateNode`. */
86+
/** A post-update node is synthesized for all nodes which satisfy `NeedsSyntheticPostUpdateNode`. */
8787
class SyntheticPostUpdateNode extends PostUpdateNode, TSyntheticPostUpdateNode {
8888
NeedsSyntheticPostUpdateNode pre;
8989

@@ -99,7 +99,7 @@ class SyntheticPostUpdateNode extends PostUpdateNode, TSyntheticPostUpdateNode {
9999
}
100100

101101
/**
102-
* Calls to constructors are treated as post-update nodes for the synthesised argument
102+
* Calls to constructors are treated as post-update nodes for the synthesized argument
103103
* that is mapped to the `self` parameter. That way, constructor calls represent the value of the
104104
* object after the constructor (currently only `__init__`) has run.
105105
*/
@@ -305,7 +305,7 @@ class DataFlowModuleScope extends DataFlowCallable, TModule {
305305
*
306306
* An `__init__` method can also be called directly, so that the callable can be targeted by
307307
* different types of calls. In that case, the parameter mappings will be different,
308-
* as the class call will synthesise an argument node to be mapped to the `self` parameter.
308+
* as the class call will synthesize an argument node to be mapped to the `self` parameter.
309309
*
310310
* A call corresponding to a special method call is handled by the corresponding `SpecialMethodCallNode`.
311311
*/
@@ -598,16 +598,18 @@ predicate comprehensionStoreStep(CfgNode nodeFrom, Content c, CfgNode nodeTo) {
598598
}
599599

600600
/**
601-
* In
601+
* Holds if `nodeFrom` flows into an attribute (corresponding to `c`) of `nodeTo` via an attribute assignment.
602+
*
603+
* For example, in
602604
* ```python
603605
* obj.foo = x
604606
* ```
605607
* data flows from `x` to (the post-update node for) `obj` via assignment to `foo`.
606608
*/
607-
predicate attributeStoreStep(CfgNode nodeFrom, Content c, PostUpdateNode nodeTo) {
609+
predicate attributeStoreStep(CfgNode nodeFrom, AttributeContent c, PostUpdateNode nodeTo) {
608610
exists(AttrNode attr |
609611
nodeFrom.asCfgNode() = attr.(DefinitionNode).getValue() and
610-
attr.getName() = c.(AttributeContent).getAttribute() and
612+
attr.getName() = c.getAttribute() and
611613
attr.getObject() = nodeTo.getPreUpdateNode().(CfgNode).getNode()
612614
)
613615
}
@@ -710,17 +712,19 @@ predicate comprehensionReadStep(CfgNode nodeFrom, Content c, EssaNode nodeTo) {
710712
}
711713

712714
/**
713-
* In
715+
* Holds if `nodeTo` is a read of an attribute (corresponding to `c`) of the object in `nodeFrom`.
716+
*
717+
* For example, in
714718
* ```python
715719
* obj.foo
716720
* ```
717721
* data flows from `obj` to `obj.foo` via a read from `foo`.
718722
*/
719-
predicate attributeReadStep(CfgNode nodeFrom, Content c, CfgNode nodeTo) {
723+
predicate attributeReadStep(CfgNode nodeFrom, AttributeContent c, CfgNode nodeTo) {
720724
exists(AttrNode attr |
721-
nodeTo.asCfgNode() = attr and
722725
nodeFrom.asCfgNode() = attr.getObject() and
723-
attr.getName() = c.(AttributeContent).getAttribute() and
726+
nodeTo.asCfgNode() = attr and
727+
attr.getName() = c.getAttribute() and
724728
attr.isLoad()
725729
)
726730
}

python/ql/test/experimental/dataflow/coverage/argumentRouting1.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class ArgumentRoutingConfig extends DataFlow::Configuration {
1212
exists(AssignmentDefinition def, DataFlowPrivate::DataFlowCall call |
1313
def.getVariable() = node.(DataFlow::EssaNode).getVar() and
1414
def.getValue() = call.getNode() and
15-
call.getNode().(CallNode).getNode().(Call).toString().matches("With\\_%") // TODO: Do not rely on toString
15+
call.getNode().(CallNode).getFunction().(NameNode).getId().matches("With\\_%")
1616
) and
1717
node.(DataFlow::EssaNode).getVar().getName().matches("with\\_%")
1818
}

0 commit comments

Comments
 (0)