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

Commit 620c5b7

Browse files
committed
[client] Take into account Administrative Areas
1 parent eebfccc commit 620c5b7

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

pycti/entities/opencti_location.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,9 +342,18 @@ def import_from_stix2(self, **kwargs):
342342
self.opencti.log("error", "[opencti_location] Missing name")
343343
return
344344
if "x_opencti_location_type" in stix_object:
345-
type = stix_object["x_opencti_location_type"]
345+
if stix_object["x_opencti_location_type"] == "Administrative-Area":
346+
type = "AdministrativeArea"
347+
else:
348+
type = stix_object["x_opencti_location_type"]
346349
elif self.opencti.get_attribute_in_extension("type", stix_object) is not None:
347-
type = self.opencti.get_attribute_in_extension("type", stix_object)
350+
if (
351+
self.opencti.get_attribute_in_extension("type", stix_object)
352+
== "Administrative-Area"
353+
):
354+
type = "AdministrativeArea"
355+
else:
356+
type = self.opencti.get_attribute_in_extension("type", stix_object)
348357
else:
349358
if "city" in stix_object:
350359
type = "City"

pycti/utils/constants.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,10 @@ def has_value(cls, value):
5555

5656

5757
class LocationTypes(Enum):
58-
CITY = "City"
59-
COUNTRY = "Country"
6058
REGION = "Region"
59+
COUNTRY = "Country"
60+
ADMINISTRATIVE_AREA = "Administrative-Area"
61+
CITY = "City"
6162
POSITION = "Position"
6263

6364
@classmethod

pycti/utils/opencti_stix2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1123,7 +1123,7 @@ def generate_export(self, entity: Dict, no_custom_attributes: bool = False) -> D
11231123

11241124
# Locations
11251125
if LocationTypes.has_value(entity["entity_type"]):
1126-
if not not no_custom_attributes:
1126+
if not no_custom_attributes:
11271127
entity["x_opencti_location_type"] = entity["entity_type"]
11281128
if entity["entity_type"] == "City":
11291129
entity["city"] = entity["name"]

0 commit comments

Comments
 (0)