Skip to content
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

Make the ht password shorter #990

Merged
merged 1 commit into from
Oct 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 3 additions & 16 deletions ods_ci/build/install_idp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
echo "----> Performing log in the cluster using oc CLI command"
for i in {1..7}
do
oc login $1 --username $2 --password $3 || (echo "Login failed $i times. Trying again in 30 seconds (max 7 times)." && sleep 30)

Check warning on line 6 in ods_ci/build/install_idp.sh

View workflow job for this annotation

GitHub Actions / shellcheck linter

[shellcheck] reported by reviewdog 🐶 Double quote to prevent globbing and word splitting. [SC2086](https://github.com/koalaman/shellcheck/wiki/SC2086) Raw Output: ./ods_ci/build/install_idp.sh:6:16:info:Double quote to prevent globbing and word splitting. [SC2086](https://github.com/koalaman/shellcheck/wiki/SC2086)

Check warning on line 6 in ods_ci/build/install_idp.sh

View workflow job for this annotation

GitHub Actions / shellcheck linter

[shellcheck] reported by reviewdog 🐶 Double quote to prevent globbing and word splitting. [SC2086](https://github.com/koalaman/shellcheck/wiki/SC2086) Raw Output: ./ods_ci/build/install_idp.sh:6:30:info:Double quote to prevent globbing and word splitting. [SC2086](https://github.com/koalaman/shellcheck/wiki/SC2086)

Check warning on line 6 in ods_ci/build/install_idp.sh

View workflow job for this annotation

GitHub Actions / shellcheck linter

[shellcheck] reported by reviewdog 🐶 Double quote to prevent globbing and word splitting. [SC2086](https://github.com/koalaman/shellcheck/wiki/SC2086) Raw Output: ./ods_ci/build/install_idp.sh:6:44:info:Double quote to prevent globbing and word splitting. [SC2086](https://github.com/koalaman/shellcheck/wiki/SC2086)
done
}

Expand All @@ -13,9 +13,9 @@
then
echo "ocm envirnment: ${OCM_ENV}"
if [ -n "${OCM_ENV}" ]; then \
ocm login --token=${OCM_TOKEN} --url=${OCM_ENV} ;\

Check warning on line 16 in ods_ci/build/install_idp.sh

View workflow job for this annotation

GitHub Actions / shellcheck linter

[shellcheck] reported by reviewdog 🐶 Double quote to prevent globbing and word splitting. [SC2086](https://github.com/koalaman/shellcheck/wiki/SC2086) Raw Output: ./ods_ci/build/install_idp.sh:16:35:info:Double quote to prevent globbing and word splitting. [SC2086](https://github.com/koalaman/shellcheck/wiki/SC2086)

Check warning on line 16 in ods_ci/build/install_idp.sh

View workflow job for this annotation

GitHub Actions / shellcheck linter

[shellcheck] reported by reviewdog 🐶 Double quote to prevent globbing and word splitting. [SC2086](https://github.com/koalaman/shellcheck/wiki/SC2086) Raw Output: ./ods_ci/build/install_idp.sh:16:54:info:Double quote to prevent globbing and word splitting. [SC2086](https://github.com/koalaman/shellcheck/wiki/SC2086)
else
ocm login --token=${OCM_TOKEN}

Check warning on line 18 in ods_ci/build/install_idp.sh

View workflow job for this annotation

GitHub Actions / shellcheck linter

[shellcheck] reported by reviewdog 🐶 Double quote to prevent globbing and word splitting. [SC2086](https://github.com/koalaman/shellcheck/wiki/SC2086) Raw Output: ./ods_ci/build/install_idp.sh:18:35:info:Double quote to prevent globbing and word splitting. [SC2086](https://github.com/koalaman/shellcheck/wiki/SC2086)
fi
else
echo -e "\033[0;33m OCM Token not set. Please run again and set the required token \033[0m"
Expand All @@ -24,40 +24,27 @@
}

function generate_rand_string(){
# sleep 2
# date +%s | sha256sum | base64 | head -c 64
p_array=()
for i in {a..z} {A..Z} {0..9};
do
p_array[$RANDOM]=$i
done
first=${p_array[-1]}
chars='@#$%_+='
for el in ${p_array[@]}
do
p_array[$RANDOM]=${chars:$((RANDOM % ${#chars})):1}
done
p_array[0]=$first
printf %s ${p_array[@]}
local length="${1:-64}"
cat /dev/urandom | tr -dc "0-9a-zA-Z@#$%_+=" | head -c "${length}"

Check failure on line 28 in ods_ci/build/install_idp.sh

View workflow job for this annotation

GitHub Actions / shellcheck linter

[shellcheck] reported by reviewdog 🐶 Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead. [SC2002](https://github.com/koalaman/shellcheck/wiki/SC2002) Raw Output: ./ods_ci/build/install_idp.sh:28:7:style:Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead. [SC2002](https://github.com/koalaman/shellcheck/wiki/SC2002)
}

function generate_rand_user_base_suffix(){
array=()
for i in {a..z} {A..Z};
do
array[$RANDOM]=$i

Check failure on line 35 in ods_ci/build/install_idp.sh

View workflow job for this annotation

GitHub Actions / shellcheck linter

[shellcheck] reported by reviewdog 🐶 $/${} is unnecessary on arithmetic variables. [SC2004](https://github.com/koalaman/shellcheck/wiki/SC2004) Raw Output: ./ods_ci/build/install_idp.sh:35:11:style:$/${} is unnecessary on arithmetic variables. [SC2004](https://github.com/koalaman/shellcheck/wiki/SC2004)
done
printf %s ${array[@]::$1} $'\n'

Check failure on line 37 in ods_ci/build/install_idp.sh

View workflow job for this annotation

GitHub Actions / shellcheck linter

[shellcheck] reported by reviewdog 🐶 Double quote array expansions to avoid re-splitting elements. [SC2068](https://github.com/koalaman/shellcheck/wiki/SC2068) Raw Output: ./ods_ci/build/install_idp.sh:37:13:error:Double quote array expansions to avoid re-splitting elements. [SC2068](https://github.com/koalaman/shellcheck/wiki/SC2068)
}

function generate_incremental_suffixes(){
n_users=$(echo $suffix_info | jq '.n_users')

Check warning on line 41 in ods_ci/build/install_idp.sh

View workflow job for this annotation

GitHub Actions / shellcheck linter

[shellcheck] reported by reviewdog 🐶 Double quote to prevent globbing and word splitting. [SC2086](https://github.com/koalaman/shellcheck/wiki/SC2086) Raw Output: ./ods_ci/build/install_idp.sh:41:20:info:Double quote to prevent globbing and word splitting. [SC2086](https://github.com/koalaman/shellcheck/wiki/SC2086)
additional_base_suffix=$1
i=1
if [[ $n_users -eq 1 ]]
then
USERS_ARR+=($prefix$additional_base_suffix)

Check warning on line 46 in ods_ci/build/install_idp.sh

View workflow job for this annotation

GitHub Actions / shellcheck linter

[shellcheck] reported by reviewdog 🐶 Quote to prevent word splitting/globbing, or split robustly with mapfile or read -a. [SC2206](https://github.com/koalaman/shellcheck/wiki/SC2206) Raw Output: ./ods_ci/build/install_idp.sh:46:25:warning:Quote to prevent word splitting/globbing, or split robustly with mapfile or read -a. [SC2206](https://github.com/koalaman/shellcheck/wiki/SC2206)

Check warning on line 46 in ods_ci/build/install_idp.sh

View workflow job for this annotation

GitHub Actions / shellcheck linter

[shellcheck] reported by reviewdog 🐶 Quote to prevent word splitting/globbing, or split robustly with mapfile or read -a. [SC2206](https://github.com/koalaman/shellcheck/wiki/SC2206) Raw Output: ./ods_ci/build/install_idp.sh:46:32:warning:Quote to prevent word splitting/globbing, or split robustly with mapfile or read -a. [SC2206](https://github.com/koalaman/shellcheck/wiki/SC2206)
PWS_ARR+=($pw)

Check warning on line 47 in ods_ci/build/install_idp.sh

View workflow job for this annotation

GitHub Actions / shellcheck linter

[shellcheck] reported by reviewdog 🐶 Quote to prevent word splitting/globbing, or split robustly with mapfile or read -a. [SC2206](https://github.com/koalaman/shellcheck/wiki/SC2206) Raw Output: ./ods_ci/build/install_idp.sh:47:23:warning:Quote to prevent word splitting/globbing, or split robustly with mapfile or read -a. [SC2206](https://github.com/koalaman/shellcheck/wiki/SC2206)
else
while [[ $i -le $n_users ]]; do
USERS_ARR+=($prefix$additional_base_suffix$i)
Expand Down Expand Up @@ -86,7 +73,7 @@
test_user_mapping=$(jq -r --arg idpname $1 --arg test_user $2 '.[][$idpname][$test_user]' ods_ci/configs/templates/user_config.json)
users_string=$3
if [[ "$test_user_mapping" = *"<RAND_BASE>"* ]]; then
test_user_regex=$(echo "${test_user_mapping/<RAND_BASE>/"[a-zA-Z]+"}")

Check failure on line 76 in ods_ci/build/install_idp.sh

View workflow job for this annotation

GitHub Actions / shellcheck linter

[shellcheck] reported by reviewdog 🐶 Useless echo? Instead of 'cmd $(echo foo)', just use 'cmd foo'. [SC2116](https://github.com/koalaman/shellcheck/wiki/SC2116) Raw Output: ./ods_ci/build/install_idp.sh:76:23:style:Useless echo? Instead of 'cmd $(echo foo)', just use 'cmd foo'. [SC2116](https://github.com/koalaman/shellcheck/wiki/SC2116)
test_user_mapping=$(echo $users_string | egrep -o "$test_user_regex(,|$)" | tr -d ",")
echo $test_user_mapping
else
Expand All @@ -101,7 +88,7 @@
pw=$(echo $idp | jq -r '.pw')
if [[ "$pw" = "<GEN_RAMDOM_PW>" ]]
then
pw=$(generate_rand_string)
pw=$(generate_rand_string "64")
if [ "${RETURN_PW}" -eq 1 ]
then
echo Random $1 pasword: $pw
Expand Down Expand Up @@ -141,7 +128,7 @@
generate_users_creds htpasswd
HTP_USERS=("${USERS_ARR[@]}")
htp_pw=$pw
htp_users_string=$(printf ,%s ${HTP_USERS[@]})

Check failure on line 131 in ods_ci/build/install_idp.sh

View workflow job for this annotation

GitHub Actions / shellcheck linter

[shellcheck] reported by reviewdog 🐶 Double quote array expansions to avoid re-splitting elements. [SC2068](https://github.com/koalaman/shellcheck/wiki/SC2068) Raw Output: ./ods_ci/build/install_idp.sh:131:33:error:Double quote array expansions to avoid re-splitting elements. [SC2068](https://github.com/koalaman/shellcheck/wiki/SC2068)
cluster_adm_user=$(extract_testvariables_users_mapping htpasswd cluster_admin_username $htp_users_string)
if [ "${RETURN_PW}" -eq 1 ]
then
Expand Down Expand Up @@ -199,8 +186,8 @@
generate_users_creds ldap
LDAP_USERS=("${USERS_ARR[@]}")
LDAP_PWS=("${PWS_ARR[@]}")
ldap_users_str=$(printf ,%s ${LDAP_USERS[@]})

Check failure on line 189 in ods_ci/build/install_idp.sh

View workflow job for this annotation

GitHub Actions / shellcheck linter

[shellcheck] reported by reviewdog 🐶 Double quote array expansions to avoid re-splitting elements. [SC2068](https://github.com/koalaman/shellcheck/wiki/SC2068) Raw Output: ./ods_ci/build/install_idp.sh:189:31:error:Double quote array expansions to avoid re-splitting elements. [SC2068](https://github.com/koalaman/shellcheck/wiki/SC2068)
ldap_pws_str=$(printf ,%s ${LDAP_PWS[@]})

Check failure on line 190 in ods_ci/build/install_idp.sh

View workflow job for this annotation

GitHub Actions / shellcheck linter

[shellcheck] reported by reviewdog 🐶 Double quote array expansions to avoid re-splitting elements. [SC2068](https://github.com/koalaman/shellcheck/wiki/SC2068) Raw Output: ./ods_ci/build/install_idp.sh:190:29:error:Double quote array expansions to avoid re-splitting elements. [SC2068](https://github.com/koalaman/shellcheck/wiki/SC2068)
ldap_users_str=${ldap_users_str:1}
ldap_pws_str=${ldap_pws_str:1}
ldap_pw=$pw
Expand Down Expand Up @@ -385,7 +372,7 @@
for prefix in "${prefixes[@]}"; do
suffix_info=$(echo $idp | jq --arg pref $prefix '.suffixes[$pref]')
suffix_type=$(echo $suffix_info | jq --raw-output '.type')
if [[ $suffix_info = "null" || -z "${suffix_info// }" || ! -n $suffix_info || $suffix_type = "null" || -z "${suffix_type// }" || ! -n $suffix_type ]]; then

Check failure on line 375 in ods_ci/build/install_idp.sh

View workflow job for this annotation

GitHub Actions / shellcheck linter

[shellcheck] reported by reviewdog 🐶 Use -z instead of ! -n. [SC2236](https://github.com/koalaman/shellcheck/wiki/SC2236) Raw Output: ./ods_ci/build/install_idp.sh:375:65:style:Use -z instead of ! -n. [SC2236](https://github.com/koalaman/shellcheck/wiki/SC2236)

Check failure on line 375 in ods_ci/build/install_idp.sh

View workflow job for this annotation

GitHub Actions / shellcheck linter

[shellcheck] reported by reviewdog 🐶 Use -z instead of ! -n. [SC2236](https://github.com/koalaman/shellcheck/wiki/SC2236) Raw Output: ./ods_ci/build/install_idp.sh:375:137:style:Use -z instead of ! -n. [SC2236](https://github.com/koalaman/shellcheck/wiki/SC2236)
echo ".suffixes and its content must be set!"
exit 1
fi
Expand Down
Loading