Permalink
Browse files

Updated to 1.2 and improved the sandbox, making it more like clojureb…

…ot and sexpbot's sandboxes.

Closes #9, #8.
  • Loading branch information...
1 parent 811b314 commit 8eb873337ee443ebd987d9d6756eac787054ead2 @Raynes committed Nov 5, 2010
Showing with 20 additions and 22 deletions.
  1. +7 −7 project.clj
  2. +13 −15 src/tryclojure/core.clj
View
14 project.clj
@@ -1,12 +1,12 @@
(defproject tryclojure "0.1.0-SNAPSHOT"
:description "A simple web-based Clojure REPL for trying out Clojure without having to install it."
- :dependencies [[org.clojure/clojure "1.1.0"]
- [org.clojure/clojure-contrib "1.1.0"]
+ :dependencies [[org.clojure/clojure "1.2.0"]
+ [org.clojure/clojure-contrib "1.2.0"]
[net.cgrand/moustache "1.0.0-SNAPSHOT"]
- [ring "0.2.5"]
+ [ring "0.3.3"]
[commons-lang/commons-lang "2.5"]
- [clj-sandbox "0.3.8"]
- [clj-highlight "0.1.1-SNAPSHOT"]
- [hiccup "0.2.6"]]
+ [org.clojars.rayne/clj-sandbox "0.4.2-SNAPSHOT"]
+ [org.clojars.rayne/clj-highlight "1.1.1-SNAPSHOT"]
+ [hiccup "0.2.7"]]
:dev-dependencies [[swank-clojure "1.2.1"]
- [ring/ring-devel "0.2.5"]])
+ [ring/ring-devel "0.3.3"]])
View
28 src/tryclojure/core.clj
@@ -1,30 +1,28 @@
(ns tryclojure.core
(:use ring.adapter.jetty
- net.licenser.sandbox
[net.licenser.sandbox tester matcher]
[hiccup core form-helpers page-helpers]
[ring.middleware reload stacktrace params file session]
net.cgrand.moustache
[clojure.stacktrace :only [root-cause]]
tryclojure.tutorial)
+ (:require [net.licenser.sandbox :as sb])
(:import java.io.StringWriter
java.util.concurrent.TimeoutException))
-(enable-security-manager)
+(sb/enable-security-manager)
(def sandbox-tester
- (extend-tester secure-tester
- (whitelist
- (function-matcher 'println 'print 'pr 'prn 'var 'print-doc 'doc 'throw
- 'def 'def* 'dosync 'alter '. 'finally '*math-context*)
- (class-matcher java.io.StringWriter String Byte Character StrictMath StringBuffer
- java.net.URL java.net.URI java.math.MathContext))))
+ (new-tester
+ (whitelist)
+ (blacklist
+ (function-matcher 'alter-var-root 'intern 'eval 'catch
+ 'load-string 'load-reader 'clojure.core/addMethod
+ 'ns-resolve))))
(def my-obj-tester
- (extend-tester default-obj-tester
- (whitelist
- (class-matcher java.io.StringWriter String Byte Character StrictMath StringBuffer
- java.net.URL java.net.URI java.math.MathContext))))
+ (extend-tester sb/default-obj-tester
+ (whitelist)))
(def state-tester
(new-tester (whitelist (constantly '(true)))
@@ -33,11 +31,11 @@
'swap! 'compare-and-set!))))
(defn has-state? [form]
- (not (state-tester form nil)))
+ (not (state-tester form nil)))
(defn execute-text [txt history]
- (let [sc (new-sandbox-compiler :tester sandbox-tester
- :timeout 1000)
+ (let [sc (sb/new-sandbox-compiler :tester sandbox-tester
+ :timeout 1000)
result (try
(loop [history history]
(when (not (empty? history))

0 comments on commit 8eb8733

Please sign in to comment.