Python taint-tracking: update test results.

This commit is contained in:
Mark Shannon
2019-08-05 12:03:02 +01:00
parent a7845ae0e1
commit 1addfaac1a
16 changed files with 36 additions and 17 deletions

View File

@@ -700,6 +700,15 @@ module DataFlow {
abstract Location getLocation();
AstNode asAstNode() {
result = this.asCfgNode().getNode()
}
/** For backwards compatibility -- Use asAstNode() instead */
deprecated AstNode getNode() {
result = this.asAstNode()
}
}
class CfgNode extends Node, TCfgNode {

View File

@@ -10,7 +10,14 @@ class SimpleTest extends TaintKind {
}
class SimpleConfig extends TaintTracking::Configuration {
abstract class TestConfig extends TaintTracking::Configuration {
bindingset[this]
TestConfig() { any() }
}
class SimpleConfig extends TestConfig {
SimpleConfig() { this = "Simple config" }
@@ -49,7 +56,7 @@ class BasicCustomTaint extends TaintKind {
}
class BasicCustomConfig extends TaintTracking::Configuration {
class BasicCustomConfig extends TestConfig {
BasicCustomConfig() { this = "Basic custom config" }
@@ -99,7 +106,7 @@ class Scissors extends TaintKind {
}
class RockPaperScissorConfig extends TaintTracking::Configuration {
class RockPaperScissorConfig extends TestConfig {
RockPaperScissorConfig() { this = "Rock-paper-scissors config" }
@@ -145,7 +152,7 @@ class TaintCarrier extends TaintKind {
}
class TaintCarrierConfig extends TaintTracking::Configuration {
class TaintCarrierConfig extends TestConfig {
TaintCarrierConfig() { this = "Taint carrier config" }
@@ -327,5 +334,3 @@ class TaintIterableSource extends TaintSource {
}

View File

@@ -9,5 +9,6 @@ import semmle.python.dataflow.Implementation
from TaintTrackingImplementation config, TaintTrackingNode src, CallNode call,
TaintTrackingContext caller, CallableValue pyfunc, int arg, AttributePath path, TaintKind kind
where config.callWithTaintedArgument(src, call, caller, pyfunc, arg, path, kind)
where config instanceof TestConfig and
config.callWithTaintedArgument(src, call, caller, pyfunc, arg, path, kind)
select config, src, call, caller, pyfunc, arg, path, kind

View File

@@ -5,5 +5,6 @@ import TaintLib
from TaintTrackingNode n
where n.getConfiguration() instanceof TestConfig
select n.getTaintKind(), n.getLocation().toString(), n.getNode().toString(), n.getPath().toString(), n.getContext().toString()

View File

@@ -2,7 +2,7 @@ import python
import semmle.python.security.TaintTracking
import TaintLib
from TaintTracking::Configuration config, DataFlow::Node sink, TaintKind kind
from TestConfig config, DataFlow::Node sink, TaintKind kind
where config.isSink(sink, kind)
select config, sink.getLocation().toString(), sink.getLocation().getStartLine(), sink.toString(), kind

View File

@@ -2,7 +2,7 @@ import python
import semmle.python.security.TaintTracking
import TaintLib
from TaintTracking::Configuration config, DataFlow::Node source, TaintKind kind
from TestConfig config, DataFlow::Node source, TaintKind kind
where config.isSource(source, kind)
select config, source.getLocation().toString(), source.getLocation().getStartLine(), source.toString(), kind

View File

@@ -4,7 +4,7 @@ import TaintLib
import semmle.python.dataflow.Implementation
from TaintTrackingNode n, TaintTrackingNode s, TaintTracking::Configuration config
from TaintTrackingNode n, TaintTrackingNode s, TestConfig config
where s = n.getASuccessor() and config = n.getConfiguration()
select
config + ":",

View File

@@ -1,2 +1 @@
ERROR: getNode() cannot be resolved for type Node (TestNode.ql:5,69-76)
ERROR: getTrackedValue() cannot be resolved for type TaintedNode (TestNode.ql:5,10-25)
WARNING: Predicate getNode has been deprecated and may be removed in future (TestNode.ql:5,77-84)

View File

@@ -2,4 +2,4 @@ import python
import Config
from TaintedNode n
select n.getTrackedValue(), n.getLocation().toString(), n.getNode().getNode().toString(), n.getContext()
select "Taint " + n.getTaintKind(), n.getLocation().toString(), n.getNode().getNode().toString(), n.getContext()

View File

@@ -1,3 +1,4 @@
WARNING: Predicate getNode has been deprecated and may be removed in future (TestNode.ql:8,43-50)
| test.py:10:11:10:47 | test.py:10 | MyException() | exception.kind |
| test.py:15:25:15:25 | test.py:15 | e | exception.kind |
| test.py:16:13:16:34 | test.py:16 | Attribute() | exception.info |

View File

@@ -1,3 +1,5 @@
WARNING: Predicate getNode has been deprecated and may be removed in future (TestStep.ql:12,74-81)
WARNING: Predicate getNode has been deprecated and may be removed in future (TestStep.ql:14,74-81)
| Taint [exception.info] | test.py:19 | Attribute() | | --> | Taint [exception.info] | test.py:21 | t | |
| Taint [exception.info] | test.py:19 | Attribute() | | --> | Taint [exception.info] | test.py:27 | t | |
| Taint [exception.info] | test.py:20 | Attribute() | | --> | Taint [exception.info] | test.py:27 | u | |

View File

@@ -9,6 +9,6 @@ where
not n.getLocation().getFile().inStdlib() and
not s.getLocation().getFile().inStdlib()
select
n.getTrackedValue(), n.getLocation().toString(), n.getNode().getNode().toString(), n.getContext(),
"Taint " + n.getTaintKind(), n.getLocation().toString(), n.getNode().getNode().toString(), n.getContext(),
" --> ",
s.getTrackedValue(), s.getLocation().toString(), s.getNode().getNode().toString(), s.getContext()
"Taint " + n.getTaintKind(), s.getLocation().toString(), s.getNode().getNode().toString(), s.getContext()

View File

@@ -1,3 +1,4 @@
WARNING: Predicate getNode has been deprecated and may be removed in future (/home/mark/repos/ql/python/ql/test/library-tests/web/turbogears/Taint.ql:12,54-61)
| ../../../query-tests/Security/lib/bottle.py:64 | LocalRequest() | bottle.request |
| ../../../query-tests/Security/lib/bottle.py:64 | request | bottle.request |
| ../../../query-tests/Security/lib/bottle.py:68 | url | externally controlled string |

View File

@@ -1 +0,0 @@
| test.py:17 | Attribute() | externally controlled string |

View File

@@ -1,3 +1,4 @@
WARNING: Predicate getNode has been deprecated and may be removed in future (Taint.ql:12,54-61)
| test.py:9 | req | falcon.request |
| test.py:9 | resp | falcon.response |
| test.py:10 | Attribute | file[externally controlled string] |
@@ -8,7 +9,6 @@
| test.py:12 | resp | falcon.response |
| test.py:13 | Dict | {json[externally controlled string]} |
| test.py:15 | result | json[externally controlled string] |
| test.py:17 | resp | falcon.response |
| test.py:17 | result | {json[externally controlled string]} |
| test.py:19 | req | falcon.request |
| test.py:19 | resp | falcon.response |

View File

@@ -1,3 +1,4 @@
WARNING: Predicate getNode has been deprecated and may be removed in future (Taint.ql:12,54-61)
| test.py:18 | b | externally controlled string |
| test.py:19 | BinaryExpr | [externally controlled string] |
| test.py:19 | BinaryExpr | externally controlled string |