Skip to content

fix(external-programs): remove cmd.exe from Windows launches#1587

Closed
s0up4200 wants to merge 2 commits intodevelopfrom
fix/windows-external-program-launch
Closed

fix(external-programs): remove cmd.exe from Windows launches#1587
s0up4200 wants to merge 2 commits intodevelopfrom
fix/windows-external-program-launch

Conversation

@s0up4200
Copy link
Copy Markdown
Collaborator

@s0up4200 s0up4200 commented Mar 10, 2026

This removes the Windows cmd.exe hop from external program execution and launches configured programs directly instead. That closes the command-injection path where torrent-derived metadata could be interpreted as shell syntax.

It also updates Windows-specific tests and the external programs docs to reflect the new behavior, including the hard cut that shell wrappers must now be configured explicitly.

Summary by CodeRabbit

  • New Features

    • External programs on Windows now launch directly without shell interpretation; arguments are passed literally.
  • Bug Fixes

    • Improved argument handling to prevent shell metacharacter injection across platforms.
  • Documentation

    • Updated guidance on external program execution with platform-specific behavior clarifications for Windows, Linux, and macOS.
    • Added recommendations for shell script handling and terminal window persistence.

@s0up4200 s0up4200 requested a review from Audionut March 10, 2026 09:42
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 10, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: cf20646e-705e-4387-ab9b-0bc54ad83b28

📥 Commits

Reviewing files that changed from the base of the PR and between 4b05177 and 980b111.

📒 Files selected for processing (6)
  • documentation/docs/features/external-programs.md
  • internal/services/externalprograms/command_other.go
  • internal/services/externalprograms/command_windows.go
  • internal/services/externalprograms/service.go
  • internal/services/externalprograms/service_test.go
  • internal/services/externalprograms/service_windows_test.go

Walkthrough

Changes transition external program execution on Windows from cmd.exe wrapper invocation to direct program launching with literal arguments. Includes documentation updates clarifying Windows-specific behavior, platform-specific command builders for Windows and non-Windows systems, unified service execution flow, and corresponding test updates.

Changes

Cohort / File(s) Summary
Documentation
documentation/docs/features/external-programs.md
Added warnings about shell script wrapping, guidance on avoiding cmd.exe wrappers, and updated cross-platform terminal emulator behavior documentation for Windows vs. Unix-like systems.
Platform-specific Command Builders
internal/services/externalprograms/command_windows.go, internal/services/externalprograms/command_other.go
New files introducing buildNativeCommand with platform-specific implementations: Windows version applies SysProcAttr for process creation flags (DETACHED_PROCESS or CREATE_NEW_CONSOLE); non-Windows version uses direct CommandContext construction.
Service Execution Flow
internal/services/externalprograms/service.go
Unified executeAsync path across platforms by removing separate Windows/Unix branches; replaced cmd.exe wrapping with buildNativeCommand calls for both terminal and direct execution modes; maintained post-start lifecycle and error handling.
Tests
internal/services/externalprograms/service_test.go, internal/services/externalprograms/service_windows_test.go
Updated command construction assertions to expect direct program invocation with literal arguments instead of cmd.exe wrapping; added new Windows-specific test file validating SysProcAttr creation flags for terminal vs. direct modes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

bugfix, external-programs, tests, needs-docs, area/backend

Poem

A rabbit hops free from cmd.exe's chain,
Direct paths now flourish, no wrapper refrain,
Windows and Unix, at last unified hands,
Arguments literal, as each platform demands,
Hopping with joy through these cross-platform lands! 🐰✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: removing cmd.exe from Windows external program launches, which is the primary objective of this PR.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/windows-external-program-launch

Comment @coderabbitai help to get the list of available commands and usage tips.

@s0up4200 s0up4200 closed this Mar 31, 2026
@s0up4200 s0up4200 deleted the fix/windows-external-program-launch branch March 31, 2026 08:10
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