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

"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 

Recently uploaded (20)

"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 

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