Skip to content

Commit b5a6356

Browse files
Update bito-cra.sh
1 parent 9d5e47a commit b5a6356

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

cra-scripts/bito-cra.sh

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,6 @@ optional_params_server=(
423423
"code_context"
424424
"nexus_url"
425425
"cr_event_type"
426-
"encryption_key"
427426
)
428427

429428
bee_params=(
@@ -576,8 +575,6 @@ for param in "${required_params[@]}" "${bee_params[@]}" "${optional_params[@]}";
576575
nexus_url=$(echo "${props[$param]}" | sed 's/^[ \t]*//;s/[ \t]*$//')
577576
elif [ "$param" == "cr_event_type" ]; then
578577
validate_cr_event_type "${props[$param]}"
579-
elif [ "$param" == "encryption_key" ]; then
580-
encryption_key_value=${props[$param]}
581578
else
582579
docker_cmd+=" --$param=${props[$param]}"
583580
fi
@@ -594,6 +591,7 @@ encrypt_git_secret() {
594591
local plaintext=$2
595592

596593
# Convert key to hex
594+
local key=$(openssl rand -base64 32)
597595
local hex_key=$(echo -n "$key" | xxd -p -c 256)
598596

599597
# Generate IV (Initialization Vector)
@@ -614,22 +612,15 @@ encrypt_git_secret() {
614612

615613
param_bito_access_key="bito_cli.bito.access_key"
616614
param_git_access_token="git.access_token"
617-
param_encryption_key="encryption_key"
615+
618616
docker_enc_params=
619617
if [ "$mode" == "server" ]; then
620618
if [ -n "${props[$param_bito_access_key]}" ] && [ -n "${props[$param_git_access_token]}" ]; then
621619
git_secret="${props[$param_bito_access_key]}@#~^${props[$param_git_access_token]}"
622-
623-
if [ -n "${props[$param_encryption_key]}" ]; then
624-
encryption_key="${props[$param_encryption_key]}"
625-
if [[ ${#encryption_key} -eq 44 ]] && [[ $encryption_key =~ ^[A-Za-z0-9+/]{43}=$ ]]; then
626-
git_secret=$(encrypt_git_secret "$encryption_key" "$git_secret")
627-
docker_enc_params=" --git.secret=$git_secret --encryption_key=$encryption_key"
628-
else
629-
echo "Error: Encryption key must be a 44-character base64 string generated by openssl rand -base64 32."
630-
exit 1
631-
fi
632-
fi
620+
encryption_key=$(openssl rand -base64 32)
621+
git_secret=$(encrypt_git_secret "$encryption_key" "$git_secret")
622+
docker_enc_params=" --git.secret=$git_secret --encryption_key=$encryption_key"
623+
633624

634625
echo "Use below as Gitlab and Github Webhook secret:"
635626
echo "$git_secret"

0 commit comments

Comments
 (0)