Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ Committing with `git commit -s` will add the sign-off at the end of the commit m
- Felix Hörsting <[email protected]>
- Matthew Cascio <[email protected]>
- Patryk Miłek <[email protected]>
- Renato Burton <[email protected]>
3 changes: 3 additions & 0 deletions hooks/generic-webhook/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ Kubernetes: `>=v1.11.0-0`
| hook.authentication.basic.passwordKey | string | `"password"` | Name of the password key in the `userSecret` secret. Use this if you already have a secret with different key / value pairs |
| hook.authentication.basic.userSecret | string | `"generic-webhook-credentials"` | Link a pre-existing generic secret with `usernameKey` and `passwordKey` key / value pairs |
| hook.authentication.basic.usernameKey | string | `"username"` | Name of the username key in the `userSecret` secret. Use this if you already have a secret with different key / value pairs |
| hook.authentication.apikey.userSecret | string | `"generic-webhook-credentials"` | Link a pre-existing generic secret with `usernameKey` and `passwordKey` key / value pairs |
| hook.authentication.apikey.headerName | string | `"X-api-key"` | Customize header name as per your needs |
| hook.authentication.apikey.headerValue | string | `"26ea529e517748baa6d87ebfe5781475"` | Use your API key |
| hook.image.repository | string | `"docker.io/securecodebox/hook-generic-webhook"` | Hook image repository |
| hook.image.tag | string | defaults to the charts version | The image Tag defaults to the charts version if not defined. |
| hook.labels | object | `{}` | Add Kubernetes Labels to the hook definition |
Expand Down
3 changes: 3 additions & 0 deletions hooks/generic-webhook/docs/README.ArtifactHub.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ Kubernetes: `>=v1.11.0-0`
| hook.authentication.basic.passwordKey | string | `"password"` | Name of the password key in the `userSecret` secret. Use this if you already have a secret with different key / value pairs |
| hook.authentication.basic.userSecret | string | `"generic-webhook-credentials"` | Link a pre-existing generic secret with `usernameKey` and `passwordKey` key / value pairs |
| hook.authentication.basic.usernameKey | string | `"username"` | Name of the username key in the `userSecret` secret. Use this if you already have a secret with different key / value pairs |
| hook.authentication.apikey.userSecret | string | `"generic-webhook-credentials"` | Link a pre-existing generic secret with `usernameKey` and `passwordKey` key / value pairs |
| hook.authentication.apikey.headerName | string | `"X-api-key"` | Customize header name as per your needs |
| hook.authentication.apikey.headerValue | string | `"26ea529e517748baa6d87ebfe5781475"` | Use your API key |
| hook.image.repository | string | `"docker.io/securecodebox/hook-generic-webhook"` | Hook image repository |
| hook.image.tag | string | defaults to the charts version | The image Tag defaults to the charts version if not defined. |
| hook.labels | object | `{}` | Add Kubernetes Labels to the hook definition |
Expand Down
6 changes: 5 additions & 1 deletion hooks/generic-webhook/hook/hook.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@ async function handle({
webhookUrl = process.env["WEBHOOK_URL"],
webhookUser = process.env["WEBHOOK_USER"],
webhookPassword = process.env["WEBHOOK_PASSWORD"],
webhookApikey = process.env["WEBHOOK_APIKEY"],
webhookApikeySecret = process.env["WEBHOOK_APIKEY_SECRET"],
axios = require('axios')
}) {
const findings = await getFindings();

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

if (webhookUser && webhookPassword){
if (webhookApikey && webhookApikeySecret){
await axios.post(webhookUrl, {scan, findings }, {headers: { [webhookApikey]: webhookApikeySecret}});
}else if (webhookUser && webhookPassword){
await axios.post(webhookUrl, {scan, findings }, {auth: {username: webhookUser, password: webhookPassword}});
}else{
await axios.post(webhookUrl, {scan, findings });
Expand Down
12 changes: 12 additions & 0 deletions hooks/generic-webhook/templates/webhook-hook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ spec:
name: {{ .Values.hook.authentication.basic.userSecret }}
key: {{ .Values.hook.authentication.basic.passwordKey }}
optional: true
- name: WEBHOOK_APIKEY
valueFrom:
secretKeyRef:
name: {{ .Values.hook.authentication.apikey.userSecret }}
key: {{ .Values.hook.authentication.apikey.headerName }}
optional: true
- name: WEBHOOK_APIKEY_SECRET
valueFrom:
secretKeyRef:
name: {{ .Values.hook.authentication.apikey.userSecret }}
key: {{ .Values.hook.authentication.apikey.headerValue }}
optional: true
affinity:
{{- toYaml .Values.hook.affinity | nindent 4 }}
tolerations:
Expand Down
8 changes: 7 additions & 1 deletion hooks/generic-webhook/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,14 @@ hook:
# hook.tolerations -- Optional tolerations settings that control how the hook job is scheduled (see: https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/)
tolerations: []

# hook.authentication -- Optional basic authentication credentials
# hook.authentication -- Optional basic authentication credentials or apikey
authentication:
apikey:
# -- Link a pre-existing generic secret with `usernameKey` and `passwordKey` key / value pairs
userSecret: generic-webhook-credentials
# -- Customize header name as per your needs ex: X-Api-Key
headerName: X-Example-Header
headerValue: example
basic:
# -- Link a pre-existing generic secret with `usernameKey` and `passwordKey` key / value pairs
userSecret: generic-webhook-credentials
Expand Down