-
Notifications
You must be signed in to change notification settings - Fork 10
enhancement(dsl): Integrate nsjail sandbox for Python DSL execution #400
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
SafeDep Report SummaryNo dependency changes detected. Nothing to scan. This report is generated by SafeDep Github App |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #400 +/- ##
==========================================
- Coverage 80.70% 80.47% -0.23%
==========================================
Files 77 77
Lines 7736 7763 +27
==========================================
+ Hits 6243 6247 +4
- Misses 1248 1269 +21
- Partials 245 247 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This stack of pull requests is managed by Graphite. Learn more about stacking. |
Merge activity
|
Add nsjail sandboxing support to dsl/loader.go for secure Python rule execution: - Add isSandboxEnabled() to check PATHFINDER_SANDBOX_ENABLED env var - Add buildNsjailCommand() to construct nsjail command with security flags - Modify loadRulesFromFile() to use nsjail when sandbox is enabled - Update entrypoint.sh to create /tmp/nsjail_root at runtime - Add test-nsjail-integration.sh for integration testing Security features: - Network isolation (--iface_no_lo) - Filesystem isolation (chroot to /tmp/nsjail_root) - Process isolation (PID namespace) - User isolation (run as nobody) - Resource limits: 512MB memory, 30s CPU, 1MB file size Implements PR-02 from python-sandboxing tech spec. Stacks on PR-01 (Docker runtime setup). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
47d8dd5 to
d548f58
Compare

This change integrates the nsjail sandboxing capabilities into the DSL rule loader for secure Python code execution at runtime. The implementation adds conditional sandbox execution that checks an environment variable to determine whether rules should run in isolated mode or directly. When sandboxing is enabled, the system constructs nsjail commands with comprehensive security parameters including network isolation, filesystem restrictions, process separation, and resource limits. The entrypoint script ensures the sandbox environment is properly initialized before rule execution begins. Three new helper functions provide the core functionality for environment detection, command construction, and secure execution. The integration maintains backward compatibility by allowing sandbox disablement for development workflows while defaulting to secure execution in production. This completes the sandboxing architecture by connecting the runtime environment from the previous change to the actual DSL rule execution pipeline.