Skip to content

Commit 5411c8c

Browse files
committed
Removed thehive alerter
1 parent f8f6fc5 commit 5411c8c

File tree

6 files changed

+2
-132
lines changed

6 files changed

+2
-132
lines changed

docs/source/elastalert.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ Currently, we have support built in for these alert types:
4242
- GoogleChat
4343
- Debug
4444
- Stomp
45-
- theHive
4645

4746
Additional rule types and alerts can be easily imported or written. (See :ref:`Writing rule types <writingrules>` and :ref:`Writing alerts <writingalerts>`)
4847

docs/source/ruletypes.rst

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ kibana_discover_version
549549

550550
``kibana_discover_version``: Specifies the version of the Kibana Discover application.
551551

552-
The currently supported versions of Kibana Discover are:
552+
The currently supported versions of Kibana Discover are:
553553

554554
- `5.6`
555555
- `6.0`, `6.1`, `6.2`, `6.3`, `6.4`, `6.5`, `6.6`, `6.7`, `6.8`
@@ -2186,51 +2186,6 @@ Required:
21862186

21872187
``linenotify_access_token``: The access token that you got from https://notify-bot.line.me/my/
21882188

2189-
theHive
2190-
~~~~~~~
2191-
2192-
theHive alert type will send JSON request to theHive (Security Incident Response Platform) with TheHive4py API. Sent request will be stored like Hive Alert with description and observables.
2193-
2194-
Required:
2195-
2196-
``hive_connection``: The connection details as key:values. Required keys are ``hive_host``, ``hive_port`` and ``hive_apikey``.
2197-
2198-
``hive_alert_config``: Configuration options for the alert.
2199-
2200-
Optional:
2201-
2202-
``hive_proxies``: Proxy configuration.
2203-
2204-
``hive_observable_data_mapping``: If needed, matched data fields can be mapped to TheHive observable types using python string formatting.
2205-
2206-
Example usage::
2207-
2208-
alert: hivealerter
2209-
2210-
hive_connection:
2211-
hive_host: http://localhost
2212-
hive_port: <hive_port>
2213-
hive_apikey: <hive_apikey>
2214-
hive_proxies:
2215-
http: ''
2216-
https: ''
2217-
2218-
hive_alert_config:
2219-
title: 'Title' ## This will default to {rule[index]_rule[name]} if not provided
2220-
type: 'external'
2221-
source: 'elastalert'
2222-
description: '{match[field1]} {rule[name]} Sample description'
2223-
severity: 2
2224-
tags: ['tag1', 'tag2 {rule[name]}']
2225-
tlp: 3
2226-
status: 'New'
2227-
follow: True
2228-
2229-
hive_observable_data_mapping:
2230-
- domain: "{match[field1]}_{rule[name]}"
2231-
- domain: "{match[field]}"
2232-
- ip: "{match[ip_field]}"
2233-
22342189

22352190
Zabbix
22362191
~~~~~~~~~~~

elastalert/alerts.py

Lines changed: 0 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import json
55
import logging
66
import os
7-
import re
87
import subprocess
98
import sys
109
import time
@@ -29,10 +28,6 @@
2928
from requests.exceptions import RequestException
3029
from staticconf.loader import yaml_loader
3130
from texttable import Texttable
32-
from thehive4py.api import TheHiveApi
33-
from thehive4py.models import Alert
34-
from thehive4py.models import AlertArtifact
35-
from thehive4py.models import CustomFieldHelper
3631
from twilio.base.exceptions import TwilioRestException
3732
from twilio.rest import Client as TwilioClient
3833

@@ -2109,79 +2104,3 @@ def alert(self, matches):
21092104

