Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-43480

security sandbox disallows groovy implicit class constructors

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Minor Minor
    • script-security-plugin
    • None
    • jenkins 2.19.4
      script-security 1.27

      The sandbox appears to be unhappy with groovy classes unless they have an explicit constructor. Eg.

      class Foo {
          String bar
      }
      
      def f = new Foo(bar: 'baz')
      echo f.bar
      

      Blows up with:

      org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: unclassified new Foo java.util.LinkedHashMap
      	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onNewInstance(SandboxInterceptor.java:126)
      ...
      

      While it is happy with:

      class Foo {
          String bar
          
          Foo(String b) {
              this.bar = b
          }
      }
      
      def f = new Foo('baz')
      echo f.bar

            abayer Andrew Bayer
            jhoblitt Joshua Hoblitt
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: