Skip to content

Commit f49314f

Browse files
Merge branch 'main' into robertbrignull/export_results_telemetry
2 parents b76bef4 + 9044d11 commit f49314f

File tree

25 files changed

+531
-1083
lines changed

25 files changed

+531
-1083
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[fork]: https://github.com/github/vscode-codeql/fork
44
[pr]: https://github.com/github/vscode-codeql/compare
5-
[style]: https://primer.style
5+
[style]: https://github.com/microsoft/vscode-webview-ui-toolkit
66
[code-of-conduct]: CODE_OF_CONDUCT.md
77

88
Hi there! We're thrilled that you'd like to contribute to this project. Your help is essential for keeping it great.

extensions/ql-vscode/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## [UNRELEASED]
44

5+
- Show data flow paths of a variant analysis in a new tab
6+
57
## 1.8.0 - 9 March 2023
68

79
- Send telemetry about unhandled errors happening within the extension. [#2125](https://github.com/github/vscode-codeql/pull/2125)

extensions/ql-vscode/package-lock.json

Lines changed: 56 additions & 548 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

extensions/ql-vscode/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1433,8 +1433,6 @@
14331433
"dependencies": {
14341434
"@octokit/plugin-retry": "^3.0.9",
14351435
"@octokit/rest": "^19.0.4",
1436-
"@primer/octicons-react": "^17.6.0",
1437-
"@primer/react": "^35.0.0",
14381436
"@vscode/codicons": "^0.0.31",
14391437
"@vscode/webview-ui-toolkit": "^1.0.1",
14401438
"ajv": "^8.11.0",
@@ -1512,6 +1510,7 @@
15121510
"@types/semver": "~7.2.0",
15131511
"@types/stream-chain": "~2.0.1",
15141512
"@types/stream-json": "~1.7.1",
1513+
"@types/styled-components": "^5.1.11",
15151514
"@types/tar-stream": "^2.2.2",
15161515
"@types/through2": "^2.0.36",
15171516
"@types/tmp": "^0.1.0",

extensions/ql-vscode/src/common/commands.ts

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
1-
import { CommandManager } from "../packages/commands";
1+
import type { CommandManager } from "../packages/commands";
22
import type { Uri } from "vscode";
3+
import type { DbTreeViewItem } from "../databases/ui/db-tree-view-item";
4+
import type { QueryHistoryInfo } from "../query-history/query-history-info";
5+
6+
// A command function matching the signature that VS Code calls when
7+
// a command on a selection is invoked.
8+
export type SelectionCommandFunction<Item> = (
9+
singleItem: Item,
10+
multiSelect: Item[],
11+
) => Promise<void>;
12+
13+
// A command function matching the signature that VS Code calls when
14+
// a command on a selection is invoked when canSelectMany is false.
15+
export type SingleSelectionCommandFunction<Item> = (
16+
singleItem: Item,
17+
) => Promise<void>;
318

419
/**
520
* Contains type definitions for all commands used by the extension.
@@ -13,6 +28,38 @@ export type BaseCommands = {
1328
"codeQL.openDocumentation": () => Promise<void>;
1429
};
1530

31+
// Commands used for the query history panel
32+
export type QueryHistoryCommands = {
33+
// Commands in the "navigation" group
34+
"codeQLQueryHistory.sortByName": () => Promise<void>;
35+
"codeQLQueryHistory.sortByDate": () => Promise<void>;
36+
"codeQLQueryHistory.sortByCount": () => Promise<void>;
37+
38+
// Commands in the context menu or in the hover menu
39+
"codeQLQueryHistory.openQueryTitleMenu": SelectionCommandFunction<QueryHistoryInfo>;
40+
"codeQLQueryHistory.openQueryContextMenu": SelectionCommandFunction<QueryHistoryInfo>;
41+
"codeQLQueryHistory.removeHistoryItemTitleMenu": SelectionCommandFunction<QueryHistoryInfo>;
42+
"codeQLQueryHistory.removeHistoryItemContextMenu": SelectionCommandFunction<QueryHistoryInfo>;
43+
"codeQLQueryHistory.removeHistoryItemContextInline": SelectionCommandFunction<QueryHistoryInfo>;
44+
"codeQLQueryHistory.renameItem": SelectionCommandFunction<QueryHistoryInfo>;
45+
"codeQLQueryHistory.compareWith": SelectionCommandFunction<QueryHistoryInfo>;
46+
"codeQLQueryHistory.showEvalLog": SelectionCommandFunction<QueryHistoryInfo>;
47+
"codeQLQueryHistory.showEvalLogSummary": SelectionCommandFunction<QueryHistoryInfo>;
48+
"codeQLQueryHistory.showEvalLogViewer": SelectionCommandFunction<QueryHistoryInfo>;
49+
"codeQLQueryHistory.showQueryLog": SelectionCommandFunction<QueryHistoryInfo>;
50+
"codeQLQueryHistory.showQueryText": SelectionCommandFunction<QueryHistoryInfo>;
51+
"codeQLQueryHistory.openQueryDirectory": SelectionCommandFunction<QueryHistoryInfo>;
52+
"codeQLQueryHistory.cancel": SelectionCommandFunction<QueryHistoryInfo>;
53+
"codeQLQueryHistory.exportResults": SelectionCommandFunction<QueryHistoryInfo>;
54+
"codeQLQueryHistory.viewCsvResults": SelectionCommandFunction<QueryHistoryInfo>;
55+
"codeQLQueryHistory.viewCsvAlerts": SelectionCommandFunction<QueryHistoryInfo>;
56+
"codeQLQueryHistory.viewSarifAlerts": SelectionCommandFunction<QueryHistoryInfo>;
57+
"codeQLQueryHistory.viewDil": SelectionCommandFunction<QueryHistoryInfo>;
58+
"codeQLQueryHistory.itemClicked": SelectionCommandFunction<QueryHistoryInfo>;
59+
"codeQLQueryHistory.openOnGithub": SelectionCommandFunction<QueryHistoryInfo>;
60+
"codeQLQueryHistory.copyRepoList": SelectionCommandFunction<QueryHistoryInfo>;
61+
};
62+
1663
// Commands tied to variant analysis
1764
export type VariantAnalysisCommands = {
1865
"codeQL.openVariantAnalysisLogs": (
@@ -22,6 +69,22 @@ export type VariantAnalysisCommands = {
2269
"codeQL.runVariantAnalysisContextEditor": (uri?: Uri) => Promise<void>;
2370
};
2471

25-
export type AllCommands = BaseCommands & VariantAnalysisCommands;
72+
export type DatabasePanelCommands = {
73+
"codeQLVariantAnalysisRepositories.openConfigFile": () => Promise<void>;
74+
"codeQLVariantAnalysisRepositories.addNewDatabase": () => Promise<void>;
75+
"codeQLVariantAnalysisRepositories.addNewList": () => Promise<void>;
76+
"codeQLVariantAnalysisRepositories.setupControllerRepository": () => Promise<void>;
77+
78+
"codeQLVariantAnalysisRepositories.setSelectedItem": SingleSelectionCommandFunction<DbTreeViewItem>;
79+
"codeQLVariantAnalysisRepositories.setSelectedItemContextMenu": SingleSelectionCommandFunction<DbTreeViewItem>;
80+
"codeQLVariantAnalysisRepositories.openOnGitHubContextMenu": SingleSelectionCommandFunction<DbTreeViewItem>;
81+
"codeQLVariantAnalysisRepositories.renameItemContextMenu": SingleSelectionCommandFunction<DbTreeViewItem>;
82+
"codeQLVariantAnalysisRepositories.removeItemContextMenu": SingleSelectionCommandFunction<DbTreeViewItem>;
83+
};
84+
85+
export type AllCommands = BaseCommands &
86+
QueryHistoryCommands &
87+
VariantAnalysisCommands &
88+
DatabasePanelCommands;
2689

2790
export type AppCommandManager = CommandManager<AllCommands>;

extensions/ql-vscode/src/databases/db-module.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ import { DbConfigStore } from "./config/db-config-store";
66
import { DbManager } from "./db-manager";
77
import { DbPanel } from "./ui/db-panel";
88
import { DbSelectionDecorationProvider } from "./ui/db-selection-decoration-provider";
9+
import { DatabasePanelCommands } from "../common/commands";
910

1011
export class DbModule extends DisposableObject {
1112
public readonly dbManager: DbManager;
1213
private readonly dbConfigStore: DbConfigStore;
14+
private dbPanel: DbPanel | undefined;
1315

1416
private constructor(app: App) {
1517
super();
@@ -26,15 +28,24 @@ export class DbModule extends DisposableObject {
2628
return dbModule;
2729
}
2830

31+
public getCommands(): DatabasePanelCommands {
32+
if (!this.dbPanel) {
33+
throw new Error("Database panel not initialized");
34+
}
35+
36+
return {
37+
...this.dbPanel.getCommands(),
38+
};
39+
}
40+
2941
private async initialize(app: App): Promise<void> {
3042
void extLogger.log("Initializing database module");
3143

3244
await this.dbConfigStore.initialize();
3345

34-
const dbPanel = new DbPanel(this.dbManager, app.credentials);
35-
await dbPanel.initialize();
46+
this.dbPanel = new DbPanel(this.dbManager, app.credentials);
3647

37-
this.push(dbPanel);
48+
this.push(this.dbPanel);
3849
this.push(this.dbConfigStore);
3950

4051
const dbSelectionDecorationProvider = new DbSelectionDecorationProvider();

extensions/ql-vscode/src/databases/ui/db-panel.ts

Lines changed: 24 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
window,
88
workspace,
99
} from "vscode";
10-
import { commandRunner, UserCancellationException } from "../../commandRunner";
10+
import { UserCancellationException } from "../../commandRunner";
1111
import {
1212
getNwoFromGitHubUrl,
1313
isValidGitHubNwo,
@@ -32,6 +32,7 @@ import { getGitHubUrl } from "./db-tree-view-item-action";
3232
import { getControllerRepo } from "../../variant-analysis/run-remote-query";
3333
import { getErrorMessage } from "../../pure/helpers-pure";
3434
import { Credentials } from "../../common/authentication";
35+
import { DatabasePanelCommands } from "../../common/commands";
3536

3637
export interface RemoteDatabaseQuickPickItem extends QuickPickItem {
3738
kind: string;
@@ -72,58 +73,28 @@ export class DbPanel extends DisposableObject {
7273
this.push(this.treeView);
7374
}
7475

75-
public async initialize(): Promise<void> {
76-
this.push(
77-
commandRunner("codeQLVariantAnalysisRepositories.openConfigFile", () =>
78-
this.openConfigFile(),
79-
),
80-
);
81-
this.push(
82-
commandRunner("codeQLVariantAnalysisRepositories.addNewDatabase", () =>
83-
this.addNewRemoteDatabase(),
84-
),
85-
);
86-
this.push(
87-
commandRunner("codeQLVariantAnalysisRepositories.addNewList", () =>
88-
this.addNewList(),
89-
),
90-
);
91-
this.push(
92-
commandRunner(
93-
"codeQLVariantAnalysisRepositories.setSelectedItem",
94-
(treeViewItem: DbTreeViewItem) => this.setSelectedItem(treeViewItem),
95-
),
96-
);
97-
this.push(
98-
commandRunner(
99-
"codeQLVariantAnalysisRepositories.setSelectedItemContextMenu",
100-
(treeViewItem: DbTreeViewItem) => this.setSelectedItem(treeViewItem),
101-
),
102-
);
103-
this.push(
104-
commandRunner(
105-
"codeQLVariantAnalysisRepositories.openOnGitHubContextMenu",
106-
(treeViewItem: DbTreeViewItem) => this.openOnGitHub(treeViewItem),
107-
),
108-
);
109-
this.push(
110-
commandRunner(
111-
"codeQLVariantAnalysisRepositories.renameItemContextMenu",
112-
(treeViewItem: DbTreeViewItem) => this.renameItem(treeViewItem),
113-
),
114-
);
115-
this.push(
116-
commandRunner(
117-
"codeQLVariantAnalysisRepositories.removeItemContextMenu",
118-
(treeViewItem: DbTreeViewItem) => this.removeItem(treeViewItem),
119-
),
120-
);
121-
this.push(
122-
commandRunner(
123-
"codeQLVariantAnalysisRepositories.setupControllerRepository",
124-
() => this.setupControllerRepository(),
125-
),
126-
);
76+
public getCommands(): DatabasePanelCommands {
77+
return {
78+
"codeQLVariantAnalysisRepositories.openConfigFile":
79+
this.openConfigFile.bind(this),
80+
"codeQLVariantAnalysisRepositories.addNewDatabase":
81+
this.addNewRemoteDatabase.bind(this),
82+
"codeQLVariantAnalysisRepositories.addNewList":
83+
this.addNewList.bind(this),
84+
"codeQLVariantAnalysisRepositories.setupControllerRepository":
85+
this.setupControllerRepository.bind(this),
86+
87+
"codeQLVariantAnalysisRepositories.setSelectedItem":
88+
this.setSelectedItem.bind(this),
89+
"codeQLVariantAnalysisRepositories.setSelectedItemContextMenu":
90+
this.setSelectedItem.bind(this),
91+
"codeQLVariantAnalysisRepositories.openOnGitHubContextMenu":
92+
this.openOnGitHub.bind(this),
93+
"codeQLVariantAnalysisRepositories.renameItemContextMenu":
94+
this.renameItem.bind(this),
95+
"codeQLVariantAnalysisRepositories.removeItemContextMenu":
96+
this.removeItem.bind(this),
97+
};
12798
}
12899

129100
private async openConfigFile(): Promise<void> {

extensions/ql-vscode/src/extension.ts

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,7 +1091,9 @@ async function activateWithInstalledDistribution(
10911091

10921092
const allCommands: AllCommands = {
10931093
...getCommands(),
1094+
...qhm.getCommands(),
10941095
...variantAnalysisManager.getCommands(),
1096+
...dbModule.getCommands(),
10951097
};
10961098

10971099
for (const [commandName, command] of Object.entries(allCommands)) {
@@ -1142,15 +1144,6 @@ async function activateWithInstalledDistribution(
11421144
),
11431145
);
11441146

1145-
ctx.subscriptions.push(
1146-
commandRunner(
1147-
"codeQL.cancelVariantAnalysis",
1148-
async (variantAnalysisId: number) => {
1149-
await variantAnalysisManager.cancelVariantAnalysis(variantAnalysisId);
1150-
},
1151-
),
1152-
);
1153-
11541147
ctx.subscriptions.push(
11551148
commandRunner("codeQL.exportSelectedVariantAnalysisResults", async () => {
11561149
await exportSelectedVariantAnalysisResults(variantAnalysisManager, qhm);
@@ -1179,15 +1172,6 @@ async function activateWithInstalledDistribution(
11791172
),
11801173
);
11811174

1182-
ctx.subscriptions.push(
1183-
commandRunner(
1184-
"codeQL.openVariantAnalysisQueryText",
1185-
async (variantAnalysisId: number) => {
1186-
await variantAnalysisManager.openQueryText(variantAnalysisId);
1187-
},
1188-
),
1189-
);
1190-
11911175
ctx.subscriptions.push(
11921176
commandRunner("codeQL.openReferencedFile", async (selectedQuery: Uri) => {
11931177
await openReferencedFile(qs, cliServer, selectedQuery);

extensions/ql-vscode/src/pure/interface-types.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,11 @@ export interface CancelVariantAnalysisMessage {
449449
t: "cancelVariantAnalysis";
450450
}
451451

452+
export interface ShowDataFlowPathsMessage {
453+
t: "showDataFlowPaths";
454+
dataFlowPaths: DataFlowPaths;
455+
}
456+
452457
export type ToVariantAnalysisMessage =
453458
| SetVariantAnalysisMessage
454459
| SetRepoResultsMessage
@@ -462,7 +467,8 @@ export type FromVariantAnalysisMessage =
462467
| CopyRepositoryListMessage
463468
| ExportResultsMessage
464469
| OpenLogsMessage
465-
| CancelVariantAnalysisMessage;
470+
| CancelVariantAnalysisMessage
471+
| ShowDataFlowPathsMessage;
466472

467473
export interface SetDataFlowPathsMessage {
468474
t: "setDataFlowPaths";

0 commit comments

Comments
 (0)