This commit is contained in:
P4T12ICK
2021-03-02 09:13:27 +01:00
parent 84984b453b
commit fa561db694
4 changed files with 18 additions and 8 deletions
@@ -4,7 +4,6 @@ import pytest
import argparse
from modules.github_service import GithubService
from modules.security_content_handler import prepare_test
def main(args):
@@ -21,8 +21,7 @@ class DataManipulation:
def manipulate_timestamp_exchange_logs(self, file_path):
path = os.path.join(os.path.dirname(__file__), '../attack_data/' + file_path)
path = path.replace('modules/../','')
path = file_path
f = io.open(path, "r", encoding="utf-8")
@@ -48,8 +47,7 @@ class DataManipulation:
def manipulate_timestamp_windows_event_log_raw(self, file_path):
path = os.path.join(os.path.dirname(__file__), '../attack_data/' + file_path)
path = path.replace('modules/../','')
path = file_path
f = io.open(path, "r", encoding="utf-8")
self.now = datetime.now()
@@ -84,8 +82,7 @@ class DataManipulation:
def manipulate_timestamp_cloudtrail(self, file_path):
path = os.path.join(os.path.dirname(__file__), '../attack_data/' + file_path)
path = path.replace('modules/../','')
path = file_path
f = io.open(path, "r", encoding="utf-8")
@@ -30,6 +30,7 @@ def prepare_test(file_path):
for attack_data in test['attack_data']:
url = attack_data['data']
r = requests.get(url, allow_redirects=True)
attack_data_file_path = folder_name + '/' + attack_data['file_name']
open(folder_name + '/' + attack_data['file_name'], 'wb').write(r.content)
# Update timestamps before replay
@@ -38,3 +39,9 @@ def prepare_test(file_path):
data_manipulation = DataManipulation()
data_manipulation.manipulate_timestamp(folder_name + '/' + attack_data['file_name'], attack_data['sourcetype'], attack_data['source'])
dict_test = {
"test_obj": test_obj,
"attack_data_file_path": attack_data_file_path
}
return dict_test
@@ -3,11 +3,13 @@ import pytest
import logging
import os
import time
import pytest_check as check
from http import HTTPStatus
from modules.streams_service_api_helper import DSPApi
from modules.utils import read_spl, read_data
import pytest_check as check
from modules.security_content_handler import prepare_test
# Logger
logging.basicConfig(level=os.environ.get("LOGLEVEL", "INFO"))
@@ -22,6 +24,11 @@ def header_token(token):
def api(env, tenant, header_token):
return DSPApi(env, tenant, header_token)
@pytest.fixture
def test_file(test_file):
prepare_test(test_file)
return test_file
@pytest.fixture
def results_index(api):