mirror of
https://github.com/github/codeql.git
synced 2026-05-05 13:45:19 +02:00
Python: Add tests for turbogears.
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
| test.py:7:5:7:32 | Function onerror |
|
||||
| test.py:13:5:13:50 | Function ok_validated |
|
||||
| test.py:18:5:18:57 | Function partially_validated |
|
||||
| test.py:22:5:22:51 | Function not_validated |
|
||||
@@ -0,0 +1,9 @@
|
||||
|
||||
|
||||
import python
|
||||
|
||||
import semmle.python.web.turbogears.TurboGears
|
||||
|
||||
from TurboGearsControllerMethod m
|
||||
select m
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
| test.py:8 | BinaryExpr | externally controlled string |
|
||||
| test.py:14 | BinaryExpr | externally controlled string |
|
||||
| test.py:19 | BinaryExpr | externally controlled string |
|
||||
| test.py:23 | BinaryExpr | externally controlled string |
|
||||
10
python/ql/test/library-tests/web/turbogears/Sinks.ql
Normal file
10
python/ql/test/library-tests/web/turbogears/Sinks.ql
Normal file
@@ -0,0 +1,10 @@
|
||||
|
||||
import python
|
||||
|
||||
import semmle.python.web.HttpRequest
|
||||
import semmle.python.web.HttpResponse
|
||||
import semmle.python.security.strings.Untrusted
|
||||
|
||||
from TaintSink sink, TaintKind kind
|
||||
where sink.sinks(kind)
|
||||
select sink.getLocation().toString(), sink.(ControlFlowNode).getNode().toString(), kind
|
||||
@@ -0,0 +1,3 @@
|
||||
| test.py:18 | b | externally controlled string |
|
||||
| test.py:22 | a | externally controlled string |
|
||||
| test.py:22 | b | externally controlled string |
|
||||
10
python/ql/test/library-tests/web/turbogears/Sources.ql
Normal file
10
python/ql/test/library-tests/web/turbogears/Sources.ql
Normal file
@@ -0,0 +1,10 @@
|
||||
|
||||
import python
|
||||
|
||||
import semmle.python.web.HttpRequest
|
||||
import semmle.python.security.strings.Untrusted
|
||||
|
||||
|
||||
from TaintSource src, TaintKind kind
|
||||
where src.isSourceOf(kind)
|
||||
select src.getLocation().toString(), src.(ControlFlowNode).getNode().toString(), kind
|
||||
12
python/ql/test/library-tests/web/turbogears/Taint.expected
Normal file
12
python/ql/test/library-tests/web/turbogears/Taint.expected
Normal file
@@ -0,0 +1,12 @@
|
||||
| test.py:18 | b | externally controlled string |
|
||||
| test.py:19 | BinaryExpr | [externally controlled string] |
|
||||
| test.py:19 | BinaryExpr | externally controlled string |
|
||||
| test.py:19 | Tuple | [externally controlled string] |
|
||||
| test.py:19 | b | externally controlled string |
|
||||
| test.py:22 | a | externally controlled string |
|
||||
| test.py:22 | b | externally controlled string |
|
||||
| test.py:23 | BinaryExpr | [externally controlled string] |
|
||||
| test.py:23 | BinaryExpr | externally controlled string |
|
||||
| test.py:23 | Tuple | [externally controlled string] |
|
||||
| test.py:23 | a | externally controlled string |
|
||||
| test.py:23 | b | externally controlled string |
|
||||
13
python/ql/test/library-tests/web/turbogears/Taint.ql
Normal file
13
python/ql/test/library-tests/web/turbogears/Taint.ql
Normal file
@@ -0,0 +1,13 @@
|
||||
|
||||
import python
|
||||
|
||||
|
||||
import semmle.python.web.HttpRequest
|
||||
import semmle.python.web.HttpResponse
|
||||
import semmle.python.security.strings.Untrusted
|
||||
|
||||
|
||||
from TaintedNode node
|
||||
|
||||
select node.getLocation().toString(), node.getNode().getNode().toString(), node.getTaintKind()
|
||||
|
||||
2
python/ql/test/library-tests/web/turbogears/options
Normal file
2
python/ql/test/library-tests/web/turbogears/options
Normal file
@@ -0,0 +1,2 @@
|
||||
semmle-extractor-options: --max-import-depth=3 --lang=3 -p ../../../query-tests/Security/lib/
|
||||
optimize: true
|
||||
23
python/ql/test/library-tests/web/turbogears/test.py
Normal file
23
python/ql/test/library-tests/web/turbogears/test.py
Normal file
@@ -0,0 +1,23 @@
|
||||
|
||||
from tg import request, validate, expose, TGController
|
||||
from formencode import validators
|
||||
|
||||
class RootController(TGController):
|
||||
@expose()
|
||||
def onerror(self, **kwargs):
|
||||
return 'An error occurred: %s' % request.validation['errors']
|
||||
|
||||
@expose()
|
||||
@validate({"a": validators.Int(not_empty=True), "b": validators.Email},
|
||||
error_handler=onerror)
|
||||
def ok_validated(self, a=None, b=None, *args):
|
||||
return 'Values: %s, %s, %s' % (a, b, args)
|
||||
|
||||
@expose()
|
||||
@validate({"a": validators.Int(not_empty=True)})
|
||||
def partially_validated(self, a=None, b=None, *args):
|
||||
return 'Values: %s, %s, %s' % (a, b, args)
|
||||
|
||||
@expose()
|
||||
def not_validated(self, a=None, b=None, *args):
|
||||
return 'Values: %s, %s, %s' % (a, b, args)
|
||||
Reference in New Issue
Block a user