@fabasoad/sarif-to-slack 0.2.5 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/release.yml +1 -1
- package/.github/workflows/security.yml +0 -1
- package/.github/workflows/send-sarif-to-slack.yml +145 -73
- package/.gitleaksignore +8 -0
- package/.pre-commit-config.yaml +3 -3
- package/.tool-versions +1 -1
- package/dist/Logger.js +4 -1
- package/dist/SarifToSlackClient.d.ts +33 -0
- package/dist/SarifToSlackClient.d.ts.map +1 -0
- package/dist/SarifToSlackClient.js +178 -0
- package/dist/SlackMessageBuilder.js +34 -82
- package/dist/System.d.ts +1 -3
- package/dist/System.d.ts.map +1 -1
- package/dist/System.js +10 -3
- package/dist/index.cjs +840 -472
- package/dist/index.d.ts +35 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +36 -12
- package/dist/model/Color.d.ts +70 -0
- package/dist/model/Color.d.ts.map +1 -0
- package/dist/model/Color.js +119 -0
- package/dist/model/Finding.d.ts +2 -0
- package/dist/model/Finding.d.ts.map +1 -0
- package/dist/model/Finding.js +93 -0
- package/dist/model/FindingsArray.d.ts +2 -0
- package/dist/model/FindingsArray.d.ts.map +1 -0
- package/dist/model/FindingsArray.js +24 -0
- package/dist/processors/CodeQLProcessor.d.ts +2 -0
- package/dist/processors/CodeQLProcessor.d.ts.map +1 -0
- package/dist/processors/CodeQLProcessor.js +17 -0
- package/dist/processors/CommonProcessor.d.ts +2 -0
- package/dist/processors/CommonProcessor.d.ts.map +1 -0
- package/dist/processors/CommonProcessor.js +84 -0
- package/dist/processors/ProcessorFactory.d.ts +2 -0
- package/dist/processors/ProcessorFactory.d.ts.map +1 -0
- package/dist/processors/ProcessorFactory.js +22 -0
- package/dist/processors/SnykProcessor.d.ts +2 -0
- package/dist/processors/SnykProcessor.d.ts.map +1 -0
- package/dist/processors/SnykProcessor.js +18 -0
- package/dist/representations/CompactGroupByRepresentation.d.ts +2 -0
- package/dist/representations/CompactGroupByRepresentation.d.ts.map +1 -0
- package/dist/representations/CompactGroupByRepresentation.js +58 -0
- package/dist/representations/CompactGroupByRunPerLevelRepresentation.d.ts +2 -0
- package/dist/representations/CompactGroupByRunPerLevelRepresentation.d.ts.map +1 -0
- package/dist/representations/CompactGroupByRunPerLevelRepresentation.js +13 -0
- package/dist/representations/CompactGroupByRunPerSeverityRepresentation.d.ts +2 -0
- package/dist/representations/CompactGroupByRunPerSeverityRepresentation.d.ts.map +1 -0
- package/dist/representations/CompactGroupByRunPerSeverityRepresentation.js +13 -0
- package/dist/representations/CompactGroupByRunRepresentation.d.ts +2 -0
- package/dist/representations/CompactGroupByRunRepresentation.d.ts.map +1 -0
- package/dist/representations/CompactGroupByRunRepresentation.js +39 -0
- package/dist/representations/CompactGroupBySarifPerLevelRepresentation.d.ts +2 -0
- package/dist/representations/CompactGroupBySarifPerLevelRepresentation.d.ts.map +1 -0
- package/dist/representations/CompactGroupBySarifPerLevelRepresentation.js +13 -0
- package/dist/representations/CompactGroupBySarifPerSeverityRepresentation.d.ts +2 -0
- package/dist/representations/CompactGroupBySarifPerSeverityRepresentation.d.ts.map +1 -0
- package/dist/representations/CompactGroupBySarifPerSeverityRepresentation.js +13 -0
- package/dist/representations/CompactGroupBySarifRepresentation.d.ts +2 -0
- package/dist/representations/CompactGroupBySarifRepresentation.d.ts.map +1 -0
- package/dist/representations/CompactGroupBySarifRepresentation.js +40 -0
- package/dist/representations/CompactGroupByToolNamePerLevelRepresentation.d.ts +2 -0
- package/dist/representations/CompactGroupByToolNamePerLevelRepresentation.d.ts.map +1 -0
- package/dist/representations/CompactGroupByToolNamePerLevelRepresentation.js +13 -0
- package/dist/representations/CompactGroupByToolNamePerSeverityRepresentation.d.ts +2 -0
- package/dist/representations/CompactGroupByToolNamePerSeverityRepresentation.d.ts.map +1 -0
- package/dist/representations/CompactGroupByToolNamePerSeverityRepresentation.js +13 -0
- package/dist/representations/CompactGroupByToolNameRepresentation.d.ts +2 -0
- package/dist/representations/CompactGroupByToolNameRepresentation.d.ts.map +1 -0
- package/dist/representations/CompactGroupByToolNameRepresentation.js +39 -0
- package/dist/representations/CompactTotalPerLevelRepresentation.d.ts +2 -0
- package/dist/representations/CompactTotalPerLevelRepresentation.d.ts.map +1 -0
- package/dist/representations/CompactTotalPerLevelRepresentation.js +13 -0
- package/dist/representations/CompactTotalPerSeverityRepresentation.d.ts +2 -0
- package/dist/representations/CompactTotalPerSeverityRepresentation.d.ts.map +1 -0
- package/dist/representations/CompactTotalPerSeverityRepresentation.js +13 -0
- package/dist/representations/CompactTotalRepresentation.d.ts +2 -0
- package/dist/representations/CompactTotalRepresentation.d.ts.map +1 -0
- package/dist/representations/CompactTotalRepresentation.js +25 -0
- package/dist/representations/Representation.d.ts +2 -0
- package/dist/representations/Representation.d.ts.map +1 -0
- package/dist/representations/Representation.js +28 -0
- package/dist/representations/RepresentationFactory.d.ts +2 -0
- package/dist/representations/RepresentationFactory.d.ts.map +1 -0
- package/dist/representations/RepresentationFactory.js +37 -0
- package/dist/sarif-to-slack.d.ts +337 -85
- package/dist/tsdoc-metadata.json +1 -1
- package/dist/types.d.ts +215 -51
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +225 -33
- package/dist/utils/Comparators.d.ts +2 -0
- package/dist/utils/Comparators.d.ts.map +1 -0
- package/dist/utils/Comparators.js +18 -0
- package/dist/utils/ExtendedArray.d.ts +2 -0
- package/dist/utils/ExtendedArray.d.ts.map +1 -0
- package/dist/utils/ExtendedArray.js +11 -0
- package/dist/utils/FileUtils.d.ts +2 -0
- package/dist/utils/FileUtils.d.ts.map +1 -0
- package/dist/utils/FileUtils.js +51 -0
- package/dist/utils/SarifUtils.js +20 -54
- package/etc/sarif-to-slack.api.md +161 -99
- package/jest.config.json +2 -2
- package/package.json +7 -7
- package/scripts/save-metadata.sh +12 -10
- package/src/Logger.ts +4 -0
- package/src/SarifToSlackClient.ts +202 -0
- package/src/SlackMessageBuilder.ts +35 -115
- package/src/System.ts +9 -2
- package/src/index.ts +47 -20
- package/src/model/Color.ts +201 -0
- package/src/model/Finding.ts +137 -0
- package/src/model/FindingsArray.ts +27 -0
- package/src/processors/CodeQLProcessor.ts +19 -0
- package/src/processors/CommonProcessor.ts +103 -0
- package/src/processors/ProcessorFactory.ts +23 -0
- package/src/processors/SnykProcessor.ts +19 -0
- package/src/representations/CompactGroupByRepresentation.ts +67 -0
- package/src/representations/CompactGroupByRunPerLevelRepresentation.ts +14 -0
- package/src/representations/CompactGroupByRunPerSeverityRepresentation.ts +14 -0
- package/src/representations/CompactGroupByRunRepresentation.ts +44 -0
- package/src/representations/CompactGroupBySarifPerLevelRepresentation.ts +15 -0
- package/src/representations/CompactGroupBySarifPerSeverityRepresentation.ts +15 -0
- package/src/representations/CompactGroupBySarifRepresentation.ts +45 -0
- package/src/representations/CompactGroupByToolNamePerLevelRepresentation.ts +15 -0
- package/src/representations/CompactGroupByToolNamePerSeverityRepresentation.ts +15 -0
- package/src/representations/CompactGroupByToolNameRepresentation.ts +44 -0
- package/src/representations/CompactTotalPerLevelRepresentation.ts +14 -0
- package/src/representations/CompactTotalPerSeverityRepresentation.ts +14 -0
- package/src/representations/CompactTotalRepresentation.ts +27 -0
- package/src/representations/Representation.ts +35 -0
- package/src/representations/RepresentationFactory.ts +49 -0
- package/src/types.ts +270 -53
- package/src/utils/Comparators.ts +19 -0
- package/src/utils/ExtendedArray.ts +11 -0
- package/src/utils/FileUtils.ts +60 -0
- package/src/utils/SarifUtils.ts +20 -72
- package/test-data/sarif/codeql-python.sarif +1448 -1
- package/test-data/sarif/codeql-typescript.sarif +3474 -1
- package/test-data/sarif/grype-github-actions.sarif +65 -0
- package/test-data/sarif/osv-scanner-composer.sarif +972 -0
- package/test-data/sarif/osv-scanner-container.sarif +2278 -0
- package/test-data/sarif/osv-scanner-gomodules.sarif +813 -0
- package/test-data/sarif/osv-scanner-hex.sarif +147 -0
- package/test-data/sarif/osv-scanner-maven.sarif +171 -0
- package/test-data/sarif/osv-scanner-npm.sarif +627 -0
- package/test-data/sarif/osv-scanner-pip.sarif +206 -0
- package/test-data/sarif/osv-scanner-pipenv.sarif +243 -0
- package/test-data/sarif/osv-scanner-pnpm.sarif +174 -0
- package/test-data/sarif/osv-scanner-poetry.sarif +1893 -0
- package/test-data/sarif/osv-scanner-rubygems.sarif +402 -0
- package/test-data/sarif/osv-scanner-uv.sarif +206 -0
- package/test-data/sarif/osv-scanner-yarn.sarif +5207 -0
- package/test-data/sarif/runs-0.sarif +5 -0
- package/test-data/sarif/runs-2-tools-2-results-0.sarif +1 -1
- package/test-data/sarif/runs-2-tools-2.sarif +1 -1
- package/test-data/sarif/runs-3-tools-2-results-0.sarif +1 -1
- package/test-data/sarif/runs-3-tools-2.sarif +1 -1
- package/test-data/sarif/tmp/codeql-csharp.sarif +1 -0
- package/test-data/sarif/tmp/grype-container.sarif +1774 -0
- package/test-data/sarif/tmp/runs-1-tools-1-results-0.sarif +18 -0
- package/test-data/sarif/tmp/runs-2-tools-2.sarif +686 -0
- package/test-data/sarif/trivy-iac.sarif +1 -1
- package/tests/integration/SendSarifToSlack.spec.ts +95 -27
- package/tsconfig.json +2 -0
- package/dist/Processors.d.ts +0 -2
- package/dist/Processors.d.ts.map +0 -1
- package/dist/Processors.js +0 -61
- package/dist/SarifToSlackService.d.ts +0 -39
- package/dist/SarifToSlackService.d.ts.map +0 -1
- package/dist/SarifToSlackService.js +0 -104
- package/dist/metadata.d.ts +0 -2
- package/dist/metadata.d.ts.map +0 -1
- package/dist/metadata.js +0 -11
- package/dist/model/SarifModelPerRun.d.ts +0 -2
- package/dist/model/SarifModelPerRun.d.ts.map +0 -1
- package/dist/model/SarifModelPerRun.js +0 -90
- package/dist/model/SarifModelPerSarif.d.ts +0 -2
- package/dist/model/SarifModelPerSarif.d.ts.map +0 -1
- package/dist/model/SarifModelPerSarif.js +0 -102
- package/dist/model/types.d.ts +0 -2
- package/dist/model/types.d.ts.map +0 -1
- package/dist/model/types.js +0 -49
- package/dist/utils/SortUtils.d.ts +0 -2
- package/dist/utils/SortUtils.d.ts.map +0 -1
- package/dist/utils/SortUtils.js +0 -20
- package/src/Processors.ts +0 -68
- package/src/SarifToSlackService.ts +0 -117
- package/src/metadata.ts +0 -10
- package/src/model/SarifModelPerRun.ts +0 -120
- package/src/model/SarifModelPerSarif.ts +0 -126
- package/src/model/types.ts +0 -50
- package/src/utils/SortUtils.ts +0 -33
- package/tests/Processors.spec.ts +0 -76
|
@@ -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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiRmlsZVV0aWxzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3V0aWxzL0ZpbGVVdGlscy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsTUFBTSxJQUFJLENBQUE7QUFDbkIsT0FBTyxNQUFNLE1BQU0sV0FBVyxDQUFBO0FBRTlCLE9BQU8sS0FBSyxJQUFJLE1BQU0sTUFBTSxDQUFBO0FBRTVCOzs7Ozs7O0dBT0c7QUFDSCxTQUFTLG9CQUFvQixDQUMzQixHQUFXLEVBQ1gsU0FBNkIsRUFDN0IsV0FBcUIsRUFBRTtJQUV2QixNQUFNLE9BQU8sR0FBYSxFQUFFLENBQUMsV0FBVyxDQUFDLEdBQUcsQ0FBQyxDQUFBO0lBQzdDLE9BQU8sQ0FBQyxPQUFPLENBQUMsQ0FBQyxLQUFhLEVBQVEsRUFBRTtRQUN0QyxNQUFNLFFBQVEsR0FBVyxJQUFJLENBQUMsSUFBSSxDQUFDLEdBQUcsRUFBRSxLQUFLLENBQUMsQ0FBQTtRQUM5QyxJQUFJLEVBQUUsQ0FBQyxRQUFRLENBQUMsUUFBUSxDQUFDLENBQUMsV0FBVyxFQUFFLEVBQUUsQ0FBQztZQUN4QyxvQkFBb0IsQ0FBQyxRQUFRLEVBQUUsU0FBUyxFQUFFLFFBQVEsQ0FBQyxDQUFBO1FBQ3JELENBQUM7YUFBTSxJQUFJLElBQUksQ0FBQyxPQUFPLENBQUMsUUFBUSxDQUFDLENBQUMsV0FBVyxFQUFFLEtBQUssSUFBSSxTQUFTLEVBQUUsRUFBRSxDQUFDO1lBQ3BFLFFBQVEsQ0FBQyxJQUFJLENBQUMsUUFBUSxDQUFDLENBQUE7UUFDekIsQ0FBQztJQUNILENBQUMsQ0FBQyxDQUFBO0lBQ0YsT0FBTyxRQUFRLENBQUE7QUFDakIsQ0FBQztBQUVEOzs7OztHQUtHO0FBQ0gsTUFBTSxVQUFVLGtCQUFrQixDQUFDLElBQWtCO0lBQ25ELElBQUksQ0FBQyxFQUFFLENBQUMsVUFBVSxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsRUFBRSxDQUFDO1FBQzlCLE1BQU0sSUFBSSxLQUFLLENBQUMsaUNBQWlDLElBQUksQ0FBQyxJQUFJLEVBQUUsQ0FBQyxDQUFBO0lBQy9ELENBQUM7SUFFRCxNQUFNLEtBQUssR0FBYSxFQUFFLENBQUMsUUFBUSxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsQ0FBQTtJQUU5QyxJQUFJLEtBQUssQ0FBQyxXQUFXLEVBQUUsRUFBRSxDQUFDO1FBQ3hCLE1BQU0sQ0FBQyxJQUFJLENBQUMsaUNBQWlDLElBQUksQ0FBQyxJQUFJLEVBQUUsQ0FBQyxDQUFBO1FBQ3pELE1BQU0sS0FBSyxHQUFhLElBQUksQ0FBQyxTQUFTO2VBQ2pDLG9CQUFvQixDQUFDLElBQUksQ0FBQyxJQUFJLEVBQUUsSUFBSSxDQUFDLFNBQVMsSUFBSSxPQUFPLENBQUM7ZUFDMUQsRUFBRSxDQUFDLFdBQVcsQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUE7UUFDOUIsTUFBTSxDQUFDLElBQUksQ0FBQyxTQUFTLEtBQUssQ0FBQyxNQUFNLGFBQWEsSUFBSSxDQUFDLElBQUksbUJBQW1CLElBQUksQ0FBQyxTQUFTLFlBQVksQ0FBQyxDQUFBO1FBQ3JHLE1BQU0sQ0FBQyxLQUFLLENBQUMsZ0JBQWdCLEtBQUssQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLEVBQUUsQ0FBQyxDQUFBO1FBQ2hELE9BQU8sS0FBSyxDQUFBO0lBQ2QsQ0FBQztJQUVELElBQUksS0FBSyxDQUFDLE1BQU0sRUFBRSxFQUFFLENBQUM7UUFDbkIsTUFBTSxDQUFDLElBQUksQ0FBQyw0QkFBNEIsSUFBSSxDQUFDLElBQUksRUFBRSxDQUFDLENBQUE7UUFDcEQsT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsQ0FBQTtJQUNwQixDQUFDO0lBRUQsTUFBTSxJQUFJLEtBQUssQ0FBQyxvREFBb0QsSUFBSSxDQUFDLElBQUksRUFBRSxDQUFDLENBQUE7QUFDbEYsQ0FBQyJ9
|
package/dist/utils/SarifUtils.js
CHANGED
|
@@ -1,66 +1,32 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* @
|
|
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
|
|
8
|
-
|
|
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
|
-
*
|
|
19
|
-
* @
|
|
20
|
-
*
|
|
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
|
|
24
|
-
|
|
25
|
-
if (result.rule) {
|
|
26
|
-
|
|
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
|
|
21
|
+
return tool;
|
|
50
22
|
}
|
|
51
23
|
/**
|
|
52
|
-
*
|
|
53
|
-
* the
|
|
54
|
-
*
|
|
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
|
|
60
|
-
|
|
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,
|
|
32
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiU2FyaWZVdGlscy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlscy9TYXJpZlV0aWxzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUVBOzs7OztHQUtHO0FBQ0gsTUFBTSxVQUFVLHVCQUF1QixDQUFDLEdBQVE7SUFDOUMsT0FBTyxHQUFHLENBQUMsSUFBSSxDQUFDLE1BQU0sQ0FBQTtBQUN4QixDQUFDO0FBRUQ7Ozs7O0dBS0c7QUFDSCxNQUFNLFVBQVUsNkJBQTZCLENBQUMsR0FBUSxFQUFFLE1BQWM7SUFDcEUsSUFBSSxJQUErQixDQUFBO0lBQ25DLElBQUksTUFBTSxDQUFDLElBQUksRUFBRSxhQUFhLEVBQUUsS0FBSyxJQUFJLElBQUksRUFBRSxDQUFDO1FBQzlDLElBQUksR0FBRyxHQUFHLENBQUMsSUFBSSxDQUFDLFVBQVUsRUFBRSxDQUFDLE1BQU0sQ0FBQyxJQUFJLENBQUMsYUFBYSxDQUFDLEtBQUssQ0FBQyxDQUFBO0lBQy9ELENBQUM7SUFDRCxPQUFPLElBQUksQ0FBQTtBQUNiLENBQUM7QUFFRDs7Ozs7R0FLRztBQUNILE1BQU0sVUFBVSxpQkFBaUIsQ0FBQyxHQUFRLEVBQUUsTUFBYztJQUN4RCxPQUFPLDZCQUE2QixDQUFDLEdBQUcsRUFBRSxNQUFNLENBQUMsSUFBSSx1QkFBdUIsQ0FBQyxHQUFHLENBQUMsQ0FBQTtBQUNuRixDQUFDIn0=
|
|
@@ -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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
// @public
|
|
16
|
-
export type
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fabasoad/sarif-to-slack",
|
|
3
|
-
"version": "0.
|
|
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.
|
|
52
|
-
"@microsoft/api-documenter": "7.26.
|
|
53
|
-
"@microsoft/api-extractor": "7.52.
|
|
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.
|
|
57
|
+
"ts-jest": "29.4.1",
|
|
58
58
|
"tsup": "8.5.0",
|
|
59
|
-
"typescript": "5.
|
|
59
|
+
"typescript": "5.9.2"
|
|
60
60
|
}
|
|
61
61
|
}
|
package/scripts/save-metadata.sh
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env sh
|
|
2
2
|
|
|
3
3
|
version=$(jq -r '.version' package.json)
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|