Skip to content

Commit 696b467

Browse files
committed
Handle single file case in findAndUpload
1 parent c8e017d commit 696b467

File tree

2 files changed

+34
-23
lines changed

2 files changed

+34
-23
lines changed

lib/upload-sarif-action.js

Lines changed: 16 additions & 11 deletions
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: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ interface UploadSarifStatusReport
3838
*
3939
* @param logger The logger to use.
4040
* @param features Information about FFs.
41-
* @param sarifPath The path to a directory containing SARIF files.
41+
* @param sarifPath The path to a SARIF file or directory containing SARIF files.
4242
* @param pathStats Information about `sarifPath`.
4343
* @param checkoutPath The checkout path.
4444
* @param analysis The configuration of the analysis we should upload SARIF files for.
@@ -54,22 +54,28 @@ async function findAndUpload(
5454
analysis: analyses.AnalysisConfig,
5555
category?: string,
5656
): Promise<upload_lib.UploadResult | undefined> {
57+
let sarifFiles: string[] | undefined;
58+
5759
if (pathStats.isDirectory()) {
58-
const sarifFiles = upload_lib.findSarifFilesInDir(
60+
sarifFiles = upload_lib.findSarifFilesInDir(
5961
sarifPath,
6062
analysis.sarifPredicate,
6163
);
64+
} else if (pathStats.isFile() && analysis.sarifPredicate(sarifPath)) {
65+
sarifFiles = [sarifPath];
66+
} else {
67+
return undefined;
68+
}
6269

63-
if (sarifFiles.length !== 0) {
64-
return await upload_lib.uploadSpecifiedFiles(
65-
sarifFiles,
66-
checkoutPath,
67-
category,
68-
features,
69-
logger,
70-
analysis,
71-
);
72-
}
70+
if (sarifFiles.length !== 0) {
71+
return await upload_lib.uploadSpecifiedFiles(
72+
sarifFiles,
73+
checkoutPath,
74+
category,
75+
features,
76+
logger,
77+
analysis,
78+
);
7379
}
7480

7581
return undefined;

0 commit comments

Comments
 (0)