Skip to content

Conversation

@shivasurya
Copy link
Owner

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.

@shivasurya shivasurya added the enhancement New feature or request label Nov 24, 2025
@shivasurya shivasurya self-assigned this Nov 24, 2025
@shivasurya shivasurya added the enhancement New feature or request label Nov 24, 2025
@safedep
Copy link

safedep bot commented Nov 24, 2025

SafeDep Report Summary

Green Malicious Packages Badge Green Vulnerable Packages Badge Green Risky License Badge

No dependency changes detected. Nothing to scan.

This report is generated by SafeDep Github App

@codecov
Copy link

codecov bot commented Nov 24, 2025

Codecov Report

❌ Patch coverage is 17.85714% with 23 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.47%. Comparing base (6abaf97) to head (d548f58).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
sourcecode-parser/dsl/loader.go 17.85% 21 Missing and 2 partials ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Owner Author

shivasurya commented Nov 24, 2025

Copy link
Owner Author

shivasurya commented Nov 24, 2025

Merge activity

  • Nov 24, 3:14 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Nov 24, 3:15 AM UTC: Graphite rebased this pull request as part of a merge.
  • Nov 24, 3:16 AM UTC: @shivasurya merged this pull request with Graphite.

@shivasurya shivasurya changed the base branch from shiva/sandbox-pr01-docker to graphite-base/400 November 24, 2025 03:14
@shivasurya shivasurya changed the base branch from graphite-base/400 to main November 24, 2025 03:14
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 <[email protected]>
@shivasurya shivasurya force-pushed the shiva/sandbox-pr02-code branch from 47d8dd5 to d548f58 Compare November 24, 2025 03:15
@shivasurya shivasurya merged commit a283b2c into main Nov 24, 2025
3 checks passed
@shivasurya shivasurya deleted the shiva/sandbox-pr02-code branch November 24, 2025 03:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants