-
Notifications
You must be signed in to change notification settings - Fork 0
Fix: [for cherry-picking] Removed the allowlist filter pipeline's fail- #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,10 +49,15 @@ 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:]]' \ | ||
| | 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) while applying allowlists — failing closed." | ||
| exit 2 | ||
| fi | ||
|
Comment on lines
+55
to
+60
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔍 Sibling scanner content-policy.sh still swallows allowlist-filter errors The same fail-open pattern the PR fixes here still exists in the companion script: Was this helpful? React with 👍 or 👎 to provide feedback.
Comment on lines
53
to
+60
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟨 Leak gate can silently pass when the first allowlist filter errors The new fail-closed check inspects only the pipeline's aggregate status ( Was this helpful? React with 👍 or 👎 to provide feedback. |
||
| [[ -z "$matches" ]] && return 0 | ||
| local count; count="$(printf '%s\n' "$matches" | grep -c '')" | ||
| # Print the LINE NUMBER only — never the matched text. This annotation is itself | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Scanner failure in the first allowlist step can still go unnoticed and let text pass unchecked
The new failure check reads only the combined result of the two-step allowlist filter (
filter_rc=$?atscripts/public-repo-guard/body-policy.sh:56) instead of each step's own result, so a crash in the first step is hidden by the second step's normal "nothing left" result and the text is declared clean.Impact: If part of the text scanner breaks, the gate can silently report success instead of blocking, allowing leaked internal text to be published.
How bash pipefail masks the earlier command's exit code
With
set -o pipefail, the pipeline status is the exit status of the rightmost command that exited non-zero, not the maximum. In the pipeline atscripts/public-repo-guard/body-policy.sh:53-55, if the firstrg -vN(guard:allow filter) fails with exit 2, it emits no output; the secondrg -vNiPthen reads empty input and exits 1 (no lines selected). The pipeline status is therefore 1,filter_rcis 1, the>= 2guard at line 57 does not trigger,matchesis empty, andcheckreturns 0 as clean — exactly the fail-open the change intends to prevent. Only a failure in the last stage is currently caught. Using${PIPESTATUS[@]}(captured immediately after the assignment) and failing if any element is >= 2 closes the gap.Was this helpful? React with 👍 or 👎 to provide feedback.