Skip to content

Commit d6c1fc1

Browse files
[client] New OpenCTI capability "manage taxonomy" prevents creating data (#985)
1 parent 9f2f789 commit d6c1fc1

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

pycti/entities/opencti_vocabulary.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def read(self, **kwargs):
9595
)
9696
return None
9797

98-
def handle_vocab(self, vocab, cache, field):
98+
def read_or_create_unchecked_with_cache(self, vocab, cache, field):
9999
if "vocab_" + vocab in cache:
100100
vocab_data = cache["vocab_" + vocab]
101101
else:

pycti/utils/opencti_stix2.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -360,17 +360,23 @@ def extract_embedded_relationships(
360360
if isinstance(stix_object.get(f["key"]), list):
361361
object_open_vocabularies[f["key"]] = []
362362
for vocab in stix_object[f["key"]]:
363-
object_open_vocabularies[f["key"]].append(
364-
self.opencti.vocabulary.handle_vocab(
363+
resolved_vocab = (
364+
self.opencti.vocabulary.read_or_create_unchecked_with_cache(
365365
vocab, self.mapping_cache_permanent, field=f
366-
)["name"]
366+
)
367367
)
368+
if resolved_vocab is not None:
369+
object_open_vocabularies[f["key"]].append(
370+
resolved_vocab["name"]
371+
)
368372
else:
369-
object_open_vocabularies[f["key"]] = (
370-
self.opencti.vocabulary.handle_vocab(
373+
resolved_vocab = (
374+
self.opencti.vocabulary.read_or_create_unchecked_with_cache(
371375
stix_object[f["key"]], self.mapping_cache_permanent, field=f
372-
)["name"]
376+
)
373377
)
378+
if resolved_vocab is not None:
379+
object_open_vocabularies[f["key"]] = resolved_vocab["name"]
374380

375381
# Object Labels
376382
object_label_ids = []

0 commit comments

Comments
 (0)