mirror of
https://github.com/mvt-project/mvt.git
synced 2024-06-01 18:55:31 +00:00
Uniforming style in test units
This commit is contained in:
parent
fa84b3f296
commit
1460828c30
|
@ -23,22 +23,22 @@ def generate_test_stix_file(file_path):
|
||||||
for d in domains:
|
for d in domains:
|
||||||
i = Indicator(indicator_types=["malicious-activity"], pattern="[domain-name:value='{}']".format(d), pattern_type="stix")
|
i = Indicator(indicator_types=["malicious-activity"], pattern="[domain-name:value='{}']".format(d), pattern_type="stix")
|
||||||
res.append(i)
|
res.append(i)
|
||||||
res.append(Relationship(i, 'indicates', malware))
|
res.append(Relationship(i, "indicates", malware))
|
||||||
|
|
||||||
for p in processes:
|
for p in processes:
|
||||||
i = Indicator(indicator_types=["malicious-activity"], pattern="[process:name='{}']".format(p), pattern_type="stix")
|
i = Indicator(indicator_types=["malicious-activity"], pattern="[process:name='{}']".format(p), pattern_type="stix")
|
||||||
res.append(i)
|
res.append(i)
|
||||||
res.append(Relationship(i, 'indicates', malware))
|
res.append(Relationship(i, "indicates", malware))
|
||||||
|
|
||||||
for f in filenames:
|
for f in filenames:
|
||||||
i = Indicator(indicator_types=["malicious-activity"], pattern="[file:name='{}']".format(f), pattern_type="stix")
|
i = Indicator(indicator_types=["malicious-activity"], pattern="[file:name='{}']".format(f), pattern_type="stix")
|
||||||
res.append(i)
|
res.append(i)
|
||||||
res.append(Relationship(i, 'indicates', malware))
|
res.append(Relationship(i, "indicates", malware))
|
||||||
|
|
||||||
for e in emails:
|
for e in emails:
|
||||||
i = Indicator(indicator_types=["malicious-activity"], pattern="[email-addr:value='{}']".format(e), pattern_type="stix")
|
i = Indicator(indicator_types=["malicious-activity"], pattern="[email-addr:value='{}']".format(e), pattern_type="stix")
|
||||||
res.append(i)
|
res.append(i)
|
||||||
res.append(Relationship(i, 'indicates', malware))
|
res.append(Relationship(i, "indicates", malware))
|
||||||
|
|
||||||
bundle = Bundle(objects=res)
|
bundle = Bundle(objects=res)
|
||||||
with open(file_path, "w+") as f:
|
with open(file_path, "w+") as f:
|
||||||
|
|
|
@ -21,6 +21,6 @@ def indicator_file(request, tmp_path_factory):
|
||||||
@pytest.fixture(scope="session", autouse=True)
|
@pytest.fixture(scope="session", autouse=True)
|
||||||
def clean_test_env(request, tmp_path_factory):
|
def clean_test_env(request, tmp_path_factory):
|
||||||
try:
|
try:
|
||||||
del os.environ['MVT_STIX2']
|
del os.environ["MVT_STIX2"]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -16,4 +16,4 @@ class TestBackupInfoModule:
|
||||||
m = BackupInfo(base_folder=get_backup_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"
|
||||||
|
|
|
@ -24,7 +24,7 @@ class TestDatausageModule:
|
||||||
m = Datausage(base_folder=get_backup_folder(), log=logging, results=[])
|
m = Datausage(base_folder=get_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.
|
||||||
ind.ioc_processes[0] = "CumulativeUsageTracker"
|
ind.ioc_processes[0] = "CumulativeUsageTracker"
|
||||||
m.indicators = ind
|
m.indicators = ind
|
||||||
run_module(m)
|
run_module(m)
|
||||||
|
|
|
@ -23,5 +23,6 @@ def get_artifact_folder():
|
||||||
def get_backup_folder():
|
def get_backup_folder():
|
||||||
return os.path.join(os.path.dirname(__file__), "artifacts", "ios_backup")
|
return os.path.join(os.path.dirname(__file__), "artifacts", "ios_backup")
|
||||||
|
|
||||||
|
|
||||||
def get_indicator_file():
|
def get_indicator_file():
|
||||||
print("PYTEST env", os.getenv('PYTEST_CURRENT_TEST'))
|
print("PYTEST env", os.getenv("PYTEST_CURRENT_TEST"))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user