@continuoussecuritytooling/keycloak-reporter 0.2.0 → 0.5.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/.bin/wait-for-server.sh +1 -0
- package/.ct.yaml +6 -0
- package/.eslintrc.cjs +3 -3
- package/.github/CONTRIBUTING.md +48 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +34 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +25 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +35 -0
- package/.github/workflows/pipeline.yml +63 -13
- package/.github/workflows/release.yml +37 -0
- package/.prettierrc +6 -0
- package/CHANGELOG.md +22 -0
- package/Dockerfile +1 -1
- package/README.md +34 -9
- package/charts/keycloak-reporter/.helmignore +23 -0
- package/charts/keycloak-reporter/Chart.yaml +29 -0
- package/charts/keycloak-reporter/README.md +51 -0
- package/charts/keycloak-reporter/templates/NOTES.txt +0 -0
- package/charts/keycloak-reporter/templates/_helpers.tpl +62 -0
- package/charts/keycloak-reporter/templates/cronjob.yaml +66 -0
- package/charts/keycloak-reporter/templates/pvc.yaml +15 -0
- package/charts/keycloak-reporter/templates/secret.yaml +14 -0
- package/charts/keycloak-reporter/templates/serviceaccount.yaml +12 -0
- package/charts/keycloak-reporter/values.yaml +79 -0
- package/cli.ts +80 -17
- package/config/schema.json +8 -0
- package/dist/cli.js +58 -15
- package/dist/cli.js.map +1 -1
- package/dist/config/schema.json +8 -0
- package/dist/index.js +0 -0
- package/dist/index.js.map +0 -0
- package/dist/lib/client.js +0 -0
- package/dist/lib/client.js.map +0 -0
- package/dist/lib/convert.js +0 -0
- package/dist/lib/convert.js.map +0 -0
- package/dist/lib/output.js +57 -42
- package/dist/lib/output.js.map +1 -1
- package/dist/lib/user.js +0 -0
- package/dist/lib/user.js.map +0 -0
- package/dist/src/cli.js +0 -0
- package/dist/src/cli.js.map +0 -0
- package/dist/src/config.js +0 -0
- package/dist/src/config.js.map +0 -0
- package/e2e/spec/clients.js +1 -3
- package/e2e/spec/config.js +1 -3
- package/e2e/spec/users.js +1 -3
- package/e2e/spec/webhooks.js +81 -12
- package/jest.config.js +0 -1
- package/lib/output.ts +66 -47
- package/lintconf.yaml +42 -0
- package/package.json +6 -4
- package/renovate.json +23 -13
package/dist/lib/output.js
CHANGED
|
@@ -5,7 +5,7 @@ var WebhookType;
|
|
|
5
5
|
WebhookType["SLACK"] = "slack";
|
|
6
6
|
WebhookType["TEAMS"] = "teams";
|
|
7
7
|
})(WebhookType || (WebhookType = {}));
|
|
8
|
-
export async function post2Webhook(type, url, title, reportContent) {
|
|
8
|
+
export async function post2Webhook(type, url, title, reportContent, text) {
|
|
9
9
|
//const title= 'Keycloak Reporting';
|
|
10
10
|
const date = new Date();
|
|
11
11
|
switch (type) {
|
|
@@ -25,14 +25,19 @@ export async function post2Webhook(type, url, title, reportContent) {
|
|
|
25
25
|
facts: [
|
|
26
26
|
{
|
|
27
27
|
title: 'Type',
|
|
28
|
-
value: title
|
|
28
|
+
value: title
|
|
29
29
|
},
|
|
30
30
|
{
|
|
31
31
|
title: 'Date',
|
|
32
|
-
value: `${date.getDate()}-${date.getMonth() + 1}-${date.getFullYear()}
|
|
33
|
-
}
|
|
34
|
-
]
|
|
32
|
+
value: `${date.getDate()}-${date.getMonth() + 1}-${date.getFullYear()}`
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
35
|
},
|
|
36
|
+
{
|
|
37
|
+
type: 'TextBlock',
|
|
38
|
+
text: text != null ? text : '',
|
|
39
|
+
wrap: true
|
|
40
|
+
}
|
|
36
41
|
],
|
|
37
42
|
actions: [
|
|
38
43
|
{
|
|
@@ -44,52 +49,62 @@ export async function post2Webhook(type, url, title, reportContent) {
|
|
|
44
49
|
{
|
|
45
50
|
type: 'TextBlock',
|
|
46
51
|
text: reportContent,
|
|
47
|
-
wrap: true
|
|
48
|
-
}
|
|
52
|
+
wrap: true
|
|
53
|
+
}
|
|
49
54
|
],
|
|
50
|
-
$schema: 'http://adaptivecards.io/schemas/adaptive-card.json'
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
]
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
]
|
|
55
|
+
$schema: 'http://adaptivecards.io/schemas/adaptive-card.json'
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
]
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
]
|
|
57
62
|
});
|
|
58
63
|
// defaulting to Slack
|
|
59
64
|
default:
|
|
60
|
-
|
|
61
|
-
|
|
65
|
+
// eslint-disable-next-line no-case-declarations
|
|
66
|
+
const blockEntries = [
|
|
67
|
+
{
|
|
68
|
+
type: 'section',
|
|
69
|
+
fields: [
|
|
70
|
+
{ type: 'mrkdwn', text: `*Type*: ${title}` },
|
|
71
|
+
{
|
|
72
|
+
type: 'mrkdwn',
|
|
73
|
+
text: `*Date*: ${date.getDate()}-${date.getMonth() + 1}-${date.getFullYear()}`
|
|
74
|
+
}
|
|
75
|
+
]
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
type: 'divider'
|
|
79
|
+
}
|
|
80
|
+
];
|
|
81
|
+
if (text != null) {
|
|
82
|
+
blockEntries.push({
|
|
83
|
+
type: 'context',
|
|
84
|
+
elements: [{ type: 'plain_text', text: text }]
|
|
85
|
+
});
|
|
86
|
+
blockEntries.push({
|
|
87
|
+
type: 'divider'
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
blockEntries.push({
|
|
91
|
+
type: 'context',
|
|
92
|
+
elements: [
|
|
62
93
|
{
|
|
63
|
-
type: '
|
|
64
|
-
|
|
65
|
-
{ type: 'mrkdwn', text: `*Type*: ${title}` },
|
|
66
|
-
{
|
|
67
|
-
type: 'mrkdwn',
|
|
68
|
-
text: `*Date*: ${date.getDate()}-${date.getMonth() + 1}-${date.getFullYear()}`,
|
|
69
|
-
},
|
|
70
|
-
],
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
type: 'divider',
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
type: 'context',
|
|
77
|
-
elements: [
|
|
78
|
-
{
|
|
79
|
-
type: 'mrkdwn',
|
|
80
|
-
text: `
|
|
94
|
+
type: 'mrkdwn',
|
|
95
|
+
text: `
|
|
81
96
|
\`\`\`
|
|
82
97
|
${reportContent}
|
|
83
98
|
\`\`\`
|
|
84
99
|
`
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
100
|
+
}
|
|
101
|
+
]
|
|
102
|
+
}, {
|
|
103
|
+
type: 'context',
|
|
104
|
+
elements: [{ type: 'plain_text', text: 'Raw report data' }]
|
|
105
|
+
});
|
|
106
|
+
return new SlackWebhook(url).send({
|
|
107
|
+
blocks: blockEntries
|
|
93
108
|
});
|
|
94
109
|
}
|
|
95
110
|
}
|
package/dist/lib/output.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output.js","sourceRoot":"","sources":["../../lib/output.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,IAAI,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEnE,OAAO,EAAE,eAAe,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEjE,IAAK,WAGJ;AAHD,WAAK,WAAW;IACd,8BAAe,CAAA;IACf,8BAAe,CAAA;AACjB,CAAC,EAHI,WAAW,KAAX,WAAW,QAGf;AAOD,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,IAAY,EACZ,GAAW,EACX,KAAa,EACb,aAAqB;
|
|
1
|
+
{"version":3,"file":"output.js","sourceRoot":"","sources":["../../lib/output.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,IAAI,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEnE,OAAO,EAAE,eAAe,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEjE,IAAK,WAGJ;AAHD,WAAK,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File without changes
|
package/dist/lib/user.js.map
CHANGED
|
File without changes
|
package/dist/src/cli.js
CHANGED
|
File without changes
|
package/dist/src/cli.js.map
CHANGED
|
File without changes
|
package/dist/src/config.js
CHANGED
|
File without changes
|
package/dist/src/config.js.map
CHANGED
|
File without changes
|
package/e2e/spec/clients.js
CHANGED
|
@@ -23,11 +23,9 @@ test('Should list clients as JSON', { timeout: 3000 }, (t) => {
|
|
|
23
23
|
cli.stdout.on('data', (chunk) => {
|
|
24
24
|
console.log(chunk.toString())
|
|
25
25
|
t.equal(JSON.parse(chunk.toString()).length, 24);
|
|
26
|
+
t.end();
|
|
26
27
|
});
|
|
27
28
|
cli.stderr.on('data', (msg) => {
|
|
28
29
|
t.fail(msg)
|
|
29
30
|
});
|
|
30
|
-
cli.stdout.on('end', () => {
|
|
31
|
-
t.end();
|
|
32
|
-
});
|
|
33
31
|
});
|
package/e2e/spec/config.js
CHANGED
|
@@ -21,11 +21,9 @@ test('Should use config file', { timeout: 3000 }, (t) => {
|
|
|
21
21
|
cli.stdout.on('data', (chunk) => {
|
|
22
22
|
console.log(chunk.toString())
|
|
23
23
|
t.equal(JSON.parse(chunk.toString()).length, 24);
|
|
24
|
+
t.end();
|
|
24
25
|
});
|
|
25
26
|
cli.stderr.on('data', (msg) => {
|
|
26
27
|
t.fail(msg)
|
|
27
28
|
});
|
|
28
|
-
cli.stdout.on('end', () => {
|
|
29
|
-
t.end();
|
|
30
|
-
});
|
|
31
29
|
});
|
package/e2e/spec/users.js
CHANGED
|
@@ -23,11 +23,9 @@ test('Should list users as JSON', { timeout: 3000 }, (t) => {
|
|
|
23
23
|
cli.stdout.on('data', (chunk) => {
|
|
24
24
|
console.log(chunk.toString())
|
|
25
25
|
t.equal(JSON.parse(chunk.toString()).length, 3);
|
|
26
|
+
t.end();
|
|
26
27
|
});
|
|
27
28
|
cli.stderr.on('data', (msg) => {
|
|
28
29
|
t.fail(msg)
|
|
29
30
|
});
|
|
30
|
-
cli.stdout.on('end', () => {
|
|
31
|
-
t.end();
|
|
32
|
-
});
|
|
33
31
|
});
|
package/e2e/spec/webhooks.js
CHANGED
|
@@ -4,7 +4,7 @@ import { test } from 'tape';
|
|
|
4
4
|
import { spawn } from 'node:child_process';
|
|
5
5
|
import path from 'node:path';
|
|
6
6
|
|
|
7
|
-
test('Should post message to Teams',
|
|
7
|
+
test('Should post message to Teams', { timeout: 10000 }, (t) => {
|
|
8
8
|
const cli = spawn(
|
|
9
9
|
path.join(path.dirname('.'), 'node'),
|
|
10
10
|
[
|
|
@@ -15,26 +15,64 @@ test('Should post message to Teams', { timeout: 3000 }, (t) => {
|
|
|
15
15
|
'3UYhI2hryFwoVtcd7ljlaDuD9HXrGV5r',
|
|
16
16
|
'--output=webhook',
|
|
17
17
|
'--webhookType=teams',
|
|
18
|
-
'--webhookUrl=' + process.env.WEBHOOK_TESTING_TEAMS
|
|
18
|
+
'--webhookUrl=' + process.env.WEBHOOK_TESTING_TEAMS
|
|
19
19
|
],
|
|
20
20
|
{
|
|
21
21
|
env: {
|
|
22
|
-
...process.env
|
|
23
|
-
}
|
|
22
|
+
...process.env
|
|
23
|
+
}
|
|
24
24
|
}
|
|
25
25
|
);
|
|
26
26
|
cli.stdout.on('data', (chunk) => {
|
|
27
|
-
console.log(chunk.toString())
|
|
27
|
+
console.log(chunk.toString());
|
|
28
28
|
});
|
|
29
29
|
cli.stderr.on('data', (msg) => {
|
|
30
|
-
t.fail(msg)
|
|
30
|
+
t.fail(msg);
|
|
31
31
|
});
|
|
32
32
|
cli.stdout.on('end', () => {
|
|
33
33
|
t.end();
|
|
34
34
|
});
|
|
35
35
|
});
|
|
36
36
|
|
|
37
|
-
test(
|
|
37
|
+
test(
|
|
38
|
+
'Should post message to Teams with additional message',
|
|
39
|
+
{ timeout: 10000 },
|
|
40
|
+
(t) => {
|
|
41
|
+
const cli = spawn(
|
|
42
|
+
path.join(path.dirname('.'), 'node'),
|
|
43
|
+
[
|
|
44
|
+
'dist/cli.js',
|
|
45
|
+
'listUsers',
|
|
46
|
+
'http://localhost:8080',
|
|
47
|
+
'keycloak-reporter',
|
|
48
|
+
'3UYhI2hryFwoVtcd7ljlaDuD9HXrGV5r',
|
|
49
|
+
'--output=webhook',
|
|
50
|
+
'--webhookType=teams',
|
|
51
|
+
'--webhookUrl=' + process.env.WEBHOOK_TESTING_TEAMS,
|
|
52
|
+
'--webhookMessage="From Github Actions"'
|
|
53
|
+
],
|
|
54
|
+
{
|
|
55
|
+
env: {
|
|
56
|
+
...process.env
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
cli.stdout.on('data', (chunk) => {
|
|
61
|
+
console.log(chunk.toString());
|
|
62
|
+
});
|
|
63
|
+
cli.stderr.on('data', (msg) => {
|
|
64
|
+
t.fail(msg);
|
|
65
|
+
});
|
|
66
|
+
cli.stdout.on('end', () => {
|
|
67
|
+
t.end();
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
test(
|
|
73
|
+
'Should post message to Slack with additional message',
|
|
74
|
+
{ timeout: 10000 },
|
|
75
|
+
(t) => {
|
|
38
76
|
const cli = spawn(
|
|
39
77
|
path.join(path.dirname('.'), 'node'),
|
|
40
78
|
[
|
|
@@ -46,21 +84,52 @@ test('Should post message to Slack', { timeout: 3000 }, (t) => {
|
|
|
46
84
|
'--output=webhook',
|
|
47
85
|
'--webhookType=slack',
|
|
48
86
|
'--webhookUrl=' + process.env.WEBHOOK_TESTING_SLACK,
|
|
87
|
+
'--webhookMessage="From Github Actions"'
|
|
49
88
|
],
|
|
50
89
|
{
|
|
51
90
|
env: {
|
|
52
|
-
...process.env
|
|
53
|
-
}
|
|
91
|
+
...process.env
|
|
92
|
+
}
|
|
54
93
|
}
|
|
55
94
|
);
|
|
56
95
|
cli.stdout.on('data', (chunk) => {
|
|
57
|
-
console.log(chunk.toString())
|
|
96
|
+
console.log(chunk.toString());
|
|
58
97
|
});
|
|
59
98
|
cli.stderr.on('data', (msg) => {
|
|
60
|
-
t.fail(msg)
|
|
99
|
+
t.fail(msg);
|
|
61
100
|
});
|
|
62
101
|
cli.stdout.on('end', () => {
|
|
63
102
|
t.end();
|
|
64
103
|
});
|
|
104
|
+
}
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
test('Should post message to Slack', { timeout: 10000 }, (t) => {
|
|
108
|
+
const cli = spawn(
|
|
109
|
+
path.join(path.dirname('.'), 'node'),
|
|
110
|
+
[
|
|
111
|
+
'dist/cli.js',
|
|
112
|
+
'listUsers',
|
|
113
|
+
'http://localhost:8080',
|
|
114
|
+
'keycloak-reporter',
|
|
115
|
+
'3UYhI2hryFwoVtcd7ljlaDuD9HXrGV5r',
|
|
116
|
+
'--output=webhook',
|
|
117
|
+
'--webhookType=slack',
|
|
118
|
+
'--webhookUrl=' + process.env.WEBHOOK_TESTING_SLACK
|
|
119
|
+
],
|
|
120
|
+
{
|
|
121
|
+
env: {
|
|
122
|
+
...process.env
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
);
|
|
126
|
+
cli.stdout.on('data', (chunk) => {
|
|
127
|
+
console.log(chunk.toString());
|
|
65
128
|
});
|
|
66
|
-
|
|
129
|
+
cli.stderr.on('data', (msg) => {
|
|
130
|
+
t.fail(msg);
|
|
131
|
+
});
|
|
132
|
+
cli.stdout.on('end', () => {
|
|
133
|
+
t.end();
|
|
134
|
+
});
|
|
135
|
+
});
|
package/jest.config.js
CHANGED
package/lib/output.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { IncomingWebhook as TeamsWebhook } from 'ms-teams-webhook';
|
|
2
|
-
import { Block, SectionBlock } from '@slack/types';
|
|
2
|
+
import { Block, ContextBlock, SectionBlock } from '@slack/types';
|
|
3
3
|
import { IncomingWebhook as SlackWebhook } from '@slack/webhook';
|
|
4
4
|
|
|
5
5
|
enum WebhookType {
|
|
6
6
|
SLACK = 'slack',
|
|
7
|
-
TEAMS = 'teams'
|
|
7
|
+
TEAMS = 'teams'
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export interface WebhookMessage {
|
|
@@ -16,7 +16,8 @@ export async function post2Webhook(
|
|
|
16
16
|
type: string,
|
|
17
17
|
url: string,
|
|
18
18
|
title: string,
|
|
19
|
-
reportContent: string
|
|
19
|
+
reportContent: string,
|
|
20
|
+
text?: string
|
|
20
21
|
): Promise<unknown> {
|
|
21
22
|
//const title= 'Keycloak Reporting';
|
|
22
23
|
const date = new Date();
|
|
@@ -37,16 +38,21 @@ export async function post2Webhook(
|
|
|
37
38
|
facts: [
|
|
38
39
|
{
|
|
39
40
|
title: 'Type',
|
|
40
|
-
value: title
|
|
41
|
+
value: title
|
|
41
42
|
},
|
|
42
43
|
{
|
|
43
44
|
title: 'Date',
|
|
44
45
|
value: `${date.getDate()}-${
|
|
45
46
|
date.getMonth() + 1
|
|
46
|
-
}-${date.getFullYear()}
|
|
47
|
-
}
|
|
48
|
-
]
|
|
47
|
+
}-${date.getFullYear()}`
|
|
48
|
+
}
|
|
49
|
+
]
|
|
49
50
|
},
|
|
51
|
+
{
|
|
52
|
+
type: 'TextBlock',
|
|
53
|
+
text: text != null ? text : '',
|
|
54
|
+
wrap: true
|
|
55
|
+
}
|
|
50
56
|
],
|
|
51
57
|
actions: [
|
|
52
58
|
{
|
|
@@ -58,55 +64,68 @@ export async function post2Webhook(
|
|
|
58
64
|
{
|
|
59
65
|
type: 'TextBlock',
|
|
60
66
|
text: reportContent,
|
|
61
|
-
wrap: true
|
|
62
|
-
}
|
|
67
|
+
wrap: true
|
|
68
|
+
}
|
|
63
69
|
],
|
|
64
70
|
$schema:
|
|
65
|
-
'http://adaptivecards.io/schemas/adaptive-card.json'
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
]
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
]
|
|
71
|
+
'http://adaptivecards.io/schemas/adaptive-card.json'
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
]
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
]
|
|
72
78
|
});
|
|
73
79
|
// defaulting to Slack
|
|
74
80
|
default:
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
81
|
+
// eslint-disable-next-line no-case-declarations
|
|
82
|
+
const blockEntries: Array<Block | ContextBlock | SectionBlock> = [
|
|
83
|
+
{
|
|
84
|
+
type: 'section',
|
|
85
|
+
fields: [
|
|
86
|
+
{ type: 'mrkdwn', text: `*Type*: ${title}` },
|
|
87
|
+
{
|
|
88
|
+
type: 'mrkdwn',
|
|
89
|
+
text: `*Date*: ${date.getDate()}-${
|
|
90
|
+
date.getMonth() + 1
|
|
91
|
+
}-${date.getFullYear()}`
|
|
92
|
+
}
|
|
93
|
+
]
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
type: 'divider'
|
|
97
|
+
}
|
|
98
|
+
];
|
|
99
|
+
if (text != null) {
|
|
100
|
+
blockEntries.push({
|
|
101
|
+
type: 'context',
|
|
102
|
+
elements: [{ type: 'plain_text', text: text }]
|
|
103
|
+
});
|
|
104
|
+
blockEntries.push({
|
|
105
|
+
type: 'divider'
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
blockEntries.push(
|
|
109
|
+
{
|
|
110
|
+
type: 'context',
|
|
111
|
+
elements: [
|
|
112
|
+
{
|
|
113
|
+
type: 'mrkdwn',
|
|
114
|
+
text: `
|
|
98
115
|
\`\`\`
|
|
99
116
|
${reportContent}
|
|
100
117
|
\`\`\`
|
|
101
118
|
`
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
119
|
+
}
|
|
120
|
+
]
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
type: 'context',
|
|
124
|
+
elements: [{ type: 'plain_text', text: 'Raw report data' }]
|
|
125
|
+
}
|
|
126
|
+
);
|
|
127
|
+
return new SlackWebhook(url).send({
|
|
128
|
+
blocks: blockEntries
|
|
110
129
|
});
|
|
111
130
|
}
|
|
112
131
|
}
|
package/lintconf.yaml
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
rules:
|
|
3
|
+
braces:
|
|
4
|
+
min-spaces-inside: 0
|
|
5
|
+
max-spaces-inside: 0
|
|
6
|
+
min-spaces-inside-empty: -1
|
|
7
|
+
max-spaces-inside-empty: -1
|
|
8
|
+
brackets:
|
|
9
|
+
min-spaces-inside: 0
|
|
10
|
+
max-spaces-inside: 0
|
|
11
|
+
min-spaces-inside-empty: -1
|
|
12
|
+
max-spaces-inside-empty: -1
|
|
13
|
+
colons:
|
|
14
|
+
max-spaces-before: 0
|
|
15
|
+
max-spaces-after: 1
|
|
16
|
+
commas:
|
|
17
|
+
max-spaces-before: 0
|
|
18
|
+
min-spaces-after: 1
|
|
19
|
+
max-spaces-after: 1
|
|
20
|
+
comments:
|
|
21
|
+
require-starting-space: true
|
|
22
|
+
min-spaces-from-content: 2
|
|
23
|
+
document-end: disable
|
|
24
|
+
document-start: disable # No --- to start a file
|
|
25
|
+
empty-lines:
|
|
26
|
+
max: 2
|
|
27
|
+
max-start: 0
|
|
28
|
+
max-end: 0
|
|
29
|
+
hyphens:
|
|
30
|
+
max-spaces-after: 1
|
|
31
|
+
indentation:
|
|
32
|
+
spaces: consistent
|
|
33
|
+
indent-sequences: whatever # - list indentation will handle both indentation and without
|
|
34
|
+
check-multi-line-strings: false
|
|
35
|
+
key-duplicates: enable
|
|
36
|
+
line-length: disable # Lines can be any length
|
|
37
|
+
new-line-at-end-of-file: disable
|
|
38
|
+
new-lines:
|
|
39
|
+
type: unix
|
|
40
|
+
trailing-spaces: enable
|
|
41
|
+
truthy:
|
|
42
|
+
level: warning
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@continuoussecuritytooling/keycloak-reporter",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Reporting Tools for Keycloak",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"ajv": "^8.12.0",
|
|
32
32
|
"install": "^0.13.0",
|
|
33
33
|
"ms-teams-webhook": "^2.0.2",
|
|
34
|
-
"npm": "^
|
|
34
|
+
"npm": "^10.0.0",
|
|
35
35
|
"openid-client": "^5.4.2",
|
|
36
36
|
"ramda": "^0.29.0",
|
|
37
37
|
"yargs": "^17.7.2"
|
|
@@ -44,13 +44,15 @@
|
|
|
44
44
|
"@typescript-eslint/eslint-plugin": "^5.59.6",
|
|
45
45
|
"@typescript-eslint/parser": "^5.59.6",
|
|
46
46
|
"eslint": "^8.40.0",
|
|
47
|
+
"eslint-config-prettier": "^9.0.0",
|
|
48
|
+
"eslint-plugin-prettier": "^5.0.0",
|
|
47
49
|
"gunzip-maybe": "^1.4.2",
|
|
48
50
|
"jest": "^29.5.0",
|
|
49
|
-
"jest-extended": "^
|
|
51
|
+
"jest-extended": "^4.0.0",
|
|
50
52
|
"node-fetch": "^3.3.1",
|
|
51
53
|
"tap-xunit": "^2.4.1",
|
|
52
54
|
"tape": "^5.6.3",
|
|
53
|
-
"tar-fs": "^
|
|
55
|
+
"tar-fs": "^3.0.0",
|
|
54
56
|
"ts-jest": "^29.1.0",
|
|
55
57
|
"typescript": "^5.0.4"
|
|
56
58
|
}
|
package/renovate.json
CHANGED
|
@@ -1,14 +1,24 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
2
|
+
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
|
3
|
+
"extends": ["config:base", ":rebaseStalePrs"],
|
|
4
|
+
"platformAutomerge": true,
|
|
5
|
+
"packageRules": [
|
|
6
|
+
{
|
|
7
|
+
"description": "Automatically merge minor and patch-level updates",
|
|
8
|
+
"matchUpdateTypes": ["minor", "patch", "digest"],
|
|
9
|
+
"automerge": true,
|
|
10
|
+
"automergeType": "branch"
|
|
11
|
+
}
|
|
12
|
+
],
|
|
13
|
+
"regexManagers": [
|
|
14
|
+
{
|
|
15
|
+
"description": "Update version entries in YAML files",
|
|
16
|
+
"fileMatch": [".*y[a]?ml$"],
|
|
17
|
+
"matchStrings": [
|
|
18
|
+
"# renovate: datasource=(?<datasource>[a-z-]+?)(?: lookupName=(?<lookupName>.+?))?(?: versioning=(?<versioning>[a-z-]+?))?\\sRUN install-[a-z]+? (?<depName>[a-z-]+?) (?<currentValue>.+?)\\s"
|
|
19
|
+
],
|
|
20
|
+
"versioningTemplate": "{{#if versioning}}{{versioning}}{{else}}semver{{/if}}"
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
"prHourlyLimit": 10
|
|
24
|
+
}
|