---
title: "groovy shell 安全"
author: "dikar"
date: "2017-01-18T11:29:36Z"
tags: []
categories: ["编程语言"]
slug: "groovy-shell"
draft: false
lastmod: "2017-01-18T11:29:36Z"
id: 2353698
url: "https://dikar.iteye.com/blog/2353698"
---

groovy 可以动态执行代码，但是我们也想他在一定的沙箱中，目前有2种方式

 

1：利用java的 permissions

 

https://www.chrismoos.com/2010/03/24/groovy-scripts-and-jvm-security/

 

http://www.sdidit.nl/2012/12/groovy-dsl-executing-scripts-in-sandbox.html

 

2：在编译时动手脚，限制某些类

http://melix.github.io/blog/2015/03/sandboxing.html

 

https://github.com/groovy/groovy-core/blob/master/src/examples/groovyShell/BlacklistingShell.groovy