Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions extensions/ql-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,11 @@
"scope": "window",
"minimum": 0,
"description": "Report a warning for any join order whose metric exceeds this value."
},
"codeQL.databaseDownload.allowHttp": {
"type": "boolean",
"default": false,
"description": "Allow databased to be downloaded via HTTP. Warning: enabling this option will allow downloading from insecure servers."
Comment thread
aeisenberg marked this conversation as resolved.
Outdated
}
}
},
Expand Down
8 changes: 8 additions & 0 deletions extensions/ql-vscode/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -608,3 +608,11 @@ export const CODESPACES_TEMPLATE = new Setting(
export function isCodespacesTemplate() {
return !!CODESPACES_TEMPLATE.getValue<boolean>();
}

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;
}
7 changes: 4 additions & 3 deletions extensions/ql-vscode/src/databaseFetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
} from "./common/github-url-identifier-helper";
import { Credentials } from "./common/authentication";
import { AppCommandManager } from "./common/commands";
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.
Expand All @@ -49,7 +50,7 @@ export async function promptImportInternetDatabase(
return;
}

validateHttpsUrl(databaseUrl);
validateUrl(databaseUrl);

const item = await databaseArchiveFetcher(
databaseUrl,
Expand Down Expand Up @@ -356,15 +357,15 @@ 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);
} catch (e) {
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.");
}
}
Expand Down