File tree Expand file tree Collapse file tree 1 file changed +48
-0
lines changed
python/ql/test/library-tests/frameworks/aiohttp Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change
1
+ """
2
+ This file is a test of an extra data-flow step that we want to have for
3
+ aiohttp.web.Application
4
+
5
+ We don't really have an established way to test extra data-flow steps in external
6
+ libraries right now, so for now I've just used our normal taint-flow testing ¯\_(ツ)_/¯
7
+
8
+ see https://docs.aiohttp.org/en/stable/web_advanced.html#application-s-config
9
+ """
10
+
11
+ from aiohttp import web
12
+
13
+ # to make code runable
14
+ TAINTED_STRING = "TAINTED_STRING"
15
+ def ensure_tainted (* args , ** kwargs ):
16
+ pass
17
+
18
+ ensure_tainted (
19
+ TAINTED_STRING # $ tainted
20
+ )
21
+
22
+
23
+ async def example (request : web .Request ): # $ requestHandler
24
+ return web .Response (text = f'example { request .app ["foo" ]= } ' ) # $ HttpResponse
25
+
26
+
27
+ async def also_works (request : web .Request ): # $ requestHandler
28
+ return web .Response (text = f'also_works { request .config_dict ["foo" ]= } ' ) # $ HttpResponse
29
+
30
+
31
+ async def taint_test (request : web .Request ): # $ requestHandler
32
+ ensure_tainted (
33
+ request .app ["ts" ], # $ MISSING: tainted
34
+ request .config_dict ["ts" ], # $ MISSING: tainted
35
+ )
36
+ return web .Response (text = "ok" ) # $ HttpResponse
37
+
38
+
39
+ app = web .Application ()
40
+ app .router .add_get ("" , example ) # $ routeSetup=""
41
+ app .router .add_get ("/also-works" , also_works ) # $ routeSetup="/also-works"
42
+ app .router .add_get ("/taint-test" , taint_test ) # $ routeSetup="/taint-test"
43
+ app ["foo" ] = 42
44
+ app ["ts" ] = TAINTED_STRING
45
+
46
+
47
+ if __name__ == "__main__" :
48
+ web .run_app (app )
You can’t perform that action at this time.
0 commit comments