feat: remediate reviewer cache permissions - #70
Conversation
derekmisler
left a comment
There was a problem hiding this comment.
🤖 Automated PR Review — this comment was posted by the pr-reviewer bot, not by a human or the implementer agent
Assessment: 🟢 APPROVE
The implementation is solid. The indentation-based YAML scanner, regex patterns, four-bucket file classification (changedFiles / manualFiles / compliantFiles / skippedFiles), and CRLF/quote handling are all correct and well-tested.
Hypotheses investigated and dismissed:
-
Partial-fix commit when a file is in both
changedFilesandmanualFiles— the bash workflow explicitly checksMANUAL_FILESbefore the commit step and runscleanup_workdir; continueto abort the entire repo if any manual files exist. No partial commit can occur. -
USES_REregex with quoteduses:+ inline comment inside quotes — the malformed pattern (uses: "…@sha # comment") is rejected by the GitHub Actions runner as an invalid workflow reference (spaces disallowed in the ref). No real-world impact. -
jobKeyOfwith colon-containing quoted YAML job keys — GitHub Actions restricts job IDs to[a-zA-Z_][a-zA-Z0-9_-]*; colons are forbidden, making this unreachable in practice.
Other observations from the workflow YAML:
- The
2>&1 >/dev/nullredirect order in theFORK_ERRcapture is intentional and correct (stderr →$()pipe, stdout →/dev/null). - Fork-parent validation before committing (
FORK_PARENT != REPOguard) correctly prevents writing to an unrelated same-named repo. - The
ADD_ARGSloop is safe: bash command substitution strips trailing newlines from$CHANGED_FILES, so no spurious empty--add ""argument is passed tosigned-commit.js. printf -v PR_BODYuses only hardcoded strings and the runner-controlled$RUN_URL; no injection surface.
Summary
Adds remediation automation for consumer workflows that grant only
actions: readto the job calling the PR reviewer reusable workflow. Those callers fail validation because the nested review job requiresactions: writefor cache and review-lock operations.Changes
fix-reviewer-cache-permissionsworkflow with dry-run enabled by default and an optional repository allowlistactions: readtoactions: writeExpected behavior
actions: readactions: writeand prepare a PRactions: writeNeeds manual review; do not open a partial PRValidation