I have some code that is loading passwords from AWS SSM and then using them through the script. I am really concerned that some funky password character is going to be used that is going to get interpreted/escaped/munged by bash. The code in question is below. Are there any obvious problems here? Can I improve this so that no password can trip this up?
updateEnvFile() {
local user=$1
local pass=$2
local host=$3
cat "${bin}/../environments/development.properties" |
sed "s;url=jdbc:mysql://localhost/mysql;url=jdbc:mysql://$host/mysql;" |
sed "s/username=root/username=$user/" | sed "s/password=my-secret-pw/password=$pass/"
}
updateConfig() {
local dbs=$1
for db in ${dbs}; do
local user=${params["/databases/migrate/${env}/${db}.user"]}
local pass=${params["/databases/migrate/${env}/${db}.password"]}
local host=${params["/databases/migrate/${env}/${db}.host"]}
updateEnvFile "${user}" "${pass}" "${host}" > "${bin}/../environments/${db}.properties"
done
}