2022-01-18 15:00:03 +00:00
|
|
|
# Mobile Verification Toolkit (MVT)
|
|
|
|
# Copyright (c) 2021 The MVT Project Authors.
|
|
|
|
# Use of this software is governed by the MVT License 1.1 that can be found at
|
|
|
|
# https://license.mvt.re/1.1/
|
|
|
|
|
2021-12-16 11:50:12 +00:00
|
|
|
import logging
|
|
|
|
import os
|
2022-01-07 16:03:53 +00:00
|
|
|
|
|
|
|
from mvt.common.indicators import Indicators
|
|
|
|
|
2022-01-18 15:00:03 +00:00
|
|
|
|
2021-12-16 11:50:12 +00:00
|
|
|
class TestIndicators:
|
2022-01-07 16:51:21 +00:00
|
|
|
def test_parse_stix2(self, indicator_file):
|
2021-12-16 11:50:12 +00:00
|
|
|
ind = Indicators(log=logging)
|
2022-01-07 16:51:21 +00:00
|
|
|
ind.load_indicators_files([indicator_file], load_default=False)
|
2021-12-16 11:50:12 +00:00
|
|
|
assert ind.ioc_count == 4
|
|
|
|
assert len(ind.ioc_domains) == 1
|
|
|
|
assert len(ind.ioc_emails) == 1
|
|
|
|
assert len(ind.ioc_files) == 1
|
|
|
|
assert len(ind.ioc_processes) == 1
|
|
|
|
|
2022-01-07 16:51:21 +00:00
|
|
|
def test_check_domain(self, indicator_file):
|
2021-12-16 11:50:12 +00:00
|
|
|
ind = Indicators(log=logging)
|
2022-01-07 16:51:21 +00:00
|
|
|
ind.load_indicators_files([indicator_file], load_default=False)
|
2022-01-07 16:03:53 +00:00
|
|
|
assert ind.check_domain("https://www.example.org/foobar")
|
|
|
|
assert ind.check_domain("http://example.org:8080/toto")
|
2021-12-16 11:50:12 +00:00
|
|
|
|
2022-01-07 16:51:21 +00:00
|
|
|
def test_env_stix(self, indicator_file):
|
|
|
|
os.environ["MVT_STIX2"] = indicator_file
|
2021-12-16 11:50:12 +00:00
|
|
|
ind = Indicators(log=logging)
|
2022-01-07 16:51:21 +00:00
|
|
|
ind.load_indicators_files([indicator_file], load_default=False)
|
2021-12-16 11:50:12 +00:00
|
|
|
assert ind.ioc_count == 4
|