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

Cannot call closure element of map as method in sandbox

      Normal Groovy allows Closure elements of Map instances to be called using method call syntax. That is, the following is valid Groovy:

      def m = [ f: { return 'hello' } ]
      println m.f()

      However, this is rejected by the sandbox:

      groovy.lang.MissingMethodException: No signature of method: java.util.LinkedHashMap.f() is applicable for argument types: () values: []
      Possible solutions: is(java.lang.Object), find(), any(), get(java.lang.Object), get(java.lang.Object), get(java.lang.Object)
      	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:131)
      	at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:155)
      	at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:159)
      	at org.kohsuke.groovy.sandbox.impl.Checker$checkedCall.callStatic(Unknown Source)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallStatic(CallSiteArray.java:56)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:194)
      	at Script1.run(Script1.groovy:4)
      	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.run(GroovySandbox.java:141)
      	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SecureGroovyScript.evaluate(SecureGroovyScript.java:333)
      	at hudson.plugins.groovy.SystemGroovy.run(SystemGroovy.java:95)
      	at hudson.plugins.groovy.SystemGroovy.perform(SystemGroovy.java:59)
      	at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
      	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
      	at hudson.model.Build$BuildExecution.build(Build.java:205)
      	at hudson.model.Build$BuildExecution.doRun(Build.java:162)
      	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:534)
      	at hudson.model.Run.execute(Run.java:1741)
      	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
      	at hudson.model.ResourceController.execute(ResourceController.java:98)
      	at hudson.model.Executor.run(Executor.java:410)

      Note that the more explicit (m.f)() and m['f']() work just fine.

          [JENKINS-50843] Cannot call closure element of map as method in sandbox

          Rudolf-Walter Kiss-Szakacs added a comment - Pull request:  https://github.com/jenkinsci/script-security-plugin/pull/199

          Code changed in jenkins
          User: Sam Van Oort
          Path:
          src/main/java/org/jenkinsci/plugins/scriptsecurity/sandbox/groovy/SandboxInterceptor.java
          src/test/java/org/jenkinsci/plugins/scriptsecurity/sandbox/groovy/SandboxInterceptorTest.java
          http://jenkins-ci.org/commit/script-security-plugin/23fdbbb2ee30f0bec4c77d4a5268949c605c9510
          Log:
          Merge pull request #199 from rudolfwalter/JENKINS-50843

          Allow calling Closure elements of Maps as methods

          Compare: https://github.com/jenkinsci/script-security-plugin/compare/d6b52e91469a...23fdbbb2ee30

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Sam Van Oort Path: src/main/java/org/jenkinsci/plugins/scriptsecurity/sandbox/groovy/SandboxInterceptor.java src/test/java/org/jenkinsci/plugins/scriptsecurity/sandbox/groovy/SandboxInterceptorTest.java http://jenkins-ci.org/commit/script-security-plugin/23fdbbb2ee30f0bec4c77d4a5268949c605c9510 Log: Merge pull request #199 from rudolfwalter/ JENKINS-50843 Allow calling Closure elements of Maps as methods Compare: https://github.com/jenkinsci/script-security-plugin/compare/d6b52e91469a...23fdbbb2ee30

          Code changed in jenkins
          User: Oleg Nenashev
          Path:
          src/main/java/org/jenkinsci/plugins/awsdevicefarm/AWSDeviceFarmRecorder.java
          http://jenkins-ci.org/commit/aws-device-farm-plugin/12ffb279958adb6c4f1df07cf0e34e1579c86e38
          Log:
          JENKINS-50843 - Stop persisting Build Loggers within the AWSDeviceFarmRecorder publisher

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Oleg Nenashev Path: src/main/java/org/jenkinsci/plugins/awsdevicefarm/AWSDeviceFarmRecorder.java http://jenkins-ci.org/commit/aws-device-farm-plugin/12ffb279958adb6c4f1df07cf0e34e1579c86e38 Log: JENKINS-50843 - Stop persisting Build Loggers within the AWSDeviceFarmRecorder publisher

            rudolfwg Rudolf-Walter Kiss-Szakacs
            rudolfwg Rudolf-Walter Kiss-Szakacs
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: