Add StringGroovyMethods/DefaultGroovyMethods replaceFirst to whitelist entries#907
Add StringGroovyMethods/DefaultGroovyMethods replaceFirst to whitelist entries#907ugrave wants to merge 2 commits intojenkinsci:masterfrom
Conversation
| staticMethod org.codehaus.groovy.runtime.StringGroovyMethods replaceFirst java.lang.CharSequence java.util.regex.Pattern java.lang.CharSequence | ||
| staticMethod org.codehaus.groovy.runtime.StringGroovyMethods replaceFirst java.lang.String java.lang.String groovy.lang.Closure | ||
| staticMethod org.codehaus.groovy.runtime.StringGroovyMethods replaceFirst java.lang.String java.util.regex.Pattern groovy.lang.Closure | ||
| staticMethod org.codehaus.groovy.runtime.StringGroovyMethods replaceFirst java.lang.String java.util.regex.Pattern java.lang.String |
There was a problem hiding this comment.
https://github.com/apache/groovy/blob/41b990d0a20e442f29247f0e04cbed900f3dcad4/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java#L2730 This overload is deprecated. (May be true of others, I did not check yet.) Does the sandbox actually check this one specifically when you write e.g.
'xxx'.replaceFirst(/x/, 'y')or would it use the CharSequence overload? Could check in e.g.
There was a problem hiding this comment.
Yes i also saw it that the string is depreicated. But in my test is using the string overload and not the CharSequence overload.
I didt a test with all replaceFirst whiliste removed for String, StringGroovyMethodsandDefaultGroovyMethodsAn get different results depending of thereplaceFirst` is used:
'xxx'.replaceFirst(/x/, 'y'): Scripts not permitted to use method java.lang.String replaceFirst java.lang.String java.lang.String'xxx'.replaceFirst(~/x/, 'y'): Scripts not permitted to use staticMethod org.codehaus.groovy.runtime.DefaultGroovyMethods replaceFirst java.lang.String java.util.regex.Pattern java.lang.String
Nut sure when this StringGroovyMethod is used. In my case its using always the DefaultGroovyMethods or from String itself. (maybe because String itself has also now a replaceFirst method)
Add all entries which are already existing for the
StringGroovyMethods.replaceFirstalso to theDefaultGroovyMethods.replaceFirst.Include the missing signature for version for
replaceFirst java.lang.String java.util.regex.Pattern java.lang.StringforStringGroovyMethodsandDefaultGroovyMethodsThe methods on the
DefaultGroovyMethodsare marked as deprecated but are still used.Submitter checklist
Closes #906