Developing a Common Web Interface to Various Verification Tools
Total Page:16
File Type:pdf, Size:1020Kb
Developing a common web interface to various verification tools Bachelor's Thesis Report Roland Meyer [email protected] Supervised by: Malte Schwerhoff Prof. Dr. Peter M¨uller ETH Z¨urich July 27, 2012 Abstract This Bachelor's thesis introduces Tuwin, a system that allows a user to try out a command-line based tool, e.g. a verification tool or a program analyzer, online, without having to install it. This is achieved by giving such tools a common web interface similar to Microsoft Research's rise4fun [1], such that users can execute the tools from their browsers. The system consists of three parts; a central server, a graphical web interface and a number of remote web applications, the tool hosters, where each of them hosts a tool. A user can send input data such as source code to the server which redirects it to the corresponding tool hoster. The tool hoster executes its tool with the user's input and eventually returns its output through the server to the user. All communication between the three components uses standard HTTP/1.1 and messages are JSON [2] or MIME encoded. The server relies on a database for logging and both the server and the tool hoster are configurable through a configuration file. Through this file the tool hoster supports features such as user-selectable command-line parameters, multiple output files of different types, e.g. images or PDF files, or syntax highlighting the input text. Contents 1 Introduction 2 1.1 Motivation . .2 1.2 Goals . .2 1.3 Outline . .3 2 System Overview 3 3 User interface 4 3.1 Admin page . .7 4 Execution Example 8 5 Implementation 10 5.1 User Interface . 10 5.2 Tool Hoster . 11 5.2.1 Configuration . 12 5.2.2 Languages . 16 5.2.3 Examples . 16 5.2.4 Options . 17 5.2.5 Results . 18 5.3 Tuwin Server . 20 5.3.1 Configuration . 21 5.3.2 Database . 22 5.3.3 Permalinks . 22 5.4 Error handling . 23 5.4.1 Error messages and classes . 23 5.4.2 Logging and displaying errors . 24 6 Communication Protocol 25 7 Quality Assurance 28 7.1 Project management . 28 7.2 Documentation . 28 7.3 Testing . 28 7.3.1 Unit tests . 28 7.3.2 Stress tests . 28 7.3.3 UI compatibility . 31 7.4 Security . 31 8 Conclusions 31 8.1 Future Work . 32 8.2 Acknowledgments . 33 A Database tables 36 B List of Error Codes 39 1 1 Introduction 1.1 Motivation Many research groups in computer science develop various tools such as code verifiers, compilers or program analysers. These tools are often not officially released, i.e., they are not available in a stable major version since they are under constant development. There may be frequent or unforeseen changes to the APIs, and dependencies and build processes may not be thoroughly documented. This can make it difficult for people interested in using these tools as they have to keep track of the latest version and find out how to build and use it, or they might not even be allowed to install the tool due to legal issues. 1.2 Goals The goal of this Bachelor's thesis was to develop a web service that would allow an interested user to find a command-line based tool and use it without having to download and install it on his/her own computer. The web service should work in a similar way to Microsoft Research's rise4fun [1]. The user interface should be easy to understand and easy to use, such that a user could find a tool, enter their code and run it with just a few clicks. A tool developer should be able to add his/her tool to the service with as little effort as possible. The system should be configurable such that it can adapt well to many different tools. A tool developer should have the possibility to provide example input code to their users as well as to allow them to use command-line parameters. Tools that produce multiple output files should be supported. The communication in the system should use a well-defined protocol. Output from a tool should be displayed to the user as soon as it is available, i.e., intermediate results have to be visible. All user input and output from the tools, as well as errors, should be logged in a centralized way to allow debugging. The web service was to be implemented in the Scala programming lan- guage [3] and the implementation was to be well-documented and thoroughly tested to facilitate future maintenance. Security and performance were no key issues but were considered throughout the course of the project. 2 1.3 Outline The product of this Bachelor's thesis is called the Tuwin system or Tuwin for short. It stands for Tool Use Without Installation. Section 2 gives an overview of the Tuwin system and explains its components. Section 3 shows screenshots of the user interface and explains how it is used. Section 4 shows an execution example to give an impression of how the components com- municate and section 5 discusses implementation details. Section 6 explains the Tuwin communication protocol in detail and is followed by section 7 dis- cussing quality assurance and finally section 8 which concludes the report with a brief discussion about future work. 2 System Overview The Tuwin system consists of three conceptual components; the user inter- face, the server and the tool hosters (figure 1). Communication Communication (HTTP and JSON) (HTTP and JSON) Config file Tuwin Server Tool Hoster A UI Config file Tool Hoster B Config file Database Config file Tool Hoster C Figure 1: The components of Tuwin The Tuwin tool hoster is a web application of which a developer can install an instance on his computer and configure it to use a tool that he/she developed and installed on the same machine. In this way the tool hoster provides a web interface to that tool, allowing external users to feed input to it and receive back output. There may be a large number of tool hosters in the system, one for each tool. The Tuwin tool hoster is a sample implementation of a tool hoster, designed to be as generic as possible, but tool developers are not bound to use it. Instead they may want to use their own implementation which behaves according to the communication protocol. The Tuwin server is the central unit. It serves as a mediator between the users and the tool hosters by providing a user-friendly web interface 3 (see section 3). The server redirects user requests to the corresponding tool hosters and monitors the execution there by polling. It relies on a database to log input, output, and errors. Even though it may be a bottleneck, there are a number of reasons why the server is used as a middle-man. By not letting the user interface communicate directly with the tool hosters the server can ensure that all communication with the tool hosters correspond to the protocol. This is both a security measure as well as a measure of making sure that the logging works correctly. It also adds flexibility because tool hosters can be exchanged without the users noticing. The communication between the three components uses standard HTTP and JSON [2] encoded messages, as well as file downloads. Both the server and the tool hosters are configured through a JSON encoded configuration file. In this report the terms tool hoster and (Tuwin) server may refer to the components as such or to the computers they are running on. The user interface or UI is part of the server but is treated as a separate component because its code is executed on the client, i.e., the user's computer. When a user enters the Tuwin server's URL in their browser they are presented with a list of all registered tools (figure 2). Upon clicking a tool from this list they are redirected to an editor page (figure 3) where they can enter their input. Once they click the \Run" button this input is sent to the server using its HTTP interface. The term HTTP interface refers to a component's set of HTTP paths used for communication and is not to be confused with the user interface. The server forwards the request to the tool hoster's HTTP interface and the tool hoster executes its tool using the user's input. In order to know when the execution is finished, the server repeatedly polls the tool hoster to find out about the current execution status. The user interface code does the same with the server. As soon as output is available on the tool hoster, the server fetches it and stores it locally. The user interface code then fetches the output from the server and displays it to the user. In this report output is referred to as a result (file) or multiple result files. 3 User interface The first thing users see when they access the Tuwin service in their browsers is the tool selection page (figure 2). It contains a list of available tools and each tool is presented as a clickable box with its name and description inside. On top of these boxes there is an input field which can be used to filter the tools. 4 Figure 2: Screenshot of the tool selection page When the user selects a tool from the list they are taken to the editor page (figure 3).