fix: enable taxonomy failed if global pythonify is on

pull/749/head
Raphaël Vinot 2021-03-09 16:35:00 +01:00
parent 2734224958
commit aee6945e95
2 changed files with 7 additions and 1 deletions

View File

@ -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)

View File

@ -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']