Skip to content

Commit a6db9ef

Browse files
authored
Merge pull request github#1756 from markshannon/python-forward-compatible-taint-api
Python points-to: add .getAstNode() method to TaintedNode
2 parents eb39346 + 453ae19 commit a6db9ef

File tree

9 files changed

+14
-9
lines changed

9 files changed

+14
-9
lines changed

python/ql/src/semmle/python/security/TaintTracking.qll

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,11 @@ class TaintedNode extends TTaintedNode {
665665
this = TTaintedNode_(_, _, result)
666666
}
667667

668+
/** Get the AST node for this node. */
669+
AstNode getAstNode() {
670+
result = this.getNode().getNode()
671+
}
672+
668673
/** Gets the data-flow context for this node. */
669674
CallContext getContext() {
670675
this = TTaintedNode_(_, result, _)

python/ql/test/3/library-tests/web/django/Taint.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ import semmle.python.security.strings.Untrusted
1010

1111
from TaintedNode node
1212

13-
select node.getLocation().toString(), node.getNode().getNode().toString(), node.getTaintKind().toString()
13+
select node.getLocation().toString(), node.getAstNode().toString(), node.getTaintKind().toString()
1414

python/ql/test/library-tests/taint/strings/DistinctStringKinds.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ class ExternalStringSource extends TaintSource {
3535

3636
from TaintedNode n
3737
where n.getLocation().getFile().getName().matches("%test.py")
38-
select n.getTrackedValue(), n.getLocation().toString(), n.getNode().getNode(), n.getContext()
38+
select n.getTrackedValue(), n.getLocation().toString(), n.getAstNode(), n.getContext()
3939

python/ql/test/library-tests/taint/strings/TestNode.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ import Taint
55

66
from TaintedNode n
77
where n.getLocation().getFile().getName().matches("%test.py")
8-
select n.getTrackedValue(), n.getLocation().toString(), n.getNode().getNode(), n.getContext()
8+
select n.getTrackedValue(), n.getLocation().toString(), n.getAstNode(), n.getContext()
99

python/ql/test/library-tests/taint/strings/TestStep.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ where n.getLocation().getFile().getName().matches("%test.py") and
88
s.getLocation().getFile().getName().matches("%test.py") and
99
s = n.getASuccessor()
1010
select
11-
n.getTrackedValue(), n.getLocation().toString(), n.getNode().getNode(), n.getContext(),
11+
n.getTrackedValue(), n.getLocation().toString(), n.getAstNode(), n.getContext(),
1212
" --> ",
13-
s.getTrackedValue(), s.getLocation().toString(), s.getNode().getNode(), s.getContext()
13+
s.getTrackedValue(), s.getLocation().toString(), s.getAstNode(), s.getContext()

python/ql/test/library-tests/web/bottle/Taint.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ import semmle.python.security.strings.Untrusted
99

1010
from TaintedNode node
1111

12-
select node.getLocation().toString(), node.getNode().getNode().toString(), node.getTaintKind()
12+
select node.getLocation().toString(), node.getAstNode().toString(), node.getTaintKind()
1313

python/ql/test/library-tests/web/falcon/Taint.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ import semmle.python.security.strings.Untrusted
99

1010
from TaintedNode node
1111
where node.getLocation().getFile().getName().matches("%falcon/test.py")
12-
select node.getLocation().toString(), node.getNode().getNode().toString(), node.getTaintKind()
12+
select node.getLocation().toString(), node.getAstNode().toString(), node.getTaintKind()
1313

python/ql/test/library-tests/web/turbogears/Taint.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ import semmle.python.security.strings.Untrusted
99

1010
from TaintedNode node
1111

12-
select node.getLocation().toString(), node.getNode().getNode().toString(), node.getTaintKind()
12+
select node.getLocation().toString(), node.getAstNode().toString(), node.getTaintKind()
1313

python/ql/test/query-tests/Security/CWE-327/TestNode.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ import semmle.python.security.SensitiveData
66
import semmle.python.security.Crypto
77

88
from TaintedNode n, AstNode src
9-
where src = n.getNode().getNode() and src.getLocation().getFile().getName().matches("%test%")
9+
where src = n.getAstNode() and src.getLocation().getFile().getName().matches("%test%")
1010
select n.getTrackedValue(), n.getLocation(), src, n.getContext()

0 commit comments

Comments
 (0)