Return 400 or 404 instead of server errors for bad URLs
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest4 patches 0 repliesNew
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/4 | layerindex/querysethelper.py: reject an invalid API filter or orderby with a 400layerindex/ tests/ | +44 | 0 replies | |
| 2/4 | layerindex/querysethelper.py: apply the API "orderby" parameterlayerindex/ tests/ | +53 | 0 replies | |
| 3/4 | layerindex: give a 404 for a non-numeric id in a URLlayerindex/ layerindex/ tests/ | +77 | 0 replies | |
| 4/4 | layerindex/middleware.py: reject NUL characters in the URL with a 400docker/ layerindex/ settings.py +1 more | +67 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [layerindex-web][PATCH 0/4] Return 400 or 404 instead of server errors for bad URLs
Fuzzing the URLs of a test instance loaded with a copy of the production database found about 160 requests per pass that gave a 500 and about 350 that gave a 502, from a handful of causes. These fix four of them.
1: Bug 16517: an unknown field in an API "filter" or "orderby" raised a
bare BaseException, which killed the worker; a value of the wrong type, such as filter=id:abc, raised ValueError. Both are now a 400. In Piotr Buliński's analysis of the production access logs from July to November, 909 of the 912 API server errors were malformed filters.
2: Bug 16518: the API never applied "orderby" at all.
3: Bug 16519: a non-numeric id in a URL, or in branch_comparison's
from_branch and to_branch, gave a 500; it is now a 404.
4: Bug 16520: a NUL character in the URL gave a 500 on PostgreSQL. It is
now a 400 on every database.
With these, the fuzz runs give no 500s on PostgreSQL and one on MariaDB, the 4-byte emoji case of bug 16507, which these don't address. The 502s that remain are 5000-character URLs, which uWSGI rejects with its default 4 KB buffer; gunicorn returns a 400 for them.
Each fix comes with tests that fail without it. This applies on master-next, where "layerindex: add an RSS feed of recently published layers" changed the neighbouring line of layerindex/urls.py.
Tim Orling (4):
layerindex/querysethelper.py: reject an invalid API filter or orderby
with a 400
layerindex/querysethelper.py: apply the API "orderby" parameter
layerindex: give a 404 for a non-numeric id in a URL layerindex/middleware.py: reject NUL characters in the URL with a 400
docker/settings.py | 1 + layerindex/middleware.py | 21 +++++++++++- layerindex/querysethelper.py | 41 +++++++++++++++++++---- layerindex/urls.py | 18 +++++----- layerindex/views.py | 32 +++++++++--------- settings.py | 1 + tests/test_nonnumeric_ids.py | 51 ++++++++++++++++++++++++++++ tests/test_null_characters.py | 45 +++++++++++++++++++++++++ tests/test_restapi.py | 62 +++++++++++++++++++++++++++++++++++ 9 files changed, 240 insertions(+), 32 deletions(-) create mode 100644 tests/test_nonnumeric_ids.py create mode 100644 tests/test_null_characters.py
Signature · 1 line
2.56.1