Azure Key Vault: mudanças entre as edições
Ir para navegação
Ir para pesquisar
(Criou página com '<syntaxhighlight lang=bash> #!/bin/bash function KEYVAULT_SECRET_FIND() { cat $1 | jq -r '.[]|.name' | grep -i $2 | while read KEY; do cat $1 | jq -r '.[]|select(.name=="'$KE...') |
Sem resumo de edição |
||
Linha 1: | Linha 1: | ||
<syntaxhighlight lang=bash> | <syntaxhighlight lang=bash> | ||
#!/bin/bash | #!/bin/bash | ||
# _ | |||
# / \ _____ _ _ __ ___ | |||
# / _ \ |_ / | | | '__/ _ \ | |||
# / ___ \ / /| |_| | | | __/ | |||
#/_/ \_\/___|\__,_|_| \___| | |||
# | |||
function KEYVAULT_SECRET_SET() { if [ $# -eq 0 ] ; then echo HELP; echo $0 "SUB_ID VAULT_NAME SECRET_NAME VALUE \"TAG1=VALUE;TAG2=VALUE\"" ; else az keyvault secret set --subscription $1 --vault-name $2 --name $3 --value "$4" --tags $(echo $5 | tr ';' ' ') ;fi ; } | |||
function KEYVAULT_SECRET_FIND() { cat $1 | jq -r '.[]|.name' | grep -i $2 | while read KEY; do cat $1 | jq -r '.[]|select(.name=="'$KEY'")' ;done ; } | function KEYVAULT_SECRET_FIND() { cat $1 | jq -r '.[]|.name' | grep -i $2 | while read KEY; do cat $1 | jq -r '.[]|select(.name=="'$KEY'")' ;done ; } | ||
function KEYVAULT_SECRET_LIST() { if [ $# -eq 0 ] ; then echo HELP; echo $0 "SUB_ID VAULT_NAME " ; else az keyvault secret list --subscription $1 --vault-name $2 | jq -r '.[]|[{"name": .name, "updated": .attributes.updated, "tags": .tags}]';fi ; } | |||
function KEYVAULT_SECRET_SHOW() { if [ $# -eq 0 ] ; then echo HELP; echo $0 "SUB_ID VAULT_NAME " ; else az keyvault secret list --subscription $1 --vault-name $2 | jq -r ".[]|.id" | while read ID; do az keyvault secret show --id $ID | jq -r '[{"name": .name, "secret": .value, "tags": .tags}] ';done ;fi ; } | |||
function KEYVAULT_SECRET_FROM_LIST() { cat $1 | export RETORNO=$(jq -r '.[]|select(.name=="'$2'")'); echo $RETORNO |jq ; echo $RETORNO | jq -r '.tags'| grep : | sed -e "s/ *//g" -e "s/\"//g" -e "s/:/=/g" -e "s/,/\;/g" | tr '\n' ' '| sed -e "s/ //g" -e "s/$/\n/g"; } | |||
function HELP() { echo """ | function HELP() { echo """ | ||
EXAMPLE: | EXAMPLE: |
Edição atual tal como às 14h38min de 31 de agosto de 2022
#!/bin/bash
# _
# / \ _____ _ _ __ ___
# / _ \ |_ / | | | '__/ _ \
# / ___ \ / /| |_| | | | __/
#/_/ \_\/___|\__,_|_| \___|
#
function KEYVAULT_SECRET_SET() { if [ $# -eq 0 ] ; then echo HELP; echo $0 "SUB_ID VAULT_NAME SECRET_NAME VALUE \"TAG1=VALUE;TAG2=VALUE\"" ; else az keyvault secret set --subscription $1 --vault-name $2 --name $3 --value "$4" --tags $(echo $5 | tr ';' ' ') ;fi ; }
function KEYVAULT_SECRET_FIND() { cat $1 | jq -r '.[]|.name' | grep -i $2 | while read KEY; do cat $1 | jq -r '.[]|select(.name=="'$KEY'")' ;done ; }
function KEYVAULT_SECRET_LIST() { if [ $# -eq 0 ] ; then echo HELP; echo $0 "SUB_ID VAULT_NAME " ; else az keyvault secret list --subscription $1 --vault-name $2 | jq -r '.[]|[{"name": .name, "updated": .attributes.updated, "tags": .tags}]';fi ; }
function KEYVAULT_SECRET_SHOW() { if [ $# -eq 0 ] ; then echo HELP; echo $0 "SUB_ID VAULT_NAME " ; else az keyvault secret list --subscription $1 --vault-name $2 | jq -r ".[]|.id" | while read ID; do az keyvault secret show --id $ID | jq -r '[{"name": .name, "secret": .value, "tags": .tags}] ';done ;fi ; }
function KEYVAULT_SECRET_FROM_LIST() { cat $1 | export RETORNO=$(jq -r '.[]|select(.name=="'$2'")'); echo $RETORNO |jq ; echo $RETORNO | jq -r '.tags'| grep : | sed -e "s/ *//g" -e "s/\"//g" -e "s/:/=/g" -e "s/,/\;/g" | tr '\n' ' '| sed -e "s/ //g" -e "s/$/\n/g"; }
function HELP() { echo """
EXAMPLE:
$0 <SUBSCRIPTION> <VAULT> <SECRET FILE> <SECRET NAME>
"""; exit 1; }
if [ $# -ne 4 ]
then
HELP
else
export SUB=$1
export VAULT=$2
export DATA=$3
export SECRET=$4
echo KEYVAULT_SECRET_SET \
$SUB \
$VAULT \
$SECRET \
\"$(KEYVAULT_SECRET_FIND $DATA $SECRET | jq -r '.secret')\" \
\"$(KEYVAULT_SECRET_FIND $DATA $SECRET | jq -r '.tags|@text' | sed -e 's/{//g' -e 's/}//g' -e 's/\"//g' -e 's/,/;/g' -e 's/:/=/g')\"
fi