@fabasoad/sarif-to-slack 0.2.5 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (192) hide show
  1. package/.github/workflows/release.yml +1 -1
  2. package/.github/workflows/security.yml +0 -1
  3. package/.github/workflows/send-sarif-to-slack.yml +145 -73
  4. package/.gitleaksignore +8 -0
  5. package/.pre-commit-config.yaml +3 -3
  6. package/.tool-versions +1 -1
  7. package/dist/Logger.js +4 -1
  8. package/dist/SarifToSlackClient.d.ts +33 -0
  9. package/dist/SarifToSlackClient.d.ts.map +1 -0
  10. package/dist/SarifToSlackClient.js +178 -0
  11. package/dist/SlackMessageBuilder.js +34 -82
  12. package/dist/System.d.ts +1 -3
  13. package/dist/System.d.ts.map +1 -1
  14. package/dist/System.js +10 -3
  15. package/dist/index.cjs +840 -472
  16. package/dist/index.d.ts +35 -12
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +36 -12
  19. package/dist/model/Color.d.ts +70 -0
  20. package/dist/model/Color.d.ts.map +1 -0
  21. package/dist/model/Color.js +119 -0
  22. package/dist/model/Finding.d.ts +2 -0
  23. package/dist/model/Finding.d.ts.map +1 -0
  24. package/dist/model/Finding.js +93 -0
  25. package/dist/model/FindingsArray.d.ts +2 -0
  26. package/dist/model/FindingsArray.d.ts.map +1 -0
  27. package/dist/model/FindingsArray.js +24 -0
  28. package/dist/processors/CodeQLProcessor.d.ts +2 -0
  29. package/dist/processors/CodeQLProcessor.d.ts.map +1 -0
  30. package/dist/processors/CodeQLProcessor.js +17 -0
  31. package/dist/processors/CommonProcessor.d.ts +2 -0
  32. package/dist/processors/CommonProcessor.d.ts.map +1 -0
  33. package/dist/processors/CommonProcessor.js +84 -0
  34. package/dist/processors/ProcessorFactory.d.ts +2 -0
  35. package/dist/processors/ProcessorFactory.d.ts.map +1 -0
  36. package/dist/processors/ProcessorFactory.js +22 -0
  37. package/dist/processors/SnykProcessor.d.ts +2 -0
  38. package/dist/processors/SnykProcessor.d.ts.map +1 -0
  39. package/dist/processors/SnykProcessor.js +18 -0
  40. package/dist/representations/CompactGroupByRepresentation.d.ts +2 -0
  41. package/dist/representations/CompactGroupByRepresentation.d.ts.map +1 -0
  42. package/dist/representations/CompactGroupByRepresentation.js +58 -0
  43. package/dist/representations/CompactGroupByRunPerLevelRepresentation.d.ts +2 -0
  44. package/dist/representations/CompactGroupByRunPerLevelRepresentation.d.ts.map +1 -0
  45. package/dist/representations/CompactGroupByRunPerLevelRepresentation.js +13 -0
  46. package/dist/representations/CompactGroupByRunPerSeverityRepresentation.d.ts +2 -0
  47. package/dist/representations/CompactGroupByRunPerSeverityRepresentation.d.ts.map +1 -0
  48. package/dist/representations/CompactGroupByRunPerSeverityRepresentation.js +13 -0
  49. package/dist/representations/CompactGroupByRunRepresentation.d.ts +2 -0
  50. package/dist/representations/CompactGroupByRunRepresentation.d.ts.map +1 -0
  51. package/dist/representations/CompactGroupByRunRepresentation.js +39 -0
  52. package/dist/representations/CompactGroupBySarifPerLevelRepresentation.d.ts +2 -0
  53. package/dist/representations/CompactGroupBySarifPerLevelRepresentation.d.ts.map +1 -0
  54. package/dist/representations/CompactGroupBySarifPerLevelRepresentation.js +13 -0
  55. package/dist/representations/CompactGroupBySarifPerSeverityRepresentation.d.ts +2 -0
  56. package/dist/representations/CompactGroupBySarifPerSeverityRepresentation.d.ts.map +1 -0
  57. package/dist/representations/CompactGroupBySarifPerSeverityRepresentation.js +13 -0
  58. package/dist/representations/CompactGroupBySarifRepresentation.d.ts +2 -0
  59. package/dist/representations/CompactGroupBySarifRepresentation.d.ts.map +1 -0
  60. package/dist/representations/CompactGroupBySarifRepresentation.js +40 -0
  61. package/dist/representations/CompactGroupByToolNamePerLevelRepresentation.d.ts +2 -0
  62. package/dist/representations/CompactGroupByToolNamePerLevelRepresentation.d.ts.map +1 -0
  63. package/dist/representations/CompactGroupByToolNamePerLevelRepresentation.js +13 -0
  64. package/dist/representations/CompactGroupByToolNamePerSeverityRepresentation.d.ts +2 -0
  65. package/dist/representations/CompactGroupByToolNamePerSeverityRepresentation.d.ts.map +1 -0
  66. package/dist/representations/CompactGroupByToolNamePerSeverityRepresentation.js +13 -0
  67. package/dist/representations/CompactGroupByToolNameRepresentation.d.ts +2 -0
  68. package/dist/representations/CompactGroupByToolNameRepresentation.d.ts.map +1 -0
  69. package/dist/representations/CompactGroupByToolNameRepresentation.js +39 -0
  70. package/dist/representations/CompactTotalPerLevelRepresentation.d.ts +2 -0
  71. package/dist/representations/CompactTotalPerLevelRepresentation.d.ts.map +1 -0
  72. package/dist/representations/CompactTotalPerLevelRepresentation.js +13 -0
  73. package/dist/representations/CompactTotalPerSeverityRepresentation.d.ts +2 -0
  74. package/dist/representations/CompactTotalPerSeverityRepresentation.d.ts.map +1 -0
  75. package/dist/representations/CompactTotalPerSeverityRepresentation.js +13 -0
  76. package/dist/representations/CompactTotalRepresentation.d.ts +2 -0
  77. package/dist/representations/CompactTotalRepresentation.d.ts.map +1 -0
  78. package/dist/representations/CompactTotalRepresentation.js +25 -0
  79. package/dist/representations/Representation.d.ts +2 -0
  80. package/dist/representations/Representation.d.ts.map +1 -0
  81. package/dist/representations/Representation.js +28 -0
  82. package/dist/representations/RepresentationFactory.d.ts +2 -0
  83. package/dist/representations/RepresentationFactory.d.ts.map +1 -0
  84. package/dist/representations/RepresentationFactory.js +37 -0
  85. package/dist/sarif-to-slack.d.ts +337 -85
  86. package/dist/tsdoc-metadata.json +1 -1
  87. package/dist/types.d.ts +215 -51
  88. package/dist/types.d.ts.map +1 -1
  89. package/dist/types.js +225 -33
  90. package/dist/utils/Comparators.d.ts +2 -0
  91. package/dist/utils/Comparators.d.ts.map +1 -0
  92. package/dist/utils/Comparators.js +18 -0
  93. package/dist/utils/ExtendedArray.d.ts +2 -0
  94. package/dist/utils/ExtendedArray.d.ts.map +1 -0
  95. package/dist/utils/ExtendedArray.js +11 -0
  96. package/dist/utils/FileUtils.d.ts +2 -0
  97. package/dist/utils/FileUtils.d.ts.map +1 -0
  98. package/dist/utils/FileUtils.js +51 -0
  99. package/dist/utils/SarifUtils.js +20 -54
  100. package/etc/sarif-to-slack.api.md +161 -99
  101. package/jest.config.json +2 -2
  102. package/package.json +7 -7
  103. package/scripts/save-metadata.sh +12 -10
  104. package/src/Logger.ts +4 -0
  105. package/src/SarifToSlackClient.ts +202 -0
  106. package/src/SlackMessageBuilder.ts +35 -115
  107. package/src/System.ts +9 -2
  108. package/src/index.ts +47 -20
  109. package/src/model/Color.ts +201 -0
  110. package/src/model/Finding.ts +137 -0
  111. package/src/model/FindingsArray.ts +27 -0
  112. package/src/processors/CodeQLProcessor.ts +19 -0
  113. package/src/processors/CommonProcessor.ts +103 -0
  114. package/src/processors/ProcessorFactory.ts +23 -0
  115. package/src/processors/SnykProcessor.ts +19 -0
  116. package/src/representations/CompactGroupByRepresentation.ts +67 -0
  117. package/src/representations/CompactGroupByRunPerLevelRepresentation.ts +14 -0
  118. package/src/representations/CompactGroupByRunPerSeverityRepresentation.ts +14 -0
  119. package/src/representations/CompactGroupByRunRepresentation.ts +44 -0
  120. package/src/representations/CompactGroupBySarifPerLevelRepresentation.ts +15 -0
  121. package/src/representations/CompactGroupBySarifPerSeverityRepresentation.ts +15 -0
  122. package/src/representations/CompactGroupBySarifRepresentation.ts +45 -0
  123. package/src/representations/CompactGroupByToolNamePerLevelRepresentation.ts +15 -0
  124. package/src/representations/CompactGroupByToolNamePerSeverityRepresentation.ts +15 -0
  125. package/src/representations/CompactGroupByToolNameRepresentation.ts +44 -0
  126. package/src/representations/CompactTotalPerLevelRepresentation.ts +14 -0
  127. package/src/representations/CompactTotalPerSeverityRepresentation.ts +14 -0
  128. package/src/representations/CompactTotalRepresentation.ts +27 -0
  129. package/src/representations/Representation.ts +35 -0
  130. package/src/representations/RepresentationFactory.ts +49 -0
  131. package/src/types.ts +270 -53
  132. package/src/utils/Comparators.ts +19 -0
  133. package/src/utils/ExtendedArray.ts +11 -0
  134. package/src/utils/FileUtils.ts +60 -0
  135. package/src/utils/SarifUtils.ts +20 -72
  136. package/test-data/sarif/codeql-python.sarif +1448 -1
  137. package/test-data/sarif/codeql-typescript.sarif +3474 -1
  138. package/test-data/sarif/grype-github-actions.sarif +65 -0
  139. package/test-data/sarif/osv-scanner-composer.sarif +972 -0
  140. package/test-data/sarif/osv-scanner-container.sarif +2278 -0
  141. package/test-data/sarif/osv-scanner-gomodules.sarif +813 -0
  142. package/test-data/sarif/osv-scanner-hex.sarif +147 -0
  143. package/test-data/sarif/osv-scanner-maven.sarif +171 -0
  144. package/test-data/sarif/osv-scanner-npm.sarif +627 -0
  145. package/test-data/sarif/osv-scanner-pip.sarif +206 -0
  146. package/test-data/sarif/osv-scanner-pipenv.sarif +243 -0
  147. package/test-data/sarif/osv-scanner-pnpm.sarif +174 -0
  148. package/test-data/sarif/osv-scanner-poetry.sarif +1893 -0
  149. package/test-data/sarif/osv-scanner-rubygems.sarif +402 -0
  150. package/test-data/sarif/osv-scanner-uv.sarif +206 -0
  151. package/test-data/sarif/osv-scanner-yarn.sarif +5207 -0
  152. package/test-data/sarif/runs-0.sarif +5 -0
  153. package/test-data/sarif/runs-2-tools-2-results-0.sarif +1 -1
  154. package/test-data/sarif/runs-2-tools-2.sarif +1 -1
  155. package/test-data/sarif/runs-3-tools-2-results-0.sarif +1 -1
  156. package/test-data/sarif/runs-3-tools-2.sarif +1 -1
  157. package/test-data/sarif/tmp/codeql-csharp.sarif +1 -0
  158. package/test-data/sarif/tmp/grype-container.sarif +1774 -0
  159. package/test-data/sarif/tmp/runs-1-tools-1-results-0.sarif +18 -0
  160. package/test-data/sarif/tmp/runs-2-tools-2.sarif +686 -0
  161. package/test-data/sarif/trivy-iac.sarif +1 -1
  162. package/tests/integration/SendSarifToSlack.spec.ts +95 -27
  163. package/tsconfig.json +2 -0
  164. package/dist/Processors.d.ts +0 -2
  165. package/dist/Processors.d.ts.map +0 -1
  166. package/dist/Processors.js +0 -61
  167. package/dist/SarifToSlackService.d.ts +0 -39
  168. package/dist/SarifToSlackService.d.ts.map +0 -1
  169. package/dist/SarifToSlackService.js +0 -104
  170. package/dist/metadata.d.ts +0 -2
  171. package/dist/metadata.d.ts.map +0 -1
  172. package/dist/metadata.js +0 -11
  173. package/dist/model/SarifModelPerRun.d.ts +0 -2
  174. package/dist/model/SarifModelPerRun.d.ts.map +0 -1
  175. package/dist/model/SarifModelPerRun.js +0 -90
  176. package/dist/model/SarifModelPerSarif.d.ts +0 -2
  177. package/dist/model/SarifModelPerSarif.d.ts.map +0 -1
  178. package/dist/model/SarifModelPerSarif.js +0 -102
  179. package/dist/model/types.d.ts +0 -2
  180. package/dist/model/types.d.ts.map +0 -1
  181. package/dist/model/types.js +0 -49
  182. package/dist/utils/SortUtils.d.ts +0 -2
  183. package/dist/utils/SortUtils.d.ts.map +0 -1
  184. package/dist/utils/SortUtils.js +0 -20
  185. package/src/Processors.ts +0 -68
  186. package/src/SarifToSlackService.ts +0 -117
  187. package/src/metadata.ts +0 -10
  188. package/src/model/SarifModelPerRun.ts +0 -120
  189. package/src/model/SarifModelPerSarif.ts +0 -126
  190. package/src/model/types.ts +0 -50
  191. package/src/utils/SortUtils.ts +0 -33
  192. package/tests/Processors.spec.ts +0 -76
