Skip to content

Commit 4580a55

Browse files
committed
feat(box.tool): mask sensitive token in subscription URL logs
1 parent 1c43da1 commit 4580a55

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

box/scripts/box.tool

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ upfile() {
5757
if [ -f "${file_bak}" ]; then
5858
mv "${file_bak}" "${file}" || true
5959
fi
60-
log Error "Download ${request} ${orange}failed${normal}"
60+
request_url=$(echo "${request}" | sed -E 's/(token=[^&]{6})[^&]*/\1*****/')
61+
log Error "Download ${request_url} failed"
6162
return 1
6263
}
6364
return 0
@@ -415,7 +416,9 @@ upsubs() {
415416
update_file_name="${update_file_name}.subscription"
416417
fi
417418

418-
log Debug "Downloading ${sub_url}${update_file_name}"
419+
# token_url="${sub_url:0:25}*****"
420+
token_url=$(echo "$sub_url" | sed -E 's/(token=[^&]{6})[^&]*/\1*****/')
421+
log Debug "Downloading ${token_url}${update_file_name}"
419422
if upfile "${update_file_name}" "${sub_url}"; then
420423
log Info "${update_file_name} saved"
421424

@@ -464,7 +467,7 @@ upsubs() {
464467
exit 1
465468
fi
466469
else
467-
log Error "update $bin_name subscription failed → ${sub_url}"
470+
log Error "update $bin_name subscription failed → ${token_url}"
468471
return 1
469472
fi
470473
done

0 commit comments

Comments
 (0)