From aee6945e95c647cf01d04fdf1282b6887744e041 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Tue, 9 Mar 2021 16:35:00 +0100 Subject: [PATCH] fix: enable taxonomy failed if global pythonify is on --- pymisp/api.py | 5 ++++- pymisp/mispevent.py | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/pymisp/api.py b/pymisp/api.py index f0f4cf0..6efff1e 100644 --- a/pymisp/api.py +++ b/pymisp/api.py @@ -1134,7 +1134,10 @@ class PyMISP: """ taxonomy_id = get_uuid_or_id_from_abstract_misp(taxonomy) t = self.get_taxonomy(taxonomy_id) - if not t['Taxonomy']['enabled']: + if isinstance(t, MISPTaxonomy) and not t.enabled: + # Can happen if global pythonify is enabled. + raise PyMISPError(f"The taxonomy {t.name} is not enabled.") + elif not t['Taxonomy']['enabled']: raise PyMISPError(f"The taxonomy {t['Taxonomy']['name']} is not enabled.") url = urljoin(self.root_url, 'taxonomies/addTag/{}'.format(taxonomy_id)) response = self._prepare_request('POST', url) diff --git a/pymisp/mispevent.py b/pymisp/mispevent.py index 5117334..218dea0 100644 --- a/pymisp/mispevent.py +++ b/pymisp/mispevent.py @@ -2054,6 +2054,9 @@ class MISPWarninglist(AbstractMISP): class MISPTaxonomy(AbstractMISP): + name: str + enabled: bool + def from_dict(self, **kwargs): if 'Taxonomy' in kwargs: kwargs = kwargs['Taxonomy']