@fabasoad/sarif-to-slack 1.3.4 → 1.3.5

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.
@@ -28,7 +28,7 @@ jobs:
28
28
  ref-name: ${{ steps.metadata.outputs.ref-name }}
29
29
  steps:
30
30
  - name: Get GitHub token
31
- uses: actions/create-github-app-token@v2
31
+ uses: actions/create-github-app-token@v3
32
32
  id: github-app
33
33
  with:
34
34
  app-id: ${{ vars.GH_APP_CONTENTS_CRUD_APP_ID }}
@@ -40,7 +40,7 @@ repos:
40
40
  hooks:
41
41
  - id: detect-secrets
42
42
  - repo: https://github.com/gitleaks/gitleaks
43
- rev: v8.30.0
43
+ rev: v8.30.1
44
44
  hooks:
45
45
  - id: gitleaks
46
46
  - repo: https://github.com/fabasoad/pre-commit-snyk
@@ -60,7 +60,7 @@ repos:
60
60
  - --hook-args=--log-level debug
61
61
  stages: ["pre-push"]
62
62
  - repo: https://github.com/google/osv-scanner
63
- rev: v2.3.3
63
+ rev: v2.3.5
64
64
  hooks:
65
65
  - id: osv-scanner
66
66
  args:
@@ -69,7 +69,7 @@ repos:
69
69
  stages: ["pre-push"]
70
70
  # Markdown
71
71
  - repo: https://github.com/igorshubovych/markdownlint-cli
72
- rev: v0.47.0
72
+ rev: v0.48.0
73
73
  hooks:
74
74
  - id: markdownlint-fix
75
75
  stages: ["pre-commit"]
@@ -81,7 +81,7 @@ repos:
81
81
  stages: ["pre-push"]
82
82
  # GitHub Actions
83
83
  - repo: https://github.com/rhysd/actionlint
84
- rev: v1.7.10
84
+ rev: v1.7.12
85
85
  hooks:
86
86
  - id: actionlint
87
87
  args: ["-pyflakes=", "-shellcheck="]
package/.tool-versions CHANGED
@@ -1 +1 @@
1
- nodejs 25.6.1
1
+ nodejs 25.9.0
package/Makefile CHANGED
@@ -43,7 +43,7 @@ npm/update:
43
43
 
44
44
  .PHONY: pre-commit/update
45
45
  pre-commit/update:
46
- @pre-commit autoupdate
46
+ @command -v prek >/dev/null 2>&1 && prek auto-update || pre-commit autoupdate
47
47
 
48
48
  .PHONY: update
49
49
  update: npm/update pre-commit/update
@@ -264,7 +264,7 @@
264
264
  /**
265
265
  * (REQUIRED) Whether to generate the .d.ts rollup file.
266
266
  */
267
- "enabled": true
267
+ "enabled": true,
268
268
 
269
269
  /**
270
270
  * Specifies the output path for a .d.ts rollup file to be generated without any trimming.
@@ -278,7 +278,7 @@
278
278
  * SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
279
279
  * DEFAULT VALUE: "<projectFolder>/dist/<unscopedPackageName>.d.ts"
280
280
  */
281
- // "untrimmedFilePath": "<projectFolder>/dist/<unscopedPackageName>.d.ts",
281
+ "untrimmedFilePath": "<projectFolder>/dist/index.d.ts",
282
282
 
283
283
  /**
284
284
  * Specifies the output path for a .d.ts rollup file to be generated with trimming for an "alpha" release.
package/dist/index.cjs CHANGED
@@ -175,9 +175,9 @@ var import_zod2 = require("zod");
175
175
  var import_zod = require("zod");
176
176
 
177
177
  // src/metadata.json
178
- var version = "1.3.4";
179
- var sha = "7dcec52f94545c8b5319ca92f2e77130b7bd0f3a";
180
- var buildAt = "2026-02-13T14:07:20Z";
178
+ var version = "1.3.5";
179
+ var sha = "4b44572f95bfdaab5159a2bd89a3ed2b193b55aa";
180
+ var buildAt = "2026-04-04T14:25:40Z";
181
181
 
182
182
  // src/system.ts
183
183
  function logMetadata() {
@@ -565,6 +565,7 @@ var Column = class {
565
565
  this.header = header;
566
566
  this._cells = new Array(cellsCount);
567
567
  }
568
+ header;
568
569
  _logger = new Logger("Column");
569
570
  _cells;
570
571
  get total() {
@@ -596,6 +597,7 @@ var Cell = class {
596
597
  this._value = _value;
597
598
  this._width = _value.toString().length;
598
599
  }
600
+ _value;
599
601
  _width;
600
602
  setWidth(width) {
601
603
  this._width = width > this._width ? width : this._width;
@@ -621,6 +623,8 @@ var Row = class {
621
623
  this._cells = Array.from({ length: cellsCount }, () => new Cell());
622
624
  this._totalWidth = 1;
623
625
  }
626
+ _header;
627
+ headerWidth;
624
628
  _logger = new Logger("Row");
625
629
  _cells;
626
630
  _totalWidth;
@@ -729,6 +733,9 @@ var TableGroupRepresentation = class extends Representation {
729
733
  this._keyPer = _keyPer;
730
734
  this._values = _values;
731
735
  }
736
+ _keyBy;
737
+ _keyPer;
738
+ _values;
732
739
  _logger = new Logger("TableGroupRepresentation");
733
740
  groupFindingsPer(findings) {
734
741
  return findings.reduce(
package/dist/index.d.ts CHANGED
@@ -69,9 +69,494 @@
69
69
  *
70
70
  * @packageDocumentation
71
71
  */
