From 7ca2dd2b0d70bec6019209ea59172a113263fe78 Mon Sep 17 00:00:00 2001 From: Samuel Hassine Date: Fri, 21 Jul 2023 00:41:47 +0200 Subject: [PATCH] [client] Implement missing granted_refs at creation --- pycti/entities/opencti_attack_pattern.py | 12 +++++------ pycti/entities/opencti_campaign.py | 12 +++++------ pycti/entities/opencti_case_incident.py | 12 +++++------ pycti/entities/opencti_case_rfi.py | 12 +++++------ pycti/entities/opencti_case_rft.py | 12 +++++------ pycti/entities/opencti_channel.py | 4 ++-- pycti/entities/opencti_course_of_action.py | 4 ++-- pycti/entities/opencti_data_component.py | 4 ++-- pycti/entities/opencti_data_source.py | 4 ++-- pycti/entities/opencti_feedback.py | 4 ++-- pycti/entities/opencti_grouping.py | 4 ++-- pycti/entities/opencti_incident.py | 4 ++-- pycti/entities/opencti_indicator.py | 4 ++-- pycti/entities/opencti_infrastructure.py | 21 ++++++++++++------- pycti/entities/opencti_intrusion_set.py | 4 ++-- pycti/entities/opencti_malware.py | 4 ++-- pycti/entities/opencti_malware_analysis.py | 4 ++-- pycti/entities/opencti_narrative.py | 4 ++-- pycti/entities/opencti_note.py | 4 ++-- pycti/entities/opencti_observed_data.py | 4 ++-- pycti/entities/opencti_opinion.py | 4 ++-- pycti/entities/opencti_report.py | 4 ++-- pycti/entities/opencti_task.py | 4 ++-- pycti/entities/opencti_threat_actor_group.py | 4 ++-- .../opencti_threat_actor_individual.py | 4 ++-- pycti/entities/opencti_tool.py | 10 ++++++++- pycti/entities/opencti_vulnerability.py | 10 ++++++++- 27 files changed, 100 insertions(+), 77 deletions(-) diff --git a/pycti/entities/opencti_attack_pattern.py b/pycti/entities/opencti_attack_pattern.py index a1e8e7c6..f72731b5 100644 --- a/pycti/entities/opencti_attack_pattern.py +++ b/pycti/entities/opencti_attack_pattern.py @@ -427,10 +427,10 @@ def import_from_stix2(self, **kwargs): stix_object[ "x_opencti_stix_ids" ] = self.opencti.get_attribute_in_extension("stix_ids", stix_object) - if "granted_refs" not in stix_object: - stix_object["granted_refs"] = self.opencti.get_attribute_in_extension( - "granted_refs", stix_object - ) + if "x_opencti_granted_refs" not in stix_object: + stix_object[ + "x_opencti_granted_refs" + ] = self.opencti.get_attribute_in_extension("granted_refs", stix_object) return self.create( stix_id=stix_object["id"], @@ -478,8 +478,8 @@ def import_from_stix2(self, **kwargs): x_opencti_stix_ids=stix_object["x_opencti_stix_ids"] if "x_opencti_stix_ids" in stix_object else None, - objectOrganization=stix_object["granted_refs"] - if "granted_refs" in stix_object + objectOrganization=stix_object["x_opencti_granted_refs"] + if "x_opencti_granted_refs" in stix_object else None, update=update, ) diff --git a/pycti/entities/opencti_campaign.py b/pycti/entities/opencti_campaign.py index 699e3094..1237437e 100644 --- a/pycti/entities/opencti_campaign.py +++ b/pycti/entities/opencti_campaign.py @@ -350,10 +350,10 @@ def import_from_stix2(self, **kwargs): stix_object[ "x_opencti_stix_ids" ] = self.opencti.get_attribute_in_extension("stix_ids", stix_object) - if "granted_refs" not in stix_object: - stix_object["granted_refs"] = self.opencti.get_attribute_in_extension( - "granted_refs", stix_object - ) + if "x_opencti_granted_refs" not in stix_object: + stix_object[ + "x_opencti_granted_refs" + ] = self.opencti.get_attribute_in_extension("granted_refs", stix_object) return self.create( stix_id=stix_object["id"], @@ -395,8 +395,8 @@ def import_from_stix2(self, **kwargs): x_opencti_stix_ids=stix_object["x_opencti_stix_ids"] if "x_opencti_stix_ids" in stix_object else None, - objectOrganization=stix_object["granted_refs"] - if "granted_refs" in stix_object + objectOrganization=stix_object["x_opencti_granted_refs"] + if "x_opencti_granted_refs" in stix_object else None, update=update, ) diff --git a/pycti/entities/opencti_case_incident.py b/pycti/entities/opencti_case_incident.py index a735d210..da7774cb 100644 --- a/pycti/entities/opencti_case_incident.py +++ b/pycti/entities/opencti_case_incident.py @@ -634,10 +634,10 @@ def import_from_stix2(self, **kwargs): stix_object[ "x_opencti_stix_ids" ] = self.opencti.get_attribute_in_extension("stix_ids", stix_object) - if "granted_refs" not in stix_object: - stix_object["granted_refs"] = self.opencti.get_attribute_in_extension( - "granted_refs", stix_object - ) + if "x_opencti_granted_refs" not in stix_object: + stix_object[ + "x_opencti_granted_refs" + ] = self.opencti.get_attribute_in_extension("granted_refs", stix_object) if "x_opencti_workflow_id" not in stix_object: stix_object[ "x_opencti_workflow_id" @@ -681,8 +681,8 @@ def import_from_stix2(self, **kwargs): x_opencti_stix_ids=stix_object["x_opencti_stix_ids"] if "x_opencti_stix_ids" in stix_object else None, - objectOrganization=stix_object["granted_refs"] - if "granted_refs" in stix_object + objectOrganization=stix_object["x_opencti_granted_refs"] + if "x_opencti_granted_refs" in stix_object else None, x_opencti_workflow_id=stix_object["x_opencti_workflow_id"] if "x_opencti_workflow_id" in stix_object diff --git a/pycti/entities/opencti_case_rfi.py b/pycti/entities/opencti_case_rfi.py index 66acf5a2..966b9596 100644 --- a/pycti/entities/opencti_case_rfi.py +++ b/pycti/entities/opencti_case_rfi.py @@ -626,10 +626,10 @@ def import_from_stix2(self, **kwargs): stix_object[ "x_opencti_stix_ids" ] = self.opencti.get_attribute_in_extension("stix_ids", stix_object) - if "granted_refs" not in stix_object: - stix_object["granted_refs"] = self.opencti.get_attribute_in_extension( - "granted_refs", stix_object - ) + if "x_opencti_granted_refs" not in stix_object: + stix_object[ + "x_opencti_granted_refs" + ] = self.opencti.get_attribute_in_extension("granted_refs", stix_object) return self.create( stix_id=stix_object["id"], @@ -662,8 +662,8 @@ def import_from_stix2(self, **kwargs): x_opencti_stix_ids=stix_object["x_opencti_stix_ids"] if "x_opencti_stix_ids" in stix_object else None, - objectOrganization=stix_object["granted_refs"] - if "granted_refs" in stix_object + objectOrganization=stix_object["x_opencti_granted_refs"] + if "x_opencti_granted_refs" in stix_object else None, update=update, information_types=stix_object["information_types"] diff --git a/pycti/entities/opencti_case_rft.py b/pycti/entities/opencti_case_rft.py index 7e07d4b6..de912bf8 100644 --- a/pycti/entities/opencti_case_rft.py +++ b/pycti/entities/opencti_case_rft.py @@ -622,10 +622,10 @@ def import_from_stix2(self, **kwargs): stix_object[ "x_opencti_stix_ids" ] = self.opencti.get_attribute_in_extension("stix_ids", stix_object) - if "granted_refs" not in stix_object: - stix_object["granted_refs"] = self.opencti.get_attribute_in_extension( - "granted_refs", stix_object - ) + if "x_opencti_granted_refs" not in stix_object: + stix_object[ + "x_opencti_granted_refs" + ] = self.opencti.get_attribute_in_extension("granted_refs", stix_object) return self.create( stix_id=stix_object["id"], @@ -661,8 +661,8 @@ def import_from_stix2(self, **kwargs): x_opencti_stix_ids=stix_object["x_opencti_stix_ids"] if "x_opencti_stix_ids" in stix_object else None, - objectOrganization=stix_object["granted_refs"] - if "granted_refs" in stix_object + objectOrganization=stix_object["x_opencti_granted_refs"] + if "x_opencti_granted_refs" in stix_object else None, update=update, ) diff --git a/pycti/entities/opencti_channel.py b/pycti/entities/opencti_channel.py index 1a2d6f35..1c59cdcd 100644 --- a/pycti/entities/opencti_channel.py +++ b/pycti/entities/opencti_channel.py @@ -383,8 +383,8 @@ def import_from_stix2(self, **kwargs): x_opencti_stix_ids=stix_object["x_opencti_stix_ids"] if "x_opencti_stix_ids" in stix_object else None, - objectOrganization=stix_object["granted_refs"] - if "granted_refs" in stix_object + objectOrganization=stix_object["x_opencti_granted_refs"] + if "x_opencti_granted_refs" in stix_object else None, update=update, ) diff --git a/pycti/entities/opencti_course_of_action.py b/pycti/entities/opencti_course_of_action.py index b234048a..f7989ac9 100644 --- a/pycti/entities/opencti_course_of_action.py +++ b/pycti/entities/opencti_course_of_action.py @@ -415,8 +415,8 @@ def import_from_stix2(self, **kwargs): else None, x_opencti_aliases=self.opencti.stix2.pick_aliases(stix_object), x_mitre_id=x_mitre_id, - objectOrganization=stix_object["granted_refs"] - if "granted_refs" in stix_object + objectOrganization=stix_object["x_opencti_granted_refs"] + if "x_opencti_granted_refs" in stix_object else None, update=update, ) diff --git a/pycti/entities/opencti_data_component.py b/pycti/entities/opencti_data_component.py index 9c551060..fd2bfa68 100644 --- a/pycti/entities/opencti_data_component.py +++ b/pycti/entities/opencti_data_component.py @@ -421,8 +421,8 @@ def import_from_stix2(self, **kwargs): x_opencti_stix_ids=stix_object["x_opencti_stix_ids"] if "x_opencti_stix_ids" in stix_object else None, - objectOrganization=stix_object["granted_refs"] - if "granted_refs" in stix_object + objectOrganization=stix_object["x_opencti_granted_refs"] + if "x_opencti_granted_refs" in stix_object else None, update=update, ) diff --git a/pycti/entities/opencti_data_source.py b/pycti/entities/opencti_data_source.py index a5cfe7fe..3fc88065 100644 --- a/pycti/entities/opencti_data_source.py +++ b/pycti/entities/opencti_data_source.py @@ -413,8 +413,8 @@ def import_from_stix2(self, **kwargs): x_opencti_stix_ids=stix_object["x_opencti_stix_ids"] if "x_opencti_stix_ids" in stix_object else None, - objectOrganization=stix_object["granted_refs"] - if "granted_refs" in stix_object + objectOrganization=stix_object["x_opencti_granted_refs"] + if "x_opencti_granted_refs" in stix_object else None, update=update, ) diff --git a/pycti/entities/opencti_feedback.py b/pycti/entities/opencti_feedback.py index 242af8df..a7f91a86 100644 --- a/pycti/entities/opencti_feedback.py +++ b/pycti/entities/opencti_feedback.py @@ -685,8 +685,8 @@ def import_from_stix2(self, **kwargs): x_opencti_stix_ids=stix_object["x_opencti_stix_ids"] if "x_opencti_stix_ids" in stix_object else None, - objectOrganization=stix_object["granted_refs"] - if "granted_refs" in stix_object + objectOrganization=stix_object["x_opencti_granted_refs"] + if "x_opencti_granted_refs" in stix_object else None, update=update, ) diff --git a/pycti/entities/opencti_grouping.py b/pycti/entities/opencti_grouping.py index 4da49797..b0595441 100644 --- a/pycti/entities/opencti_grouping.py +++ b/pycti/entities/opencti_grouping.py @@ -627,8 +627,8 @@ def import_from_stix2(self, **kwargs): x_opencti_stix_ids=stix_object["x_opencti_stix_ids"] if "x_opencti_stix_ids" in stix_object else None, - objectOrganization=stix_object["granted_refs"] - if "granted_refs" in stix_object + objectOrganization=stix_object["x_opencti_granted_refs"] + if "x_opencti_granted_refs" in stix_object else None, x_opencti_aliases=self.opencti.stix2.pick_aliases(stix_object), update=update, diff --git a/pycti/entities/opencti_incident.py b/pycti/entities/opencti_incident.py index 4443581f..428d937d 100644 --- a/pycti/entities/opencti_incident.py +++ b/pycti/entities/opencti_incident.py @@ -412,8 +412,8 @@ def import_from_stix2(self, **kwargs): x_opencti_stix_ids=stix_object["x_opencti_stix_ids"] if "x_opencti_stix_ids" in stix_object else None, - objectOrganization=stix_object["granted_refs"] - if "granted_refs" in stix_object + objectOrganization=stix_object["x_opencti_granted_refs"] + if "x_opencti_granted_refs" in stix_object else None, update=update, ) diff --git a/pycti/entities/opencti_indicator.py b/pycti/entities/opencti_indicator.py index e7d61aac..dd025f85 100644 --- a/pycti/entities/opencti_indicator.py +++ b/pycti/entities/opencti_indicator.py @@ -596,8 +596,8 @@ def import_from_stix2(self, **kwargs): x_opencti_create_observables=stix_object["x_opencti_create_observables"] if "x_opencti_create_observables" in stix_object else False, - objectOrganization=stix_object["granted_refs"] - if "granted_refs" in stix_object + objectOrganization=stix_object["x_opencti_granted_refs"] + if "x_opencti_granted_refs" in stix_object else None, update=update, ) diff --git a/pycti/entities/opencti_infrastructure.py b/pycti/entities/opencti_infrastructure.py index ac993fe6..7faf586d 100644 --- a/pycti/entities/opencti_infrastructure.py +++ b/pycti/entities/opencti_infrastructure.py @@ -321,6 +321,7 @@ def create(self, **kwargs): last_seen = kwargs.get("last_seen", None) kill_chain_phases = kwargs.get("killChainPhases", None) x_opencti_stix_ids = kwargs.get("x_opencti_stix_ids", None) + granted_refs = kwargs.get("objectOrganization", None) update = kwargs.get("update", False) if name is not None: @@ -343,6 +344,7 @@ def create(self, **kwargs): "createdBy": created_by, "objectMarking": object_marking, "objectLabel": object_label, + "objectOrganization": granted_refs, "externalReferences": external_references, "revoked": revoked, "confidence": confidence, @@ -381,14 +383,16 @@ def import_from_stix2(self, **kwargs): stix_object = kwargs.get("stixObject", None) extras = kwargs.get("extras", {}) update = kwargs.get("update", False) - - # Search in extensions - if "x_opencti_stix_ids" not in stix_object: - stix_object["x_opencti_stix_ids"] = self.opencti.get_attribute_in_extension( - "stix_ids", stix_object - ) - if stix_object is not None: + # Search in extensions + if "x_opencti_stix_ids" not in stix_object: + stix_object[ + "x_opencti_stix_ids" + ] = self.opencti.get_attribute_in_extension("stix_ids", stix_object) + if "x_opencti_granted_refs" not in stix_object: + stix_object[ + "x_opencti_granted_refs" + ] = self.opencti.get_attribute_in_extension("granted_refs", stix_object) return self.create( stix_id=stix_object["id"], createdBy=extras["created_by_id"] @@ -432,6 +436,9 @@ def import_from_stix2(self, **kwargs): x_opencti_stix_ids=stix_object["x_opencti_stix_ids"] if "x_opencti_stix_ids" in stix_object else None, + objectOrganization=stix_object["x_opencti_granted_refs"] + if "x_opencti_granted_refs" in stix_object + else None, update=update, ) else: diff --git a/pycti/entities/opencti_intrusion_set.py b/pycti/entities/opencti_intrusion_set.py index d10882b5..45b6d215 100644 --- a/pycti/entities/opencti_intrusion_set.py +++ b/pycti/entities/opencti_intrusion_set.py @@ -393,8 +393,8 @@ def import_from_stix2(self, **kwargs): x_opencti_stix_ids=stix_object["x_opencti_stix_ids"] if "x_opencti_stix_ids" in stix_object else None, - objectOrganization=stix_object["granted_refs"] - if "granted_refs" in stix_object + objectOrganization=stix_object["x_opencti_granted_refs"] + if "x_opencti_granted_refs" in stix_object else None, update=update, ) diff --git a/pycti/entities/opencti_malware.py b/pycti/entities/opencti_malware.py index fdb894c5..62df26ff 100644 --- a/pycti/entities/opencti_malware.py +++ b/pycti/entities/opencti_malware.py @@ -439,8 +439,8 @@ def import_from_stix2(self, **kwargs): x_opencti_stix_ids=stix_object["x_opencti_stix_ids"] if "x_opencti_stix_ids" in stix_object else None, - objectOrganization=stix_object["granted_refs"] - if "granted_refs" in stix_object + objectOrganization=stix_object["x_opencti_granted_refs"] + if "x_opencti_granted_refs" in stix_object else None, update=update, ) diff --git a/pycti/entities/opencti_malware_analysis.py b/pycti/entities/opencti_malware_analysis.py index 98dbc293..7c81f161 100644 --- a/pycti/entities/opencti_malware_analysis.py +++ b/pycti/entities/opencti_malware_analysis.py @@ -451,8 +451,8 @@ def import_from_stix2(self, **kwargs): x_opencti_stix_ids=stix_object["x_opencti_stix_ids"] if "x_opencti_stix_ids" in stix_object else None, - objectOrganization=stix_object["granted_refs"] - if "granted_refs" in stix_object + objectOrganization=stix_object["x_opencti_granted_refs"] + if "x_opencti_granted_refs" in stix_object else None, update=update, ) diff --git a/pycti/entities/opencti_narrative.py b/pycti/entities/opencti_narrative.py index b2c1a1c4..097907be 100644 --- a/pycti/entities/opencti_narrative.py +++ b/pycti/entities/opencti_narrative.py @@ -383,8 +383,8 @@ def import_from_stix2(self, **kwargs): x_opencti_stix_ids=stix_object["x_opencti_stix_ids"] if "x_opencti_stix_ids" in stix_object else None, - objectOrganization=stix_object["granted_refs"] - if "granted_refs" in stix_object + objectOrganization=stix_object["x_opencti_granted_refs"] + if "x_opencti_granted_refs" in stix_object else None, update=update, ) diff --git a/pycti/entities/opencti_note.py b/pycti/entities/opencti_note.py index 3087c681..ae6e1d5c 100644 --- a/pycti/entities/opencti_note.py +++ b/pycti/entities/opencti_note.py @@ -629,8 +629,8 @@ def import_from_stix2(self, **kwargs): likelihood=stix_object["likelihood"] if "likelihood" in stix_object else None, - objectOrganization=stix_object["granted_refs"] - if "granted_refs" in stix_object + objectOrganization=stix_object["x_opencti_granted_refs"] + if "x_opencti_granted_refs" in stix_object else None, update=update, ) diff --git a/pycti/entities/opencti_observed_data.py b/pycti/entities/opencti_observed_data.py index e7b418b5..d949aa1c 100644 --- a/pycti/entities/opencti_observed_data.py +++ b/pycti/entities/opencti_observed_data.py @@ -627,8 +627,8 @@ def import_from_stix2(self, **kwargs): x_opencti_stix_ids=stix_object["x_opencti_stix_ids"] if "x_opencti_stix_ids" in stix_object else None, - objectOrganization=stix_object["granted_refs"] - if "granted_refs" in stix_object + objectOrganization=stix_object["x_opencti_granted_refs"] + if "x_opencti_granted_refs" in stix_object else None, update=update, ) diff --git a/pycti/entities/opencti_opinion.py b/pycti/entities/opencti_opinion.py index d48b2ca5..98bf9a80 100644 --- a/pycti/entities/opencti_opinion.py +++ b/pycti/entities/opencti_opinion.py @@ -590,8 +590,8 @@ def import_from_stix2(self, **kwargs): if "x_opencti_stix_ids" in stix_object else None, opinion=stix_object["opinion"] if "opinion" in stix_object else None, - objectOrganization=stix_object["granted_refs"] - if "granted_refs" in stix_object + objectOrganization=stix_object["x_opencti_granted_refs"] + if "x_opencti_granted_refs" in stix_object else None, update=update, ) diff --git a/pycti/entities/opencti_report.py b/pycti/entities/opencti_report.py index 9b55ab8e..384f5a48 100644 --- a/pycti/entities/opencti_report.py +++ b/pycti/entities/opencti_report.py @@ -658,8 +658,8 @@ def import_from_stix2(self, **kwargs): x_opencti_stix_ids=stix_object["x_opencti_stix_ids"] if "x_opencti_stix_ids" in stix_object else None, - objectOrganization=stix_object["granted_refs"] - if "granted_refs" in stix_object + objectOrganization=stix_object["x_opencti_granted_refs"] + if "x_opencti_granted_refs" in stix_object else None, update=update, ) diff --git a/pycti/entities/opencti_task.py b/pycti/entities/opencti_task.py index a58ddced..40a6540e 100644 --- a/pycti/entities/opencti_task.py +++ b/pycti/entities/opencti_task.py @@ -651,8 +651,8 @@ def import_from_stix2(self, **kwargs): if "description" in stix_object else None, due_date=stix_object["due_date"] if "due_date" in stix_object else None, - objectOrganization=stix_object["granted_refs"] - if "granted_refs" in stix_object + objectOrganization=stix_object["x_opencti_granted_refs"] + if "x_opencti_granted_refs" in stix_object else None, update=update, ) diff --git a/pycti/entities/opencti_threat_actor_group.py b/pycti/entities/opencti_threat_actor_group.py index 12c2200f..5021c46c 100644 --- a/pycti/entities/opencti_threat_actor_group.py +++ b/pycti/entities/opencti_threat_actor_group.py @@ -463,8 +463,8 @@ def import_from_stix2(self, **kwargs): x_opencti_stix_ids=stix_object["x_opencti_stix_ids"] if "x_opencti_stix_ids" in stix_object else None, - objectOrganization=stix_object["granted_refs"] - if "granted_refs" in stix_object + objectOrganization=stix_object["x_opencti_granted_refs"] + if "x_opencti_granted_refs" in stix_object else None, update=update, ) diff --git a/pycti/entities/opencti_threat_actor_individual.py b/pycti/entities/opencti_threat_actor_individual.py index 4e04f31a..53889567 100644 --- a/pycti/entities/opencti_threat_actor_individual.py +++ b/pycti/entities/opencti_threat_actor_individual.py @@ -465,8 +465,8 @@ def import_from_stix2(self, **kwargs): x_opencti_stix_ids=stix_object["x_opencti_stix_ids"] if "x_opencti_stix_ids" in stix_object else None, - objectOrganization=stix_object["granted_refs"] - if "granted_refs" in stix_object + objectOrganization=stix_object["x_opencti_granted_refs"] + if "x_opencti_granted_refs" in stix_object else None, update=update, ) diff --git a/pycti/entities/opencti_tool.py b/pycti/entities/opencti_tool.py index 4d343cb7..00467ec3 100644 --- a/pycti/entities/opencti_tool.py +++ b/pycti/entities/opencti_tool.py @@ -301,6 +301,7 @@ def create(self, **kwargs): tool_version = kwargs.get("tool_version", None) kill_chain_phases = kwargs.get("killChainPhases", None) x_opencti_stix_ids = kwargs.get("x_opencti_stix_ids", None) + granted_refs = kwargs.get("objectOrganization", None) update = kwargs.get("update", False) if name is not None: @@ -323,6 +324,7 @@ def create(self, **kwargs): "createdBy": created_by, "objectMarking": object_marking, "objectLabel": object_label, + "objectOrganization": granted_refs, "externalReferences": external_references, "revoked": revoked, "confidence": confidence, @@ -361,7 +363,10 @@ def import_from_stix2(self, **kwargs): stix_object[ "x_opencti_stix_ids" ] = self.opencti.get_attribute_in_extension("stix_ids", stix_object) - + if "x_opencti_granted_refs" not in stix_object: + stix_object[ + "x_opencti_granted_refs" + ] = self.opencti.get_attribute_in_extension("granted_refs", stix_object) return self.opencti.tool.create( stix_id=stix_object["id"], createdBy=extras["created_by_id"] @@ -402,6 +407,9 @@ def import_from_stix2(self, **kwargs): x_opencti_stix_ids=stix_object["x_opencti_stix_ids"] if "x_opencti_stix_ids" in stix_object else None, + objectOrganization=stix_object["x_opencti_granted_refs"] + if "x_opencti_granted_refs" in stix_object + else None, update=update, ) else: diff --git a/pycti/entities/opencti_vulnerability.py b/pycti/entities/opencti_vulnerability.py index 01d930cf..bf5fe47c 100644 --- a/pycti/entities/opencti_vulnerability.py +++ b/pycti/entities/opencti_vulnerability.py @@ -299,6 +299,7 @@ def create(self, **kwargs): "x_opencti_confidentiality_impact", None ) x_opencti_stix_ids = kwargs.get("x_opencti_stix_ids", None) + granted_refs = kwargs.get("objectOrganization", None) update = kwargs.get("update", False) if name is not None: @@ -321,6 +322,7 @@ def create(self, **kwargs): "createdBy": created_by, "objectMarking": object_marking, "objectLabel": object_label, + "objectOrganization": granted_refs, "externalReferences": external_references, "revoked": revoked, "confidence": confidence, @@ -404,7 +406,10 @@ def import_from_stix2(self, **kwargs): stix_object[ "x_opencti_stix_ids" ] = self.opencti.get_attribute_in_extension("stix_ids", stix_object) - + if "x_opencti_granted_refs" not in stix_object: + stix_object[ + "x_opencti_granted_refs" + ] = self.opencti.get_attribute_in_extension("granted_refs", stix_object) return self.create( stix_id=stix_object["id"], createdBy=extras["created_by_id"] @@ -460,6 +465,9 @@ def import_from_stix2(self, **kwargs): x_opencti_stix_ids=stix_object["x_opencti_stix_ids"] if "x_opencti_stix_ids" in stix_object else None, + objectOrganization=stix_object["x_opencti_granted_refs"] + if "x_opencti_granted_refs" in stix_object + else None, update=update, ) else: