Fixed tests

This commit is contained in:
Nex 2022-06-16 15:24:43 +02:00
parent e7fe30e201
commit abc0f2768b
9 changed files with 17 additions and 17 deletions

View File

@ -13,7 +13,7 @@ from .modules.mixed import MIXED_MODULES
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class CmdIOSChecKFS(Command): class CmdIOSCheckFS(Command):
name = "check-fs" name = "check-fs"
modules = FS_MODULES + MIXED_MODULES modules = FS_MODULES + MIXED_MODULES

View File

@ -18,7 +18,7 @@ from ..utils import get_android_backup_folder
class TestBackupModule: class TestBackupModule:
def test_module_folder(self): def test_module_folder(self):
backup_path = get_android_backup_folder() backup_path = get_android_backup_folder()
mod = SMS(base_folder=backup_path, log=logging) mod = SMS(target_path=backup_path, log=logging)
files = [] files = []
for root, subdirs, subfiles in os.walk(os.path.abspath(backup_path)): for root, subdirs, subfiles in os.walk(os.path.abspath(backup_path)):
for fname in subfiles: for fname in subfiles:
@ -31,7 +31,7 @@ class TestBackupModule:
def test_module_file(self): def test_module_file(self):
fpath = os.path.join(get_android_backup_folder(), "backup.ab") fpath = os.path.join(get_android_backup_folder(), "backup.ab")
mod = SMS(base_folder=fpath, log=logging) mod = SMS(target_path=fpath, log=logging)
with open(fpath, "rb") as f: with open(fpath, "rb") as f:
data = f.read() data = f.read()
tardata = parse_backup_file(data) tardata = parse_backup_file(data)
@ -47,7 +47,7 @@ class TestBackupModule:
def test_module_file2(self): def test_module_file2(self):
fpath = os.path.join(get_android_backup_folder(), "backup2.ab") fpath = os.path.join(get_android_backup_folder(), "backup2.ab")
mod = SMS(base_folder=fpath, log=logging) mod = SMS(target_path=fpath, log=logging)
with open(fpath, "rb") as f: with open(fpath, "rb") as f:
data = f.read() data = f.read()
tardata = parse_backup_file(data, password="123456") tardata = parse_backup_file(data, password="123456")
@ -63,7 +63,7 @@ class TestBackupModule:
def test_module_file3(self): def test_module_file3(self):
fpath = os.path.join(get_android_backup_folder(), "backup3.ab") fpath = os.path.join(get_android_backup_folder(), "backup3.ab")
mod = SMS(base_folder=fpath, log=logging) mod = SMS(target_path=fpath, log=logging)
with open(fpath, "rb") as f: with open(fpath, "rb") as f:
data = f.read() data = f.read()
tardata = parse_backup_file(data) tardata = parse_backup_file(data)

View File

@ -16,7 +16,7 @@ from ..utils import get_artifact_folder
class TestAppopsModule: class TestAppopsModule:
def test_appops_parsing(self): def test_appops_parsing(self):
fpath = os.path.join(get_artifact_folder(), "android_data/bugreport/") fpath = os.path.join(get_artifact_folder(), "android_data/bugreport/")
m = Appops(base_folder=fpath, log=logging, results=[]) m = Appops(target_path=fpath, log=logging, results=[])
folder_files = [] folder_files = []
parent_path = Path(fpath).absolute().as_posix() parent_path = Path(fpath).absolute().as_posix()
for root, subdirs, subfiles in os.walk(os.path.abspath(fpath)): for root, subdirs, subfiles in os.walk(os.path.abspath(fpath)):

View File

@ -13,7 +13,7 @@ from ..utils import get_ios_backup_folder
class TestBackupInfoModule: class TestBackupInfoModule:
def test_manifest(self): def test_manifest(self):
m = BackupInfo(base_folder=get_ios_backup_folder(), log=logging) m = BackupInfo(target_path=get_ios_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

@ -14,14 +14,14 @@ from ..utils import get_ios_backup_folder
class TestDatausageModule: class TestDatausageModule:
def test_datausage(self): def test_datausage(self):
m = Datausage(base_folder=get_ios_backup_folder(), log=logging, results=[]) m = Datausage(target_path=get_ios_backup_folder(), log=logging, results=[])
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, indicator_file): def test_detection(self, indicator_file):
m = Datausage(base_folder=get_ios_backup_folder(), log=logging, results=[]) m = Datausage(target_path=get_ios_backup_folder(), log=logging, results=[])
ind = Indicators(log=logging) ind = Indicators(log=logging)
ind.parse_stix2(indicator_file) ind.parse_stix2(indicator_file)
# Adds a file that exists in the manifest. # Adds a file that exists in the manifest.

