pradeepagrawal8184 commented on code in PR #872:
URL: https://github.com/apache/ranger/pull/872#discussion_r3129636693
##########
plugin-nestedstructure/src/main/java/org/apache/ranger/authorization/nestedstructure/authorizer/RecordFilterJavaScript.java:
##########
@@ -54,8 +57,25 @@ public static boolean filterRow(String user, String
filterExpr, String jsonStrin
throw new MaskingException("cannot process filter expression due
to security concern \"this.engine\": " + filterExpr);
}
- NashornScriptEngineFactory factory = new NashornScriptEngineFactory();
- ScriptEngine engine =
factory.getScriptEngine(securityFilter);
+ ClassLoader clsLoader = Thread.currentThread().getContextClassLoader();
+ ScriptEngineManager mgr = new ScriptEngineManager(clsLoader);
+ ScriptEngine engine = mgr.getEngineByName("graal.js");
+
+ if (engine != null) {
+ try {
+ Map<String, Boolean> graalVmConfigs = new HashMap<>();
+
+ graalVmConfigs.put("polyglot.js.allowHostAccess",
Boolean.TRUE); // default is true for backward(Nashorn) compatibility
+ graalVmConfigs.put("polyglot.js.nashorn-compat",
Boolean.TRUE); // default is true for backward(Nashorn) compatibility
+
+ // enable configured script features
+ Bindings bindings =
engine.getBindings(ScriptContext.ENGINE_SCOPE);
+ bindings.putAll(graalVmConfigs);
+ engine.setBindings(bindings, ScriptContext.ENGINE_SCOPE);
Review Comment:
Done, please review
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]