Skip to content

configure.sh's $live Reads Are Unguarded, Same Abort Risk as $file #1260

Closed

Description

@ptr727

Summary

check_ruleset()'s reads of $live (the parsed response body from a successful gh api "repos/$repo/rulesets/$id" call) are unguarded bare assignments, the same construct that made an earlier $file read abort the whole configure.sh check run via set -e (see #1246's fix). check_settings() has the identical shape on its own $live reads.

The defect

got_types="$(jqr '[.rules[].type] | sort | join(",")' <<<"$live")"
...
bypass="$(jqr '[.bypass_actors[]? | ...] | join("; ")' <<<"$live")"

(repo-config/configure.sh, check_ruleset(), around lines 291 and 297.) live is only checked for a successful gh api call (if ! live="$(gh api ...)"; then fail ...; return; fi), never for whether its body actually parses as an object with a .rules array. If gh api exits 0 with a body jq can't index that way (a truncated response, a proxy-injected non-JSON 200), the first such read aborts the whole script with a bare, unattributed jq error instead of the clean, attributed FAIL the rest of this function was just fixed to guarantee for the analogous $file case.

The same bare-assignment-on-$live-via-jqr shape also exists in check_settings(), around lines 348/352/355/357 (got="$(jqr --arg k "$key" '.[$k]' <<<"$live")", private="$(jqr '.private' <<<"$live")", etc.), reading the settings API response the same way.

Suggested fix

Guard the first $live read in each function (check_ruleset()'s got_types, check_settings()'s private or its first per-key read) the same way the $file guards already are, so a malformed live response reports a named FAIL instead of aborting.

Context

Found via an adversarial local-review confirmation pass on #1246's PR. Lower likelihood than the $file case, since $live comes from an already-successful gh api call, but the failure mode (full script abort vs. a clean FAIL) is identical. Filed separately to keep #1246's PR scoped to the payload-file reads it was assigned.

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