@@ -68,16 +68,20 @@ class RemediateSecretIncidentsResult(BaseModel):
6868 env_example_content : str | None = Field (default = None , description = "Suggested .env.example content" )
6969 env_example_instructions : list [str ] | None = Field (default = None , description = "Instructions for .env.example" )
7070 git_commands : dict [str , Any ] | None = Field (default = None , description = "Git commands to fix history" )
71- applied_filters : dict [str , Any ] = Field (default_factory = dict , description = "Filters applied when querying occurrences" )
71+ applied_filters : dict [str , Any ] = Field (default_factory = dict ,
72+ description = "Filters applied when querying occurrences" )
7273 suggestion : str = Field (default = "" , description = "Suggestions for interpreting results" )
74+ sub_tools_results : dict [str , Any ] = Field (default_factory = dict , description = "Results from sub tools" )
7375
7476
7577class RemediateSecretIncidentsError (BaseModel ):
7678 """Error result from remediating secret incidents."""
7779 error : str = Field (description = "Error message" )
80+ sub_tools_results : dict [str , Any ] = Field (default_factory = dict , description = "Results from sub tools" )
7881
7982
80- async def remediate_secret_incidents (params : RemediateSecretIncidentsParams ) -> RemediateSecretIncidentsResult | RemediateSecretIncidentsError :
83+ async def remediate_secret_incidents (
84+ params : RemediateSecretIncidentsParams ) -> RemediateSecretIncidentsResult | RemediateSecretIncidentsError :
8185 """
8286 Find and remediate secret incidents in the current repository using EXACT match locations.
8387
@@ -124,12 +128,31 @@ async def remediate_secret_incidents(params: RemediateSecretIncidentsParams) ->
124128
125129 try :
126130 # Get detailed occurrences with exact match locations
127- # Extract filter parameters from list_repo_occurrences_params
128- occurrences_result = await list_repo_occurrences (params .list_repo_occurrences_params )
131+ # Build ListRepoOccurrencesParams by combining repository info with filters
132+ from .list_repo_occurrences import ListRepoOccurrencesParams
133+
134+ occurrences_params = ListRepoOccurrencesParams (
135+ repository_name = params .repository_name ,
136+ source_id = params .source_id ,
137+ from_date = params .list_repo_occurrences_params .from_date ,
138+ to_date = params .list_repo_occurrences_params .to_date ,
139+ presence = params .list_repo_occurrences_params .presence ,
140+ tags = params .list_repo_occurrences_params .tags ,
141+ exclude_tags = params .list_repo_occurrences_params .exclude_tags ,
142+ status = params .list_repo_occurrences_params .status ,
143+ severity = params .list_repo_occurrences_params .severity ,
144+ validity = params .list_repo_occurrences_params .validity ,
145+ ordering = None ,
146+ per_page = 20 ,
147+ cursor = None ,
148+ get_all = params .get_all ,
149+ )
150+ occurrences_result = await list_repo_occurrences (occurrences_params )
129151
130152 # Check if list_repo_occurrences returned an error
131- if getattr (occurrences_result , "error" ):
132- return RemediateSecretIncidentsError (error = occurrences_result .error )
153+ if hasattr (occurrences_result , "error" ) and occurrences_result .error :
154+ return RemediateSecretIncidentsError (error = occurrences_result .error ,
155+ sub_tools_results = {"list_repo_occurrences" : occurrences_result })
133156 occurrences = occurrences_result .occurrences
134157
135158 # Filter by assignee if mine=True
@@ -157,6 +180,7 @@ async def remediate_secret_incidents(params: RemediateSecretIncidentsParams) ->
157180 remediation_steps = [],
158181 applied_filters = occurrences_result .applied_filters or {},
159182 suggestion = occurrences_result .suggestion or "" ,
183+ sub_tools_results = {"list_repo_occurrences" : occurrences_result }
160184 )
161185
162186 # Process occurrences for remediation with exact location data
@@ -168,22 +192,34 @@ async def remediate_secret_incidents(params: RemediateSecretIncidentsParams) ->
168192 create_env_example = params .create_env_example ,
169193 )
170194 logger .debug (
171- f"Remediation processing complete, returning result with { len (result .get ( ' remediation_steps' , []) )} steps"
195+ f"Remediation processing complete, returning result with { len (result .remediation_steps )} steps"
172196 )
173- # Convert dict result to Pydantic model
174- return RemediateSecretIncidentsResult (** result )
197+
198+ # Add sub_tools_results and applied_filters/suggestion from occurrences_result
199+ result_dict = result .model_dump ()
200+ result_dict ["sub_tools_results" ] = {
201+ "list_repo_occurrences" : {
202+ "total_occurrences" : result .summary .get ("total_occurrences" ,
203+ len (occurrences )) if result .summary else len (occurrences ),
204+ "affected_files" : result .summary .get ("affected_files" , 0 ) if result .summary else 0 ,
205+ }
206+ }
207+ result_dict ["applied_filters" ] = occurrences_result .applied_filters or {}
208+ result_dict ["suggestion" ] = occurrences_result .suggestion or ""
209+
210+ return RemediateSecretIncidentsResult (** result_dict )
175211
176212 except Exception as e :
177213 logger .error (f"Error remediating incidents: { str (e )} " )
178214 return RemediateSecretIncidentsError (error = f"Failed to remediate incidents: { str (e )} " )
179215
180216
181217async def _process_occurrences_for_remediation (
182- occurrences : list [dict [str , Any ]],
183- repository_name : str ,
184- include_git_commands : bool = True ,
185- create_env_example : bool = True ,
186- ) -> dict [ str , Any ] :
218+ occurrences : list [dict [str , Any ]],
219+ repository_name : str ,
220+ include_git_commands : bool = True ,
221+ create_env_example : bool = True ,
222+ ) -> RemediateSecretIncidentsResult :
187223 """
188224 Process occurrences for remediation using exact match locations.
189225
@@ -319,4 +355,4 @@ async def _process_occurrences_for_remediation(
319355 if git_commands :
320356 result ["git_commands" ] = git_commands
321357
322- return result
358+ return RemediateSecretIncidentsResult ( ** result )
0 commit comments