2021-12-16 11:50:12 +00:00
|
|
|
import pytest
|
|
|
|
import logging
|
2022-01-07 16:03:53 +00:00
|
|
|
|
|
|
|
from mvt.common.indicators import Indicators
|
2021-12-16 11:50:12 +00:00
|
|
|
from mvt.ios.modules.mixed.net_datausage import Datausage
|
|
|
|
from mvt.common.module import run_module
|
|
|
|
|
2022-01-07 16:08:46 +00:00
|
|
|
from ..utils import get_artifact, get_backup_folder, init_setup
|
2021-12-16 11:50:12 +00:00
|
|
|
|
|
|
|
class TestDatausageModule:
|
|
|
|
@pytest.fixture(scope="session", autouse=True)
|
|
|
|
def set(self):
|
|
|
|
init_setup()
|
|
|
|
|
|
|
|
def test_datausage(self):
|
2022-01-07 16:08:46 +00:00
|
|
|
m = Datausage(base_folder=get_backup_folder(), log=logging)
|
2021-12-16 11:50:12 +00:00
|
|
|
run_module(m)
|
|
|
|
assert len(m.results) == 42
|
|
|
|
assert len(m.timeline) == 60
|
|
|
|
assert len(m.detected) == 0
|
|
|
|
|
|
|
|
def test_detection(self):
|
2022-01-07 16:08:46 +00:00
|
|
|
m = Datausage(base_folder=get_backup_folder(), log=logging)
|
2021-12-16 11:50:12 +00:00
|
|
|
ind = Indicators(log=logging)
|
|
|
|
ind.parse_stix2(get_artifact("test.stix2"))
|
|
|
|
# Adds a file that exists in the manifest
|
|
|
|
ind.ioc_processes[0] = "CumulativeUsageTracker"
|
|
|
|
m.indicators = ind
|
|
|
|
run_module(m)
|
|
|
|
assert len(m.detected) == 4
|