Skip to content

Commit ffe64ae

Browse files
committed
use git check-ref-format for base-ref validation
1 parent 2fca4e8 commit ffe64ae

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎action.yml‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ runs:
4848
run: |
4949
# Plain branch name only. Revision syntax (main^, main~1, main@{1}) would
5050
# resolve here but widen the diff to commits outside the PR.
51-
if [[ ! "${BASE_REF}" =~ ^[A-Za-z0-9._/-]+$ || "${BASE_REF}" == *".."* ]]; then
51+
# check-ref-format rejects ^ ~ : ? * [ .. and @{ while allowing everything
52+
# else Git considers a legal branch name; the dash guard blocks option-lookalikes.
53+
if [[ "${BASE_REF}" == -* ]] || ! git check-ref-format "refs/heads/${BASE_REF}"; then
5254
echo "::error title=Unplug scan misconfigured::'base-ref' must be a plain branch name, not a git revision expression (received '${BASE_REF}')."
5355
exit 1
5456
fi

0 commit comments

Comments
 (0)