@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
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{{- $fullName := include "keycloak-reporter.fullname" . -}}
|
|
2
|
+
{{- range .Values.cronjobs }}
|
|
3
|
+
apiVersion: batch/v1
|
|
4
|
+
kind: CronJob
|
|
5
|
+
metadata:
|
|
6
|
+
name: {{ printf "%s-job-%s" $fullName .name }}
|
|
7
|
+
spec:
|
|
8
|
+
schedule: "{{ .schedule }}"
|
|
9
|
+
jobTemplate:
|
|
10
|
+
spec:
|
|
11
|
+
template:
|
|
12
|
+
{{- with $.Values.podAnnotations }}
|
|
13
|
+
annotations:
|
|
14
|
+
{{- toYaml . | nindent 8 }}
|
|
15
|
+
{{- end }}
|
|
16
|
+
spec:
|
|
17
|
+
{{- with $.Values.imagePullSecrets }}
|
|
18
|
+
imagePullSecrets:
|
|
19
|
+
{{- toYaml . | nindent 8 }}
|
|
20
|
+
{{- end }}
|
|
21
|
+
containers:
|
|
22
|
+
- name: {{ .name }}
|
|
23
|
+
image: "{{ $.Values.image.repository }}:{{ $.Values.image.tag | default $.Chart.AppVersion }}"
|
|
24
|
+
imagePullPolicy: {{ $.Values.image.pullPolicy }}
|
|
25
|
+
command:
|
|
26
|
+
- /bin/sh
|
|
27
|
+
- -c
|
|
28
|
+
- {{ .script }}
|
|
29
|
+
env:
|
|
30
|
+
- name: CONFIG_FILE
|
|
31
|
+
value: "/app/config.json"
|
|
32
|
+
{{- with $.Values.env }}
|
|
33
|
+
{{- tpl (toYaml .) $ | nindent 12 }}
|
|
34
|
+
{{- end }}
|
|
35
|
+
volumeMounts:
|
|
36
|
+
- name: config-file
|
|
37
|
+
mountPath: "/app/config.json"
|
|
38
|
+
readOnly: true
|
|
39
|
+
{{- if ($.Values.keycloak.config.volumes).reports }}
|
|
40
|
+
- name: reports-dir
|
|
41
|
+
mountPath: "/app/reports"
|
|
42
|
+
{{- end }}
|
|
43
|
+
restartPolicy: OnFailure
|
|
44
|
+
{{- if $.Values.resources }}
|
|
45
|
+
resources:
|
|
46
|
+
{{ toYaml $.Values.resources }}
|
|
47
|
+
{{- end }}
|
|
48
|
+
{{- if $.Values.nodeSelector }}
|
|
49
|
+
nodeSelector:
|
|
50
|
+
{{ toYaml $.Values.nodeSelector | indent 12 }}
|
|
51
|
+
{{- end }}
|
|
52
|
+
{{- if $.Values.tolerations }}
|
|
53
|
+
tolerations:
|
|
54
|
+
{{ toYaml $.Values.tolerations | indent 12 }}
|
|
55
|
+
{{- end }}
|
|
56
|
+
volumes:
|
|
57
|
+
- name: config-file
|
|
58
|
+
secret:
|
|
59
|
+
secretName: {{ $fullName }}
|
|
60
|
+
{{- if ($.Values.keycloak.config.volumes).reports }}
|
|
61
|
+
- name: reports-dir
|
|
62
|
+
persistentVolumeClaim:
|
|
63
|
+
claimName: {{ $fullName }}-reports
|
|
64
|
+
{{- end }}
|
|
65
|
+
---
|
|
66
|
+
{{- end -}}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{{- $fullName := include "keycloak-reporter.fullname" . -}}
|
|
2
|
+
{{- if (.Values.keycloak.config.volumes).reports }}
|
|
3
|
+
apiVersion: v1
|
|
4
|
+
kind: PersistentVolumeClaim
|
|
5
|
+
metadata:
|
|
6
|
+
name: {{ $fullName }}-reports
|
|
7
|
+
annotations: {{ .Values.keycloak.config.volumes.reports.annotations }}
|
|
8
|
+
spec:
|
|
9
|
+
accessModes:
|
|
10
|
+
- ReadWriteMany
|
|
11
|
+
storageClassName: {{ .Values.keycloak.config.volumes.reports.storageClassName }}
|
|
12
|
+
resources:
|
|
13
|
+
requests:
|
|
14
|
+
storage: {{ .Values.keycloak.config.volumes.reports.volumeSize }}
|
|
15
|
+
{{- end }}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{{- $fullName := include "keycloak-reporter.fullname" . -}}
|
|
2
|
+
apiVersion: v1
|
|
3
|
+
kind: Secret
|
|
4
|
+
metadata:
|
|
5
|
+
name: {{ $fullName }}
|
|
6
|
+
stringData:
|
|
7
|
+
{{- range $k, $v := .Values.keycloak.config }}
|
|
8
|
+
{{- if $v}}
|
|
9
|
+
{{ $k }}: {{ $v }}
|
|
10
|
+
{{- end }}
|
|
11
|
+
{{- end }}
|
|
12
|
+
{{- if (.Values.keycloak.config.volumes).reports }}
|
|
13
|
+
reports: /app/reports
|
|
14
|
+
{{- end }}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{{- if .Values.serviceAccount.create -}}
|
|
2
|
+
apiVersion: v1
|
|
3
|
+
kind: ServiceAccount
|
|
4
|
+
metadata:
|
|
5
|
+
name: {{ include "keycloak-reporter.serviceAccountName" . }}
|
|
6
|
+
labels:
|
|
7
|
+
{{- include "keycloak-reporter.labels" . | nindent 4 }}
|
|
8
|
+
{{- with .Values.serviceAccount.annotations }}
|
|
9
|
+
annotations:
|
|
10
|
+
{{- toYaml . | nindent 4 }}
|
|
11
|
+
{{- end }}
|
|
12
|
+
{{- end }}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Default values for keycloak-reporter.
|
|
2
|
+
# This is a YAML-formatted file.
|
|
3
|
+
# Declare variables to be passed into your templates.
|
|
4
|
+
|
|
5
|
+
replicaCount: 1
|
|
6
|
+
|
|
7
|
+
image:
|
|
8
|
+
repository: continuoussecuritytooling/keycloak-reporting-cli
|
|
9
|
+
pullPolicy: IfNotPresent
|
|
10
|
+
# Overrides the image tag whose default is the chart appVersion.
|
|
11
|
+
tag: "latest"
|
|
12
|
+
|
|
13
|
+
imagePullSecrets: []
|
|
14
|
+
nameOverride: ""
|
|
15
|
+
fullnameOverride: ""
|
|
16
|
+
|
|
17
|
+
serviceAccount:
|
|
18
|
+
# Specifies whether a service account should be created
|
|
19
|
+
create: true
|
|
20
|
+
# Annotations to add to the service account
|
|
21
|
+
annotations: {}
|
|
22
|
+
# The name of the service account to use.
|
|
23
|
+
# If not set and create is true, a name is generated using the fullname template
|
|
24
|
+
name: ""
|
|
25
|
+
|
|
26
|
+
podAnnotations: {}
|
|
27
|
+
|
|
28
|
+
podSecurityContext: {}
|
|
29
|
+
# fsGroup: 2000
|
|
30
|
+
|
|
31
|
+
securityContext: {}
|
|
32
|
+
|
|
33
|
+
env: {}
|
|
34
|
+
# capabilities:
|
|
35
|
+
# drop:
|
|
36
|
+
# - ALL
|
|
37
|
+
# readOnlyRootFilesystem: true
|
|
38
|
+
# runAsNonRoot: true
|
|
39
|
+
# runAsUser: 1000
|
|
40
|
+
|
|
41
|
+
keycloak:
|
|
42
|
+
config:
|
|
43
|
+
url: ""
|
|
44
|
+
clientId: ""
|
|
45
|
+
clientSecret: ""
|
|
46
|
+
output: "webhook"
|
|
47
|
+
webhookType: ""
|
|
48
|
+
webhookUrl: ""
|
|
49
|
+
# -- optional message for the webhook post
|
|
50
|
+
webhookMessage: ""
|
|
51
|
+
volumes:
|
|
52
|
+
reports: ""
|
|
53
|
+
|
|
54
|
+
cronjobs:
|
|
55
|
+
- name: clients
|
|
56
|
+
script: /app/index.js listClients
|
|
57
|
+
schedule: 0 0 1 */3 *
|
|
58
|
+
- name: users
|
|
59
|
+
script: /app/index.js listUsers
|
|
60
|
+
schedule: 0 0 1 */3 *
|
|
61
|
+
|
|
62
|
+
resources: {}
|
|
63
|
+
# We usually recommend not to specify default resources and to leave this as a conscious
|
|
64
|
+
# choice for the user. This also increases chances charts run on environments with little
|
|
65
|
+
# resources, such as Minikube. If you do want to specify resources, uncomment the following
|
|
66
|
+
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
|
|
67
|
+
# limits:
|
|
68
|
+
# cpu: 100m
|
|
69
|
+
# memory: 128Mi
|
|
70
|
+
# requests:
|
|
71
|
+
# cpu: 100m
|
|
72
|
+
# memory: 128Mi
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
nodeSelector: {}
|
|
76
|
+
|
|
77
|
+
tolerations: []
|
|
78
|
+
|
|
79
|
+
affinity: {}
|
package/cli.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
+
import { writeFileSync } from 'node:fs';
|
|
4
|
+
import path from 'path';
|
|
3
5
|
import yargs from 'yargs/yargs';
|
|
4
6
|
import { hideBin } from 'yargs/helpers';
|
|
5
7
|
import {
|
|
@@ -7,25 +9,32 @@ import {
|
|
|
7
9
|
listClients,
|
|
8
10
|
Options,
|
|
9
11
|
convertJSON2CSV,
|
|
10
|
-
post2Webhook
|
|
12
|
+
post2Webhook
|
|
11
13
|
} from './index.js';
|
|
12
14
|
import config from './src/config.js';
|
|
13
15
|
|
|
14
|
-
|
|
15
16
|
class WebhookConfig {
|
|
16
17
|
type: string;
|
|
17
18
|
url: string;
|
|
18
19
|
title: string;
|
|
19
|
-
|
|
20
|
+
message?: string;
|
|
21
|
+
constructor(type: string, url: string, title: string, message?: string) {
|
|
20
22
|
this.type = type;
|
|
21
23
|
this.url = url;
|
|
22
24
|
this.title = title;
|
|
25
|
+
this.message = message;
|
|
23
26
|
}
|
|
24
27
|
}
|
|
25
28
|
|
|
29
|
+
class ReportConfig {
|
|
30
|
+
name: string;
|
|
31
|
+
directory: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
26
34
|
async function convert(
|
|
27
35
|
format: string,
|
|
28
36
|
output: string,
|
|
37
|
+
reports: ReportConfig,
|
|
29
38
|
config: WebhookConfig,
|
|
30
39
|
json: object
|
|
31
40
|
) {
|
|
@@ -38,6 +47,18 @@ async function convert(
|
|
|
38
47
|
default:
|
|
39
48
|
outputContent = JSON.stringify(json);
|
|
40
49
|
}
|
|
50
|
+
if (reports.directory) {
|
|
51
|
+
const date = new Date();
|
|
52
|
+
writeFileSync(
|
|
53
|
+
path.join(
|
|
54
|
+
`${reports.directory}`,
|
|
55
|
+
`${reports.name}_${date.getFullYear()}-${
|
|
56
|
+
date.getMonth() + 1
|
|
57
|
+
}-${date.getDate()}.${format.toLowerCase()}`
|
|
58
|
+
),
|
|
59
|
+
outputContent
|
|
60
|
+
);
|
|
61
|
+
}
|
|
41
62
|
switch (output) {
|
|
42
63
|
case 'webhook':
|
|
43
64
|
try {
|
|
@@ -45,10 +66,24 @@ async function convert(
|
|
|
45
66
|
config.type,
|
|
46
67
|
config.url,
|
|
47
68
|
config.title,
|
|
48
|
-
outputContent
|
|
69
|
+
outputContent,
|
|
70
|
+
config.message
|
|
49
71
|
);
|
|
50
72
|
} catch (e) {
|
|
51
|
-
|
|
73
|
+
switch (e.code || e.message) {
|
|
74
|
+
case 'Request failed with status code 400':
|
|
75
|
+
console.error('Invalid Teams Webhook Payload. Check your params.');
|
|
76
|
+
throw new Error('Invalid Teams Payload');
|
|
77
|
+
case 'slack_webhook_http_error':
|
|
78
|
+
console.error('Invalid Slack Webhook Payload. Check your params.');
|
|
79
|
+
throw new Error('Invalid Slack Payload');
|
|
80
|
+
default:
|
|
81
|
+
console.error(
|
|
82
|
+
`Error during sending webhook.(${e?.code})`,
|
|
83
|
+
e?.original
|
|
84
|
+
);
|
|
85
|
+
throw e;
|
|
86
|
+
}
|
|
52
87
|
}
|
|
53
88
|
break;
|
|
54
89
|
// defaulting to standard out
|
|
@@ -65,17 +100,26 @@ yargs(hideBin(process.argv))
|
|
|
65
100
|
() => {},
|
|
66
101
|
async (argv) => {
|
|
67
102
|
const users = await listUsers(<Options>{
|
|
68
|
-
clientId: argv.clientId ? argv.clientId as string: config.clientId,
|
|
69
|
-
clientSecret: argv.clientSecret
|
|
70
|
-
|
|
103
|
+
clientId: argv.clientId ? (argv.clientId as string) : config.clientId,
|
|
104
|
+
clientSecret: argv.clientSecret
|
|
105
|
+
? (argv.clientSecret as string)
|
|
106
|
+
: config.clientSecret,
|
|
107
|
+
rootUrl: argv.url ? (argv.url as string) : config.url
|
|
71
108
|
});
|
|
72
109
|
await convert(
|
|
73
110
|
argv.format as string,
|
|
74
111
|
argv.output as string,
|
|
112
|
+
{
|
|
113
|
+
name: 'user_listing',
|
|
114
|
+
directory: argv.reports as string
|
|
115
|
+
},
|
|
75
116
|
new WebhookConfig(
|
|
76
117
|
argv.webhookType as string,
|
|
77
118
|
argv.webhookUrl as string,
|
|
78
|
-
'User Listing'
|
|
119
|
+
'User Listing',
|
|
120
|
+
argv.webhookMessage
|
|
121
|
+
? (argv.webhookMessage as string)
|
|
122
|
+
: config.webhookMessage
|
|
79
123
|
),
|
|
80
124
|
users
|
|
81
125
|
);
|
|
@@ -88,17 +132,26 @@ yargs(hideBin(process.argv))
|
|
|
88
132
|
() => {},
|
|
89
133
|
async (argv) => {
|
|
90
134
|
const clients = await listClients(<Options>{
|
|
91
|
-
clientId: argv.clientId ? argv.clientId as string: config.clientId,
|
|
92
|
-
clientSecret: argv.clientSecret
|
|
93
|
-
|
|
135
|
+
clientId: argv.clientId ? (argv.clientId as string) : config.clientId,
|
|
136
|
+
clientSecret: argv.clientSecret
|
|
137
|
+
? (argv.clientSecret as string)
|
|
138
|
+
: config.clientSecret,
|
|
139
|
+
rootUrl: argv.url ? (argv.url as string) : config.url
|
|
94
140
|
});
|
|
95
141
|
await convert(
|
|
96
142
|
argv.format as string,
|
|
97
143
|
argv.output as string,
|
|
144
|
+
{
|
|
145
|
+
name: 'client_listing',
|
|
146
|
+
directory: argv.reports as string
|
|
147
|
+
},
|
|
98
148
|
new WebhookConfig(
|
|
99
149
|
argv.webhookType as string,
|
|
100
150
|
argv.webhookUrl as string,
|
|
101
|
-
'Client Listing'
|
|
151
|
+
'Client Listing',
|
|
152
|
+
argv.webhookMessage
|
|
153
|
+
? (argv.webhookMessage as string)
|
|
154
|
+
: config.webhookMessage
|
|
102
155
|
),
|
|
103
156
|
clients
|
|
104
157
|
);
|
|
@@ -108,23 +161,33 @@ yargs(hideBin(process.argv))
|
|
|
108
161
|
alias: 'f',
|
|
109
162
|
type: 'string',
|
|
110
163
|
default: 'json',
|
|
111
|
-
description: 'output format, e.g. JSON|CSV'
|
|
164
|
+
description: 'output format, e.g. JSON|CSV'
|
|
112
165
|
})
|
|
113
166
|
.option('output', {
|
|
114
167
|
alias: 'o',
|
|
115
168
|
type: 'string',
|
|
116
169
|
default: 'stdout',
|
|
117
|
-
description: 'output channel'
|
|
170
|
+
description: 'output channel'
|
|
118
171
|
})
|
|
119
172
|
.option('webhookType', {
|
|
120
173
|
alias: 'w',
|
|
121
174
|
type: 'string',
|
|
122
175
|
default: 'slack',
|
|
123
|
-
description: 'Webhook Type'
|
|
176
|
+
description: 'Webhook Type'
|
|
177
|
+
})
|
|
178
|
+
.option('webhookMessage', {
|
|
179
|
+
alias: 'm',
|
|
180
|
+
type: 'string',
|
|
181
|
+
description: 'Webhook Message'
|
|
124
182
|
})
|
|
125
183
|
.option('webhookUrl', {
|
|
126
184
|
alias: 't',
|
|
127
185
|
type: 'string',
|
|
128
|
-
description: 'Webhook URL'
|
|
186
|
+
description: 'Webhook URL'
|
|
187
|
+
})
|
|
188
|
+
.option('reports', {
|
|
189
|
+
alias: 'r',
|
|
190
|
+
type: 'string',
|
|
191
|
+
description: 'Reports directory'
|
|
129
192
|
})
|
|
130
193
|
.parse();
|
package/config/schema.json
CHANGED
|
@@ -49,9 +49,17 @@
|
|
|
49
49
|
},
|
|
50
50
|
"description": "Type of webhook"
|
|
51
51
|
},
|
|
52
|
+
"webhookMessage": {
|
|
53
|
+
"type": "string",
|
|
54
|
+
"description": "Message added to the webhook post"
|
|
55
|
+
},
|
|
52
56
|
"webhookUrl": {
|
|
53
57
|
"type": "string",
|
|
54
58
|
"description": "URL of the webhook"
|
|
59
|
+
},
|
|
60
|
+
"reports": {
|
|
61
|
+
"type": "string",
|
|
62
|
+
"description": "Reports directory"
|
|
55
63
|
}
|
|
56
64
|
}
|
|
57
65
|
}
|
package/dist/cli.js
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { writeFileSync } from 'node:fs';
|
|
3
|
+
import path from 'path';
|
|
2
4
|
import yargs from 'yargs/yargs';
|
|
3
5
|
import { hideBin } from 'yargs/helpers';
|
|
4
|
-
import { listUsers, listClients, convertJSON2CSV, post2Webhook
|
|
6
|
+
import { listUsers, listClients, convertJSON2CSV, post2Webhook } from './index.js';
|
|
5
7
|
import config from './src/config.js';
|
|
6
8
|
class WebhookConfig {
|
|
7
|
-
constructor(type, url, title) {
|
|
9
|
+
constructor(type, url, title, message) {
|
|
8
10
|
this.type = type;
|
|
9
11
|
this.url = url;
|
|
10
12
|
this.title = title;
|
|
13
|
+
this.message = message;
|
|
11
14
|
}
|
|
12
15
|
}
|
|
13
|
-
|
|
16
|
+
class ReportConfig {
|
|
17
|
+
}
|
|
18
|
+
async function convert(format, output, reports, config, json) {
|
|
14
19
|
let outputContent;
|
|
15
20
|
switch (format) {
|
|
16
21
|
case 'csv':
|
|
@@ -20,13 +25,27 @@ async function convert(format, output, config, json) {
|
|
|
20
25
|
default:
|
|
21
26
|
outputContent = JSON.stringify(json);
|
|
22
27
|
}
|
|
28
|
+
if (reports.directory) {
|
|
29
|
+
const date = new Date();
|
|
30
|
+
writeFileSync(path.join(`${reports.directory}`, `${reports.name}_${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}.${format.toLowerCase()}`), outputContent);
|
|
31
|
+
}
|
|
23
32
|
switch (output) {
|
|
24
33
|
case 'webhook':
|
|
25
34
|
try {
|
|
26
|
-
await post2Webhook(config.type, config.url, config.title, outputContent);
|
|
35
|
+
await post2Webhook(config.type, config.url, config.title, outputContent, config.message);
|
|
27
36
|
}
|
|
28
37
|
catch (e) {
|
|
29
|
-
|
|
38
|
+
switch (e.code || e.message) {
|
|
39
|
+
case 'Request failed with status code 400':
|
|
40
|
+
console.error('Invalid Teams Webhook Payload. Check your params.');
|
|
41
|
+
throw new Error('Invalid Teams Payload');
|
|
42
|
+
case 'slack_webhook_http_error':
|
|
43
|
+
console.error('Invalid Slack Webhook Payload. Check your params.');
|
|
44
|
+
throw new Error('Invalid Slack Payload');
|
|
45
|
+
default:
|
|
46
|
+
console.error(`Error during sending webhook.(${e === null || e === void 0 ? void 0 : e.code})`, e === null || e === void 0 ? void 0 : e.original);
|
|
47
|
+
throw e;
|
|
48
|
+
}
|
|
30
49
|
}
|
|
31
50
|
break;
|
|
32
51
|
// defaulting to standard out
|
|
@@ -40,43 +59,67 @@ yargs(hideBin(process.argv))
|
|
|
40
59
|
() => { }, async (argv) => {
|
|
41
60
|
const users = await listUsers({
|
|
42
61
|
clientId: argv.clientId ? argv.clientId : config.clientId,
|
|
43
|
-
clientSecret: argv.clientSecret
|
|
44
|
-
|
|
62
|
+
clientSecret: argv.clientSecret
|
|
63
|
+
? argv.clientSecret
|
|
64
|
+
: config.clientSecret,
|
|
65
|
+
rootUrl: argv.url ? argv.url : config.url
|
|
45
66
|
});
|
|
46
|
-
await convert(argv.format, argv.output,
|
|
67
|
+
await convert(argv.format, argv.output, {
|
|
68
|
+
name: 'user_listing',
|
|
69
|
+
directory: argv.reports
|
|
70
|
+
}, new WebhookConfig(argv.webhookType, argv.webhookUrl, 'User Listing', argv.webhookMessage
|
|
71
|
+
? argv.webhookMessage
|
|
72
|
+
: config.webhookMessage), users);
|
|
47
73
|
})
|
|
48
74
|
.command('listClients [url] [clientId] [clientSecret]', 'fetches all clients in the realms.',
|
|
49
75
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
50
76
|
() => { }, async (argv) => {
|
|
51
77
|
const clients = await listClients({
|
|
52
78
|
clientId: argv.clientId ? argv.clientId : config.clientId,
|
|
53
|
-
clientSecret: argv.clientSecret
|
|
54
|
-
|
|
79
|
+
clientSecret: argv.clientSecret
|
|
80
|
+
? argv.clientSecret
|
|
81
|
+
: config.clientSecret,
|
|
82
|
+
rootUrl: argv.url ? argv.url : config.url
|
|
55
83
|
});
|
|
56
|
-
await convert(argv.format, argv.output,
|
|
84
|
+
await convert(argv.format, argv.output, {
|
|
85
|
+
name: 'client_listing',
|
|
86
|
+
directory: argv.reports
|
|
87
|
+
}, new WebhookConfig(argv.webhookType, argv.webhookUrl, 'Client Listing', argv.webhookMessage
|
|
88
|
+
? argv.webhookMessage
|
|
89
|
+
: config.webhookMessage), clients);
|
|
57
90
|
})
|
|
58
91
|
.option('format', {
|
|
59
92
|
alias: 'f',
|
|
60
93
|
type: 'string',
|
|
61
94
|
default: 'json',
|
|
62
|
-
description: 'output format, e.g. JSON|CSV'
|
|
95
|
+
description: 'output format, e.g. JSON|CSV'
|
|
63
96
|
})
|
|
64
97
|
.option('output', {
|
|
65
98
|
alias: 'o',
|
|
66
99
|
type: 'string',
|
|
67
100
|
default: 'stdout',
|
|
68
|
-
description: 'output channel'
|
|
101
|
+
description: 'output channel'
|
|
69
102
|
})
|
|
70
103
|
.option('webhookType', {
|
|
71
104
|
alias: 'w',
|
|
72
105
|
type: 'string',
|
|
73
106
|
default: 'slack',
|
|
74
|
-
description: 'Webhook Type'
|
|
107
|
+
description: 'Webhook Type'
|
|
108
|
+
})
|
|
109
|
+
.option('webhookMessage', {
|
|
110
|
+
alias: 'm',
|
|
111
|
+
type: 'string',
|
|
112
|
+
description: 'Webhook Message'
|
|
75
113
|
})
|
|
76
114
|
.option('webhookUrl', {
|
|
77
115
|
alias: 't',
|
|
78
116
|
type: 'string',
|
|
79
|
-
description: 'Webhook URL'
|
|
117
|
+
description: 'Webhook URL'
|
|
118
|
+
})
|
|
119
|
+
.option('reports', {
|
|
120
|
+
alias: 'r',
|
|
121
|
+
type: 'string',
|
|
122
|
+
description: 'Reports directory'
|
|
80
123
|
})
|
|
81
124
|
.parse();
|
|
82
125
|
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../cli.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,MAAM,aAAa,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,O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53
|
+
"type": "string",
|
|
54
|
+
"description": "Message added to the webhook post"
|
|
55
|
+
},
|
|
52
56
|
"webhookUrl": {
|
|
53
57
|
"type": "string",
|
|
54
58
|
"description": "URL of the webhook"
|
|
59
|
+
},
|
|
60
|
+
"reports": {
|
|
61
|
+
"type": "string",
|
|
62
|
+
"description": "Reports directory"
|
|
55
63
|
}
|
|
56
64
|
}
|
|
57
65
|
}
|
package/dist/index.js
CHANGED
|
File without changes
|
package/dist/index.js.map
CHANGED
|
File without changes
|
package/dist/lib/client.js
CHANGED
|
File without changes
|
package/dist/lib/client.js.map
CHANGED
|
File without changes
|
package/dist/lib/convert.js
CHANGED
|
File without changes
|
package/dist/lib/convert.js.map
CHANGED
|
File without changes
|