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

Support String.eachMatch, String.findAll in Pipeline

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Minor Minor
    • workflow-cps-plugin
    • None

      I'd like the ability to iterate over regex matches against a string.

      Thus far my attempts at using eachMatch and findAll have both met a similar end:

       

      00:04:43.237 Got exception: org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: Scripts not permitted to use staticMethod org.codehaus.groovy.runtime.DefaultGroovyMethods eachMatch java.lang.String java.lang.String groovy.lang.Closure [Pipeline] }

          [JENKINS-46358] Support String.eachMatch, String.findAll in Pipeline

          Sean Busbey added a comment -

          if anyone has a workaround I can use in the mean time I'd really appreciate it.

          Sean Busbey added a comment - if anyone has a workaround I can use in the mean time I'd really appreciate it.

          Andrew Bayer added a comment -

          Initial PR up at https://github.com/cloudbees/groovy-cps/pull/70 - still need to do the downstream workflow-cps PR to go with it.

          Andrew Bayer added a comment - Initial PR up at https://github.com/cloudbees/groovy-cps/pull/70 - still need to do the downstream workflow-cps PR to go with it.

          Andrew Bayer added a comment -

          Also adding script security PR for whitelisting.

          Andrew Bayer added a comment - Also adding script security PR for whitelisting.

          Andrew Bayer added a comment -

          And downstream PR in workflow-cps up at https://github.com/jenkinsci/workflow-cps-plugin/pull/168

          Andrew Bayer added a comment - And downstream PR in workflow-cps up at https://github.com/jenkinsci/workflow-cps-plugin/pull/168

          Andrew Bayer added a comment -

          fwiw, the core problem here was that StringGroovyMethods has closure methods that weren't being transformed (and those methods weren't whitelisted, which makes sense, since they wouldn't work right!). So now, with this change, we transform the closure methods in StringGroovyMethods, whitelist them, and test. Woo.

          Andrew Bayer added a comment - fwiw, the core problem here was that StringGroovyMethods has closure methods that weren't being transformed (and those methods weren't whitelisted, which makes sense, since they wouldn't work right!). So now, with this change, we transform the closure methods in StringGroovyMethods , whitelist them, and test. Woo.

          Code changed in jenkins
          User: Andrew Bayer
          Path:
          src/main/resources/org/jenkinsci/plugins/scriptsecurity/sandbox/whitelists/generic-whitelist
          http://jenkins-ci.org/commit/script-security-plugin/dc9dcd991d18184cd9e93256ebbc8dcda1f54749
          Log:
          JENKINS-46358 Whitelist new StringGroovyMethods

          These will be added to CPS in https://github.com/cloudbees/groovy-cps/pull/70

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Andrew Bayer Path: src/main/resources/org/jenkinsci/plugins/scriptsecurity/sandbox/whitelists/generic-whitelist http://jenkins-ci.org/commit/script-security-plugin/dc9dcd991d18184cd9e93256ebbc8dcda1f54749 Log: JENKINS-46358 Whitelist new StringGroovyMethods These will be added to CPS in https://github.com/cloudbees/groovy-cps/pull/70

          Code changed in jenkins
          User: Andrew Bayer
          Path:
          src/main/java/org/jenkinsci/plugins/scriptsecurity/sandbox/groovy/SandboxInterceptor.java
          src/main/resources/org/jenkinsci/plugins/scriptsecurity/sandbox/whitelists/generic-whitelist
          src/test/java/org/jenkinsci/plugins/scriptsecurity/sandbox/groovy/SandboxInterceptorTest.java
          http://jenkins-ci.org/commit/script-security-plugin/0226a85c5961c19df0d9df1f721b72e36787f780
          Log:
          Merge pull request #145 from abayer/jenkins-46358

          JENKINS-46358 Whitelist new StringGroovyMethods

          Compare: https://github.com/jenkinsci/script-security-plugin/compare/6ee006972bd1...0226a85c5961

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Andrew Bayer Path: src/main/java/org/jenkinsci/plugins/scriptsecurity/sandbox/groovy/SandboxInterceptor.java src/main/resources/org/jenkinsci/plugins/scriptsecurity/sandbox/whitelists/generic-whitelist src/test/java/org/jenkinsci/plugins/scriptsecurity/sandbox/groovy/SandboxInterceptorTest.java http://jenkins-ci.org/commit/script-security-plugin/0226a85c5961c19df0d9df1f721b72e36787f780 Log: Merge pull request #145 from abayer/jenkins-46358 JENKINS-46358 Whitelist new StringGroovyMethods Compare: https://github.com/jenkinsci/script-security-plugin/compare/6ee006972bd1...0226a85c5961

            abayer Andrew Bayer
            busbey Sean Busbey
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: