Updated pre-commit regex for new token format (#60031)

updated regex
This commit is contained in:
James McNamara 2024-02-05 04:57:56 -08:00 committed by GitHub
parent acabf5e57f
commit 660c755c7e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -20,9 +20,16 @@ files=$(git diff --name-only --staged --diff-filter ACMR)
function check() {
local file="$1"
if ! grep -qE "(?:(?:\/\/)|(?:#)|(?:--)) ?pre-commit:ignore_sourcegraph_token$" "$file" && grep -qE "s(?:g[psd]|lk)_[0-9a-fA-F]{40,}" "$file" ; then
echo "Found a Sourcegraph token in git staged file: $file. Please remove it."
exit 1
if ! grep -qE "(?:(?:\/\/)|(?:#)|(?:--)) ?pre-commit:ignore_sourcegraph_token$" "$file"; then
if grep -qE "s(?:g[psd]|lk)_[0-9a-fA-F]{40,}" "$file"; then
echo "Found a Sourcegraph token in git staged file: $file. Please remove it."
exit 1
fi
if grep -qE "sgph_[a-f0-9]{16}_[a-f0-9]{40}" "$file"; then
echo "Found a Sourcegraph token in git staged file: $file. Please remove it."
exit 1
fi
fi
if grep -qE "gh[pousr]_[0-9a-zA-Z]{36}" "$file"; then
echo "Found a GitHub token in git staged file: $file. Please remove it."