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

Commit 646014c

Browse files
committed
[client] Change task ID generation
1 parent ec3808c commit 646014c

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

pycti/entities/opencti_task.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import datetime
12
import json
23
import uuid
34

45
from dateutil.parser import parse
6+
from stix2.canonicalization.Canonicalize import canonicalize
57

68
from pycti.entities import LOGGER
79

@@ -237,8 +239,14 @@ def __init__(self, opencti):
237239
"""
238240

239241
@staticmethod
240-
def generate_id():
241-
return "task--" + str(uuid.uuid4())
242+
def generate_id(name, created):
243+
name = name.lower().strip()
244+
if isinstance(created, datetime.datetime):
245+
created = created.isoformat()
246+
data = {"name": name, "created": created}
247+
data = canonicalize(data, utf8=False)
248+
id = str(uuid.uuid5(uuid.UUID("00abedb4-aa42-466c-9c01-fed23315a9b7"), data))
249+
return "task--" + id
242250

243251
"""
244252
List Task objects

0 commit comments

Comments
 (0)