mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2025-12-06 09:12:45 +01:00
Playbook - create play API
This commit is contained in:
23
salt/elastalert/files/modules/so/playbook-es.py
Normal file
23
salt/elastalert/files/modules/so/playbook-es.py
Normal file
@@ -0,0 +1,23 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from datetime import date
|
||||
import requests,json
|
||||
from elastalert.alerts import Alerter
|
||||
|
||||
class PlaybookESAlerter(Alerter):
|
||||
"""
|
||||
Use matched data to create alerts in elasticsearch
|
||||
"""
|
||||
|
||||
required_options = set(['play_title','play_url','sigma_level','elasticsearch_host'])
|
||||
|
||||
def alert(self, matches):
|
||||
for match in matches:
|
||||
headers = {"Content-Type": "application/json"}
|
||||
payload = {"play_title": self.rule['play_title'],"play_url": self.rule['play_url'],"sigma_level": self.rule['sigma_level'],"data": match}
|
||||
today = str(date.today())
|
||||
url = f"http://{self.rule['elasticsearch_host']}/playbook-alerts-{today}/_doc/"
|
||||
requests.post(url, data=json.dumps(payload), headers=headers, verify=False)
|
||||
|
||||
def get_info(self):
|
||||
return {'type': 'PlaybookESAlerter'}
|
||||
Reference in New Issue
Block a user