Skip to content

fix(server): run interpolated gh and git commands without a shell - #15

Merged
Tam-Leal merged 5 commits into
mainfrom
feat/execfile-interpolated-commands
Nov 11, 2026
Merged

Tam-Leal merged 5 commits into
mainfrom
feat/execfile-interpolated-commands

Conversation

@Tam-Leal

Copy link
Copy Markdown
Contributor

Summary

  • Interpolated gh and git rev-list commands in server.js ran through execSync, which uses a shell. Those values were already sanitized, so the practical risk was low. This removes that shell-injection class and keeps the same results.
  • githubApiForAccount, gh repo list, gh repo view, both repository-transfer gh api calls, git rev-list origin/<branch>..HEAD, and gh api graphql --input now use execFileSync with an argument list. cwd, inherited environment (including GH_TOKEN), encoding, timeout, stdio, error handling, and trim match runGit. shell stays off, so Windows git.exe and gh.exe are launched directly.
  • Shell quotes are not part of the child argv. The child receives --jq .full_name, --format=%h, and -f new_owner=<user>, which is what the shell used to pass after removing quotes.
  • These commands have no pipes, redirects, or stdin. The GraphQL body is still written to a temp file and passed with --input.
  • githubApiForAccount drops its unused opts.ghBodyArgs option. Nothing in the server passed it. method and jq stay as separate arguments.
  • Fixed git and gh commands that do not interpolate variables stay on runCommand.

Type of change

  • Bug fix (user-visible)
  • Feature (user-visible)
  • Documentation / site only
  • Tests, CI, or refactor (no user-visible change)

Checklist

  • I ran npm test locally (required for code changes)
  • I smoke-tested with npm start if dashboard.html or API behavior changed
  • No secrets in commits (config.json tokens, .env, PATs)
  • Updated CHANGELOG.md under Unreleased when the change is notable

Release

  • No GitHub Release needed (behavior is unchanged; the interpolated values were already sanitized)
  • Release needed: describe why users should download a new build:

Test plan

  • npm test on Node.js 22.23.4, exit 0 (50 tests, 18 suites, 50 pass, 0 fail)
  • After opening the PR, confirm the Tests workflow runs on ubuntu-latest and windows-latest

Out of scope

  • Release workflow, hub/, Dockerfile, other docs, version, and tags.
  • Fixed commands (git status, git fetch, git rev-list --count HEAD, gh auth status, and the other runCommand call sites) stay on the shell helper.

Pass method, path, owner, repo, branch, and input file values to
execFileSync as separate arguments. cwd, inherited environment
(including GH_TOKEN), encoding, timeout, and the result shape stay
the same. Fixed git commands that do not interpolate stay on runCommand.

The unused ghBodyArgs suffix is split into literal words. Quotes group
one argument. There is no globbing or command expansion.
Spawn node through the exported execFile helper and assert each
interpolated gh and git rev-list argv list is delivered literally.
Keep Node.js 22 and npm ci. The ubuntu job stays in the matrix.
It had no caller in the server.
Branch protection requires a check named test. It passes only when both OS jobs pass.
@Tam-Leal
Tam-Leal merged commit 7425f29 into main Nov 11, 2026
3 checks passed
@Tam-Leal
Tam-Leal deleted the feat/execfile-interpolated-commands branch November 11, 2026 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant