Starlette 1.6.0
Last reviewed Sep 20, 2026
Prompt Details
Prompt Composition
2prompts
- Python 3155 lines · 3.8K tokens
- Starlette 1.6.083 lines · 4.2K tokens
Total238 lines · 8K tokens
CWE Coverage
- 20
- 22
- 23
- 36
- 59
- 78
- 79
- 89
- 95
- 113
- 117
- 203
- 208
- 209
- 214
- 250
- 287
- 295
- 306
- 319
- 328
- 338
- 347
- 352
- 367
- 379
- 409
- 416
- 426
- 427
- 434
- 470
- 488
- 502
- 524
- 532
- 552
- 601
- 611
- 613
- 614
- 639
- 674
- 732
- 770
- 772
- 776
- 807
- 829
- 862
- 916
- 918
- 942
- 1004
- 1104
- 1275
- 1333
- 1395
Prompt Preview
Apply the Python 3 prompt first. Target Starlette 1.6.0 on a maintained Python 3.10–3.14 runtime. These rules address Starlette's ASGI boundaries and APIs; retain the baseline controls for database queries, outbound requests, dependencies, and secrets.
Routing, middleware, and proxy trust
- Declare
Route,Mount, andHostentries in trusted code, put specific paths before catch-all routes, and specify permitted HTTP methods. A route permittingGETalso acceptsHEAD;HTTPEndpointcan dispatchHEADtoget(). Apply the same authorization and keep both methods free of state changes. - Cover every protected mount, host, static subtree, fallback, and
WebSocketRoutewith authorization. Middleware attached to one route or mount does not protect siblings; a bareRouterdoes not supply theStarletteapplication's default error middleware. - Review the actual stack:
ServerErrorMiddleware, optional applicationRequestBodyLimitMiddleware, user middleware in list order, thenExceptionMiddlewareand routing. PlaceSessionMiddlewarebeforeAuthenticationMiddlewarewhen the backend reads sessions. Return denial responses directly from application middleware instead of relying on endpointHTTPExceptionhandling. - Use pure ASGI middleware for controls that must cover both
httpandwebsocketscopes, and passlifespanthrough.BaseHTTPMiddlewarehandles HTTP only and prevents endpointContextVarchanges from propagating back to outer middleware; do not base authorization or audit identity on that propagation. - Keep connection-specific identity,