mirror of
https://github.com/apache/superset.git
synced 2026-04-18 15:44:57 +00:00
fix: check that imports are ZIPs (#21875)
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
# pylint: disable=unused-argument, import-outside-toplevel, line-too-long
|
||||
|
||||
import json
|
||||
from io import BytesIO
|
||||
from typing import Any
|
||||
from uuid import UUID
|
||||
|
||||
@@ -157,3 +158,36 @@ def test_update_with_password_mask(
|
||||
database.encrypted_extra
|
||||
== '{"service_account_info": {"project_id": "yellow-unicorn-314419", "private_key": "SECRET"}}'
|
||||
)
|
||||
|
||||
|
||||
def test_non_zip_import(client: Any, full_api_access: None) -> None:
|
||||
"""
|
||||
Test that non-ZIP imports are not allowed.
|
||||
"""
|
||||
buf = BytesIO(b"definitely_not_a_zip_file")
|
||||
form_data = {
|
||||
"formData": (buf, "evil.pdf"),
|
||||
}
|
||||
response = client.post(
|
||||
"/api/v1/database/import/",
|
||||
data=form_data,
|
||||
content_type="multipart/form-data",
|
||||
)
|
||||
assert response.status_code == 422
|
||||
assert response.json == {
|
||||
"errors": [
|
||||
{
|
||||
"message": "Not a ZIP file",
|
||||
"error_type": "GENERIC_COMMAND_ERROR",
|
||||
"level": "warning",
|
||||
"extra": {
|
||||
"issue_codes": [
|
||||
{
|
||||
"code": 1010,
|
||||
"message": "Issue 1010 - Superset encountered an error while running a command.",
|
||||
}
|
||||
]
|
||||
},
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user