Skip to content

Commit 961f71d

Browse files
committed
Changes requested from PR
1 parent 99eb274 commit 961f71d

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

extensions/ql-vscode/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,10 +294,10 @@
294294
"minimum": 0,
295295
"description": "Report a warning for any join order whose metric exceeds this value."
296296
},
297-
"codeQL.allowHttp": {
297+
"codeQL.databaseDownload.allowHttp": {
298298
"type": "boolean",
299299
"default": false,
300-
"description": "Allow databased to be downloaded via HTTP"
300+
"description": "Allow databased to be downloaded via HTTP. Warning: enabling this option will allow downloading from insecure servers."
301301
}
302302
}
303303
},

extensions/ql-vscode/src/config.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -609,10 +609,9 @@ export function isCodespacesTemplate() {
609609
return !!CODESPACES_TEMPLATE.getValue<boolean>();
610610
}
611611

612-
export const ALLOW_HTTP = new Setting(
613-
"allowHttp",
614-
ROOT_SETTING,
615-
);
612+
const DATABASE_DOWNLOAD_SETTING = new Setting("databaseDownload", ROOT_SETTING);
613+
614+
export const ALLOW_HTTP_SETTING = new Setting("allowHttp", DATABASE_DOWNLOAD_SETTING);
616615

617616
export function allowHttp(): boolean {
618617
return ALLOW_HTTP.getValue<boolean>() || false;

extensions/ql-vscode/src/databaseFetcher.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import {
2727
} from "./common/github-url-identifier-helper";
2828
import { Credentials } from "./common/authentication";
2929
import { AppCommandManager } from "./common/commands";
30-
import { ALLOW_HTTP } from "./config";
30+
import { ALLOW_HTTP_SETTING } from "./config";
3131

3232
/**
3333
* Prompts a user to fetch a database from a remote location. Database is assumed to be an archive file.
@@ -50,9 +50,7 @@ export async function promptImportInternetDatabase(
5050
return;
5151
}
5252

53-
if (!ALLOW_HTTP.getValue()) {
54-
validateHttpsUrl(databaseUrl);
55-
}
53+
validateUrl(databaseUrl);
5654

5755
const item = await databaseArchiveFetcher(
5856
databaseUrl,
@@ -359,15 +357,15 @@ async function getStorageFolder(storagePath: string, urlStr: string) {
359357
return folderName;
360358
}
361359

362-
function validateHttpsUrl(databaseUrl: string) {
360+
function validateUrl(databaseUrl: string) {
363361
let uri;
364362
try {
365363
uri = Uri.parse(databaseUrl, true);
366364
} catch (e) {
367365
throw new Error(`Invalid url: ${databaseUrl}`);
368366
}
369367

370-
if (uri.scheme !== "https") {
368+
if (!ALLOW_HTTP_SETTING.getValue() && uri.scheme !== "https") {
371369
throw new Error("Must use https for downloading a database.");
372370
}
373371
}

0 commit comments

Comments
 (0)