fix(macos): Target app processes exactly#484
Conversation
Stop macOS apps by exact executable name instead of matching the app name against every process argument. Reject empty app names and unsafe process IDs before command execution. Fixes #306
commit: |
There was a problem hiding this comment.
Pull request overview
This PR hardens the stop_mac_app tool’s process targeting on macOS by switching from command-line substring matching to exact process-name matching, preventing accidental termination of unrelated processes (e.g., tmux, shells) whose arguments contain the app name.
Changes:
- Tightened tool input validation:
appNamemust be non-empty andprocessIdmust be a positive integer. - Changed name-based termination from
pkill -ftopkill -x(exact process name), with escaping to prevent regex interpretation. - Updated unit tests and added a changelog entry for the behavior change and validation hardening.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/mcp/tools/macos/stop_mac_app.ts | Updates schema validation and switches pkill invocation to exact-name matching with regex escaping. |
| src/mcp/tools/macos/tests/stop_mac_app.test.ts | Expands schema validation assertions and updates command-generation expectations for pkill -x. |
| CHANGELOG.md | Documents the fix under ## [Unreleased] and links it to issue #306. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Reject unsafe process IDs before constructing or invoking kill, even when callers bypass the typed-tool schema. Refs #306
|
CI status note: all repository-controlled checks pass and all review threads are resolved on the current head. The remaining external GitHub marks the external suite rerequestable, but the documented check-suite rerequest endpoint returns 404 for the maintainer token, so only the Warden app/service owner can clear these app-owned statuses. No repository code failure remains to address. |
stop_mac_appnow treats an application name as an exact executable name instead of a regular expression matched against every process argument. This prevents unrelated tmux, shell, editor, or agent processes from being terminated merely because their arguments contain the app name.The tool also rejects empty names and process IDs that are zero, negative, or fractional before executing
pkillorkill. Name-based calls still stop every process with that exact executable name; callers targeting one instance should continue usingprocessId.Fixes #306.