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

Classpath exception in Email Extension Plugin preSend script.

    • Icon: Bug Bug
    • Resolution: Not A Defect
    • Icon: Major Major
    • None
    • Jenkins 2.89.1
      Email Extension Plugin 2.61
      Script Security Plugin 1.38
      Groovy Plugin 2.0

      I had defined a working email extension in one of my templates that fired off emails in certain cases.  This extension defined the following groovy pre-send script:

      def getReplacementIndicatorFile(subproject) {
           if (subproject == null) {
                build.getWorkspace().child('build').child('replaceInfo.txt')
           } else {
                build.getWorkspace().child(subproject).child('build').child('replaceInfo.txt')

                }
      }
      if (this.hasProperty("RAWSUB")) {
          def replaceInfoFile = getReplacementIndicatorFile("${RAWSUB}")  
          logger.println("replaceInfoFile=${replaceInfoFile}")
          if (replaceInfoFile.exists()) {
              msg.text = replaceInfoFile.readToString()
          } else {
              cancel = true

              }
      } else {
         cancel = true
      }

       

      This script now fails with the following error:

       

      Pre-send script tried to access secured objects: classpath entry file:/ is a class directory, which are not allowed.
      ERROR: Could not send email as a part of the post-build publishers.
      org.jenkinsci.plugins.scriptsecurity.scripts.UnapprovedClasspathException: classpath entry file:/ is a class directory, which are not allowed.
              at org.jenkinsci.plugins.scriptsecurity.scripts.ScriptApproval.using(ScriptApproval.java:570)
              at hudson.plugins.emailext.ExtendedEmailPublisher.expandClasspath(ExtendedEmailPublisher.java:678)
              at hudson.plugins.emailext.ExtendedEmailPublisher.executeScript(ExtendedEmailPublisher.java:620)
              at hudson.plugins.emailext.ExtendedEmailPublisher.executePresendScript(ExtendedEmailPublisher.java:573)
              at hudson.plugins.emailext.ExtendedEmailPublisher.sendMail(ExtendedEmailPublisher.java:456)
              at hudson.plugins.emailext.ExtendedEmailPublisher._perform(ExtendedEmailPublisher.java:441)
              at hudson.plugins.emailext.ExtendedEmailPublisher.perform(ExtendedEmailPublisher.java:349)
              at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
              at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744)
              at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:690)
              at hudson.model.Build$BuildExecution.cleanUp(Build.java:196)
              at hudson.model.Run.execute(Run.java:1771)
              at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
              at hudson.model.ResourceController.execute(ResourceController.java:97)
              at hudson.model.Executor.run(Executor.java:421)
      Finished: SUCCESS

       

      Since my script says nothing about the classpath, I wonder what I would need to do to set up a classpath for my script that does not produce this error.  Why is file:/ the default classpath?

      Also, nothing is available in the script approval page that I can approve to get around this.

      This issue was not present prior to the upgrade to the above versions.

       

          [JENKINS-48522] Classpath exception in Email Extension Plugin preSend script.

          Steve Cohen created issue -
          Steve Cohen made changes -
          Description Original: I had defined a working email extension in one of my templates that fired off emails in certain cases.  This extension defined the following groovy pre-send script:

          {{def getReplacementIndicatorFile(subproject) \{}}
          {{     if (subproject == null) \{}}
          {{          build.getWorkspace().child('build').child('replaceInfo.txt')}}
          {{     } else \{}}
          {{          build.getWorkspace().child(subproject).child('build').child('replaceInfo.txt')}}
          {{     }}}
          {{}}}
          {{if (this.hasProperty("RAWSUB")) \{}}
          {{    def replaceInfoFile = getReplacementIndicatorFile("$\{RAWSUB}")  }}
          {{    logger.println("replaceInfoFile=$\{replaceInfoFile}")}}
          {{    if (replaceInfoFile.exists()) \{}}
          {{        msg.text = replaceInfoFile.readToString()}}
          {{    } else \{}}
          {{        cancel = true}}
          {{    }}}
          {{} else \{}}
          {{   cancel = true}}
          {{}}}

           

          This script now fails with the following error:

           

          {{Pre-send script tried to access secured objects: classpath entry file:/ is a class directory, which are not allowed.}}
          {{ERROR: Could not send email as a part of the post-build publishers.}}
          {{org.jenkinsci.plugins.scriptsecurity.scripts.UnapprovedClasspathException: classpath entry file:/ is a class directory, which are not allowed.}}
          {{        at org.jenkinsci.plugins.scriptsecurity.scripts.ScriptApproval.using(ScriptApproval.java:570)}}
          {{        at hudson.plugins.emailext.ExtendedEmailPublisher.expandClasspath(ExtendedEmailPublisher.java:678)}}
          {{        at hudson.plugins.emailext.ExtendedEmailPublisher.executeScript(ExtendedEmailPublisher.java:620)}}
          {{        at hudson.plugins.emailext.ExtendedEmailPublisher.executePresendScript(ExtendedEmailPublisher.java:573)}}
          {{        at hudson.plugins.emailext.ExtendedEmailPublisher.sendMail(ExtendedEmailPublisher.java:456)}}
          {{        at hudson.plugins.emailext.ExtendedEmailPublisher._perform(ExtendedEmailPublisher.java:441)}}
          {{        at hudson.plugins.emailext.ExtendedEmailPublisher.perform(ExtendedEmailPublisher.java:349)}}
          {{        at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)}}
          {{        at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744)}}
          {{        at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:690)}}
          {{        at hudson.model.Build$BuildExecution.cleanUp(Build.java:196)}}
          {{        at hudson.model.Run.execute(Run.java:1771)}}
          {{        at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)}}
          {{        at hudson.model.ResourceController.execute(ResourceController.java:97)}}
          {{        at hudson.model.Executor.run(Executor.java:421)}}
          {{Finished: SUCCESS}}

           

          Since my script says nothing about the classpath, I wonder what I would need to do to set up a classpath for my script that does not produce this error.  Why is file:/ the default classpath?

          Also, nothing is available in the script approval page that I can approve to get around this.

          This issue was not present prior to the upgrade to the above versions.

           
          New: I had defined a working email extension in one of my templates that fired off emails in certain cases.  This extension defined the following groovy pre-send script:

          {{def getReplacementIndicatorFile(subproject) \{}}
           {{     if (subproject == null) \{}}
           {{          build.getWorkspace().child('build').child('replaceInfo.txt')}}
           {{     } else \{}}
           {{          build.getWorkspace().child(subproject).child('build').child('replaceInfo.txt')}}
          {{}}}
           {{if (this.hasProperty("RAWSUB")) \{}}
           {{    def replaceInfoFile = getReplacementIndicatorFile("$\{RAWSUB}")  }}
           {{    logger.println("replaceInfoFile=$\{replaceInfoFile}")}}
           {{    if (replaceInfoFile.exists()) \{}}
           {{        msg.text = replaceInfoFile.readToString()}}
           {{    } else \{}}
           {{        cancel = true}}
          {{} else \{}}
           {{   cancel = true}}
           {{}}}

           

          This script now fails with the following error:

           

          {{Pre-send script tried to access secured objects: classpath entry [file:/|file:///] is a class directory, which are not allowed.}}
           {{ERROR: Could not send email as a part of the post-build publishers.}}
           {{org.jenkinsci.plugins.scriptsecurity.scripts.UnapprovedClasspathException: classpath entry [file:/|file:///] is a class directory, which are not allowed.}}
           {{        at org.jenkinsci.plugins.scriptsecurity.scripts.ScriptApproval.using(ScriptApproval.java:570)}}
           {{        at hudson.plugins.emailext.ExtendedEmailPublisher.expandClasspath(ExtendedEmailPublisher.java:678)}}
           {{        at hudson.plugins.emailext.ExtendedEmailPublisher.executeScript(ExtendedEmailPublisher.java:620)}}
           {{        at hudson.plugins.emailext.ExtendedEmailPublisher.executePresendScript(ExtendedEmailPublisher.java:573)}}
           {{        at hudson.plugins.emailext.ExtendedEmailPublisher.sendMail(ExtendedEmailPublisher.java:456)}}
           {{        at hudson.plugins.emailext.ExtendedEmailPublisher._perform(ExtendedEmailPublisher.java:441)}}
           {{        at hudson.plugins.emailext.ExtendedEmailPublisher.perform(ExtendedEmailPublisher.java:349)}}
           {{        at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)}}
           {{        at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744)}}
           {{        at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:690)}}
           {{        at hudson.model.Build$BuildExecution.cleanUp(Build.java:196)}}
           {{        at hudson.model.Run.execute(Run.java:1771)}}
           {{        at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)}}
           {{        at hudson.model.ResourceController.execute(ResourceController.java:97)}}
           {{        at hudson.model.Executor.run(Executor.java:421)}}
           {{Finished: SUCCESS}}

           

          Since my script says nothing about the classpath, I wonder what I would need to do to set up a classpath for my script that does not produce this error.  Why is [file:/|file:///] the default classpath?

          Also, nothing is available in the script approval page that I can approve to get around this.

          This issue was not present prior to the upgrade to the above versions.

           
          Steve Cohen made changes -
          Description Original: I had defined a working email extension in one of my templates that fired off emails in certain cases.  This extension defined the following groovy pre-send script:

          {{def getReplacementIndicatorFile(subproject) \{}}
           {{     if (subproject == null) \{}}
           {{          build.getWorkspace().child('build').child('replaceInfo.txt')}}
           {{     } else \{}}
           {{          build.getWorkspace().child(subproject).child('build').child('replaceInfo.txt')}}
          {{}}}
           {{if (this.hasProperty("RAWSUB")) \{}}
           {{    def replaceInfoFile = getReplacementIndicatorFile("$\{RAWSUB}")  }}
           {{    logger.println("replaceInfoFile=$\{replaceInfoFile}")}}
           {{    if (replaceInfoFile.exists()) \{}}
           {{        msg.text = replaceInfoFile.readToString()}}
           {{    } else \{}}
           {{        cancel = true}}
          {{} else \{}}
           {{   cancel = true}}
           {{}}}

           

          This script now fails with the following error:

           

          {{Pre-send script tried to access secured objects: classpath entry [file:/|file:///] is a class directory, which are not allowed.}}
           {{ERROR: Could not send email as a part of the post-build publishers.}}
           {{org.jenkinsci.plugins.scriptsecurity.scripts.UnapprovedClasspathException: classpath entry [file:/|file:///] is a class directory, which are not allowed.}}
           {{        at org.jenkinsci.plugins.scriptsecurity.scripts.ScriptApproval.using(ScriptApproval.java:570)}}
           {{        at hudson.plugins.emailext.ExtendedEmailPublisher.expandClasspath(ExtendedEmailPublisher.java:678)}}
           {{        at hudson.plugins.emailext.ExtendedEmailPublisher.executeScript(ExtendedEmailPublisher.java:620)}}
           {{        at hudson.plugins.emailext.ExtendedEmailPublisher.executePresendScript(ExtendedEmailPublisher.java:573)}}
           {{        at hudson.plugins.emailext.ExtendedEmailPublisher.sendMail(ExtendedEmailPublisher.java:456)}}
           {{        at hudson.plugins.emailext.ExtendedEmailPublisher._perform(ExtendedEmailPublisher.java:441)}}
           {{        at hudson.plugins.emailext.ExtendedEmailPublisher.perform(ExtendedEmailPublisher.java:349)}}
           {{        at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)}}
           {{        at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744)}}
           {{        at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:690)}}
           {{        at hudson.model.Build$BuildExecution.cleanUp(Build.java:196)}}
           {{        at hudson.model.Run.execute(Run.java:1771)}}
           {{        at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)}}
           {{        at hudson.model.ResourceController.execute(ResourceController.java:97)}}
           {{        at hudson.model.Executor.run(Executor.java:421)}}
           {{Finished: SUCCESS}}

           

          Since my script says nothing about the classpath, I wonder what I would need to do to set up a classpath for my script that does not produce this error.  Why is [file:/|file:///] the default classpath?

          Also, nothing is available in the script approval page that I can approve to get around this.

          This issue was not present prior to the upgrade to the above versions.

           
          New: I had defined a working email extension in one of my templates that fired off emails in certain cases.  This extension defined the following groovy pre-send script:

          {{def getReplacementIndicatorFile(subproject) \{}}
           {{     if (subproject == null) \{}}
           {{          build.getWorkspace().child('build').child('replaceInfo.txt')}}
           {{     } else \{}}
           {{          build.getWorkspace().child(subproject).child('build').child('replaceInfo.txt')}}
           {{}}}
           {{if (this.hasProperty("RAWSUB")) \{}}
           {{    def replaceInfoFile = getReplacementIndicatorFile("$\{RAWSUB}")  }}
           {{    logger.println("replaceInfoFile=$\{replaceInfoFile}")}}
           {{    if (replaceInfoFile.exists()) \{}}
           {{        msg.text = replaceInfoFile.readToString()}}
           {{    } else \{}}
           {{        cancel = true}}

                  }
           {{} else \{}}
           {{   cancel = true}}
           {{}}}

           

          This script now fails with the following error:

           

          {{Pre-send script tried to access secured objects: classpath entry [file:/|file:///] is a class directory, which are not allowed.}}
           {{ERROR: Could not send email as a part of the post-build publishers.}}
           {{org.jenkinsci.plugins.scriptsecurity.scripts.UnapprovedClasspathException: classpath entry [file:/|file:///] is a class directory, which are not allowed.}}
           {{        at org.jenkinsci.plugins.scriptsecurity.scripts.ScriptApproval.using(ScriptApproval.java:570)}}
           {{        at hudson.plugins.emailext.ExtendedEmailPublisher.expandClasspath(ExtendedEmailPublisher.java:678)}}
           {{        at hudson.plugins.emailext.ExtendedEmailPublisher.executeScript(ExtendedEmailPublisher.java:620)}}
           {{        at hudson.plugins.emailext.ExtendedEmailPublisher.executePresendScript(ExtendedEmailPublisher.java:573)}}
           {{        at hudson.plugins.emailext.ExtendedEmailPublisher.sendMail(ExtendedEmailPublisher.java:456)}}
           {{        at hudson.plugins.emailext.ExtendedEmailPublisher._perform(ExtendedEmailPublisher.java:441)}}
           {{        at hudson.plugins.emailext.ExtendedEmailPublisher.perform(ExtendedEmailPublisher.java:349)}}
           {{        at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)}}
           {{        at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744)}}
           {{        at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:690)}}
           {{        at hudson.model.Build$BuildExecution.cleanUp(Build.java:196)}}
           {{        at hudson.model.Run.execute(Run.java:1771)}}
           {{        at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)}}
           {{        at hudson.model.ResourceController.execute(ResourceController.java:97)}}
           {{        at hudson.model.Executor.run(Executor.java:421)}}
           {{Finished: SUCCESS}}

           

          Since my script says nothing about the classpath, I wonder what I would need to do to set up a classpath for my script that does not produce this error.  Why is [file:/|file:///] the default classpath?

          Also, nothing is available in the script approval page that I can approve to get around this.

          This issue was not present prior to the upgrade to the above versions.

           
          Steve Cohen made changes -
          Attachment New: AdditionalGroovyClasspath.png [ 40661 ]
          Steve Cohen made changes -
          Component/s Original: email-ext-plugin [ 15538 ]
          Steve Cohen made changes -
          Priority Original: Minor [ 4 ] New: Major [ 3 ]
          Steve Cohen made changes -
          Issue Type Original: Story [ 10002 ] New: Bug [ 1 ]
          Steve Cohen made changes -
          Component/s New: email-ext-plugin [ 15538 ]
          David van Laatum made changes -
          Assignee Original: David van Laatum [ davidvanlaatum ] New: Andrew Bayer [ abayer ]
          Steve Cohen made changes -
          Description Original: I had defined a working email extension in one of my templates that fired off emails in certain cases.  This extension defined the following groovy pre-send script:

          {{def getReplacementIndicatorFile(subproject) \{}}
           {{     if (subproject == null) \{}}
           {{          build.getWorkspace().child('build').child('replaceInfo.txt')}}
           {{     } else \{}}
           {{          build.getWorkspace().child(subproject).child('build').child('replaceInfo.txt')}}
           {{}}}
           {{if (this.hasProperty("RAWSUB")) \{}}
           {{    def replaceInfoFile = getReplacementIndicatorFile("$\{RAWSUB}")  }}
           {{    logger.println("replaceInfoFile=$\{replaceInfoFile}")}}
           {{    if (replaceInfoFile.exists()) \{}}
           {{        msg.text = replaceInfoFile.readToString()}}
           {{    } else \{}}
           {{        cancel = true}}

                  }
           {{} else \{}}
           {{   cancel = true}}
           {{}}}

           

          This script now fails with the following error:

           

          {{Pre-send script tried to access secured objects: classpath entry [file:/|file:///] is a class directory, which are not allowed.}}
           {{ERROR: Could not send email as a part of the post-build publishers.}}
           {{org.jenkinsci.plugins.scriptsecurity.scripts.UnapprovedClasspathException: classpath entry [file:/|file:///] is a class directory, which are not allowed.}}
           {{        at org.jenkinsci.plugins.scriptsecurity.scripts.ScriptApproval.using(ScriptApproval.java:570)}}
           {{        at hudson.plugins.emailext.ExtendedEmailPublisher.expandClasspath(ExtendedEmailPublisher.java:678)}}
           {{        at hudson.plugins.emailext.ExtendedEmailPublisher.executeScript(ExtendedEmailPublisher.java:620)}}
           {{        at hudson.plugins.emailext.ExtendedEmailPublisher.executePresendScript(ExtendedEmailPublisher.java:573)}}
           {{        at hudson.plugins.emailext.ExtendedEmailPublisher.sendMail(ExtendedEmailPublisher.java:456)}}
           {{        at hudson.plugins.emailext.ExtendedEmailPublisher._perform(ExtendedEmailPublisher.java:441)}}
           {{        at hudson.plugins.emailext.ExtendedEmailPublisher.perform(ExtendedEmailPublisher.java:349)}}
           {{        at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)}}
           {{        at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744)}}
           {{        at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:690)}}
           {{        at hudson.model.Build$BuildExecution.cleanUp(Build.java:196)}}
           {{        at hudson.model.Run.execute(Run.java:1771)}}
           {{        at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)}}
           {{        at hudson.model.ResourceController.execute(ResourceController.java:97)}}
           {{        at hudson.model.Executor.run(Executor.java:421)}}
           {{Finished: SUCCESS}}

           

          Since my script says nothing about the classpath, I wonder what I would need to do to set up a classpath for my script that does not produce this error.  Why is [file:/|file:///] the default classpath?

          Also, nothing is available in the script approval page that I can approve to get around this.

          This issue was not present prior to the upgrade to the above versions.

           
          New: I had defined a working email extension in one of my templates that fired off emails in certain cases.  This extension defined the following groovy pre-send script:

          {{def getReplacementIndicatorFile(subproject) \{}}
           {{     if (subproject == null) \{}}
           {{          build.getWorkspace().child('build').child('replaceInfo.txt')}}
           {{     } else \{}}
           {{          build.getWorkspace().child(subproject).child('build').child('replaceInfo.txt')}}

                    }
           {{}}}
           {{if (this.hasProperty("RAWSUB")) \{}}
           {{    def replaceInfoFile = getReplacementIndicatorFile("$\{RAWSUB}")  }}
           {{    logger.println("replaceInfoFile=$\{replaceInfoFile}")}}
           {{    if (replaceInfoFile.exists()) \{}}
           {{        msg.text = replaceInfoFile.readToString()}}
           {{    } else \{}}
           {{        cancel = true}}

                  }
           {{} else \{}}
           {{   cancel = true}}
           {{}}}

           

          This script now fails with the following error:

           

          {{Pre-send script tried to access secured objects: classpath entry [file:/|file:///] is a class directory, which are not allowed.}}
           {{ERROR: Could not send email as a part of the post-build publishers.}}
           {{org.jenkinsci.plugins.scriptsecurity.scripts.UnapprovedClasspathException: classpath entry [file:/|file:///] is a class directory, which are not allowed.}}
           {{        at org.jenkinsci.plugins.scriptsecurity.scripts.ScriptApproval.using(ScriptApproval.java:570)}}
           {{        at hudson.plugins.emailext.ExtendedEmailPublisher.expandClasspath(ExtendedEmailPublisher.java:678)}}
           {{        at hudson.plugins.emailext.ExtendedEmailPublisher.executeScript(ExtendedEmailPublisher.java:620)}}
           {{        at hudson.plugins.emailext.ExtendedEmailPublisher.executePresendScript(ExtendedEmailPublisher.java:573)}}
           {{        at hudson.plugins.emailext.ExtendedEmailPublisher.sendMail(ExtendedEmailPublisher.java:456)}}
           {{        at hudson.plugins.emailext.ExtendedEmailPublisher._perform(ExtendedEmailPublisher.java:441)}}
           {{        at hudson.plugins.emailext.ExtendedEmailPublisher.perform(ExtendedEmailPublisher.java:349)}}
           {{        at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)}}
           {{        at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744)}}
           {{        at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:690)}}
           {{        at hudson.model.Build$BuildExecution.cleanUp(Build.java:196)}}
           {{        at hudson.model.Run.execute(Run.java:1771)}}
           {{        at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)}}
           {{        at hudson.model.ResourceController.execute(ResourceController.java:97)}}
           {{        at hudson.model.Executor.run(Executor.java:421)}}
           {{Finished: SUCCESS}}

           

          Since my script says nothing about the classpath, I wonder what I would need to do to set up a classpath for my script that does not produce this error.  Why is [file:/|file:///] the default classpath?

          Also, nothing is available in the script approval page that I can approve to get around this.

          This issue was not present prior to the upgrade to the above versions.

           
          Steve Cohen made changes -
          Comment [ Is it the presence of File objects in my script what is causing this script to fail?  I can't see anything else that could cause file:/ URLs  to be present, and yet I don't understand why their presence should have anything to do with the classpath.  But something isn't right here.

            ]

            davidvanlaatum David van Laatum
            sc1478 Steve Cohen
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: