♻️(backend) stop returning a 415 on cors-proxy endpoint

When the content-type return by the targeted url is not an image, the
endpoint was returning a 415 status code. We don't want to provide this
info anymore avoid disclosing information an attacker can use.
This commit is contained in:
Manuel Raynaud
2025-12-09 17:14:39 +01:00
parent f28da7c2c2
commit 2556823a69
2 changed files with 4 additions and 2 deletions

View File

@@ -1810,7 +1810,8 @@ class DocumentViewSet(
if not content_type.startswith("image/"):
return drf.response.Response(
status=status.HTTP_415_UNSUPPORTED_MEDIA_TYPE
{"detail": "Invalid URL used."},
status=status.HTTP_400_BAD_REQUEST
)
# Use StreamingHttpResponse with the response's iter_content to properly stream the data

View File

@@ -186,7 +186,8 @@ def test_api_docs_cors_proxy_unsupported_media_type(mock_getaddrinfo):
response = client.get(
f"/api/v1.0/documents/{document.id!s}/cors-proxy/?url={url_to_fetch}"
)
assert response.status_code == 415
assert response.status_code == 400
assert response.json() == {"detail": "Invalid URL used."}
@pytest.mark.parametrize(