mirror of https://github.com/MISP/PyMISP
Merge pull request #83 from bernhl/fix_api_version_check
Fix checks of recommended versionpull/84/head
commit
e76f19e793
|
@ -117,19 +117,16 @@ class PyMISP(object):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Make sure the MISP instance is working and the URL is valid
|
# Make sure the MISP instance is working and the URL is valid
|
||||||
pymisp_version = __version__.split('.')
|
|
||||||
response = self.get_recommended_api_version()
|
response = self.get_recommended_api_version()
|
||||||
if not response.get('version'):
|
if not response.get('version'):
|
||||||
logger.warning("Unable to check the recommended PyMISP version (MISP <2.4.60), please upgrade.")
|
logger.warning("Unable to check the recommended PyMISP version (MISP <2.4.60), please upgrade.")
|
||||||
else:
|
else:
|
||||||
recommended_pymisp_version = response['version'].split('.')
|
pymisp_version_tup = tuple(int(x) for x in __version__.split('.'))
|
||||||
for a, b in zip(pymisp_version, recommended_pymisp_version):
|
recommended_version_tup = tuple(int(x) for x in response['version'].split('.'))
|
||||||
if a == b:
|
if recommended_version_tup < pymisp_version_tup:
|
||||||
continue
|
logger.warning("The version of PyMISP recommended by the MISP instance ({}) is older than the one you're using now ({}). Please upgrade the MISP instance or use an older PyMISP version.".format(response['version'], __version__))
|
||||||
elif a > b:
|
elif pymisp_version_tup < recommended_version_tup:
|
||||||
logger.warning("The version of PyMISP recommended by the MISP instance ({}) is older than the one you're using now ({}). Please upgrade the MISP instance or use an older PyMISP version.".format(response['version'], __version__))
|
logger.warning("The version of PyMISP recommended by the MISP instance ({}) is newer than the one you're using now ({}). Please upgrade PyMISP.".format(response['version'], __version__))
|
||||||
else: # a < b
|
|
||||||
logger.warning("The version of PyMISP recommended by the MISP instance ({}) is newer than the one you're using now ({}). Please upgrade PyMISP.".format(response['version'], __version__))
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise PyMISPError('Unable to connect to MISP ({}). Please make sure the API key and the URL are correct (http/https is required): {}'.format(self.root_url, e))
|
raise PyMISPError('Unable to connect to MISP ({}). Please make sure the API key and the URL are correct (http/https is required): {}'.format(self.root_url, e))
|
||||||
|
|
Loading…
Reference in New Issue