mirror of https://github.com/MISP/PyMISP
fix: enable taxonomy failed if global pythonify is on
parent
2734224958
commit
aee6945e95
|
@ -1134,7 +1134,10 @@ class PyMISP:
|
||||||
"""
|
"""
|
||||||
taxonomy_id = get_uuid_or_id_from_abstract_misp(taxonomy)
|
taxonomy_id = get_uuid_or_id_from_abstract_misp(taxonomy)
|
||||||
t = self.get_taxonomy(taxonomy_id)
|
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.")
|
raise PyMISPError(f"The taxonomy {t['Taxonomy']['name']} is not enabled.")
|
||||||
url = urljoin(self.root_url, 'taxonomies/addTag/{}'.format(taxonomy_id))
|
url = urljoin(self.root_url, 'taxonomies/addTag/{}'.format(taxonomy_id))
|
||||||
response = self._prepare_request('POST', url)
|
response = self._prepare_request('POST', url)
|
||||||
|
|
|
@ -2054,6 +2054,9 @@ class MISPWarninglist(AbstractMISP):
|
||||||
|
|
||||||
class MISPTaxonomy(AbstractMISP):
|
class MISPTaxonomy(AbstractMISP):
|
||||||
|
|
||||||
|
name: str
|
||||||
|
enabled: bool
|
||||||
|
|
||||||
def from_dict(self, **kwargs):
|
def from_dict(self, **kwargs):
|
||||||
if 'Taxonomy' in kwargs:
|
if 'Taxonomy' in kwargs:
|
||||||
kwargs = kwargs['Taxonomy']
|
kwargs = kwargs['Taxonomy']
|
||||||
|
|
Loading…
Reference in New Issue