Skip to content

fix(audit): graceful degradation when ruleset endpoint not readable#15

Merged
WomB0ComB0 merged 1 commit intomainfrom
fix/audit-graceful-ruleset-fail
Apr 18, 2026
Merged

fix(audit): graceful degradation when ruleset endpoint not readable#15
WomB0ComB0 merged 1 commit intomainfrom
fix/audit-graceful-ruleset-fail

Conversation

@WomB0ComB0
Copy link
Copy Markdown
Member

@WomB0ComB0 WomB0ComB0 commented Apr 18, 2026

Discovered on first live audit run: /orgs/$ORG/rulesets/$RULESET_ID requires admin:org scope which GITHUB_TOKEN doesn't have. The script hit set -e on the 403 and every run failed immediately. Wrap the fetch in a conditional that logs a warning and assumes empty exclude list on failure, so the gap detection still runs against every repo. For authoritative results (reads the actual exclude list), set SYNC_TOKEN at org or repo level.

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced error handling in the audit workflow for fetching repository exclusion lists.
    • Added warning notification when the ruleset endpoint cannot be accessed, recommending proper token configuration for complete audit results.

GITHUB_TOKEN lacks admin:org scope so /orgs/$ORG/rulesets/$RULESET_ID
returns 403, triggering set -e and the whole scan step failing before
any repo gets examined.

Wrapped the ruleset fetch in a conditional: on failure, log a warning
and treat the exclude list as empty. The audit then scans every repo;
false-positive exempt status only happens if a repo IS in the exclude
list and the token can't read it, which the warning calls out.

For authoritative results, set SYNC_TOKEN (or any PAT with admin:org
read scope) as a secret on this repo. The workflow already prefers it
over GITHUB_TOKEN via: secrets.SYNC_TOKEN || secrets.GITHUB_TOKEN.
@gemini-code-assist
Copy link
Copy Markdown

Note

Gemini is unable to generate a review for this pull request due to the file types involved not being currently supported.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 18, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fbed3945-7d0c-42b6-83b4-6dbf9402b64f

📥 Commits

Reviewing files that changed from the base of the PR and between 2e2af3e and 7f89532.

📒 Files selected for processing (1)
  • .github/workflows/audit-required-job.yml

📝 Walkthrough

Walkthrough

Modified GitHub Actions workflow to add error handling when fetching ruleset repository exclusions. Wraps the gh api call with error suppression and conditional logic. If the endpoint cannot be accessed, the workflow defaults to an empty excluded repositories list and emits a warning.

Changes

Cohort / File(s) Summary
GitHub Actions Workflow
.github/workflows/audit-required-job.yml
Added error handling for ruleset endpoint calls. Wraps gh api call in conditional with 2>/dev/null to suppress errors. On failure, initializes empty excluded list and emits GitHub Actions warning about missing SYNC_TOKEN with admin:org scope for authoritative results.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

The workflow adapts when permissions fall short,
With error suppression in logical fort,
When tokens are missing, no panic, no fuss,
Just warnings and defaults—how gracious for us! 🐰✨

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/audit-graceful-ruleset-fail

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@WomB0ComB0 WomB0ComB0 merged commit bd95037 into main Apr 18, 2026
5 of 6 checks passed
@WomB0ComB0 WomB0ComB0 deleted the fix/audit-graceful-ruleset-fail branch April 18, 2026 02:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant