Skip to content

Commit

Permalink
Merge pull request #2381 from wazuh/2350-fix-dns-validation
Browse files Browse the repository at this point in the history
Fixed DNS validation in the Installation Assistant
  • Loading branch information
teddytpc1 authored Aug 25, 2023
2 parents e5543fc + 7187a92 commit 55cfe35
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions unattended_installer/cert_tool/certFunctions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function cert_generateCertificateconfiguration() {
sed -i '/IP.1/d' "${cert_tmp_path}/${1}.conf"
for (( i=2; i<=${#@}; i++ )); do
isIP=$(echo "${!i}" | grep -P "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$")
isDNS=$(echo "${!i}" | grep -P "^[a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9](?:\.[a-zA-Z-]{2,})+$" )
isDNS=$(echo "${!i}" | grep -P "^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])\.([A-Za-z]{2,})$" )
j=$((i-1))
if [ "${isIP}" ]; then
printf '%s\n' " IP.${j} = ${!i}" >> "${cert_tmp_path}/${1}.conf"
Expand Down Expand Up @@ -330,9 +330,12 @@ function cert_readConfig() {
all_ips=("${indexer_node_ips[@]}" "${server_node_ips[@]}" "${dashboard_node_ips[@]}")

for ip in "${all_ips[@]}"; do
if ! cert_checkPrivateIp "$ip"; then
common_logger -e "The IP ${ip} is public."
exit 1
isIP=$(echo "${ip}" | grep -P "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$")
if [[ -n "${isIP}" ]]; then
if ! cert_checkPrivateIp "$ip"; then
common_logger -e "The IP ${ip} is public."
exit 1
fi
fi
done

Expand Down

0 comments on commit 55cfe35

Please sign in to comment.