42atomys/webhooked

fix: Empty environment variable is catch like empty string and cause 200 OK response when no header is send

Closed this issue · 0 comments

Describe the bug
When the configuration of a webhook entry is defined to load a value from an environment variable and the env variable is not set, we can pass the security with an empty header or no header.

To Reproduce
Steps to reproduce the behavior:

  1. My config is
- name: exampleHook
  entrypointUrl: /webhooks/example
  security:
  - header:
      inputs:
      - name: headerName
        value: X-Hook-Secret
  - compare:
      inputs:
      - name: first
        value: '{{ .Outputs.header.value }}'
      - name: second
        valueFrom:
          envRef: HOOK_SECRET
  1. Try to store following payload '....'
curl --request POST \
  --url http://atomys.atomys.lab:8080/v1alpha1/webhooks/example \
  --header 'Content-Type: application/json' \
  --header 'X-Hook-Secret: ' \
  --data '{
	"type": 42,
	"payload": {
		"nested": "amazing"
	}
}'

Expected behavior
Check if the environment variable is correctly set before get it. Its usefull to prevent misspell or typo error