MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / executeFileSuggestionCommand

Function executeFileSuggestionCommand

source code/utils/hooks.ts:4677–4740  ·  view source on GitHub ↗
(
  fileSuggestionInput: FileSuggestionCommandInput,
  signal?: AbortSignal,
  timeoutMs: number = 5000, // Short timeout for typeahead suggestions
)

Source from the content-addressed store, hash-verified

4675 * @returns Array of file paths, or empty array if no command configured
4676 */
4677export async function executeFileSuggestionCommand(
4678 fileSuggestionInput: FileSuggestionCommandInput,
4679 signal?: AbortSignal,
4680 timeoutMs: number = 5000, // Short timeout for typeahead suggestions
4681): Promise<string[]> {
4682 // Check if all hooks are disabled by managed settings
4683 if (shouldDisableAllHooksIncludingManaged()) {
4684 return []
4685 }
4686
4687 // SECURITY: ALL hooks require workspace trust in interactive mode
4688 // This centralized check prevents RCE vulnerabilities for all current and future hooks
4689 if (shouldSkipHookDueToTrust()) {
4690 logForDebugging(
4691 `Skipping FileSuggestion command execution - workspace trust not accepted`,
4692 )
4693 return []
4694 }
4695
4696 // When disableAllHooks is set in non-managed settings, only managed fileSuggestion runs
4697 // (non-managed settings cannot disable managed commands, but non-managed commands are disabled)
4698 let fileSuggestion
4699 if (shouldAllowManagedHooksOnly()) {
4700 fileSuggestion = getSettingsForSource('policySettings')?.fileSuggestion
4701 } else {
4702 fileSuggestion = getSettings_DEPRECATED()?.fileSuggestion
4703 }
4704
4705 if (!fileSuggestion || fileSuggestion.type !== 'command') {
4706 return []
4707 }
4708
4709 // Use provided signal or create a default one
4710 const abortSignal = signal || AbortSignal.timeout(timeoutMs)
4711
4712 try {
4713 const jsonInput = jsonStringify(fileSuggestionInput)
4714
4715 const hook = { type: 'command' as const, command: fileSuggestion.command }
4716
4717 const result = await execCommandHook(
4718 hook,
4719 'FileSuggestion',
4720 'FileSuggestion',
4721 jsonInput,
4722 abortSignal,
4723 randomUUID(),
4724 )
4725
4726 if (result.aborted || result.status !== 0) {
4727 return []
4728 }
4729
4730 return result.stdout
4731 .split('\n')
4732 .map(line => line.trim())
4733 .filter(Boolean)
4734 } catch (error) {

Callers 1

generateFileSuggestionsFunction · 0.85

Calls 7

shouldSkipHookDueToTrustFunction · 0.85
logForDebuggingFunction · 0.85
getSettingsForSourceFunction · 0.85
jsonStringifyFunction · 0.85
execCommandHookFunction · 0.85

Tested by

no test coverage detected