We are using GitLab version 8.5.0. I am writing a custom server side update hook to lock specific branches. It works great, however, I would like to allow GitLab merge requests to be processed. All GitLab merge requests will usually have "See Merge request" comment in the commit description. Hence, I thought to allow only those commits, which contains commit message "See Merge request". However, it doesnt work the way I thought.
Any other possible ways to allow only gitlab merge requests?
#!/usr/bin/env bash
GIT_COMMIT_MSG=`git log -1 HEAD --pretty=format:%s`
if [[ "$1" == refs/heads/master ]]; then
if [[ "$GIT_COMMIT_MSG" =~ *"See Merge request"* ]]; then
echo "This is GitLab Merge Request"
else
echo $GIT_COMMIT_MSG
echo "ERROR: you are not allowed to update master" >&2
exit 1
fi
fi
See Merge request
to get through, then what would stop a malicious user from inserting this text to spoof your scripts? – Tim Biegeleisen