wip labeled data

This commit is contained in:
P4T12ICK
2021-06-18 13:24:50 +02:00
parent c90b2093ce
commit dfe21c1da8
3 changed files with 37 additions and 0 deletions
@@ -54,6 +54,38 @@ def test_baseline_search(splunk_host, splunk_password, search, pass_condition, b
return test_results
def run_modified_splunk_search(splunk_host, splunk_password, search, detection_name, detection_file, earliest_time, latest_time):
try:
service = client.connect(
host=splunk_host,
port=8089,
username='admin',
password=splunk_password
)
except Exception as e:
print("Unable to connect to Splunk instance: " + str(e))
return 1, {}
if search.startswith('|'):
search = search
else:
search = 'search ' + search
kwargs = {"exec_mode": "blocking",
"dispatch.earliest_time": "-1d",
"dispatch.latest_time": "now"}
splunk_search = search + ' ' + pass_condition
try:
job = service.jobs.create(splunk_search, **kwargs)
except Exception as e:
print("Unable to execute detection: " + str(e))
return 1, {}
print(job)
def test_detection_search(splunk_host, splunk_password, search, pass_condition, detection_name, detection_file, earliest_time, latest_time):
try:
service = client.connect(
@@ -9,6 +9,7 @@ import requests
from modules.DataManipulation import DataManipulation
from modules import splunk_sdk, aws_service
def prepare_detection_testing(ssh_key_name, private_key, splunk_ip, splunk_password):
with open(ssh_key_name, 'w') as file :
file.write(private_key)
@@ -97,6 +98,9 @@ def test_detection(ssh_key_name, private_key, splunk_ip, splunk_password, test_f
detection = load_file(os.path.join(os.path.dirname(__file__), '../security_content/detections', detection_file_name))
result_detection = splunk_sdk.test_detection_search(splunk_ip, splunk_password, detection['search'], test['pass_condition'], detection['name'], test['file'], test['earliest_time'], test['latest_time'])
# for testing
splunk_sdk.run_modified_splunk_search(splunk_ip, splunk_password, detection['search'], detection['name'], test['file'], test['earliest_time'], test['latest_time'])
result_detection['detection_name'] = test['name']
result_detection['detection_file'] = test['file']
result_test['detection_result'] = result_detection
@@ -51,3 +51,4 @@ tags:
- Processes.dest
security_domain: endpoint