Skip to content
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
7 changes: 6 additions & 1 deletion cortexutils/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,16 @@ def report(self, full_report, ensure_ascii=False):
summary = self.summary(full_report)
except Exception:
pass

operation_list = []
try:
operation_list = self.operations(full_report)
except Exception:
pass
super(Analyzer, self).report({
'success': True,
'summary': summary,
'artifacts': self.artifacts(full_report),
'operations': operation_list,
'full': full_report
}, ensure_ascii)

Expand Down
38 changes: 19 additions & 19 deletions cortexutils/responder.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,25 @@ def get_data(self):
:return: Data (observable value) given through Cortex"""
return self.get_param('data', None, 'Missing data field')

@staticmethod
def build_operation(op_type, **parameters):
"""
:param op_type: an operation type as a string
:param parameters: a dict including the operation's params
:return: dict
"""
operation = {
'type': op_type
}
operation.update(parameters)

return operation

def operations(self, raw):
"""Returns the list of operations to be executed after the job completes

:returns: by default return an empty array"""
return []
# @staticmethod
# def build_operation(op_type, **parameters):
# """
# :param op_type: an operation type as a string
# :param parameters: a dict including the operation's params
# :return: dict
# """
# operation = {
# 'type': op_type
# }
# operation.update(parameters)

# return operation

# def operations(self, raw):
# """Returns the list of operations to be executed after the job completes

# :returns: by default return an empty array"""
# return []

def report(self, full_report, ensure_ascii=False):
"""Returns a json dict via stdout.
Expand Down
20 changes: 20 additions & 0 deletions cortexutils/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,26 @@ def get_data(self):
:return: Data (observable value) given through Cortex"""
return self.get_param('data', None, 'Missing data field')

@staticmethod
def build_operation(op_type, **parameters):
"""
:param op_type: an operation type as a string
:param parameters: a dict including the operation's params
:return: dict
"""
operation = {
'type': op_type
}
operation.update(parameters)

return operation

def operations(self, raw):
"""Returns the list of operations to be executed after the job completes

:returns: by default return an empty array"""
return []

def get_param(self, name, default=None, message=None):
"""Just a wrapper for Analyzer.__get_param.
:param name: Name of the parameter to get. JSON-like syntax, e.g. `config.username`
Expand Down