Changes requested from PR

This commit is contained in:
Joe Rozner
2023-04-17 12:36:47 -07:00
parent 99eb274029
commit 961f71d8a5
3 changed files with 9 additions and 12 deletions

View File

@@ -294,10 +294,10 @@
"minimum": 0,
"description": "Report a warning for any join order whose metric exceeds this value."
},
"codeQL.allowHttp": {
"codeQL.databaseDownload.allowHttp": {
"type": "boolean",
"default": false,
"description": "Allow databased to be downloaded via HTTP"
"description": "Allow databased to be downloaded via HTTP. Warning: enabling this option will allow downloading from insecure servers."
}
}
},

View File

@@ -609,10 +609,9 @@ export function isCodespacesTemplate() {
return !!CODESPACES_TEMPLATE.getValue<boolean>();
}
export const ALLOW_HTTP = new Setting(
"allowHttp",
ROOT_SETTING,
);
const DATABASE_DOWNLOAD_SETTING = new Setting("databaseDownload", ROOT_SETTING);
export const ALLOW_HTTP_SETTING = new Setting("allowHttp", DATABASE_DOWNLOAD_SETTING);
export function allowHttp(): boolean {
return ALLOW_HTTP.getValue<boolean>() || false;

View File

@@ -27,7 +27,7 @@ import {
} from "./common/github-url-identifier-helper";
import { Credentials } from "./common/authentication";
import { AppCommandManager } from "./common/commands";
import { ALLOW_HTTP } from "./config";
import { ALLOW_HTTP_SETTING } from "./config";
/**
* 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(
return;
}
if (!ALLOW_HTTP.getValue()) {
validateHttpsUrl(databaseUrl);
}
validateUrl(databaseUrl);
const item = await databaseArchiveFetcher(
databaseUrl,
@@ -359,7 +357,7 @@ async function getStorageFolder(storagePath: string, urlStr: string) {
return folderName;
}
function validateHttpsUrl(databaseUrl: string) {
function validateUrl(databaseUrl: string) {
let uri;
try {
uri = Uri.parse(databaseUrl, true);
@@ -367,7 +365,7 @@ function validateHttpsUrl(databaseUrl: string) {
throw new Error(`Invalid url: ${databaseUrl}`);
}
if (uri.scheme !== "https") {
if (!ALLOW_HTTP_SETTING.getValue() && uri.scheme !== "https") {
throw new Error("Must use https for downloading a database.");
}
}