72
- export { Color } from './model/color/Color';
73
- export { ColorOptions, ColorGroupCommon, ColorGroupByLevel, ColorGroupBySeverity } from './model/color/ColorOptions';
74
- export { SendIf } from './model/SendIf';
75
- export { SarifToSlackClient } from './SarifToSlackClient';
76
- export { FooterOptions, FooterType, IncludeAwareOptions, IncludeAwareWithValueOptions, RepresentationType, SarifFileExtension, SarifOptions, SarifToSlackClientOptions } from './types';
77
- //# sourceMappingURL=index.d.ts.map
72
+
73
+ /**
74
+ * This class represents a color in hex format.
75
+ * @public
76
+ */
77
+ export declare class Color {
78
+ /**
79
+ * A valid string that represents a color in hex format.
80
+ * @public
81
+ */
82
+ readonly color: string;
83
+ private constructor();
84
+ /**
85
+ * Creates an instance of {@link Color} class. Before creating an instance of
86
+ * {@link Color} class, it (if applicable) maps CI status into the hex color,
87
+ * and also validates color parameter to be a valid string that represents a
88
+ * color in hex format.
89
+ * @param color - Can be either undefined, valid color in hex format or GitHub
90
+ * CI status (one of: success, failure, cancelled, skipped).
91
+ * @returns An instance of {@link Color} or undefined if color parameter is falsy.
92
+ * @public
93
+ */
94
+ static from(color: string | undefined): Color | undefined;
95
+ private assertHexColor;
96
+ private mapColor;
97
+ }
98
+
99
+ /**
100
+ * Color schema for the findings with the certain level. Color is used by the
101
+ * level importance, i.e. if at least 1 error finding exists then
102
+ * {@link ColorGroupByLevel#error} color is used, then if at least 1 warning
103
+ * finding exists then {@link ColorGroupByLevel#warning} color is used, etc.
104
+ * @public
105
+ */
106
+ export declare type ColorGroupByLevel = ColorGroupCommon & {
107
+ error?: Color;
108
+ warning?: Color;
109
+ note?: Color;
110
+ };
111
+
112
+ /**
113
+ * Color schema for the findings with the certain severity. Color is used by the
114
+ * severity importance, i.e. if at least 1 critical finding exists then
115
+ * {@link ColorGroupBySeverity#critical} color is used, then if at least 1 high
116
+ * finding exists then {@link ColorGroupBySeverity#high} color is used, etc.
117
+ * @public
118
+ */
119
+ export declare type ColorGroupBySeverity = ColorGroupCommon & {
120
+ critical?: Color;
121
+ high?: Color;
122
+ medium?: Color;
123
+ low?: Color;
124
+ };
125
+
126
+ /**
127
+ * Base type that has common fields for both {@link ColorGroupByLevel} and
128
+ * {@link ColorGroupBySeverity}.
129
+ * @public
130
+ */
131
+ export declare type ColorGroupCommon = {
132
+ none?: Color;
133
+ unknown?: Color;
134
+ };
135
+
136
+ /**
137
+ * Represents configuration of the color scheme. If both {@link ColorOptions#byLevel}
138
+ * and {@link ColorOptions#bySeverity} are defined, then {@link ColorOptions#bySeverity}
139
+ * takes precedence.
140
+ * @public
141
+ */
142
+ export declare type ColorOptions = {
143
+ /**
144
+ * Default color if specific color was not found. It is a fallback option.
145
+ */
146
+ default?: Color;
147
+ /**
148
+ * Color scheme for the findings where certain level is presented.
149
+ */
150
+ byLevel?: ColorGroupByLevel;
151
+ /**
152
+ * Color scheme for the findings where certain severity is presented.
153
+ */
154
+ bySeverity?: ColorGroupBySeverity;
155
+ /**
156
+ * Color when no findings are found.
157
+ */
158
+ empty?: Color;
159
+ };
160
+
161
+ /**
162
+ * Options for the footer of a Slack message. "type" is ignored if "value" is
163
+ * not defined.
164
+ * @public
165
+ */
166
+ export declare type FooterOptions = IncludeAwareWithValueOptions & {
167
+ type?: FooterType;
168
+ };
169
+
170
+ /**
171
+ * Enum representing the type of footer in a Slack message.
172
+ * @public
173
+ */
174
+ export declare enum FooterType {
175
+ /**
176
+ * Represents a plain text footer. Text is not formatted and appears as-is.
177
+ */
178
+ PlainText = "plain_text",
179
+ /**
180
+ * Represents a footer with Markdown formatting. Text can include formatting
181
+ * such as bold, italics, and links.
182
+ */
183
+ Markdown = "mrkdwn"
184
+ }
185
+
186
+ /**
187
+ * Type representing properties that indicate whether to include certain information
188
+ * in the Slack message.
189
+ * @public
190
+ */
191
+ export declare type IncludeAwareOptions = {
192
+ include: boolean;
193
+ };
194
+
195
+ /**
196
+ * Type representing properties that indicate whether to include certain information
197
+ * in the Slack message, along with an optional value.
198
+ * @public
199
+ */
200
+ export declare type IncludeAwareWithValueOptions = IncludeAwareOptions & {
201
+ value?: string;
202
+ };
203
+
204
+ /**
205
+ * This represents what type of message should be sent. There are various options
206
+ * to show information from SARIF in Slack message.
207
+ * @public
208
+ */
209
+ export declare enum RepresentationType {
210
+ /**
211
+ * Compact information about findings grouped by Run with the level representation.
212
+ * @example
213
+ * ```text
214
+ * [Run 1] Grype
215
+ * Error: 1, Warning: 4
216
+ * [Run 2] Grype
217
+ * Warning: 1, Note: 20
218
+ * ```
219
+ */
220
+ CompactGroupByRunPerLevel = 0,
221
+ /**
222
+ * Compact information about findings grouped by Run with the severity representation.
223
+ * @example
224
+ * ```text
225
+ * [Run 1] Grype
226
+ * Critical: 1, High: 3, Medium: 1
227
+ * [Run 2] Grype
228
+ * Medium: 1, Low: 20
229
+ * ```
230
+ */
231
+ CompactGroupByRunPerSeverity = 1,
232
+ /**
233
+ * Compact information about findings grouped by tool name with the level representation.
234
+ * @example
235
+ * ```text
236
+ * Grype
237
+ * Error: 1, Warning: 5, Note: 20
238
+ * ```
239
+ */
240
+ CompactGroupByToolNamePerLevel = 2,
241
+ /**
242
+ * Compact information about findings grouped by tool name with the severity representation.
243
+ * @example
244
+ * ```text
245
+ * Grype
246
+ * Critical: 1, High: 3, Medium: 2, Low: 20
247
+ * ```
248
+ */
249
+ CompactGroupByToolNamePerSeverity = 3,
250
+ /**
251
+ * Compact information about findings grouped by SARIF file with the level representation.
252
+ * @example
253
+ * ```text
254
+ * grype-results-01.sarif
255
+ * Error: 1, Warning: 2, Note: 1
256
+ * grype-results-02.sarif
257
+ * Warning: 3, Note: 19
258
+ * ```
259
+ */
260
+ CompactGroupBySarifPerLevel = 4,
261
+ /**
262
+ * Compact information about findings grouped by SARIF file with the severity
263
+ * representation.
264
+ * @example
265
+ * ```text
266
+ * grype-results-01.sarif
267
+ * High: 3, Medium: 1, Low: 11
268
+ * grype-results-02.sarif
269
+ * Critical: 1, Medium: 1, Low: 9
270
+ * ```
271
+ */
272
+ CompactGroupBySarifPerSeverity = 5,
273
+ /**
274
+ * Compact information about findings with the level representation.
275
+ * @example
276
+ * ```text
277
+ * Total
278
+ * Error: 1, Warning: 5, Note: 20
279
+ * ```
280
+ */
281
+ CompactTotalPerLevel = 6,
282
+ /**
283
+ * Compact information about findings with the severity representation.
284
+ * @example
285
+ * ```text
286
+ * Total
287
+ * Critical: 1, High: 3, Medium: 2, Low: 20
288
+ * ```
289
+ */
290
+ CompactTotalPerSeverity = 7,
291
+ /**
292
+ * Table information about findings grouped by Run with the level representation.
293
+ * @example
294
+ * ```text
295
+ * | | Unknown | None | Note | Warning | Error | Total |
296
+ * | ----- | ------- | ---- | ---- | ------- | ----- | ----- |
297
+ * | 1 | 0 | 0 | 0 | 1 | 0 | 1 |
298
+ * | 2 | 0 | 0 | 9 | 20 | 10 | 39 |
299
+ * | 3 | 0 | 0 | 1 | 0 | 1 | 2 |
300
+ * | 4 | 0 | 0 | 5 | 5 | 0 | 10 |
301
+ * | ----- | ------- | ---- | ---- | ------- | ----- | ----- |
302
+ * | Total | 0 | 0 | 15 | 26 | 11 | 52 |
303
+ * ```
304
+ */
305
+ TableGroupByRunPerLevel = 8,
306
+ /**
307
+ * Table information about findings grouped by Run with the severity representation.
308
+ * @example
309
+ * ```text
310
+ * | | Unknown | None | Low | Medium | High | Critical | Total |
311
+ * | ----- | ------- | ---- | --- | ------ | ---- | -------- | ----- |
312
+ * | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 1 |
313
+ * | 2 | 0 | 0 | 9 | 20 | 10 | 0 | 39 |
314
+ * | 3 | 0 | 0 | 1 | 0 | 1 | 0 | 2 |
315
+ * | 4 | 0 | 0 | 5 | 5 | 0 | 0 | 10 |
316
+ * | ----- | ------- | ---- | --- | ------ | ---- | -------- | ----- |
317
+ * | Total | 0 | 0 | 15 | 26 | 11 | 0 | 52 |
318
+ * ```
319
+ */
320
+ TableGroupByRunPerSeverity = 9,
321
+ /**
322
+ * Table information about findings grouped by tool name with the level representation.
323
+ * @example
324
+ * ```text
325
+ * | | Unknown | None | Note | Warning | Error | Total |
326
+ * | ------ | ------- | ---- | ---- | ------- | ----- | ----- |
327
+ * | CodeQL | 0 | 0 | 0 | 1 | 0 | 1 |
328
+ * | grype | 0 | 0 | 9 | 20 | 10 | 39 |
329
+ * | Trivy | 0 | 0 | 1 | 0 | 1 | 2 |
330
+ * | WizCLI | 0 | 0 | 5 | 5 | 0 | 10 |
331
+ * | ------ | ------- | ---- | ---- | ------- | ----- | ----- |
332
+ * | Total | 0 | 0 | 15 | 26 | 11 | 52 |
333
+ * ```
334
+ */
335
+ TableGroupByToolNamePerLevel = 10,
336
+ /**
337
+ * Table information about findings grouped by tool name with the severity representation.
338
+ * @example
339
+ * ```text
340
+ * | | Unknown | None | Low | Medium | High | Critical | Total |
341
+ * | ------ | ------- | ---- | --- | ------ | ---- | -------- | ----- |
342
+ * | CodeQL | 0 | 0 | 0 | 1 | 0 | 0 | 1 |
343
+ * | grype | 0 | 0 | 9 | 20 | 10 | 0 | 39 |
344
+ * | Trivy | 0 | 0 | 1 | 0 | 1 | 0 | 2 |
345
+ * | WizCLI | 0 | 0 | 5 | 5 | 0 | 0 | 10 |
346
+ * | ------ | ------- | ---- | --- | ------ | ---- | -------- | ----- |
347
+ * | Total | 0 | 0 | 15 | 26 | 11 | 0 | 52 |
348
+ * ```
349
+ */
350
+ TableGroupByToolNamePerSeverity = 11,
351
+ /**
352
+ * Table information about findings grouped by SARIF file with the level representation.
353
+ * @example
354
+ * ```text
355
+ * | | Unknown | None | Note | Warning | Error | Total |
356
+ * | ----- | ------- | ---- | ---- | ------- | ----- | ----- |
357
+ * | 1 | 0 | 0 | 0 | 1 | 0 | 1 |
358
+ * | 2 | 0 | 0 | 9 | 20 | 10 | 39 |
359
+ * | ----- | ------- | ---- | ---- | ------- | ----- | ----- |
360
+ * | Total | 0 | 0 | 9 | 21 | 10 | 40 |
361
+ * ```
362
+ */
363
+ TableGroupBySarifPerLevel = 12,
364
+ /**
365
+ * Table information about findings grouped by SARIF file with the severity representation.
366
+ * @example
367
+ * ```text
368
+ * | | Unknown | None | Low | Medium | High | Critical | Total |
369
+ * | ----- | ------- | ---- | --- | ------ | ---- | -------- | ----- |
370
+ * | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 1 |
371
+ * | 2 | 0 | 0 | 9 | 20 | 10 | 0 | 39 |
372
+ * | ----- | ------- | ---- | --- | ------ | ---- | -------- | ----- |
373
+ * | Total | 0 | 0 | 9 | 21 | 10 | 0 | 40 |
374
+ * ```
375
+ */
376
+ TableGroupBySarifPerSeverity = 13
377
+ }
378
+
379
+ /**
380
+ * SARIF file extension.
381
+ * @public
382
+ */
383
+ export declare type SarifFileExtension = 'sarif' | 'json';
384
+
385
+ /**
386
+ * Represents options for the provided SARIF file(s), such as path, should files
387
+ * from this path be retrieved recursively or not, and file extension.
388
+ * @public
389
+ */
390
+ export declare type SarifOptions = {
391
+ path: string;
392
+ recursive?: boolean;
393
+ extension?: SarifFileExtension;
394
+ };
395
+
396
+ /**
397
+ * Service to convert SARIF files to Slack messages and send them.
398
+ * @public
399
+ */
400
+ export declare class SarifToSlackClient {
401
+ private readonly _logger;
402
+ private _message?;
403
+ private _sarifModel?;
404
+ private _sendIf;
405
+ private constructor();
406
+ private static createRunIdGenerator;
407
+ /**
408
+ * Creates an instance of {@link SarifToSlackClient} class. It already has all
409
+ * properties and fields initialized.
410
+ * @param webhookUrl - Slack webhook URL.
411
+ * @param opts - An instance of {@link SarifToSlackClientOptions} type.
412
+ *
413
+ * @see SarifToSlackClientOptions
414
+ *
415
+ * @public
416
+ */
417
+ static create(webhookUrl: string, opts: SarifToSlackClientOptions): Promise<SarifToSlackClient>;
418
+ private static buildModel;
419
+ /**
420
+ * Sends a Slack message.
421
+ * @returns A promise that resolves when the message has been sent.
422
+ * @throws Error if a Slack message was not prepared for the given SARIF path.
423
+ * @public
424
+ */
425
+ send(): Promise<void>;
426
+ private get shouldSendMessage();
427
+ }
428
+
429
+ /**
430
+ * Options for the SarifToSlackClient.
431
+ * @public
432
+ */
433
+ export declare type SarifToSlackClientOptions = {
434
+ sarif: SarifOptions;
435
+ username?: string;
436
+ iconUrl?: string;
437
+ color?: ColorOptions;
438
+ header?: IncludeAwareWithValueOptions;
439
+ footer?: FooterOptions;
440
+ actor?: IncludeAwareWithValueOptions;
441
+ run?: IncludeAwareOptions;
442
+ representation?: RepresentationType;
443
+ sendIf?: SendIf;
444
+ };
445
+
446
+ /**
447
+ * This enum represents the condition on when message should be sent. If this
448
+ * condition is satisfied then message is sent, otherwise - message is not sent.
449
+ * @public
450
+ */
451
+ export declare enum SendIf {
452
+ /**
453
+ * Send message only if there is at least one finding with "Critical" severity.
454
+ * Since it is the higher possible severity, it is the same as "Critical" or
455
+ * higher.
456
+ */
457
+ SeverityCritical = 0,
458
+ /**
459
+ * Send message only if there is at least one finding with "High" severity.
460
+ */
461
+ SeverityHigh = 1,
462
+ /**
463
+ * Send message only if there is at least one finding with "High" severity or
464
+ * higher, that includes "High" and "Critical".
465
+ */
466
+ SeverityHighOrHigher = 2,
467
+ /**
468
+ * Send message only if there is at least one finding with "Medium" severity.
469
+ */
470
+ SeverityMedium = 3,
471
+ /**
472
+ * Send message only if there is at least one finding with "Medium" severity
473
+ * or higher, that includes "Medium", "High" and "Critical".
474
+ */
475
+ SeverityMediumOrHigher = 4,
476
+ /**
477
+ * Send message only if there is at least one finding with "Low" severity.
478
+ */
479
+ SeverityLow = 5,
480
+ /**
481
+ * Send message only if there is at least one finding with "Low" severity or
482
+ * higher, that includes "Low", "Medium", "High" and "Critical".
483
+ */
484
+ SeverityLowOrHigher = 6,
485
+ /**
486
+ * Send message only if there is at least one finding with "None" severity.
487
+ */
488
+ SeverityNone = 7,
489
+ /**
490
+ * Send message only if there is at least one finding with "None" severity or
491
+ * higher, that includes "None", "Low", "Medium", "High" and "Critical".
492
+ */
493
+ SeverityNoneOrHigher = 8,
494
+ /**
495
+ * Send message only if there is at least one finding with "Unknown" severity.
496
+ */
497
+ SeverityUnknown = 9,
498
+ /**
499
+ * Send message only if there is at least one finding with "Unknown" severity
500
+ * or higher, that includes "Unknown", "None", "Low", "Medium", "High" and "Critical".
501
+ */
502
+ SeverityUnknownOrHigher = 10,
503
+ /**
504
+ * Send message only if there is at least one finding with "Error" level.
505
+ * Since it is the higher possible level, it is the same as "Error" or higher.
506
+ */
507
+ LevelError = 11,
508
+ /**
509
+ * Send message only if there is at least one finding with "Warning" level.
510
+ */
511
+ LevelWarning = 12,
512
+ /**
513
+ * Send message only if there is at least one finding with "Warning" level or
514
+ * higher, that includes "Warning" and "Error".
515
+ */
516
+ LevelWarningOrHigher = 13,
517
+ /**
518
+ * Send message only if there is at least one finding with "Note" level.
519
+ */
520
+ LevelNote = 14,
521
+ /**
522
+ * Send message only if there is at least one finding with "Note" level or
523
+ * higher, that includes "Note", "Warning" and "Error.
524
+ */
525
+ LevelNoteOrHigher = 15,
526
+ /**
527
+ * Send message only if there is at least one finding with "None" level.
528
+ */
529
+ LevelNone = 16,
530
+ /**
531
+ * Send message only if there is at least one finding with "None" level or
532
+ * higher, that includes "None", "Note", "Warning" and "Error.
533
+ */
534
+ LevelNoneOrHigher = 17,
535
+ /**
536
+ * Send message only if there is at least one finding with "Unknown" level.
537
+ */
538
+ LevelUnknown = 18,
539
+ /**
540
+ * Send message only if there is at least one finding with "Unknown" level or
541
+ * higher, that includes "Unknown", "None", "Note", "Warning" and "Error.
542
+ */
543
+ LevelUnknownOrHigher = 19,
544
+ /**
545
+ * Always send a message.
546
+ */
547
+ Always = 20,
548
+ /**
549
+ * Send a message if at least 1 vulnerability is found.
550
+ */
551
+ Some = 21,
552
+ /**
553
+ * Send a message only if no vulnerabilities are found.
554
+ */
555
+ Empty = 22,
556
+ /**
557
+ * Never send a message.
558
+ */
559
+ Never = 23
560
+ }
561
+
562
+ export { }
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.56.3"
8
+ "packageVersion": "7.58.1"
9
9
  }
