<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Vm on 月盾的博客</title>
    <link>https://blog.hopefly.top/tags/vm/</link>
    <description>Recent content in Vm on 月盾的博客</description>
    <generator>Hugo</generator>
    <language>zh-cn</language>
    <lastBuildDate>Wed, 25 May 2016 10:06:22 +0000</lastBuildDate>
    <atom:link href="https://blog.hopefly.top/tags/vm/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>nodejs中vm模块的作用</title>
      <link>https://blog.hopefly.top/blogdetail/5745791ed5034dff53ec6aa4/</link>
      <pubDate>Wed, 25 May 2016 10:06:22 +0000</pubDate>
      <guid>https://blog.hopefly.top/blogdetail/5745791ed5034dff53ec6aa4/</guid>
      <description>&lt;p&gt;vm提供了一个沙箱环境，什么叫沙箱环境？类似于一个独立的执行空间，什么时候会用到vm模块？就以我现在接触的需求来说，每个月都有运营活动，但是每次需求又不同，比如一些优惠规则不同，最后可能只需要得到一个结果，如果每次活动都去修改代码就会显得很麻烦，我们提供一个后台管理界面，或者直接在数据库里写入每次活动的不同计算规则，这些规则其实也是JavaScript代码，既然是代码就需要执行才行。这就形成了一种情况：在已有的程序中插入一段代码进行执行，这要怎么实现？如果觉得很容易插入的话，那么是不是黑客可以在你的程序中插入一段代码执行呢？这当然是不允许的，所以就需要提供一种安全环境来执行——就是沙箱了，而vm模块就是提供了这样一种执行环境。&#xA;&lt;a href=&#34;http://www.cnblogs.com/softlover/archive/2012/10/03/2707144.html&#34;&gt;http://www.cnblogs.com/softlover/archive/2012/10/03/2707144.html&lt;/a&gt;&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
