Testing and Analysis of Web Applications Using Page Models

Testing and Analysis of Web Applications Using Page Models

Testing and Analysis of Web Applications using Page Models Snigdha Athaiya Raghavan Komondoor Indian Institute of Science Indian Institute of Science Bangalore, India Bangalore, India [email protected] [email protected] ABSTRACT cart := cart [ (p1; q1) (c) Web applications are difficult to analyze using code-based tools user := “none” Add Item Delivery Options because data-flow and control-flow through the application occurs state := “uninit” if (state = “addr_selected”) f cart := new Cart Accepts Product ID p1 If a1 is in a city Accept express option via both server-side code and client-side pages. Client-side pages and quantity q g (a) 1 user are typically specified in a scripting language that is different from := u1 state = “logged_in” ? state state , := “logged_in” state := “addr_selected” the main server-side language; moreover, the pages are generated addresses := registered “addr_selected” ? (h) (g) dynamically from the scripts. To address these issues we propose addresses of u1 (d) a static-analysis approach that automatically constructs a “model” Login Select Address (b) state f Accepts username u1 (e) if ( = “logged_in”) of each page in a given application. A page model is a code frag- Displays user’s addresses and password pw1 ment in the same language as the server-side code, which faithfully user := “none” in a drop-down list. cart new Cart := (f) Accepts a selection a1. over-approximates the possible elements of the page as well as the state := “uninit” g control-flows and data-flows due to these elements. The server-side state , “logged_in” ? state := “uninit” code in conjunction with the page models then becomes a standard Error page (non-web) program, thus amenable to analysis using standard code- based tools. We have implemented our approach in the context of Figure 1: An illustrative web application J2EE applications. We demonstrate the versatility and usefulness of our approach by applying three standard analysis tools on the resultant programs from our approach: a concolic-execution based model checker (JPF), a dynamic fault localization tool (Zoltar), and key focus for a large part of the software development commu- a static slicer (Wala). nity. Yet, the problem of automated code-based analysis of web applications remains a challenge, for the following key reasons: (1) CCS CONCEPTS Client-side pages and server-side code are both responsible for pro- viding the overall functionality of the application, but are typically • Information systems → Web applications; • Software and implemented using different languages and technologies. (2) Client- its engineering → Automated static analysis; Dynamic anal- side pages are generated dynamically by server-side code based on ysis; Functionality; the contents of server-side state, yet are responsible for key control- flow data-flow links within the application overall. In other words, KEYWORDS client-side pages conceptually resemble self-modifying code, which JSP; Web Applications; Static Analysis is very hard to analyze. (3) User interactions need to be accounted for. ACM Reference format: Snigdha Athaiya and Raghavan Komondoor. 2017. Testing and Analysis of Web Applications using Page Models. In Proceedings of 26th International 1.1 Motivating Example Symposium on Software Testing and Analysis , Santa Barbara, CA, USA, July Figure 1 shows schematically a simplified e-commerce web applica- 2017 (ISSTA’17), 11 pages. tion that we use as a running example throughout this paper. Each https://doi.org/10.1145/3092703.3092734 rectangle represents a page, with its title (underlined) at the top, and with its main responsibility described in English after the title. 1 INTRODUCTION Edges in the figure represent traversal paths between pages, either via clickable links or via form submissions. Web applications belonging to fields such as banking, e-commerce, Each “Accept” verb in a page description is shorthand for a text- health management, etc., have widespread uses, and constitute the box or a drop-down list. Subscripted symbols such as p1, q1, pw1, etc., denote values that are passed by each page to the server in Permission to make digital or hard copies of all or part of this work for personal or request parameters classroom use is granted without fee provided that copies are not made or distributed the form of whenever an edge out of the page is for profit or commercial advantage and that copies bear this notice and the full citation traversed. on the first page. Copyrights for components of this work owned by others than ACM The variables in typewriter font, namely, user, state, addresses, must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a and cart, are session attributes. The server maintains a separate fee. Request permissions from [email protected]. copy of these variables for each user’s current session, with the ISSTA’17, July 2017, Santa Barbara, CA, USA lifetime of these variables being the entire duration of the session. © 2017 Association for Computing Machinery. ACM ISBN 978-1-4503-5076-1/17/07...$15.00 The annotations on some of the edges in the figure indicate https://doi.org/10.1145/3092703.3092734 the server-side actions that are performed when these edges are ISSTA’17, July 2017, Santa Barbara, CA, USA Snigdha Athaiya and Raghavan Komondoor 1 <c : choose > of the JSP page specification for the page titled “Select Address” 2 <c : when t e s t =“${state==‘ l o g g e d _ i n ’}”> in Figure 1. This JSP specification is processed at the server side addresses 3 <c : forEach var =“addr” i t e m s =“${ }”> whenever the user clicks the link (e) in Figure 1. We describe below 4 <a href = “DeliveryOptions.jsp?address=${addr}”> 5 Select ${addr} </a> informally the meaning of the JSP specification, and the steps taken 6 </ c : forEach > at the server-side to process it. 7 <c : s e t var =“state” value=“addr_selected”/> First, the session attribute state is checked in Line 2 in the JSP 8 </ c : when> specification to see if it has value ‘logged_in’. If this check passes, it 9 <c : otherwise > indicates that the current user has logged in successfully previously. 10 <a href=“Login.jsp”> You are not logged in </a> 11 <c : s e t var =“state” value=“uninit”/> (When the user would have previously successfully logged in, then, 12 </ c : otherwise > as depicted next to link (d) in Figure 1, the server-side code would 13 </ c : choose > have set state to value ‘logged_in’ and would have also populated addresses with the addresses of the just logged-in user. For brevity, Figure 2: SelectAddress.jsp we have not shown this server-side code.) Reverting back to the page specification in Figure 2, the constructs within “${” and“}” are called EL expressions. These are used in JSP to refer to session traversed; e.g., when the user traverses from the “Login” page to the attributes, and, to test conditions and to compute expressions over “Add Item” page, the session attribute user gets set in the server session attributes as well as JSP local variables. Next, the loop in to the user-name u1 that the user entered in the Login page’s user- Lines 3-6 emits dynamically a set of HTML links, with each link name text box (u1 gets passed to the server by the Login page as a containing an assignment of the request parameter ‘address’ to request parameter). one of the addresses in addresses. The idea is that the user who Some of the edges have a guard on them; e.g., the link (g) from views the “Select Address” page can click the link that contains “Select Address” has the guard ‘state = “logged_in”’. What this the address to which they want to schedule delivery. (In practice, means is that the form/link via which this edge is traversed is a form with a drop-down list containing all the addresses would placed by the server in the “Select Address” page only if this guard have been used in this scenario rather than a set of links.) Line 7 evaluates to true on the server-side during the (dynamic) generation uses the JSP tag c:set to set the session attribute state to contain of this page. the value “addr_selected”. On other hand, if the check in Line 2 In this paper, we address the problem of code-based (i.e., white- does not pass, lines 9-12 specify that a link to the “Login” page is box), end-to-end analysis of web applications. For instance, a devel- required (instead of links to the “Delivery Options” page); in this oper may want to use a property checking approach such as concolic case, Line 11 sets state to “uninit”. Finally, after all the updates execution [14] to check whether the application could ever vio- to the session-attributes and generation of HTML corresponding late the property that the address a1 that is used in the “Delivery to the “Select Address” page as mentioned above are completed at Options” page will always be a registered address of the currently the server-side, the thus generated HTML page is sent to the user’s logged-in user. Note that if a bug in the application can cause some browser. other user’s address to appear here, then it would be an erroneous outcome – the items could get shipped to a user who did not or- 1.3 Illustration of Challenges in Analysis der the product unless the user happens to notice the mistake on the web page. Another developer may want to use the static pro- The example above illustrates a few features of pages and page gram slicing [31] operation to determine the statements throughout specifications that pose challenges to any approach that aimsto the application’s code that affect the address being passed tothe perform end-to-end whitebox analysis of web applications: “Delivery Options” page.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    11 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us