Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions extensions/ql-vscode/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Update variant analysis view to show when cancelation is in progress. [#3405](https://github.com/github/vscode-codeql/pull/3405)
- Remove support for CodeQL CLI versions older than 2.13.5. [#3371](https://github.com/github/vscode-codeql/pull/3371)
- Add a timeout to downloading databases and the CodeQL CLI. These can be changed using the `codeQL.addingDatabases.downloadTimeout` and `codeQL.cli.downloadTimeout` settings respectively. [#3373](https://github.com/github/vscode-codeql/pull/3373)
- When downloading a CodeQL database through the model editor, only use credentials when in canary mode. [#3440](https://github.com/github/vscode-codeql/pull/3440)

## 1.12.2 - 14 February 2024

Expand Down
18 changes: 10 additions & 8 deletions extensions/ql-vscode/src/databases/database-fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,19 @@ import {
getNwoFromGitHubUrl,
isValidGitHubNwo,
} from "../common/github-url-identifier-helper";
import type { Credentials } from "../common/authentication";
import type { AppCommandManager } from "../common/commands";
import {
addDatabaseSourceToWorkspace,
allowHttp,
downloadTimeout,
isCanary,
} from "../config";
import { showAndLogInformationMessage } from "../common/logging";
import { AppOctokit } from "../common/octokit";
import { getLanguageDisplayName } from "../common/query-language";
import type { DatabaseOrigin } from "./local-databases/database-origin";
import { createTimeoutSignal } from "../common/fetch-stream";
import type { App } from "../common/app";

/**
* Prompts a user to fetch a database from a remote location. Database is assumed to be an archive file.
Expand Down Expand Up @@ -90,20 +91,19 @@ export async function promptImportInternetDatabase(
* User enters a GitHub repository and then the user is asked which language
* to download (if there is more than one)
*
* @param app the App
* @param databaseManager the DatabaseManager
* @param storagePath where to store the unzipped database.
* @param credentials the credentials to use to authenticate with GitHub
* @param progress the progress callback
* @param cli the CodeQL CLI server
* @param language the language to download. If undefined, the user will be prompted to choose a language.
* @param makeSelected make the new database selected in the databases panel (default: true)
* @param addSourceArchiveFolder whether to add a workspace folder containing the source archive to the workspace
*/
export async function promptImportGithubDatabase(
commandManager: AppCommandManager,
app: App,
databaseManager: DatabaseManager,
storagePath: string,
credentials: Credentials | undefined,
progress: ProgressCallback,
cli: CodeQLCliServer,
language?: string,
Expand All @@ -117,9 +117,9 @@ export async function promptImportGithubDatabase(

const databaseItem = await downloadGitHubDatabase(
githubRepo,
app,
databaseManager,
storagePath,
credentials,
progress,
cli,
language,
Expand All @@ -129,7 +129,7 @@ export async function promptImportGithubDatabase(

if (databaseItem) {
if (makeSelected) {
await commandManager.execute("codeQLDatabases.focus");
await app.commands.execute("codeQLDatabases.focus");
}
void showAndLogInformationMessage(
extLogger,
Expand Down Expand Up @@ -169,9 +169,9 @@ export async function askForGitHubRepo(
* Downloads a database from GitHub
*
* @param githubRepo the GitHub repository to download the database from
* @param app the App
* @param databaseManager the DatabaseManager
* @param storagePath where to store the unzipped database.
* @param credentials the credentials to use to authenticate with GitHub
* @param progress the progress callback
* @param cli the CodeQL CLI server
* @param language the language to download. If undefined, the user will be prompted to choose a language.
Expand All @@ -180,9 +180,9 @@ export async function askForGitHubRepo(
**/
export async function downloadGitHubDatabase(
githubRepo: string,
app: App,
databaseManager: DatabaseManager,
storagePath: string,
credentials: Credentials | undefined,
progress: ProgressCallback,
cli: CodeQLCliServer,
language?: string,
Expand All @@ -194,6 +194,8 @@ export async function downloadGitHubDatabase(
throw new Error(`Invalid GitHub repository: ${githubRepo}`);
}

const credentials = isCanary() ? app.credentials : undefined;

const octokit = credentials
? await credentials.getOctokit()
: new AppOctokit();
Expand Down
6 changes: 1 addition & 5 deletions extensions/ql-vscode/src/databases/local-databases-ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ import {
} from "./database-fetcher";
import { asError, asyncFilter, getErrorMessage } from "../common/helpers-pure";
import type { QueryRunner } from "../query-server";
import { isCanary } from "../config";
import type { App } from "../common/app";
import { redactableError } from "../common/errors";
import type { LocalDatabasesCommands } from "../common/commands";
Expand Down Expand Up @@ -558,13 +557,10 @@ export class DatabaseUI extends DisposableObject {
private async handleChooseDatabaseGithub(): Promise<void> {
return withProgress(
async (progress) => {
const credentials = isCanary() ? this.app.credentials : undefined;

await promptImportGithubDatabase(
this.app.commands,
this.app,
this.databaseManager,
this.storagePath,
credentials,
progress,
this.queryServer.cliServer,
);
Expand Down
4 changes: 1 addition & 3 deletions extensions/ql-vscode/src/local-queries/local-queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
showAndLogErrorMessage,
showAndLogWarningMessage,
} from "../common/logging";
import { isCanary, MAX_QUERIES } from "../config";
import { MAX_QUERIES } from "../config";
import { gatherQlFiles } from "../common/files";
import { basename } from "path";
import { showBinaryChoiceDialog } from "../common/vscode/dialog";
Expand Down Expand Up @@ -322,14 +322,12 @@ export class LocalQueries extends DisposableObject {
private async createSkeletonQuery(): Promise<void> {
await withProgress(
async (progress: ProgressCallback) => {
const credentials = isCanary() ? this.app.credentials : undefined;
const contextStoragePath =
this.app.workspaceStoragePath || this.app.globalStoragePath;
const language = this.languageContextStore.selectedLanguage;
const skeletonQueryWizard = new SkeletonQueryWizard(
this.cliServer,
progress,
credentials,
this.app,
this.databaseManager,
contextStoragePath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { dirname, join } from "path";
import { Uri, window, window as Window, workspace } from "vscode";
import type { CodeQLCliServer } from "../codeql-cli/cli";
import { showAndLogExceptionWithTelemetry } from "../common/logging";
import type { Credentials } from "../common/authentication";
import type { QueryLanguage } from "../common/query-language";
import { getLanguageDisplayName } from "../common/query-language";
import {
Expand Down Expand Up @@ -61,7 +60,6 @@ export class SkeletonQueryWizard {
constructor(
private readonly cliServer: CodeQLCliServer,
private readonly progress: ProgressCallback,
private readonly credentials: Credentials | undefined,
private readonly app: App,
private readonly databaseManager: DatabaseManager,
private readonly databaseStoragePath: string | undefined,
Expand Down Expand Up @@ -388,9 +386,9 @@ export class SkeletonQueryWizard {

await downloadGitHubDatabase(
chosenRepo,
this.app,
this.databaseManager,
this.databaseStoragePath,
this.credentials,
progress,
this.cliServer,
this.language,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -917,10 +917,9 @@ export class ModelEditorView extends AbstractWebview<
// imported to the query server, so we need to register it to our workspace.
const makeSelected = false;
const addedDatabase = await promptImportGithubDatabase(
this.app.commands,
this.app,
this.databaseManager,
this.app.workspaceStoragePath ?? this.app.globalStoragePath,
this.app.credentials,
progress,
this.cliServer,
this.databaseItem.language,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
removeSync,
} from "fs-extra";
import { dirname, join } from "path";
import { testCredentialsWithStub } from "../../../factories/authentication";
import type {
DatabaseItem,
DatabaseManager,
Expand Down Expand Up @@ -69,7 +68,6 @@ describe("SkeletonQueryWizard", () => {
typeof CodeQLCliServer.prototype.resolveQlpacks
>;

const credentials = testCredentialsWithStub();
const chosenLanguage = "ruby";
const selectedItems: QueryTreeViewItem[] = [];

Expand Down Expand Up @@ -145,7 +143,6 @@ describe("SkeletonQueryWizard", () => {
wizard = new SkeletonQueryWizard(
mockCli,
jest.fn(),
credentials,
mockApp,
mockDatabaseManager,
storagePath,
Expand Down Expand Up @@ -173,7 +170,6 @@ describe("SkeletonQueryWizard", () => {
wizard = new SkeletonQueryWizard(
mockCli,
jest.fn(),
credentials,
mockApp,
mockDatabaseManager,
storagePath,
Expand Down Expand Up @@ -322,7 +318,6 @@ describe("SkeletonQueryWizard", () => {
wizard = new SkeletonQueryWizard(
mockCli,
jest.fn(),
credentials,
mockApp,
mockDatabaseManagerWithItems,
storagePath,
Expand Down Expand Up @@ -372,7 +367,6 @@ describe("SkeletonQueryWizard", () => {
wizard = new SkeletonQueryWizard(
mockCli,
jest.fn(),
credentials,
mockApp,
mockDatabaseManagerWithItems,
storagePath,
Expand Down Expand Up @@ -508,7 +502,6 @@ describe("SkeletonQueryWizard", () => {
wizard = new SkeletonQueryWizard(
mockCli,
jest.fn(),
credentials,
mockApp,
mockDatabaseManager,
storagePath,
Expand Down Expand Up @@ -730,7 +723,6 @@ describe("SkeletonQueryWizard", () => {
wizard = new SkeletonQueryWizard(
mockCli,
jest.fn(),
credentials,
mockApp,
mockDatabaseManager,
storagePath,
Expand Down Expand Up @@ -760,7 +752,6 @@ describe("SkeletonQueryWizard", () => {
wizard = new SkeletonQueryWizard(
mockCli,
jest.fn(),
credentials,
mockApp,
mockDatabaseManager,
storagePath,
Expand Down Expand Up @@ -794,7 +785,6 @@ describe("SkeletonQueryWizard", () => {
wizard = new SkeletonQueryWizard(
mockCli,
jest.fn(),
credentials,
mockApp,
mockDatabaseManager,
storagePath,
Expand Down Expand Up @@ -838,7 +828,6 @@ describe("SkeletonQueryWizard", () => {
wizard = new SkeletonQueryWizard(
mockCli,
jest.fn(),
credentials,
mockApp,
mockDatabaseManager,
storagePath,
Expand Down