@@ -12,7 +12,7 @@ import { EXTENSION_ROOT_DIR } from '../../../../constants';
1212import { createDeferred , createDeferredFrom } from '../../../../common/utils/async' ;
1313import { DisposableBase , DisposableStore } from '../../../../common/utils/resourceLifecycle' ;
1414import { noop } from '../../../../common/utils/misc' ;
15- import { getConfiguration , getWorkspaceFolderPaths } from '../../../../common/vscodeApis/workspaceApis' ;
15+ import { getConfiguration , getWorkspaceFolderPaths , isTrusted } from '../../../../common/vscodeApis/workspaceApis' ;
1616import { CONDAPATH_SETTING_KEY } from '../../../common/environmentManagers/conda' ;
1717import { VENVFOLDERS_SETTING_KEY , VENVPATH_SETTING_KEY } from '../lowLevel/customVirtualEnvLocator' ;
1818import { getUserHomeDir } from '../../../../common/utils/platform' ;
@@ -22,6 +22,7 @@ import { NativePythonEnvironmentKind } from './nativePythonUtils';
2222import type { IExtensionContext } from '../../../../common/types' ;
2323import { StopWatch } from '../../../../common/utils/stopWatch' ;
2424import { untildify } from '../../../../common/helpers' ;
25+ import { traceError } from '../../../../logging' ;
2526
2627const PYTHON_ENV_TOOLS_PATH = isWindows ( )
2728 ? path . join ( EXTENSION_ROOT_DIR , 'python-env-tools' , 'bin' , 'pet.exe' )
@@ -440,6 +441,25 @@ function getPythonSettingAndUntildify<T>(name: string, scope?: Uri): T | undefin
440441
441442let _finder : NativePythonFinder | undefined ;
442443export function getNativePythonFinder ( context ?: IExtensionContext ) : NativePythonFinder {
444+ if ( ! isTrusted ( ) ) {
445+ return {
446+ async * refresh ( ) {
447+ traceError ( 'Python discovery not supported in untrusted workspace' ) ;
448+ yield * [ ] ;
449+ } ,
450+ async resolve ( ) {
451+ traceError ( 'Python discovery not supported in untrusted workspace' ) ;
452+ return { } ;
453+ } ,
454+ async getCondaInfo ( ) {
455+ traceError ( 'Python discovery not supported in untrusted workspace' ) ;
456+ return ( { } as unknown ) as NativeCondaInfo ;
457+ } ,
458+ dispose ( ) {
459+ // do nothing
460+ } ,
461+ } ;
462+ }
443463 if ( ! _finder ) {
444464 const cacheDirectory = context ? getCacheDirectory ( context ) : undefined ;
445465 _finder = new NativePythonFinderImpl ( cacheDirectory ) ;
0 commit comments