@fabasoad/sarif-to-slack 0.2.0 → 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 (84) hide show
  1. package/.github/workflows/release.yml +3 -1
  2. package/.github/workflows/send-sarif-to-slack.yml +214 -0
  3. package/.pre-commit-config.yaml +3 -3
  4. package/.tool-versions +1 -1
  5. package/Makefile +9 -2
  6. package/README.md +1 -1
  7. package/dist/Logger.js +15 -6
  8. package/dist/Processors.js +23 -22
  9. package/dist/SarifToSlackService.d.ts.map +1 -1
  10. package/dist/SarifToSlackService.js +5 -6
  11. package/dist/SlackMessageBuilder.js +46 -52
  12. package/dist/index.d.ts +6 -2
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +7 -3
  15. package/dist/model/SarifModelPerRun.d.ts +17 -0
  16. package/dist/model/SarifModelPerRun.d.ts.map +1 -0
  17. package/dist/model/SarifModelPerRun.js +84 -0
  18. package/dist/model/SarifModelPerSarif.d.ts +20 -0
  19. package/dist/model/SarifModelPerSarif.d.ts.map +1 -0
  20. package/dist/model/SarifModelPerSarif.js +97 -0
  21. package/dist/model/types.d.ts +17 -0
  22. package/dist/model/types.d.ts.map +1 -0
  23. package/dist/model/types.js +31 -0
  24. package/dist/sarif-to-slack.d.ts +96 -12
  25. package/dist/tsdoc-metadata.json +1 -1
  26. package/dist/types.d.ts +87 -11
  27. package/dist/types.d.ts.map +1 -1
  28. package/dist/types.js +66 -9
  29. package/dist/utils/SarifUtils.d.ts +5 -0
  30. package/dist/utils/SarifUtils.d.ts.map +1 -0
  31. package/dist/utils/SarifUtils.js +32 -0
  32. package/dist/utils/SortUtils.d.ts +5 -0
  33. package/dist/utils/SortUtils.d.ts.map +1 -0
  34. package/dist/utils/SortUtils.js +8 -0
  35. package/dist/version.d.ts +1 -1
  36. package/dist/version.js +1 -1
  37. package/etc/sarif-to-slack.api.md +32 -7
  38. package/jest.config.json +4 -4
  39. package/package.json +9 -7
  40. package/src/Logger.ts +20 -17
  41. package/src/Processors.ts +22 -22
  42. package/src/SarifToSlackService.ts +5 -6
  43. package/src/SlackMessageBuilder.ts +78 -63
  44. package/src/index.ts +10 -2
  45. package/src/model/SarifModelPerRun.ts +114 -0
  46. package/src/model/SarifModelPerSarif.ts +116 -0
  47. package/src/model/types.ts +31 -0
  48. package/src/types.ts +91 -11
  49. package/src/utils/SarifUtils.ts +44 -0
  50. package/src/utils/SortUtils.ts +21 -0
  51. package/src/version.ts +1 -1
  52. package/test-data/sarif/codeql-csharp.sarif +1 -0
  53. package/test-data/sarif/codeql-go.sarif +1 -0
  54. package/test-data/sarif/codeql-python.sarif +1 -0
  55. package/test-data/sarif/codeql-ruby.sarif +1 -0
  56. package/test-data/sarif/codeql-typescript.sarif +1 -0
  57. package/test-data/sarif/grype-container.sarif +1774 -0
  58. package/test-data/sarif/runs-1-tools-1-results-0.sarif +18 -0
  59. package/test-data/sarif/runs-2-tools-1-results-0.sarif +30 -0
  60. package/test-data/sarif/runs-2-tools-1.sarif +656 -0
  61. package/test-data/sarif/runs-2-tools-2-results-0.sarif +44 -0
  62. package/test-data/sarif/runs-2-tools-2.sarif +686 -0
  63. package/test-data/sarif/runs-3-tools-2-results-0.sarif +48 -0
  64. package/test-data/sarif/runs-3-tools-2.sarif +278 -0
  65. package/test-data/sarif/snyk-composer.sarif +934 -0
  66. package/test-data/sarif/snyk-container.sarif +313 -0
  67. package/test-data/sarif/snyk-gomodules.sarif +388 -0
  68. package/test-data/sarif/snyk-gradle.sarif +274 -0
  69. package/test-data/sarif/snyk-hex.sarif +66 -0
  70. package/test-data/sarif/snyk-maven.sarif +274 -0
  71. package/test-data/sarif/snyk-npm.sarif +896 -0
  72. package/test-data/sarif/snyk-nuget.sarif +90 -0
  73. package/test-data/sarif/snyk-pip.sarif +66 -0
  74. package/test-data/sarif/snyk-pnpm.sarif +90 -0
  75. package/test-data/sarif/snyk-poetry.sarif +1952 -0
  76. package/test-data/sarif/snyk-rubygems.sarif +440 -0
  77. package/test-data/sarif/snyk-sbt.sarif +178 -0
  78. package/test-data/sarif/snyk-swift.sarif +112 -0
  79. package/test-data/sarif/snyk-yarn.sarif +2900 -0
  80. package/test-data/sarif/trivy-iac.sarif +134 -0
  81. package/test-data/sarif/wiz-container.sarif +30916 -0
  82. package/test-data/sarif/wiz-iac.sarif +558 -0
  83. package/tests/Processors.spec.ts +3 -3
  84. package/tests/integration/SendSarifToSlack.spec.ts +56 -0
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
  }
