From 3ac74258dbfc2c661558287aca0add40e989b46b Mon Sep 17 00:00:00 2001 From: monsterry <44836730+monsterry@users.noreply.github.com> Date: Wed, 15 Jul 2020 07:28:02 +0200 Subject: [PATCH] [Config] Allow CIDR notation for API_ALLOW_FROM (#3655) --- data/Dockerfiles/phpfpm/docker-entrypoint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/Dockerfiles/phpfpm/docker-entrypoint.sh b/data/Dockerfiles/phpfpm/docker-entrypoint.sh index 4f2f777e..e69bfbc6 100755 --- a/data/Dockerfiles/phpfpm/docker-entrypoint.sh +++ b/data/Dockerfiles/phpfpm/docker-entrypoint.sh @@ -116,8 +116,8 @@ if [[ "${MASTER}" =~ ^([yY][eE][sS]|[yY])+$ ]]; then if [[ ${API_ALLOW_FROM} != "invalid" ]] && [[ ! -z ${API_ALLOW_FROM} ]]; then IFS=',' read -r -a API_ALLOW_FROM_ARR <<< "${API_ALLOW_FROM}" declare -a VALIDATED_API_ALLOW_FROM_ARR - REGEX_IP6='^([0-9a-fA-F]{0,4}:){1,7}[0-9a-fA-F]{0,4}$' - REGEX_IP4='^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$' + REGEX_IP6='^([0-9a-fA-F]{0,4}:){1,7}[0-9a-fA-F]{0,4}(/([0-9]|[1-9][0-9]|1[0-1][0-9]|12[0-8]))?$' + REGEX_IP4='^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+(/([0-9]|[1-2][0-9]|3[0-2]))?$' for IP in "${API_ALLOW_FROM_ARR[@]}"; do if [[ ${IP} =~ ${REGEX_IP6} ]] || [[ ${IP} =~ ${REGEX_IP4} ]]; then VALIDATED_API_ALLOW_FROM_ARR+=("${IP}")