jenkinsci / jenkinsci/script-security-plugin

[JENKINS-48108] isMoreSpecific fails in script security for overloads

Open
#782 0 comments 0 reactions 0 assignees View on GitHub
component:script-security-plugin imported-jira-issue priority:minor resolution:unresolved
Dominant language
Java
Stars
76
Forks
181
Avg merge
14h 55m
Merged PRs (30d)
3

Description

I have the following methods:

def executeCake(String target, String configuration, Boolean failOnError, String... arguments) {

   // Some fancy logic
}
def executeCake(String target, String configuration, String... arguments) {
    executeCake(target, configuration, true, arguments)
}

Now when running this in Jenkins, it fails to find the correct method and ends in the following exception:

java.lang.IllegalStateException: cannot compare public java.lang.Object project.Utilities.executeCake(java.lang.String,java.lang.String,java.lang.Boolean,java.lang.String[]) to public java.lang.Object project.Utilities.executeCake(java.lang.String,java.lang.String,java.lang.String[])

at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovyCallSiteSelector.isMoreSpecific(GroovyCallSiteSelector.java:250)
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovyCallSiteSelector.findMatchingMethod(GroovyCallSiteSelector.java:196)
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovyCallSiteSelector.method(GroovyCallSiteSelector.java:146)
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:87)
at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:153)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:157)
at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:17)
at WorkflowScript.executeCake(WorkflowScript:164)
at WorkflowScript.run(WorkflowScript:83)

This is probably due to an incomplete implementation of choosing the most specific method: 

https://github.com/jenkinsci/script-security-plugin/blob/5f3851062f4fd9431f4eb20c1e55748ef83c4ac8/src/main/java/org/jenkinsci/plugins/scriptsecurity/sandbox/groovy/GroovyCallSiteSelector.java#L241

---
Originally reported by roemer, imported from: isMoreSpecific fails in script security for overloads


  • status: Open
  • priority: Minor
  • component(s): script-security-plugin
  • resolution: Unresolved
  • votes: 0
  • watchers: 2
  • imported: 2025-12-09

Raw content of original issue

I have the following methods:



def executeCake(String target, String configuration, Boolean failOnError, String... arguments) {

   // Some fancy logic
}
def executeCake(String target, String configuration, String... arguments) {
    executeCake(target, configuration, true, arguments)
}


Now when running this in Jenkins, it fails to find the correct method and ends in the following exception:



java.lang.IllegalStateException: cannot compare public java.lang.Object project.Utilities.executeCake(java.lang.String,java.lang.String,java.lang.Boolean,java.lang.String[]) to public java.lang.Object project.Utilities.executeCake(java.lang.String,java.lang.String,java.lang.String[])

at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovyCallSiteSelector.isMoreSpecific(GroovyCallSiteSelector.java:250)
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovyCallSiteSelector.findMatchingMethod(GroovyCallSiteSelector.java:196)
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovyCallSiteSelector.method(GroovyCallSiteSelector.java:146)
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:87)
at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:153)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:157)
at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:17)
at WorkflowScript.executeCake(WorkflowScript:164)
at WorkflowScript.run(WorkflowScript:83)


This is probably due to an incomplete implementation of choosing the most specific method: 

https://github.com/jenkinsci/script-security-plugin/blob/5f3851062f4fd9431f4eb20c1e55748ef83c4ac8/src/main/java/org/jenkinsci/plugins/scriptsecurity/sandbox/groovy/GroovyCallSiteSelector.java#L241

  • environment: Jenkins 2.89

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.