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

Commit f485949

Browse files
author
Samuel Hassine
committed
[client] Fix creation of locations
1 parent 6d6a84d commit f485949

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

pycti/entities/opencti_location.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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
)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from setuptools import setup
66
from setuptools.command.install import install
77

8-
VERSION = "4.1.1"
8+
VERSION = "4.2.0"
99

1010
with open("README.md", "r") as fh:
1111
long_description = fh.read()

0 commit comments

Comments
 (0)