mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-18 14:34:21 +01:00
1422 block imports without db folder (#1424)
* Don't allow backups to be imported if they do not have a `db` folder * Closes #1422
This commit is contained in:
@@ -96,6 +96,14 @@ def import_ctf(backup, erase=True):
|
||||
if info.file_size > max_content_length:
|
||||
raise zipfile.LargeZipFile
|
||||
|
||||
# Get list of directories in zipfile
|
||||
member_dirs = [os.path.split(m)[0] for m in members if "/" in m]
|
||||
if "db" not in member_dirs:
|
||||
raise Exception(
|
||||
'CTFd couldn\'t find the "db" folder in this backup. '
|
||||
"The backup may be malformed or corrupted and the import process cannot continue."
|
||||
)
|
||||
|
||||
try:
|
||||
alembic_version = json.loads(backup.open("db/alembic_version.json").read())
|
||||
alembic_version = alembic_version["results"][0]["version_num"]
|
||||
|
||||
Reference in New Issue
Block a user