@fabasoad/sarif-to-slack 1.3.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +16 -14
- package/dist/utils/FileUtils.js +16 -15
- package/package.json +3 -3
- package/src/utils/FileUtils.ts +15 -13
- package/tests/integration/SendSarifToSlack.spec.ts +1 -1
package/dist/index.cjs
CHANGED
|
@@ -214,9 +214,9 @@ var SecurityLevel = /* @__PURE__ */ ((SecurityLevel2) => {
|
|
|
214
214
|
})(SecurityLevel || {});
|
|
215
215
|
|
|
216
216
|
// src/metadata.json
|
|
217
|
-
var version = "1.3.
|
|
218
|
-
var sha = "
|
|
219
|
-
var buildAt = "2025-08-
|
|
217
|
+
var version = "1.3.1";
|
|
218
|
+
var sha = "fac0524704ae1c62880212a04af4e48ac31297ed";
|
|
219
|
+
var buildAt = "2025-08-25T09:16:54Z";
|
|
220
220
|
|
|
221
221
|
// src/model/SlackMessage.ts
|
|
222
222
|
function createSlackMessage(url, opts) {
|
|
@@ -351,16 +351,18 @@ var System = class {
|
|
|
351
351
|
// src/utils/FileUtils.ts
|
|
352
352
|
var import_fs = __toESM(require("fs"));
|
|
353
353
|
var path = __toESM(require("path"));
|
|
354
|
-
function
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
354
|
+
function listFiles(dir, recursive, extension, fileList = []) {
|
|
355
|
+
if (import_fs.default.statSync(dir).isDirectory()) {
|
|
356
|
+
const entries = import_fs.default.readdirSync(dir);
|
|
357
|
+
entries.forEach((entry) => {
|
|
358
|
+
const fullPath = path.join(dir, entry);
|
|
359
|
+
if (recursive && import_fs.default.statSync(fullPath).isDirectory()) {
|
|
360
|
+
listFiles(fullPath, recursive, extension, fileList);
|
|
361
|
+
} else if (path.extname(fullPath).toLowerCase() === `.${extension}`) {
|
|
362
|
+
fileList.push(fullPath);
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
}
|
|
364
366
|
return fileList;
|
|
365
367
|
}
|
|
366
368
|
function extractListOfFiles(opts) {
|
|
@@ -370,7 +372,7 @@ function extractListOfFiles(opts) {
|
|
|
370
372
|
const stats = import_fs.default.statSync(opts.path);
|
|
371
373
|
if (stats.isDirectory()) {
|
|
372
374
|
Logger.info(`Provided path is a directory: ${opts.path}`);
|
|
373
|
-
const files = opts.
|
|
375
|
+
const files = listFiles(opts.path, !!opts.recursive, opts.extension ?? "sarif");
|
|
374
376
|
Logger.info(`Found ${files.length} files in ${opts.path} directory with ${opts.extension} extension`);
|
|
375
377
|
Logger.debug(`Found files: ${files.join(", ")}`);
|
|
376
378
|
return files;
|
package/dist/utils/FileUtils.js
CHANGED
|
@@ -5,21 +5,24 @@ import * as path from 'path';
|
|
|
5
5
|
* Traverse directory recursively and returns list of files with the requested
|
|
6
6
|
* extension.
|
|
7
7
|
* @param dir A root directory. Starting point.
|
|
8
|
+
* @param recursive Whether to list files recursively or not.
|
|
8
9
|
* @param extension An instance of {@link SarifFileExtension} type.
|
|
9
10
|
* @param fileList Collected list of files.
|
|
10
11
|
* @private
|
|
11
12
|
*/
|
|
12
|
-
function
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
13
|
+
function listFiles(dir, recursive, extension, fileList = []) {
|
|
14
|
+
if (fs.statSync(dir).isDirectory()) {
|
|
15
|
+
const entries = fs.readdirSync(dir);
|
|
16
|
+
entries.forEach((entry) => {
|
|
17
|
+
const fullPath = path.join(dir, entry);
|
|
18
|
+
if (recursive && fs.statSync(fullPath).isDirectory()) {
|
|
19
|
+
listFiles(fullPath, recursive, extension, fileList);
|
|
20
|
+
}
|
|
21
|
+
else if (path.extname(fullPath).toLowerCase() === `.${extension}`) {
|
|
22
|
+
fileList.push(fullPath);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
23
26
|
return fileList;
|
|
24
27
|
}
|
|
25
28
|
/**
|
|
@@ -35,9 +38,7 @@ export function extractListOfFiles(opts) {
|
|
|
35
38
|
const stats = fs.statSync(opts.path);
|
|
36
39
|
if (stats.isDirectory()) {
|
|
37
40
|
Logger.info(`Provided path is a directory: ${opts.path}`);
|
|
38
|
-
const files = opts.recursive
|
|
39
|
-
&& listFilesRecursively(opts.path, opts.extension ?? 'sarif')
|
|
40
|
-
|| fs.readdirSync(opts.path);
|
|
41
|
+
const files = listFiles(opts.path, !!opts.recursive, opts.extension ?? 'sarif');
|
|
41
42
|
Logger.info(`Found ${files.length} files in ${opts.path} directory with ${opts.extension} extension`);
|
|
42
43
|
Logger.debug(`Found files: ${files.join(', ')}`);
|
|
43
44
|
return files;
|
|
@@ -48,4 +49,4 @@ export function extractListOfFiles(opts) {
|
|
|
48
49
|
}
|
|
49
50
|
throw new Error(`Provided path is neither a file nor a directory: ${opts.path}`);
|
|
50
51
|
}
|
|
51
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
52
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiRmlsZVV0aWxzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3V0aWxzL0ZpbGVVdGlscy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsTUFBTSxJQUFJLENBQUE7QUFDbkIsT0FBTyxNQUFNLE1BQU0sV0FBVyxDQUFBO0FBRTlCLE9BQU8sS0FBSyxJQUFJLE1BQU0sTUFBTSxDQUFBO0FBRTVCOzs7Ozs7OztHQVFHO0FBQ0gsU0FBUyxTQUFTLENBQ2hCLEdBQVcsRUFDWCxTQUFrQixFQUNsQixTQUE2QixFQUM3QixXQUFxQixFQUFFO0lBRXZCLElBQUksRUFBRSxDQUFDLFFBQVEsQ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
"description": "TypeScript library to send results of SARIF file to Slack webhook URL.",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -42,12 +42,12 @@
|
|
|
42
42
|
},
|
|
43
43
|
"homepage": "https://github.com/fabasoad/sarif-to-slack#readme",
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@slack/webhook": "7.0.
|
|
45
|
+
"@slack/webhook": "7.0.6",
|
|
46
46
|
"@types/sarif": "2.1.7",
|
|
47
47
|
"tslog": "4.9.3"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@biomejs/biome": "2.2.
|
|
50
|
+
"@biomejs/biome": "2.2.2",
|
|
51
51
|
"@microsoft/api-documenter": "7.26.32",
|
|
52
52
|
"@microsoft/api-extractor": "7.52.11",
|
|
53
53
|
"@types/jest": "30.0.0",
|
package/src/utils/FileUtils.ts
CHANGED
|
@@ -7,24 +7,28 @@ import * as path from 'path'
|
|
|
7
7
|
* Traverse directory recursively and returns list of files with the requested
|
|
8
8
|
* extension.
|
|
9
9
|
* @param dir A root directory. Starting point.
|
|
10
|
+
* @param recursive Whether to list files recursively or not.
|
|
10
11
|
* @param extension An instance of {@link SarifFileExtension} type.
|
|
11
12
|
* @param fileList Collected list of files.
|
|
12
13
|
* @private
|
|
13
14
|
*/
|
|
14
|
-
function
|
|
15
|
+
function listFiles(
|
|
15
16
|
dir: string,
|
|
17
|
+
recursive: boolean,
|
|
16
18
|
extension: SarifFileExtension,
|
|
17
19
|
fileList: string[] = []
|
|
18
20
|
): string[] {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
if (fs.statSync(dir).isDirectory()) {
|
|
22
|
+
const entries: string[] = fs.readdirSync(dir)
|
|
23
|
+
entries.forEach((entry: string): void => {
|
|
24
|
+
const fullPath: string = path.join(dir, entry)
|
|
25
|
+
if (recursive && fs.statSync(fullPath).isDirectory()) {
|
|
26
|
+
listFiles(fullPath, recursive, extension, fileList)
|
|
27
|
+
} else if (path.extname(fullPath).toLowerCase() === `.${extension}`) {
|
|
28
|
+
fileList.push(fullPath)
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
}
|
|
28
32
|
return fileList
|
|
29
33
|
}
|
|
30
34
|
|
|
@@ -43,9 +47,7 @@ export function extractListOfFiles(opts: SarifOptions): string[] {
|
|
|
43
47
|
|
|
44
48
|
if (stats.isDirectory()) {
|
|
45
49
|
Logger.info(`Provided path is a directory: ${opts.path}`)
|
|
46
|
-
const files: string[] = opts.recursive
|
|
47
|
-
&& listFilesRecursively(opts.path, opts.extension ?? 'sarif')
|
|
48
|
-
|| fs.readdirSync(opts.path)
|
|
50
|
+
const files: string[] = listFiles(opts.path, !!opts.recursive, opts.extension ?? 'sarif')
|
|
49
51
|
Logger.info(`Found ${files.length} files in ${opts.path} directory with ${opts.extension} extension`)
|
|
50
52
|
Logger.debug(`Found files: ${files.join(', ')}`)
|
|
51
53
|
return files
|
|
@@ -128,7 +128,7 @@ describe('(integration): SendSarifToSlack', (): void => {
|
|
|
128
128
|
sarif: {
|
|
129
129
|
path: process.env.SARIF_TO_SLACK_SARIF_PATH as string,
|
|
130
130
|
recursive: process.env.SARIF_TO_SLACK_SARIF_PATH_RECURSIVE
|
|
131
|
-
?
|
|
131
|
+
? process.env.SARIF_TO_SLACK_SARIF_PATH_RECURSIVE.toLowerCase() === 'true'
|
|
132
132
|
: false,
|
|
133
133
|
extension: process.env.SARIF_TO_SLACK_SARIF_FILE_EXTENSION
|
|
134
134
|
? processSarifExtension(process.env.SARIF_TO_SLACK_SARIF_FILE_EXTENSION)
|