Skip to content

Commit c93ffcf

Browse files
committed
Merge branch 'master' into release/current
2 parents 23f6ddb + 7ac955d commit c93ffcf

File tree

7 files changed

+53
-9
lines changed

7 files changed

+53
-9
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ on:
2424
schedule:
2525
- cron: "21 11 * * 0"
2626

27+
permissions:
28+
actions: read
29+
contents: read
30+
security-events: write
31+
2732
jobs:
2833
analyze:
2934
name: Analyze

pycti/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
__version__ = "6.7.9"
2+
__version__ = "6.7.11"
33

44
from .api.opencti_api_client import OpenCTIApiClient
55
from .api.opencti_api_connector import OpenCTIApiConnector

pycti/connector/opencti_connector_helper.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@ def _data_handler(self, json_data) -> None:
376376
e
377377
for e in stix_objects
378378
if e["id"] == opencti_entity["standard_id"]
379+
or e["id"] == "x-opencti-" + opencti_entity["standard_id"]
379380
][0]
380381
event_data["stix_objects"] = stix_objects
381382
event_data["stix_entity"] = stix_entity

pycti/entities/opencti_user.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,28 @@ def token_renew(self, **kwargs) -> Optional[Dict]:
785785
result["data"]["userEdit"]["tokenRenew"]
786786
)
787787

788+
def send_mail(self, **kwargs):
789+
id = kwargs.get("id", None)
790+
template_id = kwargs.get("template_id", None)
791+
if id is None or template_id is None:
792+
self.opencti.admin_logger.error(
793+
"[opencti_user] Missing parameters: id and template_id"
794+
)
795+
796+
self.opencti.admin_logger.info(
797+
"Send email to user", {"id": id, "template_id": template_id}
798+
)
799+
input = {
800+
"target_user_id": id,
801+
"email_template_id": template_id,
802+
}
803+
query = """
804+
mutation SendUserMail($input: SendUserMailInput!) {
805+
sendUserMail(input: $input)
806+
}
807+
"""
808+
self.opencti.query(query, {"input": input})
809+
788810
def process_multiple_fields(self, data):
789811
if "roles" in data:
790812
data["roles"] = self.opencti.process_multiple(data["roles"])

pycti/utils/opencti_stix2.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2646,11 +2646,25 @@ def element_remove_groups(self, item):
26462646
{"type": item["type"]},
26472647
)
26482648

2649+
def send_email(self, item):
2650+
template_id = self.opencti.get_attribute_in_extension("template_id", item)
2651+
if template_id is None:
2652+
template_id = item["template_id"]
2653+
if item["type"] == "user":
2654+
self.opencti.user.send_mail(id=item["id"], template_id=template_id[0])
2655+
else:
2656+
raise ValueError(
2657+
"Not supported opencti_operation for this type",
2658+
{"type": item["type"]},
2659+
)
2660+
26492661
def element_operation_delete(self, item, operation):
26502662
# If data is stix, just use the generic stix function for deletion
26512663
force_delete = operation == "delete_force"
26522664
if item["type"] == "relationship":
26532665
self.opencti.stix_core_relationship.delete(id=item["id"])
2666+
elif item["type"] == "external-reference":
2667+
self.opencti.external_reference.delete(item["id"])
26542668
elif item["type"] == "sighting":
26552669
self.opencti.stix_sighting_relationship.delete(id=item["id"])
26562670
elif item["type"] in STIX_META_OBJECTS:
@@ -2736,6 +2750,8 @@ def apply_opencti_operation(self, item, operation):
27362750
self.element_add_groups(item)
27372751
elif operation == "remove_groups":
27382752
self.element_remove_groups(item)
2753+
elif operation == "send_email":
2754+
self.send_email(item=item)
27392755
else:
27402756
raise ValueError(
27412757
"Not supported opencti_operation",

requirements.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ python-magic~=0.4.27; sys_platform == 'linux' or sys_platform == 'darwin'
55
python-magic-bin~=0.4.14; sys_platform == 'win32'
66
python_json_logger~=3.3.0
77
PyYAML~=6.0
8-
pydantic~=2.11.3
9-
requests~=2.32.3
8+
pydantic>=2.8.2, <3
9+
requests>=2.32.0, <3
1010
setuptools~=80.9.0
1111
cachetools~=5.5.2
1212
prometheus-client~=0.22.1
1313
opentelemetry-api~=1.35.0
1414
opentelemetry-sdk~=1.35.0
1515
deprecation~=2.1.0
16-
fastapi>=0.116.1,<0.117.0
17-
uvicorn[standard]>=0.35.0,<0.36.0
16+
fastapi>=0.115.2, <1
17+
uvicorn[standard]>=0.34.0,<0.36.0
1818
# OpenCTI
1919
filigran-sseclient>=1.0.2
2020
stix2~=3.0.1

setup.cfg

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,20 @@ install_requires =
3737
# Filigran
3838
datefinder~=0.7.3
3939
pika~=1.3.0
40-
pydantic~=2.11.3
40+
pydantic>=2.8.2, <3
4141
python-magic~=0.4.27; sys_platform == 'linux' or sys_platform == 'darwin'
4242
python-magic-bin~=0.4.14; sys_platform == 'win32'
4343
python_json_logger~=3.3.0
4444
PyYAML~=6.0
45-
requests~=2.32.3
45+
requests>=2.32.0, <3
4646
setuptools~=80.9.0
4747
cachetools~=5.5.2
4848
prometheus-client~=0.22.1
4949
opentelemetry-api~=1.35.0
5050
opentelemetry-sdk~=1.35.0
5151
deprecation~=2.1.0
52-
fastapi>=0.116.1,<0.117.0
53-
uvicorn[standard]>=0.35.0,<0.36.0
52+
fastapi>=0.115.2,<0.117.0
53+
uvicorn[standard]>=0.34.0,<0.36.0
5454
# OpenCTI
5555
filigran-sseclient>=1.0.2
5656
stix2~=3.0.1

0 commit comments

Comments
 (0)