@@ -2500,6 +2500,9 @@ def import_item(
25002500 if processing_count > MAX_PROCESSING_COUNT :
25012501 if work_id is not None :
25022502 item_str = json .dumps (item )
2503+ # report expectation without impersonated user
2504+ current_applicant_id = self .opencti .get_request_headers ()["opencti-applicant-id" ]
2505+ self .opencti .set_applicant_id_header ('' )
25032506 self .opencti .work .report_expectation (
25042507 work_id ,
25052508 {
@@ -2509,6 +2512,7 @@ def import_item(
25092512 ),
25102513 },
25112514 )
2515+ self .opencti .set_applicant_id_header (current_applicant_id )
25122516 return False
25132517 try :
25142518 self .opencti .set_retry_number (processing_count )
@@ -2645,7 +2649,11 @@ def import_item(
26452649 ):
26462650 self .import_object (item , update , types )
26472651 if work_id is not None :
2652+ # report expectation without impersonated user
2653+ current_applicant_id = self .opencti .get_request_headers ()["opencti-applicant-id" ]
2654+ self .opencti .set_applicant_id_header ('' )
26482655 self .opencti .work .report_expectation (work_id , None )
2656+ self .opencti .set_applicant_id_header (current_applicant_id )
26492657 bundles_success_counter .add (1 )
26502658 return True
26512659 except (RequestException , Timeout ):
@@ -2702,20 +2710,27 @@ def import_item(
27022710 bundles_technical_error_counter .add (1 )
27032711 if work_id is not None :
27042712 self .opencti .work .api .set_draft_id ("" )
2713+ # report expectation without impersonated user
2714+ current_applicant_id = self .opencti .get_request_headers ()["opencti-applicant-id" ]
2715+ self .opencti .set_applicant_id_header ('' )
27052716 self .opencti .work .report_expectation (
27062717 work_id ,
27072718 {
27082719 "error" : error ,
27092720 "source" : "Draft in read only" ,
27102721 },
27112722 )
2723+ self .opencti .set_applicant_id_header (current_applicant_id )
27122724 return False
27132725 # Platform does not know what to do and raises an error:
27142726 # That also works for missing reference with too much execution
27152727 else :
27162728 bundles_technical_error_counter .add (1 )
27172729 if work_id is not None :
27182730 item_str = json .dumps (item )
2731+ # report expectation without impersonated user
2732+ current_applicant_id = self .opencti .get_request_headers ()["opencti-applicant-id" ]
2733+ self .opencti .set_applicant_id_header ('' )
27192734 self .opencti .work .report_expectation (
27202735 work_id ,
27212736 {
@@ -2727,6 +2742,7 @@ def import_item(
27272742 ),
27282743 },
27292744 )
2745+ self .opencti .set_applicant_id_header (current_applicant_id )
27302746 return False
27312747
27322748 def import_bundle (
0 commit comments