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

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

Source:RestrictiveGroovyInterceptor.java Github

copy

Full Screen

...186 instanceAllAllowedClasses.addAll(additionalAllAllowedClasses);187 instanceAllowedPackages.addAll(additionalAllowedPackages);188 }189 @Override190 public Object onStaticCall(Invoker invoker, @SuppressWarnings("rawtypes") Class receiver,191 String method, Object... args) throws Throwable {192 if (isAllowedClass(receiver) || isScriptClass(receiver)) {193 return super.onStaticCall(invoker, receiver, method, args);194 } else {195 throw new GroovyRestrictionException("using class " + receiver.getSimpleName()196 + " is not allowed!");197 }198 }199 @Override200 public Object onNewInstance(Invoker invoker, @SuppressWarnings("rawtypes") Class receiver,201 Object... args) throws Throwable {202 // classes defined in the script would be okay, sadly it is not possible203 // to identify those?204 if (isAllowedClass(receiver) || isScriptClass(receiver)) {205 return super.onNewInstance(invoker, receiver, args);206 } else {207 throw new GroovyRestrictionException("using class " + receiver.getSimpleName()...

Full Screen

Full Screen

onStaticCall

Using AI Code Generation

copy

Full Screen

1import org.cerberus.service.groovy.impl.RestrictiveGroovyInterceptor2RestrictiveGroovyInterceptor.onStaticCall {3 if (it.methodName == 'getProperty' && it.arguments[0] == 'java.lang.System') {4 throw new SecurityException("System.getProperty() is not allowed")5 }6 if (it.methodName == 'getProperty' && it.arguments[0] == 'user.dir') {7 return it.proceed()8 }9 throw new SecurityException("Method ${it.methodName} is not allowed")10}11import org.cerberus.service.groovy.impl.RestrictiveGroovyInterceptor12RestrictiveGroovyInterceptor.onMethodCall {13 if (it.methodName == 'getProperty' && it.arguments[0] == 'java.lang.System') {14 throw new SecurityException("System.getProperty() is not allowed")15 }16 if (it.methodName == 'getProperty' && it.arguments[0] == 'user.dir') {17 return it.proceed()18 }19 throw new SecurityException("Method ${it.methodName} is not allowed")20}21import org.cerberus.service.groovy.impl.RestrictiveGroovyInterceptor22RestrictiveGroovyInterceptor.onStaticCall {23 if (it.methodName == 'getProperty' && it.arguments[0] == 'java.lang.System') {24 throw new SecurityException("System.getProperty() is not allowed")25 }26 if (it.methodName == 'getProperty' && it.arguments[0] == 'user.dir') {27 return it.proceed()28 }29 throw new SecurityException("Method ${it.methodName} is not allowed")30}31import org.cerberus.service.groovy.impl.RestrictiveGroovyInterceptor32RestrictiveGroovyInterceptor.onStaticCall {33 if (it.methodName == 'getProperty' && it.arguments[0] == 'java.lang.System')

Full Screen

Full Screen

onStaticCall

Using AI Code Generation

copy

Full Screen

1def onStaticCall(StaticCall call) {2 def argsSize = args.size()3 if (methodOwner == java.lang.Math.class) {4 if (methodName == 'random') {5 return [new ConstantExpression(Math.random())]6 } else if (methodName == 'abs') {7 if (argsSize == 1) {8 return [new MethodCallExpression(new ClassExpression(java.lang.Math.class), 'abs', args)]9 } else {10 throw new SecurityException('Math.abs method can only be called with 1 argument')11 }12 } else if (methodName == 'round') {13 if (argsSize == 1) {14 return [new MethodCallExpression(new ClassExpression(java.lang.Math.class), 'round', args)]15 } else {16 throw new SecurityException('Math.round method can only be called with 1 argument')17 }18 } else if (methodName == 'floor') {19 if (argsSize == 1) {20 return [new MethodCallExpression(new ClassExpression(java.lang.Math.class), 'floor', args)]21 } else {22 throw new SecurityException('Math.floor method can only be called with 1 argument')23 }24 } else if (methodName == 'ceil') {25 if (argsSize == 1) {26 return [new MethodCallExpression(new ClassExpression(java.lang.Math.class), 'ceil', args)]27 } else {28 throw new SecurityException('Math.ceil method can only be called with 1 argument')29 }30 } else if (methodName == 'max') {31 if (argsSize == 2) {32 return [new MethodCallExpression(new ClassExpression(java.lang.Math.class), 'max', args)]33 } else {34 throw new SecurityException('Math.max method can only be called with 2 arguments')35 }36 } else if (methodName == 'min') {37 if (argsSize == 2) {38 return [new MethodCallExpression(new ClassExpression(java.lang.Math.class), 'min', args)]39 } else {40 throw new SecurityException('Math.min method can only be called with 2 arguments')41 }42 } else {43 throw new SecurityException('Method ' + methodName +

Full Screen

Full Screen

onStaticCall

Using AI Code Generation

copy

Full Screen

1def onStaticCall(Class clazz, String methodName, Object[] args){2 if (clazz.name in staticWhitelist || !(clazz.name in staticBlacklist) || methodName in staticWhitelist || !(methodName in staticBlacklist)) {3 } else {4 }5}6def onInstanceCall(Object instance, String methodName, Object[] args){7 if (instance.class.name in instanceWhitelist || !(instance.class.name in instanceBlacklist) || methodName in instanceWhitelist || !(methodName in instanceBlacklist)) {8 } else {9 }10}11def onFieldGet(Object instance, String fieldName){12 if (instance.class.name in fieldWhitelist || !(instance.class.name in fieldBlacklist) || fieldName in fieldWhitelist || !(fieldName in fieldBlacklist)) {13 } else {14 }15}

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