@fabasoad/sarif-to-slack 0.2.5 → 1.1.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 +826 -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 +80 -0
- package/dist/model/Color.d.ts.map +1 -0
- package/dist/model/Color.js +106 -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 +347 -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 +162 -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 +195 -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,100 @@
|
|
|
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. If both {@link ColorOptions.byLevel}
|
|
135
|
+
* and {@link ColorOptions.bySeverity} are defined, then {@link ColorOptions.bySeverity}
|
|
136
|
+
* takes precedence.
|
|
137
|
+
* @public
|
|
138
|
+
*/
|
|
139
|
+
export declare type ColorOptions = {
|
|
140
|
+
/**
|
|
141
|
+
* Default color if specific color was not found. It is a fallback option.
|
|
142
|
+
*/
|
|
143
|
+
default?: Color;
|
|
144
|
+
/**
|
|
145
|
+
* Color scheme for the findings where certain level is presented.
|
|
146
|
+
*/
|
|
147
|
+
byLevel?: ColorGroupByLevel;
|
|
148
|
+
/**
|
|
149
|
+
* Color scheme for the findings where certain severity is presented.
|
|
150
|
+
*/
|
|
151
|
+
bySeverity?: ColorGroupBySeverity;
|
|
152
|
+
};
|
|
153
|
+
|
|
73
154
|
/**
|
|
74
155
|
* Options for the footer of a Slack message. "type" is ignored if "value" is
|
|
75
156
|
* not defined.
|
|
@@ -95,27 +176,6 @@ export declare enum FooterType {
|
|
|
95
176
|
Markdown = "mrkdwn"
|
|
96
177
|
}
|
|
97
178
|
|
|
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
179
|
/**
|
|
120
180
|
* Type representing properties that indicate whether to include certain information
|
|
121
181
|
* in the Slack message.
|
|
@@ -189,76 +249,278 @@ export declare type LogOptions = {
|
|
|
189
249
|
};
|
|
190
250
|
|
|
191
251
|
/**
|
|
192
|
-
*
|
|
252
|
+
* This represents what type of message should be sent. There are various options
|
|
253
|
+
* to show information from SARIF in Slack message.
|
|
254
|
+
* @public
|
|
255
|
+
*/
|
|
256
|
+
export declare enum RepresentationType {
|
|
257
|
+
/**
|
|
258
|
+
* Compact information about findings grouped by Run with the level representation.
|
|
259
|
+
* @example
|
|
260
|
+
* ```text
|
|
261
|
+
* [Run 1] Grype
|
|
262
|
+
* Error: 1, Warning: 4
|
|
263
|
+
* [Run 2] Grype
|
|
264
|
+
* Warning: 1, Note: 20
|
|
265
|
+
* ```
|
|
266
|
+
*/
|
|
267
|
+
CompactGroupByRunPerLevel = 0,
|
|
268
|
+
/**
|
|
269
|
+
* Compact information about findings grouped by Run with the severity representation.
|
|
270
|
+
* @example
|
|
271
|
+
* ```text
|
|
272
|
+
* [Run 1] Grype
|
|
273
|
+
* Critical: 1, High: 3, Medium: 1
|
|
274
|
+
* [Run 2] Grype
|
|
275
|
+
* Medium: 1, Low: 20
|
|
276
|
+
* ```
|
|
277
|
+
*/
|
|
278
|
+
CompactGroupByRunPerSeverity = 1,
|
|
279
|
+
/**
|
|
280
|
+
* Compact information about findings grouped by tool name with the level representation.
|
|
281
|
+
* @example
|
|
282
|
+
* ```text
|
|
283
|
+
* Grype
|
|
284
|
+
* Error: 1, Warning: 5, Note: 20
|
|
285
|
+
* ```
|
|
286
|
+
*/
|
|
287
|
+
CompactGroupByToolNamePerLevel = 2,
|
|
288
|
+
/**
|
|
289
|
+
* Compact information about findings grouped by tool name with the severity representation.
|
|
290
|
+
* @example
|
|
291
|
+
* ```text
|
|
292
|
+
* Grype
|
|
293
|
+
* Critical: 1, High: 3, Medium: 2, Low: 20
|
|
294
|
+
* ```
|
|
295
|
+
*/
|
|
296
|
+
CompactGroupByToolNamePerSeverity = 3,
|
|
297
|
+
/**
|
|
298
|
+
* Compact information about findings grouped by SARIF file with the level representation.
|
|
299
|
+
* @example
|
|
300
|
+
* ```text
|
|
301
|
+
* grype-results-01.sarif
|
|
302
|
+
* Error: 1, Warning: 2, Note: 1
|
|
303
|
+
* grype-results-02.sarif
|
|
304
|
+
* Warning: 3, Note: 19
|
|
305
|
+
* ```
|
|
306
|
+
*/
|
|
307
|
+
CompactGroupBySarifPerLevel = 4,
|
|
308
|
+
/**
|
|
309
|
+
* Compact information about findings grouped by SARIF file with the severity
|
|
310
|
+
* representation.
|
|
311
|
+
* @example
|
|
312
|
+
* ```text
|
|
313
|
+
* grype-results-01.sarif
|
|
314
|
+
* High: 3, Medium: 1, Low: 11
|
|
315
|
+
* grype-results-02.sarif
|
|
316
|
+
* Critical: 1, Medium: 1, Low: 9
|
|
317
|
+
* ```
|
|
318
|
+
*/
|
|
319
|
+
CompactGroupBySarifPerSeverity = 5,
|
|
320
|
+
/**
|
|
321
|
+
* Compact information about findings with the level representation.
|
|
322
|
+
* @example
|
|
323
|
+
* ```text
|
|
324
|
+
* Total
|
|
325
|
+
* Error: 1, Warning: 5, Note: 20
|
|
326
|
+
* ```
|
|
327
|
+
*/
|
|
328
|
+
CompactTotalPerLevel = 6,
|
|
329
|
+
/**
|
|
330
|
+
* Compact information about findings with the severity representation.
|
|
331
|
+
* @example
|
|
332
|
+
* ```text
|
|
333
|
+
* Total
|
|
334
|
+
* Critical: 1, High: 3, Medium: 2, Low: 20
|
|
335
|
+
* ```
|
|
336
|
+
*/
|
|
337
|
+
CompactTotalPerSeverity = 7
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* SARIF file extension.
|
|
193
342
|
* @public
|
|
194
343
|
*/
|
|
195
|
-
export declare type
|
|
344
|
+
export declare type SarifFileExtension = 'sarif' | 'json';
|
|
196
345
|
|
|
197
346
|
/**
|
|
198
|
-
*
|
|
347
|
+
* Represents options for the provided SARIF file(s), such as path, should files
|
|
348
|
+
* from this path be retrieved recursively or not, and file extension.
|
|
199
349
|
* @public
|
|
200
350
|
*/
|
|
201
|
-
export declare type
|
|
202
|
-
|
|
203
|
-
|
|
351
|
+
export declare type SarifOptions = {
|
|
352
|
+
path: string;
|
|
353
|
+
recursive?: boolean;
|
|
354
|
+
extension?: SarifFileExtension;
|
|
204
355
|
};
|
|
205
356
|
|
|
206
357
|
/**
|
|
207
358
|
* Service to convert SARIF files to Slack messages and send them.
|
|
208
359
|
* @public
|
|
209
360
|
*/
|
|
210
|
-
export declare class
|
|
211
|
-
private
|
|
361
|
+
export declare class SarifToSlackClient {
|
|
362
|
+
private _message?;
|
|
363
|
+
private _sarifModel?;
|
|
364
|
+
private _sendIf;
|
|
212
365
|
private constructor();
|
|
366
|
+
private static createRunIdGenerator;
|
|
367
|
+
static create(opts: SarifToSlackClientOptions): Promise<SarifToSlackClient>;
|
|
368
|
+
private static buildModel;
|
|
213
369
|
/**
|
|
214
|
-
*
|
|
215
|
-
*
|
|
216
|
-
* @
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
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
|
|
370
|
+
* The main function to initialize a list of {@link SlackMessage} objects based
|
|
371
|
+
* on the given SARIF file(s).
|
|
372
|
+
* @param sarifModel An instance of {@link SarifModel} object.
|
|
373
|
+
* @param opts An instance of {@link SarifToSlackClientOptions} object.
|
|
374
|
+
* @returns A map where key is the SARIF file and value is an instance of
|
|
375
|
+
* {@link SlackMessage} object
|
|
376
|
+
* @private
|
|
225
377
|
*/
|
|
226
|
-
static
|
|
378
|
+
private static initialize;
|
|
227
379
|
/**
|
|
228
|
-
* Sends
|
|
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.
|
|
380
|
+
* Sends a Slack message.
|
|
237
381
|
* @returns A promise that resolves when the message has been sent.
|
|
238
382
|
* @throws Error if a Slack message was not prepared for the given SARIF path.
|
|
239
383
|
* @public
|
|
240
384
|
*/
|
|
241
|
-
send(
|
|
385
|
+
send(): Promise<void>;
|
|
386
|
+
private get shouldSendMessage();
|
|
242
387
|
}
|
|
243
388
|
|
|
244
389
|
/**
|
|
245
|
-
* Options for the
|
|
390
|
+
* Options for the SarifToSlackClient.
|
|
246
391
|
* @public
|
|
247
392
|
*/
|
|
248
|
-
export declare type
|
|
393
|
+
export declare type SarifToSlackClientOptions = {
|
|
249
394
|
webhookUrl: string;
|
|
250
|
-
|
|
395
|
+
sarif: SarifOptions;
|
|
251
396
|
username?: string;
|
|
252
397
|
iconUrl?: string;
|
|
253
|
-
color?:
|
|
398
|
+
color?: ColorOptions;
|
|
254
399
|
log?: LogOptions;
|
|
255
400
|
header?: IncludeAwareWithValueOptions;
|
|
256
401
|
footer?: FooterOptions;
|
|
257
402
|
actor?: IncludeAwareWithValueOptions;
|
|
258
403
|
run?: IncludeAwareOptions;
|
|
259
|
-
|
|
404
|
+
representation?: RepresentationType;
|
|
405
|
+
sendIf?: SendIf;
|
|
260
406
|
};
|
|
261
407
|
|
|
408
|
+
/**
|
|
409
|
+
* This enum represents the condition on when message should be sent. If this
|
|
410
|
+
* condition is satisfied then message is sent, otherwise - message is not sent.
|
|
411
|
+
* @public
|
|
412
|
+
*/
|
|
413
|
+
export declare enum SendIf {
|
|
414
|
+
/**
|
|
415
|
+
* Send message only if there is at least one finding with "Critical" severity.
|
|
416
|
+
* Since it is the higher possible severity, it is the same as "Critical" or
|
|
417
|
+
* higher.
|
|
418
|
+
*/
|
|
419
|
+
SeverityCritical = 0,
|
|
420
|
+
/**
|
|
421
|
+
* Send message only if there is at least one finding with "High" severity.
|
|
422
|
+
*/
|
|
423
|
+
SeverityHigh = 1,
|
|
424
|
+
/**
|
|
425
|
+
* Send message only if there is at least one finding with "High" severity or
|
|
426
|
+
* higher, that includes "High" and "Critical".
|
|
427
|
+
*/
|
|
428
|
+
SeverityHighOrHigher = 2,
|
|
429
|
+
/**
|
|
430
|
+
* Send message only if there is at least one finding with "Medium" severity.
|
|
431
|
+
*/
|
|
432
|
+
SeverityMedium = 3,
|
|
433
|
+
/**
|
|
434
|
+
* Send message only if there is at least one finding with "Medium" severity
|
|
435
|
+
* or higher, that includes "Medium", "High" and "Critical".
|
|
436
|
+
*/
|
|
437
|
+
SeverityMediumOrHigher = 4,
|
|
438
|
+
/**
|
|
439
|
+
* Send message only if there is at least one finding with "Low" severity.
|
|
440
|
+
*/
|
|
441
|
+
SeverityLow = 5,
|
|
442
|
+
/**
|
|
443
|
+
* Send message only if there is at least one finding with "Low" severity or
|
|
444
|
+
* higher, that includes "Low", "Medium", "High" and "Critical".
|
|
445
|
+
*/
|
|
446
|
+
SeverityLowOrHigher = 6,
|
|
447
|
+
/**
|
|
448
|
+
* Send message only if there is at least one finding with "None" severity.
|
|
449
|
+
*/
|
|
450
|
+
SeverityNone = 7,
|
|
451
|
+
/**
|
|
452
|
+
* Send message only if there is at least one finding with "None" severity or
|
|
453
|
+
* higher, that includes "None", "Low", "Medium", "High" and "Critical".
|
|
454
|
+
*/
|
|
455
|
+
SeverityNoneOrHigher = 8,
|
|
456
|
+
/**
|
|
457
|
+
* Send message only if there is at least one finding with "Unknown" severity.
|
|
458
|
+
*/
|
|
459
|
+
SeverityUnknown = 9,
|
|
460
|
+
/**
|
|
461
|
+
* Send message only if there is at least one finding with "Unknown" severity
|
|
462
|
+
* or higher, that includes "Unknown", "None", "Low", "Medium", "High" and "Critical".
|
|
463
|
+
*/
|
|
464
|
+
SeverityUnknownOrHigher = 10,
|
|
465
|
+
/**
|
|
466
|
+
* Send message only if there is at least one finding with "Error" level.
|
|
467
|
+
* Since it is the higher possible level, it is the same as "Error" or higher.
|
|
468
|
+
*/
|
|
469
|
+
LevelError = 11,
|
|
470
|
+
/**
|
|
471
|
+
* Send message only if there is at least one finding with "Warning" level.
|
|
472
|
+
*/
|
|
473
|
+
LevelWarning = 12,
|
|
474
|
+
/**
|
|
475
|
+
* Send message only if there is at least one finding with "Warning" level or
|
|
476
|
+
* higher, that includes "Warning" and "Error".
|
|
477
|
+
*/
|
|
478
|
+
LevelWarningOrHigher = 13,
|
|
479
|
+
/**
|
|
480
|
+
* Send message only if there is at least one finding with "Note" level.
|
|
481
|
+
*/
|
|
482
|
+
LevelNote = 14,
|
|
483
|
+
/**
|
|
484
|
+
* Send message only if there is at least one finding with "Note" level or
|
|
485
|
+
* higher, that includes "Note", "Warning" and "Error.
|
|
486
|
+
*/
|
|
487
|
+
LevelNoteOrHigher = 15,
|
|
488
|
+
/**
|
|
489
|
+
* Send message only if there is at least one finding with "None" level.
|
|
490
|
+
*/
|
|
491
|
+
LevelNone = 16,
|
|
492
|
+
/**
|
|
493
|
+
* Send message only if there is at least one finding with "None" level or
|
|
494
|
+
* higher, that includes "None", "Note", "Warning" and "Error.
|
|
495
|
+
*/
|
|
496
|
+
LevelNoneOrHigher = 17,
|
|
497
|
+
/**
|
|
498
|
+
* Send message only if there is at least one finding with "Unknown" level.
|
|
499
|
+
*/
|
|
500
|
+
LevelUnknown = 18,
|
|
501
|
+
/**
|
|
502
|
+
* Send message only if there is at least one finding with "Unknown" level or
|
|
503
|
+
* higher, that includes "Unknown", "None", "Note", "Warning" and "Error.
|
|
504
|
+
*/
|
|
505
|
+
LevelUnknownOrHigher = 19,
|
|
506
|
+
/**
|
|
507
|
+
* Always send a message.
|
|
508
|
+
*/
|
|
509
|
+
Always = 20,
|
|
510
|
+
/**
|
|
511
|
+
* Send a message if at least 1 vulnerability is found.
|
|
512
|
+
*/
|
|
513
|
+
Some = 21,
|
|
514
|
+
/**
|
|
515
|
+
* Send a message only if no vulnerabilities are found.
|
|
516
|
+
*/
|
|
517
|
+
Empty = 22,
|
|
518
|
+
/**
|
|
519
|
+
* Never send a message.
|
|
520
|
+
*/
|
|
521
|
+
Never = 23
|
|
522
|
+
}
|
|
523
|
+
|
|
262
524
|
/**
|
|
263
525
|
* Interface for a Slack message that can be sent.
|
|
264
526
|
* @public
|
|
@@ -269,10 +531,10 @@ export declare interface SlackMessage {
|
|
|
269
531
|
* @returns A promise that resolves to the response from the Slack webhook.
|
|
270
532
|
*/
|
|
271
533
|
send: () => Promise<string>;
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
534
|
+
withActor(actor?: string): void;
|
|
535
|
+
withFooter(text?: string, type?: FooterType): void;
|
|
536
|
+
withHeader(header?: string): void;
|
|
537
|
+
withRun(): void;
|
|
276
538
|
}
|
|
277
539
|
|
|
278
540
|
export { }
|