Skip to content

Commit a6161a8

Browse files
committed
Call lstatSync on sarifPath earlier and check that the path exists then
1 parent 35454d3 commit a6161a8

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

lib/upload-sarif-action.js

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/upload-sarif-action.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,11 @@ async function run() {
129129
const sarifPath = actionsUtil.getRequiredInput("sarif_file");
130130
const checkoutPath = actionsUtil.getRequiredInput("checkout_path");
131131
const category = actionsUtil.getOptionalInput("category");
132+
const pathStats = fs.lstatSync(sarifPath, { throwIfNoEntry: false });
133+
134+
if (pathStats === undefined) {
135+
throw new ConfigurationError(`Path does not exist: ${sarifPath}.`);
136+
}
132137

133138
const uploadResult = await upload_lib.uploadFiles(
134139
sarifPath,
@@ -143,7 +148,7 @@ async function run() {
143148
// If there are `.quality.sarif` files in `sarifPath`, then upload those to the code quality service.
144149
// Code quality can currently only be enabled on top of security, so we'd currently always expect to
145150
// have a directory for the results here.
146-
if (fs.lstatSync(sarifPath).isDirectory()) {
151+
if (pathStats.isDirectory()) {
147152
await findAndUpload(
148153
logger,
149154
features,

0 commit comments

Comments
 (0)