Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions scripts/public-repo-guard/body-policy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,22 @@ check() {
# Filter with rg, not grep: BSD/macOS grep has no -P, so a `grep -P` allowlist
# silently errors out locally while working on GNU/CI — the gate would then
# disagree with itself depending on where it ran. rg is already required above.
local matches
local matches filter_rc
matches="$(printf '%s' "$raw" \
| rg -vN -- 'guard:allow[[:space:]]+[^[:space:]]' || true)"
| rg -vN -- 'guard:allow[[:space:]]+[^[:space:]]')"
filter_rc=$?
if (( filter_rc >= 2 )); then
echo "::error title=public-repo-guard ($name)::ripgrep failed (exit $filter_rc) filtering allowlisted lines for rule '$name' — failing closed."
exit 2
fi
if [[ "$exempt" == "about-exempt" ]]; then
matches="$(printf '%s' "$matches" \
| rg -vNiP -- "$ABOUT_THE_CONTROL" || true)"
| rg -vNiP -- "$ABOUT_THE_CONTROL")"
filter_rc=$?
if (( filter_rc >= 2 )); then
echo "::error title=public-repo-guard ($name)::ripgrep failed (exit $filter_rc) filtering control references for rule '$name' — failing closed."
exit 2
fi
fi
[[ -z "$matches" ]] && return 0
local count; count="$(printf '%s\n' "$matches" | grep -c '')"
Expand Down
Loading