Open
Description
Background
Currently, the custom code compiler uses raw exec()
to execute user-provided Python code, which could potentially be unsafe as it has unrestricted access to Python builtins and the global namespace.
Proposed Solution
Implement RestrictedPython to provide a safer execution environment for custom code. This will:
- Restrict access to potentially dangerous builtins
- Run code in an isolated namespace
- Prevent access to sensitive operations
References
- Original PR discussion: feat(source-declarative-manifest): add support for custom Python components from dynamic text input #174 (comment)
Implementation Notes
- Add RestrictedPython as a dependency
- Replace current
exec()
implementation with RestrictedPython's secure execution - Add tests to verify security restrictions are working as expected
Security Considerations
This enhancement will improve the security posture of the custom code execution feature by preventing potentially malicious code from accessing sensitive operations or resources.
Metadata
Metadata
Assignees
Labels
No labels