Skip to content

Commit a2c01bc

Browse files
committed
Add resolveQueriesStartingPacks()
1 parent 6e1ed0d commit a2c01bc

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
@@ -190,6 +190,10 @@ export interface CodeQL {
190190
): Promise<void>;
191191
/** Get the location of an extractor for the specified language. */
192192
resolveExtractor(language: Language): Promise<string>;
193+
/**
194+
* Run 'codeql resolve queries --format=startingpacks'.
195+
*/
196+
resolveQueriesStartingPacks(queries: string[]): Promise<string[]>;
193197
/**
194198
* Run 'codeql github merge-results'.
195199
*/
@@ -456,6 +460,10 @@ export function setCodeQL(partialCodeql: Partial<CodeQL>): CodeQL {
456460
),
457461
diagnosticsExport: resolveFunction(partialCodeql, "diagnosticsExport"),
458462
resolveExtractor: resolveFunction(partialCodeql, "resolveExtractor"),
463+
resolveQueriesStartingPacks: resolveFunction(
464+
partialCodeql,
465+
"resolveQueriesStartingPacks",
466+
),
459467
mergeResults: resolveFunction(partialCodeql, "mergeResults"),
460468
};
461469
return cachedCodeQL;
@@ -952,6 +960,24 @@ export async function getCodeQLForCmd(
952960
).exec();
953961
return JSON.parse(extractorPath) as string;
954962
},
963+
async resolveQueriesStartingPacks(queries: string[]): Promise<string[]> {
964+
const codeqlArgs = [
965+
"resolve",
966+
"queries",
967+
"--format=startingpacks",
968+
...getExtraOptionsFromEnv(["resolve", "queries"]),
969+
...queries,
970+
];
971+
const output = await runCli(cmd, codeqlArgs, { noStreamStdout: true });
972+
973+
try {
974+
return JSON.parse(output) as string[];
975+
} catch (e) {
976+
throw new Error(
977+
`Unexpected output from codeql resolve queries --format=startingpacks: ${e}`,
978+
);
979+
}
980+
},
955981
async mergeResults(
956982
sarifFiles: string[],
957983
outputFile: string,

0 commit comments

Comments
 (0)