From a4de88d39c6370cec253966826d7d08ec66c859f Mon Sep 17 00:00:00 2001 From: Rasmus Wriedt Larsen Date: Wed, 17 Feb 2021 13:11:40 +0100 Subject: [PATCH] Python: Update type-tracking snippet based on what I learned in https://github.com/github/codeql/pull/5184 --- python/.vscode/ql.code-snippets | 8 ++++---- python/ql/src/semmle/python/dataflow/new/TypeTracker.qll | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/python/.vscode/ql.code-snippets b/python/.vscode/ql.code-snippets index 80c6ef1290d..6ccb9aa6657 100644 --- a/python/.vscode/ql.code-snippets +++ b/python/.vscode/ql.code-snippets @@ -105,8 +105,8 @@ "scope": "ql", "prefix": "type tracking", "body": [ - "/** Gets a reference to a ${3:thing}. */", - "private DataFlow::Node ${1:myType}(DataFlow::TypeTracker t) {", + "/** Gets a reference to ${3:a thing}. */", + "private DataFlow::LocalSourceNode ${1:myType}(DataFlow::TypeTracker t) {", " t.start() and", " result = ${2:value}", " or", @@ -115,9 +115,9 @@ " )", "}", "", - "/** Gets a reference to a ${3:thing}. */", + "/** Gets a reference to $3. */", "DataFlow::Node $1() {", - " result = $1(DataFlow::TypeTracker::end())", + " $1(DataFlow::TypeTracker::end()).flowsTo(result)", "}" ], "description": "Type tracking predicate", diff --git a/python/ql/src/semmle/python/dataflow/new/TypeTracker.qll b/python/ql/src/semmle/python/dataflow/new/TypeTracker.qll index b6de3cd7764..be9b42d470e 100644 --- a/python/ql/src/semmle/python/dataflow/new/TypeTracker.qll +++ b/python/ql/src/semmle/python/dataflow/new/TypeTracker.qll @@ -180,7 +180,7 @@ private newtype TTypeTracker = MkTypeTracker(Boolean hasCall, OptionalAttributeN * It is recommended that all uses of this type are written in the following form, * for tracking some type `myType`: * ``` - * DataFlow::Node myType(DataFlow::TypeTracker t) { + * DataFlow::LocalSourceNode myType(DataFlow::TypeTracker t) { * t.start() and * result = < source of myType > * or @@ -189,7 +189,7 @@ private newtype TTypeTracker = MkTypeTracker(Boolean hasCall, OptionalAttributeN * ) * } * - * DataFlow::Node myType() { result = myType(DataFlow::TypeTracker::end()) } + * DataFlow::Node myType() { myType(DataFlow::TypeTracker::end()).flowsTo(result) } * ``` * * Instead of `result = myType(t2).track(t2, t)`, you can also use the equivalent