Skip to content

Commit f3ce393

Browse files
committed
Python: Add AdditionalTaintStep to type-tracking class snippet
I know that the TODO about not having the tools to handling `meth = obj.meth; meth()` is outdated now that we `DataFlow::MethodCallNode`, but I'm planning to deal with that later on ;)
1 parent dac71de commit f3ce393

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

python/.vscode/ql.code-snippets

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,42 @@
195195
"",
196196
" /** Gets a reference to an instance of `${TM_SELECTED_TEXT}`. */",
197197
" DataFlow::Node instance() { instance(DataFlow::TypeTracker::end()).flowsTo(result) }",
198+
"",
199+
" /**",
200+
" * Taint propagation for `${TM_SELECTED_TEXT}`.",
201+
" */",
202+
" private class AdditionalTaintStep extends TaintTracking::AdditionalTaintStep {",
203+
" override predicate step(DataFlow::Node nodeFrom, DataFlow::Node nodeTo) {",
204+
" // Methods",
205+
" //",
206+
" // TODO: When we have tools that make it easy, model these properly to handle",
207+
" // `meth = obj.meth; meth()`. Until then, we'll use this more syntactic approach",
208+
" // (since it allows us to at least capture the most common cases).",
209+
" nodeFrom = instance() and",
210+
" exists(DataFlow::AttrRead attr | attr.getObject() = nodeFrom |",
211+
" // normal (non-async) methods",
212+
" attr.getAttributeName() in [\"TODO\"] and",
213+
" nodeTo.(DataFlow::CallCfgNode).getFunction() = attr",
214+
" or",
215+
" // async methods",
216+
" exists(Await await, DataFlow::CallCfgNode call |",
217+
" attr.getAttributeName() in [\"TODO\"] and",
218+
" call.getFunction() = attr and",
219+
" await.getValue() = call.asExpr() and",
220+
" nodeTo.asExpr() = await",
221+
" )",
222+
" )",
223+
" or",
224+
" // Attributes",
225+
" nodeFrom = instance() and",
226+
" nodeTo.(DataFlow::AttrRead).getObject() = nodeFrom and",
227+
" nodeTo.(DataFlow::AttrRead).getAttributeName() in [\"TODO\"]",
228+
" }",
229+
" }",
198230
"}",
199231
],
200232
"description": "Type tracking class (select full class path before inserting)",
201233
},
202-
203234
"API graph .getMember chain": {
204235
"scope": "ql",
205236
"prefix": "api graph .getMember chain",

0 commit comments

Comments
 (0)