Skip to content

Commit

Permalink
Merge pull request #840 from frikky/master
Browse files Browse the repository at this point in the history
Added Shuffle workflow execution responder
  • Loading branch information
garanews authored Sep 18, 2020
2 parents 96ace1b + 271d023 commit 5bfeecc
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
2 changes: 2 additions & 0 deletions responders/Shuffle/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cortexutils
requests
35 changes: 35 additions & 0 deletions responders/Shuffle/shuffle.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "Shuffle",
"version": "1.0",
"author": "@frikkylikeme",
"url": "https://github.com/frikky/shuffle",
"license": "AGPL-V3",
"description": "Execute a workflow in Shuffle",
"dataTypeList": ["thehive:case", "thehive:alert"],
"command": "Shuffle/shuffle.py",
"baseConfig": "Shuffle",
"configurationItems": [
{
"name": "url",
"description": "The URL to your shuffle instance",
"type": "string",
"multi": false,
"required": true,
"defaultValue": "https://shuffler.io"
},
{
"name": "api_key",
"description": "The API key to your Shuffle user",
"type": "string",
"multi": false,
"required": true
},
{
"name": "workflow_id",
"description": "The ID of the workflow to execute",
"type": "string",
"multi": false,
"required": true
}
]
}
27 changes: 27 additions & 0 deletions responders/Shuffle/shuffle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env python3
from cortexutils.responder import Responder
import requests

class Shuffle(Responder):
def __init__(self):
Responder.__init__(self)
self.api_key = self.get_param("config.api_key", "")
self.url = self.get_param("config.url", "")
self.workflow_id = self.get_param("config.workflow_id", "")

def run(self):
Responder.run(self)

parsed_url = "%s/api/v1/workflows/%s/execute" % (self.url, self.workflow_id)
headers = {
"Authorization": "Bearer %s" % self.api_key
}
r = requests.post(parsed_url, headers=headers)
if r.status_code == 200:
self.report({"Message": "Executed workflow"})
else:
self.error(r.status_code)

if __name__ == '__main__':
Shuffle().run()

0 comments on commit 5bfeecc

Please sign in to comment.