10
10
  ]
11
11
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fabasoad/sarif-to-slack",
3
- "version": "1.3.4",
3
+ "version": "1.3.5",
4
4
  "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,20 +42,20 @@
42
42
  },
43
43
  "homepage": "https://github.com/fabasoad/sarif-to-slack#readme",
44
44
  "dependencies": {
45
- "@slack/webhook": "~7.0.7",
45
+ "@slack/webhook": "~7.0.8",
46
46
  "@types/sarif": "~2.1.7",
47
47
  "tslog": "~4.10.2",
48
48
  "zod": "~4.3.6"
49
49
  },
50
50
  "devDependencies": {
51
- "@biomejs/biome": "~2.3.15",
52
- "@microsoft/api-documenter": "~7.28.9",
53
- "@microsoft/api-extractor": "~7.56.3",
51
+ "@biomejs/biome": "~2.4.10",
52
+ "@microsoft/api-documenter": "~7.29.10",
53
+ "@microsoft/api-extractor": "~7.58.1",
54
54
  "@types/jest": "~30.0.0",
55
- "jest": "~30.2.0",
56
- "jest-circus": "~30.2.0",
57
- "ts-jest": "~29.4.6",
55
+ "jest": "~30.3.0",
56
+ "jest-circus": "~30.3.0",
57
+ "ts-jest": "~29.4.9",
58
58
  "tsup": "~8.5.1",
59
- "typescript": "~5.9.3"
59
+ "typescript": "~6.0.2"
60
60
  }
