Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Poor error messages for testers using ClojailWrapper #16

Open
dgshep opened this issue Nov 28, 2020 · 0 comments
Open

Poor error messages for testers using ClojailWrapper #16

dgshep opened this issue Nov 28, 2020 · 0 comments

Comments

@dgshep
Copy link

dgshep commented Nov 28, 2020

When tripping a tester that uses the ClojailWrapper, the error message uses the default Object.toString and thus doesn't contain much useful context:

=> (let [sb (sandbox secure-tester)]
     (sb '(java.util.concurrent.ForkJoinPool.)))

Execution error (SecurityException) at clojail.core/security-exception (core.clj:119).
You tripped the alarm! clojail.testers.ClojailWrapper@5f0e3437 is bad!

It looks like this could be fixed by adding a toString implementation to ClojailWrapper:

--- a/src/clojail/testers.clj
+++ b/src/clojail/testers.clj
@@ -5,12 +5,15 @@
   (:require [bultitude.core :as nses]
             [serializable.fn :as sfn]))

-(deftype ClojailWrapper [object])
+(deftype ClojailWrapper [object]
+  Object
+  (toString [this]
+    (pr-str object)))

 (defmethod print-method ClojailWrapper
   [p out]
   (.write out (str "#clojail.testers.ClojailWrapper["
-                   (binding [*print-dup* true] (pr-str (.object p)))
+                   (binding [*print-dup* true] (str p))
                    "]")))

 (defn wrap-object
=> (let [sb (sandbox secure-tester)]
     (sb '(java.util.concurrent.ForkJoinPool.)))

Execution error (SecurityException) at clojail.core/security-exception (core.clj:119).
You tripped the alarm! "java.util.concurrent" is bad!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant