@fabasoad/sarif-to-slack 0.2.5 → 1.0.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 +0 -1
- package/.github/workflows/send-sarif-to-slack.yml +145 -73
- package/.gitleaksignore +8 -0
- package/.pre-commit-config.yaml +3 -3
- package/.tool-versions +1 -1
- package/dist/Logger.js +4 -1
- package/dist/SarifToSlackClient.d.ts +33 -0
- package/dist/SarifToSlackClient.d.ts.map +1 -0
- package/dist/SarifToSlackClient.js +178 -0
- package/dist/SlackMessageBuilder.js +34 -82
- package/dist/System.d.ts +1 -3
- package/dist/System.d.ts.map +1 -1
- package/dist/System.js +10 -3
- package/dist/index.cjs +840 -472
- package/dist/index.d.ts +35 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +36 -12
- package/dist/model/Color.d.ts +70 -0
- package/dist/model/Color.d.ts.map +1 -0
- package/dist/model/Color.js +119 -0
- package/dist/model/Finding.d.ts +2 -0
- package/dist/model/Finding.d.ts.map +1 -0
- package/dist/model/Finding.js +93 -0
- package/dist/model/FindingsArray.d.ts +2 -0
- package/dist/model/FindingsArray.d.ts.map +1 -0
- package/dist/model/FindingsArray.js +24 -0
- package/dist/processors/CodeQLProcessor.d.ts +2 -0
- package/dist/processors/CodeQLProcessor.d.ts.map +1 -0
- package/dist/processors/CodeQLProcessor.js +17 -0
- package/dist/processors/CommonProcessor.d.ts +2 -0
- package/dist/processors/CommonProcessor.d.ts.map +1 -0
- package/dist/processors/CommonProcessor.js +84 -0
- package/dist/processors/ProcessorFactory.d.ts +2 -0
- package/dist/processors/ProcessorFactory.d.ts.map +1 -0
- package/dist/processors/ProcessorFactory.js +22 -0
- package/dist/processors/SnykProcessor.d.ts +2 -0
- package/dist/processors/SnykProcessor.d.ts.map +1 -0
- package/dist/processors/SnykProcessor.js +18 -0
- package/dist/representations/CompactGroupByRepresentation.d.ts +2 -0
- package/dist/representations/CompactGroupByRepresentation.d.ts.map +1 -0
- package/dist/representations/CompactGroupByRepresentation.js +58 -0
- package/dist/representations/CompactGroupByRunPerLevelRepresentation.d.ts +2 -0
- package/dist/representations/CompactGroupByRunPerLevelRepresentation.d.ts.map +1 -0
- package/dist/representations/CompactGroupByRunPerLevelRepresentation.js +13 -0
- package/dist/representations/CompactGroupByRunPerSeverityRepresentation.d.ts +2 -0
- package/dist/representations/CompactGroupByRunPerSeverityRepresentation.d.ts.map +1 -0
- package/dist/representations/CompactGroupByRunPerSeverityRepresentation.js +13 -0
- package/dist/representations/CompactGroupByRunRepresentation.d.ts +2 -0
- package/dist/representations/CompactGroupByRunRepresentation.d.ts.map +1 -0
- package/dist/representations/CompactGroupByRunRepresentation.js +39 -0
- package/dist/representations/CompactGroupBySarifPerLevelRepresentation.d.ts +2 -0
- package/dist/representations/CompactGroupBySarifPerLevelRepresentation.d.ts.map +1 -0
- package/dist/representations/CompactGroupBySarifPerLevelRepresentation.js +13 -0
- package/dist/representations/CompactGroupBySarifPerSeverityRepresentation.d.ts +2 -0
- package/dist/representations/CompactGroupBySarifPerSeverityRepresentation.d.ts.map +1 -0
- package/dist/representations/CompactGroupBySarifPerSeverityRepresentation.js +13 -0
- package/dist/representations/CompactGroupBySarifRepresentation.d.ts +2 -0
- package/dist/representations/CompactGroupBySarifRepresentation.d.ts.map +1 -0
- package/dist/representations/CompactGroupBySarifRepresentation.js +40 -0
- package/dist/representations/CompactGroupByToolNamePerLevelRepresentation.d.ts +2 -0
- package/dist/representations/CompactGroupByToolNamePerLevelRepresentation.d.ts.map +1 -0
- package/dist/representations/CompactGroupByToolNamePerLevelRepresentation.js +13 -0
- package/dist/representations/CompactGroupByToolNamePerSeverityRepresentation.d.ts +2 -0
- package/dist/representations/CompactGroupByToolNamePerSeverityRepresentation.d.ts.map +1 -0
- package/dist/representations/CompactGroupByToolNamePerSeverityRepresentation.js +13 -0
- package/dist/representations/CompactGroupByToolNameRepresentation.d.ts +2 -0
- package/dist/representations/CompactGroupByToolNameRepresentation.d.ts.map +1 -0
- package/dist/representations/CompactGroupByToolNameRepresentation.js +39 -0
- package/dist/representations/CompactTotalPerLevelRepresentation.d.ts +2 -0
- package/dist/representations/CompactTotalPerLevelRepresentation.d.ts.map +1 -0
- package/dist/representations/CompactTotalPerLevelRepresentation.js +13 -0
- package/dist/representations/CompactTotalPerSeverityRepresentation.d.ts +2 -0
- package/dist/representations/CompactTotalPerSeverityRepresentation.d.ts.map +1 -0
- package/dist/representations/CompactTotalPerSeverityRepresentation.js +13 -0
- package/dist/representations/CompactTotalRepresentation.d.ts +2 -0
- package/dist/representations/CompactTotalRepresentation.d.ts.map +1 -0
- package/dist/representations/CompactTotalRepresentation.js +25 -0
- package/dist/representations/Representation.d.ts +2 -0
- package/dist/representations/Representation.d.ts.map +1 -0
- package/dist/representations/Representation.js +28 -0
- package/dist/representations/RepresentationFactory.d.ts +2 -0
- package/dist/representations/RepresentationFactory.d.ts.map +1 -0
- package/dist/representations/RepresentationFactory.js +37 -0
- package/dist/sarif-to-slack.d.ts +337 -85
- package/dist/tsdoc-metadata.json +1 -1
- package/dist/types.d.ts +215 -51
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +225 -33
- package/dist/utils/Comparators.d.ts +2 -0
- package/dist/utils/Comparators.d.ts.map +1 -0
- package/dist/utils/Comparators.js +18 -0
- package/dist/utils/ExtendedArray.d.ts +2 -0
- package/dist/utils/ExtendedArray.d.ts.map +1 -0
- package/dist/utils/ExtendedArray.js +11 -0
- package/dist/utils/FileUtils.d.ts +2 -0
- package/dist/utils/FileUtils.d.ts.map +1 -0
- package/dist/utils/FileUtils.js +51 -0
- package/dist/utils/SarifUtils.js +20 -54
- package/etc/sarif-to-slack.api.md +161 -99
- package/jest.config.json +2 -2
- package/package.json +7 -7
- package/scripts/save-metadata.sh +12 -10
- package/src/Logger.ts +4 -0
- package/src/SarifToSlackClient.ts +202 -0
- package/src/SlackMessageBuilder.ts +35 -115
- package/src/System.ts +9 -2
- package/src/index.ts +47 -20
- package/src/model/Color.ts +201 -0
- package/src/model/Finding.ts +137 -0
- package/src/model/FindingsArray.ts +27 -0
- package/src/processors/CodeQLProcessor.ts +19 -0
- package/src/processors/CommonProcessor.ts +103 -0
- package/src/processors/ProcessorFactory.ts +23 -0
- package/src/processors/SnykProcessor.ts +19 -0
- package/src/representations/CompactGroupByRepresentation.ts +67 -0
- package/src/representations/CompactGroupByRunPerLevelRepresentation.ts +14 -0
- package/src/representations/CompactGroupByRunPerSeverityRepresentation.ts +14 -0
- package/src/representations/CompactGroupByRunRepresentation.ts +44 -0
- package/src/representations/CompactGroupBySarifPerLevelRepresentation.ts +15 -0
- package/src/representations/CompactGroupBySarifPerSeverityRepresentation.ts +15 -0
- package/src/representations/CompactGroupBySarifRepresentation.ts +45 -0
- package/src/representations/CompactGroupByToolNamePerLevelRepresentation.ts +15 -0
- package/src/representations/CompactGroupByToolNamePerSeverityRepresentation.ts +15 -0
- package/src/representations/CompactGroupByToolNameRepresentation.ts +44 -0
- package/src/representations/CompactTotalPerLevelRepresentation.ts +14 -0
- package/src/representations/CompactTotalPerSeverityRepresentation.ts +14 -0
- package/src/representations/CompactTotalRepresentation.ts +27 -0
- package/src/representations/Representation.ts +35 -0
- package/src/representations/RepresentationFactory.ts +49 -0
- package/src/types.ts +270 -53
- package/src/utils/Comparators.ts +19 -0
- package/src/utils/ExtendedArray.ts +11 -0
- package/src/utils/FileUtils.ts +60 -0
- package/src/utils/SarifUtils.ts +20 -72
- package/test-data/sarif/codeql-python.sarif +1448 -1
- package/test-data/sarif/codeql-typescript.sarif +3474 -1
- package/test-data/sarif/grype-github-actions.sarif +65 -0
- package/test-data/sarif/osv-scanner-composer.sarif +972 -0
- package/test-data/sarif/osv-scanner-container.sarif +2278 -0
- package/test-data/sarif/osv-scanner-gomodules.sarif +813 -0
- package/test-data/sarif/osv-scanner-hex.sarif +147 -0
- package/test-data/sarif/osv-scanner-maven.sarif +171 -0
- package/test-data/sarif/osv-scanner-npm.sarif +627 -0
- package/test-data/sarif/osv-scanner-pip.sarif +206 -0
- package/test-data/sarif/osv-scanner-pipenv.sarif +243 -0
- package/test-data/sarif/osv-scanner-pnpm.sarif +174 -0
- package/test-data/sarif/osv-scanner-poetry.sarif +1893 -0
- package/test-data/sarif/osv-scanner-rubygems.sarif +402 -0
- package/test-data/sarif/osv-scanner-uv.sarif +206 -0
- package/test-data/sarif/osv-scanner-yarn.sarif +5207 -0
- package/test-data/sarif/runs-0.sarif +5 -0
- package/test-data/sarif/runs-2-tools-2-results-0.sarif +1 -1
- package/test-data/sarif/runs-2-tools-2.sarif +1 -1
- package/test-data/sarif/runs-3-tools-2-results-0.sarif +1 -1
- package/test-data/sarif/runs-3-tools-2.sarif +1 -1
- package/test-data/sarif/tmp/codeql-csharp.sarif +1 -0
- package/test-data/sarif/tmp/grype-container.sarif +1774 -0
- package/test-data/sarif/tmp/runs-1-tools-1-results-0.sarif +18 -0
- package/test-data/sarif/tmp/runs-2-tools-2.sarif +686 -0
- package/test-data/sarif/trivy-iac.sarif +1 -1
- package/tests/integration/SendSarifToSlack.spec.ts +95 -27
- package/tsconfig.json +2 -0
- package/dist/Processors.d.ts +0 -2
- package/dist/Processors.d.ts.map +0 -1
- package/dist/Processors.js +0 -61
- package/dist/SarifToSlackService.d.ts +0 -39
- package/dist/SarifToSlackService.d.ts.map +0 -1
- package/dist/SarifToSlackService.js +0 -104
- package/dist/metadata.d.ts +0 -2
- package/dist/metadata.d.ts.map +0 -1
- package/dist/metadata.js +0 -11
- package/dist/model/SarifModelPerRun.d.ts +0 -2
- package/dist/model/SarifModelPerRun.d.ts.map +0 -1
- package/dist/model/SarifModelPerRun.js +0 -90
- package/dist/model/SarifModelPerSarif.d.ts +0 -2
- package/dist/model/SarifModelPerSarif.d.ts.map +0 -1
- package/dist/model/SarifModelPerSarif.js +0 -102
- package/dist/model/types.d.ts +0 -2
- package/dist/model/types.d.ts.map +0 -1
- package/dist/model/types.js +0 -49
- package/dist/utils/SortUtils.d.ts +0 -2
- package/dist/utils/SortUtils.d.ts.map +0 -1
- package/dist/utils/SortUtils.js +0 -20
- package/src/Processors.ts +0 -68
- package/src/SarifToSlackService.ts +0 -117
- package/src/metadata.ts +0 -10
- package/src/model/SarifModelPerRun.ts +0 -120
- package/src/model/SarifModelPerSarif.ts +0 -126
- package/src/model/types.ts +0 -50
- package/src/utils/SortUtils.ts +0 -33
- package/tests/Processors.spec.ts +0 -76
package/dist/sarif-to-slack.d.ts
CHANGED
|
@@ -2,24 +2,45 @@
|
|
|
2
2
|
* Sarif to Slack message converter library.
|
|
3
3
|
*
|
|
4
4
|
* @remarks
|
|
5
|
-
* This library provides a
|
|
5
|
+
* This library provides a client to send a Slack messages based on the provided
|
|
6
6
|
* SARIF (Static Analysis Results Interchange Format) files.
|
|
7
7
|
*
|
|
8
8
|
* @example
|
|
9
9
|
* ```typescript
|
|
10
|
-
* import {
|
|
10
|
+
* import {
|
|
11
|
+
* Color,
|
|
12
|
+
* FooterType,
|
|
13
|
+
* LogLevel,
|
|
14
|
+
* RepresentationType,
|
|
15
|
+
* SarifToSlackClient,
|
|
16
|
+
* SendIf
|
|
17
|
+
* } from '@fabasoad/sarif-to-slack';
|
|
11
18
|
*
|
|
12
|
-
* const
|
|
19
|
+
* const client: SarifToSlackClient = await SarifToSlackClient.create({
|
|
13
20
|
* webhookUrl: 'https://hooks.slack.com/services/your/webhook/url',
|
|
14
|
-
*
|
|
21
|
+
* username: 'SARIF to Slack Bot',
|
|
22
|
+
* iconUrl: 'https://example.com/icon.png',
|
|
23
|
+
* color: {
|
|
24
|
+
* bySeverity: {
|
|
25
|
+
* critical: new Color('#ff0000'),
|
|
26
|
+
* high: new Color('#ff4500'),
|
|
27
|
+
* medium: new Color('#ffa500'),
|
|
28
|
+
* low: new Color('#ffff00'),
|
|
29
|
+
* none: new Color('#808080'),
|
|
30
|
+
* unknown: new Color('#800080'),
|
|
31
|
+
* empty: new Color('#d3d3d3'),
|
|
32
|
+
* },
|
|
33
|
+
* },
|
|
34
|
+
* sarif: {
|
|
35
|
+
* path: 'path/to/your/sarif-files',
|
|
36
|
+
* recursive: true,
|
|
37
|
+
* extension: 'sarif',
|
|
38
|
+
* },
|
|
15
39
|
* log: {
|
|
16
40
|
* level: LogLevel.Info,
|
|
17
41
|
* template: '[{{logLevelName}}] [{{name}}] {{dateIsoStr}} ',
|
|
18
42
|
* colored: false,
|
|
19
43
|
* },
|
|
20
|
-
* username: 'SARIF Bot',
|
|
21
|
-
* iconUrl: 'https://example.com/icon.png',
|
|
22
|
-
* color: '#36a64f',
|
|
23
44
|
* header: {
|
|
24
45
|
* include: true,
|
|
25
46
|
* value: 'SARIF Analysis Results'
|
|
@@ -36,40 +57,90 @@
|
|
|
36
57
|
* run: {
|
|
37
58
|
* include: true
|
|
38
59
|
* },
|
|
60
|
+
* representation: RepresentationType.CompactGroupByToolNamePerSeverity,
|
|
61
|
+
* sendIf: SendIf.MediumOrHigher,
|
|
39
62
|
* });
|
|
40
|
-
* await
|
|
63
|
+
* await client.send();
|
|
41
64
|
* ```
|
|
42
65
|
*
|
|
43
|
-
* @see {@link
|
|
66
|
+
* @see {@link SarifToSlackClient}
|
|
44
67
|
*
|
|
45
68
|
* @packageDocumentation
|
|
46
69
|
*/
|
|
47
70
|
|
|
48
|
-
import type { Log } from 'sarif';
|
|
49
|
-
|
|
50
71
|
/**
|
|
51
|
-
*
|
|
72
|
+
* This class represents a color in hex format.
|
|
52
73
|
* @public
|
|
53
74
|
*/
|
|
54
|
-
export declare
|
|
75
|
+
export declare class Color {
|
|
76
|
+
private readonly _color?;
|
|
55
77
|
/**
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
78
|
+
* Creates an instance of {@link Color} class. Before creating an instance of
|
|
79
|
+
* {@link Color} class, it (if applicable) maps CI status into the hex color,
|
|
80
|
+
* and also validates {@param color} to be a valid string that represents a
|
|
81
|
+
* color in hex format.
|
|
82
|
+
* @param color Can be either undefined, valid color in hex format or GitHub
|
|
83
|
+
* CI status (one of: success, failure, cancelled, skipped)
|
|
84
|
+
* @public
|
|
61
85
|
*/
|
|
62
|
-
|
|
86
|
+
constructor(color?: string);
|
|
63
87
|
/**
|
|
64
|
-
*
|
|
65
|
-
* Medium, Low, None and Unknown. it tries to get the security severity from the
|
|
66
|
-
* respective rule of each result, using the rules[].properties['security-severity']
|
|
67
|
-
* property. This property contains CVSS score, which is then mapped to the
|
|
68
|
-
* security severity value.
|
|
88
|
+
* Returns a valid string that represents a color in hex format, or undefined.
|
|
69
89
|
*/
|
|
70
|
-
|
|
90
|
+
get value(): string | undefined;
|
|
91
|
+
private validateHexColor;
|
|
92
|
+
private mapColor;
|
|
71
93
|
}
|
|
72
94
|
|
|
95
|
+
/**
|
|
96
|
+
* Color schema for the findings with the certain level. Color is used by the
|
|
97
|
+
* level importance, i.e. if at least 1 error finding exists then
|
|
98
|
+
* {@link ColorGroupByLevel.error} color is used, then if at least 1 warning
|
|
99
|
+
* finding exists then {@link ColorGroupByLevel.warning} color is used, etc.
|
|
100
|
+
* @public
|
|
101
|
+
*/
|
|
102
|
+
export declare type ColorGroupByLevel = ColorGroupCommon & {
|
|
103
|
+
error?: Color;
|
|
104
|
+
warning?: Color;
|
|
105
|
+
note?: Color;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Color schema for the findings with the certain severity. Color is used by the
|
|
110
|
+
* severity importance, i.e. if at least 1 critical finding exists then
|
|
111
|
+
* {@link ColorGroupBySeverity.critical} color is used, then if at least 1 high
|
|
112
|
+
* finding exists then {@link ColorGroupBySeverity.high} color is used, etc.
|
|
113
|
+
* @public
|
|
114
|
+
*/
|
|
115
|
+
export declare type ColorGroupBySeverity = ColorGroupCommon & {
|
|
116
|
+
critical?: Color;
|
|
117
|
+
high?: Color;
|
|
118
|
+
medium?: Color;
|
|
119
|
+
low?: Color;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Base type that has common fields for both {@link ColorGroupByLevel} and
|
|
124
|
+
* {@link ColorGroupBySeverity}.
|
|
125
|
+
* @private
|
|
126
|
+
*/
|
|
127
|
+
declare type ColorGroupCommon = {
|
|
128
|
+
none?: Color;
|
|
129
|
+
unknown?: Color;
|
|
130
|
+
empty?: Color;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Represents configuration of the color scheme. {@link ColorOptions.byLevel} has
|
|
135
|
+
* color scheme for the findings where certain level presented. {@link ColorOptions.bySeverity}
|
|
136
|
+
* has color scheme for the findings where certain severity presented.
|
|
137
|
+
* @public
|
|
138
|
+
*/
|
|
139
|
+
export declare type ColorOptions = {
|
|
140
|
+
byLevel?: ColorGroupByLevel;
|
|
141
|
+
bySeverity?: ColorGroupBySeverity;
|
|
142
|
+
};
|
|
143
|
+
|
|
73
144
|
/**
|
|
74
145
|
* Options for the footer of a Slack message. "type" is ignored if "value" is
|
|
75
146
|
* not defined.
|
|
@@ -95,27 +166,6 @@ export declare enum FooterType {
|
|
|
95
166
|
Markdown = "mrkdwn"
|
|
96
167
|
}
|
|
97
168
|
|
|
98
|
-
/**
|
|
99
|
-
* Enum representing how to group results.
|
|
100
|
-
* @public
|
|
101
|
-
*/
|
|
102
|
-
export declare enum GroupResultsBy {
|
|
103
|
-
/**
|
|
104
|
-
* Groups results by the tool name. Particularly, groups by the runs[].tool.driver.name
|
|
105
|
-
* property from the SARIF file(s).
|
|
106
|
-
*/
|
|
107
|
-
ToolName = 0,
|
|
108
|
-
/**
|
|
109
|
-
* Groups results by the run. It provides the result from each run individually.
|
|
110
|
-
*/
|
|
111
|
-
Run = 1,
|
|
112
|
-
/**
|
|
113
|
-
* Does not group results. It provides the result from all the runs from all
|
|
114
|
-
* the provided SARIF files.
|
|
115
|
-
*/
|
|
116
|
-
Total = 2
|
|
117
|
-
}
|
|
118
|
-
|
|
119
169
|
/**
|
|
120
170
|
* Type representing properties that indicate whether to include certain information
|
|
121
171
|
* in the Slack message.
|
|
@@ -189,76 +239,278 @@ export declare type LogOptions = {
|
|
|
189
239
|
};
|
|
190
240
|
|
|
191
241
|
/**
|
|
192
|
-
*
|
|
242
|
+
* This represents what type of message should be sent. There are various options
|
|
243
|
+
* to show information from SARIF in Slack message.
|
|
244
|
+
* @public
|
|
245
|
+
*/
|
|
246
|
+
export declare enum RepresentationType {
|
|
247
|
+
/**
|
|
248
|
+
* Compact information about findings grouped by Run with the level representation.
|
|
249
|
+
* @example
|
|
250
|
+
* ```text
|
|
251
|
+
* [Run 1] Grype
|
|
252
|
+
* Error: 1, Warning: 4
|
|
253
|
+
* [Run 2] Grype
|
|
254
|
+
* Warning: 1, Note: 20
|
|
255
|
+
* ```
|
|
256
|
+
*/
|
|
257
|
+
CompactGroupByRunPerLevel = 0,
|
|
258
|
+
/**
|
|
259
|
+
* Compact information about findings grouped by Run with the severity representation.
|
|
260
|
+
* @example
|
|
261
|
+
* ```text
|
|
262
|
+
* [Run 1] Grype
|
|
263
|
+
* Critical: 1, High: 3, Medium: 1
|
|
264
|
+
* [Run 2] Grype
|
|
265
|
+
* Medium: 1, Low: 20
|
|
266
|
+
* ```
|
|
267
|
+
*/
|
|
268
|
+
CompactGroupByRunPerSeverity = 1,
|
|
269
|
+
/**
|
|
270
|
+
* Compact information about findings grouped by tool name with the level representation.
|
|
271
|
+
* @example
|
|
272
|
+
* ```text
|
|
273
|
+
* Grype
|
|
274
|
+
* Error: 1, Warning: 5, Note: 20
|
|
275
|
+
* ```
|
|
276
|
+
*/
|
|
277
|
+
CompactGroupByToolNamePerLevel = 2,
|
|
278
|
+
/**
|
|
279
|
+
* Compact information about findings grouped by tool name with the severity representation.
|
|
280
|
+
* @example
|
|
281
|
+
* ```text
|
|
282
|
+
* Grype
|
|
283
|
+
* Critical: 1, High: 3, Medium: 2, Low: 20
|
|
284
|
+
* ```
|
|
285
|
+
*/
|
|
286
|
+
CompactGroupByToolNamePerSeverity = 3,
|
|
287
|
+
/**
|
|
288
|
+
* Compact information about findings grouped by SARIF file with the level representation.
|
|
289
|
+
* @example
|
|
290
|
+
* ```text
|
|
291
|
+
* grype-results-01.sarif
|
|
292
|
+
* Error: 1, Warning: 2, Note: 1
|
|
293
|
+
* grype-results-02.sarif
|
|
294
|
+
* Warning: 3, Note: 19
|
|
295
|
+
* ```
|
|
296
|
+
*/
|
|
297
|
+
CompactGroupBySarifPerLevel = 4,
|
|
298
|
+
/**
|
|
299
|
+
* Compact information about findings grouped by SARIF file with the severity
|
|
300
|
+
* representation.
|
|
301
|
+
* @example
|
|
302
|
+
* ```text
|
|
303
|
+
* grype-results-01.sarif
|
|
304
|
+
* High: 3, Medium: 1, Low: 11
|
|
305
|
+
* grype-results-02.sarif
|
|
306
|
+
* Critical: 1, Medium: 1, Low: 9
|
|
307
|
+
* ```
|
|
308
|
+
*/
|
|
309
|
+
CompactGroupBySarifPerSeverity = 5,
|
|
310
|
+
/**
|
|
311
|
+
* Compact information about findings with the level representation.
|
|
312
|
+
* @example
|
|
313
|
+
* ```text
|
|
314
|
+
* Total
|
|
315
|
+
* Error: 1, Warning: 5, Note: 20
|
|
316
|
+
* ```
|
|
317
|
+
*/
|
|
318
|
+
CompactTotalPerLevel = 6,
|
|
319
|
+
/**
|
|
320
|
+
* Compact information about findings with the severity representation.
|
|
321
|
+
* @example
|
|
322
|
+
* ```text
|
|
323
|
+
* Total
|
|
324
|
+
* Critical: 1, High: 3, Medium: 2, Low: 20
|
|
325
|
+
* ```
|
|
326
|
+
*/
|
|
327
|
+
CompactTotalPerSeverity = 7
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* SARIF file extension.
|
|
193
332
|
* @public
|
|
194
333
|
*/
|
|
195
|
-
export declare type
|
|
334
|
+
export declare type SarifFileExtension = 'sarif' | 'json';
|
|
196
335
|
|
|
197
336
|
/**
|
|
198
|
-
*
|
|
337
|
+
* Represents options for the provided SARIF file(s), such as path, should files
|
|
338
|
+
* from this path be retrieved recursively or not, and file extension.
|
|
199
339
|
* @public
|
|
200
340
|
*/
|
|
201
|
-
export declare type
|
|
202
|
-
|
|
203
|
-
|
|
341
|
+
export declare type SarifOptions = {
|
|
342
|
+
path: string;
|
|
343
|
+
recursive?: boolean;
|
|
344
|
+
extension?: SarifFileExtension;
|
|
204
345
|
};
|
|
205
346
|
|
|
206
347
|
/**
|
|
207
348
|
* Service to convert SARIF files to Slack messages and send them.
|
|
208
349
|
* @public
|
|
209
350
|
*/
|
|
210
|
-
export declare class
|
|
211
|
-
private
|
|
351
|
+
export declare class SarifToSlackClient {
|
|
352
|
+
private _message?;
|
|
353
|
+
private _sarifModel?;
|
|
354
|
+
private _sendIf;
|
|
212
355
|
private constructor();
|
|
356
|
+
private static createRunIdGenerator;
|
|
357
|
+
static create(opts: SarifToSlackClientOptions): Promise<SarifToSlackClient>;
|
|
358
|
+
private static buildModel;
|
|
213
359
|
/**
|
|
214
|
-
*
|
|
215
|
-
*
|
|
216
|
-
* @
|
|
360
|
+
* The main function to initialize a list of {@link SlackMessage} objects based
|
|
361
|
+
* on the given SARIF file(s).
|
|
362
|
+
* @param sarifModel An instance of {@link SarifModel} object.
|
|
363
|
+
* @param opts An instance of {@link SarifToSlackClientOptions} object.
|
|
364
|
+
* @returns A map where key is the SARIF file and value is an instance of
|
|
365
|
+
* {@link SlackMessage} object
|
|
366
|
+
* @private
|
|
217
367
|
*/
|
|
218
|
-
|
|
368
|
+
private static initialize;
|
|
219
369
|
/**
|
|
220
|
-
*
|
|
221
|
-
* @param opts - Options for the service, including webhook URL, SARIF path, and other configurations.
|
|
222
|
-
* @returns A promise that resolves to an instance of SarifToSlackService.
|
|
223
|
-
* @throws Error if no SARIF files are found at the provided path.
|
|
224
|
-
* @public
|
|
225
|
-
*/
|
|
226
|
-
static create(opts: SarifToSlackServiceOptions): Promise<SarifToSlackService>;
|
|
227
|
-
/**
|
|
228
|
-
* Sends all prepared Slack messages.
|
|
229
|
-
* @returns A promise that resolves when all messages have been sent.
|
|
230
|
-
* @throws Error if a Slack message was not prepared for a SARIF path.
|
|
231
|
-
* @public
|
|
232
|
-
*/
|
|
233
|
-
sendAll(): Promise<void>;
|
|
234
|
-
/**
|
|
235
|
-
* Sends a Slack message for a specific SARIF path.
|
|
236
|
-
* @param sarifPath - The path of the SARIF file for which the message should be sent.
|
|
370
|
+
* Sends a Slack message.
|
|
237
371
|
* @returns A promise that resolves when the message has been sent.
|
|
238
372
|
* @throws Error if a Slack message was not prepared for the given SARIF path.
|
|
239
373
|
* @public
|
|
240
374
|
*/
|
|
241
|
-
send(
|
|
375
|
+
send(): Promise<void>;
|
|
376
|
+
private get shouldSendMessage();
|
|
242
377
|
}
|
|
243
378
|
|
|
244
379
|
/**
|
|
245
|
-
* Options for the
|
|
380
|
+
* Options for the SarifToSlackClient.
|
|
246
381
|
* @public
|
|
247
382
|
*/
|
|
248
|
-
export declare type
|
|
383
|
+
export declare type SarifToSlackClientOptions = {
|
|
249
384
|
webhookUrl: string;
|
|
250
|
-
|
|
385
|
+
sarif: SarifOptions;
|
|
251
386
|
username?: string;
|
|
252
387
|
iconUrl?: string;
|
|
253
|
-
color?:
|
|
388
|
+
color?: Color | ColorOptions;
|
|
254
389
|
log?: LogOptions;
|
|
255
390
|
header?: IncludeAwareWithValueOptions;
|
|
256
391
|
footer?: FooterOptions;
|
|
257
392
|
actor?: IncludeAwareWithValueOptions;
|
|
258
393
|
run?: IncludeAwareOptions;
|
|
259
|
-
|
|
394
|
+
representation?: RepresentationType;
|
|
395
|
+
sendIf?: SendIf;
|
|
260
396
|
};
|
|
261
397
|
|
|
398
|
+
/**
|
|
399
|
+
* This enum represents the condition on when message should be sent. If this
|
|
400
|
+
* condition is satisfied then message is sent, otherwise - message is not sent.
|
|
401
|
+
* @public
|
|
402
|
+
*/
|
|
403
|
+
export declare enum SendIf {
|
|
404
|
+
/**
|
|
405
|
+
* Send message only if there is at least one finding with "Critical" severity.
|
|
406
|
+
* Since it is the higher possible severity, it is the same as "Critical" or
|
|
407
|
+
* higher.
|
|
408
|
+
*/
|
|
409
|
+
SeverityCritical = 0,
|
|
410
|
+
/**
|
|
411
|
+
* Send message only if there is at least one finding with "High" severity.
|
|
412
|
+
*/
|
|
413
|
+
SeverityHigh = 1,
|
|
414
|
+
/**
|
|
415
|
+
* Send message only if there is at least one finding with "High" severity or
|
|
416
|
+
* higher, that includes "High" and "Critical".
|
|
417
|
+
*/
|
|
418
|
+
SeverityHighOrHigher = 2,
|
|
419
|
+
/**
|
|
420
|
+
* Send message only if there is at least one finding with "Medium" severity.
|
|
421
|
+
*/
|
|
422
|
+
SeverityMedium = 3,
|
|
423
|
+
/**
|
|
424
|
+
* Send message only if there is at least one finding with "Medium" severity
|
|
425
|
+
* or higher, that includes "Medium", "High" and "Critical".
|
|
426
|
+
*/
|
|
427
|
+
SeverityMediumOrHigher = 4,
|
|
428
|
+
/**
|
|
429
|
+
* Send message only if there is at least one finding with "Low" severity.
|
|
430
|
+
*/
|
|
431
|
+
SeverityLow = 5,
|
|
432
|
+
/**
|
|
433
|
+
* Send message only if there is at least one finding with "Low" severity or
|
|
434
|
+
* higher, that includes "Low", "Medium", "High" and "Critical".
|
|
435
|
+
*/
|
|
436
|
+
SeverityLowOrHigher = 6,
|
|
437
|
+
/**
|
|
438
|
+
* Send message only if there is at least one finding with "None" severity.
|
|
439
|
+
*/
|
|
440
|
+
SeverityNone = 7,
|
|
441
|
+
/**
|
|
442
|
+
* Send message only if there is at least one finding with "None" severity or
|
|
443
|
+
* higher, that includes "None", "Low", "Medium", "High" and "Critical".
|
|
444
|
+
*/
|
|
445
|
+
SeverityNoneOrHigher = 8,
|
|
446
|
+
/**
|
|
447
|
+
* Send message only if there is at least one finding with "Unknown" severity.
|
|
448
|
+
*/
|
|
449
|
+
SeverityUnknown = 9,
|
|
450
|
+
/**
|
|
451
|
+
* Send message only if there is at least one finding with "Unknown" severity
|
|
452
|
+
* or higher, that includes "Unknown", "None", "Low", "Medium", "High" and "Critical".
|
|
453
|
+
*/
|
|
454
|
+
SeverityUnknownOrHigher = 10,
|
|
455
|
+
/**
|
|
456
|
+
* Send message only if there is at least one finding with "Error" level.
|
|
457
|
+
* Since it is the higher possible level, it is the same as "Error" or higher.
|
|
458
|
+
*/
|
|
459
|
+
LevelError = 11,
|
|
460
|
+
/**
|
|
461
|
+
* Send message only if there is at least one finding with "Warning" level.
|
|
462
|
+
*/
|
|
463
|
+
LevelWarning = 12,
|
|
464
|
+
/**
|
|
465
|
+
* Send message only if there is at least one finding with "Warning" level or
|
|
466
|
+
* higher, that includes "Warning" and "Error".
|
|
467
|
+
*/
|
|
468
|
+
LevelWarningOrHigher = 13,
|
|
469
|
+
/**
|
|
470
|
+
* Send message only if there is at least one finding with "Note" level.
|
|
471
|
+
*/
|
|
472
|
+
LevelNote = 14,
|
|
473
|
+
/**
|
|
474
|
+
* Send message only if there is at least one finding with "Note" level or
|
|
475
|
+
* higher, that includes "Note", "Warning" and "Error.
|
|
476
|
+
*/
|
|
477
|
+
LevelNoteOrHigher = 15,
|
|
478
|
+
/**
|
|
479
|
+
* Send message only if there is at least one finding with "None" level.
|
|
480
|
+
*/
|
|
481
|
+
LevelNone = 16,
|
|
482
|
+
/**
|
|
483
|
+
* Send message only if there is at least one finding with "None" level or
|
|
484
|
+
* higher, that includes "None", "Note", "Warning" and "Error.
|
|
485
|
+
*/
|
|
486
|
+
LevelNoneOrHigher = 17,
|
|
487
|
+
/**
|
|
488
|
+
* Send message only if there is at least one finding with "Unknown" level.
|
|
489
|
+
*/
|
|
490
|
+
LevelUnknown = 18,
|
|
491
|
+
/**
|
|
492
|
+
* Send message only if there is at least one finding with "Unknown" level or
|
|
493
|
+
* higher, that includes "Unknown", "None", "Note", "Warning" and "Error.
|
|
494
|
+
*/
|
|
495
|
+
LevelUnknownOrHigher = 19,
|
|
496
|
+
/**
|
|
497
|
+
* Always send a message.
|
|
498
|
+
*/
|
|
499
|
+
Always = 20,
|
|
500
|
+
/**
|
|
501
|
+
* Send a message if at least 1 vulnerability is found.
|
|
502
|
+
*/
|
|
503
|
+
Some = 21,
|
|
504
|
+
/**
|
|
505
|
+
* Send a message only if no vulnerabilities are found.
|
|
506
|
+
*/
|
|
507
|
+
Empty = 22,
|
|
508
|
+
/**
|
|
509
|
+
* Never send a message.
|
|
510
|
+
*/
|
|
511
|
+
Never = 23
|
|
512
|
+
}
|
|
513
|
+
|
|
262
514
|
/**
|
|
263
515
|
* Interface for a Slack message that can be sent.
|
|
264
516
|
* @public
|
|
@@ -269,10 +521,10 @@ export declare interface SlackMessage {
|
|
|
269
521
|
* @returns A promise that resolves to the response from the Slack webhook.
|
|
270
522
|
*/
|
|
271
523
|
send: () => Promise<string>;
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
524
|
+
withActor(actor?: string): void;
|
|
525
|
+
withFooter(text?: string, type?: FooterType): void;
|
|
526
|
+
withHeader(header?: string): void;
|
|
527
|
+
withRun(): void;
|
|
276
528
|
}
|
|
277
529
|
|
|
278
530
|
export { }
|