View File

@ -14,14 +14,14 @@ from ..utils import get_ios_backup_folder
class TestManifestModule: class TestManifestModule:
def test_manifest(self): def test_manifest(self):
m = Manifest(base_folder=get_ios_backup_folder(), log=logging, results=[]) m = Manifest(target_path=get_ios_backup_folder(), log=logging, results=[])
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, indicator_file): def test_detection(self, indicator_file):
m = Manifest(base_folder=get_ios_backup_folder(), log=logging, results=[]) m = Manifest(target_path=get_ios_backup_folder(), log=logging, results=[])
ind = Indicators(log=logging) ind = Indicators(log=logging)
ind.parse_stix2(indicator_file) ind.parse_stix2(indicator_file)
ind.ioc_collections[0]["file_names"].append("com.apple.CoreBrightness.plist") ind.ioc_collections[0]["file_names"].append("com.apple.CoreBrightness.plist")

View File

@ -14,7 +14,7 @@ from ..utils import get_ios_backup_folder
class TestSafariBrowserStateModule: class TestSafariBrowserStateModule:
def test_parsing(self): def test_parsing(self):
m = SafariBrowserState(base_folder=get_ios_backup_folder(), log=logging, results=[]) m = SafariBrowserState(target_path=get_ios_backup_folder(), log=logging, results=[])
m.is_backup = True m.is_backup = True
run_module(m) run_module(m)
assert m.file_path is not None assert m.file_path is not None
@ -23,7 +23,7 @@ class TestSafariBrowserStateModule:
assert len(m.detected) == 0 assert len(m.detected) == 0
def test_detection(self, indicator_file): def test_detection(self, indicator_file):
m = SafariBrowserState(base_folder=get_ios_backup_folder(), log=logging, results=[]) m = SafariBrowserState(target_path=get_ios_backup_folder(), log=logging, results=[])
m.is_backup = True m.is_backup = True
ind = Indicators(log=logging) ind = Indicators(log=logging)
ind.parse_stix2(indicator_file) ind.parse_stix2(indicator_file)

View File

@ -14,14 +14,14 @@ from ..utils import get_ios_backup_folder
class TestSMSModule: class TestSMSModule:
def test_sms(self): def test_sms(self):
m = SMS(base_folder=get_ios_backup_folder(), log=logging, results=[]) m = SMS(target_path=get_ios_backup_folder(), log=logging, results=[])
run_module(m) run_module(m)
assert len(m.results) == 1 assert len(m.results) == 1
assert len(m.timeline) == 1 assert len(m.timeline) == 1
assert len(m.detected) == 0 assert len(m.detected) == 0
def test_detection(self, indicator_file): def test_detection(self, indicator_file):
m = SMS(base_folder=get_ios_backup_folder(), log=logging, results=[]) m = SMS(target_path=get_ios_backup_folder(), log=logging, results=[])
ind = Indicators(log=logging) ind = Indicators(log=logging)
ind.parse_stix2(indicator_file) ind.parse_stix2(indicator_file)
# Adds a file that exists in the manifest. # Adds a file that exists in the manifest.

View File

@ -14,7 +14,7 @@ from ..utils import get_ios_backup_folder
class TestTCCtModule: class TestTCCtModule:
def test_tcc(self): def test_tcc(self):
m = TCC(base_folder=get_ios_backup_folder(), log=logging, results=[]) m = TCC(target_path=get_ios_backup_folder(), log=logging, results=[])
run_module(m) run_module(m)
assert len(m.results) == 11 assert len(m.results) == 11
assert len(m.timeline) == 11 assert len(m.timeline) == 11
@ -24,7 +24,7 @@ class TestTCCtModule:
assert m.results[0]["auth_value"] == "allowed" assert m.results[0]["auth_value"] == "allowed"
def test_tcc_detection(self, indicator_file): def test_tcc_detection(self, indicator_file):
m = TCC(base_folder=get_ios_backup_folder(), log=logging, results=[]) m = TCC(target_path=get_ios_backup_folder(), log=logging, results=[])
ind = Indicators(log=logging) ind = Indicators(log=logging)
ind.parse_stix2(indicator_file) ind.parse_stix2(indicator_file)
m.indicators = ind m.indicators = ind