Feat Containerized Sandbox Code Execution #433
Open
hassan11196 wants to merge 17 commits intomainfrom
Open
Conversation
- Added RBAC module with permission registry, role-to-permission mappings, and route protection decorators. - Introduced JWT token parsing for role extraction and audit logging for security events. - Created user profile widget in the chat application interface to display user information and roles. - Implemented permission checking utilities for use in templates and application logic. - Established centralized RBAC registry for managing roles and permissions, including validation and caching. - Added decorators for route protection based on user authentication and permissions. - Developed audit logging for permission checks and role assignments to enhance security monitoring.
…or SSO integration
fix: Update user role retrieval to handle missing session data style: Hide user profile widget in chat UI
- Introduced `create_sandbox_tool` and `create_sandbox_tool_with_files` functions for executing code in a secure sandboxed environment. - Implemented `SandboxExecutor` class to manage Docker container lifecycle for code execution. - Added configuration schema for sandbox settings, including resource limits and allowed images. - Updated `requirements-base.txt` to include the `docker` package for container management. - Modified existing agent and template manager to support sandbox configuration. - Enhanced YAML templates to conditionally mount Docker socket for sandbox execution.
…enhanced rendering
- Added CSS styles for sandbox approval modal and indicators. - Enhanced JavaScript to manage sandbox approval toggle and render approval requests. - Introduced HTML structure for sandbox approval settings in the user interface. - Developed a new approval module to handle approval requests, statuses, and callbacks. - Integrated approval mode configuration into the sandbox settings. - Updated existing functions to support approval request handling and user notifications.
Open
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.
Sandbox Code Execution Approval System
Overview
Implements a comprehensive approval mechanism for sandbox code execution, allowing administrators to configure approval requirements at deployment level and users to toggle approval mode per session.
Features
1. Deployment-Level Configuration
autoormanual) in deployment YAMLsrc/utils/sandbox/config.py2. Session-Level Approval Toggle
3. Real-Time Approval Flow
queue.Queuefor thread-safe communication4. Enhanced UI
5. API Endpoints
GET/POST /api/sandbox/approval-mode- Get/set session approval preferenceGET /api/sandbox/approval/<id>- Get approval request detailsPOST /api/sandbox/approval/<id>/approve- Approve executionPOST /api/sandbox/approval/<id>/reject- Reject executionGET /api/sandbox/approvals/pending- List pending approvalsGET /api/sandbox/config- Get deployment sandbox configurationAll endpoints protected with
require_authdecorator for SSO/RBAC integration.Implementation Details
Backend Changes
src/archi/pipelines/agents/tools/sandbox.py: Approval callback integration, mode resolution (deployment → session → auto)src/utils/sandbox/approval.py: Approval request storage, resolution tracking, pending request queriessrc/utils/sandbox/config.py: Configuration management withApprovalModeenumsrc/interfaces/chat_app/app.py:session['user']instead ofsession['uid'])Frontend Changes
src/interfaces/chat_app/static/chat.js:handleSandboxApproval()for approval/rejection withcredentials: 'include'renderApprovalRequest()enhanced with full code displayapproval_requestSSE eventssrc/interfaces/chat_app/static/chat.css:Security Considerations
require_authdecoratorcredentials: 'include'for proper session handlingTesting
Enable manual approval mode and verify:
Technical Architecture
Future Enhancements