Skip to content

configure.sh's ruleset_id() Still Reads a Plain jq -r, Blocking check_ruleset() on Windows #1253

Closed

Description

@ptr727

Summary

Next in the #1123/#1234/#1246 chain. repo-config/configure.sh's ruleset_id() still reads a ruleset id with a plain jq -r rather than the jqr() helper #1229 introduced, and it sits directly upstream of check_ruleset(), the function #1246 just fixed.

The defect

ids="$(jq -r --arg n "$1" '.[] | select(.name==$n) | .id' <<<"$out")"

(repo-config/configure.sh, ruleset_id(), around line 125.) ruleset_id() is called from check_ruleset() (id="$(ruleset_id "$rname")") and from apply_ruleset(). On a native Windows jq, the returned id carries a trailing \r. The [ -z "$id" ] guard passes (the string is non-empty), and the CR-suffixed id is then interpolated straight into the API URL: gh api "repos/$repo/rulesets/$id". That request targets rulesets/<id>\r, which fails outright, so check_ruleset() reports "could not read live state" (or apply_ruleset() aborts) before the comparisons #1246 just fixed are ever reached.

This is the same CRLF-exposure class #1123/#1234/#1246 already fixed at three other sites in the same file, on the one remaining call in check_ruleset()'s own dependency chain.

Secondary, cosmetic-only

Same function, the bypass-list extraction also uses plain jq -r:

bypass="$(jq -r '[.bypass_actors[]? | "\(.actor_type) \(.actor_id) \(.bypass_mode)"] | join("; ")' <<<"$live")"

This value only feeds a note() display line (never compared or asserted), so a trailing \r here would corrupt a printed diagnostic, not a check's pass/fail result. Worth fixing for consistency while the other sites are being swept, but not itself a false pass/fail.

Suggested fix

Route both extractions through jqr(), matching the treatment check_settings() and the rest of check_ruleset() (after #1246) already get.

Context

Found via an adversarial local-review pass while fixing #1246. Filed separately to keep that PR scoped to its assigned function.

Unverified on a real Windows host, same as #1123/#1234/#1246.

Metadata

Metadata

Assignees

No one assigned

    Labels

    script

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions