-
Notifications
You must be signed in to change notification settings - Fork 3.8k
feat: add pull request creation endpoint with GitHub CLI integration #8861
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
✅ Review Complete Code Review Summary |
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 issues found across 3 files
Prompt for AI agents (all 3 issues)
Understand the root cause of the following 3 issues and fix them.
<file name="extensions/cli/src/commands/serve.ts">
<violation number="1" location="extensions/cli/src/commands/serve.ts:329">
`/pr` accepts untrusted JSON and feeds it into createPullRequest, which constructs `gh pr create` via string concatenation and executes it with `child_process.exec`, allowing remote command injection via crafted title/body/base values.</violation>
<violation number="2" location="extensions/cli/src/commands/serve.ts:419">
Rule violated: **Don't use console.log**
The newly added POST /pr endpoint announcement uses console.log instead of the project logger, violating the "Don't use console.log" rule. Use logger.info/logger.warn for all runtime logging to keep output centralized and configurable.</violation>
</file>
<file name="extensions/cli/src/commands/pr.ts">
<violation number="1" location="extensions/cli/src/commands/pr.ts:91">
User-supplied PR metadata is interpolated into a shell command (`execAsync("gh …")`), allowing command injection and even breaking when titles/bodies contain spaces. Use spawn/execFile with an argument array instead of building a shell string.</violation>
</file>
Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR
| state.lastActivity = Date.now(); | ||
|
|
||
| try { | ||
| const options: PrOptions = req.body; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/pr accepts untrusted JSON and feeds it into createPullRequest, which constructs gh pr create via string concatenation and executes it with child_process.exec, allowing remote command injection via crafted title/body/base values.
Prompt for AI agents
Address the following comment on extensions/cli/src/commands/serve.ts at line 329:
<comment>`/pr` accepts untrusted JSON and feeds it into createPullRequest, which constructs `gh pr create` via string concatenation and executes it with `child_process.exec`, allowing remote command injection via crafted title/body/base values.</comment>
<file context>
@@ -320,6 +321,40 @@ export async function serve(prompt?: string, options: ServeOptions = {}) {
+ state.lastActivity = Date.now();
+
+ try {
+ const options: PrOptions = req.body;
+ logger.info("Creating pull request", { options });
+
</file context>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4 issues found across 3 files
Prompt for AI agents (all 4 issues)
Understand the root cause of the following 4 issues and fix them.
<file name="extensions/cli/src/commands/pr.ts">
<violation number="1" location="extensions/cli/src/commands/pr.ts:116">
User-controlled base is interpolated into a git log shell command executed via execAsync, enabling command injection. Use execFile with argument arrays or strictly validate allowed branch names before executing git.</violation>
</file>
<file name="extensions/cli/src/commands/pr.test.ts">
<violation number="1" location="extensions/cli/src/commands/pr.test.ts:17">
Mocked `child_process` never exposes `execFile`, so importing the module under test throws before any test runs.</violation>
<violation number="2" location="extensions/cli/src/commands/pr.test.ts:121">
The `execMock` implementations use an `exec`-style signature, but the code under test calls `execFile(file, args, options, callback)`, so callbacks are never invoked and the command matching logic never triggers.</violation>
</file>
<file name="extensions/cli/src/commands/serve.ts">
<violation number="1" location="extensions/cli/src/commands/serve.ts:419">
Rule violated: **Don't use console.log**
Replace this new console.log with the shared logger (e.g., logger.info) to comply with the “Don’t use console.log” rule for server output.</violation>
</file>
Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
…edev/continue into nate/add-pr-endpoint-cli
Summary by cubic
Add POST /pr endpoint to create GitHub pull requests via the GitHub CLI. Validates repo state, auto-fills title/body, and returns the PR URL.
New Features
Refactors
Written for commit d3cba54. Summary will update automatically on new commits.