use api_key parameter, add detail in case of api issue and fix name to avoid template issues

This commit is contained in:
Remy Dewailly 2020-05-06 14:46:26 +02:00
parent 9d113c09f6
commit 3e97eb8eea
2 changed files with 12 additions and 4 deletions

View File

@ -1,5 +1,5 @@
{ {
"name": "LIS Get Report", "name": "LIS_Get_Report",
"version": "1.0", "version": "1.0",
"author": "LastInfoSec", "author": "LastInfoSec",
"url": "https://github.com/TheHive-Project/Cortex-Analyzers", "url": "https://github.com/TheHive-Project/Cortex-Analyzers",

View File

@ -12,10 +12,10 @@ class LIS_GetReport(Analyzer):
def run(self): def run(self):
url = "https://api.client.lastinfosec.com/v2/lis/search_hash/{0}?key={1}".format(self.observable_value, url = "https://api.client.lastinfosec.com/v2/lis/search_hash/{0}?api_key={1}".format(self.observable_value,
self.api_key) self.api_key)
if self.data_type == 'domain': if self.data_type == 'domain':
url = "https://api.client.lastinfosec.com/v2/lis/search_hash/{0}?key={1}".format(self.observable_value, url = "https://api.client.lastinfosec.com/v2/lis/search_hash/{0}?api_key={1}".format(self.observable_value,
self.api_key) self.api_key)
useragent = { useragent = {
@ -25,6 +25,14 @@ class LIS_GetReport(Analyzer):
def check_response(self, response): def check_response(self, response):
if response.status_code != 200: if response.status_code != 200:
try:
result = response.json()
if "detail" in result and "details" in result["detail"] and "error" in result["detail"]["details"][0]:
self.error(
'Bad status: {0}. {1}'.format(response.status_code, result["detail"]["details"][0]["error"]))
else:
self.error('Bad status: {0}'.format(response.status_code))
except Exception as ex:
self.error('Bad status: {0}'.format(response.status_code)) self.error('Bad status: {0}'.format(response.status_code))
else: else:
try: try: