Skip to content

Commit 1f520aa

Browse files
committed
CodeQL: Add resolveDatabase method
1 parent f0ac9bf commit 1f520aa

10 files changed

+177
-0
lines changed

lib/analyze-action-post.js

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

lib/analyze-action.js

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

lib/autobuild-action.js

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

lib/init-action-post.js

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

lib/init-action.js

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

lib/resolve-environment-action.js

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

lib/setup-codeql-action.js

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

lib/upload-lib.js

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

lib/upload-sarif-action.js

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

src/codeql.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ export interface CodeQL {
206206
* Run 'codeql resolve queries --format=startingpacks'.
207207
*/
208208
resolveQueriesStartingPacks(queries: string[]): Promise<string[]>;
209+
resolveDatabase(config: Config): Promise<ResolveDatabaseOutput>;
209210
/**
210211
* Run 'codeql github merge-results'.
211212
*/
@@ -230,6 +231,10 @@ export interface VersionInfo {
230231
overlayVersion?: number;
231232
}
232233

234+
export interface ResolveDatabaseOutput {
235+
[key: string]: string | [string];
236+
}
237+
233238
export interface ResolveLanguagesOutput {
234239
[language: string]: [string];
235240
}
@@ -493,6 +498,7 @@ export function createStubCodeQL(partialCodeql: Partial<CodeQL>): CodeQL {
493498
partialCodeql,
494499
"resolveQueriesStartingPacks",
495500
),
501+
resolveDatabase: resolveFunction(partialCodeql, "resolveDatabase"),
496502
mergeResults: resolveFunction(partialCodeql, "mergeResults"),
497503
};
498504
}
@@ -1003,6 +1009,24 @@ async function getCodeQLForCmd(
10031009
);
10041010
}
10051011
},
1012+
async resolveDatabase(config: Config): Promise<ResolveDatabaseOutput> {
1013+
const codeqlArgs = [
1014+
"resolve",
1015+
"database",
1016+
"--format=json",
1017+
...getExtraOptionsFromEnv(["resolve", "database"]),
1018+
...config.dbLocation,
1019+
];
1020+
const output = await runCli(cmd, codeqlArgs, { noStreamStdout: true });
1021+
1022+
try {
1023+
return JSON.parse(output) as ResolveDatabaseOutput;
1024+
} catch (e) {
1025+
throw new Error(
1026+
`Unexpected output from codeql resolve database --format=json: ${e}`,
1027+
);
1028+
}
1029+
},
10061030
async mergeResults(
10071031
sarifFiles: string[],
10081032
outputFile: string,

0 commit comments

Comments
 (0)