Skip to content

Commit c415f3e

Browse files
committed
Fix a hole where lazy seqs were getting realized outside the sandbox.
1 parent f4d9d68 commit c415f3e

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/clojail/core.clj

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
(defn eagerly-consume
1010
"Recursively force all lazy-seqs in val."
1111
[val]
12-
(try
13-
(postwalk-replace {} val)
14-
(catch Throwable _))
12+
(postwalk-replace {} val)
1513
val)
1614

1715
(def ^{:doc "Create a map of pretty keywords to ugly TimeUnits"}
@@ -161,7 +159,7 @@
161159
(read-string ~tester-str)))
162160
~(make-dot tester-sym)
163161
~(ensafen code))]
164-
(with-bindings bindings (transform (jvm-sandbox #(eval code) context)))))))
162+
(with-bindings bindings (jvm-sandbox #(transform (eval code)) context))))))
165163

166164
(defn set-security-manager
167165
"Sets the system security manager to whatever you pass. Passing nil is

test/clojail/core_test.clj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,8 @@
168168
x))
169169
'(dotimes [n 1000000]
170170
(Math/ceil n)))))
171+
172+
(deftest laziness-test
173+
(let [sb (sandbox secure-tester)]
174+
(is (thrown-with-msg? Exception #"access denied"
175+
(sb '(map slurp ["project.clj"]))))))

0 commit comments

Comments
 (0)