jenkinsci / groovy-sandbox

(Deprecated) Compile-time transformer to run Groovy code in a restrictive sandbox
MIT License
122 stars 60 forks source link

Sandbox ignoring Owners and Delegates of nested Closures. #41

Open BloodWorkXGaming opened 6 years ago

BloodWorkXGaming commented 6 years ago

If I have nested Closures and I try to access something from the outside Closure I will run into a problem as it is only checking the functions from the inner Closure.

Here is an attempted fix for it:

https://github.com/BloodWorkXGaming/GroovySandboxedLauncher/blob/82761afcc3f69b5e17bd47784b76ccca01dc0495/src/main/java/org/kohsuke/groovy/sandbox/impl/ClosureSupport.java#L28-L65

The already existing code is smart enough to check it in the correct order, while the recursion adds the other objects to the back of the list the deeper we go in the hierarchy.