diff --git a/bb/graal_tests.clj b/bb/graal_tests.clj index b8c00d6f..3397ebea 100755 --- a/bb/graal_tests.clj +++ b/bb/graal_tests.clj @@ -28,7 +28,9 @@ (let [graalvm-home (System/getenv "GRAALVM_HOME") bin-dir (str (fs/file graalvm-home "bin"))] (shell (executable bin-dir "gu") "install" "native-image") - (shell (executable bin-dir "native-image") "-jar" "target/graal-tests.jar" "--no-fallback" "graal_tests"))) + (shell (executable bin-dir "native-image") + "--features=clj_easy.graal_build_time.InitClojureClasses" + "--no-fallback" "-jar" "target/graal-tests.jar" "graal_tests"))) (defn run-tests [] (let [{:keys [out]} (shell {:out :string} (executable "." "graal_tests"))] diff --git a/src/taoensso/nippy.clj b/src/taoensso/nippy.clj index decf6197..626671fc 100644 --- a/src/taoensso/nippy.clj +++ b/src/taoensso/nippy.clj @@ -25,7 +25,7 @@ PersistentQueue PersistentTreeMap PersistentTreeSet PersistentList LazySeq IRecord ISeq IType])) -(enc/assert-min-encore-version [3 58 0]) +(enc/assert-min-encore-version [3 67 0]) (comment (set! *unchecked-math* :warn-on-boxed) @@ -471,8 +471,8 @@ (or (when-let [s (or - (do (enc/get-sys-val (get-in ids [action :base :prop]) (get-in ids [action :base :env]))) - (when incl-legacy? (enc/get-sys-val (get-in ids [:legacy :base :prop]) (get-in ids [:legacy :base :env]))))] + (do (enc/get-sys-val* (get-in ids [action :base :prop]) (get-in ids [action :base :env]))) + (when incl-legacy? (enc/get-sys-val* (get-in ids [:legacy :base :prop]) (get-in ids [:legacy :base :env]))))] (if (allow-and-record? s) s (split-class-names>set s))) default) @@ -480,8 +480,8 @@ allowlist-add (when-let [s (or - (do (enc/get-sys-val (get-in ids [action :add :prop]) (get-in ids [action :add :env]))) - (when incl-legacy? (enc/get-sys-val (get-in ids [:legacy :add :prop]) (get-in ids [:legacy :add :env]))))] + (do (enc/get-sys-val* (get-in ids [action :add :prop]) (get-in ids [action :add :env]))) + (when incl-legacy? (enc/get-sys-val* (get-in ids [:legacy :add :prop]) (get-in ids [:legacy :add :env]))))] (if (allow-and-record? s) s (split-class-names>set s)))] @@ -547,8 +547,8 @@ Upgrading from an older version of Nippy and unsure whether you've been using Nippy's Serializable support, or which classes to allow? See [2]. - See also `taoensso.encore/compile-str-filter` for a util to help easily - build more advanced predicate functions. + See also `taoensso.encore/name-filter` for a util to help easily build + more advanced predicate functions. Thanks to Timo Mihaljov (@solita-timo-mihaljov) for an excellent report identifying this vulnerability. @@ -649,7 +649,7 @@ (fn [x] (if (allow-and-record? x) allow-and-record-any-serializable-class-unsafe - (enc/compile-str-filter x)))) + (enc/name-filter x)))) conform?* (fn [x cn] ((compile x) cn)) ; Uncached because input domain possibly infinite conform? diff --git a/src/taoensso/nippy/utils.clj b/src/taoensso/nippy/utils.clj index fb5e84ec..3b262afa 100644 --- a/src/taoensso/nippy/utils.clj +++ b/src/taoensso/nippy/utils.clj @@ -9,17 +9,17 @@ ;; Unfortunately the only ~reliable way we can tell if something's ;; really serializable/readable is to actually try a full roundtrip. -(let [swap-cache! enc/-swap-val!] - (defn- memoize-type-test [test-fn] - (let [cache (atom {})] ; { } - (fn [x] - (let [t (type x) - ;; This is a bit hackish, but no other obvious solutions (?): - cacheable? (not (re-find #"__\d+" (str t))) ; gensym form - test (fn [] (try (test-fn x) (catch Exception _ false)))] - (if cacheable? - @(swap-cache! cache t #(if % % (delay (test)))) - (test))))))) +(defn- memoize-type-test [test-fn] + (let [cache_ (enc/latom {})] ; { } + (fn [x] + (let [t (type x) + gensym? (re-find #"__\d+" (str t)) + cacheable? (not gensym?) ; Hack, but no obviously better solutions + test (fn [] (try (test-fn x) (catch Exception _ false)))] + + (if cacheable? + @(cache_ t #(if % % (delay (test)))) + (do (test))))))) (def readable? (memoize-type-test (fn [x] (-> x enc/pr-edn enc/read-edn) true))) (def serializable? @@ -53,7 +53,7 @@ (serializable? "Hello world") ; Cacheable (readable? (fn [])) ; Uncacheable (serializable? (fn [])) ; Uncacheable - )) ; [5.65 5.88 1129.46 1.4] + )) ; [2.52 2.53 521.34 0.63] ;;;;