@@ -0,0 +1,51 @@
1
+ import fs from 'fs';
2
+ import Logger from '../Logger';
3
+ import * as path from 'path';
4
+ /**
5
+ * Traverse directory recursively and returns list of files with the requested
6
+ * extension.
7
+ * @param dir A root directory. Starting point.
8
+ * @param extension An instance of {@link SarifFileExtension} type.
9
+ * @param fileList Collected list of files.
10
+ * @private
11
+ */
12
+ function listFilesRecursively(dir, extension, fileList = []) {
13
+ const entries = fs.readdirSync(dir);
14
+ entries.forEach((entry) => {
15
+ const fullPath = path.join(dir, entry);
16
+ if (fs.statSync(fullPath).isDirectory()) {
17
+ listFilesRecursively(fullPath, extension, fileList);
18
+ }
19
+ else if (path.extname(fullPath).toLowerCase() === `.${extension}`) {
20
+ fileList.push(fullPath);
21
+ }
22
+ });
23
+ return fileList;
24
+ }
25
+ /**
26
+ * Extract list of files based on the parameters from the given {@link SarifOptions}
27
+ * object.
28
+ * @param opts An instance of {@link SarifOptions} type.
29
+ * @internal
30
+ */
31
+ export function extractListOfFiles(opts) {
32
+ if (!fs.existsSync(opts.path)) {
33
+ throw new Error(`Provided path does not exist: ${opts.path}`);
34
+ }
35
+ const stats = fs.statSync(opts.path);
36
+ if (stats.isDirectory()) {
37
+ Logger.info(`Provided path is a directory: ${opts.path}`);
38
+ const files = opts.recursive
39
+ && listFilesRecursively(opts.path, opts.extension ?? 'sarif')
40
+ || fs.readdirSync(opts.path);
41
+ Logger.info(`Found ${files.length} files in ${opts.path} directory with ${opts.extension} extension`);
42
+ Logger.debug(`Found files: ${files.join(', ')}`);
43
+ return files;
44
+ }
45
+ if (stats.isFile()) {
46
+ Logger.info(`Provided path is a file: ${opts.path}`);
47
+ return [opts.path];
48
+ }
49
+ throw new Error(`Provided path is neither a file nor a directory: ${opts.path}`);
50
+ }
51
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiRmlsZVV0aWxzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3V0aWxzL0ZpbGVVdGlscy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsTUFBTSxJQUFJLENBQUE7QUFDbkIsT0FBTyxNQUFNLE1BQU0sV0FBVyxDQUFBO0FBRTlCLE9BQU8sS0FBSyxJQUFJLE1BQU0sTUFBTSxDQUFBO0FBRTVCOzs7Ozs7O0dBT0c7QUFDSCxTQUFTLG9CQUFvQixDQUMzQixHQUFXLEVBQ1gsU0FBNkIsRUFDN0IsV0FBcUIsRUFBRTtJQUV2QixNQUFNLE9BQU8sR0FBYSxFQUFFLENBQUMsV0FBVyxDQUFDLEdBQUcsQ0FBQyxDQUFBO0lBQzdDLE9BQU8sQ0FBQyxPQUFPLENBQUMsQ0FBQ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0FBQyxTQUFTO2VBQ2pDLG9CQUFvQixDQUFDLElBQUksQ0FBQyxJQUFJLEVBQUUsSUFBSSxDQUFDLFNBQVMsSUFBSSxPQUFPLENBQUM7ZUFDMUQsRUFBRSxDQUFDLFdBQVcsQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUE7UUFDOUIsTUFBTSxDQUFDLElBQUksQ0FBQyxTQUFTLEtBQUssQ0FBQyxNQUFNLGFBQWEsSUFBSSxDQUFDLElBQUksbUJBQW1CLElBQUksQ0FBQyxTQUFTLFlBQVksQ0FBQyxDQUFBO1FBQ3JHLE1BQU0sQ0FBQyxLQUFLLENBQUMsZ0JBQWdCLEtBQUssQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLEVBQUUsQ0FBQyxDQUFBO1FBQ2hELE9BQU8sS0FBSyxDQUFBO0lBQ2QsQ0FBQztJQUVELElBQUksS0FBSyxDQUFDLE1BQU0sRUFBRSxFQUFFLENBQUM7UUFDbkIsTUFBTSxDQUFDLElBQUksQ0FBQyw0QkFBNEIsSUFBSSxDQUFDLElBQUksRUFBRSxDQUFDLENBQUE7UUFDcEQsT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsQ0FBQTtJQUNwQixDQUFDO0lBRUQsTUFBTSxJQUFJLEtBQUssQ0FBQyxvREFBb0QsSUFBSSxDQUFDLElBQUksRUFBRSxDQUFDLENBQUE7QUFDbEYsQ0FBQyJ9
@@ -1,66 +1,32 @@
1
1
  /**
2
- * This function finds the respective tool for the given result.
3
- * @param run An instance of {@link Run} object.
4
- * @param result An instance of {@link Result} object.
5
- * @private
2
+ * Returns {@link ToolComponent} instance for the given {@link Run}. It does not
3
+ * count extensions but returns {@link ToolComponent} directly from "run.tool.driver",
4
+ * despite the fact if extension exists or not.
5
+ * @internal
6
6
  */
