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

Commit f4b3560

Browse files
committed
[client] handle indicator field patch
1 parent 42517c5 commit f4b3560

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

pycti/entities/opencti_indicator.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,46 @@ def create(self, **kwargs):
301301
"name or pattern or pattern_type or x_opencti_main_observable_type"
302302
)
303303

304+
305+
"""
306+
Update an Indicator object field
307+
308+
:param id: the Indicator id
309+
:param input: the input of the field
310+
"""
311+
312+
313+
def update_field(self, **kwargs):
314+
id = kwargs.get("id", None)
315+
input = kwargs.get("input", None)
316+
if id is not None and input is not None:
317+
self.opencti.app_logger.info("Updating Indicator", {"id": id})
318+
query = """
319+
mutation IndicatorFieldPatch($id: ID!, $input: [EditInput]!) {
320+
indicatorFieldPatch(id: $id, input: $input) {
321+
id
322+
standard_id
323+
entity_type
324+
}
325+
}
326+
}
327+
"""
328+
result = self.opencti.query(
329+
query,
330+
{
331+
"id": id,
332+
"input": input,
333+
},
334+
)
335+
return self.opencti.process_multiple_fields(
336+
result["data"]["indicatorFieldPatch"]
337+
)
338+
else:
339+
self.opencti.app_logger.error(
340+
"[opencti_stix_domain_object] Missing parameters: id and input"
341+
)
342+
return None
343+
304344
def add_stix_cyber_observable(self, **kwargs):
305345
"""
306346
Add a Stix-Cyber-Observable object to Indicator object (based-on)

pycti/utils/opencti_stix2.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2485,6 +2485,10 @@ def apply_patch(self, item):
24852485
self.opencti.external_reference.update_field(
24862486
id=item_id, input=field_patch_without_files
24872487
)
2488+
elif item["type"] == "indicator":
2489+
self.opencti.indicator.update_field(
2490+
id=item_id, input=field_patch_without_files
2491+
)
24882492
else:
24892493
self.opencti.stix_domain_object.update_field(
24902494
id=item_id, input=field_patch_without_files

0 commit comments

Comments
 (0)