Nowadays, OSGi is becoming more and more popular in Java world. Consequently, the quantity of available bundles is increasing rapidly, and the means to verify and assess security guaranties about these artifacts are lacking. In the context of opening its platforms to third party applications, Orange is seeking the necessary mechanisms and tools that could be used in order to ensure platforms' protection and robustness. We propose a platform that offers several services that enable statical analysis and transformation of OSGi bundles. The services range from simple ones, like for instance a service for analyzing bundles' manifests, to more complex ones that allow byte-code inspection and transformation. The platform is itself built on OSGi for modularity and extensibility. We further demonstrate the usefulness of our approach by instrumenting an instance of the Eclipse IDE in order to monitor thread creation and CPU consumption per bundle.
Radu Kopetz, Technical Architect - Orange Labs
Boost Fertility New Invention Ups Success Rates.pdf
Â
A toolbox for statical analysis and transformation of OSGi bundles
1. A toolbox for statical analysis and
transformation of OSGi bundles
Radu Kopetz â Orange Labs
radu.kopetz @orange.com
OSGi Usersâ Group France Meeting
25/11/2011
31. how it was done
⢠unjar
⢠parse the manifest
⢠retrieve the Activator / DS components bytes
⢠instrument the bytecode
⢠remove digital signature
⢠jar
32. how it was done
⢠unjar
⢠parse the manifest
⢠retrieve the Activator / DS components bytes
⢠instrument the bytecode
⢠remove digital signature
⢠jar
=> used almost all of our basic services
34. bytecode instrumentation
public void renamed_start(BundleContext
context) throws Exception {
// method body
}
class MyActivator implements
BundleActivator {
âŚ
public void start(
BundleContext context)
throws Exception {
// method body
}
âŚ
}
35. bytecode instrumentation
public void renamed_start(BundleContext
context) throws Exception {
// method body
}
class MyActivator implements
BundleActivator { public void start(BundleContext context)
⌠throws Exception {
⌠// get bundleName from manifest
public void start(
BundleContext context) ThreadGroup tg = new
throws Exception { ThreadGroup(bundleName+"_TGroup");
// method body ThreadGroup oldTg =
Thread.currentThread().getThreadGroup()
} ;
⌠âŚ// modify the thread group of
}
âŚ// current thread
renamed_start(context);
âŚ// restore the thread group
}
36. conclusion
⢠some tools for statical analysis &
transformation of bundles
⢠complete solution: statical analysis + modified
OSGi framework + modified JVM
⢠nice to have: public repository with LOTs of
bundles offering generic analysis services