Add OPA-gated subprocess execution APIs (Deno.Command and child_process.exec)#101
Open
r33drichards wants to merge 2 commits intomainfrom
Open
Add OPA-gated subprocess execution APIs (Deno.Command and child_process.exec)#101r33drichards wants to merge 2 commits intomainfrom
r33drichards wants to merge 2 commits intomainfrom
Conversation
Adds policy-gated subprocess execution to the JS runtime, exposing two
APIs behind OPA policy evaluation:
- Deno.Command: `new Deno.Command("cmd", {args}).output()` runs a
command to completion, returning {code, stdout, stderr} with
Uint8Array output (matching the Deno subprocess API).
- child_process.exec: `await child_process.exec("shell command", opts)`
runs a shell command via /bin/sh -c, returning {code, stdout, stderr}
as strings (matching the Node.js child_process.exec API).
Every invocation is checked against a PolicyChain (local Rego or remote
OPA) before execution. The policy input includes operation type, command,
args, cwd, and env. Configuration uses the same --policies-json schema
with a new "subprocess" key.
https://claude.ai/code/session_011eLgvj7BYjWQzr42j3WHK5
MCP-V8 Load Test Benchmark ReportComparison of single-node vs 3-node cluster at various request rates. Results
P95 Latency
Notes
|
Tests both Deno.Command and child_process.exec APIs with a local Rego policy that allows only echo and cat commands while denying everything else. Covers allowed/denied commands, exit codes, cwd options, stdout/stderr capture, and API availability checks. https://claude.ai/code/session_01FmHwVDVVu1pPfpedeA6WDL
r33drichards
added a commit
that referenced
this pull request
Mar 23, 2026
Resolves conflicts in server/src/engine/mod.rs, server/src/main.rs, server/src/engine/opa.rs, and flake.nix. Both mcp_headers (from main) and subprocess_config (from #101) are preserved and work together in ExecutionConfig and the RunJsRequest builder.
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
This PR adds policy-gated subprocess execution capabilities to the JavaScript runtime, supporting both Deno's
CommandAPI and Node.js-compatiblechild_process.exec(). All subprocess invocations are evaluated against an OPA policy chain before execution.Key Changes
New subprocess module (
server/src/engine/subprocess.rs):op_subprocess_output(forDeno.Command.output()) andop_subprocess_exec(forchild_process.exec())OPA policy integration:
command_output,command_spawn, andexecsubprocessfield toPoliciesConfigto configure subprocess policy chainsRuntime integration:
SubprocessConfigtoExecutionConfigfor passing policy chains to the runtimemain.rsExample policy (
policies/subprocess.rego):Comprehensive testing:
Implementation Details
Uint8Arrayin JavaScript for the Deno APIchild_process.exec()implementation supports configurable encoding (defaults to UTF-8 strings, can be set to "buffer" for binary)exec()is platform-aware (uses/bin/sh -con Unix,cmd /Con Windows)https://claude.ai/code/session_011eLgvj7BYjWQzr42j3WHK5