Add external module import policy enforcement via OPA#78
Merged
Conversation
MCP-V8 Load Test Benchmark ReportComparison of single-node vs 3-node cluster at various request rates. Results
P95 Latency
Notes
|
…auditing External module imports (npm:, jsr:, URL) are now blocked by default. Two new CLI flags control this behavior: - --allow-external-modules: enables external imports - --opa-module-policy: when set with --opa-url, audits each module import against an OPA policy before fetching Includes OPA policy (policies/modules.rego) with allowlists for npm packages, JSR packages, and URL hosts. Adds unit tests, engine integration tests, and e2e tests that spin up a real OPA server to verify policy enforcement. https://claude.ai/code/session_015zV3QdtyMgbizp4ZrSzqjq
…tests Remove server/tests/module_policy_e2e.rs and replace it with a Docker Compose-based integration test that spins up real containers (OPA + mcp-js) and makes actual HTTP requests, matching the pattern of the existing docker-compose-integration.sh tests. New files: - docker-compose.module-policy.yml: two mcp-js services (default + OPA policy) - tests/module-policy-integration.sh: 8 tests covering blocked imports, OPA allow/deny, and plain JS execution - .github/workflows/module-policy-integration.yml: CI workflow https://claude.ai/code/session_01ReRwVdpytBRvCLn8pWHNEV
Remove push-to-main, daily schedule, and workflow_dispatch triggers. https://claude.ai/code/session_01ReRwVdpytBRvCLn8pWHNEV
a0bc330 to
7693fd8
Compare
- Add missing module_loader_config parameter to fuzz_execute_stateless - Update docker-compose-integration.sh for async execution model (submit + poll) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
test_stdio_run_js_execution was checking raw run_js response for "2" but the async API returns an execution_id UUID. Use run_js_and_wait to poll for the actual result. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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 implements a comprehensive module import policy system that allows operators to control which external packages (npm, JSR, and URL imports) are permitted in JavaScript code execution. By default, external module imports are blocked for security. When enabled with
--allow-external-modules, imports can be optionally audited against an OPA policy before being fetched.Key Changes
Module Loader Configuration: Added
ModuleLoaderConfigstruct to control external module access with three settings:allow_external: Enable/disable all external module imports (default: false)opa_client: Optional OPA client for policy auditingopa_module_policy: OPA policy path for module validationDefault-Deny Security Model: External module imports (npm:, jsr:, https://) are now rejected by default with a clear error message directing users to use
--allow-external-modulesOPA Module Auditing: When both
--allow-external-modulesand--opa-module-policyare set, each module import is audited against the OPA policy before fetching. The policy receives:CLI Arguments: Added two new command-line flags:
--allow-external-modules: Enable external module imports--opa-module-policy PATH: OPA policy path (requires both--opa-urland--allow-external-modules)OPA Policy Example: Added
policies/modules.regodemonstrating a practical policy that:Comprehensive Testing:
Implementation Details
NetworkModuleLoaderlevel, rejecting external specifiers before any network requestshttps://claude.ai/code/session_015zV3QdtyMgbizp4ZrSzqjq