Repository navigation
chore(rulesets): add audit and apply scripts for the org baseline - #444
Merged
Merged
Conversation
BryanFRD
enabled auto-merge (squash)
November 28, 2026 15:24
Contributor
There was a problem hiding this comment.
Approved. The ruleset tooling is dry-run by default, backs up every write and reads each change back to verify it. The review found no blocking issue, only minor ones.
To fix (minor)
scripts/rulesets/apply.sh:171: rollback of a created ruleset reports success when the DELETE fails.writes_enabled && gh api -X DELETE ... && log ...is followed by an unconditionalreturn 0, so a 403, 404 or network error exits 0 with no message. Every other write path logs the failure and returns 1. Fix:if writes_enabled; then gh api -X DELETE "$path" >/dev/null || { log "DELETE failed: $path"; return 1; }; log "deleted $path"; fi; return 0scripts/rulesets/derive-checks.sh:4:checks.jsonis written to the caller's cwd, butapply.shreads$HERE/checks.json. Running the script from the repo root puts the file at the root, outside the.gitignore, where it can be committed, andapply.shthen reports it missing. Fix: default the output to the script directory,out=${1:-$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/checks.json}. Do the same foraudit.sh(audit.tsvandaudit.notes).
Suggestions
scripts/rulesets/apply.sh:148: the second fetchjson=$(gh api "repos/$repo/rulesets/$id")has no error handling, unlike the identical fetch in the loop above. Store the candidate's JSON in the loop (e.g.cand_json) and reuse it.scripts/rulesets/apply.sh:143: the.created.jsonbackup is written with the default umask, whilebackup_currentsets 600 on PUT backups. Addchmod 600or route it throughbackup_current.scripts/rulesets/derive-checks.sh:9:gh pr listsorts by creation date, so the sample is the 5 most recently created merged PRs, not the 5 most recently merged. The README says "last 5 merged PRs". Reword the README, or sort bymergedAtafter fetching a larger limit.
Formal verification
Nothing to prove. The PR touches no Rust source, Cargo.toml or Cargo.lock, only bash scripts, a README and a .gitignore. The scripts call the live GitHub API through gh, so nothing was built or run.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Scripts for LABS-1048: read-only audit, per-repo required-check derivation, and an apply script (dry run by default, backup before each write, --rollback). Nothing is applied by this PR. Auto-merge intentionally left off.