diff --git a/lib/upload-sarif-action.js b/lib/upload-sarif-action.js index f98e2e221..bc908440b 100644 --- a/lib/upload-sarif-action.js +++ b/lib/upload-sarif-action.js @@ -93421,6 +93421,10 @@ async function run() { const sarifPath = getRequiredInput("sarif_file"); const checkoutPath = getRequiredInput("checkout_path"); const category = getOptionalInput("category"); + const pathStats = fs15.lstatSync(sarifPath, { throwIfNoEntry: false }); + if (pathStats === void 0) { + throw new ConfigurationError(`Path does not exist: ${sarifPath}.`); + } const uploadResult = await uploadFiles( sarifPath, checkoutPath, @@ -93430,7 +93434,7 @@ async function run() { CodeScanning ); core13.setOutput("sarif-id", uploadResult.sarifID); - if (fs15.lstatSync(sarifPath).isDirectory()) { + if (pathStats.isDirectory()) { await findAndUpload( logger, features, diff --git a/src/upload-sarif-action.ts b/src/upload-sarif-action.ts index 7881232d3..ee7cd6ad3 100644 --- a/src/upload-sarif-action.ts +++ b/src/upload-sarif-action.ts @@ -129,6 +129,11 @@ async function run() { const sarifPath = actionsUtil.getRequiredInput("sarif_file"); const checkoutPath = actionsUtil.getRequiredInput("checkout_path"); const category = actionsUtil.getOptionalInput("category"); + const pathStats = fs.lstatSync(sarifPath, { throwIfNoEntry: false }); + + if (pathStats === undefined) { + throw new ConfigurationError(`Path does not exist: ${sarifPath}.`); + } const uploadResult = await upload_lib.uploadFiles( sarifPath, @@ -143,7 +148,7 @@ async function run() { // If there are `.quality.sarif` files in `sarifPath`, then upload those to the code quality service. // Code quality can currently only be enabled on top of security, so we'd currently always expect to // have a directory for the results here. - if (fs.lstatSync(sarifPath).isDirectory()) { + if (pathStats.isDirectory()) { await findAndUpload( logger, features,