Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:TheHive-Project/Cortex-Analyzers…
Browse files Browse the repository at this point in the history
… into develop
  • Loading branch information
jeromeleonard committed Jun 18, 2018
2 parents 0f1e9b4 + 05b78fc commit e719da3
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 42 deletions.
82 changes: 52 additions & 30 deletions analyzers/MISP/MISP.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,60 @@
"url": "https://github.com/BSI-CERT-Bund/cortex-analyzers",
"version": "2.0",
"description": "Query multiple MISP instances for events containing an observable.",
"dataTypeList": ["domain", "ip", "url", "fqdn", "uri_path","user-agent", "hash", "email", "mail", "mail_subject" , "registry", "regexp", "other", "filename"],
"dataTypeList": [
"domain",
"ip",
"url",
"fqdn",
"uri_path",
"user-agent",
"hash",
"email",
"mail",
"mail_subject",
"registry",
"regexp",
"other",
"filename"
],
"baseConfig": "MISP",
"command": "MISP/misp.py",
"configurationItems": [
{
"name": "url",
"description": "URL of MISP servers",
"type": "string",
"multi": true,
"required": true
},
{
"name": "key",
"description": "API key for each server",
"type": "string",
"multi": true,
"required": true
},
{
"name": "cert_check",
"description": "Verify server certificate",
"type": "boolean",
"multi": false,
"required": true,
"defaultValue": true
},
{
"name": "cert_path",
"description": "Path to the CA on the system used to check server certificate",
"type": "string",
"multi": true,
"required": false
}
{
"name": "name",
"description": "Name of MISP servers",
"multi": true,
"required": false,
"type": "string"
},
{
"name": "url",
"description": "URL of MISP servers",
"type": "string",
"multi": true,
"required": true
},
{
"name": "key",
"description": "API key for each server",
"type": "string",
"multi": true,
"required": true
},
{
"name": "cert_check",
"description": "Verify server certificate",
"type": "boolean",
"multi": false,
"required": true,
"defaultValue": true
},
{
"name": "cert_path",
"description": "Path to the CA on the system used to check server certificate",
"type": "string",
"multi": true,
"required": false
}
]
}
6 changes: 5 additions & 1 deletion analyzers/MISP/misp.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ def __init__(self):
# Fixes #94. Instead of None, the string Unnamed should be passed to MISPClient constructor
name = self.get_param('config.name', 'Unnamed')
if self.get_param('config.cert_check', True):
ssl = self.get_param('config.cert_path', True)
ssl_path = self.get_param('config.cert_path', None)
if not ssl_path or ssl_path == '':
ssl = True
else:
ssl = ssl_path
else:
ssl = False
try:
Expand Down
21 changes: 10 additions & 11 deletions analyzers/MISP/mispclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,29 +44,28 @@ def __init__(self, url, key, ssl=True, name='Unnamed', proxies=None):
if isinstance(ssl, list):
if isinstance(ssl[idx], str) and os.path.isfile(ssl[idx]):
verify = ssl[idx]
elif isinstance(ssl[idx], str) and not os.path.isfile(ssl[idx]):
elif isinstance(ssl[idx], str) and not os.path.isfile(ssl[idx]) and ssl[idx] != "":
raise CertificateNotFoundError('Certificate not found under {}.'.format(ssl[idx]))
elif isinstance(ssl[idx], bool):
verify = ssl[idx]
else:
raise TypeError('SSL parameter is a not expected type.')

# Do the same checks again, for the non-list type
elif isinstance(ssl, str):
if os.path.isfile(ssl):
verify = ssl
elif isinstance(ssl, str) and os.path.isfile(ssl):
verify = ssl
elif isinstance(ssl, str) and not os.path.isfile(ssl) and ssl != "":
raise CertificateNotFoundError('Certificate not found under {}.'.format(ssl))
elif isinstance(ssl, bool):
verify = ssl
else:
raise TypeError('SSL parameter is a not expected type.')
self.misp_connections.append(pymisp.PyMISP(url=server,
key=key[idx],
ssl=verify,
proxies=proxies))
else:
verify = True
if isinstance(ssl, str):
if os.path.isfile(ssl):
verify = ssl
if isinstance(ssl, str) and os.path.isfile(ssl):
verify = ssl
elif isinstance(ssl, str) and not os.path.isfile(ssl) and ssl != "":
raise CertificateNotFoundError('Certificate not found under {}.'.format(ssl))
elif isinstance(ssl, bool):
verify = ssl
self.misp_connections.append(pymisp.PyMISP(url=url,
Expand Down

0 comments on commit e719da3

Please sign in to comment.