300 likes | 443 Views
Relational Constraint Driven Test Case Synthesis for Web Applications. Dr. Xiang Fu Assistant Professor Department of Computer Science Hofstra University. Outline. Introduction Path Transducer Model Relational Constraint Call Sequence Synthesis Detecting Workflow Attack
E N D
Relational Constraint Driven Test Case Synthesis for Web Applications Dr. Xiang FuAssistant ProfessorDepartment of Computer ScienceHofstra University
Outline • Introduction • Path Transducer Model • Relational Constraint • Call Sequence Synthesis • Detecting Workflow Attack • Related Work and Conclusion
Web Application and Database Databases Web Server
Testing Web App & DB • Traditionally, SQLUnit & DBUnit • ManualTest Case Design • Reverse Inference of DB State • Given Query & Expected Result • Generate Initial DB Instance • Our Problem: Synthesis Problem • Given Database State • Synthesize Call Sequence of Servlets
Our Proposal • White-box Analysis • (1) Interface Extraction Path Transducers • (2) Coverage Goal Extraction • (3) Call Sequence Generation • Adaptation Discover Workflow Attacks
Path Transducer Model • Servlet Path Transducers • Relational Transducer that Models One Execution Path • Path Condition • Side Effects to DB Servlet
Path Transducer Model • Relational Data Schema • Input Domain • Finite Set of Session Variables • Boolean Combination of Terms • Equality • v’ = v + 1 • Satisfiability Check
Relational Algebra Formula • Selection • Projection • Cross Product • Union • Difference
Motivating Example SimpleScarf Login.php ShowSessions.php GenOptions.php AddMember.php InsertSession.php
Database Schema Users Sessions vchar uname intsid vcharpwd vcharsname Members intsid vchar uname
Path Transducer of ShowSession • Check Valid Session Var#uname • Select Session Info • No Side Effects
InsertSession.php • User Specify New Session Name $SI • Update Relation Sessions
AddMember.php • Takes Two Parameters • $uA: User Name • $sA: Session Name • Add Membership Info
Generaloptions.php • Add User: One of Many Functions Available • Takes Two Parameters • $uG: User name • $pG: Password Encrypt Password Password Rules Encoded Using String Constraint
Login.php • Given Two Parameters • $uL: user name • $pL: password • When Success, Update Session Variable • #u: Session Variable on user name
Solving Relational Constraint • Key to Synthesis • Khurshid’s Approach [ASE’08] • Translate to Alloy
Pre/Post Images Post Image Transition System
Key Problem: Satisfiability Check Join of Session and Membership Select Session Name ‘s1’ Project to uname Find users in paper session ‘s1’ but not in ‘s2’ Goal: Find DB Instance Satisfies query
Call Sequence Synthesis Coverage Goal: Line # 45 CALL SeqSynthesis Algorithm List of HTTP Requests Path Transducers
Heuristic Algorithm • Knowledge In Advance: • (1) Each Path Transducer – Transition System (Relational Logic) • (2) Relations being Modified (add, drop, modify) • (3) Session Varsbeing Modified • Algorithm: Backtrack ϒ’ = Pre(H’, ϒ) Current Constraint Heuristic to pick to the next servlet: watch the difference between the relations in the current constraints and target constraints. “Insertion” has priority HTTP Request (Η’,ϒ’) (Η,ϒ)
Example: Coverage Target Coverage Goal Target Constraint: True Initial Constraint: Path Transducer:
Pre-Image Computation Transition Post-Image Standard Existential Quantification M and #u modified! Next servlet: AddMember or Login Compare Initial Constraint:
Constraint in Last Step 1.07 seconds for generating the model by ALLOY
Workflow Attack EnterAddr ChargeCC GenReceipt PrintShipping How to Detect Workflow Attack? Static Analysis for ALL URLS that could be generated by a servlet Modify the Backtrack algorithm for locating an “abnormal” link not in the ALL_URLs set Database manipulation TAKEN CARE OF.
Conclusion • Proposal of Several Interesting Directions • Extraction of Path Transducer Model • Solving Relational Constraints • Call Sequence Synthesis Algorithm • Extension for Detecting Workflow Attacks • Future Directions • Implementation …
Related Work • Interface Extraction • [Halfond’FSE07], [Halfond’FSE’08] • Relational Transducer • [Abiteboul’JCSS00] • Query Aware Relational Constraint Solving • [Binnig’ICDE07, Khalek’ICSE08] • Session Based Testing of Web App • [Elbaum’TSE05, Sampath’ASE05, Sprenkle’FSE05]