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

Commit 61362d2

Browse files
[client] create get_reader method from entity_type (#605)
1 parent ed85161 commit 61362d2

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

pycti/utils/opencti_stix2.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,21 @@ def get_readers(self):
835835
"Vulnerability": self.opencti.vulnerability.read,
836836
}
837837

838+
def get_reader(self, entity_type: str):
839+
# Map types
840+
if entity_type == "StixFile":
841+
entity_type = "File"
842+
if IdentityTypes.has_value(entity_type):
843+
entity_type = "Identity"
844+
if LocationTypes.has_value(entity_type):
845+
entity_type = "Location"
846+
if StixCyberObservableTypes.has_value(entity_type):
847+
entity_type = "Stix-Cyber-Observable"
848+
readers = self.get_readers()
849+
return readers.get(
850+
entity_type, lambda **kwargs: self.unknown_type({"type": entity_type})
851+
)
852+
838853
# endregion
839854

840855
# region import

0 commit comments

Comments
 (0)