andi scharfstein seminar on functional programming 2006
play

Andi Scharfstein, Seminar on Functional Programming 2006 Why are we - PowerPoint PPT Presentation

Andi Scharfstein, Seminar on Functional Programming 2006 Why are we here? [ Live Demo of the Orbitz Bug : 1. Visit orbitz.com in a web browser 2. Open multiple fl ights in multiple windows ] 3. T ry to book a fl ight. Regardless of which


  1. Andi Scharfstein, Seminar on Functional Programming 2006

  2. Why are we here?

  3. [ Live Demo of the „ Orbitz Bug “ : 1. Visit orbitz.com in a web browser 2. Open multiple fl ights in multiple windows ] 3. T ry to book a fl ight. Regardless of which fl ight was selected in your window, the fl ight that will be booked will always be the fl ight from the most recently opened window ( even if it was closed in the meantime )]

  4. W e want to fi x such bugs!

  5. Constructing the Model W eb Server Client

  6. The W eb Server W eb Server Client

  7. The W eb Server • Internal storage flight 815 • Consists of key/value pairs • Represented by σ : Key → V dest. SF alue • Describes server state ... ... W eb Server Client

  8. The W eb Server • Internal storage flight 815 • Consists of key/value pairs • Represented by σ : Key → V dest. SF alue • Describes server state ... ... • Scripts ( dynamic pages, forms ) Scripts W eb Server Client

  9. The W eb Server • Internal storage flight 815 • Consists of key/value pairs • Represented by σ : Key → V dest. SF alue • Describes server state ... ... <?php display - for i in fl ights display ( i ) fl ights.htm end> Scripts ... ... W eb Server Client

  10. The W eb Server • Internal storage flight 815 • Consists of key/value pairs • Represented by σ : Key → V dest. SF alue • Describes server state ... ... • Scripts ( dynamic pages, forms ) Scripts • Lookup function P: URL → Form W eb Server Client

  11. The Client flight 815 dest. SF ... ... Scripts W eb Server Client

  12. The Client flight 815 Current dest. SF • Active page form ... ... Scripts W eb Server Client

  13. The Client flight 815 Current dest. SF • Active page form ... ... • Browser cache Scripts • All previously ... ... ... seen forms W eb Server Client

  14. Forms <html> <form action= ‘ book -fl ight.html ‘ > <input name= ‘fl ight ‘ type= ‘ text ‘ value= ‘ 815 ‘ > <input name= ‘ destination ‘ type= ‘ text ‘ value= ‘ San Francisco ‘ > <input name= ‘ submit ‘ type= ‘ submit ‘ value= ‘ Submit! ‘ > </form> </html>

  15. Forms <html> <form action= ‘ book -fl ight.html ‘ > <input name= ‘fl ight ‘ type= ‘ text ‘ value= ‘ 815 ‘ > Representation: <input name= ‘ destination ‘ type= ‘ text ‘ URL: book -fl ight.html value= ‘ San Francisco ‘ > <input name= ‘ submit ‘ flight 815 type= ‘ submit ‘ value= ‘ Submit! ‘ > San destination Francisco </form> </html>

  16. Supported Actions • Users may do any of the following at any time: - Enter data into the current form - Switch to a cached page ( e.g., click on the back button ) - Submit a form

  17. What happens, when... • Users enter form data: - The key/value vector of the form is modi fi ed to store the updated value URL: book -fl ight.html flight 816 San destination Francisco

  18. What happens, when... • Users enter form data: - The key/value vector of the form is modi fi ed to store the updated value - The updated form is added to the browser cache Current URL: book -fl ight.html flight 816 San destination ... ... ... Francisco

  19. What happens, when... • Users switch to some form: Current form - The new form is set as the client ‘ s „ current page “ ( but only if it ‘ s found in the cache ) ... ... ...

  20. What happens, when... • Users submit a form?

  21. Form Submissions flight 815 Current Current dest. SF form form ... ... Scripts ... ... ... ... W eb Server Client

  22. Form Submissions • Server computes the new form flight 815 Current Current dest. SF form form ... ... Scripts ... ... ... ... W eb Server Client

  23. Form Submissions • Server state ( storage ) is updated flight 815 Current Current dest. SF form form ... ... Scripts ... ... ... ... W eb Server Client

  24. Form Submissions • Client ‘ s „ current page “ is set to the new form flight 815 Current dest. SF form ... ... Scripts ... ... ... ... W eb Server Client

  25. Form Submissions • New form is added to client ‘ s browser cache flight 815 Current dest. SF form ... ... Scripts ... ... ... W eb Server Client

  26. Attention, Mini - Test! How does switching work again? Explain. Current form ... ... ...

  27. Attention, Mini - Test! How does switching work again? Explain. „ Rewriting “ describes the transition directly and precisely: Current form ➝ <s, <f , f >> ⁰ ➝ <s, <f , f >> ➞ ➝ ¹ where ¹ f f ∈ ... ... ...

  28. Scripting Language • Use identi fi ers, variables • Create functions • Apply functions • Create new forms • Extract values from forms ( via keys ) • Basic I/O ( Server storage read/write )

  29. Scripting Language • Use identi fi ers, variables • Create functions • Apply functions • Create new forms • Extract values from forms ( via keys ) • Basic I/O ( Server storage read/write )

  30. Modelling the Bug Show flight - Flights dest. - ... ... Scripts W eb Pages W eb Server

  31. Modelling the Bug Show flight - Flights dest. - ... ... Flight 1 Details Scripts W eb Pages W eb Server

  32. Modelling the Bug Show 815 flight Flights dest. SF ... ... Flight 1 Details Scripts W eb Pages W eb Server

  33. Modelling the Bug Show 815 flight Flights dest. SF ... ... Flight 1 Flight 2 Details Details Scripts W eb Pages W eb Server

  34. Modelling the Bug Show 1632 flight Flights dest. SF ... ... Flight 1 Flight 2 Details Details Scripts W eb Pages W eb Server

  35. Modelling the Bug Show 1632 flight Flights dest. SF ... ... Flight 1 Flight 2 Details Details Scripts Book Flight W eb Pages W eb Server

  36. Modelling the Bug Show 1632 flight Flights dest. SF ... ... Flight 1 Flight 2 Details Details Scripts Book Flight W eb Pages W eb Server

  37. Explaining the Bug • Obviously, submitting „ outdated “ forms causes undesired behaviour • The HTTP Observer Problem: Server cannot „ push “ updates to the client ( as in MVC ) ➡ At least produce warnings when detecting outdated requests

  38. Detecting outdated requests flight 815 3 dest. SF 1 • Server needs a notion of time: ... ... ➡ Model as number of submits time 4 • Storage records time of last write for each fi eld Scripts

  39. Detecting outdated requests • Introduce „ carrier sets “ into forms: All locations accessed by this script • Each form stores its creation time flight 815 3 URL: book -fl ight.html dest. SF 1 time 4 carriers ... ... ... time 4 flight 815 San destination Francisco Scripts

  40. Detecting outdated requests • Whenever a form is submitted, check its carrier set against current storage state and compare time stamps • The carrier set represents the assumptions the script made while working • If any location from this set was overwritten, script assumptions may have been violated

  41. Thank you! • W e have built a comprehensive, yet simple model of web interactions • Three basic semantic rules su ffi ce to describe all possible user actions: - „ switch “ - „fi ll - out “ - „ submit “ • Any questions?

  42. References • Shriram Krishnamurti, Robert Bruce Findler, Paul Graunke, Matthias Felleisen: „ Modeling W eb Interactions and Errors “ ( 2004 ) • Daniel R. Licata, Shriram Krishnamurthi: „ V erifying Interactive W eb Programs “ ( 2005 )

  43. Addendum: Fun with Types • Make forms typed! • Enables static checks for common bugs, like trying to access form data that never got submitted • Also enables us to give some other safety guarantees • But: How to keep track of types in a dynamic setting?

  44. Incremental Type Checking • Uses constraints along with regular type judgements • Constraints are introduced by creating forms: - The successor url of any form must contain a program that takes as input exactly the data ( type ) of that form • Otherwise, forms behave essentially like records

  45. Consistency • Consistency is achieved by checking that all types registered for some form at a particular URL are equivalent • Since type constraints can be introduced by the regular type system as well as by additional constraints, this is not always the case • If the types are not consistent, refuse to execute the script

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend