fix: ignore system files on import (#12526)
This commit is contained in:
parent
192832c262
commit
7bef5ab4d2
|
|
@ -63,7 +63,7 @@ from superset.charts.schemas import (
|
|||
thumbnail_query_schema,
|
||||
)
|
||||
from superset.commands.exceptions import CommandInvalidError
|
||||
from superset.commands.importers.v1.utils import is_valid_config, remove_root
|
||||
from superset.commands.importers.v1.utils import get_contents_from_bundle
|
||||
from superset.constants import MODEL_API_RW_METHOD_PERMISSION_MAP, RouteMethod
|
||||
from superset.exceptions import SupersetSecurityException
|
||||
from superset.extensions import event_logger
|
||||
|
|
@ -1013,11 +1013,7 @@ class ChartRestApi(BaseSupersetModelRestApi):
|
|||
if not upload:
|
||||
return self.response_400()
|
||||
with ZipFile(upload) as bundle:
|
||||
contents = {
|
||||
remove_root(file_name): bundle.read(file_name).decode()
|
||||
for file_name in bundle.namelist()
|
||||
if is_valid_config(file_name)
|
||||
}
|
||||
contents = get_contents_from_bundle(bundle)
|
||||
|
||||
passwords = (
|
||||
json.loads(request.form["passwords"])
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
import logging
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict
|
||||
from zipfile import ZipFile
|
||||
|
||||
import yaml
|
||||
from marshmallow import fields, Schema, validate
|
||||
|
|
@ -87,3 +88,11 @@ def is_valid_config(file_name: str) -> bool:
|
|||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def get_contents_from_bundle(bundle: ZipFile) -> Dict[str, str]:
|
||||
return {
|
||||
remove_root(file_name): bundle.read(file_name).decode()
|
||||
for file_name in bundle.namelist()
|
||||
if is_valid_config(file_name)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ from werkzeug.wsgi import FileWrapper
|
|||
|
||||
from superset import is_feature_enabled, thumbnail_cache
|
||||
from superset.commands.exceptions import CommandInvalidError
|
||||
from superset.commands.importers.v1.utils import remove_root
|
||||
from superset.commands.importers.v1.utils import get_contents_from_bundle
|
||||
from superset.constants import MODEL_API_RW_METHOD_PERMISSION_MAP, RouteMethod
|
||||
from superset.dashboards.commands.bulk_delete import BulkDeleteDashboardCommand
|
||||
from superset.dashboards.commands.create import CreateDashboardCommand
|
||||
|
|
@ -729,10 +729,7 @@ class DashboardRestApi(BaseSupersetModelRestApi):
|
|||
if not upload:
|
||||
return self.response_400()
|
||||
with ZipFile(upload) as bundle:
|
||||
contents = {
|
||||
remove_root(file_name): bundle.read(file_name).decode()
|
||||
for file_name in bundle.namelist()
|
||||
}
|
||||
contents = get_contents_from_bundle(bundle)
|
||||
|
||||
passwords = (
|
||||
json.loads(request.form["passwords"])
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ from sqlalchemy.exc import NoSuchTableError, OperationalError, SQLAlchemyError
|
|||
|
||||
from superset import event_logger
|
||||
from superset.commands.exceptions import CommandInvalidError
|
||||
from superset.commands.importers.v1.utils import remove_root
|
||||
from superset.commands.importers.v1.utils import get_contents_from_bundle
|
||||
from superset.constants import MODEL_API_RW_METHOD_PERMISSION_MAP, RouteMethod
|
||||
from superset.databases.commands.create import CreateDatabaseCommand
|
||||
from superset.databases.commands.delete import DeleteDatabaseCommand
|
||||
|
|
@ -778,10 +778,7 @@ class DatabaseRestApi(BaseSupersetModelRestApi):
|
|||
if not upload:
|
||||
return self.response_400()
|
||||
with ZipFile(upload) as bundle:
|
||||
contents = {
|
||||
remove_root(file_name): bundle.read(file_name).decode()
|
||||
for file_name in bundle.namelist()
|
||||
}
|
||||
contents = get_contents_from_bundle(bundle)
|
||||
|
||||
passwords = (
|
||||
json.loads(request.form["passwords"])
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ from marshmallow import ValidationError
|
|||
|
||||
from superset import event_logger, is_feature_enabled
|
||||
from superset.commands.exceptions import CommandInvalidError
|
||||
from superset.commands.importers.v1.utils import remove_root
|
||||
from superset.commands.importers.v1.utils import get_contents_from_bundle
|
||||
from superset.connectors.sqla.models import SqlaTable
|
||||
from superset.constants import MODEL_API_RW_METHOD_PERMISSION_MAP, RouteMethod
|
||||
from superset.databases.filters import DatabaseFilter
|
||||
|
|
@ -687,10 +687,7 @@ class DatasetRestApi(BaseSupersetModelRestApi):
|
|||
if not upload:
|
||||
return self.response_400()
|
||||
with ZipFile(upload) as bundle:
|
||||
contents = {
|
||||
remove_root(file_name): bundle.read(file_name).decode()
|
||||
for file_name in bundle.namelist()
|
||||
}
|
||||
contents = get_contents_from_bundle(bundle)
|
||||
|
||||
passwords = (
|
||||
json.loads(request.form["passwords"])
|
||||
|
|
|
|||
Loading…
Reference in New Issue