Skip to content

Commit a4de88d

Browse files
committed
Python: Update type-tracking snippet
based on what I learned in #5184
1 parent e0dca2b commit a4de88d

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

python/.vscode/ql.code-snippets

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@
105105
"scope": "ql",
106106
"prefix": "type tracking",
107107
"body": [
108-
"/** Gets a reference to a ${3:thing}. */",
109-
"private DataFlow::Node ${1:myType}(DataFlow::TypeTracker t) {",
108+
"/** Gets a reference to ${3:a thing}. */",
109+
"private DataFlow::LocalSourceNode ${1:myType}(DataFlow::TypeTracker t) {",
110110
" t.start() and",
111111
" result = ${2:value}",
112112
" or",
@@ -115,9 +115,9 @@
115115
" )",
116116
"}",
117117
"",
118-
"/** Gets a reference to a ${3:thing}. */",
118+
"/** Gets a reference to $3. */",
119119
"DataFlow::Node $1() {",
120-
" result = $1(DataFlow::TypeTracker::end())",
120+
" $1(DataFlow::TypeTracker::end()).flowsTo(result)",
121121
"}"
122122
],
123123
"description": "Type tracking predicate",

python/ql/src/semmle/python/dataflow/new/TypeTracker.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ private newtype TTypeTracker = MkTypeTracker(Boolean hasCall, OptionalAttributeN
180180
* It is recommended that all uses of this type are written in the following form,
181181
* for tracking some type `myType`:
182182
* ```
183-
* DataFlow::Node myType(DataFlow::TypeTracker t) {
183+
* DataFlow::LocalSourceNode myType(DataFlow::TypeTracker t) {
184184
* t.start() and
185185
* result = < source of myType >
186186
* or
@@ -189,7 +189,7 @@ private newtype TTypeTracker = MkTypeTracker(Boolean hasCall, OptionalAttributeN
189189
* )
190190
* }
191191
*
192-
* DataFlow::Node myType() { result = myType(DataFlow::TypeTracker::end()) }
192+
* DataFlow::Node myType() { myType(DataFlow::TypeTracker::end()).flowsTo(result) }
193193
* ```
194194
*
195195
* Instead of `result = myType(t2).track(t2, t)`, you can also use the equivalent

0 commit comments

Comments
 (0)