mirror of
https://github.com/github/codeql-action.git
synced 2026-01-01 04:00:24 +08:00
CodeQL: Add resolveDatabase method
This commit is contained in:
@@ -206,6 +206,7 @@ export interface CodeQL {
|
||||
* Run 'codeql resolve queries --format=startingpacks'.
|
||||
*/
|
||||
resolveQueriesStartingPacks(queries: string[]): Promise<string[]>;
|
||||
resolveDatabase(databasePath: string): Promise<ResolveDatabaseOutput>;
|
||||
/**
|
||||
* Run 'codeql github merge-results'.
|
||||
*/
|
||||
@@ -230,6 +231,10 @@ export interface VersionInfo {
|
||||
overlayVersion?: number;
|
||||
}
|
||||
|
||||
export interface ResolveDatabaseOutput {
|
||||
[key: string]: string | [string];
|
||||
}
|
||||
|
||||
export interface ResolveLanguagesOutput {
|
||||
[language: string]: [string];
|
||||
}
|
||||
@@ -493,6 +498,7 @@ export function createStubCodeQL(partialCodeql: Partial<CodeQL>): CodeQL {
|
||||
partialCodeql,
|
||||
"resolveQueriesStartingPacks",
|
||||
),
|
||||
resolveDatabase: resolveFunction(partialCodeql, "resolveDatabase"),
|
||||
mergeResults: resolveFunction(partialCodeql, "mergeResults"),
|
||||
};
|
||||
}
|
||||
@@ -1003,6 +1009,26 @@ async function getCodeQLForCmd(
|
||||
);
|
||||
}
|
||||
},
|
||||
async resolveDatabase(
|
||||
databasePath: string,
|
||||
): Promise<ResolveDatabaseOutput> {
|
||||
const codeqlArgs = [
|
||||
"resolve",
|
||||
"database",
|
||||
databasePath,
|
||||
"--format=json",
|
||||
...getExtraOptionsFromEnv(["resolve", "database"]),
|
||||
];
|
||||
const output = await runCli(cmd, codeqlArgs, { noStreamStdout: true });
|
||||
|
||||
try {
|
||||
return JSON.parse(output) as ResolveDatabaseOutput;
|
||||
} catch (e) {
|
||||
throw new Error(
|
||||
`Unexpected output from codeql resolve database --format=json: ${e}`,
|
||||
);
|
||||
}
|
||||
},
|
||||
async mergeResults(
|
||||
sarifFiles: string[],
|
||||
outputFile: string,
|
||||
|
||||
Reference in New Issue
Block a user