@fabasoad/sarif-to-slack 0.1.0 → 0.2.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/ISSUE_TEMPLATE/bug_report.md +1 -1
- package/.github/pull_request_template.md +3 -3
- package/.github/workflows/linting.yml +14 -0
- package/.github/workflows/release.yml +2 -0
- package/.github/workflows/unit-tests.yml +1 -0
- package/.pre-commit-config.yaml +2 -2
- package/CONTRIBUTING.md +1 -1
- package/Makefile +1 -1
- package/README.md +36 -5
- package/api-extractor.json +1 -1
- package/biome.json +15 -12
- package/dist/Logger.d.ts +2 -0
- package/dist/Logger.d.ts.map +1 -0
- package/dist/Logger.js +25 -0
- package/dist/Processors.d.ts +2 -0
- package/dist/Processors.d.ts.map +1 -0
- package/dist/Processors.js +91 -0
- package/dist/SarifToSlackService.d.ts +39 -0
- package/dist/SarifToSlackService.d.ts.map +1 -0
- package/dist/SarifToSlackService.js +95 -0
- package/dist/SlackMessageBuilder.d.ts +2 -0
- package/dist/SlackMessageBuilder.d.ts.map +1 -0
- package/dist/SlackMessageBuilder.js +145 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +46 -0
- package/dist/sarif-to-slack.d.ts +28 -9
- package/dist/types.d.ts +104 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +45 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +4 -0
- package/etc/sarif-to-slack.api.md +19 -6
- package/jest.config.json +2 -2
- package/package.json +10 -5
- package/scripts/save-version.sh +6 -0
- package/src/Logger.ts +2 -0
- package/src/SarifToSlackService.ts +5 -3
- package/src/SlackMessageBuilder.ts +11 -9
- package/src/index.ts +7 -4
- package/src/types.ts +24 -6
- package/src/version.ts +3 -0
- package/tsconfig.json +27 -13
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { AnyBlock } from '@slack/types'
|
|
2
|
-
import {
|
|
2
|
+
import { ContextBlock, HeaderBlock } from '@slack/types/dist/block-kit/blocks'
|
|
3
|
+
import { TextObject } from '@slack/types/dist/block-kit/composition-objects'
|
|
3
4
|
import { IncomingWebhook } from '@slack/webhook'
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
5
|
+
import { FooterType, Sarif, SlackMessage } from './types'
|
|
6
|
+
import type { ReportingDescriptor, Result, Run } from 'sarif'
|
|
7
|
+
import { LIB_VERSION } from './version'
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
10
|
* Options for the SlackMessageBuilder.
|
|
@@ -61,14 +63,14 @@ export class SlackMessageBuilder implements SlackMessage {
|
|
|
61
63
|
this.runId = process.env.GITHUB_RUN_ID
|
|
62
64
|
}
|
|
63
65
|
|
|
64
|
-
withFooter(
|
|
65
|
-
const repoName = 'fabasoad/sarif-to-slack
|
|
66
|
+
withFooter(text?: string, type?: FooterType): void {
|
|
67
|
+
const repoName = 'fabasoad/sarif-to-slack'
|
|
68
|
+
const element: TextObject = text
|
|
69
|
+
? { type: type || FooterType.PLAIN_TEXT, text }
|
|
70
|
+
: { type: FooterType.MARKDOWN, text: `Generated by <${this.gitHubServerUrl}/${repoName}|@${repoName}@${LIB_VERSION}>` }
|
|
66
71
|
this.footer = {
|
|
67
72
|
type: 'context',
|
|
68
|
-
elements: [
|
|
69
|
-
type: footer ? 'plain_text' : 'mrkdwn',
|
|
70
|
-
text: footer || `Generated by <${this.gitHubServerUrl}/${repoName}|${repoName}>`
|
|
71
|
-
}],
|
|
73
|
+
elements: [element],
|
|
72
74
|
}
|
|
73
75
|
}
|
|
74
76
|
|
package/src/index.ts
CHANGED
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
*
|
|
10
10
|
* @example
|
|
11
11
|
* ```typescript
|
|
12
|
-
* import { SarifToSlackService } from 'sarif-to-slack';
|
|
12
|
+
* import { SarifToSlackService, FooterType } from '@fabasoad/sarif-to-slack';
|
|
13
13
|
*
|
|
14
|
-
* const service =
|
|
14
|
+
* const service = await SarifToSlackService.create({
|
|
15
15
|
* webhookUrl: 'https://hooks.slack.com/services/your/webhook/url',
|
|
16
16
|
* sarifPath: 'path/to/your/sarif/file.sarif',
|
|
17
17
|
* logLevel: 'info',
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
* },
|
|
25
25
|
* footer: {
|
|
26
26
|
* include: true,
|
|
27
|
+
* type: FooterType.PLAIN_TEXT,
|
|
27
28
|
* value: 'Generated by @fabasoad/sarif-to-slack'
|
|
28
29
|
* },
|
|
29
30
|
* actor: {
|
|
@@ -43,8 +44,10 @@
|
|
|
43
44
|
*/
|
|
44
45
|
export { SarifToSlackService } from './SarifToSlackService'
|
|
45
46
|
export {
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
FooterOptions,
|
|
48
|
+
FooterType,
|
|
49
|
+
IncludeAwareOptions,
|
|
50
|
+
IncludeAwareWithValueOptions,
|
|
48
51
|
LogLevel,
|
|
49
52
|
Sarif,
|
|
50
53
|
SarifToSlackServiceOptions,
|
package/src/types.ts
CHANGED
|
@@ -62,7 +62,7 @@ export enum LogLevel {
|
|
|
62
62
|
* in the Slack message.
|
|
63
63
|
* @public
|
|
64
64
|
*/
|
|
65
|
-
export type
|
|
65
|
+
export type IncludeAwareOptions = {
|
|
66
66
|
include: boolean
|
|
67
67
|
}
|
|
68
68
|
|
|
@@ -71,10 +71,28 @@ export type IncludeAwareProps = {
|
|
|
71
71
|
* in the Slack message, along with an optional value.
|
|
72
72
|
* @public
|
|
73
73
|
*/
|
|
74
|
-
export type
|
|
74
|
+
export type IncludeAwareWithValueOptions = IncludeAwareOptions & {
|
|
75
75
|
value?: string
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
/**
|
|
79
|
+
* Enum representing the type of footer in a Slack message.
|
|
80
|
+
* @public
|
|
81
|
+
*/
|
|
82
|
+
export enum FooterType {
|
|
83
|
+
PLAIN_TEXT = 'plain_text',
|
|
84
|
+
MARKDOWN = 'mrkdwn'
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Options for the footer of a Slack message. "type" is ignored if "value" is
|
|
89
|
+
* not defined.
|
|
90
|
+
* @public
|
|
91
|
+
*/
|
|
92
|
+
export type FooterOptions = IncludeAwareWithValueOptions & {
|
|
93
|
+
type?: FooterType
|
|
94
|
+
}
|
|
95
|
+
|
|
78
96
|
/**
|
|
79
97
|
* Options for the SarifToSlackService.
|
|
80
98
|
* @public
|
|
@@ -87,8 +105,8 @@ export type SarifToSlackServiceOptions = {
|
|
|
87
105
|
iconUrl?: string,
|
|
88
106
|
color?: string,
|
|
89
107
|
logLevel?: LogLevel | string,
|
|
90
|
-
header?:
|
|
91
|
-
footer?:
|
|
92
|
-
actor?:
|
|
93
|
-
run?:
|
|
108
|
+
header?: IncludeAwareWithValueOptions,
|
|
109
|
+
footer?: FooterOptions,
|
|
110
|
+
actor?: IncludeAwareWithValueOptions,
|
|
111
|
+
run?: IncludeAwareOptions,
|
|
94
112
|
}
|
package/src/version.ts
ADDED
package/tsconfig.json
CHANGED
|
@@ -1,21 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json.schemastore.org/tsconfig",
|
|
3
3
|
"compilerOptions": {
|
|
4
|
-
"
|
|
5
|
-
"
|
|
4
|
+
"allowSyntheticDefaultImports": true,
|
|
5
|
+
"alwaysStrict": true,
|
|
6
|
+
"baseUrl": ".",
|
|
6
7
|
"declaration": true,
|
|
7
|
-
"
|
|
8
|
+
"declarationDir": "dist",
|
|
8
9
|
"declarationMap": true,
|
|
9
|
-
"
|
|
10
|
-
"
|
|
10
|
+
"downlevelIteration": true,
|
|
11
|
+
"emitDecoratorMetadata": true,
|
|
12
|
+
"esModuleInterop": true,
|
|
13
|
+
"experimentalDecorators": true,
|
|
14
|
+
"forceConsistentCasingInFileNames": true,
|
|
15
|
+
"inlineSourceMap": true,
|
|
16
|
+
"lib": ["es2024"],
|
|
17
|
+
"module": "es2022",
|
|
18
|
+
"moduleResolution": "node",
|
|
11
19
|
"newLine": "lf",
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"
|
|
20
|
+
"noFallthroughCasesInSwitch": true,
|
|
21
|
+
"noImplicitAny": true,
|
|
22
|
+
"noImplicitThis": true,
|
|
23
|
+
"noUnusedLocals": true,
|
|
24
|
+
"noUnusedParameters": true,
|
|
25
|
+
"outDir": "dist",
|
|
26
|
+
"skipLibCheck": true,
|
|
27
|
+
"strict": true,
|
|
28
|
+
"stripInternal": true,
|
|
29
|
+
"target": "es2024",
|
|
30
|
+
"typeRoots": ["node_modules/@types", "@types"],
|
|
31
|
+
"types": ["node", "jest"]
|
|
16
32
|
},
|
|
17
|
-
"include": [
|
|
18
|
-
|
|
19
|
-
],
|
|
20
|
-
"exclude": ["node_modules", "tests"]
|
|
33
|
+
"include": ["src"],
|
|
34
|
+
"exclude": ["node_modules", "dist", "tests"]
|
|
21
35
|
}
|