-
Notifications
You must be signed in to change notification settings - Fork 226
Expand file tree
/
Copy pathbqrs-processing.ts
More file actions
42 lines (35 loc) · 1.38 KB
/
bqrs-processing.ts
File metadata and controls
42 lines (35 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { CodeQLCliServer } from "../codeql-cli/cli";
import { Logger } from "../common";
import { transformBqrsResultSet } from "../pure/bqrs-cli-types";
import { AnalysisRawResults } from "./shared/analysis-result";
import { MAX_RAW_RESULTS } from "./shared/result-limits";
import { SELECT_TABLE_NAME } from "../pure/interface-types";
export async function extractRawResults(
cliServer: CodeQLCliServer,
logger: Logger,
filePath: string,
fileLinkPrefix: string,
sourceLocationPrefix: string,
): Promise<AnalysisRawResults> {
const bqrsInfo = await cliServer.bqrsInfo(filePath);
const resultSets = bqrsInfo["result-sets"];
if (resultSets.length < 1) {
throw new Error("No result sets found in results file.");
}
if (resultSets.length > 1) {
void logger.log(
"Multiple result sets found in results file. Only one will be used.",
);
}
// Always prefer #select over any other result set. #select is usually the result the user
// wants to see since it contains the outer #select.
const schema =
resultSets.find((resultSet) => resultSet.name === SELECT_TABLE_NAME) ??
resultSets[0];
const chunk = await cliServer.bqrsDecode(filePath, schema.name, {
pageSize: MAX_RAW_RESULTS,
});
const resultSet = transformBqrsResultSet(schema, chunk);
const capped = !!chunk.next;
return { schema, resultSet, fileLinkPrefix, sourceLocationPrefix, capped };
}