Skip to content

Commit b02fb90

Browse files
committed
Python: Add getObject(string attrName) to AttrRef
Now that I got started adding small things that are nice, I've been missing this one (that is available on an `AttrNode`).
1 parent 9137f04 commit b02fb90

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@ abstract class AttrRef extends Node {
1717
*/
1818
abstract Node getObject();
1919

20+
/**
21+
* Gets the data flow node corresponding to the object whose attribute named
22+
* `attrName` is being read or written.
23+
*/
24+
Node getObject(string attrName) {
25+
result = this.getObject() and
26+
attrName = this.getAttributeName()
27+
}
28+
2029
/**
2130
* Gets the expression node that defines the attribute being accessed, if any. This is
2231
* usually an identifier or literal.

0 commit comments

Comments
 (0)