mirror of
https://github.com/github/codeql-action.git
synced 2026-04-02 09:42:16 +00:00
Wrap JSON parsing in try/catch
This commit is contained in:
8
lib/codeql.js
generated
8
lib/codeql.js
generated
@@ -255,7 +255,13 @@ async function getCodeQLForCmd(cmd, checkVersion) {
|
||||
async getVersion() {
|
||||
let result = util.getCachedCodeQlVersion();
|
||||
if (result === undefined) {
|
||||
result = JSON.parse(await runTool(cmd, ["version", "--format=json"]));
|
||||
const output = await runTool(cmd, ["version", "--format=json"]);
|
||||
try {
|
||||
result = JSON.parse(output);
|
||||
}
|
||||
catch (err) {
|
||||
throw Error(`Invalid JSON output from \`version --format=json\`: ${output}`);
|
||||
}
|
||||
util.cacheCodeQlVersion(result);
|
||||
}
|
||||
return result;
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -554,9 +554,14 @@ export async function getCodeQLForCmd(
|
||||
async getVersion() {
|
||||
let result = util.getCachedCodeQlVersion();
|
||||
if (result === undefined) {
|
||||
result = JSON.parse(
|
||||
await runTool(cmd, ["version", "--format=json"]),
|
||||
) as VersionOutput;
|
||||
const output = await runTool(cmd, ["version", "--format=json"]);
|
||||
try {
|
||||
result = JSON.parse(output) as VersionOutput;
|
||||
} catch (err) {
|
||||
throw Error(
|
||||
`Invalid JSON output from \`version --format=json\`: ${output}`,
|
||||
);
|
||||
}
|
||||
util.cacheCodeQlVersion(result);
|
||||
}
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user