How to use checkMethodCall method of org.cerberus.service.groovy.impl.RestrictiveGroovyInterceptor class

Best Cerberus-source code snippet using org.cerberus.service.groovy.impl.RestrictiveGroovyInterceptor.checkMethodCall

Source:RestrictiveGroovyInterceptor.java Github

copy

Full Screen

...220 }221 // Return value doesn't matter!222 // true -> allowed delegation found223 // false -> no disallowed delegation found224 checkMethodCall(receiver, method);225 return super.onMethodCall(invoker, receiver, method, args);226 }227 private boolean checkMethodCall(Object receiver, String method)228 throws GroovyRestrictionException {229 if (receiver instanceof Closure) {230 // Closure method names were tested before.231 Closure<?> closure = (Closure<?>) receiver;232 Object owner = closure.getOwner();233 Object delegate = closure.getDelegate();234 int rs = closure.getResolveStrategy();235 // Check owner first.236 if (rs == Closure.OWNER_FIRST || rs == Closure.OWNER_ONLY) {237 if (checkMethodCall(owner, method)) {238 return true;239 }240 }241 // Check delegate first/second.242 if (rs == Closure.OWNER_FIRST || rs == Closure.DELEGATE_FIRST243 || rs == Closure.DELEGATE_ONLY) {244 if (delegate != null && delegate != closure) {245 if (checkMethodCall(delegate, method)) {246 return true;247 }248 }249 }250 // Check owner second.251 if (rs == Closure.DELEGATE_FIRST) {252 if (checkMethodCall(owner, method)) {253 return true;254 }255 }256 // Cannot be 100% sure whether the call will be handled by257 // delegation to this closure.258 return false;259 } else if (isAllowedClass(receiver.getClass())) {260 checkExecute(receiver, method);261 return instanceAllAllowedClasses.contains(receiver.getClass())262 || !InvokerHelper.getMetaClass(receiver).respondsTo(receiver, method).isEmpty();263 } else if (isScriptClass(receiver.getClass()) && !disallowedScriptMethods.contains(method)) {264 return !InvokerHelper.getMetaClass(receiver).respondsTo(receiver, method).isEmpty();265 }266 throw new GroovyRestrictionException("Possible access of method " + method + " on class "...

Full Screen

Full Screen

checkMethodCall

Using AI Code Generation

copy

Full Screen

1import org.cerberus.service.groovy.impl.RestrictiveGroovyInterceptor2import org.cerberus.service.groovy.impl.GroovyMethodInterceptor3def groovyInterceptor = new RestrictiveGroovyInterceptor()4def groovyMethodInterceptor = new GroovyMethodInterceptor(groovyInterceptor)5def groovyShell = new GroovyShell(groovyMethodInterceptor)6groovyShell.evaluate("def a = 1; def b = 2; a + b")7import java.util.regex.Pattern8def regex = Pattern.compile("^[a-zA-Z0-9_]*$")9def t = "cerberus{"10def u = "cerberus}"11def x = "cerberus("12def cc = "cerberus;"

Full Screen

Full Screen

checkMethodCall

Using AI Code Generation

copy

Full Screen

1import groovy.lang.GroovyShell2import org.cerberus.service.groovy.impl.RestrictiveGroovyInterceptor3def shell = new GroovyShell()4shell.setVariable('interceptor', new RestrictiveGroovyInterceptor())5shell.setVariable('groovy', new RestrictiveGroovyInterceptor())6shell.evaluate('''7 groovy.checkMethodCall("groovy", "checkMethodCall", null)

Full Screen

Full Screen

checkMethodCall

Using AI Code Generation

copy

Full Screen

1import org.cerberus.service.groovy.impl.RestrictiveGroovyInterceptor2RestrictiveGroovyInterceptor.checkMethodCall("org.cerberus.engine.entity.MessageEvent")3import org.cerberus.service.groovy.impl.RestrictiveGroovyInterceptor4RestrictiveGroovyInterceptor.checkMethodCall("org.cerberus.engine.entity.MessageEvent")5import org.cerberus.service.groovy.impl.RestrictiveGroovyInterceptor6RestrictiveGroovyInterceptor.checkMethodCall("org.cerberus.engine.entity.MessageEvent")7import org.cerberus.service.groovy.impl.RestrictiveGroovyInterceptor8RestrictiveGroovyInterceptor.checkMethodCall("org.cerberus.engine.entity.MessageEvent")9import org.cerberus.service.groovy.impl.RestrictiveGroovyInterceptor10RestrictiveGroovyInterceptor.checkMethodCall("org.cerberus.engine.entity.MessageEvent")11import org.cerberus.service.groovy.impl.RestrictiveGroovyInterceptor

Full Screen

Full Screen

checkMethodCall

Using AI Code Generation

copy

Full Screen

1def mygroovy = new GroovyShell()2mygroovy.setVariable("cerberus", cerberus)3mygroovy.setVariable("myclass", myclass)4mygroovy.setVariable("myobject", myobject)5mygroovy.setVariable("myobject2", myobject2)6mygroovy.setVariable("myobject3", myobject3)7mygroovy.setVariable("myobject4", myobject4)8mygroovy.setVariable("myobject5", myobject5)9mygroovy.setVariable("myobject6", myobject6)10mygroovy.setVariable("myobject7", myobject7)11mygroovy.setVariable("myobject8", myobject8)12mygroovy.setVariable("myobject9", myobject9)13mygroovy.setVariable("myobject10", myobject10)14mygroovy.setVariable("myobject11", myobject11)15mygroovy.setVariable("myobject12", myobject12)16mygroovy.setVariable("myobject13", myobject13)17mygroovy.setVariable("myobject14", myobject14)18mygroovy.setVariable("myobject15", myobject15)19mygroovy.setVariable("myobject16", myobject16)20mygroovy.setVariable("myobject17", myobject17)21mygroovy.setVariable("myobject18", myobject18)22mygroovy.setVariable("myobject19", myobject19)23mygroovy.setVariable("myobject20", myobject20)24mygroovy.setVariable("myobject21", myobject21)25mygroovy.setVariable("myobject22", myobject22)26mygroovy.setVariable("myobject23", myobject23)27mygroovy.setVariable("myobject24", myobject24)28mygroovy.setVariable("myobject25", myobject25)29mygroovy.setVariable("myobject26", myobject26)30mygroovy.setVariable("myobject27", myobject27)31mygroovy.setVariable("myobject28", myobject28)32mygroovy.setVariable("myobject29", myobject29)33mygroovy.setVariable("myobject30", myobject30)34mygroovy.setVariable("myobject31", myobject31)35mygroovy.setVariable("myobject32", myobject32)

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Cerberus-source automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful