@@ -287,11 +287,29 @@ def import_from_stix2(self, **kwargs):
287287 stix_object = kwargs .get ("stixObject" , None )
288288 extras = kwargs .get ("extras" , {})
289289 update = kwargs .get ("update" , False )
290- if stix_object is not None :
291- if "x_opencti_location_type" in stix_object :
292- type = stix_object ["x_opencti_location_type" ]
290+ if "name" in stix_object :
291+ name = stix_object ["name" ]
292+ elif "city" in stix_object :
293+ name = stix_object ["city" ]
294+ elif "country" in stix_object :
295+ name = stix_object ["country" ]
296+ elif "region" in stix_object :
297+ name = stix_object ["region" ]
298+ else :
299+ self .opencti .log ("error" , "[opencti_location] Missing name" )
300+ return
301+ if "x_opencti_location_type" in stix_object :
302+ type = stix_object ["x_opencti_location_type" ]
303+ else :
304+ if "city" in stix_object :
305+ type = "City"
306+ elif "country" in stix_object :
307+ type = "Country"
308+ elif "region" in stix_object :
309+ type = "Region"
293310 else :
294311 type = "Position"
312+ if stix_object is not None :
295313 return self .create (
296314 type = type ,
297315 stix_id = stix_object ["id" ],
@@ -314,7 +332,7 @@ def import_from_stix2(self, **kwargs):
314332 lang = stix_object ["lang" ] if "lang" in stix_object else None ,
315333 created = stix_object ["created" ] if "created" in stix_object else None ,
316334 modified = stix_object ["modified" ] if "modified" in stix_object else None ,
317- name = stix_object [ " name" ] ,
335+ name = name ,
318336 description = self .opencti .stix2 .convert_markdown (
319337 stix_object ["description" ]
320338 )
0 commit comments