@@ -110,10 +110,10 @@ spec:
110110 # Control params
111111 - name : debug
112112 description : |
113- Warning setting this param to true expose credentials
114-
115- The parameter is intended to add verbosity on the task execution and also print credentials on stdout
116- to easily access to remote machice
113+ Warning setting this param to true exposes partially masked credentials
114+
115+ The parameter is intended to add verbosity on the task execution and also print masked credentials
116+ (showing first and last character with *** in the middle) on stdout to help with debugging
117117 default : ' false'
118118
119119 results :
@@ -142,12 +142,20 @@ spec:
142142 script : |
143143 #!/bin/sh
144144
145- # If debug add verbosity
146- if [[ $(params.debug) == "true" ]]; then
147- set -xuo
148- fi
149-
150- # Credentials
145+ set -euo pipefail
146+
147+ # Function to mask credentials (show first and last char, hide middle)
148+ mask_credential() {
149+ local cred="$1"
150+ local len=${#cred}
151+ if [ $len -le 2 ]; then
152+ echo "***"
153+ else
154+ echo "${cred:0:1}***${cred: -1}"
155+ fi
156+ }
157+
158+ # Credentials - set these BEFORE enabling debug mode
151159 export ARM_TENANT_ID=$(cat /opt/az-credentials/tenant_id)
152160 export ARM_SUBSCRIPTION_ID=$(cat /opt/az-credentials/subscription_id)
153161 export ARM_CLIENT_ID=$(cat /opt/az-credentials/client_id)
@@ -156,6 +164,18 @@ spec:
156164 export AZURE_STORAGE_KEY=$(cat /opt/az-credentials/storage_key)
157165 BLOB=$(cat /opt/az-credentials/blob)
158166
167+ # If debug add verbosity and print masked credentials
168+ if [[ $(params.debug) == "true" ]]; then
169+ echo "ARM_TENANT_ID=$(mask_credential "$ARM_TENANT_ID")"
170+ echo "ARM_SUBSCRIPTION_ID=$(mask_credential "$ARM_SUBSCRIPTION_ID")"
171+ echo "ARM_CLIENT_ID=$(mask_credential "$ARM_CLIENT_ID")"
172+ echo "ARM_CLIENT_SECRET=$(mask_credential "$ARM_CLIENT_SECRET")"
173+ echo "AZURE_STORAGE_ACCOUNT=$(mask_credential "$AZURE_STORAGE_ACCOUNT")"
174+ echo "AZURE_STORAGE_KEY=$(mask_credential "$AZURE_STORAGE_KEY")"
175+ echo "BLOB=$BLOB"
176+ set -xeuo pipefail
177+ fi
178+
159179 if [[ $(params.operation) == "create" ]]; then
160180 if [[ $(params.ownerName) == "" || $(params.ownerUid) == "" ]]; then
161181 echo "Parameter ownerName and ownerUid is required for create instance"
0 commit comments