-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[bitnami/keycloak] Add support for ipv6 #40224
Conversation
bitnami/keycloak/21/debian-11/rootfs/opt/bitnami/scripts/libkeycloak.sh
Outdated
Show resolved
Hide resolved
Hi @covert8, Thanks for your contribution. I have tested your
And it execution results
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check the IPv6 output for ::1
(IPv6 localhost address) and other special addresses like that.
bitnami/keycloak/21/debian-11/prebuildfs/opt/bitnami/scripts/libvalidations.sh
Outdated
Show resolved
Hide resolved
#!/bin/bash
validate_ipv6() {
local ip="${1:?ip is missing}"
local stat=1
local full_address_regex='^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$'
local short_address_regex='^((([0-9a-fA-F]{1,4}:){0,6}[0-9a-fA-F]{1,4}){0,6}::(([0-9a-fA-F]{1,4}:){0,6}[0-9a-fA-F]{1,4}){0,6})$'
if [[ $ip =~ $full_address_regex || $ip =~ $short_address_regex || $ip == "::" ]]; then
stat=0
fi
echo $stat
}
echo "Tests for IPv6 addresses:"
echo "-------------------------"
valid_ipv6_addresses=(
"::1"
"::"
"1234::"
"2001:0db8:85a3:0000:0000:8a2e:0370:7334"
"2001:db8::1:0:0:1"
"fe80::1"
"2001:0:3238:DFE1:63::FEFB"
"2001:db8:85a3:0:0:8a2e:370:7334"
"2001:db8:1234:5678::abcd"
"2001:0db8:0001:0000:0000:0ab9:C0A8:0102"
"2001:db8:0:1:1:1:1:1"
"::1234:5678"
"2001:0db8:0000:0000:0000:0000:0000:0000"
"2001:0db8:0000:0000:0000::"
"2001:0db8:0000:0000::"
"::2001:0db8:0000:0000:0000"
)
invalid_ipv6_addresses=(
"::2001:0db8:0000:0000::"
"::2001:0db8:0000::"
"::2001:0db8::"
"127.0.0.1"
"192.168.0.1"
"2001:db8:3333:4444:5555:6666:7777"
"2001:db8:3333:4444:5555:6666:7777:"
":::"
"::gggg"
"2001:::8888"
"2001:db8:3333:4444:5555:6666:7777:8888:9999"
"2001:db8:3333:4444:5555:6666:7777:::"
"2001:0db8:0000:0000:0000:0000:0000:0000:0000"
":::1234:5678"
)
# Test valid IPv6 addresses
echo "Valid IPv6 addresses:"
for ip in "${valid_ipv6_addresses[@]}"; do
result=$(validate_ipv6 "$ip")
if [[ $result -ne 0 ]]; then
echo "$ip - Invalid"
else
echo "$ip - Valid"
fi
done
# Test invalid IPv6 addresses
echo "Invalid IPv6 addresses:"
for ip in "${invalid_ipv6_addresses[@]}"; do
result=$(validate_ipv6 "$ip")
if [[ $result -eq 0 ]]; then
echo "$ip - Valid"
else
echo "$ip - Invalid"
fi
done |
3a359c8
to
6a13033
Compare
It should cover most base cases now; although i don't know if for example 2001:0db8:0000:0000:0000:: is strictly rfc compliant |
eb5d82e
to
9957327
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple of aesthetic changes.
bitnami/keycloak/21/debian-11/prebuildfs/opt/bitnami/scripts/libvalidations.sh
Outdated
Show resolved
Hide resolved
bitnami/keycloak/21/debian-11/prebuildfs/opt/bitnami/scripts/libvalidations.sh
Outdated
Show resolved
Hide resolved
bitnami/keycloak/21/debian-11/prebuildfs/opt/bitnami/scripts/libvalidations.sh
Outdated
Show resolved
Hide resolved
bitnami/keycloak/21/debian-11/prebuildfs/opt/bitnami/scripts/libvalidations.sh
Outdated
Show resolved
Hide resolved
bitnami/keycloak/21/debian-11/prebuildfs/opt/bitnami/scripts/libvalidations.sh
Outdated
Show resolved
Hide resolved
bitnami/keycloak/21/debian-11/prebuildfs/opt/bitnami/scripts/libvalidations.sh
Outdated
Show resolved
Hide resolved
Thanks for the review, I think I got all the changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution!
@covert8 changes look fine to me, but you have to meet the DCO requirement. Please check the docs linked below https://github.com/bitnami/containers/pull/40224/checks?check_run_id=15133446058 |
ip="2001:0db8:85a3:0000:0000:8a2e:0370:7334" ip="fd00::" ip="::" validate_ipv6 "$ip" result=$? if [[ $result -eq 0 ]]; then echo "IPv6 address is valid" else echo "IPv6 address is invalid" fi Signed-off-by: Louis <covert8@users.noreply.github.com> Signed-off-by: covert <covert8@users.noreply.github.com>
Signed-off-by: Louis <covert8@users.noreply.github.com> Signed-off-by: covert <covert8@users.noreply.github.com>
Signed-off-by: Louis <covert8@users.noreply.github.com> Signed-off-by: covert <covert8@users.noreply.github.com>
Co-authored-by: Damiano Albani <damiano.albani@gmail.com> Signed-off-by: Louis <covert8@users.noreply.github.com> Signed-off-by: covert <covert8@users.noreply.github.com>
Signed-off-by: covert <covert8@users.noreply.github.com>
@gongomgra done :) |
Quick question, will this change also be merged for all other containers making use of validate_ipv4? |
Hi @covert8, The changes in |
Description of the change
Adds supporting functions for validating ipv6 and replace strict ipv4 validator allowing both ipv4 and ipv6
Benefits
fixes #21223
Possible drawbacks
none
Applicable issues
#21223
Additional information