首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >plv8禁用eval()中的execute和prepare函数

plv8禁用eval()中的execute和prepare函数
EN

Stack Overflow用户
提问于 2015-06-08 18:03:40
回答 1查看 278关注 0票数 1

如何在评估中停用对plv8函数的访问?

代码语言:javascript
复制
create or replace function
js(src text, input json) returns json as $$
  plv8.elog(NOTICE, 'test');
  //--plv8 = null; // this would disable permanently plv8, also after another call of the function
  var evalRes = eval('var output=null; ' + src + '; output;');
  return JSON.stringify(evalRes);
$$ LANGUAGE plv8;
EN

回答 1

Stack Overflow用户

发布于 2015-06-09 14:17:51

我终于找到了解决方案:

代码语言:javascript
复制
create or replace function
public.js(src text, input json) returns json as $$
  //-- select js('var a = input.test; var output = []; for(k in a) { output.push(10+a[k]); };', '{"test": [1,2,3]}'::json)
  //-- select public.js('plv8.elog(NOTICE, "yoyo");', null) // should not be possible
  plv8.elog(NOTICE, 'test');
  var evalRes = null;
  (function() {
        var plv8 = null; //-- In order to disable execute, prepare...
        evalRes = eval('var output=null; ' + src + '; output;');
  })();
  plv8.elog(NOTICE, 'test2');
  return JSON.stringify(evalRes);
$$ LANGUAGE plv8;
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30706274

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档