Python: FastAPI: Add HTTP header taint example

This commit is contained in:
Rasmus Wriedt Larsen
2021-10-26 15:34:16 +02:00
parent 7619d0fc33
commit 29e3abc977

View File

@@ -73,6 +73,17 @@ async def form_example(username: str = Form(None)): # $ requestHandler routedPar
return "ok" # $ HttpResponse
# --- HTTP headers ---
# see https://fastapi.tiangolo.com/tutorial/header-params/
from fastapi import Header
@app.get("/header-example") # $ routeSetup="/header-example"
async def header_example(user_agent: Optional[str] = Header(None)): # $ requestHandler routedParameter=user_agent
ensure_tainted(user_agent) # $ tainted
return "ok" # $ HttpResponse
# --- file upload ---
# see https://fastapi.tiangolo.com/tutorial/request-files/
# see https://fastapi.tiangolo.com/tutorial/request-files/#uploadfile