File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -333,3 +333,15 @@ export function getRemoteControllerRepo(): string | undefined {
333333export async function setRemoteControllerRepo ( repo : string | undefined ) {
334334 await REMOTE_CONTROLLER_REPO . updateValue ( repo , ConfigurationTarget . Global ) ;
335335}
336+
337+ /**
338+ * Whether to insecurely load ML models from CodeQL packs.
339+ *
340+ * This setting is for internal users only.
341+ */
342+ const SHOULD_INSECURELY_LOAD_MODELS_FROM_PACKS =
343+ new Setting ( 'shouldInsecurelyLoadModelsFromPacks' , RUNNING_QUERIES_SETTING ) ;
344+
345+ export function shouldInsecurelyLoadMlModelsFromPacks ( ) : boolean {
346+ return SHOULD_INSECURELY_LOAD_MODELS_FROM_PACKS . getValue < boolean > ( ) ;
347+ }
Original file line number Diff line number Diff line change 88 TextDocument ,
99 TextEditor ,
1010 Uri ,
11- window
11+ window ,
12+ workspace
1213} from 'vscode' ;
1314import { ErrorCodes , ResponseError } from 'vscode-languageclient' ;
1415
@@ -617,12 +618,18 @@ export async function compileAndRunQueryAgainstDatabase(
617618 }
618619
619620 let availableMlModels : cli . MlModelInfo [ ] = [ ] ;
620- if ( await cliServer . cliConstraints . supportsResolveMlModels ( ) ) {
621+ // The `capabilities.untrustedWorkspaces.restrictedConfigurations` entry in package.json doesn't
622+ // work with hidden settings, so we manually check that the workspace is trusted before looking at
623+ // whether the `shouldInsecurelyLoadMlModelsFromPacks` setting is enabled.
624+ if ( workspace . isTrusted &&
625+ config . shouldInsecurelyLoadMlModelsFromPacks ( ) &&
626+ await cliServer . cliConstraints . supportsResolveMlModels ( ) ) {
621627 try {
622628 availableMlModels = ( await cliServer . resolveMlModels ( diskWorkspaceFolders ) ) . models ;
623629 void logger . log ( `Found available ML models at the following paths: ${ availableMlModels . map ( x => `'${ x . path } '` ) . join ( ', ' ) } .` ) ;
624630 } catch ( e ) {
625- const message = `Couldn't resolve available ML models for ${ qlProgram . queryPath } : ${ e } ` ;
631+ const message = `Couldn't resolve available ML models for ${ qlProgram . queryPath } . Running the ` +
632+ `query without any ML models: ${ e } .` ;
626633 void logger . log ( message ) ;
627634 void showAndLogErrorMessage ( message ) ;
628635 }
You can’t perform that action at this time.
0 commit comments