E Tensible,Fastandsecurescalae Ressionevaluationengine
Total Page:16
File Type:pdf, Size:1020Kb
Journal of Automation, Mobile Robotics & Intelligent Systems VOLUME 11, N∘ 3 2017 EE,, F A S S E E E Submied: 25th March 2017; accepted: 26th October 2017 Arkadiusz Janik, Roman Janusz DOI: 10.14313/JAMRIS_3-2017/26 Keywords: expression evaluaon engine, Scala Abstract: 1. Introducon Scripng and expression evaluaon engines are popular Embedding scripting environments inside larger tools in the Java soware ecosystem which is understood software systems is a commonly used technique as any environment using Java Virtual Machine (JVM) to where the system serves as a container for some spe- execute code (which does not have to be generated from cialized, domain speciic logic that can be loaded and Java language). With the current, wide-spread popularity executed dynamically. Such environments allow im- of Java and Java bytecode compliant languages it me- plementing features that cannot be expressed by sim- ans that both: tradional, stand-alone Java programs as ple graphical interfaces without losing much of ine- well as enterprise systems run on applicaon servers or grained control and generality provided by a scripting even systems deployed in microservices architecture can language. be considered. Expression evaluaon engines are oen used for purposes like defining document templates, en- Perhaps the most ubiquitous example of such a sy- hancing various stac configuraon formats with dyna- stem is any web browser. The scripting language that mically evaluated snippets or defining data binding for it embeds is of course JavaScript and the browser ser- user interfaces. However, most of these soluons em- ves as an execution environment for scripts. ploy dynamically typed languages and suffer from limi- Embedded scripting enables dynamic loading and ted performance and lack of any concern for security. execution of entire programs. A more lightweight and This effecvely makes it impossible to use expression lan- limited version of scripting engine is an expression guage as a feature exposed to end users. This paper pre- evaluation engine. Instead of scripts that can be long sents a new approach to implemenng an expression en- and complex, an expression engine allows only sim- gine. It uses Scala as the expression language and levera- ple expressions to be evaluated, with no access to con- ges its stac type system as well as its rich feature set structs like loops, deinitions of functions or classes, to create an expression evaluaon engine with expres- etc. Expressions usually consist of method or function sive and concise language, high evaluaon performance invocations and operator applications that operate on and fine grained security control. In the paper we pre- expression input and produce some output data. The- sent use case built for the domain of telecommunicaon refore, unlike script execution, expression evaluation networks. In large telecommunicaon networks one can is usually not allowed to cause any side effects. find hundreds of devices for which configuraon has to be One of the most challenging aspects of embedded updated either periodically or on-demand when a given scripting and expression evaluation engines is secu- event occurs. Contents of configuraon files may have to rity. Loading and executing code provided dynami- be generated dynamically (based on some data associ- cally by some third party poses a serious threat of ated with a given device). On top of that, since commu- letting malicious program execute which could result nicaon networks are heterogeneous environments with in either damage to the host system or unauthorized hardware delivered by different providers, exact form of access to sensitive data. The more freedom a scripting each config file may vary depending on a type of a device engine allows, the harder it is to secure it. An expres- and its manufacturer. Moreover, as structure and size of sion engine is much easier to secure than a full-blown telecommunicaon networks evolve as new devices are embedded scripting engine like browser-embedded added, there is a need to dynamically and remotely sup- JavaScript. port completely new types of devices with a completely A good example of an expression evaluation use new format of configuraon. This paper presents how the case is an expression-enhanced administrative panel. problem can be solved by using configuraon file templa- Such panel may be used, for example, to adjust a greet- tes with placeholders that would be filled by some data ing message that is displayed to users upon logging associated with a given device. Each template is an ex- into a web portal. The message would be conigured pression that evaluates to exact configuraon file. Perfor- as an expression (template) that has access to the data mance is crucial (due to size of network) and so is security: of the user logging in. the soluon should allow to control what kind of configu- Another example could be an administrative inter- raon and by whom may be applied to devices while sll face for massive data processing system where a user allowing network operators to use a Graphical User Inter- could dynamically specify a data crunching job to be face to define (or redefine) configuraon file templates. executed on a large amount of potentially distributed 30 Journal of Automation, Mobile Robotics & Intelligent Systems VOLUME 11, N∘ 3 2017 data (e.g. a map-reduce job). An expression would de- hors to build a domain-speciic language in Scala (that ine actual transformations performed on that data. was used to deine allowed language syntactical con- The domain that authors of this paper focused on structs and calls to control and limit evaluations in when building the real-life use case, though, is tele- terms of security) and to build a real-life, working and communication networks where there is a need to commercially used system that utilizes the evaluation update coniguration of network devices (or provide engine to remotely manage devices in telecommunica- coniguration of newly added devices) in some situ- tion networks. ations such as device reconiguration, device decom- missioning, network topology change etc. The propo- 2. Related Work sed solution has been successfully used to built a de- vice management platform that allows telco operators The paper [19] presents the algorithm for evalu- to monitor and manage devices installed in their net- ating physical expressions and performing automatic works. As mentioned above the system has to work in conversions between quantities measured in different network with virtually unlimited number of devices. physical units. The paper describes CellML - the XML- The devices can be automatically or manually grouped based modelling language that can be used to repre- into hierarchies so that it is possible to manage them sent units and expressions in a way that allows their in bulk but still allowing ine-grained differences bet- easy validation and unit conversion. The authors des- ween conigurations if required. Network devices have cribed the two phases, partial evaluation algorithm. to be reconigured remotely and it can be easily done The solution, although very interesting cannot be used with coniguration iles periodically fetched by devi- in our research as it only provides a part of required ces from management systems. As part of conigura- features. It proposes checking physical units at the le- tion content is attributes (or metadata) of a given de- vel of the modelling language, removing the need for vice, coniguration ile templates can be used. In other the support in the programming language. Also - due words: each template is an expression that evaluates to a nature of the solution - security problems are not to a coniguration ile. In order to adapt to changing to- addressed at all. Similarly, although [23] presents a pology of a network and to be able to support new ty- novel approach to interpretation for abstract equati- pes of devices with a new format of coniguration iles ons using table-driven pattern matching it does not there is a need to provide a user interface to network address security problems and cannot be used to eva- operators allowing them to deine new formats dyn- luate general expressions. amically. The system guarantees a ine-grain security An interesting idea to build an expression evalua- control over information that can/cannot be deined tion engine is to use XQuery as a base and one of avai- in the template. lable XQuery engines as the execution environment. The evaluation engine built is part on an inter- This could be achieved directly in Java - for instance nal scripting language that has to be lexible as both: by using XQuery Processor for Java solution. The pa- format of coniguration expected by a given device per [20] presents XQuery as a very convenient expres- as well as output format used by a given device can sion evaluation engine. The paper summarizes non- vary but should be uniied for end-user experience. By standard applications of XQuery - using it to solve re- end-user we understood network administrators with creational problems and puzzles or - speaking more some technical background. The evaluation engine al- generally - using it as a problem-solving language. lows them to (re)adjust the system for needs of a given A special case of an evaluation engine is regular ex- customer without rebuilding and redeploying the sy- pression searching engine. A regular expression can stem. be understood as a domain speciic language (DSL) This paper describes an attempt to create an ex- that has to deal with text-parsing. There is a vari- pression engine running on the JVM that is good for ety of engines available for Java platform. FIRE/J is use cases like the ones described above. More syste- one of them [21]. What makes the solution unique matically, the essential requirements for such engine is its speed.