Add ability to use different filters in findSarifFilesInDir

This commit is contained in:
Michael B. Gale 2025-06-17 14:21:41 +01:00
parent 320f7b0fd6
commit 22444a650f
No known key found for this signature in database
GPG key ID: FF5E2765BD00628F
3 changed files with 14 additions and 5 deletions

6
lib/upload-lib.js generated
View file

@ -274,14 +274,16 @@ async function uploadPayload(payload, repositoryNwo, logger) {
throw (0, api_client_1.wrapApiConfigurationError)(e);
}
}
const qualityIsSarif = (name) => name.endsWith(".quality.sarif");
const defaultIsSarif = (name) => name.endsWith(".sarif") && !qualityIsSarif(name);
// Recursively walks a directory and returns all SARIF files it finds.
// Does not follow symlinks.
function findSarifFilesInDir(sarifPath) {
function findSarifFilesInDir(sarifPath, isSarif = defaultIsSarif) {
const sarifFiles = [];
const walkSarifFiles = (dir) => {
const entries = fs.readdirSync(dir, { withFileTypes: true });
for (const entry of entries) {
if (entry.isFile() && entry.name.endsWith(".sarif")) {
if (entry.isFile() && isSarif(entry.name)) {
sarifFiles.push(path.resolve(dir, entry.name));
}
else if (entry.isDirectory()) {

File diff suppressed because one or more lines are too long