Skip to content

Commit

Permalink
Update iris_test.py to test multiple alerts with ioc data
Browse files Browse the repository at this point in the history
  • Loading branch information
bvirgilioamnh authored Sep 16, 2024
1 parent e83c6a9 commit c991434
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions tests/alerters/iris_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,72 @@ def test_iris_make_iocs_records(caplog):
actual_data = alert.make_iocs_records([match])
assert expected_data == actual_data

def test_iris_handle_multiple_alerts_with_iocs(caplog):
caplog.set_level(logging.INFO)
rule = {
'name': 'Test Context',
'type': 'any',
'iris_type': 'alert',
'iris_host': '127.0.0.1',
'iris_api_token': 'token 12345',
'iris_customer_id': 1,
'iris_iocs': [
{
'ioc_description': 'source address',
'ioc_tags': 'ip, ipv4',
'ioc_tlp_id': 1,
'ioc_type_id': 76,
'ioc_value': 'src_ip'
},
{
'ioc_description': 'target username',
'ioc_tags': 'login, username',
'ioc_tlp_id': 3,
'ioc_type_id': 3,
'ioc_value': 'username'
},
{
'ioc_description': 'empty ioc',
'ioc_tags': 'ioc',
'ioc_tlp_id': 3,
'ioc_type_id': 3,
'ioc_value': 'non_existent_data'
}
],
'alert': []
}

rules_loader = FileRulesLoader({})
rules_loader.load_modules(rule)
alert = IrisAlerter(rule)

match = {
'@timestamp': '2023-10-21 20:00:00.000', 'username': 'evil_user', 'src_ip': '172.20.1.1', 'dst_ip': '10.0.0.1',
'event_type': 'login', 'event_status': 'success'
}

expected_data = [
{
'ioc_description': 'source address',
'ioc_tags': 'ip, ipv4',
'ioc_tlp_id': 1,
'ioc_type_id': 76,
'ioc_value': '172.20.1.1'
},
{
'ioc_description': 'target username',
'ioc_tags': 'login, username',
'ioc_tlp_id': 3,
'ioc_type_id': 3,
'ioc_value': 'evil_user'
}
]

first_alert_data = alert.make_iocs_records([match])
actual_data = alert.make_iocs_records([match])
assert expected_data == actual_data



def test_iris_make_alert_minimal(caplog):
caplog.set_level(logging.INFO)
Expand Down

0 comments on commit c991434

Please sign in to comment.