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

Commit 826d85f

Browse files
lndrtrbnArchidoitSouadHadjiat
authored
[client] New specific operations for PIR (opencti #10032)
Co-authored-by: Cathia Archidoit <[email protected]> Co-authored-by: Souad Hadjiat <[email protected]>
1 parent ac5bb79 commit 826d85f

File tree

4 files changed

+48
-0
lines changed

4 files changed

+48
-0
lines changed

pycti/api/opencti_api_client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
from pycti import __version__
1212
from pycti.api.opencti_api_connector import OpenCTIApiConnector
13+
from pycti.api.opencti_api_pir import OpenCTIApiPir
1314
from pycti.api.opencti_api_playbook import OpenCTIApiPlaybook
1415
from pycti.api.opencti_api_work import OpenCTIApiWork
1516
from pycti.entities.opencti_attack_pattern import AttackPattern
@@ -170,6 +171,7 @@ def __init__(
170171
self.playbook = OpenCTIApiPlaybook(self)
171172
self.connector = OpenCTIApiConnector(self)
172173
self.stix2 = OpenCTIStix2(self)
174+
self.pir = OpenCTIApiPir(self)
173175

174176
# Define the entities
175177
self.vocabulary = Vocabulary(self)

pycti/api/opencti_api_pir.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
class OpenCTIApiPir:
2+
"""OpenCTIApiPir"""
3+
4+
def __init__(self, api):
5+
self.api = api
6+
7+
def pir_flag_element(self, **kwargs):
8+
id = kwargs.get("id", None)
9+
input = kwargs.get("input", None)
10+
query = """
11+
mutation PirFlagElement($id: ID!, $input: PirFlagElementInput!) {
12+
pirFlagElement(id: $id, input: $input)
13+
}
14+
"""
15+
self.api.query(
16+
query,
17+
{
18+
"id": id,
19+
"input": input,
20+
},
21+
)
22+
23+
def pir_unflag_element(self, **kwargs):
24+
id = kwargs.get("id", None)
25+
input = kwargs.get("input", None)
26+
query = """
27+
mutation PirUnflagElement($id: ID!, $input: PirUnflagElementInput!) {
28+
pirUnflagElement(id: $id, input: $input)
29+
}
30+
"""
31+
self.api.query(
32+
query,
33+
{
34+
"id": id,
35+
"input": input,
36+
},
37+
)

pycti/utils/opencti_stix2.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2484,6 +2484,14 @@ def apply_opencti_operation(self, item, operation):
24842484
self.opencti.stix.merge(id=target_id, object_ids=source_ids)
24852485
elif operation == "patch":
24862486
self.apply_patch(item=item)
2487+
elif operation == "pir_flag_element":
2488+
id = item["id"]
2489+
input = item["input"]
2490+
self.opencti.pir.pir_flag_element(id=id, input=input)
2491+
elif operation == "pir_unflag_element":
2492+
id = item["id"]
2493+
input = item["input"]
2494+
self.opencti.pir.pir_unflag_element(id=id, input=input)
24872495
else:
24882496
raise ValueError("Not supported opencti_operation")
24892497

pycti/utils/opencti_stix2_splitter.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
SUPPORTED_STIX_ENTITY_OBJECTS # entities
2020
+ list(STIX_CYBER_OBSERVABLE_MAPPING.keys()) # observables
2121
+ ["relationship", "sighting"] # relationships
22+
+ ["pir"]
2223
)
2324

2425

0 commit comments

Comments
 (0)