86531c5cb0
Build & Push / Pipeline Tests (push) Successful in 1m50s
Test / Type Check (all packages) (push) Successful in 54s
Build & Push / Build & Push Docker Image (push) Failing after 32s
Test / API Unit Tests (push) Successful in 1m11s
Test / Homepage Unit Tests (push) Successful in 49s
Test / Carplace Unit Tests (push) Successful in 46s
Test / Admin Unit Tests (push) Successful in 42s
Test / Dashboard Unit Tests (push) Successful in 46s
Test / API Integration Tests (push) Successful in 1m5s
83 lines
1.8 KiB
Bash
83 lines
1.8 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
usage() {
|
|
cat <<'EOF'
|
|
Usage:
|
|
describe-env-values.sh <env-file> <KEY> [KEY...]
|
|
|
|
Prints a non-secret status for each requested key in <env-file>.
|
|
EOF
|
|
}
|
|
|
|
if [[ $# -lt 2 ]]; then
|
|
usage >&2
|
|
exit 1
|
|
fi
|
|
|
|
env_file="$1"
|
|
shift
|
|
|
|
if [[ ! -f "${env_file}" ]]; then
|
|
echo "Missing env file: ${env_file}" >&2
|
|
exit 1
|
|
fi
|
|
|
|
read_env_value() {
|
|
local key="$1"
|
|
local value
|
|
|
|
value="$(
|
|
awk -F= -v key="${key}" '
|
|
/^[[:space:]]*#/ || index($0, "=") == 0 {
|
|
next
|
|
}
|
|
{
|
|
name = $1
|
|
sub(/^[[:space:]]*export[[:space:]]+/, "", name)
|
|
gsub(/^[[:space:]]+|[[:space:]]+$/, "", name)
|
|
if (name == key) {
|
|
value = substr($0, index($0, "=") + 1)
|
|
}
|
|
}
|
|
END {
|
|
print value
|
|
}
|
|
' "${env_file}"
|
|
)"
|
|
|
|
value="${value%$'\r'}"
|
|
value="${value#"${value%%[![:space:]]*}"}"
|
|
value="${value%"${value##*[![:space:]]}"}"
|
|
if [[ "${value}" == \"*\" && "${value}" == *\" ]]; then
|
|
value="${value#\"}"
|
|
value="${value%\"}"
|
|
elif [[ "${value}" == \'*\' && "${value}" == *\' ]]; then
|
|
value="${value#\'}"
|
|
value="${value%\'}"
|
|
fi
|
|
printf '%s' "${value}"
|
|
}
|
|
|
|
describe_value() {
|
|
local key="$1"
|
|
local value="$2"
|
|
|
|
if [[ -z "${value}" ]]; then
|
|
printf '%s: missing\n' "${key}"
|
|
elif [[ "${value}" == placeholder || "${value}" == replace-with-* || "${value}" == *changeme* || "${value}" == *change-me* ]]; then
|
|
printf '%s: placeholder\n' "${key}"
|
|
elif [[ "${key}" == STRIPE_API_KEY && ( "${value}" == sk_live_* || "${value}" == rk_live_* ) ]]; then
|
|
printf '%s: valid live prefix\n' "${key}"
|
|
elif [[ "${key}" == STRIPE_WEBHOOK_SECRET && "${value}" == whsec_* ]]; then
|
|
printf '%s: valid webhook prefix\n' "${key}"
|
|
else
|
|
printf '%s: invalid prefix\n' "${key}"
|
|
fi
|
|
}
|
|
|
|
for key in "$@"; do
|
|
describe_value "${key}" "$(read_env_value "${key}")"
|
|
done
|