Skip to content

Commit dd89143

Browse files
committed
CodeQL: Add resolveDatabase method
1 parent 78357d3 commit dd89143

10 files changed

+179
-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: 26 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(databasePath: string): 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,26 @@ async function getCodeQLForCmd(
10031009
);
10041010
}
10051011
},
1012+
async resolveDatabase(
1013+
databasePath: string,
1014+
): Promise<ResolveDatabaseOutput> {
1015+
const codeqlArgs = [
1016+
"resolve",
1017+
"database",
1018+
databasePath,
1019+
"--format=json",
1020+
...getExtraOptionsFromEnv(["resolve", "database"]),
1021+
];
1022+
const output = await runCli(cmd, codeqlArgs, { noStreamStdout: true });
1023+
1024+
try {
1025+
return JSON.parse(output) as ResolveDatabaseOutput;
1026+
} catch (e) {
1027+
throw new Error(
1028+
`Unexpected output from codeql resolve database --format=json: ${e}`,
1029+
);
1030+
}
1031+
},
10061032
async mergeResults(
10071033
sarifFiles: string[],
10081034
outputFile: string,

0 commit comments

Comments
 (0)