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

Hippocampe Dockerization + Python3 Support #667

Closed
Closed
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
14 changes: 12 additions & 2 deletions analyzers/Hippocampe/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
FROM python:2
FROM python:3-alpine

LABEL author="CERT-BDF" \
license="AGPL-V3" \
source="https://github.com/TheHive-Project/Cortex-Analyzers" \
title="Hippocampe" \
url="https://github.com/TheHive-Project/Cortex-Analyzers" \
vendor="TheHive" \
version="2.0.0"

WORKDIR /worker

COPY . Hippocampe
RUN pip install --no-cache-dir -r Hippocampe/requirements.txt
ENTRYPOINT Hippocampe/hippo.py

ENTRYPOINT Hippocampe/hippo.py
2 changes: 1 addition & 1 deletion analyzers/Hippocampe/Hippocampe_hipposcore.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Hipposcore",
"version": "2.0",
"version": "2.0.0",
"author": "CERT-BDF",
"url": "https://github.com/TheHive-Project/Cortex-Analyzers",
"license": "AGPL-V3",
Expand Down
2 changes: 1 addition & 1 deletion analyzers/Hippocampe/Hippocampe_more.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "HippoMore",
"version": "2.0",
"version": "2.0.0",
"author": "CERT-BDF",
"url": "https://github.com/TheHive-Project/Cortex-Analyzers",
"license": "AGPL-V3",
Expand Down
17 changes: 8 additions & 9 deletions analyzers/Hippocampe/hippo.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env python2
#!/usr/bin/env python3
# encoding: utf-8
import sys
import json
import urllib2
import requests
from cortexutils.analyzer import Analyzer


Expand Down Expand Up @@ -61,17 +61,16 @@ def run(self):
json_data = json.dumps(value)
post_data = json_data.encode('utf-8')
headers = {'Content-Type': 'application/json'}
url = '{}/hippocampe/api/v1.0/{}'.format(self.url, self.service),

try:
request = urllib2.Request('{}/hippocampe/api/v1.0/{}'.format(self.url, self.service), post_data, headers)
response = urllib2.urlopen(request)
report = json.loads(response.read())
r = requests.post(url, data=post_data, headers=headers)
report = r.json()

self.report(report)
except urllib2.HTTPError:
self.error("Hippocampe: " + str(sys.exc_info()[1]))
except urllib2.URLError:
self.error("Hippocampe: service is not available")

except ValueError as e:
self.unexpectedError('Unable to decode to JSON: {}'.format(e))
except Exception as e:
self.unexpectedError(e)

Expand Down
2 changes: 1 addition & 1 deletion analyzers/Hippocampe/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
cortexutils
future
requests