21102105
def get_info(self):
21112106
return {"type": "linenotify", "linenotify_access_token": self.linenotify_access_token}
2112-
2113-
2114-
class HiveAlerter(Alerter):
2115-
"""
2116-
Use matched data to create alerts containing observables in an instance of TheHive
2117-
"""
2118-
2119-
required_options = set(['hive_connection', 'hive_alert_config'])
2120-
2121-
def alert(self, matches):
2122-
2123-
connection_details = self.rule['hive_connection']
2124-
2125-
api = TheHiveApi(
2126-
connection_details.get('hive_host'),
2127-
connection_details.get('hive_apikey', ''),
2128-
proxies=connection_details.get('hive_proxies', {'http': '', 'https': ''}),
2129-
cert=connection_details.get('hive_verify', False))
2130-
2131-
for match in matches:
2132-
context = {'rule': self.rule, 'match': match}
2133-
2134-
artifacts = []
2135-
for mapping in self.rule.get('hive_observable_data_mapping', []):
2136-
for observable_type, match_data_key in mapping.items():
2137-
try:
2138-
match_data_keys = re.findall(r'\{match\[([^\]]*)\]', match_data_key)
2139-
rule_data_keys = re.findall(r'\{rule\[([^\]]*)\]', match_data_key)
2140-
data_keys = match_data_keys + rule_data_keys
2141-
context_keys = list(context['match'].keys()) + list(context['rule'].keys())
2142-
if all([True if k in context_keys else False for k in data_keys]):
2143-
artifacts.append(AlertArtifact(dataType=observable_type, data=match_data_key.format(**context)))
2144-
except KeyError:
2145-
raise KeyError('\nformat string\n{}\nmatch data\n{}'.format(match_data_key, context))
2146-
2147-
alert_config = {
2148-
'artifacts': artifacts,
2149-
'sourceRef': str(uuid.uuid4())[0:6],
2150-
'title': '{rule[index]}_{rule[name]}'.format(**context)
2151-
}
2152-
alert_config.update(self.rule.get('hive_alert_config', {}))
2153-
2154-
for alert_config_field, alert_config_value in alert_config.items():
2155-
if alert_config_field == 'customFields':
2156-
custom_fields = CustomFieldHelper()
2157-
for cf_key, cf_value in alert_config_value.items():
2158-
try:
2159-
func = getattr(custom_fields, 'add_{}'.format(cf_value['type']))
2160-
except AttributeError:
2161-
raise Exception('unsupported custom field type {}'.format(cf_value['type']))
2162-
value = cf_value['value'].format(**context)
2163-
func(cf_key, value)
2164-
alert_config[alert_config_field] = custom_fields.build()
2165-
elif isinstance(alert_config_value, str):
2166-
alert_config[alert_config_field] = alert_config_value.format(**context)
2167-
elif isinstance(alert_config_value, (list, tuple)):
2168-
formatted_list = []
2169-
for element in alert_config_value:
2170-
try:
2171-
formatted_list.append(element.format(**context))
2172-
except (AttributeError, KeyError, IndexError):
2173-
formatted_list.append(element)
2174-
alert_config[alert_config_field] = formatted_list
2175-
2176-
alert = Alert(**alert_config)
2177-
response = api.create_alert(alert)
2178-
2179-
if response.status_code != 201:
2180-
raise Exception('alert not successfully created in TheHive\n{}'.format(response.text))
2181-
2182-
def get_info(self):
2183-
2184-
return {
2185-
'type': 'hivealerter',
2186-
'hive_host': self.rule.get('hive_connection', {}).get('hive_host', '')
2187-
}

elastalert/loaders.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ class RulesLoader(object):
7777
'servicenow': alerts.ServiceNowAlerter,
7878
'alerta': alerts.AlertaAlerter,
7979
'post': alerts.HTTPPostAlerter,
80-
'hivealerter': alerts.HiveAlerter
8180
}
8281

8382
# A partial ordering of alert types. Relative order will be preserved in the resulting alerts list

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,4 @@ PyYAML>=5.1
2020
requests>=2.0.0
2121
stomp.py>=4.1.17
2222
texttable>=0.8.8
23-
thehive4py>=1.4.4
2423
twilio==6.0.0

setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
base_dir = os.path.dirname(__file__)
99
setup(
1010
name='elastalert',
11-
version='0.2.1',
11+
version='0.2.2',
1212
description='Runs custom filters on Elasticsearch and alerts on matches',
1313
author='Quentin Long',
1414
author_email='[email protected]',
@@ -47,7 +47,6 @@
4747
'stomp.py>=4.1.17',
4848
'texttable>=0.8.8',
4949
'twilio>=6.0.0,<6.1',
50-
'thehive4py>=1.4.4',
5150
'python-magic>=0.4.15',
5251
'cffi>=1.11.5'
5352
]

0 commit comments

Comments
 (0)