From 46e5838b6d58acb592355342abffb164e0c9495e Mon Sep 17 00:00:00 2001 From: Mandlin Sarah Date: Sat, 10 Aug 2024 12:14:05 -0700 Subject: [PATCH] Add safety check and improved messaging for HF_TOKEN --- deploy/entrypoint.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/deploy/entrypoint.sh b/deploy/entrypoint.sh index fc93b545..68cf5e87 100644 --- a/deploy/entrypoint.sh +++ b/deploy/entrypoint.sh @@ -1,11 +1,18 @@ #!/bin/bash +function clean_token() { + local raw_token="$1" + echo "${raw_token//[^a-zA-Z0-9]/}" # Removing characters that are not alphanumeric +} + if [[ ! -z "${HF_TOKEN}" ]]; then - echo "The HF_TOKEN environment variable is set, logging to Hugging Face." - python3 -c "import huggingface_hub; huggingface_hub.login('${HF_TOKEN}')" + safe_token=$(clean_token "${HF_TOKEN}") + echo "The HF_TOKEN environment variable is set, logging to Hugging Face with sanitized token." + python3 -c "import huggingface_hub; huggingface_hub.login('${safe_token}')" else echo "The HF_TOKEN environment variable is not set or empty, not logging to Hugging Face." fi # Run the provided command exec python3 -u -m vllm.entrypoints.openai.api_server "$@" +