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

Commit 263e461

Browse files
author
Samuel Hassine
committed
[client] Fix export of locations (#154)
1 parent dd9e420 commit 263e461

File tree

2 files changed

+100
-0
lines changed

2 files changed

+100
-0
lines changed

export.json

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
{
2+
"type": "bundle",
3+
"id": "bundle--b87a7ec9-44b8-4071-a9a7-571af3eabc4a",
4+
"objects": [
5+
{
6+
"id": "report--75d46334-8698-54e9-a5ac-b3a4fce15e61",
7+
"spec_version": "2.1",
8+
"revoked": false,
9+
"confidence": 15,
10+
"created": "2021-03-14T05:00:00.000Z",
11+
"modified": "2021-03-14T21:12:56.645Z",
12+
"name": "foobarbaz",
13+
"report_types": [
14+
"threat-report"
15+
],
16+
"published": "2021-03-14T05:00:00.000Z",
17+
"x_opencti_report_status": 0,
18+
"x_opencti_id": "d2383b08-d7a1-412f-8702-be40ee933f2e",
19+
"type": "report",
20+
"object_refs": [
21+
"location--713e5fdc-da7b-5735-958d-d7dc664efa7f",
22+
"location--894bf7fe-35e0-5bdb-80b9-ca64177e6d1c",
23+
"relationship--37543c87-0ea1-46fa-a6b0-dbfeaee6854e"
24+
]
25+
},
26+
{
27+
"id": "identity--1a2a13e0-b663-5b1b-8e52-6a4b08fb8f85",
28+
"spec_version": "2.1",
29+
"name": "Agence Nationale de la S\u00e9curit\u00e9 des Syst\u00e8mes d'Information",
30+
"description": "The Agence nationale de la s\u00e9curit\u00e9 des syst\u00e8mes d'information (ANSSI; English: National Cybersecurity Agency of France) is a French service created on 7 July 2009 with responsibility for computer security.",
31+
"x_opencti_aliases": [
32+
"ANSSI"
33+
],
34+
"created": "2021-01-27T00:15:41.909Z",
35+
"modified": "2021-01-27T00:15:41.909Z",
36+
"x_opencti_organization_type": "csirt",
37+
"x_opencti_id": "635fbafb-8ad7-4135-ac16-9fb48bdbcd02",
38+
"type": "identity"
39+
},
40+
{
41+
"id": "location--713e5fdc-da7b-5735-958d-d7dc664efa7f",
42+
"spec_version": "2.1",
43+
"revoked": false,
44+
"confidence": 15,
45+
"created": "2020-09-08T07:54:26.059Z",
46+
"modified": "2020-09-08T07:54:26.059Z",
47+
"name": "Northern America",
48+
"x_opencti_location_type": "Region",
49+
"latitude": 39.7392364,
50+
"longitude": -104.9848623,
51+
"x_opencti_id": "886f6776-7d0d-42eb-b45b-853082a2fda0",
52+
"type": "location",
53+
"created_by_ref": "identity--1a2a13e0-b663-5b1b-8e52-6a4b08fb8f85"
54+
},
55+
{
56+
"id": "location--894bf7fe-35e0-5bdb-80b9-ca64177e6d1c",
57+
"spec_version": "2.1",
58+
"revoked": false,
59+
"confidence": 15,
60+
"created": "2020-09-08T07:54:26.059Z",
61+
"modified": "2020-09-08T07:54:26.059Z",
62+
"name": "Canada",
63+
"x_opencti_location_type": "Country",
64+
"latitude": 56.130366,
65+
"longitude": -106.346771,
66+
"x_opencti_aliases": [
67+
"CAN",
68+
"CA"
69+
],
70+
"x_opencti_id": "595722f9-debd-421b-9b09-2f8dd1cb2414",
71+
"type": "location",
72+
"created_by_ref": "identity--1a2a13e0-b663-5b1b-8e52-6a4b08fb8f85"
73+
},
74+
{
75+
"id": "relationship--37543c87-0ea1-46fa-a6b0-dbfeaee6854e",
76+
"spec_version": "2.1",
77+
"relationship_type": "located-at",
78+
"description": "Country Canada is a located in Northern America",
79+
"start_time": "1970-01-01T00:00:00.000Z",
80+
"stop_time": "5138-11-16T09:46:40.000Z",
81+
"revoked": false,
82+
"confidence": 100,
83+
"lang": "en",
84+
"created": "2020-09-08T07:54:26.059Z",
85+
"modified": "2020-09-08T07:54:26.059Z",
86+
"x_opencti_id": "56e83d05-b157-496b-85d4-a78c5bbebc43",
87+
"type": "relationship",
88+
"created_by_ref": "identity--1a2a13e0-b663-5b1b-8e52-6a4b08fb8f85",
89+
"source_ref": "location--894bf7fe-35e0-5bdb-80b9-ca64177e6d1c",
90+
"target_ref": "location--713e5fdc-da7b-5735-958d-d7dc664efa7f"
91+
}
92+
]
93+
}

pycti/utils/opencti_stix2.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -912,6 +912,13 @@ def generate_export(self, entity):
912912

913913
# Locations
914914
if LocationTypes.has_value(entity["entity_type"]):
915+
entity["x_opencti_location_type"] = entity["entity_type"]
916+
if entity["entity_type"] == "City":
917+
entity["city"] = entity["name"]
918+
elif entity["entity_type"] == "Country":
919+
entity["country"] = entity["name"]
920+
elif entity["entity_type"] == "Region":
921+
entity["region"] = entity["name"]
915922
entity["entity_type"] = "Location"
916923

917924
# Indicators

0 commit comments

Comments
 (0)