Permalink
Browse files

Merge pull request #2 from billmurrin/case-model-supports-customfields

Case model supports customfields
  • Loading branch information...
billmurrin committed Sep 16, 2017
2 parents aa895b9 + f78fc04 commit cf53c48ff661fc5c70be9bba346cb3efdd33e725
Showing with 6 additions and 2 deletions.
  1. +6 −2 thehive4py/models.py
View
@@ -43,6 +43,7 @@ def __init__(self, **attributes):
'tags': [],
'startDate': int(time.time()) * 1000,
'metrics': {},
'customFields': {},
'tasks': []
}
@@ -58,6 +59,7 @@ def __init__(self, **attributes):
'tags': template.tags,
'startDate': int(time.time()) * 1000,
'metrics': dict((el, None) for el in template.metricNames),
'customFields': template.customFieldNames,
'tasks': template.tasks
}
@@ -76,16 +78,17 @@ def __init__(self, **attributes):
self.tags = attributes.get('tags', defaults['tags'])
self.startDate = attributes.get('startDate', defaults['startDate'])
self.metrics = attributes.get('metrics', defaults['metrics'])
self.customFields = attributes.get('customFields', defaults['customFields'])
tasks = attributes.get('tasks', defaults['tasks'])
self.tasks = []
for task in tasks:
if type(task) == CaseTask:
self.tasks.append(task)
else:
self.tasks.append(CaseTask(json=task))
class CaseTask(JSONSerializable):
def __init__(self, **attributes):
@@ -122,6 +125,7 @@ def __init__(self, **attributes):
self.tlp = attributes.get('tlp', 2)
self.tags = attributes.get('tags', [])
self.metricNames = attributes.get('metricNames', [])
self.customFieldNames = attributes.get('customFields', {})
tasks = attributes.get('tasks', [])
self.tasks = []
@@ -131,7 +135,6 @@ def __init__(self, **attributes):
else:
self.tasks.append(CaseTask(json=task))
class CaseObservable(JSONSerializable):
def __init__(self, **attributes):
if attributes.get('json', False):
@@ -197,3 +200,4 @@ def _prepare_file_data(self, file_path):
encoded_string = base64.b64encode(file_artifact.read())
return "{};{};{}".format(filename, mime, encoded_string.decode())

0 comments on commit cf53c48

Please sign in to comment.