discourage users from importing cuckoo cwd setups

This commit is contained in:
Jurriaan Bremer
2018-04-21 11:46:54 +02:00
parent 98466d47fc
commit 0dbeefcb02
3 changed files with 28 additions and 3 deletions
+2 -2
View File
@@ -1,4 +1,4 @@
# Copyright (C) 2016-2017 Cuckoo Foundation.
# Copyright (C) 2016-2018 Cuckoo Foundation.
# This file is part of Cuckoo Sandbox - http://www.cuckoosandbox.org
# See the file 'docs/LICENSE' for copying permission.
@@ -127,7 +127,7 @@ def import_cuckoo(username, mode, dirpath):
if not version:
raise CuckooOperationalError(
"The path that you specified is not a proper Cuckoo setup. Please "
"point the path to the root of your older Cuckoo setup, i.e., to "
"point the path to the root of your legacy Cuckoo setup, i.e., to "
"the directory containing the cuckoo.py script!"
)
+13
View File
@@ -627,6 +627,19 @@ def import_(ctx, mode, path):
"""Imports an older Cuckoo setup into a new CWD. The old setup should be
identified by PATH and the new CWD may be specified with the --cwd
parameter, e.g., "cuckoo --cwd /tmp/cwd import old-cuckoo"."""
if os.path.exists(os.path.join(path, ".cwd")):
print(yellow(
"The 'cuckoo import' feature is meant to import a legacy Cuckoo, "
"i.e., Cuckoo 1.2, 2.0-dev, 2.0-rc1, or 2.0-rc2 into a new Cuckoo "
"CWD."
))
print(red(
"You're attempting to import an existing Cuckoo CWD. To upgrade "
"Cuckoo / your CWD, simply run 'pip install -U cuckoo' and re-run "
"the cuckoo commands!"
))
sys.exit(1)
if mode == "symlink" and is_windows():
sys.exit(red(
"You can only use the 'symlink' mode on non-Windows platforms."
+13 -1
View File
@@ -1,4 +1,4 @@
# Copyright (C) 2016-2017 Cuckoo Foundation.
# Copyright (C) 2016-2018 Cuckoo Foundation.
# This file is part of Cuckoo Sandbox - http://www.cuckoosandbox.org
# See the file 'docs/LICENSE' for copying permission.
@@ -298,6 +298,18 @@ def init_import_legacy(mode):
assert not os.path.exists(cwd(analysis="latest"))
return dirpath
def test_import_cuckoo_cwd(capsys):
set_cwd(tempfile.mkdtemp())
cuckoo_create()
with pytest.raises(SystemExit):
main.main(
("--cwd", cwd(), "import", cwd()), standalone_mode=False
)
out, _ = capsys.readouterr()
assert "import a legacy Cuckoo" in out
def test_import_legacy_analyses_copy():
dirpath = init_import_legacy("copy")