Repository navigation
fix(server): run interpolated gh and git commands without a shell - #15
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ghandgit rev-listcommands inserver.jsran throughexecSync, 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-transfergh apicalls,git rev-list origin/<branch>..HEAD, andgh api graphql --inputnow useexecFileSyncwith an argument list. cwd, inherited environment (includingGH_TOKEN), encoding, timeout, stdio, error handling, and trim matchrunGit.shellstays off, so Windowsgit.exeandgh.exeare launched directly.--jq.full_name,--format=%h, and-fnew_owner=<user>, which is what the shell used to pass after removing quotes.--input.githubApiForAccountdrops its unusedopts.ghBodyArgsoption. Nothing in the server passed it.methodandjqstay as separate arguments.runCommand.Type of change
Checklist
npm testlocally (required for code changes)npm startifdashboard.htmlor API behavior changedconfig.jsontokens,.env, PATs)CHANGELOG.mdunder Unreleased when the change is notableRelease
Test plan
npm teston Node.js 22.23.4, exit 0 (50 tests, 18 suites, 50 pass, 0 fail)ubuntu-latestandwindows-latestOut of scope
hub/, Dockerfile, other docs, version, and tags.git status,git fetch,git rev-list --count HEAD,gh auth status, and the otherrunCommandcall sites) stay on the shell helper.