Class SandboxMethodContributor
java.lang.Object
org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxMethodContributor
- All Implemented Interfaces:
ExtensionPoint
@Restricted(org.kohsuke.accmod.restrictions.Beta.class)
public abstract class SandboxMethodContributor
extends Object
implements ExtensionPoint
Extension point for plugins to expose additional methods on existing types to sandboxed scripts,
using Groovy's extension method pattern.
A contributed class declares static methods whose first parameter is the receiver type. Sandboxed scripts can then call those methods as if they were instance methods:
// helper class contributed by a plugin:
public class MyHelpers {
@Whitelisted
public static String getLabel(Job job) { return job.getFullDisplayName(); }
}
// in a sandboxed script:
echo job.getLabel() // method call form
echo job.label // property shorthand
Whitelist.permitsStaticMethod(java.lang.reflect.Method, java.lang.Object[]) runs before every dispatch; a method must be annotated
@Whitelisted or have a StaticWhitelist entry, otherwise
RejectedAccessException is thrown.
Execution trust: the whitelist check is an entrance gate only. Once permitted, the contributed method body runs as trusted plugin code outside the sandbox; calls within it are not subject to whitelist checks. Installed plugins are trusted by the admin.
-
Nested Class Summary
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic List<SandboxMethodContributor> all()abstract Class<?>[]Returns the static helper classes contributed by this extension.
-
Constructor Details
-
SandboxMethodContributor
public SandboxMethodContributor()
-
-
Method Details
-
getContributedClasses
Returns the static helper classes contributed by this extension. Each class must declare static methods whose first parameter is the receiver type. Methods callable from sandbox scripts must be annotated@Whitelisted. Must not returnnullor containnullelements. -
all
-