SlideShare a Scribd company logo
1 of 42
<Insert Picture Here>
Groovy In The Cloud
Jim Driscoll
JR Smiljanic
2
The following is intended to outline our general product
direction. It is intended for information purposes only,
and may not be incorporated into any contract. It is
not a commitment to deliver any material, code, or
functionality, and should not be relied upon in making
purchasing decisions.
The development, release, and timing of any features
or functionality described for Oracle’s products remains
at the sole discretion of Oracle.
3
Oracle Application Developer Framework (ADF)
View
(ADFv)
Controller
(ADFc)
Model
(ADFm)
4
Background
• ADFm
– Part of Oracle's ADF Framework
– Provides data binding and database access
– Provides ways to customize data views via Groovy
• Heavy use of Groovy
– But all framework extensions are written in Java
• Goal – make customizations modifiable by end users
– On the web, in the cloud
5
ADFm Groovy usages
• Default values for fields
• Field or row level validators
• Triggers
• Defining new Groovy functions
• Whether a field is updateable or mandatory
• Creating new fields based on Groovy scripts
• And many more...
6
Groovy Development in the Cloud
Groovy expressions can be developed in 2 ways:
– In development, via an IDE such as JDeveloper (traditional)
– During app runtime via an admin web interface (Cloud-based)
In the cloud, users need...
– a secure environment to execute/debug Groovy expressions
– a productive development environment (edit/debug)
– performant environment to develop and run scripts
7
A Secure Environment
• Incorrectly written scripts should be protected against
• Static validation
– It can only take you so far in a dynamic language
– Undefined types are listed as Object in the parser
• Timeout (cpu resource protection)
• Security
– Post-hoc security is required, no changes to the underlying
security model of ADFm
– Runtime validation required
8
A Productive Development Environment
• Static Validation
• Visual editor
• Good exception reporting
• Logging
• Debugging
9
A Performant Environment
• 10K+ scripts embedded in many applications
• Compiling scripts is expensive
• Caching becomes critical
• Classloading issues also become a bottleneck
10
Implementation Details
• Originally built on Groovy 1.6
– Some restrictions on AST Capabilities
– Upgraded to Groovy 2.0
• Few DSL modifications
– Fields available as binding variables
• So def num = DeptNo is valid
– ScriptBaseClass provides some convenience methods
• e.g. round(), floor()
– But, also allows most of Groovy expressiveness
11
AST Transforms
def i = 1
println i
12
AST Transforms
• Abstract Syntax Tree
• Most of what we do is with Custom AST Transforms
• Uses Visitor Pattern
public void visitMethodPointerExpression(MethodPointerExpression pointer)
throw new RuntimeExpression(“Not allowed”);
}
13
A Productive Development
Environment
14
Development Tools for the ADF DSL
CODE EDITOR DEBUGGER
• Support ADF language extensions • Visualization consistent with the code editor
• Implement logical code management • Hide the Groovy execution stack
• Restrict access to variables/methods • Hide Groovy execution state/variables
• Limit language expressiveness
15
Challenges with Debugging in the Cloud
Existing Groovy debuggers are good for desktop
development…
- Single user debugging
- Single user executing a test program
16
Challenges with Debugging in the Cloud
Existing Groovy debuggers are good for desktop
development…
- Single user debugging
- Single user executing a test program
...but not a good fit for debugging in the cloud
- Many users debugging
cannot share breakpoints
- Many users executing many programs
cannot suspend the machine
17
Attempts at Debugging in the Cloud
PRINT STATEMENTS SYSTEM DUMPS
• Require code changes! • Dump system data at breakpoints
• Tedious to implement
• Developer analyzes dumps with debugger
like tool
• Must know what you are looking for
• Better than print statements, can be
implemented by the DSL platform
• Storage considerations
• Must also know what you are looking for
18
Example: Groovy Eclipse Debugger
19
Example: ADF Debugger
20
Debugger Architecture
Debugger Backend
Request
Listener
Request
Listener
Event
Processor
Event
Processor
Debug State
Machine
Debug State
Machine
ADF/Groovy
Script
Execution
Engine
ADF/Groovy
Script
Execution
Engine
JDI Debug
Client
JDI Debug
Client
Debugger
UI
Debugger
UI
JDWP
Debug
Transform
Debug
Transform
Debugger Frontend
Debug SessionDebug Session
21
1: def validateBonus() {
2: if (bonus > (salary * 0.50)) {
3: return false
4: }
5: return true
6: }
1: def validateBonus() {
2: methodEntry()
3: try {
4: if (bonus >
5: endExpression(startExpression(2), salary * 0.50)) {
6: return endExpression(startExpression(3), false)
7: }
8: return endExpression(startExpression(5), true)
9: } finally {
10: methodExit()
11: }
12: }
AST Visualization – Program Counters
22
before_update_trigger
1: // Calculate a discount for the customer
2: def discount = calculateDiscount(Customer)
before_update_trigger
1: // Calculate a discount for the customer
2: def discount = endExpression(
3: startExpression(2),
4: assignment(‘discount’, calculateDiscount(Customer))
AST Visualization – Variable Assignment
23
Very Groovy!
Groovy AST transformations enable ADF to deliver a
debugger to the cloud
– “GroovyTI” enables the development of custom tooling
– Debug transform enables isolation between sessions
– Debug transform exposes Groovy context only
– Technique could be applied to any Groovy DSL
24
A Performant Environment
25
Just in Time Groovy Compilation is Expensive
• ADF developers often define 10K+ of Groovy scripts in
an ADF application
• ADF compiles each business rule as a separate script
• Dynamic language adds compilation overhead
– Lots of BeanInfo ClassLoader misses on MetaClass
instantiation (execute).
e.g. oracle.jbo.common.BaseScriptGroovyBeanInfo
– Lots of Script class ClassLoader misses on compile.
e.g. java.lang.oracle$jbo$common$BaseScriptGroovy
26
Speeding up Just In Time Groovy Compilation
• Cache frequently used script classes/instances
– Script class cache avoids compilation overhead
– Script instance cache avoids instantiation overhead
– Must be careful to ensure that script instances are not invoked
concurrently
• Define negative classloader cache for known misses
• Future: Combine user scripts into single, physical script
27
A Secure Environment
28
Timeout Protection
• Inadvertent runaway processes
– Tie up cpu
– Tie up Threads
• Groovy provides standard ASTTransforms
– groovy.transform.TimedInterrupt
– groovy.transform.ThreadInterrupt
– groovy.transform.ConditionalInterrupt
29
Security
• Java Security Manager
– (Almost) air-tight
– Requires instrumentation of existing code (checkPermission)
– Best choice, if you can instrument your code
• Groovy Security – SecureASTCustomizer
– Static analysis
– Good choice for limited DSLs
• Custom ClassLoader
30
Static Analysis Issues
• How many ways can you System.exit?
– System.exit(0)
– Eval.me("System.exit(0)")
– evaluate("System.exit(0)")
– (new GroovyShell()).evaluate("System.exit(0)")
– Class.forName("java.lang.System").exit(0)
– System.&exit.call(0)
– System.getMetaClass().invokeMethod("exit",0)
– def s = System; s.exit(0)
– Script t = this; t.evaluate("System.exit(0)")
– def s = “exit”; System.”$s”(0)
31
Static Analysis Issues
• You need to blacklist Script, Class, Object (yikes!)
• That means you can't say stuff like:
– println “test”
– def s = "test" ; s.count("t")
• Conclusion:
– Static checks aren't sufficient for open ended use
32
Security via AST wrapping
• Requirements:
– Post-hoc security (eliminates Security Manager solution)
– Dynamic calls required (eliminates static analysis)
– Fully configurable
– Performant
• Solution:
– Use AST rewriting to wrap all calls to route through a security
checker
33
Secure Wrapping Methods
• SecurityChecker.checkMethod returns Object
• Inside checkMethod, check for permission, then execute
• You can check some static methods at compile
SecurityChecker.checkMethod(instance,”method”,params)
instance.method(param)
34
Secure Wrapping Properties
• checkProperty returns Object
• Inside checkProperty, check permissions, then get prop
SecurityChecker.checkProperty(instance,”property”)
instance.property
35
Secure Wrapping Constructors
• Static check – since you can determine class at compile
SecurityChecker.checkConstructor(Class,params)
new Class(params)
new Class(params)
36
Permissions
• Whitelist
– Basic list of whitelisted classes/methods held in memory
– Annotation based extensions
– Configuration file base extensions
• A few hardcoded blacklist items
– Restricted to those that bypass security
– Method pointers, reflection, etc
37
Q&A
38
Appendix
<Insert Picture Here>
39
AST Technique
• Create a new ASTTransform
@GroovyASTTransformation(phase = CompilePhase.SEMANTIC_ANALYSIS)
class ExprASTScan implements ASTTransformation {
public void visit(ASTNode[] nodes, SourceUnit sourceUnit) {
…
ClassNode node = (ClassNode)nodes[1];
Parameter[] params = { };
MethodNode methodNode = node.getMethod("run", params);
GroovyCodeVisitor visitor = new ExprASTScanningVisitor(sourceUnit);
Statement mcontent = methodNode.getCode();
String content = mcontent.getText();
mcontent.visit(visitor);
...
40
AST Technique (2)
• Create a new ASTVisitor
class ExprASTScanningVisitor extends ClassCodeVisitorSupport
{
…
public void visitMethodPointerExpression(MethodPointerExpression pointer) {
throw new RuntimeExpression(“Not allowed”);
}
...
41
AST Technique (3)
• Create a new AST Annotation
@Retention(RetentionPolicy.SOURCE)
@Target(ElementType.TYPE)
@GroovyASTTransformationClass("oracle.jbo.script.ExprASTScan")
public @interface ExprScan {}
42
AST Technique (4)
• Apply the AST Annotation
CompilerConfiguration configuration = new
CompilerConfiguration(CompilerConfiguration.DEFAULT);
configuration.addCompilationCustomizers(
new ASTTransformationCustomizer(
oracle.jbo.script.ExprScan.class));
shell = new GroovyShell(classloader, new Binding(), configuration);

More Related Content

What's hot

"What's New in HotSpot JVM 8" @ JPoint 2014, Moscow, Russia
"What's New in HotSpot JVM 8" @ JPoint 2014, Moscow, Russia "What's New in HotSpot JVM 8" @ JPoint 2014, Moscow, Russia
"What's New in HotSpot JVM 8" @ JPoint 2014, Moscow, Russia Vladimir Ivanov
 
Java Jit. Compilation and optimization by Andrey Kovalenko
Java Jit. Compilation and optimization by Andrey KovalenkoJava Jit. Compilation and optimization by Andrey Kovalenko
Java Jit. Compilation and optimization by Andrey KovalenkoValeriia Maliarenko
 
Integrating web archiving in preservation workflows. Louise Fauduet, Clément ...
Integrating web archiving in preservation workflows. Louise Fauduet, Clément ...Integrating web archiving in preservation workflows. Louise Fauduet, Clément ...
Integrating web archiving in preservation workflows. Louise Fauduet, Clément ...Biblioteca Nacional de España
 
Intrinsic Methods in HotSpot VM
Intrinsic Methods in HotSpot VMIntrinsic Methods in HotSpot VM
Intrinsic Methods in HotSpot VMKris Mok
 
Injection on Steroids: Codeless code injection and 0-day techniques
Injection on Steroids: Codeless code injection and 0-day techniquesInjection on Steroids: Codeless code injection and 0-day techniques
Injection on Steroids: Codeless code injection and 0-day techniquesenSilo
 
Bypassing patchguard on Windows 8.1 and Windows 10
Bypassing patchguard on Windows 8.1 and Windows 10Bypassing patchguard on Windows 8.1 and Windows 10
Bypassing patchguard on Windows 8.1 and Windows 10Honorary_BoT
 
Debugging of (C)Python applications
Debugging of (C)Python applicationsDebugging of (C)Python applications
Debugging of (C)Python applicationsRoman Podoliaka
 
OpenSCAP Overview(security scanning for docker image and container)
OpenSCAP Overview(security scanning for docker image and container)OpenSCAP Overview(security scanning for docker image and container)
OpenSCAP Overview(security scanning for docker image and container)Jooho Lee
 
Lightweight Virtualization with Linux Containers and Docker | YaC 2013
Lightweight Virtualization with Linux Containers and Docker | YaC 2013Lightweight Virtualization with Linux Containers and Docker | YaC 2013
Lightweight Virtualization with Linux Containers and Docker | YaC 2013dotCloud
 
Patching Windows Executables with the Backdoor Factory | DerbyCon 2013
Patching Windows Executables with the Backdoor Factory | DerbyCon 2013Patching Windows Executables with the Backdoor Factory | DerbyCon 2013
Patching Windows Executables with the Backdoor Factory | DerbyCon 2013midnite_runr
 
Efficient DevOps Tooling with Java and GraalVM
Efficient DevOps Tooling with Java and GraalVMEfficient DevOps Tooling with Java and GraalVM
Efficient DevOps Tooling with Java and GraalVMQAware GmbH
 
Java Performance Tuning
Java Performance TuningJava Performance Tuning
Java Performance TuningMinh Hoang
 
REST in Peace. Long live gRPC!
REST in Peace. Long live gRPC!REST in Peace. Long live gRPC!
REST in Peace. Long live gRPC!QAware GmbH
 
Масштабируемый и эффективный фаззинг Google Chrome
Масштабируемый и эффективный фаззинг Google ChromeМасштабируемый и эффективный фаззинг Google Chrome
Масштабируемый и эффективный фаззинг Google ChromePositive Hack Days
 
Kubernetes Navigation Stories – DevOpsStage 2019, Kyiv
Kubernetes Navigation Stories – DevOpsStage 2019, KyivKubernetes Navigation Stories – DevOpsStage 2019, Kyiv
Kubernetes Navigation Stories – DevOpsStage 2019, KyivAleksey Asiutin
 
GraalVM - MadridJUG 2019-10-22
GraalVM - MadridJUG 2019-10-22GraalVM - MadridJUG 2019-10-22
GraalVM - MadridJUG 2019-10-22Jorge Hidalgo
 
Polyglot Applications with GraalVM
Polyglot Applications with GraalVMPolyglot Applications with GraalVM
Polyglot Applications with GraalVMjexp
 
Graal in GraalVM - A New JIT Compiler
Graal in GraalVM - A New JIT CompilerGraal in GraalVM - A New JIT Compiler
Graal in GraalVM - A New JIT CompilerKoichi Sakata
 

What's hot (20)

"What's New in HotSpot JVM 8" @ JPoint 2014, Moscow, Russia
"What's New in HotSpot JVM 8" @ JPoint 2014, Moscow, Russia "What's New in HotSpot JVM 8" @ JPoint 2014, Moscow, Russia
"What's New in HotSpot JVM 8" @ JPoint 2014, Moscow, Russia
 
Java Jit. Compilation and optimization by Andrey Kovalenko
Java Jit. Compilation and optimization by Andrey KovalenkoJava Jit. Compilation and optimization by Andrey Kovalenko
Java Jit. Compilation and optimization by Andrey Kovalenko
 
Integrating web archiving in preservation workflows. Louise Fauduet, Clément ...
Integrating web archiving in preservation workflows. Louise Fauduet, Clément ...Integrating web archiving in preservation workflows. Louise Fauduet, Clément ...
Integrating web archiving in preservation workflows. Louise Fauduet, Clément ...
 
Intrinsic Methods in HotSpot VM
Intrinsic Methods in HotSpot VMIntrinsic Methods in HotSpot VM
Intrinsic Methods in HotSpot VM
 
Injection on Steroids: Codeless code injection and 0-day techniques
Injection on Steroids: Codeless code injection and 0-day techniquesInjection on Steroids: Codeless code injection and 0-day techniques
Injection on Steroids: Codeless code injection and 0-day techniques
 
Bypassing patchguard on Windows 8.1 and Windows 10
Bypassing patchguard on Windows 8.1 and Windows 10Bypassing patchguard on Windows 8.1 and Windows 10
Bypassing patchguard on Windows 8.1 and Windows 10
 
Debugging of (C)Python applications
Debugging of (C)Python applicationsDebugging of (C)Python applications
Debugging of (C)Python applications
 
OpenSCAP Overview(security scanning for docker image and container)
OpenSCAP Overview(security scanning for docker image and container)OpenSCAP Overview(security scanning for docker image and container)
OpenSCAP Overview(security scanning for docker image and container)
 
Lightweight Virtualization with Linux Containers and Docker | YaC 2013
Lightweight Virtualization with Linux Containers and Docker | YaC 2013Lightweight Virtualization with Linux Containers and Docker | YaC 2013
Lightweight Virtualization with Linux Containers and Docker | YaC 2013
 
Patching Windows Executables with the Backdoor Factory | DerbyCon 2013
Patching Windows Executables with the Backdoor Factory | DerbyCon 2013Patching Windows Executables with the Backdoor Factory | DerbyCon 2013
Patching Windows Executables with the Backdoor Factory | DerbyCon 2013
 
The Veil-Framework
The Veil-FrameworkThe Veil-Framework
The Veil-Framework
 
Efficient DevOps Tooling with Java and GraalVM
Efficient DevOps Tooling with Java and GraalVMEfficient DevOps Tooling with Java and GraalVM
Efficient DevOps Tooling with Java and GraalVM
 
JVM++: The Graal VM
JVM++: The Graal VMJVM++: The Graal VM
JVM++: The Graal VM
 
Java Performance Tuning
Java Performance TuningJava Performance Tuning
Java Performance Tuning
 
REST in Peace. Long live gRPC!
REST in Peace. Long live gRPC!REST in Peace. Long live gRPC!
REST in Peace. Long live gRPC!
 
Масштабируемый и эффективный фаззинг Google Chrome
Масштабируемый и эффективный фаззинг Google ChromeМасштабируемый и эффективный фаззинг Google Chrome
Масштабируемый и эффективный фаззинг Google Chrome
 
Kubernetes Navigation Stories – DevOpsStage 2019, Kyiv
Kubernetes Navigation Stories – DevOpsStage 2019, KyivKubernetes Navigation Stories – DevOpsStage 2019, Kyiv
Kubernetes Navigation Stories – DevOpsStage 2019, Kyiv
 
GraalVM - MadridJUG 2019-10-22
GraalVM - MadridJUG 2019-10-22GraalVM - MadridJUG 2019-10-22
GraalVM - MadridJUG 2019-10-22
 
Polyglot Applications with GraalVM
Polyglot Applications with GraalVMPolyglot Applications with GraalVM
Polyglot Applications with GraalVM
 
Graal in GraalVM - A New JIT Compiler
Graal in GraalVM - A New JIT CompilerGraal in GraalVM - A New JIT Compiler
Graal in GraalVM - A New JIT Compiler
 

Similar to Groovy In The Cloud Development

Devopsdays london: Let’s talk about security
Devopsdays london:  Let’s talk about securityDevopsdays london:  Let’s talk about security
Devopsdays london: Let’s talk about securityJustin Cormack
 
The Future of Security and Productivity in Our Newly Remote World
The Future of Security and Productivity in Our Newly Remote WorldThe Future of Security and Productivity in Our Newly Remote World
The Future of Security and Productivity in Our Newly Remote WorldDevOps.com
 
2016 07 - CloudBridge Python library (XSEDE16)
2016 07 - CloudBridge Python library (XSEDE16)2016 07 - CloudBridge Python library (XSEDE16)
2016 07 - CloudBridge Python library (XSEDE16)Enis Afgan
 
OWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA TestersOWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA TestersJavan Rasokat
 
Code quality par Simone Civetta
Code quality par Simone CivettaCode quality par Simone Civetta
Code quality par Simone CivettaCocoaHeads France
 
Developers Testing - Girl Code at bloomon
Developers Testing - Girl Code at bloomonDevelopers Testing - Girl Code at bloomon
Developers Testing - Girl Code at bloomonIneke Scheffers
 
Typhoon Managed Execution Toolkit
Typhoon Managed Execution ToolkitTyphoon Managed Execution Toolkit
Typhoon Managed Execution ToolkitDimitry Snezhkov
 
Security research over Windows #defcon china
Security research over Windows #defcon chinaSecurity research over Windows #defcon china
Security research over Windows #defcon chinaPeter Hlavaty
 
Joomla Code Quality Control and Automation Testing
Joomla Code Quality Control and Automation TestingJoomla Code Quality Control and Automation Testing
Joomla Code Quality Control and Automation TestingShyam Sunder Verma
 
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...Malin Weiss
 
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...Speedment, Inc.
 
Pragmatic Monolith-First, easy to decompose, clean architecture
Pragmatic Monolith-First, easy to decompose, clean architecturePragmatic Monolith-First, easy to decompose, clean architecture
Pragmatic Monolith-First, easy to decompose, clean architecturePiotr Pelczar
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.jsorkaplan
 
StorageOS, Storage for Containers Shouldn't Be Annoying at Container Camp UK
StorageOS, Storage for Containers Shouldn't Be Annoying at Container Camp UKStorageOS, Storage for Containers Shouldn't Be Annoying at Container Camp UK
StorageOS, Storage for Containers Shouldn't Be Annoying at Container Camp UKStorageOS
 
Extensible dev secops pipelines with Jenkins, Docker, Terraform, and a kitche...
Extensible dev secops pipelines with Jenkins, Docker, Terraform, and a kitche...Extensible dev secops pipelines with Jenkins, Docker, Terraform, and a kitche...
Extensible dev secops pipelines with Jenkins, Docker, Terraform, and a kitche...Richard Bullington-McGuire
 
SANS_PentestHackfest_2022-PurpleTeam_Cloud_Identity.pptx
SANS_PentestHackfest_2022-PurpleTeam_Cloud_Identity.pptxSANS_PentestHackfest_2022-PurpleTeam_Cloud_Identity.pptx
SANS_PentestHackfest_2022-PurpleTeam_Cloud_Identity.pptxJasonOstrom1
 
What to expect from Java 9
What to expect from Java 9What to expect from Java 9
What to expect from Java 9Ivan Krylov
 

Similar to Groovy In The Cloud Development (20)

Devopsdays london: Let’s talk about security
Devopsdays london:  Let’s talk about securityDevopsdays london:  Let’s talk about security
Devopsdays london: Let’s talk about security
 
The Future of Security and Productivity in Our Newly Remote World
The Future of Security and Productivity in Our Newly Remote WorldThe Future of Security and Productivity in Our Newly Remote World
The Future of Security and Productivity in Our Newly Remote World
 
2016 07 - CloudBridge Python library (XSEDE16)
2016 07 - CloudBridge Python library (XSEDE16)2016 07 - CloudBridge Python library (XSEDE16)
2016 07 - CloudBridge Python library (XSEDE16)
 
OWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA TestersOWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA Testers
 
Power of Azure Devops
Power of Azure DevopsPower of Azure Devops
Power of Azure Devops
 
Code quality par Simone Civetta
Code quality par Simone CivettaCode quality par Simone Civetta
Code quality par Simone Civetta
 
Developers Testing - Girl Code at bloomon
Developers Testing - Girl Code at bloomonDevelopers Testing - Girl Code at bloomon
Developers Testing - Girl Code at bloomon
 
Typhoon Managed Execution Toolkit
Typhoon Managed Execution ToolkitTyphoon Managed Execution Toolkit
Typhoon Managed Execution Toolkit
 
Security research over Windows #defcon china
Security research over Windows #defcon chinaSecurity research over Windows #defcon china
Security research over Windows #defcon china
 
Joomla Code Quality Control and Automation Testing
Joomla Code Quality Control and Automation TestingJoomla Code Quality Control and Automation Testing
Joomla Code Quality Control and Automation Testing
 
Us 17-krug-hacking-severless-runtimes
Us 17-krug-hacking-severless-runtimesUs 17-krug-hacking-severless-runtimes
Us 17-krug-hacking-severless-runtimes
 
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
 
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
 
Pragmatic Monolith-First, easy to decompose, clean architecture
Pragmatic Monolith-First, easy to decompose, clean architecturePragmatic Monolith-First, easy to decompose, clean architecture
Pragmatic Monolith-First, easy to decompose, clean architecture
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
 
StorageOS, Storage for Containers Shouldn't Be Annoying at Container Camp UK
StorageOS, Storage for Containers Shouldn't Be Annoying at Container Camp UKStorageOS, Storage for Containers Shouldn't Be Annoying at Container Camp UK
StorageOS, Storage for Containers Shouldn't Be Annoying at Container Camp UK
 
Extensible dev secops pipelines with Jenkins, Docker, Terraform, and a kitche...
Extensible dev secops pipelines with Jenkins, Docker, Terraform, and a kitche...Extensible dev secops pipelines with Jenkins, Docker, Terraform, and a kitche...
Extensible dev secops pipelines with Jenkins, Docker, Terraform, and a kitche...
 
Apache Drill (ver. 0.2)
Apache Drill (ver. 0.2)Apache Drill (ver. 0.2)
Apache Drill (ver. 0.2)
 
SANS_PentestHackfest_2022-PurpleTeam_Cloud_Identity.pptx
SANS_PentestHackfest_2022-PurpleTeam_Cloud_Identity.pptxSANS_PentestHackfest_2022-PurpleTeam_Cloud_Identity.pptx
SANS_PentestHackfest_2022-PurpleTeam_Cloud_Identity.pptx
 
What to expect from Java 9
What to expect from Java 9What to expect from Java 9
What to expect from Java 9
 

Recently uploaded

WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetEnjoy Anytime
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Hyundai Motor Group
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 

Recently uploaded (20)

WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 

Groovy In The Cloud Development

  • 1. <Insert Picture Here> Groovy In The Cloud Jim Driscoll JR Smiljanic
  • 2. 2 The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.
  • 3. 3 Oracle Application Developer Framework (ADF) View (ADFv) Controller (ADFc) Model (ADFm)
  • 4. 4 Background • ADFm – Part of Oracle's ADF Framework – Provides data binding and database access – Provides ways to customize data views via Groovy • Heavy use of Groovy – But all framework extensions are written in Java • Goal – make customizations modifiable by end users – On the web, in the cloud
  • 5. 5 ADFm Groovy usages • Default values for fields • Field or row level validators • Triggers • Defining new Groovy functions • Whether a field is updateable or mandatory • Creating new fields based on Groovy scripts • And many more...
  • 6. 6 Groovy Development in the Cloud Groovy expressions can be developed in 2 ways: – In development, via an IDE such as JDeveloper (traditional) – During app runtime via an admin web interface (Cloud-based) In the cloud, users need... – a secure environment to execute/debug Groovy expressions – a productive development environment (edit/debug) – performant environment to develop and run scripts
  • 7. 7 A Secure Environment • Incorrectly written scripts should be protected against • Static validation – It can only take you so far in a dynamic language – Undefined types are listed as Object in the parser • Timeout (cpu resource protection) • Security – Post-hoc security is required, no changes to the underlying security model of ADFm – Runtime validation required
  • 8. 8 A Productive Development Environment • Static Validation • Visual editor • Good exception reporting • Logging • Debugging
  • 9. 9 A Performant Environment • 10K+ scripts embedded in many applications • Compiling scripts is expensive • Caching becomes critical • Classloading issues also become a bottleneck
  • 10. 10 Implementation Details • Originally built on Groovy 1.6 – Some restrictions on AST Capabilities – Upgraded to Groovy 2.0 • Few DSL modifications – Fields available as binding variables • So def num = DeptNo is valid – ScriptBaseClass provides some convenience methods • e.g. round(), floor() – But, also allows most of Groovy expressiveness
  • 11. 11 AST Transforms def i = 1 println i
  • 12. 12 AST Transforms • Abstract Syntax Tree • Most of what we do is with Custom AST Transforms • Uses Visitor Pattern public void visitMethodPointerExpression(MethodPointerExpression pointer) throw new RuntimeExpression(“Not allowed”); }
  • 14. 14 Development Tools for the ADF DSL CODE EDITOR DEBUGGER • Support ADF language extensions • Visualization consistent with the code editor • Implement logical code management • Hide the Groovy execution stack • Restrict access to variables/methods • Hide Groovy execution state/variables • Limit language expressiveness
  • 15. 15 Challenges with Debugging in the Cloud Existing Groovy debuggers are good for desktop development… - Single user debugging - Single user executing a test program
  • 16. 16 Challenges with Debugging in the Cloud Existing Groovy debuggers are good for desktop development… - Single user debugging - Single user executing a test program ...but not a good fit for debugging in the cloud - Many users debugging cannot share breakpoints - Many users executing many programs cannot suspend the machine
  • 17. 17 Attempts at Debugging in the Cloud PRINT STATEMENTS SYSTEM DUMPS • Require code changes! • Dump system data at breakpoints • Tedious to implement • Developer analyzes dumps with debugger like tool • Must know what you are looking for • Better than print statements, can be implemented by the DSL platform • Storage considerations • Must also know what you are looking for
  • 20. 20 Debugger Architecture Debugger Backend Request Listener Request Listener Event Processor Event Processor Debug State Machine Debug State Machine ADF/Groovy Script Execution Engine ADF/Groovy Script Execution Engine JDI Debug Client JDI Debug Client Debugger UI Debugger UI JDWP Debug Transform Debug Transform Debugger Frontend Debug SessionDebug Session
  • 21. 21 1: def validateBonus() { 2: if (bonus > (salary * 0.50)) { 3: return false 4: } 5: return true 6: } 1: def validateBonus() { 2: methodEntry() 3: try { 4: if (bonus > 5: endExpression(startExpression(2), salary * 0.50)) { 6: return endExpression(startExpression(3), false) 7: } 8: return endExpression(startExpression(5), true) 9: } finally { 10: methodExit() 11: } 12: } AST Visualization – Program Counters
  • 22. 22 before_update_trigger 1: // Calculate a discount for the customer 2: def discount = calculateDiscount(Customer) before_update_trigger 1: // Calculate a discount for the customer 2: def discount = endExpression( 3: startExpression(2), 4: assignment(‘discount’, calculateDiscount(Customer)) AST Visualization – Variable Assignment
  • 23. 23 Very Groovy! Groovy AST transformations enable ADF to deliver a debugger to the cloud – “GroovyTI” enables the development of custom tooling – Debug transform enables isolation between sessions – Debug transform exposes Groovy context only – Technique could be applied to any Groovy DSL
  • 25. 25 Just in Time Groovy Compilation is Expensive • ADF developers often define 10K+ of Groovy scripts in an ADF application • ADF compiles each business rule as a separate script • Dynamic language adds compilation overhead – Lots of BeanInfo ClassLoader misses on MetaClass instantiation (execute). e.g. oracle.jbo.common.BaseScriptGroovyBeanInfo – Lots of Script class ClassLoader misses on compile. e.g. java.lang.oracle$jbo$common$BaseScriptGroovy
  • 26. 26 Speeding up Just In Time Groovy Compilation • Cache frequently used script classes/instances – Script class cache avoids compilation overhead – Script instance cache avoids instantiation overhead – Must be careful to ensure that script instances are not invoked concurrently • Define negative classloader cache for known misses • Future: Combine user scripts into single, physical script
  • 28. 28 Timeout Protection • Inadvertent runaway processes – Tie up cpu – Tie up Threads • Groovy provides standard ASTTransforms – groovy.transform.TimedInterrupt – groovy.transform.ThreadInterrupt – groovy.transform.ConditionalInterrupt
  • 29. 29 Security • Java Security Manager – (Almost) air-tight – Requires instrumentation of existing code (checkPermission) – Best choice, if you can instrument your code • Groovy Security – SecureASTCustomizer – Static analysis – Good choice for limited DSLs • Custom ClassLoader
  • 30. 30 Static Analysis Issues • How many ways can you System.exit? – System.exit(0) – Eval.me("System.exit(0)") – evaluate("System.exit(0)") – (new GroovyShell()).evaluate("System.exit(0)") – Class.forName("java.lang.System").exit(0) – System.&exit.call(0) – System.getMetaClass().invokeMethod("exit",0) – def s = System; s.exit(0) – Script t = this; t.evaluate("System.exit(0)") – def s = “exit”; System.”$s”(0)
  • 31. 31 Static Analysis Issues • You need to blacklist Script, Class, Object (yikes!) • That means you can't say stuff like: – println “test” – def s = "test" ; s.count("t") • Conclusion: – Static checks aren't sufficient for open ended use
  • 32. 32 Security via AST wrapping • Requirements: – Post-hoc security (eliminates Security Manager solution) – Dynamic calls required (eliminates static analysis) – Fully configurable – Performant • Solution: – Use AST rewriting to wrap all calls to route through a security checker
  • 33. 33 Secure Wrapping Methods • SecurityChecker.checkMethod returns Object • Inside checkMethod, check for permission, then execute • You can check some static methods at compile SecurityChecker.checkMethod(instance,”method”,params) instance.method(param)
  • 34. 34 Secure Wrapping Properties • checkProperty returns Object • Inside checkProperty, check permissions, then get prop SecurityChecker.checkProperty(instance,”property”) instance.property
  • 35. 35 Secure Wrapping Constructors • Static check – since you can determine class at compile SecurityChecker.checkConstructor(Class,params) new Class(params) new Class(params)
  • 36. 36 Permissions • Whitelist – Basic list of whitelisted classes/methods held in memory – Annotation based extensions – Configuration file base extensions • A few hardcoded blacklist items – Restricted to those that bypass security – Method pointers, reflection, etc
  • 39. 39 AST Technique • Create a new ASTTransform @GroovyASTTransformation(phase = CompilePhase.SEMANTIC_ANALYSIS) class ExprASTScan implements ASTTransformation { public void visit(ASTNode[] nodes, SourceUnit sourceUnit) { … ClassNode node = (ClassNode)nodes[1]; Parameter[] params = { }; MethodNode methodNode = node.getMethod("run", params); GroovyCodeVisitor visitor = new ExprASTScanningVisitor(sourceUnit); Statement mcontent = methodNode.getCode(); String content = mcontent.getText(); mcontent.visit(visitor); ...
  • 40. 40 AST Technique (2) • Create a new ASTVisitor class ExprASTScanningVisitor extends ClassCodeVisitorSupport { … public void visitMethodPointerExpression(MethodPointerExpression pointer) { throw new RuntimeExpression(“Not allowed”); } ...
  • 41. 41 AST Technique (3) • Create a new AST Annotation @Retention(RetentionPolicy.SOURCE) @Target(ElementType.TYPE) @GroovyASTTransformationClass("oracle.jbo.script.ExprASTScan") public @interface ExprScan {}
  • 42. 42 AST Technique (4) • Apply the AST Annotation CompilerConfiguration configuration = new CompilerConfiguration(CompilerConfiguration.DEFAULT); configuration.addCompilationCustomizers( new ASTTransformationCustomizer( oracle.jbo.script.ExprScan.class)); shell = new GroovyShell(classloader, new Binding(), configuration);

Editor's Notes

  1. ADF CodeEditor component is implemented using CodeMirror. CodeMirror is an open source JavaScript library that provides web-based source editing capabilities. ADF wraps CodeMirror in a JSF component.
  2. Breakpont islation – In a standard desktop development environment breakpoints are defined for the development project, not the user session. An example of how desktop environments are designed for a single session. Machine suspensions – Debuggers typically suspend the entire machine. Even if the debugger supports thread level breaks, how do I identify which thread is associated with the debug users session? Object/Type insulation – Difficult to filter GPL platform detail. Source code mapping – GPL platform debuggers require developer knowledge of the physical storage of the source code.
  3. Point out that we only really care about the transient expression call in our stack. Even that contains the physical script name that we elected to use and that we don’t want to expose to the developer. I’m aware that the desktop debugger does have a way of filtering this stuff, but that is not very DSL-like!
  4. Script execution is performed in a separate thread than the threads that are used to handle Debugger UI requests.
  5. Similar technique is applied for variable expressions in order to track variable assignments. Discuss variable tables/variable assignments
  6. Breakpont islation – In a standard desktop development environment breakpoints are defined for the development project, not the user session. An example of how desktop environments are designed for a single session. Machine suspensions – Debuggers typically suspend the entire machine. Even if the debugger supports thread level breaks, how do I identify which thread is associated with the debug users session? Object/Type insulation – Difficult to filter GPL platform detail. Source code mapping – GPL platform debuggers require developer knowledge of the physical storage of the source code.
  7. MetaClass instantiation triggers BeanInfo lookup. BeanInfos are weakly referenced
  8. 30% increase in system thro ughput