Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
betodealmeida committed Oct 26, 2022
1 parent 999c82a commit a9490b9
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 3 deletions.
2 changes: 1 addition & 1 deletion superset-frontend/src/components/ImportModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ const ImportModelsModal: FunctionComponent<ImportModelsModalProps> = ({
name="modelFile"
id="modelFile"
data-test="model-file-input"
accept=".yaml,.json,.yml,.zip,.pdf"
accept=".yaml,.json,.yml,.zip"
fileList={fileList}
onChange={changeFile}
onRemove={removeFile}
Expand Down
2 changes: 1 addition & 1 deletion superset/queries/saved_queries/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from datetime import datetime
from io import BytesIO
from typing import Any
from zipfile import ZipFile, is_zipfile
from zipfile import is_zipfile, ZipFile

from flask import g, request, Response, send_file
from flask_appbuilder.api import expose, protect, rison, safe
Expand Down
34 changes: 34 additions & 0 deletions tests/unit_tests/databases/api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.",
}
]
},
}
]
}
3 changes: 2 additions & 1 deletion tests/unit_tests/importexport/api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=invalid-name, import-outside-toplevel

# pylint: disable=invalid-name, import-outside-toplevel, unused-argument

import json
from io import BytesIO
Expand Down

0 comments on commit a9490b9

Please sign in to comment.