Skip to content

Decide Whether a Written-Out GH_REPO an Unread Builtin Sets Fails Closed With No Origin #3298

Closed

Description

@ptr727

Context

The fix for #3288 runs the write guard's unread-target check whether or not an origin resolves. That check also covers a write taking its repository from a GH_REPO that an unread builtin sets, such as declare -x, read, set -a, an eval, or GH_REPO+=. So that shape now fails closed outside a checkout too.

Example

Constructed input, run with no resolvable origin:

  • declare -x GH_REPO=stranger/example; gh pr comment 5 -b x was allowed and is now denied.
  • gh pr comment 5 --repo stranger/example -b x is still allowed.

The first writes its value out in the command, but the hook does not read declare, so the target counts as unread.

Question

Does "literal targets keep the no-origin allow" include a written-out GH_REPO value that an unread builtin sets? The fix treats it as unread and denies it, which matches the root README's own grouping of these shapes. If it should be allowed with no origin, the change is to skip only the GH_REPO branch of _gh_unread_target when no origin resolves, plus flipping one self-test case in _NO_ORIGIN_CASES.

Activity

  1. added
    decision
    script
    on Oct 21, 2026
  2. ptr727 commented on Oct 21, 2026

    @ptr727
    OwnerAuthor

    Answered by the maintainer: keep it blocked. With no resolvable origin, a GH_REPO set by a setter the guard does not read (declare -x, read, set -a, GH_REPO+=, and the like) fails closed before a gh write, as #3297 does. The guard already classes these setters as unread targets, and excluding them with no origin would add a special case for a shape that is rare outside a checkout. Nothing to change.

  3. removed
    decision
    on Oct 21, 2026
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

    script

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions