The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Change config of js execution context for static viz (#72196)
Aleksandr Lesnenkod3ba36d66dd4
diff --git a/src/metabase/channel/render/js/color.clj b/src/metabase/channel/render/js/color.cljindex 493e32d7aa9..c256e81a69e 100644--- a/src/metabase/channel/render/js/color.clj+++ b/src/metabase/channel/render/js/color.clj@@ -19,7 +19,7 @@(fn [](let [file-url (io/resource js-file-path)](assert file-url (trs "Can''t find JS color selector at ''{0}''" js-file-path))- (doto (js.engine/context)+ (doto (js.engine/trusted-context)(js.engine/load-resource js-file-path))))5))diff --git a/src/metabase/channel/render/js/engine.clj b/src/metabase/channel/render/js/engine.cljindex cc3b09d7738..daa169ad574 100644--- a/src/metabase/channel/render/js/engine.clj+++ b/src/metabase/channel/render/js/engine.clj@@ -24,18 +24,40 @@:fifo/threshold threshold))(defn context- "Create a new org.graalvm.polyglot.Context suitable to evaluate javascript"+ "Create a sandboxed org.graalvm.polyglot.Context for evaluating untrusted javascript+ (e.g. custom viz plugins). No host access, no class lookup, no filesystem I/O.+ All data must be passed as JSON strings and parsed in JS."^Context [](.. (Context/newBuilder (into-array String ["js"]));; https://github.com/oracle/graaljs/blob/master/docs/user/RunOnJDK.md(option "engine.WarnInterpreterOnly" "false")(option "js.intl-402" "true")- (allowHostAccess HostAccess/ALL)+ (allowHostAccess HostAccess/NONE)(allowHostClassLookup (reify java.util.function.Predicate- (test [_ _] true)))+ (test [_ _] false)))(out System/out)(err System/err)- (allowIO true)+ (allowIO false)+ (build)))++(defn trusted-context+ "Create an org.graalvm.polyglot.Context for trusted first-party javascript only.+ Allows reading Clojure collections from JS (list/array access) but still blocks+ Java class lookup, method invocation, and filesystem I/O."+ ^Context []+ (.. (Context/newBuilder (into-array String ["js"]))+ (option "engine.WarnInterpreterOnly" "false")+ (option "js.intl-402" "true")+ (allowHostAccess (.. (HostAccess/newBuilder)+ (allowListAccess true)+ (allowArrayAccess true)+ (allowIterableAccess true)+ (build)))+ (allowHostClassLookup (reify java.util.function.Predicate+ (test [_ _] false)))+ (out System/out)+ (err System/err)+ (allowIO false)(build)))(defn load-js-string