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

Commit ccff9e6

Browse files
author
Samuel Hassine
committed
[client] More not empty for updating
1 parent e86f4ee commit ccff9e6

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

pycti/entities/opencti_intrusion_set.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -341,15 +341,15 @@ def create(self, **kwargs):
341341
object_result["name"] = name
342342
# description
343343
if (
344-
description is not None
344+
self.opencti.not_empty(description)
345345
and object_result["description"] != description
346346
):
347347
self.opencti.stix_domain_entity.update_field(
348348
id=object_result["id"], key="description", value=description
349349
)
350350
object_result["description"] = description
351351
# alias
352-
if alias is not None and object_result["alias"] != alias:
352+
if self.opencti.not_empty(alias) and object_result["alias"] != alias:
353353
if "alias" in object_result:
354354
new_aliases = object_result["alias"] + list(
355355
set(alias) - set(object_result["alias"])
@@ -373,14 +373,14 @@ def create(self, **kwargs):
373373
)
374374
object_result["last_seen"] = last_seen
375375
# goal
376-
if goal is not None and object_result["goal"] != goal:
376+
if self.opencti.not_empty(goal) and object_result["goal"] != goal:
377377
self.opencti.stix_domain_entity.update_field(
378378
id=object_result["id"], key="goal", value=goal
379379
)
380380
object_result["goal"] = goal
381381
# sophistication
382382
if (
383-
sophistication is not None
383+
self.opencti.not_empty(sophistication)
384384
and object_result["sophistication"] != sophistication
385385
):
386386
self.opencti.stix_domain_entity.update_field(
@@ -391,7 +391,7 @@ def create(self, **kwargs):
391391
object_result["sophistication"] = sophistication
392392
# resource_level
393393
if (
394-
resource_level is not None
394+
self.opencti.not_empty(resource_level)
395395
and object_result["resource_level"] != resource_level
396396
):
397397
self.opencti.stix_domain_entity.update_field(
@@ -402,7 +402,7 @@ def create(self, **kwargs):
402402
object_result["resource_level"] = resource_level
403403
# primary_motivation
404404
if (
405-
primary_motivation is not None
405+
self.opencti.not_empty(primary_motivation)
406406
and object_result["primary_motivation"] != primary_motivation
407407
):
408408
self.opencti.stix_domain_entity.update_field(
@@ -413,7 +413,7 @@ def create(self, **kwargs):
413413
object_result["primary_motivation"] = primary_motivation
414414
# secondary_motivation
415415
if (
416-
secondary_motivation is not None
416+
self.opencti.not_empty(secondary_motivation)
417417
and object_result["secondary_motivation"] != secondary_motivation
418418
):
419419
self.opencti.stix_domain_entity.update_field(

pycti/entities/opencti_malware.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,23 +324,26 @@ def create(self, **kwargs):
324324
object_result["name"] = name
325325
# description
326326
if (
327-
description is not None
327+
self.opencti.not_empty(description)
328328
and object_result["description"] != description
329329
):
330330
self.opencti.stix_domain_entity.update_field(
331331
id=object_result["id"], key="description", value=description
332332
)
333333
object_result["description"] = description
334334
# is_family
335-
if is_family is not None and object_result["is_family"] != is_family:
335+
if (
336+
self.opencti.not_empty(is_family)
337+
and object_result["is_family"] != is_family
338+
):
336339
self.opencti.stix_domain_entity.update_field(
337340
id=object_result["id"],
338341
key="is_family",
339342
value=str(is_family).lower(),
340343
)
341344
object_result["is_family"] = is_family
342345
# alias
343-
if alias is not None and object_result["alias"] != alias:
346+
if self.opencti.not_empty(alias) and object_result["alias"] != alias:
344347
if "alias" in object_result:
345348
new_aliases = object_result["alias"] + list(
346349
set(alias) - set(object_result["alias"])

0 commit comments

Comments
 (0)