Skip to content

Commit 7b7f47d

Browse files
committed
Check that file doesn't belong to other analysis in getSarifFilePaths
1 parent b26519c commit 7b7f47d

File tree

6 files changed

+74
-50
lines changed

6 files changed

+74
-50
lines changed

lib/analyze-action.js

Lines changed: 11 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/init-action-post.js

Lines changed: 11 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/upload-lib.js

Lines changed: 35 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/upload-sarif-action.js

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

src/upload-lib.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -437,13 +437,13 @@ export function findSarifFilesInDir(
437437

438438
export function getSarifFilePaths(
439439
sarifPath: string,
440-
isSarif: (name: string) => boolean,
440+
analysis: analyses.AnalysisConfig,
441441
pathStats: fs.Stats,
442442
) {
443-
let sarifFiles: string[];
443+
let sarifFiles: string[] = [];
444444
if (pathStats.isDirectory()) {
445-
sarifFiles = findSarifFilesInDir(sarifPath, isSarif);
446-
} else {
445+
sarifFiles = findSarifFilesInDir(sarifPath, analysis.sarifPredicate);
446+
} else if (!analyses.isOtherAnalysisSarif(analysis.kind, sarifPath)) {
447447
sarifFiles = [sarifPath];
448448
}
449449
return sarifFiles;
@@ -620,11 +620,7 @@ export async function uploadFiles(
620620
throw new ConfigurationError(`Path does not exist: ${inputSarifPath}`);
621621
}
622622

623-
const sarifPaths = getSarifFilePaths(
624-
inputSarifPath,
625-
uploadTarget.sarifPredicate,
626-
pathStats,
627-
);
623+
const sarifPaths = getSarifFilePaths(inputSarifPath, uploadTarget, pathStats);
628624

629625
if (sarifPaths.length === 0) {
630626
// This is always a configuration error, even for first-party runs.

src/upload-sarif.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export async function findAndUpload(
3232
): Promise<upload_lib.UploadResult | undefined> {
3333
const sarifFiles: string[] | undefined = upload_lib.getSarifFilePaths(
3434
sarifPath,
35-
analysis.sarifPredicate,
35+
analysis,
3636
pathStats,
3737
);
3838

0 commit comments

Comments
 (0)