@@ -74,8 +80,15 @@ export type IncludeAwareWithValueOptions = IncludeAwareOptions & {
74
80
  * @public
75
81
  */
76
82
  export declare enum FooterType {
77
- PLAIN_TEXT = "plain_text",
78
- MARKDOWN = "mrkdwn"
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"
79
92
  }
80
93
  /**
81
94
  * Options for the footer of a Slack message. "type" is ignored if "value" is
@@ -85,6 +98,68 @@ export declare enum FooterType {
85
98
  export type FooterOptions = IncludeAwareWithValueOptions & {
86
99
  type?: FooterType;
87
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
+ };
88
163
  /**
89
164
  * Options for the SarifToSlackService.
90
165
  * @public
@@ -95,10 +170,11 @@ export type SarifToSlackServiceOptions = {
95
170
  username?: string;
96
171
  iconUrl?: string;
97
172
  color?: string;
98
- logLevel?: LogLevel | string;
173
+ log?: LogOptions;
99
174
  header?: IncludeAwareWithValueOptions;
100
175
  footer?: FooterOptions;
101
176
  actor?: IncludeAwareWithValueOptions;
102
177
  run?: IncludeAwareOptions;
178
+ output?: SarifToSlackOutput;
103
179
  };
104
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;I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EAAE,OAAO,CAAC;CACnB,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,0BAA0B,GAAG;IAEvC,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,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,23 +14,28 @@ 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 = {}));
@@ -39,7 +45,58 @@ export var LogLevel;
39
45
  */
40
46
  export var FooterType;
41
47
  (function (FooterType) {
42
- FooterType["PLAIN_TEXT"] = "plain_text";
43
- FooterType["MARKDOWN"] = "mrkdwn";
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";
44
57
  })(FooterType || (FooterType = {}));
45
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvdHlwZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBd0JBOzs7R0FHRztBQUNILE1BQU0sQ0FBTixJQUFZLFFBNkJYO0FBN0JELFdBQVksUUFBUTtJQUNsQjs7T0FFRztJQUNILHlDQUFTLENBQUE7SUFDVDs7T0FFRztJQUNILHlDQUFTLENBQUE7SUFDVDs7T0FFRztJQUNILHlDQUFTLENBQUE7SUFDVDs7T0FFRztJQUNILHVDQUFRLENBQUE7SUFDUjs7T0FFRztJQUNILDZDQUFXLENBQUE7SUFDWDs7T0FFRztJQUNILHlDQUFTLENBQUE7SUFDVDs7T0FFRztJQUNILHlDQUFTLENBQUE7QUFDWCxDQUFDLEVBN0JXLFFBQVEsS0FBUixRQUFRLFFBNkJuQjtBQW9CRDs7O0dBR0c7QUFDSCxNQUFNLENBQU4sSUFBWSxVQUdYO0FBSEQsV0FBWSxVQUFVO0lBQ3BCLHVDQUF5QixDQUFBO0lBQ3pCLGlDQUFtQixDQUFBO0FBQ3JCLENBQUMsRUFIVyxVQUFVLEtBQVYsVUFBVSxRQUdyQiJ9
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,eyJ2ZXJzaW9uIjozLCJmaWxl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ozs7OztPQU1HO0lBQ0gsbUVBQVksQ0FBQTtBQUNkLENBQUMsRUFqQlcsa0JBQWtCLEtBQWxCLGtCQUFrQixRQWlCN0IifQ==
@@ -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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiU2FyaWZVdGlscy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlscy9TYXJpZlV0aWxzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUVBLE1BQU0sVUFBVSxnQkFBZ0IsQ0FBQyxHQUFRLEVBQUUsTUFBYztJQUN2RCxNQUFNLFFBQVEsR0FBb0MsRUFBRSxDQUFBO0lBRXBELElBQUksTUFBTSxDQUFDLElBQUksRUFBRSxDQUFDO1FBQ2hCLElBQUksTUFBTSxDQUFDLElBQUksRUFBRSxLQUFLLEVBQUUsQ0FBQztZQUN2QixRQUFRLENBQUMsS0FBSyxHQUFHLE1BQU0sQ0FBQyxJQUFJLENBQUMsS0FBSyxDQUFBO1FBQ3BDLENBQUM7UUFDRCxJQUFJLE1BQU0sQ0FBQyxJQUFJLEVBQUUsRUFBRSxFQUFFLENBQUM7WUFDcEIsUUFBUSxDQUFDLEVBQUUsR0FBRyxNQUFNLENBQUMsSUFBSSxDQUFDLEVBQUUsQ0FBQTtRQUM5QixDQUFDO0lBQ0gsQ0FBQztJQUVELElBQUksQ0FBQyxRQUFRLENBQUMsS0FBSyxJQUFJLE1BQU0sQ0FBQyxTQUFTLEVBQUUsQ0FBQztRQUN4QyxRQUFRLENBQUMsS0FBSyxHQUFHLE1BQU0sQ0FBQyxTQUFTLENBQUE7SUFDbkMsQ0FBQztJQUVELElBQUksUUFBUSxDQUFDLEtBQUs7V0FDYixHQUFHLENBQUMsSUFBSS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';
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
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const LIB_VERSION = "0.2.0";
1
+ export declare const LIB_VERSION = "0.2.1";
2
2
  //# sourceMappingURL=version.d.ts.map
package/dist/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  // This file is autogenerated by scripts/save-version.sh
2
2
  // Do not edit it manually!
3
- export const LIB_VERSION = '0.2.0';
3
+ export const LIB_VERSION = '0.2.1';
4
4
  //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmVyc2lvbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy92ZXJzaW9uLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLHdEQUF3RDtBQUN4RCwyQkFBMkI7QUFDM0IsTUFBTSxDQUFDLE1BQU0sV0FBVyxHQUFHLE9BQU8sQ0FBQSJ9
@@ -6,6 +6,12 @@
6
6
 
7
7
  import type { Log } from 'sarif';
8
8
 
9
+ // @public
10
+ export enum CalculateResultsBy {
11
+ Level = 0,
12
+ Severity = 1
13
+ }
14
+
9
15
  // @public
10
16
  export type FooterOptions = IncludeAwareWithValueOptions & {
11
17
  type?: FooterType;
@@ -13,10 +19,15 @@ export type FooterOptions = IncludeAwareWithValueOptions & {
13
19
 
14
20
  // @public
15
21
  export enum FooterType {
16
- // (undocumented)
17
- MARKDOWN = "mrkdwn",
18
- // (undocumented)
19
- PLAIN_TEXT = "plain_text"
22
+ Markdown = "mrkdwn",
23
+ PlainText = "plain_text"
24
+ }
25
+
26
+ // @public
27
+ export enum GroupResultsBy {
28
+ Run = 1,
29
+ ToolName = 0,
30
+ Total = 2
20
31
  }
21
32
 
22
33
  // @public
@@ -41,7 +52,20 @@ export enum LogLevel {
41
52
  }
42
53
 
43
54
  // @public
44
- export type Sarif = Log;
55
+ export type LogOptions = {
56
+ level?: LogLevel;
57
+ template?: string;
58
+ colored?: boolean;
59
+ };
60
+
61
+ // @public
62
+ export type SarifLog = Log;
63
+
64
+ // @public
65
+ export type SarifToSlackOutput = {
66
+ groupBy: GroupResultsBy;
67
+ calculateBy: CalculateResultsBy;
68
+ };
45
69
 
46
70
  // @public
47
71
  export class SarifToSlackService {
@@ -58,16 +82,17 @@ export type SarifToSlackServiceOptions = {
58
82
  username?: string;
59
83
  iconUrl?: string;
60
84
  color?: string;
61
- logLevel?: LogLevel | string;
85
+ log?: LogOptions;
62
86
  header?: IncludeAwareWithValueOptions;
63
87
  footer?: FooterOptions;
64
88
  actor?: IncludeAwareWithValueOptions;
65
89
  run?: IncludeAwareOptions;
90
+ output?: SarifToSlackOutput;
66
91
  };
67
92
 
68
93
  // @public
69
94
  export interface SlackMessage {
70
- sarif: Sarif;
95
+ sarif: SarifLog;
71
96
  send: () => Promise<string>;
72
97
  }
73
98
 
package/jest.config.json CHANGED
@@ -10,10 +10,10 @@
10
10
  ],
11
11
  "coverageThreshold": {
12
12
  "global": {
13
- "branches": 20,
14
- "functions": 15,
15
- "lines": 20,
16
- "statements": 20
13
+ "branches": 15,
14
+ "functions": 10,
15
+ "lines": 15,
16
+ "statements": 15
17
17
  }
18
18
  },
19
19
  "moduleFileExtensions": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fabasoad/sarif-to-slack",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "TypeScript library to send results of SARIF file to Slack webhook URL.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -8,7 +8,8 @@
8
8
  "private": false,
9
9
  "scripts": {
10
10
  "lint": "biome lint --write src",
11
- "test": "jest --config=jest.config.json --json --outputFile=jest-report.json --coverage",
11
+ "test": "jest --config=jest.config.json --json --outputFile=jest-report.json --coverage --testNamePattern=unit",
12
+ "test:integration": "jest --config=jest.config.json --testNamePattern=integration",
12
13
  "clean": "rm -rf coverage && rm -rf temp",
13
14
  "clean:unsafe": "rm -f package-lock.json && rm -rf node_modules && rm -rf dist && rm -rf lib",
14
15
  "tsc": "tsc",
@@ -44,15 +45,16 @@
44
45
  "dependencies": {
45
46
  "@slack/webhook": "7.0.5",
46
47
  "@types/sarif": "2.1.7",
48
+ "immutable": "5.1.3",
47
49
  "tslog": "4.9.3"
48
50
  },
49
51
  "devDependencies": {
50
- "@biomejs/biome": "2.0.6",
51
- "@microsoft/api-documenter": "7.26.29",
52
- "@microsoft/api-extractor": "7.52.8",
52
+ "@biomejs/biome": "2.1.2",
53
+ "@microsoft/api-documenter": "7.26.30",
54
+ "@microsoft/api-extractor": "7.52.9",
53
55
  "@types/jest": "30.0.0",
54
- "jest": "30.0.3",
55
- "jest-circus": "30.0.3",
56
+ "jest": "30.0.5",
57
+ "jest-circus": "30.0.5",
56
58
  "ts-jest": "29.4.0",
57
59
  "typescript": "5.8.3"
58
60
  }
package/src/Logger.ts CHANGED
@@ -1,36 +1,39 @@
1
- import { Logger as TSLogger, ILogObj } from 'tslog'
2
- import { LogLevel } from './types'
3
-
4
- /**
5
- * Logger options for configuring the logging behavior.
6
- * @internal
7
- */
8
- export type LoggerOptions = {
9
- logLevel?: LogLevel
10
- }
1
+ import { ILogObj, Logger as TSLogger } from 'tslog'
2
+ import { LogLevel, LogOptions } from './types'
11
3
 
12
4
  /**
13
5
  * Logger class for managing logging operations.
14
6
  * @internal
15
7
  */
16
8
  export default class Logger {
17
- private static instance: TSLogger<ILogObj> = new TSLogger();
9
+ private static DEFAULT_LOG_LEVEL: LogLevel = LogLevel.Info
10
+ private static DEFAULT_LOG_TEMPLATE: string = '[{{logLevelName}}] [{{name}}] {{dateIsoStr}} '
11
+ private static DEFAULT_LOG_COLORED: boolean = true
12
+
13
+ private static instance: TSLogger<ILogObj>
18
14
 
19
- public static initialize({ logLevel = LogLevel.Info }: LoggerOptions): void {
15
+ public static initialize(opts?: LogOptions): void {
20
16
  if (!Logger.instance) {
21
17
  Logger.instance = new TSLogger({
22
- minLevel: process.env.ACTIONS_STEP_DEBUG === 'true' ? 0 : logLevel,
18
+ name: '@fabasoad/sarif-to-slack',
19
+ minLevel: process.env.ACTIONS_STEP_DEBUG === 'true' ? LogLevel.Silly : (opts?.level ?? Logger.DEFAULT_LOG_LEVEL),
23
20
  type: 'pretty',
24
21
  prettyLogTimeZone: 'UTC',
22
+ prettyLogTemplate: opts?.template ?? Logger.DEFAULT_LOG_TEMPLATE,
23
+ stylePrettyLogs: opts?.colored ?? Logger.DEFAULT_LOG_COLORED,
25
24
  })
26
25
  }
27
26
  }
28
27
 
29
- public static info(...args: string[]): void {
30
- Logger.instance.info(args)
28
+ public static warn(...args: unknown[]): void {
29
+ Logger.instance.warn(...args)
30
+ }
31
+
32
+ public static info(...args: unknown[]): void {
33
+ Logger.instance.info(...args)
31
34
  }
32
35
 
33
- public static debug(...args: string[]): void {
34
- Logger.instance.debug(args)
36
+ public static debug(...args: unknown[]): void {
37
+ Logger.instance.debug(...args)
35
38
  }
36
39
  }
package/src/Processors.ts CHANGED
@@ -27,7 +27,7 @@ export function processColor(color?: string): string | undefined {
27
27
  Logger.info(`Converting "${color}" to #808080`)
28
28
  return '#808080'
29
29
  default:
30
- Logger.debug(`"${color}" color is not a CI status identifier. Returning as is...`)
30
+ Logger.debug(`"${color}" color is not a CI status identifier. Returning as is.`)
31
31
  return color
32
32
  }
33
33
  }
@@ -39,28 +39,28 @@ export function processColor(color?: string): string | undefined {
39
39
  * @throws Error If the input string does not match any known log level.
40
40
  * @internal
41
41
  */
42
- export function processLogLevel(logLevel?: LogLevel | string): LogLevel | undefined {
43
- if (typeof logLevel === 'string') {
44
- switch (logLevel.toLowerCase()) {
45
- case 'silly':
46
- return 0
47
- case 'trace':
48
- return 1
49
- case 'debug':
50
- return 2
51
- case 'info':
52
- return 3
53
- case 'warning':
54
- return 4
55
- case 'error':
56
- return 5
57
- case 'fatal':
58
- return 6
59
- default:
60
- throw new Error(`Unknown log level: ${logLevel}`)
61
- }
42
+ export function processLogLevel(logLevel?: string): LogLevel | undefined {
43
+ if (!logLevel) {
44
+ return undefined
45
+ }
46
+ switch (logLevel.toLowerCase()) {
47
+ case 'silly':
48
+ return LogLevel.Silly
49
+ case 'trace':
50
+ return LogLevel.Trace
51
+ case 'debug':
52
+ return LogLevel.Debug
53
+ case 'info':
54
+ return LogLevel.Info
55
+ case 'warning':
56
+ return LogLevel.Warning
57
+ case 'error':
58
+ return LogLevel.Error
59
+ case 'fatal':
60
+ return LogLevel.Fatal
61
+ default:
62
+ throw new Error(`Unknown log level: ${logLevel}`)
62
63
  }
63
- return logLevel
64
64
  }
65
65
 
66
66
  /**
@@ -1,9 +1,9 @@
1
1
  import { promises as fs } from 'fs';
2
2
  import Logger from './Logger'
3
- import { processColor, processLogLevel, processSarifPath } from './Processors'
3
+ import { processColor, processSarifPath } from './Processors'
4
4
  import { SlackMessageBuilder } from './SlackMessageBuilder'
5
5
  import {
6
- Sarif,
6
+ SarifLog,
7
7
  SarifToSlackServiceOptions,
8
8
  SlackMessage
9
9
  } from './types'
@@ -22,7 +22,8 @@ async function initialize(opts: SarifToSlackServiceOptions): Promise<Map<string,
22
22
  username: opts.username,
23
23
  iconUrl: opts.iconUrl,
24
24
  color: processColor(opts.color),
25
- sarif: JSON.parse(jsonString) as Sarif
25
+ sarif: JSON.parse(jsonString) as SarifLog,
26
+ output: opts.output,
26
27
  })
27
28
  if (opts.header?.include) {
28
29
  messageBuilder.withHeader(opts.header?.value)
@@ -69,9 +70,7 @@ export class SarifToSlackService {
69
70
  * @public
70
71
  */
71
72
  public static async create(opts: SarifToSlackServiceOptions): Promise<SarifToSlackService> {
72
- Logger.initialize({
73
- logLevel: processLogLevel(opts.logLevel)
74
- })
73
+ Logger.initialize(opts.log)
75
74
  const instance: SarifToSlackService = new SarifToSlackService()
76
75
  const map: Map<string, SlackMessage> = await initialize(opts)
77
76
  map.forEach((val: SlackMessage, key: string) => instance._slackMessages.set(key, val))