66import time
77import warnings
88from concurrent .futures import ThreadPoolExecutor
9- from typing import Optional , Union
9+ from typing import Optional , Union , List
1010from datetime import timedelta , datetime
1111from prometrix import PrometheusNotFound
1212from rich .console import Console
@@ -110,7 +110,7 @@ def _process_result(self, result: Result) -> None:
110110
111111 Formatter = settings .Formatter
112112
113- self ._send_result (settings .publish_scan_url , settings .start_time , settings .scan_id , result )
113+ self ._send_result (settings .publish_scan_url , settings .start_time , settings .scan_id , settings . named_sinks , result )
114114 formatted = result .format (Formatter )
115115 rich = getattr (Formatter , "__rich_console__" , False )
116116
@@ -520,15 +520,15 @@ async def run(self) -> int:
520520 else :
521521 return 0 # Exit with success
522522
523- def _send_result (self , url : str , start_time : datetime , scan_id : str , result : Result ):
523+ def _send_result (self , url : str , start_time : datetime , scan_id : str ,named_sinks : Optional [ List [ str ]], result : Result ):
524524 result_dict = json .loads (result .json (indent = 2 ))
525- _send_scan_payload (url , scan_id , start_time , result_dict , is_error = False )
525+ _send_scan_payload (url , scan_id , start_time , result_dict , named_sinks , is_error = False )
526526
527- def publish_input_error (url : str , scan_id : str , start_time : str , error : str ):
528- _send_scan_payload (url , scan_id , start_time , error , is_error = True )
527+ def publish_input_error (url : str , scan_id : str , start_time : str , error : str , named_sinks : Optional [ List [ str ]] ):
528+ _send_scan_payload (url , scan_id , start_time , error , named_sinks , is_error = True )
529529
530530def publish_error (error : str ):
531- _send_scan_payload (settings .publish_scan_url , settings .scan_id , settings .start_time , error , is_error = True )
531+ _send_scan_payload (settings .publish_scan_url , settings .scan_id , settings .start_time , error , settings . named_sinks , is_error = True )
532532
533533@retry (
534534 stop = stop_after_attempt (3 ),
@@ -549,13 +549,14 @@ def _send_scan_payload(
549549 scan_id : str ,
550550 start_time : Union [str , datetime ],
551551 result_data : Union [str , dict ],
552+ named_sinks : Optional [List [str ]],
552553 is_error : bool = False
553554):
554555 if not url or not scan_id or not start_time :
555556 logger .debug (f"Missing required parameters: url={ bool (url )} , scan_id={ bool (scan_id )} , start_time={ bool (start_time )} " )
556557 return
557558
558- logger .debug (f"Preparing to send scan payload. scan_id={ scan_id } , is_error={ is_error } " )
559+ logger .debug (f"Preparing to send scan payload. scan_id={ scan_id } , to sink { named_sinks } , is_error={ is_error } " )
559560
560561 headers = {"Content-Type" : "application/json" }
561562
@@ -572,6 +573,8 @@ def _send_scan_payload(
572573 "start_time" : start_time ,
573574 }
574575 }
576+ if named_sinks :
577+ action_request ["sinks" ] = named_sinks
575578
576579 try :
577580 _post_scan_request (url , headers , action_request , scan_id , is_error )
0 commit comments