Skip to content

Commit 48bee5b

Browse files
committed
#1664 Fixed Generic WebHook API Key not working correctly
Renamed the values.yaml api key authentication to correspond to the name of the key of the secret instead of the value. changed template and hook.js accordingly Signed-off-by: Ilyes Ben Dlala <ilyes.bendlala@iteratec.com>
1 parent c51a0ef commit 48bee5b

3 files changed

Lines changed: 15 additions & 14 deletions

File tree

‎hooks/generic-webhook/hook/hook.js‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ async function handle({
88
webhookUrl = process.env["WEBHOOK_URL"],
99
webhookUser = process.env["WEBHOOK_USER"],
1010
webhookPassword = process.env["WEBHOOK_PASSWORD"],
11-
webhookApikey = process.env["WEBHOOK_APIKEY"],
12-
webhookApikeySecret = process.env["WEBHOOK_APIKEY_SECRET"],
11+
webhookApikeyHeaderName = process.env["WEBHOOK_APIKEY_HEADER_NAME"],
12+
webhookApikeyHeaderValue = process.env["WEBHOOK_APIKEY_HEADER_VALUE"],
1313
axios = require('axios')
1414
}) {
1515
const findings = await getFindings();
1616

1717
console.log(`Sending ${findings.length} findings to ${webhookUrl}`);
1818

19-
if (webhookApikey && webhookApikeySecret){
20-
await axios.post(webhookUrl, {scan, findings }, {headers: { [webhookApikey]: webhookApikeySecret}});
21-
}else if (webhookUser && webhookPassword){
19+
if (webhookApikeyHeaderName && webhookApikeyHeaderValue){
20+
await axios.post(webhookUrl, {scan, findings }, {headers: { [webhookApikeyHeaderName]: webhookApikeyHeaderValue}});
21+
} else if (webhookUser && webhookPassword){
2222
await axios.post(webhookUrl, {scan, findings }, {auth: {username: webhookUser, password: webhookPassword}});
23-
}else{
23+
} else {
2424
await axios.post(webhookUrl, {scan, findings });
2525
}
2626
}

‎hooks/generic-webhook/templates/webhook-hook.yaml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,17 @@ spec:
3131
name: {{ .Values.hook.authentication.basic.userSecret }}
3232
key: {{ .Values.hook.authentication.basic.passwordKey }}
3333
optional: true
34-
- name: WEBHOOK_APIKEY
34+
- name: WEBHOOK_APIKEY_HEADER_NAME
3535
valueFrom:
3636
secretKeyRef:
3737
name: {{ .Values.hook.authentication.apikey.userSecret }}
38-
key: {{ .Values.hook.authentication.apikey.headerName }}
38+
key: {{ .Values.hook.authentication.apikey.headerNameKey }}
3939
optional: true
40-
- name: WEBHOOK_APIKEY_SECRET
40+
- name: WEBHOOK_APIKEY_HEADER_VALUE
4141
valueFrom:
4242
secretKeyRef:
4343
name: {{ .Values.hook.authentication.apikey.userSecret }}
44-
key: {{ .Values.hook.authentication.apikey.headerValue }}
44+
key: {{ .Values.hook.authentication.apikey.headerValueKey }}
4545
optional: true
4646
affinity:
4747
{{- toYaml .Values.hook.affinity | nindent 4 }}

‎hooks/generic-webhook/values.yaml‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,12 @@ hook:
3838
# hook.authentication -- Optional basic authentication credentials or apikey
3939
authentication:
4040
apikey:
41-
# -- Link a pre-existing generic secret with `usernameKey` and `passwordKey` key / value pairs
41+
# -- Link a pre-existing generic secret with `headerNameKey` and `headerValueKey` key / value pairs
4242
userSecret: generic-webhook-credentials
43-
# -- Customize header name as per your needs ex: X-Api-Key
44-
headerName: X-Example-Header
45-
headerValue: example
43+
# -- Name of the header name key in the `userSecret` secret. Use this if you already have a secret with different key / value pairs
44+
headerNameKey: headerName
45+
# -- Name of the header value key in the `userSecret` secret. Use this if you already have a secret with different key / value pairs
46+
headerValueKey: headerValue
4647
basic:
4748
# -- Link a pre-existing generic secret with `usernameKey` and `passwordKey` key / value pairs
4849
userSecret: generic-webhook-credentials

0 commit comments

Comments
 (0)