Skip to content

Commit aee6945

Browse files
committed
fix: enable taxonomy failed if global pythonify is on
1 parent 2734224 commit aee6945

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

pymisp/api.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1134,7 +1134,10 @@ def enable_taxonomy_tags(self, taxonomy: Union[MISPTaxonomy, int, str, UUID]) ->
11341134
"""
11351135
taxonomy_id = get_uuid_or_id_from_abstract_misp(taxonomy)
11361136
t = self.get_taxonomy(taxonomy_id)
1137-
if not t['Taxonomy']['enabled']:
1137+
if isinstance(t, MISPTaxonomy) and not t.enabled:
1138+
# Can happen if global pythonify is enabled.
1139+
raise PyMISPError(f"The taxonomy {t.name} is not enabled.")
1140+
elif not t['Taxonomy']['enabled']:
11381141
raise PyMISPError(f"The taxonomy {t['Taxonomy']['name']} is not enabled.")
11391142
url = urljoin(self.root_url, 'taxonomies/addTag/{}'.format(taxonomy_id))
11401143
response = self._prepare_request('POST', url)

pymisp/mispevent.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2054,6 +2054,9 @@ def from_dict(self, **kwargs):
20542054

20552055
class MISPTaxonomy(AbstractMISP):
20562056

2057+
name: str
2058+
enabled: bool
2059+
20572060
def from_dict(self, **kwargs):
20582061
if 'Taxonomy' in kwargs:
20592062
kwargs = kwargs['Taxonomy']

0 commit comments

Comments
 (0)