Skip to content

Commit 4f2cf0d

Browse files
author
Samuel Hassine
committed
[connector_helper] Hotfix - Do not process relationship if entity source_ref or target_ref is not is the bundle
1 parent 77f97e0 commit 4f2cf0d

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

pycti/opencti_connector_helper.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,11 @@ def stix2_get_embedded_objects(self, item):
163163
object_marking_refs = []
164164
if 'object_marking_refs' in item:
165165
for object_marking_ref in item['object_marking_refs']:
166-
object_marking_refs.append(self.cache_index[object_marking_ref])
166+
if object_marking_ref in self.cache_index:
167+
object_marking_refs.append(self.cache_index[object_marking_ref])
167168
# Created by ref
168169
created_by_ref = None
169-
if 'created_by_ref' in item:
170+
if 'created_by_ref' in item and item['created_by_ref'] in self.cache_index:
170171
created_by_ref = self.cache_index[item['created_by_ref']]
171172

172173
return {'object_marking_refs': object_marking_refs, 'created_by_ref': created_by_ref}
@@ -187,10 +188,16 @@ def stix2_get_entity_objects(self, entity):
187188
def stix2_get_relationship_objects(self, relationship):
188189
items = [relationship]
189190
# Get source ref
190-
items.append(self.cache_index[relationship['source_ref']])
191+
if relationship['source_ref'] in self.cache_index:
192+
items.append(self.cache_index[relationship['source_ref']])
193+
else:
194+
return []
191195

192196
# Get target ref
193-
items.append(self.cache_index[relationship['target_ref']])
197+
if relationship['target_ref'] in self.cache_index:
198+
items.append(self.cache_index[relationship['target_ref']])
199+
else:
200+
return []
194201

195202
# Get embedded objects
196203
embedded_objects = self.stix2_get_embedded_objects(relationship)

0 commit comments

Comments
 (0)