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

Script Approval: No such constructor found even so the constructor is defined

    Details

    • Similar Issues:

      Description

      I have a a shared DSL library which causes the pipeline to fail with the following error:

      No such constructor found: new java.lang.String java.lang.String java.lang.String. Administrators can decide whether to approve or reject this signature.
      [Pipeline] End of Pipeline
      org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: No such constructor found: new java.lang.String java.lang.String java.lang.String
      	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onNewInstance(SandboxInterceptor.java:168)
      	at org.kohsuke.groovy.sandbox.impl.Checker$14.call(Checker.java:594)
      	at org.kohsuke.groovy.sandbox.impl.Checker.preCheckedCast(Checker.java:599)
      

      The signature is definitively in the "ScriptApproval.xml" as follows:

      ...    
          <string>new java.lang.String java.lang.String java.lang.String</string>
      ...

      The respective line of code where its fails is this:

      String svnURL         = this.checkMandatoryParam("svnURL", props["projects"]["${application}"]["svnURL"])
      

      and

      def checkMandatoryParam(String name, param) {
          echo "[Info] Check if mandatory parameter '${name}' is defined"
          if (!param) {
              throw new AbortException("Expected parameter '${name}' is missing or empty. Please specify accordingly in the 'applications.json'")
          } else {
              return param
          }
      

      Detailed log of Jenkins pipeline:

      09:28:07  [Info] It is a dry run:  false
      [Pipeline] echo
      09:28:07  [Info] Check if mandatory parameter 'solution' is defined
      [Pipeline] echo
      09:28:07  [Info] Check if mandatory parameter 'svnURL' is defined
      [Pipeline] }
      [Pipeline] // script
      [Pipeline] }
      [Pipeline] // stage
      [Pipeline] }
      [Pipeline] // timestamps
      [Pipeline] }
      [Pipeline] // withEnv
      [Pipeline] }
      [Pipeline] // node
      No such constructor found: new java.lang.String java.lang.String java.lang.String. Administrators can decide whether to approve or reject this signature.
      [Pipeline] End of Pipeline
      org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: No such constructor found: new java.lang.String java.lang.String java.lang.String
      	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onNewInstance(SandboxInterceptor.java:168)
      	at org.kohsuke.groovy.sandbox.impl.Checker$14.call(Checker.java:594)
      	at org.kohsuke.groovy.sandbox.impl.Checker.preCheckedCast(Checker.java:599)
      	at org.kohsuke.groovy.sandbox.impl.Checker.checkedCast(Checker.java:541)
      	at org.kohsuke.groovy.sandbox.impl.Checker$checkedCast$1.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 org.kohsuke.groovy.sandbox.impl.Checker$2.call(Checker.java:189)
      	at org.kohsuke.groovy.sandbox.GroovyInterceptor.onStaticCall(GroovyInterceptor.java:35)
      	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onStaticCall(SandboxInterceptor.java:186)
      	at org.kohsuke.groovy.sandbox.impl.Checker$2.call(Checker.java:187)
      	at org.kohsuke.groovy.sandbox.impl.Checker.checkedStaticCall(Checker.java:191)
      	at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:98)
      	at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:17)
      	at defaultCdPipeline.call(D:\data\jenkins_home\jobs\DP-Pipeline-Common-CD\builds\10\libs\octopus-pipeline-core\vars\defaultCdPipeline.groovy:93)
      	at ___cps.transform___(Native Method)
      	at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:57)
      	at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:109)
      	at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:82)
      	at sun.reflect.GeneratedMethodAccessor528.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
      	at com.cloudbees.groovy.cps.impl.ConstantBlock.eval(ConstantBlock.java:21)
      	at com.cloudbees.groovy.cps.Next.step(Next.java:83)
      	at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:174)
      	at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:163)
      	at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:129)
      	at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:268)
      	at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:163)
      	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$101(SandboxContinuable.java:34)
      	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.lambda$run0$0(SandboxContinuable.java:59)
      	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:241)
      	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:58)
      	at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:182)
      	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:332)
      	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$200(CpsThreadGroup.java:83)
      	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:244)
      	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:232)
      	at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:64)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:131)
      	at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
      	at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:59)
      	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      	at java.lang.Thread.run(Thread.java:748)
      Finished: FAILURE
      
      

        Attachments

          Activity

          Hide
          danielbeck Daniel Beck added a comment -

          Which version of Script Security Plugin is this?

          Devin Nusbaum Does this look like a regression due to recent security fixes?

          Show
          danielbeck Daniel Beck added a comment - Which version of Script Security Plugin is this? Devin Nusbaum Does this look like a regression due to recent security fixes?
          Hide
          dnusbaum Devin Nusbaum added a comment -

          Daniel Beck I don't think so, Checker line 599 in Checker.preCheckedCast is a comment in the current version of groovy-sandbox.

          Adrian Wyssmann I think that your scriptApproval entry is invalid syntax. It should start with method or staticMethod, and also I don't think there is a constructor of String that takes (String, String). Did you add the entry manually or anything?

          Are you sure the code is failing in String svnURL = this.checkMandatoryParam("svnURL", props["projects"]["${application}"]["svnURL"])? We see the log message from checkMandatoryParam ("Check if mandatory parameter 'svnURL' is defined"), so maybe it is one of the next few lines that has the problem. I don't see anything particular in what you posted that looks like Groovy syntax that the sandbox isn't able to handle.

          Show
          dnusbaum Devin Nusbaum added a comment - Daniel Beck I don't think so, Checker line 599 in Checker.preCheckedCast is a comment in the current version of groovy-sandbox. Adrian Wyssmann I think that your scriptApproval entry is invalid syntax. It should start with method or staticMethod , and also I don't think there is a constructor of String that takes (String, String) . Did you add the entry manually or anything? Are you sure the code is failing in String svnURL = this.checkMandatoryParam("svnURL", props ["projects"] ["${application}"] ["svnURL"] ) ? We see the log message from checkMandatoryParam ("Check if mandatory parameter 'svnURL' is defined"), so maybe it is one of the next few lines that has the problem. I don't see anything particular in what you posted that looks like Groovy syntax that the sandbox isn't able to handle.
          Hide
          papanito Adrian Wyssmann added a comment -

          OK I've found the problem. I read a configuration from json For some reason the json had "duplicated" content

          {
             "projects": {
                "app1": {
                   "svnUrl": "https://xyz"
                }, 
                "app2": {
                   "svnUrl": "https://xyz"
                }
             }
             { "projects": {
                 "app1": {
                    "svnUrl": "https://xyz"
                 },
                 "app2": {
                    "svnUrl": "https://xyz" 
                 }
             }
          }
          

          instead of

          {
             "projects": {
                "app1": {
                   "svnUrl": "https://xyz"
                }, 
                "app2": {
                   "svnUrl": "https://xyz"
                }
             }
          }
          

          Onc// code placeholdere the input json was fixed, all went smooth.

          Yes the signature I have in the "ScriptApproval.xml" is as mentioned above

          Show
          papanito Adrian Wyssmann added a comment - OK I've found the problem. I read a configuration from json For some reason the json had "duplicated" content { "projects" : { "app1" : { "svnUrl" : "https: //xyz" }, "app2" : { "svnUrl" : "https: //xyz" } } { "projects" : { "app1" : { "svnUrl" : "https: //xyz" }, "app2" : { "svnUrl" : "https: //xyz" } } } instead of { "projects" : { "app1" : { "svnUrl" : "https: //xyz" }, "app2" : { "svnUrl" : "https: //xyz" } } } Onc// code placeholdere the input json was fixed, all went smooth. Yes the signature I have in the "ScriptApproval.xml" is as mentioned above

            People

            • Assignee:
              Unassigned
              Reporter:
              papanito Adrian Wyssmann
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: