Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: import ZIP files that have been modified #12425

Merged
merged 2 commits into from
Jan 12, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion superset/charts/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
thumbnail_query_schema,
)
from superset.commands.exceptions import CommandInvalidError
from superset.commands.importers.v1.utils import remove_root
from superset.commands.importers.v1.utils import is_valid_config, remove_root
from superset.constants import MODEL_API_RW_METHOD_PERMISSION_MAP, RouteMethod
from superset.exceptions import SupersetSecurityException
from superset.extensions import event_logger
Expand Down Expand Up @@ -976,6 +976,7 @@ def import_(self) -> Response:
contents = {
remove_root(file_name): bundle.read(file_name).decode()
for file_name in bundle.namelist()
if is_valid_config(file_name)
}

passwords = (
Expand Down
14 changes: 14 additions & 0 deletions superset/commands/importers/v1/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,17 @@ def load_metadata(contents: Dict[str, str]) -> Dict[str, str]:
raise exc

return metadata


def is_valid_config(file_name: str) -> bool:
betodealmeida marked this conversation as resolved.
Show resolved Hide resolved
path = Path(file_name)

# ignore system files that might've been added to the bundle
if path.name.startswith(".") or path.name.startswith("_"):
return False

# ensure extension is YAML
if path.suffix.lower() not in {".yaml", ".yml"}:
return False

return True