Skip to content
Prev Previous commit
Next Next commit
Move isDirectory check into findAndUpload
  • Loading branch information
mbg committed Sep 18, 2025
commit c8e017d3e778faac9a5b2898085a763c1198b3d1
47 changes: 24 additions & 23 deletions lib/upload-sarif-action.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 26 additions & 23 deletions src/upload-sarif-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ interface UploadSarifStatusReport
* @param logger The logger to use.
* @param features Information about FFs.
* @param sarifPath The path to a directory containing SARIF files.
* @param pathStats Information about `sarifPath`.
* @param checkoutPath The checkout path.
* @param analysis The configuration of the analysis we should upload SARIF files for.
* @param category The SARIF category to use for the upload.
Expand All @@ -48,24 +49,27 @@ async function findAndUpload(
logger: Logger,
features: Features,
sarifPath: string,
pathStats: fs.Stats,
checkoutPath: string,
analysis: analyses.AnalysisConfig,
category?: string,
): Promise<upload_lib.UploadResult | undefined> {
const sarifFiles = upload_lib.findSarifFilesInDir(
sarifPath,
analysis.sarifPredicate,
);

if (sarifFiles.length !== 0) {
return await upload_lib.uploadSpecifiedFiles(
sarifFiles,
checkoutPath,
category,
features,
logger,
analysis,
if (pathStats.isDirectory()) {
const sarifFiles = upload_lib.findSarifFilesInDir(
sarifPath,
analysis.sarifPredicate,
);

if (sarifFiles.length !== 0) {
return await upload_lib.uploadSpecifiedFiles(
sarifFiles,
checkoutPath,
category,
features,
logger,
analysis,
);
}
}

return undefined;
Expand Down Expand Up @@ -148,16 +152,15 @@ 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 (pathStats.isDirectory()) {
await findAndUpload(
logger,
features,
sarifPath,
checkoutPath,
analyses.CodeQuality,
actionsUtil.fixCodeQualityCategory(logger, category),
);
}
await findAndUpload(
logger,
features,
sarifPath,
pathStats,
checkoutPath,
analyses.CodeQuality,
actionsUtil.fixCodeQualityCategory(logger, category),
);

// We don't upload results in test mode, so don't wait for processing
if (isInTestMode()) {
Expand Down