Skip to content

configure.sh's check_ruleset() rname Read Aborts Ungracefully on Malformed JSON #1258

Description

@ptr727

Summary

check_ruleset()'s rname extraction (repo-config/configure.sh, around line 254) reads the ruleset payload's .name with jqr '.name // empty' "$file" and no failure guard: rname="$(jqr '.name // empty' "$file")". If the payload file is not valid JSON, jqr (jq -r | sed) returns non-zero, and since this assignment is not part of any if/while condition, set -Eeuo pipefail aborts the entire check run rather than reporting a graceful per-ruleset failure the way the function's later reads do (compare the guarded if ! want_types="$(jqr ... "$file")"; then fail "..."; return; fi a few lines down).

Because rname is the first payload read in check_ruleset(), it is also the actual first point of failure for a malformed ruleset payload: guarding a later extraction (.enforcement, done in #1246) does not by itself make the function fail gracefully on malformed JSON, since the abort already happens here first.

Suggested fix

Guard the rname extraction the same way want_types already is:

if ! rname="$(jqr '.name // empty' "$file")"; then
    fail "ruleset payload $file did not parse"
    return
fi

Context

Found while fixing #1246, verifying a review finding about a different, adjacent unguarded read (.enforcement) in the same function. Filed separately since rname's extraction predates #1246's diff and guarding it is a different, non-CRLF concern (general parse-failure handling, not the Windows CRLF exposure #1246 fixes).

Confirmed empirically: a malformed payload file passed to check_ruleset() aborts the whole script at this line (jq: parse error..., non-zero exit) rather than reporting fail "ruleset payload ... did not parse", even with #1246's .enforcement guard in place, because this read runs first.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions