Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Responder QRadarAutoClose #460

Merged
merged 4 commits into from
Oct 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions responders/QRadarAutoClose/QRadarAutoClose.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "QRadar Auto Closing Offense",
"version": "1.0",
"author": "Florian Perret",
"url": "https://github.com/TheHive-Project/Cortex-Analyzers",
"license": "AGPL-V3",
"description": "Closing the QRadar Offense associated to your case in one clic !",
"dataTypeList": ["thehive:case"],
"command": "QRadarAutoClose/QRadarAutoClose.py",
"baseConfig": "QRadarAutoClose",
"configurationItems": [
{
"name": "QRadar_API_Key",
"description": "A QRadar API key with sufficent rights to close an offense",
"type": "string",
"multi": false,
"required": true
},
{
"name": "QRadar_Url",
"description": "URL of your QRadar API, must be accessible from Cortex server. eg: myqradar.myorg.com/api/siem/offenses",
"type": "string",
"multi": false,
"required": true
},
{
"name": "Cert_Path",
"description": "If you need a certificate to authentificate to your QRadar API, please provide the path here",
"type": "string",
"multi": false,
"required": false
}
]
}
41 changes: 41 additions & 0 deletions responders/QRadarAutoClose/QRadarAutoClose.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env python
# encoding: utf-8

# QRadarAutoClose
# Author: Florian Perret (@cyber_pescadito)

from cortexutils.responder import Responder
import requests


class QRadarAutoClose(Responder):
def __init__(self):
Responder.__init__(self)
self.QRadar_URL = self.get_param('config.QRadar_Url', None, "QRadar URL is Missing")
self.QRadar_API_Key = self.get_param('config.QRadar_API_Key', None, "QRadar API Key is Missing")
self.Offense_Id = self.get_param('data.customFields.externalReferences', None, "QRadar Offense ID is Missing")
self.Cert_Path = self.get_param('config.Cert_Path')

def run(self):
h = {
'content-type': 'application/json',
'Version': '9.1',
'SEC': str(self.QRadar_API_Key)
}
payload = self.Offense_Id['string'] + '?closing_reason_id=3&status=CLOSED'

if self.Cert_Path == '':
r = requests.post(self.QRadar_URL + payload, headers=h)
else:
r = requests.post(self.QRadar_URL + payload, headers=h, verify=self.Cert_Path)

if r.status_code == 200 or \
r.status_code == 202 or \
r.status_code == 409:
self.report({'message': 'QRadar Offense succesfully closed !'})
else:
self.error({'message': r.status_code})


if __name__ == '__main__':
QRadarAutoClose().run()
4 changes: 4 additions & 0 deletions responders/QRadarAutoClose/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Simple responder to close a QRadar Offense through a simple clic !

If you need to change the customfield which contain the QRadar Offense ID, change the "externalReferences" from QRadarAutoClose.py line 15.
Be careful this have to be fulfill with the "Internal Reference" of the customfield, not it's name !
2 changes: 2 additions & 0 deletions responders/QRadarAutoClose/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cortexutils
requests