Skip to content

Commit c207580

Browse files
committed
Python: Add extra FastAPI taint tests
1 parent 17da281 commit c207580

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

python/ql/test/library-tests/frameworks/fastapi/taint_test.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class MyComplexModel(BaseModel):
2020
field: str
2121
main_foo: Foo
2222
other_foos: List[Foo]
23+
nested_foos: List[List[Foo]]
2324

2425

2526
@app.post("/test_taint/{name}/{number}") # $ routeSetup="/test_taint/{name}/{number}"
@@ -38,6 +39,20 @@ async def test_taint(name : str, number : int, also_input: MyComplexModel): # $
3839
also_input.other_foos[0], # $ tainted
3940
also_input.other_foos[0].foo, # $ tainted
4041
[f.foo for f in also_input.other_foos], # $ MISSING: tainted
42+
43+
also_input.nested_foos, # $ tainted
44+
also_input.nested_foos[0], # $ tainted
45+
also_input.nested_foos[0][0], # $ tainted
46+
also_input.nested_foos[0][0].foo, # $ MISSING: tainted
47+
)
48+
49+
other_foos = also_input.other_foos
50+
51+
ensure_tainted(
52+
other_foos, # $ tainted
53+
other_foos[0], # $ tainted
54+
other_foos[0].foo, # $ MISSING: tainted
55+
[f.foo for f in other_foos], # $ MISSING: tainted
4156
)
4257

4358
return "ok" # $ HttpResponse

0 commit comments

Comments
 (0)