Skip to content
This repository was archived by the owner on Dec 5, 2025. It is now read-only.

Commit a2c47ab

Browse files
[client] Migrate vocabulary to be handled like labels
1 parent 3e6f112 commit a2c47ab

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

pycti/entities/opencti_vocabulary.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,15 @@ def handle_vocab(self, vocab, cache, field):
8787
return vocab_data
8888

8989
def create(self, **kwargs):
90+
stix_id = kwargs.get("stix_id", None)
9091
name = kwargs.get("name", None)
9192
category = kwargs.get("category", None)
93+
description = kwargs.get("description", None)
94+
created = kwargs.get("created", None)
95+
modified = kwargs.get("modified", None)
96+
aliases = kwargs.get("aliases", None)
97+
x_opencti_stix_ids = kwargs.get("x_opencti_stix_ids", None)
98+
update = kwargs.get("update", False)
9299

93100
if name is not None and category is not None:
94101
self.opencti.log(
@@ -109,8 +116,15 @@ def create(self, **kwargs):
109116
query,
110117
{
111118
"input": {
119+
"stix_id": stix_id,
120+
"x_opencti_stix_ids": x_opencti_stix_ids,
112121
"name": name,
122+
"description": description,
113123
"category": category,
124+
"created": created,
125+
"modified": modified,
126+
"aliases": aliases,
127+
"update": update,
114128
}
115129
},
116130
)

pycti/utils/opencti_stix2.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,6 @@ def import_object(
694694
"tool": self.opencti.tool.import_from_stix2,
695695
"channel": self.opencti.channel.import_from_stix2,
696696
"narrative": self.opencti.narrative.import_from_stix2,
697-
"Vocabulary": self.opencti.vocabulary.import_from_stix2,
698697
"vulnerability": self.opencti.vulnerability.import_from_stix2,
699698
"incident": self.opencti.incident.import_from_stix2,
700699
}
@@ -1764,7 +1763,6 @@ def export_entity(
17641763
"Tool": self.opencti.tool.read,
17651764
"Channel": self.opencti.channel.read,
17661765
"Narrative": self.opencti.narrative.read,
1767-
"Vocabulary": self.opencti.vocabulary.read,
17681766
"Vulnerability": self.opencti.vulnerability.read,
17691767
"Incident": self.opencti.incident.read,
17701768
"Stix-Cyber-Observable": self.opencti.stix_cyber_observable.read,
@@ -1863,7 +1861,6 @@ def export_list(
18631861
"Tool": self.opencti.tool.list,
18641862
"Channel": self.opencti.channel.list,
18651863
"Narrative": self.opencti.narrative.list,
1866-
"Vocabulary": self.opencti.vocabulary.list,
18671864
"Vulnerability": self.opencti.vulnerability.list,
18681865
"Incident": self.opencti.incident.list,
18691866
"Stix-Cyber-Observable": self.opencti.stix_cyber_observable.list,
@@ -1965,6 +1962,17 @@ def import_bundle(
19651962
x_opencti_stix_ids=stix_ids,
19661963
update=update,
19671964
)
1965+
elif item["type"] == "vocabulary":
1966+
stix_ids = self.opencti.get_attribute_in_extension("stix_ids", item)
1967+
self.opencti.vocabulary.create(
1968+
stix_id=item["id"],
1969+
name=item["name"],
1970+
category=item["category"],
1971+
description=item["description"],
1972+
aliases=item["aliases"],
1973+
x_opencti_stix_ids=stix_ids,
1974+
update=update,
1975+
)
19681976
elif item["type"] == "external-reference":
19691977
stix_ids = self.opencti.get_attribute_in_extension("stix_ids", item)
19701978
self.opencti.external_reference.create(

0 commit comments

Comments
 (0)