Skip to content

Commit c4ed6e8

Browse files
committed
Pass sourceLocationPrefix down through all the functions
1 parent 51e6559 commit c4ed6e8

12 files changed

+35
-17
lines changed

extensions/ql-vscode/src/remote-queries/analyses-results-manager.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export class AnalysesResultsManager {
148148
status: 'Completed'
149149
};
150150
} else if (fileExtension === '.bqrs') {
151-
const queryResults = await this.readBqrsResults(artifactPath, fileLinkPrefix);
151+
const queryResults = await this.readBqrsResults(artifactPath, fileLinkPrefix, analysis.sourceLocationPrefix);
152152
newAnaysisResults = {
153153
...analysisResults,
154154
rawResults: queryResults,
@@ -180,8 +180,8 @@ export class AnalysesResultsManager {
180180
return await fs.pathExists(createDownloadPath(this.storagePath, analysis.downloadLink));
181181
}
182182

183-
private async readBqrsResults(filePath: string, fileLinkPrefix: string): Promise<AnalysisRawResults> {
184-
return await extractRawResults(this.cliServer, this.logger, filePath, fileLinkPrefix);
183+
private async readBqrsResults(filePath: string, fileLinkPrefix: string, sourceLocationPrefix: string): Promise<AnalysisRawResults> {
184+
return await extractRawResults(this.cliServer, this.logger, filePath, fileLinkPrefix, sourceLocationPrefix);
185185
}
186186

187187
private async readSarifResults(filePath: string, fileLinkPrefix: string): Promise<AnalysisAlert[]> {

extensions/ql-vscode/src/remote-queries/bqrs-processing.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export async function extractRawResults(
99
logger: Logger,
1010
filePath: string,
1111
fileLinkPrefix: string,
12+
sourceLocationPrefix: string
1213
): Promise<AnalysisRawResults> {
1314
const bqrsInfo = await cliServer.bqrsInfo(filePath);
1415
const resultSets = bqrsInfo['result-sets'];
@@ -31,5 +32,5 @@ export async function extractRawResults(
3132

3233
const capped = !!chunk.next;
3334

34-
return { schema, resultSet, fileLinkPrefix, capped };
35+
return { schema, resultSet, fileLinkPrefix, sourceLocationPrefix, capped };
3536
}

extensions/ql-vscode/src/remote-queries/gh-actions-api-client.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ interface ApiSuccessIndexItem {
1717
results_count: number;
1818
bqrs_file_size: number;
1919
sarif_file_size?: number;
20+
source_location_prefix: string;
2021
}
2122

2223
interface ApiFailureIndexItem {
@@ -59,7 +60,8 @@ export async function getRemoteQueryIndex(
5960
sha: item.sha,
6061
resultCount: item.results_count,
6162
bqrsFileSize: item.bqrs_file_size,
62-
sarifFileSize: item.sarif_file_size
63+
sarifFileSize: item.sarif_file_size,
64+
sourceLocationPrefix: item.source_location_prefix
6365
} as RemoteQuerySuccessIndexItem;
6466
});
6567

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ export class RemoteQueriesInterfaceManager {
291291
databaseSha: analysisResult.databaseSha || 'HEAD',
292292
resultCount: analysisResult.resultCount,
293293
downloadLink: analysisResult.downloadLink,
294+
sourceLocationPrefix: analysisResult.sourceLocationPrefix,
294295
fileSize: this.formatFileSize(analysisResult.fileSizeInBytes),
295296
starCount: analysisResult.starCount,
296297
lastUpdated: analysisResult.lastUpdated

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ export class RemoteQueriesManager extends DisposableObject {
171171
nwo: a.nwo,
172172
databaseSha: a.databaseSha,
173173
resultCount: a.resultCount,
174+
sourceLocationPrefix: a.sourceLocationPrefix,
174175
downloadLink: a.downloadLink,
175176
fileSize: String(a.fileSizeInBytes)
176177
}));
@@ -191,6 +192,7 @@ export class RemoteQueriesManager extends DisposableObject {
191192
nwo: item.nwo,
192193
databaseSha: item.sha || 'HEAD',
193194
resultCount: item.resultCount,
195+
sourceLocationPrefix: item.sourceLocationPrefix,
194196
fileSizeInBytes: item.sarifFileSize ? item.sarifFileSize : item.bqrsFileSize,
195197
starCount: metadata[item.nwo]?.starCount,
196198
lastUpdated: metadata[item.nwo]?.lastUpdated,

extensions/ql-vscode/src/remote-queries/remote-queries-markdown-generation.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ function generateMarkdownForRawResults(
238238

239239
for (const row of analysisRawResults.resultSet.rows) {
240240
const cells = row.map((cell) =>
241-
generateMarkdownForRawTableCell(cell, analysisRawResults.fileLinkPrefix)
241+
generateMarkdownForRawTableCell(cell, analysisRawResults.fileLinkPrefix, analysisRawResults.sourceLocationPrefix)
242242
);
243243
tableRows.push(`| ${cells.join(' | ')} |`);
244244
}
@@ -247,7 +247,8 @@ function generateMarkdownForRawResults(
247247

248248
function generateMarkdownForRawTableCell(
249249
value: CellValue,
250-
fileLinkPrefix: string
250+
fileLinkPrefix: string,
251+
sourceLocationPrefix: string
251252
) {
252253
let cellValue: string;
253254
switch (typeof value) {
@@ -258,7 +259,7 @@ function generateMarkdownForRawTableCell(
258259
break;
259260
case 'object':
260261
{
261-
const url = tryGetRemoteLocation(value.url, fileLinkPrefix);
262+
const url = tryGetRemoteLocation(value.url, fileLinkPrefix, sourceLocationPrefix);
262263
cellValue = `[\`${convertNonPrintableChars(value.label)}\`](${url})`;
263264
}
264265
break;

extensions/ql-vscode/src/remote-queries/remote-query-result-index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export interface RemoteQuerySuccessIndexItem {
1212
resultCount: number;
1313
bqrsFileSize: number;
1414
sarifFileSize?: number;
15+
sourceLocationPrefix: string;
1516
}
1617

1718
export interface RemoteQueryFailureIndexItem {

extensions/ql-vscode/src/remote-queries/remote-query-result.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export interface AnalysisSummary {
1212
nwo: string,
1313
databaseSha: string,
1414
resultCount: number,
15+
sourceLocationPrefix: string,
1516
downloadLink: DownloadLink,
1617
fileSizeInBytes: number,
1718
starCount?: number,

extensions/ql-vscode/src/remote-queries/shared/analysis-result.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export interface AnalysisRawResults {
1616
schema: ResultSetSchema;
1717
resultSet: RawResultSet;
1818
fileLinkPrefix: string;
19+
sourceLocationPrefix: string;
1920
capped: boolean;
2021
}
2122

extensions/ql-vscode/src/remote-queries/shared/remote-query-result.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export interface AnalysisSummary {
2121
nwo: string,
2222
databaseSha: string,
2323
resultCount: number,
24+
sourceLocationPrefix: string,
2425
downloadLink: DownloadLink,
2526
fileSize: string,
2627
starCount?: number,

0 commit comments

Comments
 (0)