Mark invalid SARIF errors as user errors in the upload-sarif Action

This commit is contained in:
Henry Mercer 2023-09-06 18:14:30 +01:00
parent 07d42ec34e
commit 583a1019cc
12 changed files with 95 additions and 47 deletions

4
lib/analyze-action.js generated
View file

@ -155,7 +155,7 @@ async function run() {
throw new Error("Config file could not be found at expected location. Has the 'init' action been called?");
}
if (hasBadExpectErrorInput()) {
throw new Error("`expect-error` input parameter is for internal use only. It should only be set by codeql-action or a fork.");
throw new util.UserError("`expect-error` input parameter is for internal use only. It should only be set by codeql-action or a fork.");
}
const apiDetails = (0, api_client_1.getApiDetails)();
const outputDir = actionsUtil.getRequiredInput("output");
@ -180,7 +180,7 @@ async function run() {
core.setOutput("sarif-output", path_1.default.resolve(outputDir));
const uploadInput = actionsUtil.getOptionalInput("upload");
if (runStats && actionsUtil.getUploadValue(uploadInput) === "always") {
uploadResult = await uploadLib.uploadFromActions(outputDir, actionsUtil.getRequiredInput("checkout_path"), actionsUtil.getOptionalInput("category"), logger);
uploadResult = await uploadLib.uploadFromActions(outputDir, actionsUtil.getRequiredInput("checkout_path"), actionsUtil.getOptionalInput("category"), logger, { invalidRequestIsUserError: false });
core.setOutput("sarif-id", uploadResult.sarifID);
}
else {