Skip to content

Commit a69e368

Browse files
committed
[client] wip inferred in bundle task manager
1 parent 4321ac0 commit a69e368

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

pycti/api/opencti_api_client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from pycti import __version__
1212
from pycti.api.opencti_api_connector import OpenCTIApiConnector
1313
from pycti.api.opencti_api_draft import OpenCTIApiDraft
14+
from pycti.api.opencti_api_inferred import OpenCTIApiInferred
1415
from pycti.api.opencti_api_internal_file import OpenCTIApiInternalFile
1516
from pycti.api.opencti_api_notification import OpenCTIApiNotification
1617
from pycti.api.opencti_api_pir import OpenCTIApiPir
@@ -175,6 +176,7 @@ def __init__(
175176
# Define the dependencies
176177
self.work = OpenCTIApiWork(self)
177178
self.notification = OpenCTIApiNotification(self)
179+
self.inferred = OpenCTIApiInferred(self)
178180
self.trash = OpenCTIApiTrash(self)
179181
self.draft = OpenCTIApiDraft(self)
180182
self.workspace = OpenCTIApiWorkspace(self)

pycti/api/opencti_api_inferred.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
class OpenCTIApiInferred:
2+
"""OpenCTIApiInferred"""
3+
4+
def __init__(self, api):
5+
self.api = api
6+
7+
def create_inferred_rel(self, **kwargs):
8+
input = kwargs.get("input", None)
9+
self.api.app_logger.info(
10+
"Creating inferred rel", {"input": input}
11+
)
12+
query = """
13+
mutation inferredRelationAdd($jsonInput: String!) {
14+
inferredRelationAdd(jsonInput: $jsonInput)
15+
}
16+
"""
17+
self.api.query(query, {"jsonInput": input})
18+
19+
def create_inferred_entity(self, **kwargs):
20+
input = kwargs.get("input", None)
21+
self.api.app_logger.info(
22+
"Creating inferred rel", {"input": input}
23+
)
24+
query = """
25+
mutation inferredRelationAdd($jsonInput: String!) {
26+
inferredRelationAdd(jsonInput: $jsonInput)
27+
}
28+
"""
29+
self.api.query(query, {"jsonInput": input})

pycti/utils/opencti_stix2.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2643,11 +2643,17 @@ def apply_opencti_operation(self, item, operation):
26432643
input = item["input"]
26442644
self.opencti.pir.pir_unflag_element(id=id, input=input)
26452645
elif operation == "rule_apply":
2646+
self.rule_apply(item=item)
2647+
elif operation == "inferred_entity":
2648+
raise ValueError(
2649+
"Not supported opencti_operation",
2650+
{"operation": operation},
2651+
)
2652+
elif operation == "inferred_rel":
26462653
raise ValueError(
26472654
"Not supported opencti_operation",
26482655
{"operation": operation},
26492656
)
2650-
self.rule_apply(item=item)
26512657
elif operation == "rule_clear":
26522658
self.rule_clear(item=item)
26532659
elif operation == "rules_rescan":

0 commit comments

Comments
 (0)