Skip to content

sandbox: a gh word with an expansion in it is classified by its literal parts #1252

Backlog

Description

@Vasanthdev2004

What happens

The sandbox classifier decides whether a gh command needs the network from the words that follow gh. Those words come from wordText in internal/sandbox/analyzer.go, which keeps the literal parts of a shell word and drops any expansion in it. So a word that is partly an expansion is classified by what is left of it:

command classified as first word gh receives
gh "${X}config" get y local the value of X, then config
gh "${X}help" local the value of X, then help
gh ext"$X" list local ext, then the value of X
gh he"$X"lp local he, the value of X, then lp

gh runs an extension when the first word names one, and extension names are free text with hyphens allowed. With an extension installed as gh-myext-config, X=myext-; gh "${X}config" is classified as local and runs that extension, which can make any request it likes. On Windows the approval gate is the network boundary, so the command runs without the network decision.

This is the same on main 2c509ce9 and on #1244, which narrows the local case to a short list of names (the follow-up to #1237). #1244 does not make it worse; it is the part of that design it did not cover.

Direction

A word only counts toward the local list when it is written out in full as a literal: unquoted, single-quoted, or double-quoted with nothing but literal text inside. Any word with a parameter, command or arithmetic expansion in it makes the command network. The check needs the parsed words, not the strings wordText returns, so it belongs where ghUsesNetwork is called.

Tests: the four rows above as network, plus one case each showing that gh config get y, gh 'config' get y and gh "config" get y stay local.

Activity

  1. added
    bug
    on Dec 3, 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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions