From 97fe2bfdf0c6383282d34920700b6ab9b2c21869 Mon Sep 17 00:00:00 2001 From: Thomas Stokes Date: Tue, 19 Mar 2024 19:48:22 +0100 Subject: [PATCH] Improve sync-repo security --- .../repo/usr/local/bin/sync-repo-and-execute-cmd.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/configuration/environments_scripts/repo/usr/local/bin/sync-repo-and-execute-cmd.sh b/configuration/environments_scripts/repo/usr/local/bin/sync-repo-and-execute-cmd.sh index 34468f2fba4..ba09a4f63d2 100755 --- a/configuration/environments_scripts/repo/usr/local/bin/sync-repo-and-execute-cmd.sh +++ b/configuration/environments_scripts/repo/usr/local/bin/sync-repo-and-execute-cmd.sh @@ -17,7 +17,11 @@ GIT_PATH=$1 COMMAND_ON_COMPLETION=$2 GIT_BRANCH=$3 cd ${GIT_PATH} -git checkout ${GIT_BRANCH} >/dev/null +git checkout ${GIT_BRANCH} >/dev/null 2>&1 +if [[ "$?" -ne 0 ]]; then + echo "Error encountered: issue checking out branch" + exit 1 +fi # Rev-parse gets the commit hash of given reference. CURRENT_HEAD=$(git rev-parse HEAD) GIT_SSH_COMMAND="ssh -o StrictHostKeyChecking=no" git fetch