diff --git a/pycti/utils/opencti_stix2.py b/pycti/utils/opencti_stix2.py index a303844c..e8aed0f6 100644 --- a/pycti/utils/opencti_stix2.py +++ b/pycti/utils/opencti_stix2.py @@ -2500,6 +2500,11 @@ def import_item( if processing_count > MAX_PROCESSING_COUNT: if work_id is not None: item_str = json.dumps(item) + # report expectation without impersonated user + current_applicant_id = self.opencti.get_request_headers()[ + "opencti-applicant-id" + ] + self.opencti.set_applicant_id_header("") self.opencti.work.report_expectation( work_id, { @@ -2509,6 +2514,7 @@ def import_item( ), }, ) + self.opencti.set_applicant_id_header(current_applicant_id) return False try: self.opencti.set_retry_number(processing_count) @@ -2645,7 +2651,13 @@ def import_item( ): self.import_object(item, update, types) if work_id is not None: + # report expectation without impersonated user + current_applicant_id = self.opencti.get_request_headers()[ + "opencti-applicant-id" + ] + self.opencti.set_applicant_id_header("") self.opencti.work.report_expectation(work_id, None) + self.opencti.set_applicant_id_header(current_applicant_id) bundles_success_counter.add(1) return True except (RequestException, Timeout): @@ -2702,6 +2714,11 @@ def import_item( bundles_technical_error_counter.add(1) if work_id is not None: self.opencti.work.api.set_draft_id("") + # report expectation without impersonated user + current_applicant_id = self.opencti.get_request_headers()[ + "opencti-applicant-id" + ] + self.opencti.set_applicant_id_header("") self.opencti.work.report_expectation( work_id, { @@ -2709,6 +2726,7 @@ def import_item( "source": "Draft in read only", }, ) + self.opencti.set_applicant_id_header(current_applicant_id) return False # Platform does not know what to do and raises an error: # That also works for missing reference with too much execution @@ -2716,6 +2734,11 @@ def import_item( bundles_technical_error_counter.add(1) if work_id is not None: item_str = json.dumps(item) + # report expectation without impersonated user + current_applicant_id = self.opencti.get_request_headers()[ + "opencti-applicant-id" + ] + self.opencti.set_applicant_id_header("") self.opencti.work.report_expectation( work_id, { @@ -2727,6 +2750,7 @@ def import_item( ), }, ) + self.opencti.set_applicant_id_header(current_applicant_id) return False def import_bundle(