@fabasoad/sarif-to-slack 0.1.1 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/.github/ISSUE_TEMPLATE/bug_report.md +1 -1
  2. package/.github/pull_request_template.md +3 -3
  3. package/.github/workflows/linting.yml +14 -0
  4. package/.github/workflows/release.yml +5 -1
  5. package/.github/workflows/send-sarif-to-slack.yml +214 -0
  6. package/.github/workflows/unit-tests.yml +1 -0
  7. package/.pre-commit-config.yaml +3 -3
  8. package/.tool-versions +1 -1
  9. package/CONTRIBUTING.md +1 -1
  10. package/Makefile +10 -3
  11. package/README.md +36 -5
  12. package/biome.json +15 -12
  13. package/dist/Logger.js +17 -6
  14. package/dist/Processors.js +23 -22
  15. package/dist/SarifToSlackService.d.ts.map +1 -1
  16. package/dist/SarifToSlackService.js +6 -7
  17. package/dist/SlackMessageBuilder.js +51 -55
  18. package/dist/index.d.ts +9 -4
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +10 -5
  21. package/dist/model/SarifModelPerRun.d.ts +17 -0
  22. package/dist/model/SarifModelPerRun.d.ts.map +1 -0
  23. package/dist/model/SarifModelPerRun.js +84 -0
  24. package/dist/model/SarifModelPerSarif.d.ts +20 -0
  25. package/dist/model/SarifModelPerSarif.d.ts.map +1 -0
  26. package/dist/model/SarifModelPerSarif.js +97 -0
  27. package/dist/model/types.d.ts +17 -0
  28. package/dist/model/types.d.ts.map +1 -0
  29. package/dist/model/types.js +31 -0
  30. package/dist/sarif-to-slack.d.ts +121 -18
  31. package/dist/tsdoc-metadata.json +1 -1
  32. package/dist/types.d.ts +107 -15
  33. package/dist/types.d.ts.map +1 -1
  34. package/dist/types.js +73 -7
  35. package/dist/utils/SarifUtils.d.ts +5 -0
  36. package/dist/utils/SarifUtils.d.ts.map +1 -0
  37. package/dist/utils/SarifUtils.js +32 -0
  38. package/dist/utils/SortUtils.d.ts +5 -0
  39. package/dist/utils/SortUtils.d.ts.map +1 -0
  40. package/dist/utils/SortUtils.js +8 -0
  41. package/dist/version.d.ts +2 -0
  42. package/dist/version.d.ts.map +1 -0
  43. package/dist/version.js +4 -0
  44. package/etc/sarif-to-slack.api.md +47 -9
  45. package/jest.config.json +4 -4
  46. package/package.json +14 -10
  47. package/scripts/save-version.sh +6 -0
  48. package/src/Logger.ts +22 -17
  49. package/src/Processors.ts +22 -22
  50. package/src/SarifToSlackService.ts +6 -7
  51. package/src/SlackMessageBuilder.ts +85 -68
  52. package/src/index.ts +17 -6
  53. package/src/model/SarifModelPerRun.ts +114 -0
  54. package/src/model/SarifModelPerSarif.ts +116 -0
  55. package/src/model/types.ts +31 -0
  56. package/src/types.ts +113 -15
  57. package/src/utils/SarifUtils.ts +44 -0
  58. package/src/utils/SortUtils.ts +21 -0
  59. package/src/version.ts +3 -0
  60. package/test-data/sarif/codeql-csharp.sarif +1 -0
  61. package/test-data/sarif/codeql-go.sarif +1 -0
  62. package/test-data/sarif/codeql-python.sarif +1 -0
  63. package/test-data/sarif/codeql-ruby.sarif +1 -0
  64. package/test-data/sarif/codeql-typescript.sarif +1 -0
  65. package/test-data/sarif/grype-container.sarif +1774 -0
  66. package/test-data/sarif/runs-1-tools-1-results-0.sarif +18 -0
  67. package/test-data/sarif/runs-2-tools-1-results-0.sarif +30 -0
  68. package/test-data/sarif/runs-2-tools-1.sarif +656 -0
  69. package/test-data/sarif/runs-2-tools-2-results-0.sarif +44 -0
  70. package/test-data/sarif/runs-2-tools-2.sarif +686 -0
  71. package/test-data/sarif/runs-3-tools-2-results-0.sarif +48 -0
  72. package/test-data/sarif/runs-3-tools-2.sarif +278 -0
  73. package/test-data/sarif/snyk-composer.sarif +934 -0
  74. package/test-data/sarif/snyk-container.sarif +313 -0
  75. package/test-data/sarif/snyk-gomodules.sarif +388 -0
  76. package/test-data/sarif/snyk-gradle.sarif +274 -0
  77. package/test-data/sarif/snyk-hex.sarif +66 -0
  78. package/test-data/sarif/snyk-maven.sarif +274 -0
  79. package/test-data/sarif/snyk-npm.sarif +896 -0
  80. package/test-data/sarif/snyk-nuget.sarif +90 -0
  81. package/test-data/sarif/snyk-pip.sarif +66 -0
  82. package/test-data/sarif/snyk-pnpm.sarif +90 -0
  83. package/test-data/sarif/snyk-poetry.sarif +1952 -0
  84. package/test-data/sarif/snyk-rubygems.sarif +440 -0
  85. package/test-data/sarif/snyk-sbt.sarif +178 -0
  86. package/test-data/sarif/snyk-swift.sarif +112 -0
  87. package/test-data/sarif/snyk-yarn.sarif +2900 -0
  88. package/test-data/sarif/trivy-iac.sarif +134 -0
  89. package/test-data/sarif/wiz-container.sarif +30916 -0
  90. package/test-data/sarif/wiz-iac.sarif +558 -0
  91. package/tests/Processors.spec.ts +3 -3
  92. package/tests/integration/SendSarifToSlack.spec.ts +56 -0
  93. package/tsconfig.json +14 -14
  94. package/dist/Logger.js.map +0 -1
  95. package/dist/Processors.js.map +0 -1
  96. package/dist/SarifToSlackService.js.map +0 -1
  97. package/dist/SlackMessageBuilder.js.map +0 -1
  98. package/dist/index.js.map +0 -1
  99. package/dist/types.js.map +0 -1
