Move backup binary artifact to seperate folder

This commit is contained in:
Donncha Ó Cearbhaill 2022-01-07 17:08:46 +01:00
parent 54963b0b59
commit 3f8dade610
9 changed files with 14 additions and 13 deletions

View File

@ -4,7 +4,7 @@ import logging
from mvt.ios.modules.backup.backup_info import BackupInfo from mvt.ios.modules.backup.backup_info import BackupInfo
from mvt.common.module import run_module from mvt.common.module import run_module
from ..utils import get_artifact_folder, init_setup from ..utils import get_backup_folder, init_setup
class TestBackupInfoModule: class TestBackupInfoModule:
@ -13,7 +13,7 @@ class TestBackupInfoModule:
init_setup() init_setup()
def test_manifest(self): def test_manifest(self):
m = BackupInfo(base_folder=get_artifact_folder(), log=logging) m = BackupInfo(base_folder=get_backup_folder(), log=logging)
run_module(m) run_module(m)
assert m.results["Build Version"] == "18C66" assert m.results["Build Version"] == "18C66"
assert m.results["IMEI"] == '42' assert m.results["IMEI"] == '42'

View File

@ -5,7 +5,7 @@ from mvt.common.indicators import Indicators
from mvt.ios.modules.mixed.net_datausage import Datausage from mvt.ios.modules.mixed.net_datausage import Datausage
from mvt.common.module import run_module from mvt.common.module import run_module
from ..utils import get_artifact, get_artifact_folder, init_setup from ..utils import get_artifact, get_backup_folder, init_setup
class TestDatausageModule: class TestDatausageModule:
@pytest.fixture(scope="session", autouse=True) @pytest.fixture(scope="session", autouse=True)
@ -13,14 +13,14 @@ class TestDatausageModule:
init_setup() init_setup()
def test_datausage(self): def test_datausage(self):
m = Datausage(base_folder=get_artifact_folder(), log=logging) m = Datausage(base_folder=get_backup_folder(), log=logging)
run_module(m) run_module(m)
assert len(m.results) == 42 assert len(m.results) == 42
assert len(m.timeline) == 60 assert len(m.timeline) == 60
assert len(m.detected) == 0 assert len(m.detected) == 0
def test_detection(self): def test_detection(self):
m = Datausage(base_folder=get_artifact_folder(), log=logging) m = Datausage(base_folder=get_backup_folder(), log=logging)
ind = Indicators(log=logging) ind = Indicators(log=logging)
ind.parse_stix2(get_artifact("test.stix2")) ind.parse_stix2(get_artifact("test.stix2"))
# Adds a file that exists in the manifest # Adds a file that exists in the manifest

View File

@ -5,7 +5,7 @@ from mvt.common.indicators import Indicators
from mvt.ios.modules.backup.manifest import Manifest from mvt.ios.modules.backup.manifest import Manifest
from mvt.common.module import run_module from mvt.common.module import run_module
from ..utils import get_artifact, get_artifact_folder, init_setup from ..utils import get_artifact, get_backup_folder, init_setup
class TestManifestModule: class TestManifestModule:
@pytest.fixture(scope="session", autouse=True) @pytest.fixture(scope="session", autouse=True)
@ -13,14 +13,14 @@ class TestManifestModule:
init_setup() init_setup()
def test_manifest(self): def test_manifest(self):
m = Manifest(base_folder=get_artifact_folder(), log=logging) m = Manifest(base_folder=get_backup_folder(), log=logging)
run_module(m) run_module(m)
assert len(m.results) == 3721 assert len(m.results) == 3721
assert len(m.timeline) == 5881 assert len(m.timeline) == 5881
assert len(m.detected) == 0 assert len(m.detected) == 0
def test_detection(self): def test_detection(self):
m = Manifest(base_folder=get_artifact_folder(), log=logging) m = Manifest(base_folder=get_backup_folder(), log=logging)
ind = Indicators(log=logging) ind = Indicators(log=logging)
ind.parse_stix2(get_artifact("test.stix2")) ind.parse_stix2(get_artifact("test.stix2"))
# Adds a file that exists in the manifest # Adds a file that exists in the manifest

View File

@ -4,7 +4,7 @@ import logging
from mvt.ios.modules.mixed.tcc import TCC from mvt.ios.modules.mixed.tcc import TCC
from mvt.common.module import run_module from mvt.common.module import run_module
from ..utils import get_artifact_folder, init_setup from ..utils import get_backup_folder, init_setup
class TestManifestModule: class TestManifestModule:
@pytest.fixture(scope="session", autouse=True) @pytest.fixture(scope="session", autouse=True)
@ -12,10 +12,9 @@ class TestManifestModule:
init_setup() init_setup()
def test_manifest(self): def test_manifest(self):
m = TCC(base_folder=get_artifact_folder(), log=logging) m = TCC(base_folder=get_backup_folder(), log=logging)
run_module(m) run_module(m)
assert len(m.results) == 11 assert len(m.results) == 11
# FIXME: TCC should suport timeline
assert len(m.timeline) == 11 assert len(m.timeline) == 11
assert len(m.detected) == 0 assert len(m.detected) == 0
assert m.results[0]["service"] == "kTCCServiceUbiquity" assert m.results[0]["service"] == "kTCCServiceUbiquity"

View File

@ -5,8 +5,7 @@ def get_artifact(fname):
""" """
Return the artifact path in the artifact folder Return the artifact path in the artifact folder
""" """
DATA_FOLDER = os.path.join(os.path.dirname(__file__), "artifacts") fpath = os.path.join(get_artifact_folder(), fname)
fpath = os.path.join(DATA_FOLDER, fname)
if os.path.isfile(fpath): if os.path.isfile(fpath):
return fpath return fpath
return return
@ -16,6 +15,9 @@ def get_artifact_folder():
return os.path.join(os.path.dirname(__file__), "artifacts") return os.path.join(os.path.dirname(__file__), "artifacts")
def get_backup_folder():
return os.path.join(os.path.dirname(__file__), "artifacts", "ios_backup")
def init_setup(): def init_setup():
""" """
init data to have a clean state before testing init data to have a clean state before testing