@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.
Files changed (51) hide show
  1. package/.bin/wait-for-server.sh +1 -0
  2. package/.ct.yaml +6 -0
  3. package/.eslintrc.cjs +3 -3
  4. package/.github/CONTRIBUTING.md +48 -0
  5. package/.github/ISSUE_TEMPLATE/bug_report.md +34 -0
  6. package/.github/ISSUE_TEMPLATE/feature_request.md +25 -0
  7. package/.github/PULL_REQUEST_TEMPLATE.md +35 -0
  8. package/.github/workflows/pipeline.yml +63 -13
  9. package/.github/workflows/release.yml +37 -0
  10. package/.prettierrc +6 -0
  11. package/CHANGELOG.md +22 -0
  12. package/Dockerfile +1 -1
  13. package/README.md +34 -9
  14. package/charts/keycloak-reporter/.helmignore +23 -0
  15. package/charts/keycloak-reporter/Chart.yaml +29 -0
  16. package/charts/keycloak-reporter/README.md +51 -0
  17. package/charts/keycloak-reporter/templates/NOTES.txt +0 -0
  18. package/charts/keycloak-reporter/templates/_helpers.tpl +62 -0
  19. package/charts/keycloak-reporter/templates/cronjob.yaml +66 -0
  20. package/charts/keycloak-reporter/templates/pvc.yaml +15 -0
  21. package/charts/keycloak-reporter/templates/secret.yaml +14 -0
  22. package/charts/keycloak-reporter/templates/serviceaccount.yaml +12 -0
  23. package/charts/keycloak-reporter/values.yaml +79 -0
  24. package/cli.ts +80 -17
  25. package/config/schema.json +8 -0
  26. package/dist/cli.js +58 -15
  27. package/dist/cli.js.map +1 -1
  28. package/dist/config/schema.json +8 -0
  29. package/dist/index.js +0 -0
  30. package/dist/index.js.map +0 -0
  31. package/dist/lib/client.js +0 -0
  32. package/dist/lib/client.js.map +0 -0
  33. package/dist/lib/convert.js +0 -0
  34. package/dist/lib/convert.js.map +0 -0
  35. package/dist/lib/output.js +57 -42
  36. package/dist/lib/output.js.map +1 -1
  37. package/dist/lib/user.js +0 -0
  38. package/dist/lib/user.js.map +0 -0
  39. package/dist/src/cli.js +0 -0
  40. package/dist/src/cli.js.map +0 -0
  41. package/dist/src/config.js +0 -0
  42. package/dist/src/config.js.map +0 -0
  43. package/e2e/spec/clients.js +1 -3
  44. package/e2e/spec/config.js +1 -3
  45. package/e2e/spec/users.js +1 -3
  46. package/e2e/spec/webhooks.js +81 -12
  47. package/jest.config.js +0 -1
  48. package/lib/output.ts +66 -47
  49. package/lintconf.yaml +42 -0
  50. package/package.json +6 -4
  51. package/renovate.json +23 -13
@@ -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
- return new SlackWebhook(url).send({
61
- blocks: [
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: 'section',
64
- fields: [
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
- type: 'context',
90
- elements: [{ type: 'plain_text', text: 'Raw report data' }],
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
  }
@@ -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,MAA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E;wBAC5C;4BACE,IAAI,EAAE,QAAQ;4BACd,IAAI,EAAE,WAAW,IAAI,CAAC,OAAO,EAAE,IAC7B,IAAI,CAAC,QAAQ,EAAE,GAAG,CACpB,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE;yBACzB;qBACF;iBACF;gBACD;oBACE,IAAI,EAAE,SAAS;iBAChB;aACF,CAAC;YACF,IAAI,IAAI,IAAI,IAAI,EAAE;gBAChB,YAAY,CAAC,IAAI,CAAC;oBAChB,IAAI,EAAE,SAAS;oBACf,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;iBAC/C,CAAC,CAAC;gBACH,YAAY,CAAC,IAAI,CAAC;oBAChB,IAAI,EAAE,SAAS;iBAChB,CAAC,CAAC;aACJ;YACD,YAAY,CAAC,IAAI,CACf;gBACE,IAAI,EAAE,SAAS;gBACf,QAAQ,EAAE;oBACR;wBACE,IAAI,EAAE,QAAQ;wBACd,IAAI,EAAE;;EAElB,aAAa;;CAEd;qBACY;iBACF;aACF,EACD;gBACE,IAAI,EAAE,SAAS;gBACf,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,iBAAiB,EAAE,CAAC;aAC5D,CACF,CAAC;YACF,OAAO,IAAI,YAAY,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;gBAChC,MAAM,EAAE,YAAY;aACrB,CAAC,CAAC;KACN;AACH,CAAC;AAED;GACG"}
package/dist/lib/user.js CHANGED
File without changes
File without changes
package/dist/src/cli.js CHANGED
File without changes
File without changes
File without changes
File without changes
@@ -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
  });
@@ -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
  });
@@ -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', { timeout: 3000 }, (t) => {
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('Should post message to Slack', { timeout: 3000 }, (t) => {
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
@@ -10,7 +10,6 @@ export default {
10
10
  collectCoverage: true,
11
11
  collectCoverageFrom: [
12
12
  'index.ts',
13
- 'src/**',
14
13
  'lib/**',
15
14
  ],
16
15
  setupFilesAfterEnv: [
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
- return new SlackWebhook(url).send({
76
- blocks: [
77
- {
78
- type: 'section',
79
- fields: [
80
- { type: 'mrkdwn', text: `*Type*: ${title}` },
81
- {
82
- type: 'mrkdwn',
83
- text: `*Date*: ${date.getDate()}-${
84
- date.getMonth() + 1
85
- }-${date.getFullYear()}`,
86
- },
87
- ],
88
- },
89
- {
90
- type: 'divider',
91
- },
92
- {
93
- type: 'context',
94
- elements: [
95
- {
96
- type: 'mrkdwn',
97
- text: `
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
- type: 'context',
107
- elements: [{ type: 'plain_text', text: 'Raw report data' }],
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.2.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": "^9.6.7",
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": "^3.2.4",
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": "^2.1.1",
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
- "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3
- "extends": [
4
- "config:base"
5
- ],
6
- "packageRules": [
7
- {
8
- "matchDatasources": ["npm"],
9
- "matchUpdateTypes": ["patch"],
10
- "automerge": true
11
- }
12
- ],
13
- "prHourlyLimit": 10
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
+ }