Skip to content

Commit 9c27d01

Browse files
committed
Merge branch 'main' into aeisenberg/save-query-history
2 parents 64ac33e + bd5da2b commit 9c27d01

7 files changed

Lines changed: 63 additions & 11 deletions

File tree

.github/workflows/codeql.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ jobs:
2626
with:
2727
languages: javascript
2828
config-file: ./.github/codeql/codeql-config.yml
29-
# We require at least CodeQL CLI v2.7.6 to opt into the ML-powered queries beta. This
30-
# can be removed once CodeQL Bundle v2.7.6 ships in the Actions VM images.
3129
tools: latest
3230

3331
- name: Perform CodeQL Analysis

extensions/ql-vscode/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# CodeQL for Visual Studio Code: Changelog
22

3-
## [UNRELEASED]
3+
## 1.5.11 - 10 February 2022
44

55
- Fix a bug where invoking _View AST_ from the file explorer would not view the selected file. Instead it would view the active editor. Also, prevent the _View AST_ from appearing if the current selection includes a directory or multiple files. [#1113](https://github.com/github/vscode-codeql/pull/1113)
66
- Add query history items as soon as a query is run, including new icons for each history item. [#1094](https://github.com/github/vscode-codeql/pull/1094)
77
- Save query history items across restarts. Items will be saved for 30 days and can be overwritten by setting the `codeQL.queryHistory.ttl` configuration setting. [#1130](https://github.com/github/vscode-codeql/pull/1130)
8+
- Allow in-progress query items to be cancelled from the query history view. [#1105](https://github.com/github/vscode-codeql/pull/1105)
89

910
## 1.5.10 - 25 January 2022
1011

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,8 @@ export type FromRemoteQueriesMessage =
378378
| OpenFileMsg
379379
| OpenVirtualFileMsg
380380
| RemoteQueryDownloadAnalysisResultsMessage
381-
| RemoteQueryDownloadAllAnalysesResultsMessage;
381+
| RemoteQueryDownloadAllAnalysesResultsMessage
382+
| RemoteQueryViewAnalysisResultsMessage;
382383

383384
export type ToRemoteQueriesMessage =
384385
| SetRemoteQueryResultMessage
@@ -412,3 +413,8 @@ export interface RemoteQueryDownloadAllAnalysesResultsMessage {
412413
t: 'remoteQueryDownloadAllAnalysesResults';
413414
analysisSummaries: AnalysisSummary[];
414415
}
416+
417+
export interface RemoteQueryViewAnalysisResultsMessage {
418+
t: 'remoteQueryViewAnalysisResults';
419+
analysisSummary: AnalysisSummary
420+
}

extensions/ql-vscode/src/remote-queries/remote-queries-interface.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import {
55
ViewColumn,
66
Uri,
77
workspace,
8+
extensions,
9+
commands,
810
} from 'vscode';
911
import * as path from 'path';
1012

@@ -14,6 +16,7 @@ import {
1416
FromRemoteQueriesMessage,
1517
RemoteQueryDownloadAnalysisResultsMessage,
1618
RemoteQueryDownloadAllAnalysesResultsMessage,
19+
RemoteQueryViewAnalysisResultsMessage,
1720
} from '../pure/interface-types';
1821
import { Logger } from '../logging';
1922
import { getHtmlForWebview } from '../interface-utils';
@@ -199,6 +202,9 @@ export class RemoteQueriesInterfaceManager {
199202
case 'remoteQueryDownloadAllAnalysesResults':
200203
await this.downloadAllAnalysesResults(msg);
201204
break;
205+
case 'remoteQueryViewAnalysisResults':
206+
await this.viewAnalysisResults(msg);
207+
break;
202208
default:
203209
assertNever(msg);
204210
}
@@ -217,6 +223,28 @@ export class RemoteQueriesInterfaceManager {
217223
results => this.setAnalysisResults(results));
218224
}
219225

226+
private async viewAnalysisResults(msg: RemoteQueryViewAnalysisResultsMessage): Promise<void> {
227+
const downloadLink = msg.analysisSummary.downloadLink;
228+
const filePath = path.join(tmpDir.name, downloadLink.id, downloadLink.innerFilePath || '');
229+
230+
const sarifViewerExtensionId = 'MS-SarifVSCode.sarif-viewer';
231+
232+
const sarifExt = extensions.getExtension(sarifViewerExtensionId);
233+
if (!sarifExt) {
234+
// Ask the user if they want to install the extension to view the results.
235+
void commands.executeCommand('workbench.extensions.installExtension', sarifViewerExtensionId);
236+
return;
237+
}
238+
239+
if (!sarifExt.isActive) {
240+
await sarifExt.activate();
241+
}
242+
243+
await sarifExt.exports.openLogs([
244+
Uri.file(filePath),
245+
]);
246+
}
247+
220248
public async setAnalysisResults(analysesResults: AnalysisResults[]): Promise<void> {
221249
if (this.panel?.active) {
222250
await this.postMessage({

extensions/ql-vscode/src/remote-queries/view/RemoteQueries.tsx

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import DownloadButton from './DownloadButton';
1717
import { AnalysisResults } from '../shared/analysis-result';
1818
import DownloadSpinner from './DownloadSpinner';
1919
import CollapsibleItem from './CollapsibleItem';
20+
import { FileSymlinkFileIcon } from '@primer/octicons-react';
2021

2122
const numOfReposInContractedMode = 10;
2223

@@ -47,6 +48,13 @@ const downloadAllAnalysesResults = (query: RemoteQueryResult) => {
4748
});
4849
};
4950

51+
const viewAnalysisResults = (analysisSummary: AnalysisSummary) => {
52+
vscode.postMessage({
53+
t: 'remoteQueryViewAnalysisResults',
54+
analysisSummary
55+
});
56+
};
57+
5058
const openQueryFile = (queryResult: RemoteQueryResult) => {
5159
vscode.postMessage({
5260
t: 'openFile',
@@ -110,7 +118,7 @@ const SummaryTitleNoResults = () => (
110118
</div>
111119
);
112120

113-
const SummaryItemDownload = ({
121+
const SummaryItemDownloadAndView = ({
114122
analysisSummary,
115123
analysisResults
116124
}: {
@@ -130,7 +138,13 @@ const SummaryItemDownload = ({
130138
</>;
131139
}
132140

133-
return (<></>);
141+
return <>
142+
<HorizontalSpace size={2} />
143+
<a className="vscode-codeql__analysis-result-file-link"
144+
onClick={() => viewAnalysisResults(analysisSummary)} >
145+
<FileSymlinkFileIcon size={16} />
146+
</a>
147+
</>;
134148
};
135149

136150
const SummaryItem = ({
@@ -145,7 +159,7 @@ const SummaryItem = ({
145159
<span className="vscode-codeql__analysis-item">{analysisSummary.nwo}</span>
146160
<span className="vscode-codeql__analysis-item"><Badge text={analysisSummary.resultCount.toString()} /></span>
147161
<span className="vscode-codeql__analysis-item">
148-
<SummaryItemDownload
162+
<SummaryItemDownloadAndView
149163
analysisSummary={analysisSummary}
150164
analysisResults={analysisResults} />
151165
</span>
@@ -275,13 +289,15 @@ export function RemoteQueries(): JSX.Element {
275289
return <div>Waiting for results to load.</div>;
276290
}
277291

292+
const showAnalysesResults = false;
293+
278294
try {
279295
return <div>
280296
<ThemeProvider>
281297
<ViewTitle>{queryResult.queryTitle}</ViewTitle>
282298
<QueryInfo {...queryResult} />
283299
<Summary queryResult={queryResult} analysesResults={analysesResults} />
284-
<AnalysesResults analysesResults={analysesResults} totalResults={queryResult.totalResultCount} />
300+
{showAnalysesResults && <AnalysesResults analysesResults={analysesResults} totalResults={queryResult.totalResultCount} />}
285301
</ThemeProvider>
286302
</div>;
287303
} catch (err) {

extensions/ql-vscode/src/remote-queries/view/remoteQueries.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,7 @@
6060
padding-top: 1em;
6161
font-size: x-small;
6262
}
63+
64+
.vscode-codeql__analysis-result-file-link {
65+
vertical-align: middle;
66+
}

extensions/ql-vscode/src/vscode-tests/no-workspace/telemetry.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,9 +367,8 @@ describe('telemetry reporting', function() {
367367
);
368368

369369
// Need to wait some time since the onDidChangeConfiguration listeners fire
370-
// asynchronously and we sometimes need to wait for them to complete in
371-
// order to have as successful test.
372-
await wait(50);
370+
// asynchronously. Must ensure they to complete in order to have a successful test.
371+
await wait(100);
373372
}
374373

375374
async function wait(ms = 0) {

0 commit comments

Comments
 (0)