7
- function findToolComponentByResult(run, result) {
8
- let tool;
9
- if (result.rule?.toolComponent?.index != null) {
10
- tool = run.tool.extensions?.[result.rule.toolComponent.index];
11
- }
12
- if (!tool) {
13
- tool = run.tool.driver;
14
- }
15
- return tool;
7
+ export function findToolComponentDriver(run) {
8
+ return run.tool.driver;
16
9
  }
17
10
  /**
18
- * This function tries to find the respective rule for the given result.
19
- * @param run An instance of {@link Run} object.
20
- * @param result An instance of {@link Result} object.
11
+ * Returns {@link ToolComponent} instance for the given {@link Run} from the extensions
12
+ * list if applicable. Returns {@linkcode undefined} if provided {@link Result}
13
+ * does not link to extension.
21
14
  * @internal
22
15
  */
23
- export function findRuleByResult(run, result) {
24
- const ruleData = {};
25
- if (result.rule) {
26
- if (result.rule?.index != null) {
27
- ruleData.index = result.rule.index;
28
- }
29
- if (result.rule?.id) {
30
- ruleData.id = result.rule.id;
31
- }
32
- }
33
- if (ruleData.index == null && result.ruleIndex != null) {
34
- ruleData.index = result.ruleIndex;
35
- }
36
- if (!ruleData.id && result.ruleId) {
37
- ruleData.id = result.ruleId;
38
- }
39
- const tool = findToolComponentByResult(run, result);
40
- if (ruleData.index != null
41
- && tool?.rules
42
- && ruleData.index < tool.rules.length) {
43
- return tool.rules[ruleData.index];
44
- }
45
- // If failed to find rule by index then try to find by ruleId
46
- if (ruleData.id && tool?.rules) {
47
- return tool.rules.find((r) => r.id === ruleData.id);
16
+ export function tryFindToolComponentExtension(run, result) {
17
+ let tool;
18
+ if (result.rule?.toolComponent?.index != null) {
19
+ tool = run.tool.extensions?.[result.rule.toolComponent.index];
48
20
  }
49
- return undefined;
21
+ return tool;
50
22
  }
51
23
  /**
52
- * This function searches respective rule for the given result, and then gets
53
- * the property of interest from it.
54
- * @param run An instance of {@link Run} object.
55
- * @param result An instance of {@link Result} object.
56
- * @param propertyName The property name that you want to get the value from.
24
+ * It tries to find respective {@link ToolComponent} from the {@link Result}. At
25
+ * first, it tries to find it in the list of extensions if applicable, otherwise
26
+ * it gets it directly from "run.tool.driver".
57
27
  * @internal
58
28
  */
59
- export function tryGetRulePropertyByResult(run, result, propertyName) {
60
- const rule = findRuleByResult(run, result);
61
- if (rule && rule.properties && propertyName in rule.properties) {
62
- return rule.properties[propertyName];
63
- }
64
- return undefined;
29
+ export function findToolComponent(run, result) {
30
+ return tryFindToolComponentExtension(run, result) ?? findToolComponentDriver(run);
65
31
  }
66
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiU2FyaWZVdGlscy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlscy9TYXJpZlV0aWxzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUVBOzs7OztHQUtHO0FBQ0gsU0FBUyx5QkFBeUIsQ0FBQyxHQUFRLEVBQUUsTUFBYztJQUN6RCxJQUFJLElBQStCLENBQUE7SUFDbkMsSUFBSSxNQUFNLENBQUMsSUFBSSxFQUFFLGFBQWEsRUFBRSxLQUFLLElBQUksSUFBSSxFQUFFLENBQUM7UUFDOUMsSUFBSSxHQUFHLEdBQUcsQ0FBQyxJQUFJLENBQUMsVUFBVSxFQUFFLENBQUMsTUFBTSxDQUFDLElBQUksQ0FBQyxhQUFhLENBQUMsS0FBSyxDQUFDLENBQUE7SUFDL0QsQ0FBQztJQUVELElBQUksQ0FBQyxJQUFJLEVBQUUsQ0FBQztRQUNWLElBQUksR0FBRyxHQUFHLENBQUMsSUFBSSxDQUFDLE1BQU0sQ0FBQTtJQUN4QixDQUFDO0lBRUQsT0FBTyxJQUFJLENBQUE7QUFDYixDQUFDO0FBRUQ7Ozs7O0dBS0c7QUFDSCxNQUFNLFVBQVUsZ0JBQWdCLENBQUMsR0FBUSxFQUFFLE1BQWM7SUFDdkQsTUFBTSxRQUFRLEdBQW9DLEVBQUUsQ0FBQTtJQUVwRCxJQUFJLE1BQU0sQ0FBQyxJQUFJLEVBQUUsQ0FBQztRQUNoQixJQUFJLE1BQU0sQ0FBQyxJQUFJLEVBQUUsS0FBSyxJQUFJLElBQUksRUFBRSxDQUFDO1lBQy9CLFFBQVEsQ0FBQyxLQ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BQUksR0FBRyxHQUFHLENBQUMsSUFBSSxDQUFDLFVBQVUsRUFBRSxDQUFDLE1BQU0sQ0FBQyxJQUFJLENBQUMsYUFBYSxDQUFDLEtBQUssQ0FBQyxDQUFBO0lBQy9ELENBQUM7SUFDRCxPQUFPLElBQUksQ0FBQTtBQUNiLENBQUM7QUFFRDs7Ozs7R0FLRztBQUNILE1BQU0sVUFBVSxpQkFBaUIsQ0FBQyxHQUFRLEVBQUUsTUFBYztJQUN4RCxPQUFPLDZCQUE2QixDQUFDLEdBQUcsRUFBRSxNQUFNLENBQUMsSUFBSSx1QkFBdUIsQ0FBQyxHQUFHLENBQUMsQ0FBQTtBQUNuRixDQUFDIn0=
@@ -1,99 +1,161 @@
1
- ## API Report File for "@fabasoad/sarif-to-slack"
2
-
3
- > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
-
5
- ```ts
6
-
7
- import type { Log } from 'sarif';
8
-
9
- // @public
10
- export enum CalculateResultsBy {
11
- Level = 0,
12
- Severity = 1
13
- }
14
-
15
- // @public
16
- export type FooterOptions = IncludeAwareWithValueOptions & {
17
- type?: FooterType;
18
- };
19
-
20
- // @public
21
- export enum FooterType {
22
- Markdown = "mrkdwn",
23
- PlainText = "plain_text"
24
- }
25
-
26
- // @public
27
- export enum GroupResultsBy {
28
- Run = 1,
29
- ToolName = 0,
30
- Total = 2
31
- }
32
-
33
- // @public
34
- export type IncludeAwareOptions = {
35
- include: boolean;
36
- };
37
-
38
- // @public
39
- export type IncludeAwareWithValueOptions = IncludeAwareOptions & {
40
- value?: string;
41
- };
42
-
43
- // @public
44
- export enum LogLevel {
45
- Debug = 2,
46
- Error = 5,
47
- Fatal = 6,
48
- Info = 3,
49
- Silly = 0,
50
- Trace = 1,
51
- Warning = 4
52
- }
53
-
54
- // @public
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
- };
69
-
70
- // @public
71
- export class SarifToSlackService {
72
- static create(opts: SarifToSlackServiceOptions): Promise<SarifToSlackService>;
73
- send(sarifPath: string): Promise<void>;
74
- sendAll(): Promise<void>;
75
- get slackMessages(): ReadonlyMap<string, SlackMessage>;
76
- }
77
-
78
- // @public
79
- export type SarifToSlackServiceOptions = {
80
- webhookUrl: string;
81
- sarifPath: string;
82
- username?: string;
83
- iconUrl?: string;
84
- color?: string;
85
- log?: LogOptions;
86
- header?: IncludeAwareWithValueOptions;
87
- footer?: FooterOptions;
88
- actor?: IncludeAwareWithValueOptions;
89
- run?: IncludeAwareOptions;
90
- output?: SarifToSlackOutput;
91
- };
92
-
93
- // @public
94
- export interface SlackMessage {
95
- sarif: SarifLog;
96
- send: () => Promise<string>;
97
- }
98
-
99
- ```
1
+ ## API Report File for "@fabasoad/sarif-to-slack"
2
+
3
+ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
+
5
+ ```ts
6
+
7
+ // @public
8
+ export class Color {
9
+ constructor(color?: string);
10
+ get value(): string | undefined;
11
+ }
12
+
13
+ // Warning: (ae-forgotten-export) The symbol "ColorGroupCommon" needs to be exported by the entry point index.d.ts
14
+ //
15
+ // @public
16
+ export type ColorGroupByLevel = ColorGroupCommon & {
17
+ error?: Color;
18
+ warning?: Color;
19
+ note?: Color;
20
+ };
21
+
22
+ // @public
23
+ export type ColorGroupBySeverity = ColorGroupCommon & {
24
+ critical?: Color;
25
+ high?: Color;
26
+ medium?: Color;
27
+ low?: Color;
28
+ };
29
+
30
+ // @public
31
+ export type ColorOptions = {
32
+ byLevel?: ColorGroupByLevel;
33
+ bySeverity?: ColorGroupBySeverity;
34
+ };
35
+
36
+ // @public
37
+ export type FooterOptions = IncludeAwareWithValueOptions & {
38
+ type?: FooterType;
39
+ };
40
+
41
+ // @public
42
+ export enum FooterType {
43
+ Markdown = "mrkdwn",
44
+ PlainText = "plain_text"
45
+ }
46
+
47
+ // @public
48
+ export type IncludeAwareOptions = {
49
+ include: boolean;
50
+ };
51
+
52
+ // @public
53
+ export type IncludeAwareWithValueOptions = IncludeAwareOptions & {
54
+ value?: string;
55
+ };
56
+
57
+ // @public
58
+ export enum LogLevel {
59
+ Debug = 2,
60
+ Error = 5,
61
+ Fatal = 6,
62
+ Info = 3,
63
+ Silly = 0,
64
+ Trace = 1,
65
+ Warning = 4
66
+ }
67
+
68
+ // @public
69
+ export type LogOptions = {
70
+ level?: LogLevel;
71
+ template?: string;
72
+ colored?: boolean;
73
+ };
74
+
75
+ // @public
76
+ export enum RepresentationType {
77
+ CompactGroupByRunPerLevel = 0,
78
+ CompactGroupByRunPerSeverity = 1,
79
+ CompactGroupBySarifPerLevel = 4,
80
+ CompactGroupBySarifPerSeverity = 5,
81
+ CompactGroupByToolNamePerLevel = 2,
82
+ CompactGroupByToolNamePerSeverity = 3,
83
+ CompactTotalPerLevel = 6,
84
+ CompactTotalPerSeverity = 7
85
+ }
86
+
87
+ // @public
88
+ export type SarifFileExtension = 'sarif' | 'json';
89
+
90
+ // @public
91
+ export type SarifOptions = {
92
+ path: string;
93
+ recursive?: boolean;
94
+ extension?: SarifFileExtension;
95
+ };
96
+
97
+ // @public
98
+ export class SarifToSlackClient {
99
+ // (undocumented)
100
+ static create(opts: SarifToSlackClientOptions): Promise<SarifToSlackClient>;
101
+ send(): Promise<void>;
102
+ }
103
+
104
+ // @public
105
+ export type SarifToSlackClientOptions = {
106
+ webhookUrl: string;
107
+ sarif: SarifOptions;
108
+ username?: string;
109
+ iconUrl?: string;
110
+ color?: Color | ColorOptions;
111
+ log?: LogOptions;
112
+ header?: IncludeAwareWithValueOptions;
113
+ footer?: FooterOptions;
114
+ actor?: IncludeAwareWithValueOptions;
115
+ run?: IncludeAwareOptions;
116
+ representation?: RepresentationType;
117
+ sendIf?: SendIf;
118
+ };
119
+
120
+ // @public
121
+ export enum SendIf {
122
+ Always = 20,
123
+ Empty = 22,
124
+ LevelError = 11,
125
+ LevelNone = 16,
126
+ LevelNoneOrHigher = 17,
127
+ LevelNote = 14,
128
+ LevelNoteOrHigher = 15,
129
+ LevelUnknown = 18,
130
+ LevelUnknownOrHigher = 19,
131
+ LevelWarning = 12,
132
+ LevelWarningOrHigher = 13,
133
+ Never = 23,
134
+ SeverityCritical = 0,
135
+ SeverityHigh = 1,
136
+ SeverityHighOrHigher = 2,
137
+ SeverityLow = 5,
138
+ SeverityLowOrHigher = 6,
139
+ SeverityMedium = 3,
140
+ SeverityMediumOrHigher = 4,
141
+ SeverityNone = 7,
142
+ SeverityNoneOrHigher = 8,
143
+ SeverityUnknown = 9,
144
+ SeverityUnknownOrHigher = 10,
145
+ Some = 21
146
+ }
147
+
148
+ // @public
149
+ export interface SlackMessage {
150
+ send: () => Promise<string>;
151
+ // (undocumented)
152
+ withActor(actor?: string): void;
153
+ // (undocumented)
154
+ withFooter(text?: string, type?: FooterType): void;
155
+ // (undocumented)
156
+ withHeader(header?: string): void;
157
+ // (undocumented)
158
+ withRun(): void;
159
+ }
160
+
161
+ ```
package/jest.config.json CHANGED
@@ -10,8 +10,8 @@
10
10
  ],
11
11
  "coverageThreshold": {
12
12
  "global": {
13
- "branches": 10,
14
- "functions": 10,
13
+ "branches": 3,
14
+ "functions": 3,
15
15
  "lines": 15,
16
16
  "statements": 15
17
17
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fabasoad/sarif-to-slack",
3
- "version": "0.2.5",
3
+ "version": "1.0.0",
4
4
  "description": "TypeScript library to send results of SARIF file to Slack webhook URL.",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",
@@ -44,18 +44,18 @@
44
44
  "dependencies": {
45
45
  "@slack/webhook": "7.0.5",
46
46
  "@types/sarif": "2.1.7",
47
- "immutable": "5.1.3",
48
47
  "tslog": "4.9.3"
49
48
  },
50
49
  "devDependencies": {
51
- "@biomejs/biome": "2.1.3",
52
- "@microsoft/api-documenter": "7.26.30",
53
- "@microsoft/api-extractor": "7.52.9",
50
+ "@biomejs/biome": "2.2.0",
51
+ "@microsoft/api-documenter": "7.26.31",
52
+ "@microsoft/api-extractor": "7.52.10",
54
53
  "@types/jest": "30.0.0",
54
+ "@types/uuid": "10.0.0",
55
55
  "jest": "30.0.5",
56
56
  "jest-circus": "30.0.5",
57
- "ts-jest": "29.4.0",
57
+ "ts-jest": "29.4.1",
58
58
  "tsup": "8.5.0",
59
- "typescript": "5.8.3"
59
+ "typescript": "5.9.2"
60
60
  }
61
61
  }
@@ -1,13 +1,15 @@
1
1
  #!/usr/bin/env sh
2
2
 
3
3
  version=$(jq -r '.version' package.json)
4
- echo "/**" > src/metadata.ts
5
- echo " * These values are used for the default footer in Slack message and in logging." >> src/metadata.ts
6
- echo " *" >> src/metadata.ts
7
- echo " * @privateRemarks" >> src/metadata.ts
8
- echo " * This file is autogenerated by scripts/save-metadata.sh" >> src/metadata.ts
9
- echo " * Do not edit it manually!" >> src/metadata.ts
10
- echo " *" >> src/metadata.ts
11
- echo " * @internal" >> src/metadata.ts
12
- echo " */" >> src/metadata.ts
13
- echo "export const LIB_VERSION = '${version}'" >> src/metadata.ts
4
+ sha=$(git rev-parse --verify HEAD)
5
+ build_at=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
6
+
7
+ jq -n \
8
+ --arg v "${version}" \
9
+ --arg s "${sha}" \
10
+ --arg b "${build_at}" \
11
+ '{
12
+ version: $v,
13
+ sha: $s,
14
+ buildAt: $b
15
+ }' > src/metadata.json
package/src/Logger.ts CHANGED
@@ -36,4 +36,8 @@ export default class Logger {
36
36
  public static debug(...args: unknown[]): void {
37
37
  Logger.instance.debug(...args)
38
38
  }
39
+
40
+ public static trace(...args: unknown[]): void {
41
+ Logger.instance.trace(...args)
42
+ }
39
43
  }