Skip to content

fix: harden and unit test src/lib/utils/exec.ts - #46

Merged
llbbl merged 1 commit into
mainfrom
fix/27-harden-exec
Nov 9, 2026
Merged

llbbl merged 1 commit into
mainfrom
fix/27-harden-exec

Conversation

@llbbl

@llbbl llbbl commented Nov 9, 2026

Copy link
Copy Markdown
Owner

Closes #27

  • exec now runs only the commands its callers use (npm, pnpm, yarn, bun, gh, git). Anything else is refused before a process starts.
  • A spawn failure, such as a missing binary, rejects with Failed to execute command and keeps the original error as cause. A timeout is recognised by the code's own state, not by matching the error text.
  • Removes the unused execOrThrow.
  • Adds tests/lib/utils/exec.test.ts (28 tests, run only in the Docker sandbox). It covers the allowlist, spawn errors, non-zero exits, timeout and kill (checked by PID), timer cleanup, output capture, the absence of shell interpretation, and cwd/env. exec.ts goes from 0% to 100% coverage.
  • Raises the aggregate coverage floors from 83/75 to 91/82 (functions/lines); the measured aggregate is 91.28/82.91.

- exec runs only allowlisted commands (npm, pnpm, yarn, bun, gh, git) and refuses anything else before spawning.
- A spawn failure, such as a missing binary, now rejects with "Failed to execute command" and the original error as its cause. A timeout is recognised by the code's own state, not by the error text.
- Remove the unused execOrThrow.
- Add sandboxed tests for the allowlist, spawn errors, non-zero exits, timeout and kill, timer cleanup, output capture, cwd and env. exec.ts is now at 100% coverage.
- Raise the coverage floors to 91% functions and 82% lines.

Closes #27
@llbbl
llbbl merged commit 9916539 into main Nov 9, 2026
3 checks passed
@llbbl
llbbl deleted the fix/27-harden-exec branch November 9, 2026 13:22
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.

fix: harden and unit test src/lib/utils/exec.ts

1 participant