CodeScope treats all user-supplied and imported code as completely untrusted.
- CodeScope never executes user code with
eval(),new Function(), or within the host browser context. - Execution is driven entirely by an AST-level interpreter (
AstInterpreter.ts) that interprets nodes as discrete data structures. - Host APIs (
window,document,localStorage,sessionStorage,cookies,fetch,XMLHttpRequest,WebSocket,Worker) are not passed or exposed into the interpreted environment.
To guard against malicious, accidental, or infinite execution, CodeScope enforces deterministic limits on every run:
| Limit Guard | Default Threshold | Behavior on Breach |
|---|---|---|
| Step Limit | 3,000 steps | Halts execution with LIMIT_REACHED: Exceeded maximum execution step limit. |
| Call Stack Depth | 64 frames | Halts recursive loops with LIMIT_REACHED: Maximum call stack depth exceeded. |
| Heap Object Allocations | 1,000 objects | Halts memory exhaustion with LIMIT_REACHED: Heap object limit exceeded. |
| Loop Iterations | 1,000 passes / loop | Halts runaway loops with LIMIT_REACHED: Loop exceeded maximum iterations. |
| Wall-Clock Execution Time | 4,000 milliseconds | Halts execution if time threshold is exceeded. |
- Exported traces are strictly serialized JSON schemas (
codescope-v1). - Imported files are size-checked (< 10MB) and validated for structure.
- Imported code is never automatically executed on import. It is simply populated into the editor and viewable as a read-only historical trace until the user explicitly hits "Run".