Unified sandbox manager combining filesystem, network, and resource controls.
More...
|
|
DLLEXPORT | QoreSandboxManager () |
| | Creates a new sandbox manager with default settings.
|
| |
|
virtual DLLEXPORT | ~QoreSandboxManager () |
| | Destroys the sandbox manager.
|
| |
| DLLEXPORT bool | checkFilesystemAccess (const char *path, int mode, ExceptionSink *xsink) |
| | Checks if filesystem access is allowed.
|
| |
| DLLEXPORT bool | checkIOInterrupt (ExceptionSink *xsink, const char *operation="I/O operation") const |
| | Checks if interrupt has been requested and raises exception if so.
|
| |
| DLLEXPORT bool | checkNetworkAccess (const hashdecl sockaddr *addr, socklen_t len, int proto, ExceptionSink *xsink) |
| | Checks if network access is allowed.
|
| |
|
DLLEXPORT void | clearInterrupt () |
| | Clears the interrupt request.
|
| |
| DLLEXPORT QoreSandboxManager * | copy () const |
| | Creates a copy with the same or stricter restrictions.
|
| |
| DLLEXPORT QoreFilesystemSecurityManager & | filesystem () |
| | Gets the filesystem security manager.
|
| |
|
DLLEXPORT const QoreFilesystemSecurityManager & | filesystem () const |
| | Gets the filesystem security manager (const version)
|
| |
| DLLEXPORT QoreHashNode * | getConfiguration (ExceptionSink *xsink) const |
| | Returns the full configuration as a hash.
|
| |
|
DLLEXPORT int64 | getCPUTimeLimit () const |
| | Gets the CPU time limit.
|
| |
|
DLLEXPORT int | getMaxRecursionDepth () const |
| | Gets the max recursion depth.
|
| |
|
DLLEXPORT int | getMaxThreads () const |
| | Gets the max threads limit.
|
| |
|
DLLEXPORT size_t | getMemoryLimit () const |
| | Gets the memory limit.
|
| |
|
DLLEXPORT int64 | getWallTimeLimit () const |
| | Gets the wall time limit.
|
| |
| DLLEXPORT bool | isInterruptRequested () const |
| | Checks if interrupt has been requested.
|
| |
| DLLEXPORT QoreNetworkSecurityManager & | network () |
| | Gets the network security manager.
|
| |
|
DLLEXPORT const QoreNetworkSecurityManager & | network () const |
| | Gets the network security manager (const version)
|
| |
| DLLEXPORT void | registerCancelCallback (void *context, cancel_callback_t callback) |
| | Registers a cancel callback for interruptible operations.
|
| |
| DLLEXPORT void | requestInterrupt () |
| | Requests graceful interruption of sandboxed code.
|
| |
| DLLEXPORT void | setCPUTimeLimit (int64 ms) |
| | Sets maximum CPU time in milliseconds.
|
| |
| DLLEXPORT void | setMaxRecursionDepth (int depth) |
| | Sets maximum recursion depth.
|
| |
| DLLEXPORT void | setMaxThreads (int count) |
| | Sets maximum number of threads.
|
| |
| DLLEXPORT void | setMemoryLimit (size_t bytes) |
| | Sets maximum memory usage in bytes.
|
| |
| DLLEXPORT void | setWallTimeLimit (int64 ms) |
| | Sets maximum wall clock time in milliseconds.
|
| |
| DLLEXPORT void | unregisterCancelCallback (void *context) |
| | Unregisters a cancel callback.
|
| |
|
virtual DLLLOCAL void | deref () |
| | decrements the reference count of the object without the possibility of throwing a Qore-language exception
|
| |
| virtual DLLLOCAL void | deref (ExceptionSink *xsink) |
| | decrements the reference count of the object
|
| |
|
DLLLOCAL void | ref () const |
| | increments the reference count of the object
|
| |
|
DLLEXPORT | QoreReferenceCounter () |
| | Creates the reference counter object.
|
| |
| DLLEXPORT | QoreReferenceCounter (const QoreReferenceCounter &old) |
| | Creates a new object with a reference count of 1.
|
| |
|
DLLEXPORT | ~QoreReferenceCounter () |
| | destroys the reference counter object
|
| |
| DLLEXPORT bool | is_unique () const |
| | Returns true if the reference count is 1.
|
| |
| DLLEXPORT bool | optRef () |
| | Make a strong reference only if the object is valid.
|
| |
| DLLEXPORT int | reference_count () const |
| | Gets the reference count.
|
| |
| DLLEXPORT bool | ROdereference () const |
| | Atomically decrements the reference count.
|
| |
|
DLLEXPORT void | ROreference () const |
| | Atomically increments the reference count.
|
| |
Unified sandbox manager combining filesystem, network, and resource controls.
The QoreSandboxManager class provides a unified interface for all sandboxing features including:
- Example:
#define PO_NEW_STYLE
new Qore style: no more '$' and with assumed variable scope
Definition Restrictions.h:142
DLLEXPORT int setSandboxRoot(const char *path, ExceptionSink *xsink)
Sets a sandbox root directory (chroot-like restriction)
DLLEXPORT void blockPrivateNetworks()
Preset: Blocks all private/internal networks.
supports parsing and executing Qore-language code, reference counted, dynamically-allocated only
Definition QoreProgram.h:133
DLLEXPORT void setSandboxManager(QoreSandboxManager *sm)
sets the sandbox manager for this program
Unified sandbox manager combining filesystem, network, and resource controls.
Definition QoreSandboxManager.h:432
DLLEXPORT QoreFilesystemSecurityManager & filesystem()
Gets the filesystem security manager.
DLLEXPORT void setWallTimeLimit(int64 ms)
Sets maximum wall clock time in milliseconds.
DLLEXPORT void setMemoryLimit(size_t bytes)
Sets maximum memory usage in bytes.
DLLEXPORT QoreNetworkSecurityManager & network()
Gets the network security manager.
- Since
- Qore 2.1
| DLLEXPORT void QoreSandboxManager::requestInterrupt |
( |
| ) |
|
Requests graceful interruption of sandboxed code.
This sets an interrupt flag that is checked at various points during execution (statement boundaries, blocking operations).
Interrupted code receives a PROGRAM-INTERRUPTED exception.
When interrupt is requested, all registered cancel callbacks are invoked to cancel any ongoing blocking operations (e.g., database queries).
- Note
- This is the preferred way to stop runaway sandboxed code. It allows for clean shutdown without corrupting state.