Skip to content

Commit 2494706

Browse files
ptankovtplavcic
andauthored
CLOUD-789 - adding password leak check in demand-backup, init-deploy, monitoring-2-0 (#1282)
* adding password leak check in demand-backup, init-deploy, monitoring-2-0 * CLOUD-789 - Add password leak check into demand-backup-sharded test * Remove bash to lowercase conversion so it works on older bash --------- Co-authored-by: Tomislav Plavcic <[email protected]>
1 parent 792c279 commit 2494706

File tree

5 files changed

+54
-0
lines changed

5 files changed

+54
-0
lines changed

e2e-tests/demand-backup-sharded/run

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,5 +176,8 @@ if [ -z "$SKIP_BACKUPS_TO_AWS_GCP_AZURE" ]; then
176176
check_backup_deletion "https://engk8soperators.blob.core.windows.net/operator-testing/${backup_dest_azure}" "azure-blob"
177177
fi
178178

179+
desc 'check for passwords leak'
180+
check_passwords_leak
181+
179182
kubectl_bin delete -f "$conf_dir/container-rc.yaml"
180183
destroy "$namespace"

e2e-tests/demand-backup/run

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,9 @@ if [ -z "$SKIP_BACKUPS_TO_AWS_GCP_AZURE" ]; then
180180
check_backup_deletion "https://engk8soperators.blob.core.windows.net/operator-testing/${backup_dest_azure}" "azure-blob"
181181
fi
182182

183+
desc 'check for passwords leak'
184+
check_passwords_leak
185+
183186
destroy $namespace
184187

185188
desc 'test passed'

e2e-tests/functions

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,3 +1217,45 @@ function get_mongod_ver_from_image() {
12171217
fi
12181218
echo ${version_info}
12191219
}
1220+
1221+
check_passwords_leak() {
1222+
secrets=$(kubectl_bin get secrets -o json | jq -r '.items[].data | to_entries | .[] | select(.key | (contains("_PASSWORD"))) | .value')
1223+
echo secrets=$secrets
1224+
1225+
passwords="$(for i in $secrets; do base64 -d <<< $i; echo; done) $secrets"
1226+
echo passwords=$passwords
1227+
1228+
pods=$(kubectl_bin get pods -o name | awk -F "/" '{print $2}')
1229+
echo pods=$pods
1230+
1231+
TEMP_DIR=$(mktemp -d)
1232+
1233+
collect_logs() {
1234+
NS=$1
1235+
for p in $pods; do
1236+
containers=$(kubectl_bin -n "$NS" get pod $p -o jsonpath='{.spec.containers[*].name}')
1237+
for c in $containers; do
1238+
# temporary, because of: https://jira.percona.com/browse/PMM-8357
1239+
if [[ ${c} =~ "pmm" ]]; then
1240+
continue
1241+
fi
1242+
kubectl_bin -n "$NS" logs $p -c $c > ${TEMP_DIR}/logs_output-$p-$c.txt
1243+
echo logs saved in: ${TEMP_DIR}/logs_output-$p-$c.txt
1244+
for pass in $passwords; do
1245+
count=$(grep -c --fixed-strings -- "$pass" ${TEMP_DIR}/logs_output-$p-$c.txt || :)
1246+
if [[ $count != 0 ]]; then
1247+
echo leaked passwords are found in log ${TEMP_DIR}/logs_output-$p-$c.txt
1248+
false
1249+
fi
1250+
done
1251+
done
1252+
echo
1253+
done
1254+
}
1255+
1256+
collect_logs $namespace
1257+
if [ -n "$OPERATOR_NS" ]; then
1258+
pods=$(kubectl_bin -n "${OPERATOR_NS}" get pods -o name | awk -F "/" '{print $2}')
1259+
collect_logs $OPERATOR_NS
1260+
fi
1261+
}

e2e-tests/init-deploy/run

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ compare_mongo_cmd "find" "myApp:myPass@$cluster2-0.$cluster2.$namespace" "-3rd"
9797
compare_mongo_cmd "find" "myApp:myPass@$cluster2-1.$cluster2.$namespace" "-3rd"
9898
compare_mongo_cmd "find" "myApp:myPass@$cluster2-2.$cluster2.$namespace" "-3rd"
9999

100+
desc 'check for passwords leak'
101+
check_passwords_leak
102+
100103
desc 'delete custom RuntimeClass'
101104
kubectl_bin delete -f "$conf_dir/container-rc.yaml"
102105
destroy $namespace

e2e-tests/monitoring-2-0/run

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ if [[ -n ${OPENSHIFT} ]]; then
9191
oc adm policy remove-scc-from-user privileged -z percona-server-mongodb-operator
9292
fi
9393

94+
desc 'check for passwords leak'
95+
check_passwords_leak
96+
9497
helm uninstall monitoring
9598
destroy $namespace
9699

0 commit comments

Comments
 (0)