@fabasoad/sarif-to-slack 1.3.4 → 1.4.0
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/.github/workflows/release.yml +1 -1
- package/.github/workflows/security.yml +1 -0
- package/.github/workflows/send-sarif-to-slack.yml +39 -15
- package/.pre-commit-config.yaml +4 -4
- package/.tool-versions +1 -1
- package/Makefile +1 -1
- package/README.md +8 -7
- package/api-extractor.json +2 -2
- package/dist/Logger.js +40 -30
- package/dist/SarifToSlackClient.d.ts +0 -1
- package/dist/SarifToSlackClient.d.ts.map +1 -1
- package/dist/SarifToSlackClient.js +11 -8
- package/dist/globalState.d.ts +2 -0
- package/dist/globalState.d.ts.map +1 -0
- package/dist/globalState.js +2 -0
- package/dist/index.cjs +118 -81
- package/dist/index.d.ts +529 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -2
- package/dist/model/Finding.js +7 -5
- package/dist/model/FindingArray.js +1 -1
- package/dist/model/SendIf.js +1 -1
- package/dist/model/SlackMessage.js +6 -6
- package/dist/model/color/Color.d.ts.map +1 -1
- package/dist/model/color/Color.js +1 -1
- package/dist/model/color/ColorIdentification.js +5 -5
- package/dist/model/color/ColorOptions.d.ts.map +1 -1
- package/dist/processors/CodeQLProcessor.js +1 -1
- package/dist/processors/CommonProcessor.js +1 -1
- package/dist/processors/ProcessorFactory.js +1 -1
- package/dist/processors/SnykProcessor.js +2 -1
- package/dist/representations/CompactGroupByRepresentation.js +1 -1
- package/dist/representations/CompactGroupByRunPerLevelRepresentation.js +1 -1
- package/dist/representations/CompactGroupByRunPerSeverityRepresentation.js +1 -1
- package/dist/representations/CompactGroupByRunRepresentation.js +1 -1
- package/dist/representations/CompactGroupBySarifPerLevelRepresentation.js +1 -1
- package/dist/representations/CompactGroupBySarifPerSeverityRepresentation.js +1 -1
- package/dist/representations/CompactGroupBySarifRepresentation.js +1 -1
- package/dist/representations/CompactGroupByToolNamePerLevelRepresentation.js +1 -1
- package/dist/representations/CompactGroupByToolNamePerSeverityRepresentation.js +1 -1
- package/dist/representations/CompactGroupByToolNameRepresentation.js +1 -1
- package/dist/representations/CompactTotalPerLevelRepresentation.js +1 -1
- package/dist/representations/CompactTotalPerSeverityRepresentation.js +1 -1
- package/dist/representations/CompactTotalRepresentation.js +1 -1
- package/dist/representations/Representation.js +1 -1
- package/dist/representations/RepresentationFactory.js +1 -1
- package/dist/representations/TableGroupByRunPerLevelRepresentation.d.ts.map +1 -1
- package/dist/representations/TableGroupByRunPerLevelRepresentation.js +1 -1
- package/dist/representations/TableGroupByRunPerSeverityRepresentation.d.ts.map +1 -1
- package/dist/representations/TableGroupByRunPerSeverityRepresentation.js +1 -1
- package/dist/representations/TableGroupByRunRepresentation.d.ts.map +1 -1
- package/dist/representations/TableGroupByRunRepresentation.js +1 -1
- package/dist/representations/TableGroupBySarifPerLevelRepresentation.d.ts.map +1 -1
- package/dist/representations/TableGroupBySarifPerLevelRepresentation.js +1 -1
- package/dist/representations/TableGroupBySarifPerSeverityRepresentation.d.ts.map +1 -1
- package/dist/representations/TableGroupBySarifPerSeverityRepresentation.js +1 -1
- package/dist/representations/TableGroupBySarifRepresentation.d.ts.map +1 -1
- package/dist/representations/TableGroupBySarifRepresentation.js +1 -1
- package/dist/representations/TableGroupByToolNamePerLevelRepresentation.d.ts.map +1 -1
- package/dist/representations/TableGroupByToolNamePerLevelRepresentation.js +1 -1
- package/dist/representations/TableGroupByToolNamePerSeverityRepresentation.d.ts.map +1 -1
- package/dist/representations/TableGroupByToolNamePerSeverityRepresentation.js +1 -1
- package/dist/representations/TableGroupByToolNameRepresentation.d.ts.map +1 -1
- package/dist/representations/TableGroupByToolNameRepresentation.js +1 -1
- package/dist/representations/TableGroupRepresentation.d.ts +0 -1
- package/dist/representations/TableGroupRepresentation.d.ts.map +1 -1
- package/dist/representations/TableGroupRepresentation.js +3 -3
- package/dist/representations/table/Cell.d.ts.map +1 -1
- package/dist/representations/table/Cell.js +1 -1
- package/dist/representations/table/Column.d.ts +0 -1
- package/dist/representations/table/Column.d.ts.map +1 -1
- package/dist/representations/table/Column.js +4 -3
- package/dist/representations/table/Row.d.ts +0 -1
- package/dist/representations/table/Row.d.ts.map +1 -1
- package/dist/representations/table/Row.js +3 -3
- package/dist/representations/table/Table.d.ts.map +1 -1
- package/dist/representations/table/Table.js +1 -1
- package/dist/system.js +5 -5
- package/dist/tsdoc-metadata.json +1 -1
- package/dist/types.d.ts +29 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +11 -1
- package/dist/utils/Comparators.js +1 -1
- package/dist/utils/ExtendedArray.js +1 -1
- package/dist/utils/FileUtils.js +2 -2
- package/dist/utils/SarifUtils.js +1 -1
- package/dist/utils/StringUtils.js +1 -1
- package/etc/sarif-to-slack.api.md +21 -1
- package/jest.config.json +4 -4
- package/package.json +10 -9
- package/src/Logger.ts +50 -34
- package/src/SarifToSlackClient.ts +73 -68
- package/src/globalState.ts +11 -0
- package/src/index.ts +23 -12
- package/src/model/Finding.ts +36 -35
- package/src/model/FindingArray.ts +5 -5
- package/src/model/SendIf.ts +25 -25
- package/src/model/SlackMessage.ts +49 -49
- package/src/model/color/Color.ts +7 -7
- package/src/model/color/ColorIdentification.ts +77 -77
- package/src/model/color/ColorOptions.ts +1 -1
- package/src/processors/CodeQLProcessor.ts +3 -3
- package/src/processors/CommonProcessor.ts +24 -24
- package/src/processors/ProcessorFactory.ts +9 -9
- package/src/processors/SnykProcessor.ts +3 -2
- package/src/representations/CompactGroupByRepresentation.ts +20 -20
- package/src/representations/CompactGroupByRunPerLevelRepresentation.ts +2 -2
- package/src/representations/CompactGroupByRunPerSeverityRepresentation.ts +2 -2
- package/src/representations/CompactGroupByRunRepresentation.ts +10 -10
- package/src/representations/CompactGroupBySarifPerLevelRepresentation.ts +2 -2
- package/src/representations/CompactGroupBySarifPerSeverityRepresentation.ts +2 -2
- package/src/representations/CompactGroupBySarifRepresentation.ts +11 -11
- package/src/representations/CompactGroupByToolNamePerLevelRepresentation.ts +2 -2
- package/src/representations/CompactGroupByToolNamePerSeverityRepresentation.ts +2 -2
- package/src/representations/CompactGroupByToolNameRepresentation.ts +10 -10
- package/src/representations/CompactTotalPerLevelRepresentation.ts +2 -2
- package/src/representations/CompactTotalPerSeverityRepresentation.ts +2 -2
- package/src/representations/CompactTotalRepresentation.ts +5 -5
- package/src/representations/Representation.ts +8 -8
- package/src/representations/RepresentationFactory.ts +32 -32
- package/src/representations/TableGroupByRunPerLevelRepresentation.ts +3 -3
- package/src/representations/TableGroupByRunPerSeverityRepresentation.ts +3 -3
- package/src/representations/TableGroupByRunRepresentation.ts +5 -5
- package/src/representations/TableGroupBySarifPerLevelRepresentation.ts +3 -3
- package/src/representations/TableGroupBySarifPerSeverityRepresentation.ts +3 -3
- package/src/representations/TableGroupBySarifRepresentation.ts +9 -9
- package/src/representations/TableGroupByToolNamePerLevelRepresentation.ts +3 -3
- package/src/representations/TableGroupByToolNamePerSeverityRepresentation.ts +3 -3
- package/src/representations/TableGroupByToolNameRepresentation.ts +4 -4
- package/src/representations/TableGroupRepresentation.ts +32 -32
- package/src/representations/table/Cell.ts +8 -8
- package/src/representations/table/Column.ts +13 -13
- package/src/representations/table/Row.ts +17 -17
- package/src/representations/table/Table.ts +21 -21
- package/src/system.ts +5 -5
- package/src/types.ts +43 -13
- package/src/utils/Comparators.ts +6 -6
- package/src/utils/ExtendedArray.ts +1 -1
- package/src/utils/FileUtils.ts +3 -3
- package/src/utils/SarifUtils.ts +6 -6
- package/src/utils/StringUtils.ts +3 -3
- package/tests/integration/SendSarifToSlack.spec.ts +73 -67
- package/tests/representations/CompactGroupByRunPerLevelRepresentation.spec.ts +121 -0
- package/tests/representations/CompactGroupByRunPerSeverityRepresentation.spec.ts +122 -0
- package/tests/representations/CompactGroupBySarifPerLevelRepresentation.spec.ts +132 -0
- package/tests/representations/CompactGroupBySarifPerSeverityRepresentation.spec.ts +133 -0
- package/tsconfig.json +3 -4
- package/dist/sarif-to-slack.d.ts +0 -562
package/dist/sarif-to-slack.d.ts
DELETED
|
@@ -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 { }
|