61
61
  }
package/tsconfig.json CHANGED
@@ -3,11 +3,9 @@
3
3
  "compilerOptions": {
4
4
  "allowSyntheticDefaultImports": true,
5
5
  "alwaysStrict": true,
6
- "baseUrl": ".",
7
6
  "declaration": true,
8
7
  "declarationDir": "dist",
9
8
  "declarationMap": true,
10
- "downlevelIteration": true,
11
9
  "emitDecoratorMetadata": true,
12
10
  "esModuleInterop": true,
13
11
  "experimentalDecorators": true,
@@ -15,7 +13,8 @@
15
13
  "inlineSourceMap": true,
16
14
  "lib": ["es2024"],
17
15
  "module": "es2022",
18
- "moduleResolution": "node",
16
+ "moduleResolution": "bundler",
17
+ "rootDir": "src",
19
18
  "newLine": "lf",
20
19
  "noFallthroughCasesInSwitch": true,
21
20
  "noImplicitAny": true,
@@ -1,562 +0,0 @@
1
- /**
2
- * Sarif to Slack message converter library.
3
- *
4
- * @remarks
5
- * This library provides a client to send a Slack messages based on the provided
6
- * SARIF (Static Analysis Results Interchange Format) files.
7
- *
8
- * @example
9
- * ```typescript
10
- * import {
11
- * Color,
12
- * FooterType,
13
- * RepresentationType,
14
- * SarifToSlackClient,
15
- * SendIf
16
- * } from '@fabasoad/sarif-to-slack';
17
- *
18
- * const client: SarifToSlackClient = await SarifToSlackClient.create({
19
- * webhookUrl: 'https://hooks.slack.com/services/your/webhook/url',
20
- * username: 'SARIF to Slack Bot',
21
- * iconUrl: 'https://example.com/icon.png',
22
- * color: {
23
- * default: new Color('failure'),
24
- * empty: new Color('success'),
25
- * bySeverity: {
26
- * critical: new Color('#ff0000'),
27
- * high: new Color('#ff4500'),
28
- * medium: new Color('#ffa500'),
29
- * low: new Color('#ffff00'),
30
- * none: new Color('#808080'),
31
- * unknown: new Color('#800080'),
32
- * },
33
- * byLevel: {
34
- * error: new Color('#ff0000'),
35
- * warning: new Color('#ffa500'),
36
- * note: new Color('#ffff00'),
37
- * none: new Color('#808080'),
38
- * unknown: new Color('#800080'),
39
- * },
40
- * },
41
- * sarif: {
42
- * path: 'path/to/your/sarif-files',
43
- * recursive: true,
44
- * extension: 'sarif',
45
- * },
46
- * header: {
47
- * include: true,
48
- * value: 'SARIF Analysis Results'
49
- * },
50
- * footer: {
51
- * include: true,
52
- * type: FooterType.PLAIN_TEXT,
53
- * value: 'Generated by @fabasoad/sarif-to-slack'
54
- * },
55
- * actor: {
56
- * include: true,
57
- * value: 'fabasoad'
58
- * },
59
- * run: {
60
- * include: true
61
- * },
62
- * representation: RepresentationType.CompactGroupByToolNamePerSeverity,
63
- * sendIf: SendIf.MediumOrHigher,
64
- * });
65
- * await client.send();
66
- * ```
67
- *
68
- * @see {@link SarifToSlackClient}
69
- *
70
- * @packageDocumentation
71
- */
72
-
73
- /**
74
- * This class represents a color in hex format.
75
- * @public
76
- */
77
- export declare class Color {
78
- /**
79
- * A valid string that represents a color in hex format.
80
- * @public
81
- */
82
- readonly color: string;
83
- private constructor();
84
- /**
85
- * Creates an instance of {@link Color} class. Before creating an instance of
86
- * {@link Color} class, it (if applicable) maps CI status into the hex color,
87
- * and also validates color parameter to be a valid string that represents a
88
- * color in hex format.
89
- * @param color - Can be either undefined, valid color in hex format or GitHub
90
- * CI status (one of: success, failure, cancelled, skipped).
91
- * @returns An instance of {@link Color} or undefined if color parameter is falsy.
92
- * @public
93
- */
94
- static from(color: string | undefined): Color | undefined;
95
- private assertHexColor;
96
- private mapColor;
97
- }
98
-
99
- /**
100
- * Color schema for the findings with the certain level. Color is used by the
101
- * level importance, i.e. if at least 1 error finding exists then
102
- * {@link ColorGroupByLevel#error} color is used, then if at least 1 warning
103
- * finding exists then {@link ColorGroupByLevel#warning} color is used, etc.
104
- * @public
105
- */
106
- export declare type ColorGroupByLevel = ColorGroupCommon & {
107
- error?: Color;
108
- warning?: Color;
109
- note?: Color;
110
- };
111
-
112
- /**
113
- * Color schema for the findings with the certain severity. Color is used by the
114
- * severity importance, i.e. if at least 1 critical finding exists then
115
- * {@link ColorGroupBySeverity#critical} color is used, then if at least 1 high
116
- * finding exists then {@link ColorGroupBySeverity#high} color is used, etc.
117
- * @public
118
- */
119
- export declare type ColorGroupBySeverity = ColorGroupCommon & {
120
- critical?: Color;
121
- high?: Color;
122
- medium?: Color;
123
- low?: Color;
124
- };
125
-
126
- /**
127
- * Base type that has common fields for both {@link ColorGroupByLevel} and
128
- * {@link ColorGroupBySeverity}.
129
- * @public
130
- */
131
- export declare type ColorGroupCommon = {
132
- none?: Color;
133
- unknown?: Color;
134
- };
135
-
136
- /**
137
- * Represents configuration of the color scheme. If both {@link ColorOptions#byLevel}
138
- * and {@link ColorOptions#bySeverity} are defined, then {@link ColorOptions#bySeverity}
139
- * takes precedence.
140
- * @public
141
- */
142
- export declare type ColorOptions = {
143
- /**
144
- * Default color if specific color was not found. It is a fallback option.
145
- */
146
- default?: Color;
147
- /**
148
- * Color scheme for the findings where certain level is presented.
149
- */
150
- byLevel?: ColorGroupByLevel;
151
- /**
152
- * Color scheme for the findings where certain severity is presented.
153
- */
154
- bySeverity?: ColorGroupBySeverity;
155
- /**
156
- * Color when no findings are found.
157
- */
158
- empty?: Color;
159
- };
160
-
161
- /**
162
- * Options for the footer of a Slack message. "type" is ignored if "value" is
163
- * not defined.
164
- * @public
165
- */
166
- export declare type FooterOptions = IncludeAwareWithValueOptions & {
167
- type?: FooterType;
168
- };
169
-
170
- /**
171
- * Enum representing the type of footer in a Slack message.
172
- * @public
173
- */
174
- export declare enum FooterType {
175
- /**
176
- * Represents a plain text footer. Text is not formatted and appears as-is.
177
- */
178
- PlainText = "plain_text",
179
- /**
180
- * Represents a footer with Markdown formatting. Text can include formatting
181
- * such as bold, italics, and links.
182
- */
183
- Markdown = "mrkdwn"
184
- }
185
-
186
- /**
187
- * Type representing properties that indicate whether to include certain information
188
- * in the Slack message.
189
- * @public
190
- */
191
- export declare type IncludeAwareOptions = {
192
- include: boolean;
193
- };
194
-
195
- /**
196
- * Type representing properties that indicate whether to include certain information
197
- * in the Slack message, along with an optional value.
198
- * @public
199
- */
200
- export declare type IncludeAwareWithValueOptions = IncludeAwareOptions & {
201
- value?: string;
202
- };
203
-
204
- /**
205
- * This represents what type of message should be sent. There are various options
206
- * to show information from SARIF in Slack message.
207
- * @public
208
- */
209
- export declare enum RepresentationType {
210
- /**
211
- * Compact information about findings grouped by Run with the level representation.
212
- * @example
213
- * ```text
214
- * [Run 1] Grype
215
- * Error: 1, Warning: 4
216
- * [Run 2] Grype
217
- * Warning: 1, Note: 20
218
- * ```
219
- */
220
- CompactGroupByRunPerLevel = 0,
221
- /**
222
- * Compact information about findings grouped by Run with the severity representation.
223
- * @example
224
- * ```text
225
- * [Run 1] Grype
226
- * Critical: 1, High: 3, Medium: 1
227
- * [Run 2] Grype
228
- * Medium: 1, Low: 20
229
- * ```
230
- */
231
- CompactGroupByRunPerSeverity = 1,
232
- /**
233
- * Compact information about findings grouped by tool name with the level representation.
234
- * @example
235
- * ```text
236
- * Grype
237
- * Error: 1, Warning: 5, Note: 20
238
- * ```
239
- */
240
- CompactGroupByToolNamePerLevel = 2,
241
- /**
242
- * Compact information about findings grouped by tool name with the severity representation.
243
- * @example
244
- * ```text
245
- * Grype
246
- * Critical: 1, High: 3, Medium: 2, Low: 20
247
- * ```
248
- */
249
- CompactGroupByToolNamePerSeverity = 3,
250
- /**
251
- * Compact information about findings grouped by SARIF file with the level representation.
252
- * @example
253
- * ```text
254
- * grype-results-01.sarif
255
- * Error: 1, Warning: 2, Note: 1
256
- * grype-results-02.sarif
257
- * Warning: 3, Note: 19
258
- * ```
259
- */
260
- CompactGroupBySarifPerLevel = 4,
261
- /**
262
- * Compact information about findings grouped by SARIF file with the severity
263
- * representation.
264
- * @example
265
- * ```text
266
- * grype-results-01.sarif
267
- * High: 3, Medium: 1, Low: 11
268
- * grype-results-02.sarif
269
- * Critical: 1, Medium: 1, Low: 9
270
- * ```
271
- */
272
- CompactGroupBySarifPerSeverity = 5,
273
- /**
274
- * Compact information about findings with the level representation.
275
- * @example
276
- * ```text
277
- * Total
278
- * Error: 1, Warning: 5, Note: 20
279
- * ```
280
- */
281
- CompactTotalPerLevel = 6,
282
- /**
283
- * Compact information about findings with the severity representation.
284
- * @example
285
- * ```text
286
- * Total
287
- * Critical: 1, High: 3, Medium: 2, Low: 20
288
- * ```
289
- */
290
- CompactTotalPerSeverity = 7,
291
- /**
292
- * Table information about findings grouped by Run with the level representation.
293
- * @example
294
- * ```text
295
- * | | Unknown | None | Note | Warning | Error | Total |
296
- * | ----- | ------- | ---- | ---- | ------- | ----- | ----- |
297
- * | 1 | 0 | 0 | 0 | 1 | 0 | 1 |
298
- * | 2 | 0 | 0 | 9 | 20 | 10 | 39 |
299
- * | 3 | 0 | 0 | 1 | 0 | 1 | 2 |
300
- * | 4 | 0 | 0 | 5 | 5 | 0 | 10 |
301
- * | ----- | ------- | ---- | ---- | ------- | ----- | ----- |
302
- * | Total | 0 | 0 | 15 | 26 | 11 | 52 |
303
- * ```
304
- */
305
- TableGroupByRunPerLevel = 8,
306
- /**
307
- * Table information about findings grouped by Run with the severity representation.
308
- * @example
309
- * ```text
310
- * | | Unknown | None | Low | Medium | High | Critical | Total |
311
- * | ----- | ------- | ---- | --- | ------ | ---- | -------- | ----- |
312
- * | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 1 |
313
- * | 2 | 0 | 0 | 9 | 20 | 10 | 0 | 39 |
314
- * | 3 | 0 | 0 | 1 | 0 | 1 | 0 | 2 |
315
- * | 4 | 0 | 0 | 5 | 5 | 0 | 0 | 10 |
316
- * | ----- | ------- | ---- | --- | ------ | ---- | -------- | ----- |
317
- * | Total | 0 | 0 | 15 | 26 | 11 | 0 | 52 |
318
- * ```
319
- */
320
- TableGroupByRunPerSeverity = 9,
321
- /**
322
- * Table information about findings grouped by tool name with the level representation.
323
- * @example
324
- * ```text
325
- * | | Unknown | None | Note | Warning | Error | Total |
326
- * | ------ | ------- | ---- | ---- | ------- | ----- | ----- |
327
- * | CodeQL | 0 | 0 | 0 | 1 | 0 | 1 |
328
- * | grype | 0 | 0 | 9 | 20 | 10 | 39 |
329
- * | Trivy | 0 | 0 | 1 | 0 | 1 | 2 |
330
- * | WizCLI | 0 | 0 | 5 | 5 | 0 | 10 |
331
- * | ------ | ------- | ---- | ---- | ------- | ----- | ----- |
332
- * | Total | 0 | 0 | 15 | 26 | 11 | 52 |
333
- * ```
334
- */
335
- TableGroupByToolNamePerLevel = 10,
336
- /**
337
- * Table information about findings grouped by tool name with the severity representation.
338
- * @example
339
- * ```text
340
- * | | Unknown | None | Low | Medium | High | Critical | Total |
341
- * | ------ | ------- | ---- | --- | ------ | ---- | -------- | ----- |
342
- * | CodeQL | 0 | 0 | 0 | 1 | 0 | 0 | 1 |
343
- * | grype | 0 | 0 | 9 | 20 | 10 | 0 | 39 |
344
- * | Trivy | 0 | 0 | 1 | 0 | 1 | 0 | 2 |
345
- * | WizCLI | 0 | 0 | 5 | 5 | 0 | 0 | 10 |
346
- * | ------ | ------- | ---- | --- | ------ | ---- | -------- | ----- |
347
- * | Total | 0 | 0 | 15 | 26 | 11 | 0 | 52 |
348
- * ```
349
- */
350
- TableGroupByToolNamePerSeverity = 11,
351
- /**
352
- * Table information about findings grouped by SARIF file with the level representation.
353
- * @example
354
- * ```text
355
- * | | Unknown | None | Note | Warning | Error | Total |
356
- * | ----- | ------- | ---- | ---- | ------- | ----- | ----- |
357
- * | 1 | 0 | 0 | 0 | 1 | 0 | 1 |
358
- * | 2 | 0 | 0 | 9 | 20 | 10 | 39 |
359
- * | ----- | ------- | ---- | ---- | ------- | ----- | ----- |
360
- * | Total | 0 | 0 | 9 | 21 | 10 | 40 |
361
- * ```
362
- */
363
- TableGroupBySarifPerLevel = 12,
364
- /**
365
- * Table information about findings grouped by SARIF file with the severity representation.
366
- * @example
367
- * ```text
368
- * | | Unknown | None | Low | Medium | High | Critical | Total |
369
- * | ----- | ------- | ---- | --- | ------ | ---- | -------- | ----- |
370
- * | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 1 |
371
- * | 2 | 0 | 0 | 9 | 20 | 10 | 0 | 39 |
372
- * | ----- | ------- | ---- | --- | ------ | ---- | -------- | ----- |
373
- * | Total | 0 | 0 | 9 | 21 | 10 | 0 | 40 |
374
- * ```
375
- */
376
- TableGroupBySarifPerSeverity = 13
377
- }
378
-
379
- /**
380
- * SARIF file extension.
381
- * @public
382
- */
383
- export declare type SarifFileExtension = 'sarif' | 'json';
384
-
385
- /**
386
- * Represents options for the provided SARIF file(s), such as path, should files
387
- * from this path be retrieved recursively or not, and file extension.
388
- * @public
389
- */
390
- export declare type SarifOptions = {
391
- path: string;
392
- recursive?: boolean;
393
- extension?: SarifFileExtension;
394
- };
395
-
396
- /**
397
- * Service to convert SARIF files to Slack messages and send them.
398
- * @public
399
- */
400
- export declare class SarifToSlackClient {
401
- private readonly _logger;
402
- private _message?;
403
- private _sarifModel?;
404
- private _sendIf;
405
- private constructor();
406
- private static createRunIdGenerator;
407
- /**
408
- * Creates an instance of {@link SarifToSlackClient} class. It already has all
409
- * properties and fields initialized.
410
- * @param webhookUrl - Slack webhook URL.
411
- * @param opts - An instance of {@link SarifToSlackClientOptions} type.
412
- *
413
- * @see SarifToSlackClientOptions
414
- *
415
- * @public
416
- */
417
- static create(webhookUrl: string, opts: SarifToSlackClientOptions): Promise<SarifToSlackClient>;
418
- private static buildModel;
419
- /**
420
- * Sends a Slack message.
421
- * @returns A promise that resolves when the message has been sent.
422
- * @throws Error if a Slack message was not prepared for the given SARIF path.
423
- * @public
424
- */
425
- send(): Promise<void>;
426
- private get shouldSendMessage();
427
- }
428
-
429
- /**
430
- * Options for the SarifToSlackClient.
431
- * @public
432
- */
433
- export declare type SarifToSlackClientOptions = {
434
- sarif: SarifOptions;
435
- username?: string;
436
- iconUrl?: string;
437
- color?: ColorOptions;
438
- header?: IncludeAwareWithValueOptions;
439
- footer?: FooterOptions;
440
- actor?: IncludeAwareWithValueOptions;
441
- run?: IncludeAwareOptions;
442
- representation?: RepresentationType;
443
- sendIf?: SendIf;
444
- };
445
-
446
- /**
447
- * This enum represents the condition on when message should be sent. If this
448
- * condition is satisfied then message is sent, otherwise - message is not sent.
449
- * @public
450
- */
451
- export declare enum SendIf {
452
- /**
453
- * Send message only if there is at least one finding with "Critical" severity.
454
- * Since it is the higher possible severity, it is the same as "Critical" or
455
- * higher.
456
- */
457
- SeverityCritical = 0,
458
- /**
459
- * Send message only if there is at least one finding with "High" severity.
460
- */
461
- SeverityHigh = 1,
462
- /**
463
- * Send message only if there is at least one finding with "High" severity or
464
- * higher, that includes "High" and "Critical".
465
- */
466
- SeverityHighOrHigher = 2,
467
- /**
468
- * Send message only if there is at least one finding with "Medium" severity.
469
- */
470
- SeverityMedium = 3,
471
- /**
472
- * Send message only if there is at least one finding with "Medium" severity
473
- * or higher, that includes "Medium", "High" and "Critical".
474
- */
475
- SeverityMediumOrHigher = 4,
476
- /**
477
- * Send message only if there is at least one finding with "Low" severity.
478
- */
479
- SeverityLow = 5,
480
- /**
481
- * Send message only if there is at least one finding with "Low" severity or
482
- * higher, that includes "Low", "Medium", "High" and "Critical".
483
- */
484
- SeverityLowOrHigher = 6,
485
- /**
486
- * Send message only if there is at least one finding with "None" severity.
487
- */
488
- SeverityNone = 7,
489
- /**
490
- * Send message only if there is at least one finding with "None" severity or
491
- * higher, that includes "None", "Low", "Medium", "High" and "Critical".
492
- */
493
- SeverityNoneOrHigher = 8,
494
- /**
495
- * Send message only if there is at least one finding with "Unknown" severity.
496
- */
497
- SeverityUnknown = 9,
498
- /**
499
- * Send message only if there is at least one finding with "Unknown" severity
500
- * or higher, that includes "Unknown", "None", "Low", "Medium", "High" and "Critical".
501
- */
502
- SeverityUnknownOrHigher = 10,
503
- /**
504
- * Send message only if there is at least one finding with "Error" level.
505
- * Since it is the higher possible level, it is the same as "Error" or higher.
506
- */
507
- LevelError = 11,
508
- /**
509
- * Send message only if there is at least one finding with "Warning" level.
510
- */
511
- LevelWarning = 12,
512
- /**
513
- * Send message only if there is at least one finding with "Warning" level or
514
- * higher, that includes "Warning" and "Error".
515
- */
516
- LevelWarningOrHigher = 13,
517
- /**
518
- * Send message only if there is at least one finding with "Note" level.
519
- */
520
- LevelNote = 14,
521
- /**
522
- * Send message only if there is at least one finding with "Note" level or
523
- * higher, that includes "Note", "Warning" and "Error.
524
- */
525
- LevelNoteOrHigher = 15,
526
- /**
527
- * Send message only if there is at least one finding with "None" level.
528
- */
529
- LevelNone = 16,
530
- /**
531
- * Send message only if there is at least one finding with "None" level or
532
- * higher, that includes "None", "Note", "Warning" and "Error.
533
- */
534
- LevelNoneOrHigher = 17,
535
- /**
536
- * Send message only if there is at least one finding with "Unknown" level.
537
- */
538
- LevelUnknown = 18,
539
- /**
540
- * Send message only if there is at least one finding with "Unknown" level or
541
- * higher, that includes "Unknown", "None", "Note", "Warning" and "Error.
542
- */
543
- LevelUnknownOrHigher = 19,
544
- /**
545
- * Always send a message.
546
- */
547
- Always = 20,
548
- /**
549
- * Send a message if at least 1 vulnerability is found.
550
- */
551
- Some = 21,
552
- /**
553
- * Send a message only if no vulnerabilities are found.
554
- */
555
- Empty = 22,
556
- /**
557
- * Never send a message.
558
- */
559
- Never = 23
560
- }
561
-
562
- export { }