diff --git a/src/codeql.ts b/src/codeql.ts index bd2400d3b..d312d50f8 100644 --- a/src/codeql.ts +++ b/src/codeql.ts @@ -198,6 +198,10 @@ export interface CodeQL { ): Promise; /** Get the location of an extractor for the specified language. */ resolveExtractor(language: Language): Promise; + /** + * Run 'codeql resolve queries --format=startingpacks'. + */ + resolveQueriesStartingPacks(queries: string[]): Promise; /** * Run 'codeql github merge-results'. */ @@ -479,6 +483,10 @@ export function createStubCodeQL(partialCodeql: Partial): CodeQL { ), diagnosticsExport: resolveFunction(partialCodeql, "diagnosticsExport"), resolveExtractor: resolveFunction(partialCodeql, "resolveExtractor"), + resolveQueriesStartingPacks: resolveFunction( + partialCodeql, + "resolveQueriesStartingPacks", + ), mergeResults: resolveFunction(partialCodeql, "mergeResults"), }; } @@ -974,6 +982,24 @@ export async function getCodeQLForCmd( ).exec(); return JSON.parse(extractorPath) as string; }, + async resolveQueriesStartingPacks(queries: string[]): Promise { + const codeqlArgs = [ + "resolve", + "queries", + "--format=startingpacks", + ...getExtraOptionsFromEnv(["resolve", "queries"]), + ...queries, + ]; + const output = await runCli(cmd, codeqlArgs, { noStreamStdout: true }); + + try { + return JSON.parse(output) as string[]; + } catch (e) { + throw new Error( + `Unexpected output from codeql resolve queries --format=startingpacks: ${e}`, + ); + } + }, async mergeResults( sarifFiles: string[], outputFile: string,