From 1254fabd226bbf1fee5e51eed2ec037a2002fd29 Mon Sep 17 00:00:00 2001 From: Samuel Hassine Date: Fri, 25 Oct 2019 08:16:37 +0200 Subject: [PATCH] [client] Use the proper function to update Stix Observables (#30) --- pycti/api/opencti_api_client.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/pycti/api/opencti_api_client.py b/pycti/api/opencti_api_client.py index cbc1804cf..44e79ce65 100644 --- a/pycti/api/opencti_api_client.py +++ b/pycti/api/opencti_api_client.py @@ -351,6 +351,27 @@ def update_stix_domain_entity_field(self, id, key, value): } }) + def update_stix_observable_field(self, id, key, value): + logging.info('Updating field ' + key + ' of ' + id + '...') + query = """ + mutation StixObservableEdit($id: ID!, $input: EditInput!) { + stixObservableEdit(id: $id) { + fieldPatch(input: $input) { + id + observable_value + entity_type + } + } + } + """ + self.query(query, { + 'id': id, + 'input': { + 'key': key, + 'value': value + } + }) + def update_stix_relation_field(self, id, key, value): logging.info('Updating field ' + key + ' of ' + id + '...') query = """ @@ -3234,7 +3255,7 @@ def create_stix_observable_if_not_exists(self, object_result = self.get_stix_observable_by_value(observable_value) if object_result is not None: if update: - self.update_stix_domain_entity_field(object_result['id'], 'description', description) + self.update_stix_observable_field(object_result['id'], 'description', description) object_result['description'] = description return object_result else: