Skip to content

Commit 5c9e046

Browse files
committed
converting variables in a function to local and changing TEMP_DIR to tmp_dir
1 parent bb8f7a2 commit 5c9e046

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

e2e-tests/functions

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,6 +1278,10 @@ function generate_vs_json() {
12781278
}
12791279

12801280
check_passwords_leak() {
1281+
local secrets
1282+
local passwords
1283+
local pods
1284+
12811285
secrets=$(kubectl_bin get secrets -o json | jq -r '.items[].data | to_entries | .[] | select(.key | (contains("_PASSWORD"))) | .value')
12821286
echo secrets=$secrets
12831287

@@ -1290,8 +1294,6 @@ check_passwords_leak() {
12901294
pods=$(kubectl_bin get pods -o name | awk -F "/" '{print $2}')
12911295
echo pods=$pods
12921296

1293-
TEMP_DIR=$(mktemp -d)
1294-
12951297
collect_logs() {
12961298
NS=$1
12971299
for p in $pods; do
@@ -1301,12 +1303,12 @@ check_passwords_leak() {
13011303
if [[ ${c} =~ "pmm" ]]; then
13021304
continue
13031305
fi
1304-
kubectl_bin -n "$NS" logs $p -c $c >${TEMP_DIR}/logs_output-$p-$c.txt
1305-
echo logs saved in: ${TEMP_DIR}/logs_output-$p-$c.txt
1306+
kubectl_bin -n "$NS" logs $p -c $c >${tmp_dir}/logs_output-$p-$c.txt
1307+
echo logs saved in: ${tmp_dir}/logs_output-$p-$c.txt
13061308
for pass in $passwords; do
1307-
count=$(grep -c --fixed-strings -- "$pass" ${TEMP_DIR}/logs_output-$p-$c.txt || :)
1309+
count=$(grep -c --fixed-strings -- "$pass" ${tmp_dir}/logs_output-$p-$c.txt || :)
13081310
if [[ $count != 0 ]]; then
1309-
echo leaked passwords are found in log ${TEMP_DIR}/logs_output-$p-$c.txt
1311+
echo leaked passwords are found in log ${tmp_dir}/logs_output-$p-$c.txt
13101312
false
13111313
fi
13121314
done

0 commit comments

Comments
 (0)