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

CLOUD-789 - adding password leak check in demand-backup, init-deploy, monitoring-2-0 #1282

Merged
merged 3 commits into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions e2e-tests/demand-backup-sharded/run
Original file line number Diff line number Diff line change
Expand Up @@ -176,5 +176,8 @@ if [ -z "$SKIP_BACKUPS_TO_AWS_GCP_AZURE" ]; then
check_backup_deletion "https://engk8soperators.blob.core.windows.net/operator-testing/${backup_dest_azure}" "azure-blob"
fi

desc 'check for passwords leak'
check_passwords_leak

kubectl_bin delete -f "$conf_dir/container-rc.yaml"
destroy "$namespace"
3 changes: 3 additions & 0 deletions e2e-tests/demand-backup/run
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ if [ -z "$SKIP_BACKUPS_TO_AWS_GCP_AZURE" ]; then
check_backup_deletion "https://engk8soperators.blob.core.windows.net/operator-testing/${backup_dest_azure}" "azure-blob"
fi

desc 'check for passwords leak'
check_passwords_leak

destroy $namespace

desc 'test passed'
42 changes: 42 additions & 0 deletions e2e-tests/functions
Original file line number Diff line number Diff line change
Expand Up @@ -1217,3 +1217,45 @@ function get_mongod_ver_from_image() {
fi
echo ${version_info}
}

check_passwords_leak() {
secrets=$(kubectl_bin get secrets -o json | jq -r '.items[].data | to_entries | .[] | select(.key | (contains("_PASSWORD"))) | .value')
echo secrets=$secrets

passwords="$(for i in $secrets; do base64 -d <<< $i; echo; done) $secrets"
ptankov marked this conversation as resolved.
Show resolved Hide resolved
echo passwords=$passwords

pods=$(kubectl_bin get pods -o name | awk -F "/" '{print $2}')
echo pods=$pods

TEMP_DIR=$(mktemp -d)

collect_logs() {
NS=$1
for p in $pods; do
containers=$(kubectl_bin -n "$NS" get pod $p -o jsonpath='{.spec.containers[*].name}')
for c in $containers; do
# temporary, because of: https://jira.percona.com/browse/PMM-8357
if [[ ${c} =~ "pmm" ]]; then
continue
fi
kubectl_bin -n "$NS" logs $p -c $c > ${TEMP_DIR}/logs_output-$p-$c.txt
ptankov marked this conversation as resolved.
Show resolved Hide resolved
echo logs saved in: ${TEMP_DIR}/logs_output-$p-$c.txt
for pass in $passwords; do
count=$(grep -c --fixed-strings -- "$pass" ${TEMP_DIR}/logs_output-$p-$c.txt || :)
if [[ $count != 0 ]]; then
echo leaked passwords are found in log ${TEMP_DIR}/logs_output-$p-$c.txt
false
fi
done
done
echo
done
}

collect_logs $namespace
if [ -n "$OPERATOR_NS" ]; then
pods=$(kubectl_bin -n "${OPERATOR_NS}" get pods -o name | awk -F "/" '{print $2}')
collect_logs $OPERATOR_NS
fi
}
3 changes: 3 additions & 0 deletions e2e-tests/init-deploy/run
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ compare_mongo_cmd "find" "myApp:myPass@$cluster2-0.$cluster2.$namespace" "-3rd"
compare_mongo_cmd "find" "myApp:myPass@$cluster2-1.$cluster2.$namespace" "-3rd"
compare_mongo_cmd "find" "myApp:myPass@$cluster2-2.$cluster2.$namespace" "-3rd"

desc 'check for passwords leak'
check_passwords_leak

desc 'delete custom RuntimeClass'
kubectl_bin delete -f "$conf_dir/container-rc.yaml"
destroy $namespace
Expand Down
3 changes: 3 additions & 0 deletions e2e-tests/monitoring-2-0/run
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ if [[ -n ${OPENSHIFT} ]]; then
oc adm policy remove-scc-from-user privileged -z percona-server-mongodb-operator
fi

desc 'check for passwords leak'
check_passwords_leak

helm uninstall monitoring
destroy $namespace

Expand Down
Loading