Skip to content

Commit df5aa6c

Browse files
committed
Added optional force rerun control for cortex
1 parent 3a82308 commit df5aa6c

File tree

3 files changed

+35
-5
lines changed

3 files changed

+35
-5
lines changed

cortex/1.0.0/api.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,14 @@ actions:
7575
required: false
7676
schema:
7777
type: tlp
78+
- name: force
79+
description: Whether to force rerun the analysis
80+
required: false
81+
options:
82+
- true
83+
- false
84+
schema:
85+
type: tlp
7886
returns:
7987
schema:
8088
type: string
@@ -118,6 +126,14 @@ actions:
118126
required: false
119127
schema:
120128
type: tlp
129+
- name: force
130+
description: Whether to force rerun the analysis
131+
required: false
132+
options:
133+
- true
134+
- false
135+
schema:
136+
type: tlp
121137
returns:
122138
schema:
123139
type: string

cortex/1.0.0/src/app.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,17 @@ def get_available_analyzers(self, apikey, url, datatype):
4646

4747
return all_results
4848

49-
def run_available_analyzers(self, apikey, url, data, datatype, message="", tlp=1):
49+
def run_available_analyzers(self, apikey, url, data, datatype, message="", tlp=1, force="true"):
5050
if data == "" or data == "[]":
51-
return "No values to handle []"
51+
return {
52+
"success": False,
53+
"reason": "No values to handle []",
54+
}
55+
56+
if str(force.lower()) == "true":
57+
force = 1
58+
else:
59+
force = 0
5260

5361
self.api = Api(url, apikey, cert=False)
5462
analyzers = self.get_available_analyzers(apikey, url, datatype)
@@ -61,7 +69,7 @@ def run_available_analyzers(self, apikey, url, data, datatype, message="", tlp=1
6169
'dataType': datatype,
6270
'tlp': tlp,
6371
'message': message,
64-
}, force=1)
72+
}, force=force)
6573

6674
alljobs.append(job.id)
6775
except cortex4py.exceptions.ServiceUnavailableError as e:
@@ -75,15 +83,20 @@ def run_available_analyzers(self, apikey, url, data, datatype, message="", tlp=1
7583
# return alljobs[0]
7684
return alljobs
7785

78-
def run_analyzer(self, apikey, url, analyzer_name, data, datatype, message="", tlp=1):
86+
def run_analyzer(self, apikey, url, analyzer_name, data, datatype, message="", tlp=1, force="true"):
87+
if str(force.lower()) == "true":
88+
force = 1
89+
else:
90+
force = 0
91+
7992
self.api = Api(url, apikey, cert=False)
8093
try:
8194
job = self.api.analyzers.run_by_name(analyzer_name, {
8295
'data': data,
8396
'dataType': datatype,
8497
'tlp': tlp,
8598
'message': message,
86-
}, force=1)
99+
}, force=force)
87100
except cortex4py.exceptions.ServiceUnavailableError as e:
88101
return str(e)
89102
except cortex4py.exceptions.AuthorizationError as e:

thehive/1.1.3/src/app.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,7 @@ def create_case_from_alert(
417417
response = self.thehive.promote_alert_to_case(
418418
alert_id=alert_id, case_template=case_template
419419
)
420+
420421
return response.text
421422

422423
def merge_alert_into_case(self, apikey, url, organisation, alert_id, case_id):

0 commit comments

Comments
 (0)