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

Commit e7138c1

Browse files
[client-python] Ensure the valid_until date on Indicators is set to a greater value than valid_from when empty (opencti/issue/6836)
[client-python] Ensure the valid_until date on Indicators is set to a greater value than valid_from when empty
2 parents fb15042 + cd3b5a3 commit e7138c1

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

pycti/utils/opencti_stix2.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1516,7 +1516,16 @@ def generate_export(self, entity: Dict, no_custom_attributes: bool = False) -> D
15161516
and "valid_until" in entity
15171517
and entity["valid_from"] == entity["valid_until"]
15181518
):
1519-
del entity["valid_from"]
1519+
valid_until_converted_datetime = datetime.datetime.strptime(
1520+
entity["valid_until"], "%Y-%m-%dT%H:%M:%S.%fZ"
1521+
)
1522+
new_valid_until = valid_until_converted_datetime + datetime.timedelta(
1523+
seconds=1
1524+
)
1525+
valid_until_converted_string = new_valid_until.strftime(
1526+
"%Y-%m-%dT%H:%M:%S.%fZ"
1527+
)
1528+
entity["valid_until"] = valid_until_converted_string
15201529

15211530
# Flatten
15221531
if "tasks" in entity:

0 commit comments

Comments
 (0)