@continuoussecuritytooling/keycloak-reporter 0.4.0 → 0.5.1
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 +1 -1
- package/.eslintrc.cjs +3 -3
- package/.github/CONTRIBUTING.md +5 -5
- package/.github/workflows/pipeline.yml +31 -23
- package/.github/workflows/release.yml +23 -3
- package/.prettierrc +6 -0
- package/Dockerfile +4 -2
- package/README.md +6 -7
- package/charts/keycloak-reporter/Chart.yaml +3 -2
- package/charts/keycloak-reporter/README.md +2 -2
- package/charts/keycloak-reporter/templates/_helpers.tpl +21 -0
- package/charts/keycloak-reporter/templates/cronjob.yaml +5 -3
- package/charts/keycloak-reporter/values.yaml +4 -7
- package/cli.ts +61 -30
- package/config.json +9 -0
- package/dist/cli.js +41 -19
- package/dist/cli.js.map +1 -1
- package/dist/lib/output.js +53 -50
- package/dist/lib/output.js.map +1 -1
- package/e2e/spec/webhooks.js +84 -10
- package/k8s.yaml +51 -0
- package/keycloak-reporter-0.5.0.tgz +0 -0
- package/lib/output.ts +63 -57
- package/package.json +5 -3
- package/renovate.json +15 -7
- package/test.values.yaml +8 -0
package/.bin/wait-for-server.sh
CHANGED
|
@@ -7,6 +7,7 @@ until $(curl --output /dev/null --silent --head --fail http://localhost:8080/rea
|
|
|
7
7
|
sleep 5
|
|
8
8
|
if [[ "$counter" -gt 24 ]]; then
|
|
9
9
|
printf "Keycloak server failed to start. Timeout!"
|
|
10
|
+
curl --head --fail http://localhost:8080/realms/master/.well-known/openid-configuration
|
|
10
11
|
exit 1
|
|
11
12
|
fi
|
|
12
13
|
counter=$((counter + 1))
|
package/.ct.yaml
CHANGED
package/.eslintrc.cjs
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
module.exports = {
|
|
3
3
|
env: {
|
|
4
4
|
node: true,
|
|
5
|
-
commonjs: true
|
|
5
|
+
commonjs: true
|
|
6
6
|
},
|
|
7
7
|
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
|
|
8
8
|
parser: '@typescript-eslint/parser',
|
|
9
9
|
plugins: ['@typescript-eslint'],
|
|
10
10
|
root: true,
|
|
11
11
|
rules: {
|
|
12
|
-
quotes: [2, 'single', { avoidEscape: true }]
|
|
13
|
-
}
|
|
12
|
+
quotes: [2, 'single', { avoidEscape: true }]
|
|
13
|
+
}
|
|
14
14
|
};
|
package/.github/CONTRIBUTING.md
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
We'd love for you to contribute to our source code and to make this package even better than it is
|
|
4
4
|
today! Here are the guidelines we'd like you to follow:
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
- [ Found an Issue?](#-found-an-issue)
|
|
7
|
+
- [ Want a Feature?](#-want-a-feature)
|
|
8
|
+
- [ Coding Rules](#-coding-rules)
|
|
9
|
+
- [ Git Commit Guidelines](#-git-commit-guidelines)
|
|
10
10
|
|
|
11
11
|
## <a name="issue"></a> Found an Issue?
|
|
12
12
|
|
|
@@ -17,7 +17,7 @@ with a fix. But first search if the issue is already described!
|
|
|
17
17
|
If not create a new issue:
|
|
18
18
|
|
|
19
19
|
* Tell about your environment:
|
|
20
|
-
*
|
|
20
|
+
* NodeJS version
|
|
21
21
|
* used platform and version
|
|
22
22
|
* Describe your issue
|
|
23
23
|
* describe your steps leading to the issue
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
name: Build
|
|
2
2
|
|
|
3
3
|
on:
|
|
4
|
+
pull_request:
|
|
4
5
|
merge_group:
|
|
5
6
|
push:
|
|
7
|
+
branches:
|
|
8
|
+
- develop
|
|
6
9
|
|
|
7
10
|
jobs:
|
|
8
11
|
build:
|
|
9
|
-
name:
|
|
10
|
-
runs-on:
|
|
12
|
+
name: 'Build and Test on Node ${{ matrix.node_version }} and ${{ matrix.os }}'
|
|
13
|
+
runs-on: '${{ matrix.os }}'
|
|
11
14
|
strategy:
|
|
12
15
|
matrix:
|
|
13
16
|
node_version:
|
|
14
|
-
- 16
|
|
15
17
|
- 18
|
|
16
18
|
- 20
|
|
17
19
|
os:
|
|
@@ -20,10 +22,10 @@ jobs:
|
|
|
20
22
|
- windows-latest
|
|
21
23
|
steps:
|
|
22
24
|
- uses: actions/checkout@v4
|
|
23
|
-
- name:
|
|
25
|
+
- name: 'Use Node.js ${{ matrix.node_version }}'
|
|
24
26
|
uses: actions/setup-node@v3
|
|
25
27
|
with:
|
|
26
|
-
node-version:
|
|
28
|
+
node-version: '${{ matrix.node_version }}'
|
|
27
29
|
- name: npm build and test
|
|
28
30
|
run: |
|
|
29
31
|
npm run clean
|
|
@@ -31,7 +33,7 @@ jobs:
|
|
|
31
33
|
npm run test
|
|
32
34
|
|
|
33
35
|
chart:
|
|
34
|
-
name:
|
|
36
|
+
name: 'Build and Test Helm Chart'
|
|
35
37
|
runs-on: ubuntu-latest
|
|
36
38
|
|
|
37
39
|
steps:
|
|
@@ -63,7 +65,7 @@ jobs:
|
|
|
63
65
|
|
|
64
66
|
- name: Run chart-testing (lint)
|
|
65
67
|
if: steps.list-changed.outputs.changed == 'true'
|
|
66
|
-
run: ct lint --target-branch ${{ github.event.repository.default_branch }}
|
|
68
|
+
run: ct lint --target-branch ${{ github.event.repository.default_branch }}
|
|
67
69
|
|
|
68
70
|
- name: Create kind cluster
|
|
69
71
|
if: steps.list-changed.outputs.changed == 'true'
|
|
@@ -79,30 +81,31 @@ jobs:
|
|
|
79
81
|
path: dist
|
|
80
82
|
|
|
81
83
|
end2end:
|
|
82
|
-
name:
|
|
83
|
-
runs-on:
|
|
84
|
-
needs:
|
|
85
|
-
- build
|
|
86
|
-
- chart
|
|
84
|
+
name: 'End2End Test on Node ${{ matrix.node_version }} and ${{ matrix.os }}'
|
|
85
|
+
runs-on: '${{ matrix.os }}'
|
|
87
86
|
strategy:
|
|
88
87
|
matrix:
|
|
89
88
|
node_version:
|
|
90
|
-
-
|
|
91
|
-
# TODO: Support Node 16+
|
|
92
|
-
#- 18
|
|
93
|
-
#- 20
|
|
89
|
+
- 18
|
|
94
90
|
os:
|
|
95
91
|
- ubuntu-latest
|
|
96
92
|
steps:
|
|
97
93
|
- uses: actions/checkout@v4
|
|
98
|
-
- name:
|
|
94
|
+
- name: 'Use Node.js ${{ matrix.node_version }}'
|
|
99
95
|
uses: actions/setup-node@v3
|
|
100
96
|
with:
|
|
101
|
-
node-version:
|
|
97
|
+
node-version: '${{ matrix.node_version }}'
|
|
98
|
+
- name: Install Java
|
|
99
|
+
uses: actions/setup-java@v3
|
|
100
|
+
with:
|
|
101
|
+
distribution: 'temurin' # See 'Supported distributions' for available options
|
|
102
|
+
java-version: '17'
|
|
102
103
|
- name: npm build and test
|
|
103
104
|
run: |
|
|
104
105
|
npm run clean
|
|
105
106
|
npm run build
|
|
107
|
+
- name: Tune GitHub-hosted runner network
|
|
108
|
+
uses: smorimoto/tune-github-hosted-runner-network@v1
|
|
106
109
|
|
|
107
110
|
- name: Start Keycloak server
|
|
108
111
|
run: npm run end2end:start-server &
|
|
@@ -111,23 +114,28 @@ jobs:
|
|
|
111
114
|
run: .bin/wait-for-server.sh
|
|
112
115
|
|
|
113
116
|
- name: Run end2end tests
|
|
114
|
-
run:
|
|
117
|
+
run: |
|
|
118
|
+
env
|
|
119
|
+
npm run end2end:test
|
|
115
120
|
env:
|
|
116
121
|
WEBHOOK_TESTING_TEAMS: ${{ secrets.WEBHOOK_TESTING_TEAMS }}
|
|
117
122
|
WEBHOOK_TESTING_SLACK: ${{ secrets.WEBHOOK_TESTING_SLACK }}
|
|
123
|
+
WEBHOOK_ADDITIONAL_MESSAGE: ${{ github.head_ref || github.ref_name }}
|
|
118
124
|
|
|
119
125
|
package:
|
|
120
126
|
name: Build Container Image
|
|
121
127
|
runs-on: ubuntu-latest
|
|
122
128
|
needs:
|
|
129
|
+
- build
|
|
130
|
+
- chart
|
|
123
131
|
- end2end
|
|
124
132
|
steps:
|
|
125
133
|
- uses: actions/checkout@v4
|
|
126
134
|
- uses: actions/setup-node@v3
|
|
127
|
-
|
|
135
|
+
# TODO: Support Node 16+
|
|
128
136
|
with:
|
|
129
|
-
node-version:
|
|
130
|
-
- name:
|
|
137
|
+
node-version: '16'
|
|
138
|
+
- name: 'Build Package'
|
|
131
139
|
run: |
|
|
132
140
|
npm run clean
|
|
133
141
|
npm run build
|
|
@@ -136,7 +144,7 @@ jobs:
|
|
|
136
144
|
uses: redhat-actions/buildah-build@v2
|
|
137
145
|
with:
|
|
138
146
|
image: continuoussecuritytooling/keycloak-reporting-cli
|
|
139
|
-
tags:
|
|
147
|
+
tags: 'v1 ${{ github.sha }}'
|
|
140
148
|
containerfiles: |
|
|
141
149
|
./Dockerfile
|
|
142
150
|
- name: Push To Docker Hub
|
|
@@ -25,13 +25,33 @@ jobs:
|
|
|
25
25
|
|
|
26
26
|
- name: Install Helm
|
|
27
27
|
uses: azure/setup-helm@v3
|
|
28
|
+
- name: Install Python
|
|
29
|
+
uses: actions/setup-python@v4
|
|
30
|
+
with:
|
|
31
|
+
python-version: '3.9'
|
|
32
|
+
check-latest: true
|
|
33
|
+
- name: Set up chart-testing
|
|
34
|
+
uses: helm/chart-testing-action@v2.4.0
|
|
28
35
|
|
|
29
36
|
- name: Run chart-testing (lint)
|
|
30
|
-
run: ct lint --
|
|
37
|
+
run: ct lint --config .ct.yaml
|
|
31
38
|
|
|
32
39
|
- name: Run chart-releaser
|
|
33
40
|
uses: helm/chart-releaser-action@v1.5.0
|
|
34
41
|
with:
|
|
35
|
-
|
|
42
|
+
charts_dir: charts/
|
|
36
43
|
env:
|
|
37
|
-
CR_TOKEN:
|
|
44
|
+
CR_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
|
|
45
|
+
|
|
46
|
+
- name: Login to GitHub Container Registry
|
|
47
|
+
run: |
|
|
48
|
+
echo ${{ secrets.CT_OCI_GITHUB_TOKEN }} | helm registry login ghcr.io -u $ --password-stdin
|
|
49
|
+
|
|
50
|
+
- name: Push Charts to GHCR
|
|
51
|
+
run: |
|
|
52
|
+
for pkg in .cr-release-packages/*; do
|
|
53
|
+
if [ -z "${pkg:-}" ]; then
|
|
54
|
+
break
|
|
55
|
+
fi
|
|
56
|
+
helm push "${pkg}" oci://ghcr.io/cloudtooling/helm-charts
|
|
57
|
+
done
|
package/.prettierrc
ADDED
package/Dockerfile
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
FROM node:
|
|
1
|
+
FROM node:18
|
|
2
|
+
|
|
3
|
+
LABEL org.opencontainers.image.source https://github.com/ContinuousSecurityTooling/keycloak-reporter
|
|
2
4
|
|
|
3
5
|
ENV CONFIG_FILE=/app/config.json
|
|
4
6
|
|
|
@@ -6,6 +8,6 @@ COPY dist/ docker_entrypoint.sh package.json /app
|
|
|
6
8
|
|
|
7
9
|
WORKDIR /app
|
|
8
10
|
|
|
9
|
-
RUN cd /app &&
|
|
11
|
+
RUN cd /app && npm i
|
|
10
12
|
|
|
11
13
|
ENTRYPOINT ["/app/docker_entrypoint.sh"]
|
package/README.md
CHANGED
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
|
|
4
4
|
[](LICENSE)
|
|
5
5
|
[](https://github.com/ContinuousSecurityTooling/keycloak-reporter/actions/workflows/pipeline.yml)
|
|
6
|
-
[](https://www.npmjs.com/package/@continuoussecuritytooling/keycloak-reporter)
|
|
6
|
+
[](https://www.npmjs.com/package/@continuoussecuritytooling/keycloak-reporter)
|
|
7
|
+
[](https://www.npmjs.com/package/@continuoussecuritytooling/keycloak-reporter)
|
|
9
8
|
[](https://hub.docker.com/r/continuoussecuritytooling/keycloak-reporting-cli/)
|
|
10
9
|
[](https://snyk.io/test/github/ContinuousSecurityTooling/keycloak-reporter)
|
|
11
10
|
|
|
@@ -57,13 +56,13 @@ Valid commands are:
|
|
|
57
56
|
|
|
58
57
|
## Advanced
|
|
59
58
|
|
|
60
|
-
|
|
61
59
|
### Helm
|
|
62
|
-
~
|
|
63
60
|
|
|
64
|
-
|
|
61
|
+
To install the Helm Chart use the OCI Package:
|
|
65
62
|
|
|
66
|
-
|
|
63
|
+
```
|
|
64
|
+
helm install keycloak-reporter oci://cloudtooling/helm-charts
|
|
65
|
+
```
|
|
67
66
|
|
|
68
67
|
### Config file
|
|
69
68
|
|
|
@@ -15,13 +15,14 @@ type: application
|
|
|
15
15
|
# This is the chart version. This version number should be incremented each time you make changes
|
|
16
16
|
# to the chart and its templates, including the app version.
|
|
17
17
|
# Versions are expected to follow Semantic Versioning (https://semver.org/)
|
|
18
|
-
version: 0.
|
|
18
|
+
version: 1.0.0
|
|
19
19
|
|
|
20
20
|
# This is the version number of the application being deployed. This version number should be
|
|
21
21
|
# incremented each time you make changes to the application. Versions are not expected to
|
|
22
22
|
# follow Semantic Versioning. They should reflect the version the application is using.
|
|
23
23
|
# It is recommended to use it with quotes.
|
|
24
|
-
|
|
24
|
+
# renovate: datasource=github-tags depName=ContinuousSecurityTooling/keycloak-reporter
|
|
25
|
+
appVersion: "0.5.0"
|
|
25
26
|
maintainers:
|
|
26
27
|
# Martin Reinhardt
|
|
27
28
|
- name: hypery2k
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# keycloak-reporter
|
|
2
2
|
|
|
3
|
-
  
|
|
4
4
|
|
|
5
5
|
A Helm chart for Kubernetes
|
|
6
6
|
|
|
@@ -31,7 +31,7 @@ A Helm chart for Kubernetes
|
|
|
31
31
|
| keycloak.config.clientSecret | string | `""` | |
|
|
32
32
|
| keycloak.config.output | string | `"webhook"` | |
|
|
33
33
|
| keycloak.config.url | string | `""` | |
|
|
34
|
-
| keycloak.config.webhookMessage | string | `""` |
|
|
34
|
+
| keycloak.config.webhookMessage | string | `""` | optional message for the webhook post |
|
|
35
35
|
| keycloak.config.webhookType | string | `""` | |
|
|
36
36
|
| keycloak.config.webhookUrl | string | `""` | |
|
|
37
37
|
| keycloak.volumes.reports | string | `""` | |
|
|
@@ -60,3 +60,24 @@ Create the name of the service account to use
|
|
|
60
60
|
{{- default "default" .Values.serviceAccount.name }}
|
|
61
61
|
{{- end }}
|
|
62
62
|
{{- end }}
|
|
63
|
+
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
{{/*
|
|
67
|
+
Create the name of the service account to use
|
|
68
|
+
*/}}
|
|
69
|
+
{{- define "keycloak-reporter.cronJobs" }}
|
|
70
|
+
{{- $cronJobs := list -}}
|
|
71
|
+
{{- if .Values.cronjobs.users }}
|
|
72
|
+
{{- $userCron := dict "name" "users" "script" "listUsers" "schedule" .Values.cronjobs.users }}
|
|
73
|
+
{{- $cronJobs = printf "%s" $userCron . | append $cronJobs -}}
|
|
74
|
+
{{- end }}
|
|
75
|
+
{{- if .Values.cronjobs.clients }}
|
|
76
|
+
{{- $clientCron := dict "name" "users" "script" "listClients" "schedule" .Values.cronjobs.clients }}
|
|
77
|
+
{{- $cronJobs = printf "%s" $clientCron . | append $cronJobs -}}
|
|
78
|
+
{{- end }}
|
|
79
|
+
{{ join "," $cronJobs }}
|
|
80
|
+
{{- end }}
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
{{- $fullName := include "keycloak-reporter.fullname" .
|
|
2
|
-
{{- range .
|
|
1
|
+
{{- $fullName := include "keycloak-reporter.fullname" . }}
|
|
2
|
+
{{- range include "keycloak-reporter.cronJobs" $ | split "," }}
|
|
3
3
|
apiVersion: batch/v1
|
|
4
4
|
kind: CronJob
|
|
5
5
|
metadata:
|
|
@@ -25,7 +25,8 @@ spec:
|
|
|
25
25
|
command:
|
|
26
26
|
- /bin/sh
|
|
27
27
|
- -c
|
|
28
|
-
-
|
|
28
|
+
- |
|
|
29
|
+
node /app/cli.js {{ .script }}
|
|
29
30
|
env:
|
|
30
31
|
- name: CONFIG_FILE
|
|
31
32
|
value: "/app/config.json"
|
|
@@ -35,6 +36,7 @@ spec:
|
|
|
35
36
|
volumeMounts:
|
|
36
37
|
- name: config-file
|
|
37
38
|
mountPath: "/app/config.json"
|
|
39
|
+
subPath: "config.json"
|
|
38
40
|
readOnly: true
|
|
39
41
|
{{- if ($.Values.keycloak.config.volumes).reports }}
|
|
40
42
|
- name: reports-dir
|
|
@@ -8,7 +8,7 @@ image:
|
|
|
8
8
|
repository: continuoussecuritytooling/keycloak-reporting-cli
|
|
9
9
|
pullPolicy: IfNotPresent
|
|
10
10
|
# Overrides the image tag whose default is the chart appVersion.
|
|
11
|
-
tag: "latest"
|
|
11
|
+
#tag: "latest"
|
|
12
12
|
|
|
13
13
|
imagePullSecrets: []
|
|
14
14
|
nameOverride: ""
|
|
@@ -46,17 +46,14 @@ keycloak:
|
|
|
46
46
|
output: "webhook"
|
|
47
47
|
webhookType: ""
|
|
48
48
|
webhookUrl: ""
|
|
49
|
+
# -- optional message for the webhook post
|
|
49
50
|
webhookMessage: ""
|
|
50
51
|
volumes:
|
|
51
52
|
reports: ""
|
|
52
53
|
|
|
53
54
|
cronjobs:
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
schedule: 0 0 1 */3 *
|
|
57
|
-
- name: users
|
|
58
|
-
script: /app/index.js listUsers
|
|
59
|
-
schedule: 0 0 1 */3 *
|
|
55
|
+
clients: "0 0 1 */3 *"
|
|
56
|
+
users: "0 0 1 */3 *"
|
|
60
57
|
|
|
61
58
|
resources: {}
|
|
62
59
|
# We usually recommend not to specify default resources and to leave this as a conscious
|
package/cli.ts
CHANGED
|
@@ -9,11 +9,10 @@ import {
|
|
|
9
9
|
listClients,
|
|
10
10
|
Options,
|
|
11
11
|
convertJSON2CSV,
|
|
12
|
-
post2Webhook
|
|
12
|
+
post2Webhook
|
|
13
13
|
} from './index.js';
|
|
14
14
|
import config from './src/config.js';
|
|
15
15
|
|
|
16
|
-
|
|
17
16
|
class WebhookConfig {
|
|
18
17
|
type: string;
|
|
19
18
|
url: string;
|
|
@@ -50,7 +49,15 @@ async function convert(
|
|
|
50
49
|
}
|
|
51
50
|
if (reports.directory) {
|
|
52
51
|
const date = new Date();
|
|
53
|
-
writeFileSync(
|
|
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
|
+
);
|
|
54
61
|
}
|
|
55
62
|
switch (output) {
|
|
56
63
|
case 'webhook':
|
|
@@ -60,11 +67,23 @@ async function convert(
|
|
|
60
67
|
config.url,
|
|
61
68
|
config.title,
|
|
62
69
|
outputContent,
|
|
63
|
-
config.message
|
|
70
|
+
config.message
|
|
64
71
|
);
|
|
65
72
|
} catch (e) {
|
|
66
|
-
|
|
67
|
-
|
|
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
|
+
}
|
|
68
87
|
}
|
|
69
88
|
break;
|
|
70
89
|
// defaulting to standard out
|
|
@@ -81,22 +100,28 @@ yargs(hideBin(process.argv))
|
|
|
81
100
|
() => {},
|
|
82
101
|
async (argv) => {
|
|
83
102
|
const users = await listUsers(<Options>{
|
|
84
|
-
clientId:
|
|
85
|
-
clientSecret:
|
|
86
|
-
|
|
103
|
+
clientId: config.clientId ? config.clientId : (argv.clientId as string),
|
|
104
|
+
clientSecret: config.clientSecret
|
|
105
|
+
? config.clientSecret
|
|
106
|
+
: (argv.clientSecret as string),
|
|
107
|
+
rootUrl: config.url ? config.url : (argv.url as string)
|
|
87
108
|
});
|
|
88
109
|
await convert(
|
|
89
|
-
argv.format as string,
|
|
90
|
-
argv.output as string,
|
|
110
|
+
config.format ? config.format : (argv.format as string),
|
|
111
|
+
config.output ? config.output : (argv.output as string),
|
|
91
112
|
{
|
|
92
113
|
name: 'user_listing',
|
|
93
|
-
directory: argv.reports as string
|
|
114
|
+
directory: argv.reports ? (argv.reports as string) : config.reports
|
|
94
115
|
},
|
|
95
116
|
new WebhookConfig(
|
|
96
|
-
|
|
97
|
-
|
|
117
|
+
config.webhookType
|
|
118
|
+
? config.webhookType
|
|
119
|
+
: (argv.webhookType as string),
|
|
120
|
+
config.webhookUrl ? config.webhookUrl : (argv.webhookUrl as string),
|
|
98
121
|
'User Listing',
|
|
99
|
-
|
|
122
|
+
config.webhookMessage
|
|
123
|
+
? config.webhookMessage
|
|
124
|
+
: (argv.webhookMessage as string)
|
|
100
125
|
),
|
|
101
126
|
users
|
|
102
127
|
);
|
|
@@ -109,22 +134,28 @@ yargs(hideBin(process.argv))
|
|
|
109
134
|
() => {},
|
|
110
135
|
async (argv) => {
|
|
111
136
|
const clients = await listClients(<Options>{
|
|
112
|
-
clientId:
|
|
113
|
-
clientSecret:
|
|
114
|
-
|
|
137
|
+
clientId: config.clientId ? config.clientId : (argv.clientId as string),
|
|
138
|
+
clientSecret: config.clientSecret
|
|
139
|
+
? config.clientSecret
|
|
140
|
+
: (argv.clientSecret as string),
|
|
141
|
+
rootUrl: config.url ? config.url : (argv.url as string)
|
|
115
142
|
});
|
|
116
143
|
await convert(
|
|
117
|
-
argv.format as string,
|
|
118
|
-
argv.output as string,
|
|
144
|
+
config.format ? config.format : (argv.format as string),
|
|
145
|
+
config.output ? config.output : (argv.output as string),
|
|
119
146
|
{
|
|
120
147
|
name: 'client_listing',
|
|
121
|
-
directory: argv.reports as string
|
|
148
|
+
directory: argv.reports ? (argv.reports as string) : config.reports
|
|
122
149
|
},
|
|
123
150
|
new WebhookConfig(
|
|
124
|
-
|
|
125
|
-
|
|
151
|
+
config.webhookType
|
|
152
|
+
? config.webhookType
|
|
153
|
+
: (argv.webhookType as string),
|
|
154
|
+
config.webhookUrl ? config.webhookUrl : (argv.webhookUrl as string),
|
|
126
155
|
'Client Listing',
|
|
127
|
-
|
|
156
|
+
config.webhookMessage
|
|
157
|
+
? config.webhookMessage
|
|
158
|
+
: (argv.webhookMessage as string)
|
|
128
159
|
),
|
|
129
160
|
clients
|
|
130
161
|
);
|
|
@@ -134,33 +165,33 @@ yargs(hideBin(process.argv))
|
|
|
134
165
|
alias: 'f',
|
|
135
166
|
type: 'string',
|
|
136
167
|
default: 'json',
|
|
137
|
-
description: 'output format, e.g. JSON|CSV'
|
|
168
|
+
description: 'output format, e.g. JSON|CSV'
|
|
138
169
|
})
|
|
139
170
|
.option('output', {
|
|
140
171
|
alias: 'o',
|
|
141
172
|
type: 'string',
|
|
142
173
|
default: 'stdout',
|
|
143
|
-
description: 'output channel'
|
|
174
|
+
description: 'output channel'
|
|
144
175
|
})
|
|
145
176
|
.option('webhookType', {
|
|
146
177
|
alias: 'w',
|
|
147
178
|
type: 'string',
|
|
148
179
|
default: 'slack',
|
|
149
|
-
description: 'Webhook Type'
|
|
180
|
+
description: 'Webhook Type'
|
|
150
181
|
})
|
|
151
182
|
.option('webhookMessage', {
|
|
152
183
|
alias: 'm',
|
|
153
184
|
type: 'string',
|
|
154
|
-
description: 'Webhook Message'
|
|
185
|
+
description: 'Webhook Message'
|
|
155
186
|
})
|
|
156
187
|
.option('webhookUrl', {
|
|
157
188
|
alias: 't',
|
|
158
189
|
type: 'string',
|
|
159
|
-
description: 'Webhook URL'
|
|
190
|
+
description: 'Webhook URL'
|
|
160
191
|
})
|
|
161
192
|
.option('reports', {
|
|
162
193
|
alias: 'r',
|
|
163
194
|
type: 'string',
|
|
164
|
-
description: 'Reports directory'
|
|
195
|
+
description: 'Reports directory'
|
|
165
196
|
})
|
|
166
197
|
.parse();
|
package/config.json
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"url": "https://id.m13t.de",
|
|
3
|
+
"clientId": "admin-cli",
|
|
4
|
+
"clientSecret": "PWkJ98Atq36QFP5Z25YXJDWs4tvsGvkI",
|
|
5
|
+
"output": "webhook",
|
|
6
|
+
"webhookType": "teams",
|
|
7
|
+
"webhookUrl": "https://m13t4mgmt.webhook.office.com/webhookb2/02950819-c8ca-4c83-9751-808d801e8810@09f6f098-3af9-474c-a398-d17786fff1bf/IncomingWebhook/b06222e267a04255aaa32a341acb1749/a4f92b5b-01c7-40a8-91ff-0695e08d76ff",
|
|
8
|
+
"webhookMessage": "TEST"
|
|
9
|
+
}
|