Skip to content

Commit 9d202e0

Browse files
committed
Add resolveQueriesStartingPacks()
1 parent ad19982 commit 9d202e0

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/codeql.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,10 @@ export interface CodeQL {
198198
): Promise<void>;
199199
/** Get the location of an extractor for the specified language. */
200200
resolveExtractor(language: Language): Promise<string>;
201+
/**
202+
* Run 'codeql resolve queries --format=startingpacks'.
203+
*/
204+
resolveQueriesStartingPacks(queries: string[]): Promise<string[]>;
201205
/**
202206
* Run 'codeql github merge-results'.
203207
*/
@@ -479,6 +483,10 @@ export function createStubCodeQL(partialCodeql: Partial<CodeQL>): CodeQL {
479483
),
480484
diagnosticsExport: resolveFunction(partialCodeql, "diagnosticsExport"),
481485
resolveExtractor: resolveFunction(partialCodeql, "resolveExtractor"),
486+
resolveQueriesStartingPacks: resolveFunction(
487+
partialCodeql,
488+
"resolveQueriesStartingPacks",
489+
),
482490
mergeResults: resolveFunction(partialCodeql, "mergeResults"),
483491
};
484492
}
@@ -974,6 +982,24 @@ export async function getCodeQLForCmd(
974982
).exec();
975983
return JSON.parse(extractorPath) as string;
976984
},
985+
async resolveQueriesStartingPacks(queries: string[]): Promise<string[]> {
986+
const codeqlArgs = [
987+
"resolve",
988+
"queries",
989+
"--format=startingpacks",
990+
...getExtraOptionsFromEnv(["resolve", "queries"]),
991+
...queries,
992+
];
993+
const output = await runCli(cmd, codeqlArgs, { noStreamStdout: true });
994+
995+
try {
996+
return JSON.parse(output) as string[];
997+
} catch (e) {
998+
throw new Error(
999+
`Unexpected output from codeql resolve queries --format=startingpacks: ${e}`,
1000+
);
1001+
}
1002+
},
9771003
async mergeResults(
9781004
sarifFiles: string[],
9791005
outputFile: string,

0 commit comments

Comments
 (0)