Skip to content

Commit 8a82f3d

Browse files
author
Samuel Hassine
committed
[client] Handle aliases in idetntiy
1 parent 7511c9b commit 8a82f3d

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

pycti/api/opencti_api_client.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1023,7 +1023,7 @@ def get_identities(self, limit=10000):
10231023
result = self.query(query, {'first': limit})
10241024
return self.parse_multiple(result['data']['identities'])
10251025

1026-
def create_identity(self, type, name, description, id=None, stix_id_key=None, created=None, modified=None):
1026+
def create_identity(self, type, name, description, alias=None, id=None, stix_id_key=None, created=None, modified=None):
10271027
logging.info('Creating identity ' + name + '...')
10281028
query = """
10291029
mutation IdentityAdd($input: IdentityAddInput) {
@@ -1038,6 +1038,7 @@ def create_identity(self, type, name, description, id=None, stix_id_key=None, cr
10381038
'input': {
10391039
'name': name,
10401040
'description': description,
1041+
'alias': alias,
10411042
'type': type,
10421043
'internal_id_key': id,
10431044
'stix_id_key': stix_id_key,
@@ -1051,6 +1052,7 @@ def create_identity_if_not_exists(self,
10511052
type,
10521053
name,
10531054
description,
1055+
alias=None,
10541056
id=None,
10551057
stix_id_key=None,
10561058
created=None,
@@ -1064,12 +1066,16 @@ def create_identity_if_not_exists(self,
10641066
object_result['name'] = name
10651067
self.update_stix_domain_entity_field(object_result['id'], 'description', description)
10661068
object_result['description'] = description
1069+
if alias is not None:
1070+
self.update_stix_domain_entity_field(object_result['id'], 'alias', alias)
1071+
object_result['alias'] = alias
10671072
return object_result
10681073
else:
10691074
return self.create_identity(
10701075
type,
10711076
name,
10721077
description,
1078+
alias,
10731079
id,
10741080
stix_id_key,
10751081
created,

pycti/utils/opencti_stix2.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,7 @@ def create_identity(self, stix_object, update=False):
547547
type,
548548
stix_object['name'],
549549
self.convert_markdown(stix_object['description']) if 'description' in stix_object else '',
550+
stix_object[CustomProperties.ALIASES] if CustomProperties.ALIASES in stix_object else None,
550551
stix_object[CustomProperties.ID] if CustomProperties.ID in stix_object else None,
551552
stix_object['id'] if 'id' in stix_object else None,
552553
stix_object['created'] if 'created' in stix_object else None,

0 commit comments

Comments
 (0)