@@ -7,12 +7,16 @@
7
7
  *
8
8
  * @example
9
9
  * ```typescript
10
- * import { SarifToSlackService } from 'sarif-to-slack';
10
+ * import { SarifToSlackService, FooterType } from '@fabasoad/sarif-to-slack';
11
11
  *
12
- * const service = new SarifToSlackService({
12
+ * const service = await SarifToSlackService.create({
13
13
  * webhookUrl: 'https://hooks.slack.com/services/your/webhook/url',
14
14
  * sarifPath: 'path/to/your/sarif/file.sarif',
15
- * logLevel: 'info',
15
+ * log: {
16
+ * level: 'info',
17
+ * template: '[{{logLevelName}}] [{{name}}] {{dateIsoStr}} ',
18
+ * colored: false,
19
+ * },
16
20
  * username: 'SARIF Bot',
17
21
  * iconUrl: 'https://example.com/icon.png',
18
22
  * color: '#36a64f',
@@ -22,6 +26,7 @@
22
26
  * },
23
27
  * footer: {
24
28
  * include: true,
29
+ * type: FooterType.PLAIN_TEXT,
25
30
  * value: 'Generated by @fabasoad/sarif-to-slack'
26
31
  * },
27
32
  * actor: {
@@ -42,12 +47,81 @@
42
47
 
43
48
  import type { Log } from 'sarif';
44
49
 
50
+ /**
51
+ * Enum representing how to calculate results.
52
+ * @public
53
+ */
54
+ export declare enum CalculateResultsBy {
55
+ /**
56
+ * Calculates results by the security level of the findings: Error, Warning,
57
+ * Note and Unknown. At first, it tries to get the security level from runs[].results[].level
58
+ * property. If it is not defined, it tries to get the security level from the
59
+ * respective rule of each result, using the rules[].properties['problem.severity']
60
+ * property.
61
+ */
62
+ Level = 0,
63
+ /**
64
+ * Calculates results by the security severity of the findings: Critical, High,
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.
69
+ */
70
+ Severity = 1
71
+ }
72
+
73
+ /**
74
+ * Options for the footer of a Slack message. "type" is ignored if "value" is
75
+ * not defined.
76
+ * @public
77
+ */
78
+ export declare type FooterOptions = IncludeAwareWithValueOptions & {
79
+ type?: FooterType;
80
+ };
81
+
82
+ /**
83
+ * Enum representing the type of footer in a Slack message.
84
+ * @public
85
+ */
86
+ export declare enum FooterType {
87
+ /**
88
+ * Represents a plain text footer. Text is not formatted and appears as-is.
89
+ */
90
+ PlainText = "plain_text",
91
+ /**
92
+ * Represents a footer with Markdown formatting. Text can include formatting
93
+ * such as bold, italics, and links.
94
+ */
95
+ Markdown = "mrkdwn"
96
+ }
97
+
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
+
45
119
  /**
46
120
  * Type representing properties that indicate whether to include certain information
47
121
  * in the Slack message.
48
122
  * @public
49
123
  */
50
- export declare type IncludeAwareProps = {
124
+ export declare type IncludeAwareOptions = {
51
125
  include: boolean;
52
126
  };
53
127
 
@@ -56,7 +130,7 @@ export declare type IncludeAwareProps = {
56
130
  * in the Slack message, along with an optional value.
57
131
  * @public
58
132
  */
59
- export declare type IncludeAwareWithValueProps = IncludeAwareProps & {
133
+ export declare type IncludeAwareWithValueOptions = IncludeAwareOptions & {
60
134
  value?: string;
61
135
  };
62
136
 
@@ -66,7 +140,8 @@ export declare type IncludeAwareWithValueProps = IncludeAwareProps & {
66
140
  */
67
141
  export declare enum LogLevel {
68
142
  /**
69
- * Represents the most verbose logging level, typically used for detailed debugging information.
143
+ * Represents the most verbose logging level, typically used for detailed
144
+ * debugging information.
70
145
  */
71
146
  Silly = 0,
72
147
  /**
@@ -74,32 +149,59 @@ export declare enum LogLevel {
74
149
  */
75
150
  Trace = 1,
76
151
  /**
77
- * Represents a logging level for debugging information that is less verbose than silly.
152
+ * Represents a logging level for debugging information that is less verbose
153
+ * than silly.
78
154
  */
79
155
  Debug = 2,
80
156
  /**
81
- * Represents a logging level for general informational messages that highlight the progress of the application.
157
+ * Represents a logging level for general informational messages that highlight
158
+ * the progress of the application.
82
159
  */
83
160
  Info = 3,
84
161
  /**
85
- * Represents a logging level for potentially harmful situations that require attention.
162
+ * Represents a logging level for potentially harmful situations that require
163
+ * attention.
86
164
  */
87
165
  Warning = 4,
88
166
  /**
89
- * Represents a logging level for error conditions that do not require immediate action but should be noted.
167
+ * Represents a logging level for error conditions that do not require immediate
168
+ * action but should be noted.
90
169
  */
91
170
  Error = 5,
92
171
  /**
93
- * Represents a logging level for critical errors that require immediate attention and may cause the application to terminate.
172
+ * Represents a logging level for critical errors that require immediate attention
173
+ * and may cause the application to terminate.
94
174
  */
95
175
  Fatal = 6
96
176
  }
97
177
 
178
+ /**
179
+ * Options for logging.
180
+ * @public
181
+ */
182
+ export declare type LogOptions = {
183
+ level?: LogLevel;
184
+ /**
185
+ * More details here: https://github.com/fullstack-build/tslog?tab=readme-ov-file#pretty-templates-and-styles-color-settings
186
+ */
187
+ template?: string;
188
+ colored?: boolean;
189
+ };
190
+
98
191
  /**
99
192
  * Type representing a SARIF log.
100
193
  * @public
101
194
  */
102
- export declare type Sarif = Log;
195
+ export declare type SarifLog = Log;
196
+
197
+ /**
198
+ * Options for how to output the results in the Slack message.
199
+ * @public
200
+ */
201
+ export declare type SarifToSlackOutput = {
202
+ groupBy: GroupResultsBy;
203
+ calculateBy: CalculateResultsBy;
204
+ };
103
205
 
104
206
  /**
105
207
  * Service to convert SARIF files to Slack messages and send them.
@@ -149,11 +251,12 @@ export declare type SarifToSlackServiceOptions = {
149
251
  username?: string;
150
252
  iconUrl?: string;
151
253
  color?: string;
152
- logLevel?: LogLevel | string;
153
- header?: IncludeAwareWithValueProps;
154
- footer?: IncludeAwareWithValueProps;
155
- actor?: IncludeAwareWithValueProps;
156
- run?: IncludeAwareProps;
254
+ log?: LogOptions;
255
+ header?: IncludeAwareWithValueOptions;
256
+ footer?: FooterOptions;
257
+ actor?: IncludeAwareWithValueOptions;
258
+ run?: IncludeAwareOptions;
259
+ output?: SarifToSlackOutput;
157
260
  };
158
261
 
159
262
  /**
@@ -169,7 +272,7 @@ export declare interface SlackMessage {
169
272
  /**
170
273
  * The SARIF log associated with this Slack message.
171
274
  */
172
- sarif: Sarif;
275
+ sarif: SarifLog;
173
276
  }
174
277
 
175
278
  export { }
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.52.8"
8
+ "packageVersion": "7.52.9"
9
9
  }
10
10
  ]
11
11
  }
package/dist/types.d.ts CHANGED
@@ -3,7 +3,7 @@ import type { Log } from 'sarif';
3
3
  * Type representing a SARIF log.
4
4
  * @public
5
5
  */
6
- export type Sarif = Log;
6
+ export type SarifLog = Log;
7
7
  /**
8
8
  * Interface for a Slack message that can be sent.
9
9
  * @public
@@ -17,7 +17,7 @@ export interface SlackMessage {
17
17
  /**
18
18
  * The SARIF log associated with this Slack message.
19
19
  */
20
- sarif: Sarif;
20
+ sarif: SarifLog;
21
21
  }
22
22
  /**
23
23
  * Enum representing log levels for the service.
@@ -25,7 +25,8 @@ export interface SlackMessage {
25
25
  */
26
26
  export declare enum LogLevel {
27
27
  /**
28
- * Represents the most verbose logging level, typically used for detailed debugging information.
28
+ * Represents the most verbose logging level, typically used for detailed
29
+ * debugging information.
29
30
  */
30
31
  Silly = 0,
31
32
  /**
@@ -33,23 +34,28 @@ export declare enum LogLevel {
33
34
  */
34
35
  Trace = 1,
35
36
  /**
36
- * Represents a logging level for debugging information that is less verbose than silly.
37
+ * Represents a logging level for debugging information that is less verbose
38
+ * than silly.
37
39
  */
38
40
  Debug = 2,
39
41
  /**
40
- * Represents a logging level for general informational messages that highlight the progress of the application.
42
+ * Represents a logging level for general informational messages that highlight
43
+ * the progress of the application.
41
44
  */
42
45
  Info = 3,
43
46
  /**
44
- * Represents a logging level for potentially harmful situations that require attention.
47
+ * Represents a logging level for potentially harmful situations that require
48
+ * attention.
45
49
  */
46
50
  Warning = 4,
47
51
  /**
48
- * Represents a logging level for error conditions that do not require immediate action but should be noted.
52
+ * Represents a logging level for error conditions that do not require immediate
53
+ * action but should be noted.
49
54
  */
50
55
  Error = 5,
51
56
  /**
52
- * Represents a logging level for critical errors that require immediate attention and may cause the application to terminate.
57
+ * Represents a logging level for critical errors that require immediate attention
58
+ * and may cause the application to terminate.
53
59
  */
54
60
  Fatal = 6
55
61
  }
@@ -58,7 +64,7 @@ export declare enum LogLevel {
58
64
  * in the Slack message.
59
65
  * @public
60
66
  */
61
- export type IncludeAwareProps = {
67
+ export type IncludeAwareOptions = {
62
68
  include: boolean;
63
69
  };
64
70
  /**
@@ -66,9 +72,94 @@ export type IncludeAwareProps = {
66
72
  * in the Slack message, along with an optional value.
67
73
  * @public
68
74
  */
69
- export type IncludeAwareWithValueProps = IncludeAwareProps & {
75
+ export type IncludeAwareWithValueOptions = IncludeAwareOptions & {
70
76
  value?: string;
71
77
  };
78
+ /**
79
+ * Enum representing the type of footer in a Slack message.
80
+ * @public
81
+ */
82
+ export declare enum FooterType {
83
+ /**
84
+ * Represents a plain text footer. Text is not formatted and appears as-is.
85
+ */
86
+ PlainText = "plain_text",
87
+ /**
88
+ * Represents a footer with Markdown formatting. Text can include formatting
89
+ * such as bold, italics, and links.
90
+ */
91
+ Markdown = "mrkdwn"
92
+ }
93
+ /**
94
+ * Options for the footer of a Slack message. "type" is ignored if "value" is
95
+ * not defined.
96
+ * @public
97
+ */
98
+ export type FooterOptions = IncludeAwareWithValueOptions & {
99
+ type?: FooterType;
100
+ };
101
+ /**
102
+ * Enum representing how to group results.
103
+ * @public
104
+ */
105
+ export declare enum GroupResultsBy {
106
+ /**
107
+ * Groups results by the tool name. Particularly, groups by the runs[].tool.driver.name
108
+ * property from the SARIF file(s).
109
+ */
110
+ ToolName = 0,
111
+ /**
112
+ * Groups results by the run. It provides the result from each run individually.
113
+ */
114
+ Run = 1,
115
+ /**
116
+ * Does not group results. It provides the result from all the runs from all
117
+ * the provided SARIF files.
118
+ */
119
+ Total = 2
120
+ }
121
+ /**
122
+ * Enum representing how to calculate results.
123
+ * @public
124
+ */
125
+ export declare enum CalculateResultsBy {
126
+ /**
127
+ * Calculates results by the security level of the findings: Error, Warning,
128
+ * Note and Unknown. At first, it tries to get the security level from runs[].results[].level
129
+ * property. If it is not defined, it tries to get the security level from the
130
+ * respective rule of each result, using the rules[].properties['problem.severity']
131
+ * property.
132
+ */
133
+ Level = 0,
134
+ /**
135
+ * Calculates results by the security severity of the findings: Critical, High,
136
+ * Medium, Low, None and Unknown. it tries to get the security severity from the
137
+ * respective rule of each result, using the rules[].properties['security-severity']
138
+ * property. This property contains CVSS score, which is then mapped to the
139
+ * security severity value.
140
+ */
141
+ Severity = 1
142
+ }
143
+ /**
144
+ * Options for how to output the results in the Slack message.
145
+ * @public
146
+ */
147
+ export type SarifToSlackOutput = {
148
+ groupBy: GroupResultsBy;
149
+ calculateBy: CalculateResultsBy;
150
+ };
151
+ /**
152
+ * Options for logging.
153
+ * @public
154
+ */
155
+ export type LogOptions = {
156
+ level?: LogLevel;
157
+ /**
158
+ * More details here: https://github.com/fullstack-build/tslog?tab=readme-ov-file#pretty-templates-and-styles-color-settings
159
+ */
160
+ template?: string;
161
+ colored?: boolean;
162
+ };
72
163
  /**
73
164
  * Options for the SarifToSlackService.
74
165
  * @public
@@ -79,10 +170,11 @@ export type SarifToSlackServiceOptions = {
79
170
  username?: string;
80
171
  iconUrl?: string;
81
172
  color?: string;
82
- logLevel?: LogLevel | string;
83
- header?: IncludeAwareWithValueProps;
84
- footer?: IncludeAwareWithValueProps;
85
- actor?: IncludeAwareWithValueProps;
86
- run?: IncludeAwareProps;
173
+ log?: LogOptions;
174
+ header?: IncludeAwareWithValueOptions;
175
+ footer?: FooterOptions;
176
+ actor?: IncludeAwareWithValueOptions;
177
+ run?: IncludeAwareOptions;
178
+ output?: SarifToSlackOutput;
87
179
  };
88
180
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAEhC;;;GAGG;AACH,MAAM,MAAM,KAAK,GAAG,GAAG,CAAA;AAEvB;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,IAAI,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAA;IAC3B;;OAEG;IACH,KAAK,EAAE,KAAK,CAAA;CACb;AAED;;;GAGG;AACH,oBAAY,QAAQ;IAClB;;OAEG;IACH,KAAK,IAAI;IACT;;OAEG;IACH,KAAK,IAAI;IACT;;OAEG;IACH,KAAK,IAAI;IACT;;OAEG;IACH,IAAI,IAAI;IACR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,CAAC,EAAE,UAAU,CAAC;IACjB,MAAM,CAAC,EAAE,4BAA4B,CAAC;IACtC,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,KAAK,CAAC,EAAE,4BAA4B,CAAC;IACrC,GAAG,CAAC,EAAE,mBAAmB,CAAC;IAC1B,MAAM,CAAC,EAAE,kBAAkB,CAAC;CAC7B,CAAA"}
package/dist/types.js CHANGED
@@ -5,7 +5,8 @@
5
5
  export var LogLevel;
6
6
  (function (LogLevel) {
7
7
  /**
8
- * Represents the most verbose logging level, typically used for detailed debugging information.
8
+ * Represents the most verbose logging level, typically used for detailed
9
+ * debugging information.
9
10
  */
10
11
  LogLevel[LogLevel["Silly"] = 0] = "Silly";
11
12
  /**
@@ -13,24 +14,89 @@ export var LogLevel;
13
14
  */
14
15
  LogLevel[LogLevel["Trace"] = 1] = "Trace";
15
16
  /**
16
- * Represents a logging level for debugging information that is less verbose than silly.
17
+ * Represents a logging level for debugging information that is less verbose
18
+ * than silly.
17
19
  */
18
20
  LogLevel[LogLevel["Debug"] = 2] = "Debug";
19
21
  /**
20
- * Represents a logging level for general informational messages that highlight the progress of the application.
22
+ * Represents a logging level for general informational messages that highlight
23
+ * the progress of the application.
21
24
  */
22
25
  LogLevel[LogLevel["Info"] = 3] = "Info";
23
26
  /**
24
- * Represents a logging level for potentially harmful situations that require attention.
27
+ * Represents a logging level for potentially harmful situations that require
28
+ * attention.
25
29
  */
26
30
  LogLevel[LogLevel["Warning"] = 4] = "Warning";
27
31
  /**
28
- * Represents a logging level for error conditions that do not require immediate action but should be noted.
32
+ * Represents a logging level for error conditions that do not require immediate
33
+ * action but should be noted.
29
34
  */
30
35
  LogLevel[LogLevel["Error"] = 5] = "Error";
31
36
  /**
32
- * Represents a logging level for critical errors that require immediate attention and may cause the application to terminate.
37
+ * Represents a logging level for critical errors that require immediate attention
38
+ * and may cause the application to terminate.
33
39
  */
34
40
  LogLevel[LogLevel["Fatal"] = 6] = "Fatal";
35
41
  })(LogLevel || (LogLevel = {}));
36
- //# sourceMappingURL=types.js.map
42
+ /**
43
+ * Enum representing the type of footer in a Slack message.
44
+ * @public
45
+ */
46
+ export var FooterType;
47
+ (function (FooterType) {
48
+ /**
49
+ * Represents a plain text footer. Text is not formatted and appears as-is.
50
+ */
51
+ FooterType["PlainText"] = "plain_text";
52
+ /**
53
+ * Represents a footer with Markdown formatting. Text can include formatting
54
+ * such as bold, italics, and links.
55
+ */
56
+ FooterType["Markdown"] = "mrkdwn";
57
+ })(FooterType || (FooterType = {}));
58
+ /**
59
+ * Enum representing how to group results.
60
+ * @public
61
+ */
62
+ export var GroupResultsBy;
63
+ (function (GroupResultsBy) {
64
+ /**
65
+ * Groups results by the tool name. Particularly, groups by the runs[].tool.driver.name
66
+ * property from the SARIF file(s).
67
+ */
68
+ GroupResultsBy[GroupResultsBy["ToolName"] = 0] = "ToolName";
69
+ /**
70
+ * Groups results by the run. It provides the result from each run individually.
71
+ */
72
+ GroupResultsBy[GroupResultsBy["Run"] = 1] = "Run";
73
+ /**
74
+ * Does not group results. It provides the result from all the runs from all
75
+ * the provided SARIF files.
76
+ */
77
+ GroupResultsBy[GroupResultsBy["Total"] = 2] = "Total";
78
+ })(GroupResultsBy || (GroupResultsBy = {}));
79
+ /**
80
+ * Enum representing how to calculate results.
81
+ * @public
82
+ */
83
+ export var CalculateResultsBy;
84
+ (function (CalculateResultsBy) {
85
+ /**
86
+ * Calculates results by the security level of the findings: Error, Warning,
87
+ * Note and Unknown. At first, it tries to get the security level from runs[].results[].level
88
+ * property. If it is not defined, it tries to get the security level from the
89
+ * respective rule of each result, using the rules[].properties['problem.severity']
90
+ * property.
91
+ */
92
+ CalculateResultsBy[CalculateResultsBy["Level"] = 0] = "Level";
93
+ /**
94
+ * Calculates results by the security severity of the findings: Critical, High,
95
+ * Medium, Low, None and Unknown. it tries to get the security severity from the
96
+ * respective rule of each result, using the rules[].properties['security-severity']
97
+ * property. This property contains CVSS score, which is then mapped to the
98
+ * security severity value.
99
+ */
100
+ CalculateResultsBy[CalculateResultsBy["Severity"] = 1] = "Severity";
101
+ })(CalculateResultsBy || (CalculateResultsBy = {}));
102
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvdHlwZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBd0JBOzs7R0FHRztBQUNILE1BQU0sQ0FBTixJQUFZLFFBbUNYO0FBbkNELFdBQVksUUFBUTtJQUNsQjs7O09BR0c7SUFDSCx5Q0FBUyxDQUFBO0lBQ1Q7O09BRUc7SUFDSCx5Q0FBUyxDQUFBO0lBQ1Q7OztPQUdHO0lBQ0gseUNBQVMsQ0FBQTtJQUNUOzs7T0FHRztJQUNILHVDQUFRLENBQUE7SUFDUjs7O09BR0c7SUFDSCw2Q0FBVyxDQUFBO0lBQ1g7OztPQUdHO0lBQ0gseUNBQVMsQ0FBQTtJQUNUOzs7T0FHRztJQUNILHlDQUFTLENBQUE7QUFDWCxDQUFDLEVBbkNXLFFBQVEsS0FBUixRQUFRLFFBbUNuQjtBQW9CRDs7O0dBR0c7QUFDSCxNQUFNLENBQU4sSUFBWSxVQVVYO0FBVkQsV0FBWSxVQUFVO0lBQ3BCOztPQUVHO0lBQ0gsc0NBQXdCLENBQUE7SUFDeEI7OztPQUdHO0lBQ0gsaUNBQW1CLENBQUE7QUFDckIsQ0FBQyxFQVZXLFVBQVUsS0FBVixVQUFVLFFBVXJCO0FBV0Q7OztHQUdHO0FBQ0gsTUFBTSxDQUFOLElBQVksY0FlWDtBQWZELFdBQVksY0FBYztJQUN4Qjs7O09BR0c7SUFDSCwyREFBWSxDQUFBO0lBQ1o7O09BRUc7SUFDSCxpREFBTyxDQUFBO0lBQ1A7OztPQUdHO0lBQ0gscURBQVMsQ0FBQTtBQUNYLENBQUMsRUFmVyxjQUFjLEtBQWQsY0FBYyxRQWV6QjtBQUVEOzs7R0FHRztBQUNILE1BQU0sQ0FBTixJQUFZLGtCQWlCWDtBQWpCRCxXQUFZLGtCQUFrQjtJQUM1Qjs7Ozs7O09BTUc7SUFDSCw2REFBUyxDQUFBO0lBQ1Q7Ozs7OztPQU1HO0lBQ0gsbUVBQVksQ0FBQTtBQUNkLENBQUMsRUFqQlcsa0JBQWtCLEtBQWxCLGtCQUFrQixRQWlCN0IifQ==
@@ -0,0 +1,5 @@
1
+ import type { ReportingDescriptor, Result, Run } from "sarif";
2
+ export declare function findRuleByResult(run: Run, result: Result): ReportingDescriptor | undefined;
3
+ export type RuleProperty = 'security-severity' | 'problem.severity';
4
+ export declare function tryGetRulePropertyByResult<T>(run: Run, result: Result, propertyName: RuleProperty): T | undefined;
5
+ //# sourceMappingURL=SarifUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SarifUtils.d.ts","sourceRoot":"","sources":["../../src/utils/SarifUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAE9D,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,GAAG,mBAAmB,GAAG,SAAS,CA8B1F;AAED,MAAM,MAAM,YAAY,GAAG,mBAAmB,GAAG,kBAAkB,CAAA;AAEnE,wBAAgB,0BAA0B,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,GAAG,CAAC,GAAG,SAAS,CAOjH"}
@@ -0,0 +1,32 @@
1
+ export function findRuleByResult(run, result) {
2
+ const ruleData = {};
3
+ if (result.rule) {
4
+ if (result.rule?.index) {
5
+ ruleData.index = result.rule.index;
6
+ }
7
+ if (result.rule?.id) {
8
+ ruleData.id = result.rule.id;
9
+ }
10
+ }
11
+ if (!ruleData.index && result.ruleIndex) {
12
+ ruleData.index = result.ruleIndex;
13
+ }
14
+ if (ruleData.index
15
+ && run.tool.driver?.rules
16
+ && ruleData.index < run.tool.driver.rules.length) {
17
+ return run.tool.driver.rules[ruleData.index];
18
+ }
19
+ // If failed to find rule by index then try to find by ruleId
20
+ if (result.ruleId && run.tool.driver?.rules) {
21
+ return run.tool.driver.rules.find((r) => r.id === result.ruleId);
22
+ }
23
+ return undefined;
24
+ }
25
+ export function tryGetRulePropertyByResult(run, result, propertyName) {
26
+ const rule = findRuleByResult(run, result);
27
+ if (rule && rule.properties && propertyName in rule.properties) {
28
+ return rule.properties[propertyName];
29
+ }
30
+ return undefined;
31
+ }
32
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiU2FyaWZVdGlscy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlscy9TYXJpZlV0aWxzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUVBLE1BQU0sVUFBVSxnQkFBZ0IsQ0FBQyxHQUFRLEVBQUUsTUFBYztJQUN2RCxNQUFNLFFBQVEsR0FBb0MsRUFBRSxDQUFBO0lBRXBELElBQUksTUFBTSxDQUFDLElBQUksRUFBRSxDQUFDO1FBQ2hCLElBQUksTUFBTSxDQUFDLElBQUksRUFBRSxLQUFLLEVBQUUsQ0FBQztZQUN2QixRQUFRLENBQUMsS0FBSyxHQUFHLE1BQU0sQ0FBQyxJQUFJLENBQUMsS0FBSyxDQUFBO1FBQ3BDLENBQUM7UUFDRCxJQUFJLE1BQU0sQ0FBQyxJQUFJLEVBQUUsRUFBRSxFQUFFLENBQUM7WUFDcEIsUUFBUSxDQUFDLEVBQUUsR0FBRyxNQUFNLENBQUMsSUFBSSxDQUFDLEVBQUUsQ0FBQTtRQUM5QixDQUFDO0lBQ0gsQ0FBQztJQUVELElBQUksQ0FBQyxRQUFRLENBQUMsS0FBSyxJQUFJLE1BQU0sQ0FBQyxTQUFTLEVBQUUsQ0FBQztRQUN4QyxRQUF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BQztJQUVELE9BQU8sU0FBUyxDQUFBO0FBQ2xCLENBQUMifQ==
@@ -0,0 +1,5 @@
1
+ import { Map as ImmutableMap } from 'immutable';
2
+ import { SecurityLevel, SecuritySeverity } from '../model/types';
3
+ export declare function sortSecurityLevelMap(map: ImmutableMap<SecurityLevel, number>): ImmutableMap<SecurityLevel, number>;
4
+ export declare function sortSecuritySeverityMap(map: ImmutableMap<SecuritySeverity, number>): ImmutableMap<SecuritySeverity, number>;
5
+ //# sourceMappingURL=SortUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SortUtils.d.ts","sourceRoot":"","sources":["../../src/utils/SortUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,IAAI,YAAY,EAAE,MAAM,WAAW,CAAA;AAC/C,OAAO,EACL,aAAa,EAEb,gBAAgB,EAEjB,MAAM,gBAAgB,CAAA;AAEvB,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,YAAY,CAAC,aAAa,EAAE,MAAM,CAAC,GAAG,YAAY,CAAC,aAAa,EAAE,MAAM,CAAC,CAKlH;AAED,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,YAAY,CAAC,gBAAgB,EAAE,MAAM,CAAC,GAAG,YAAY,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAK3H"}
@@ -0,0 +1,8 @@
1
+ import { SecurityLevelOrder, SecuritySeverityOrder } from '../model/types';
2
+ export function sortSecurityLevelMap(map) {
3
+ return map.sortBy((_, level) => level, (a, b) => SecurityLevelOrder.indexOf(a) - SecurityLevelOrder.indexOf(b)).asImmutable();
4
+ }
5
+ export function sortSecuritySeverityMap(map) {
6
+ return map.sortBy((_, severity) => severity, (a, b) => SecuritySeverityOrder.indexOf(a) - SecuritySeverityOrder.indexOf(b)).asImmutable();
7
+ }
8
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiU29ydFV0aWxzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3V0aWxzL1NvcnRVdGlscy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxPQUFPLEVBRUwsa0JBQWtCLEVBRWxCLHFCQUFxQixFQUN0QixNQUFNLGdCQUFnQixDQUFBO0FBRXZCLE1BQU0sVUFBVSxvQkFBb0IsQ0FBQyxHQUF3QztJQUMzRSxPQUFPLEdBQUcsQ0FBQyxNQUFNLENBQ2YsQ0FBQyxDQUFTLEVBQUUsS0FBb0IsRUFBaUIsRUFBRSxDQUFDLEtBQUssRUFDekQsQ0FBQyxDQUFnQixFQUFFLENBQWdCLEVBQVUsRUFBRSxDQUFDLGtCQUFrQixDQUFDLE9BQU8sQ0FBQyxDQUFDLENBQUMsR0FBRyxrQkFBa0IsQ0FBQyxPQUFPLENBQUMsQ0FBQyxDQUFDLENBQzlHLENBQUMsV0FBVyxFQUFFLENBQUE7QUFDakIsQ0FBQztBQUVELE1BQU0sVUFBVSx1QkFBdUIsQ0FBQyxHQUEyQztJQUNqRixPQUFPLEdBQUcsQ0FBQyxNQUFNLENBQ2YsQ0FBQyxDQUFTLEVBQUUsUUFBMEIsRUFBb0IsRUFBRSxDQUFDLFFBQVEsRUFDckUsQ0FBQyxDQUFtQixFQUFFLENBQW1CLEVBQVUsRUFBRSxDQUFDLHFCQUFxQixDQUFDLE9BQU8sQ0FBQyxDQUFDLENBQUMsR0FBRyxxQkFBcUIsQ0FBQyxPQUFPLENBQUMsQ0FBQyxDQUFDLENBQzFILENBQUMsV0FBVyxFQUFFLENBQUE7QUFDakIsQ0FBQyJ9
@@ -0,0 +1,2 @@
1
+ export declare const LIB_VERSION = "0.2.1";
2
+ //# sourceMappingURL=version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,WAAW,UAAU,CAAA"}
@@ -0,0 +1,4 @@
1
+ // This file is autogenerated by scripts/save-version.sh
2
+ // Do not edit it manually!
3
+ export const LIB_VERSION = '0.2.1';
4
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmVyc2lvbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy92ZXJzaW9uLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLHdEQUF3RDtBQUN4RCwyQkFBMkI7QUFDM0IsTUFBTSxDQUFDLE1BQU0sV0FBVyxHQUFHLE9BQU8sQ0FBQSJ9