TyOverby / ares

A Lisp made for easy integration with Rust.
9 stars 1 forks source link

Add a "sandbox" functionality #33

Open TyOverby opened 9 years ago

TyOverby commented 9 years ago

I'd like to be able to "eval" and run untrusted code without them being able to mess with my state. I'd hate to have some script modify global state without my knowledge.

In lisp-land, I'm thinking something like this:

Just ban writes

(define x 10)
(sandbox 'no-write
    (define y x) # this is fine
    (set x 5))   # this fails (can't write to x)

Ban reads and writes

(define x 10)
(sandbox 'no-read-write
    (define y x) # this fails (can't even _find_ x)
    (set x 5)) 

This should be a pretty trivial to add by adding a field to Environment that has some variants

enum SandboxMode {
    None,
    NoWrite,
    NoReadWrite
}