Skip to content

Commit

Permalink
[client] Add workflow / assignees in tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuelHassine committed Jul 20, 2023
1 parent 4de8482 commit c200f91
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
20 changes: 20 additions & 0 deletions pycti/entities/opencti_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,9 @@ def create(self, **kwargs):
created_by = kwargs.get("createdBy", None)
object_marking = kwargs.get("objectMarking", None)
object_label = kwargs.get("objectLabel", None)
object_assignee = kwargs.get("objectAssignee", None)
granted_refs = kwargs.get("objectOrganization", None)
x_opencti_workflow_id = kwargs.get("x_opencti_workflow_id", None)
update = kwargs.get("update", False)

if name is not None:
Expand Down Expand Up @@ -482,6 +484,8 @@ def create(self, **kwargs):
"objectLabel": object_label,
"objectMarking": object_marking,
"objectOrganization": granted_refs,
"objectAssignee": object_assignee,
"x_opencti_workflow_id": x_opencti_workflow_id,
"update": update,
}
},
Expand Down Expand Up @@ -630,6 +634,16 @@ def import_from_stix2(self, **kwargs):
stix_object["granted_refs"] = self.opencti.get_attribute_in_extension(
"granted_refs", stix_object
)
if "x_opencti_workflow_id" not in stix_object:
stix_object[
"x_opencti_workflow_id"
] = self.opencti.get_attribute_in_extension(
"x_opencti_workflow_id", stix_object
)
if "x_opencti_assignee_ids" not in stix_object:
stix_object[
"x_opencti_assignee_ids"
] = self.opencti.get_attribute_in_extension("assignee_ids", stix_object)

return self.create(
stix_id=stix_object["id"],
Expand All @@ -654,6 +668,12 @@ def import_from_stix2(self, **kwargs):
objectOrganization=stix_object["x_opencti_granted_refs"]
if "x_opencti_granted_refs" in stix_object
else None,
objectAssignee=stix_object["x_opencti_assignee_ids"]
if "x_opencti_assignee_ids" in stix_object
else None,
x_opencti_workflow_id=stix_object["x_opencti_workflow_id"]
if "x_opencti_workflow_id" in stix_object
else None,
update=update,
)
else:
Expand Down
3 changes: 3 additions & 0 deletions pycti/utils/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ def has_value(cls, value):
("priority", StringProperty()),
("response_types", ListProperty(StringProperty)),
("x_opencti_workflow_id", StringProperty()),
("x_opencti_assignee_ids", ListProperty(StringProperty)),
(
"object_refs",
ListProperty(
Expand All @@ -173,6 +174,7 @@ class CustomObjectCaseIncident:
("priority", StringProperty()),
("information_types", ListProperty(StringProperty)),
("x_opencti_workflow_id", StringProperty()),
("x_opencti_assignee_ids", ListProperty(StringProperty)),
(
"object_refs",
ListProperty(
Expand Down Expand Up @@ -200,6 +202,7 @@ class CustomObjectCaseRfit:
),
),
("x_opencti_workflow_id", StringProperty()),
("x_opencti_assignee_ids", ListProperty(StringProperty)),
(
"object_refs",
ListProperty(
Expand Down

0 comments on commit c200f91

Please sign in to comment.