mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2025-12-07 09:42:46 +01:00
Firewall Changes
This commit is contained in:
@@ -507,6 +507,18 @@ valid_hostname() {
|
|||||||
[[ $hostname =~ ^[a-zA-Z0-9\-]+$ ]] && [[ $hostname != 'localhost' ]] && return 0 || return 1
|
[[ $hostname =~ ^[a-zA-Z0-9\-]+$ ]] && [[ $hostname != 'localhost' ]] && return 0 || return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
verify_ip4() {
|
||||||
|
local ip=$1
|
||||||
|
# Is this an IP or CIDR?
|
||||||
|
if grep -qP "^[^/]+/[^/]+$" <<< $ip; then
|
||||||
|
# Looks like a CIDR
|
||||||
|
valid_ip4_cidr_mask "$ip"
|
||||||
|
else
|
||||||
|
# We know this is not a CIDR - Is it an IP?
|
||||||
|
valid_ip4 "$ip"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
valid_ip4() {
|
valid_ip4() {
|
||||||
local ip=$1
|
local ip=$1
|
||||||
|
|
||||||
|
|||||||
@@ -71,11 +71,11 @@ else
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Are we dealing with an IP?
|
# Are we dealing with an IP?
|
||||||
if valid_ip4 "$IP"; then
|
if verify_ip4 "$IP"; then
|
||||||
echo "$IP is valid"
|
echo "$IP is a valid IP or CIDR"
|
||||||
else
|
else
|
||||||
echo "$IP is not a valid IP Address"
|
echo "$IP is not a valid IP or CIDR"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -90,14 +90,7 @@ if [ -f "$local_salt_dir/hostgroups/$ROLE" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# If you have reached this part of your quest then let's add the IP
|
# If you have reached this part of your quest then let's add the IP
|
||||||
if [ -f "$local_salt_dir/hostgroups/$ROLE" ]; then
|
echo "Adding $IP to the $ROLE role"
|
||||||
touch $local_salt_dir/hostgroups/$ROLE
|
|
||||||
echo "Adding $IP to the $ROLE role"
|
|
||||||
echo "$IP" > $local_salt_dir/hostgroups/$ROLE
|
|
||||||
else
|
|
||||||
echo "Adding $IP to the $ROLE role"
|
|
||||||
echo "$IP" >> $local_salt_dir/hostgroups/$ROLE
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check to see if we are applying this right away.
|
# Check to see if we are applying this right away.
|
||||||
if [ "$APPLY" = "true" ]; then
|
if [ "$APPLY" = "true" ]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user