Felix Niederwanger
46418bcf3a
Sanitize the environment variables when running webhooks and add ability to add custom environment variables per webhook.
30 lines
762 B
Bash
Executable file
30 lines
762 B
Bash
Executable file
#!/bin/bash -e
|
|
# Script to test for environment variable sanitation
|
|
|
|
set -o pipefail
|
|
|
|
if [[ $PUBLIC1 != "one" ]]; then
|
|
echo "PUBLIC1 variable not valid"
|
|
exit 1
|
|
fi
|
|
if [[ $PUBLIC2 != "two" ]]; then
|
|
echo "PUBLIC2 variable not valid"
|
|
exit 1
|
|
fi
|
|
|
|
if env | grep 'SECRET1' >/dev/null; then
|
|
echo "SECRET1 variable is set but it should not be"
|
|
echo "Environment sanitation failed"
|
|
exit 1
|
|
fi
|
|
|
|
# There must never be more than 10 variables set
|
|
# Some variables will be set by bash at startup (e.g. PWD), so we are never in a
|
|
# pristine environment. However, more than 10 variables indicates something's off
|
|
# with the env sanitation
|
|
if [[ `env | wc -l` -ge 10 ]]; then
|
|
echo "More than 10 env variables detected"
|
|
exit 1
|
|
fi
|
|
|
|
echo "all good" |