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

Problem when a secret includes several words with a blank space or hyphen between them #4

Open
Dwolo opened this issue Nov 11, 2022 · 0 comments

Comments

@Dwolo
Copy link

Dwolo commented Nov 11, 2022

Description

When the value of a secret contains several words with a blank space or a hyphen between them, some of those words are printed in the log at the beginning and also the value might change if it includes a hyphen, because it changes to an underscore.

Files

init.sh

To Reproduce

  1. VARIABLE1 is stored in the parameter store (its value includes a hyphen):
    chamber write <service_name> VARIABLE1 'VALUE1 VALUE2-VALUE3'
  2. When init.sh is executed (e.g. /init.sh env), it retrieves:
VARIABLE1='VALUE1
VALUE2_VALUE3'

instead of:

VARIABLE1='VALUE1 VALUE2-VALUE3'

Posible solutions

Add double quotes when invoking a variable containing multiple words.

  1. For the case of the hyphen changing to underscore: replace line 94 in init.sh
    from:
to_secrets=$(echo $chamber_env | sed 's/export //g' | for e in $(cat -) ; do echo $e | awk '{ gsub("-", "_", $1) } 1' FS='=' OFS='='; done)

to:

to_secrets=$(echo "$chamber_env" | sed 's/export //g' | for e in "$(cat -)" ; do echo "$e" | awk '{ gsub("-", "_", $1) } 1' FS='=' OFS='='; done)
  1. For the values being printed in the log:
    Change line 95 from: eval_export $to_secrets to eval_export "$to_secrets"
    And change function eval_export (line 66) from:
eval_export() {
    to_export="$@"
    keys=$(for v in $to_export ; do echo $v | awk -F '=' '{print $1}' ; done)
    echo $keys
    eval export $to_export
}

to:

eval_export() {
    to_export="$@"
    keys=$(for v in "$to_export" ; do echo "$v" | awk -F '=' '{print $1}' ; done)
    echo $keys
    eval export $to_export
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant