Title: Programming the Interactive Web
1(No Transcript)
2(No Transcript)
3(No Transcript)
4(No Transcript)
5(No Transcript)
6(No Transcript)
7(No Transcript)
8(No Transcript)
9(No Transcript)
10(No Transcript)
11(No Transcript)
12(No Transcript)
13Popular Press
- But when I clicked on the National car rental
price , the site responded with this message
You have back-buttoned too far. This was my
first experience with back-button as a verb.
Since that was patently untrue, I decoded
its true meaning We ran out of cars. - M. Slatalla, New York Times, 2003-07-17
14A Headache for Companies
- Minor problem Users might get booked into the
wrong hotels, onto the wrong flights, etc. - Major problem People might embarrass you in
newspapers and in public talks
15Programming and Verifying the Interactive Web
- Shriram Krishnamurthi
- Brown University
16Where You See This
- URLs become simple
- https//onepass.continental.com/asp/statement.asp
- URLs become complex
- http//maps.yahoo.com/py/ddResults.py?PytTmapta
rnametardescnewnamenewdescnewHashnewTHas
hnewStsnewTStstlttlnsltslnnewFLUse
AddressBelownewaddr3007SantaMonicaBoulevard
newcszsantamonica,canewcountryusnewTFLUseA
ddressBelownewtaddr2815SantaMonicaBoulevard
newtcszSantaMonica,CA904042409newtcountryus
SubmitGetDirections
17Programming InteractiveWeb Scripts
18Adding Two Numbers(Console)
- n1 read Enter first
- n2 read Enter second
- print
- sum d\n
- (n1 n2)
- exit
19Two User Interfaces
Enter first
Enter second
20Interacting with Web Scripts
21Interacting with Web Scripts
22Interacting with Web Scripts
23Interacting with Web Scripts
24Interacting with Web Scripts
25Interacting with Web Scripts
26Program Transformation
- n1 read
- Enter first
- n2 read
- Enter second
- print
- sum d\n
- (n1 n2)
- exit
- n1 read/web
- ltformgtEnter first lt/formgt
- n2 read/web
- ltformgtEnter second lt/formgt
- print
- ltpgtsum
- (n1 n2)lt/pgt
- exit
27A Central Problem
- Web scripts write a page, then terminate (ie, the
stack is erased) - When the user replies, another script reads the
forms bindings and performs the next step (ie,
it must restore the stack)
28Consequently
n1 read/web ltformgtEnter first lt/formgt n2
read/web ltformgtEnter second lt/formgt print
ltpgtsum (n1 n2)lt/pgt exit
29More Program Transformation
- n1 read/web
- ltformgtEnter first lt/formgt
- n2 read/web
- ltformgtEnter second lt/formgt
- print
- ltpgtsum
- (n1 n2)lt/pgt
- exit
- Main () print
- ltform actionf1gt
- Enter first
- ltinput namen1gt
- lt/formgt
- f1 (form) print
- ltform actionf2gt
- ltinput hidden namen1
- valueform.n1gt
- Enter second
- ltinput namen2gt
- lt/formgt
- f2 (form) print
- The sum is
- form.n1 form.n2
30Problems
- Generating the programs is taxing
- Programmer must manually track numerous
dependencies - Mistakes have frustrating consequences(or
silently introduce dynamic scope)
31Observation
n1 read/web ltformgtEnter first lt/formgt n2
read/web ltformgtEnter second lt/formgt print
ltpgtsum (n1 n2)lt/pgt exit
n1 read/web ltformgtEnter first lt/formgt n2
read/web ltformgtEnter second lt/formgt print
ltpgtsum (n1 n2)lt/pgt exit
32The Key Insight
- The manual decomposition
- implements the
- continuation-passing style
- transformation!
33In More Detail
- Technically, it composes
- transformation of code into continuation-passing
style - lambda-lifting
- closure-conversion
- Each of these has a formal, correctness-preserving
foundation
34An API With Heavy Lifting
- APIs offer form, cookie, c primitives
- Build a richer API with read/web
- Programmers
- Stand up for your rights
- make language designers work harder!
35Two Approaches to a Better API
- A Web compiler that
- Automatically splits programs by form
- Automatically propagates fields
- Guarantees behavior preservation
- Direct support from the languageserver
36Web Programming in PLT Scheme
37The Real Primitive
- read/web lies slightly
- n1 read/web
- ltform action???gtEnter firstlt/formgt
- We provide send/suspend
- n1 send/suspend k
- ltform actionkgtEnter firstlt/formgt
send/suspend generates the URL that resumes
computation
38Generated URLs
- send/suspend generates a URL of the form
- http//host/servlets/pc-member.scmid28129579972
5 - In more detail
- http//
- host/servlets/
- pc-member.scm
- id281295799725
39Addition Servlet
- n1 send/suspend k
- ltform actionkgtEnter firstlt/formgt
- n2 send/suspend k
- ltform actionkgtEnter secondlt/formgt
- print
- ltpgtsum
- (n1 n2)lt/pgt
- exit
40Addition Servlet
http//host/servlets/add.scmid281295799725
- n1 send/suspend k
- ltform actionkgtEnter firstlt/formgt
- n2 send/suspend k
- ltform actionkgtEnter secondlt/formgt
- print
- ltpgtsum
- (n1 n2)lt/pgt
- exit
41Addition Servlet
http//host/servlets/add.scmid281348792908
with memory of the value of n1
- n1 send/suspend k
- ltform actionkgtEnter firstlt/formgt
- n2 send/suspend k
- ltform actionkgtEnter secondlt/formgt
- print
- ltpgtsum
- (n1 n2)lt/pgt
- exit
42Interacting with Web Scripts
/add.ssid17k3959569765
n1 1729
/add.ssid17k11058911710
43Applications
- Weve done more than just add numbers
44The CONTINUE Server
- Conference submission/review manager
- Used by several conferences Softvis 2005, CSFW
2005, FOAL 2005, ISSTA 2004, LMO 2005, TAV-WEB
2004, PADL 2004/3/2/1, FDPE 2003, Scheme 2003/2,
...
45Scenario
46Email Confirmation Servlet
- addr send/suspend k
- ltform actionkgtEmaillt/formgt
send/suspend k ignore response send_mail
(addr, k) ltpgtWe sent mail to addrlt/pgt
add_to_database (addr)
47Scenario
48Scenario
49One-Shot Guest URLs
- guest_review
- send/suspend k
- ltform actionkgt
- Overall Rating ltinput gt
- Expertise ltinput gt
- lt/formgt
50One-Shot Guest URLs
- guest_review
- send/finish k
- ltform actionkgt
- Overall Rating ltinput gt
- Expertise ltinput gt
- lt/formgt
51The Subtlety of Interaction
52Whats in a URL?
- Lets go back to this URL
- http//maps.yahoo.com/py/ddResults.py?PytTmapta
rnametardescnewnamenewdescnewHashnewTHas
hnewStsnewTStstlttlnsltslnnewFLUse
AddressBelownewaddr3007SantaMonicaBoulevard
newcszsantamonica,canewcountryusnewTFLUseA
ddressBelownewtaddr2815SantaMonicaBoulevard
newtcszSantaMonica,CA904042409newtcountryus
SubmitGetDirections
53Whats in a URL?
- Lets go back to this URL
- http//maps.yahoo.com/py/ddResults.py?PytTmapta
rnametardescnewnamenewdescnewHashnewTHas
hnewStsnewTStstlttlnsltslnnewFLUse
AddressBelownewaddr3007SantaMonicaBoulevard
newcszsantamonica,canewcountryusnewTFLUseA
ddressBelownewtaddr2815SantaMonicaBoulevard
newtcszSantaMonica,CA904042409newtcountryus
SubmitGetDirections
54Whats in a URL?
- Write it differently
- http//maps.yahoo.com/py/ddResults.py?
newaddr3007SantaMonicaBoulevard - newcszsantamonica,ca
- newcountryus
- newtaddr2815SantaMonicaBoulevard
- newtcszSantaMonica,CA904042409
- newtcountryus
- SubmitGetDirections
55Whats in a URL?
- Or
- http//maps.yahoo.com/py/ddResults.py?
- newaddr 3007SantaMonicaBoulevard
- newcsz santamonica,ca
- newcountry us
- newtaddr 2815SantaMonicaBoulevard
- newtcsz SantaMonica,CA904042409
- newtcountry us
- Submit GetDirections
It looks like a function call!
56The Real Picture
The script and the user are coroutines
Event lines
script
user
57Control Flow Back Button
A silent action!
58Control Flow Cloning
script
user
59Control Flow Bookmarks
60What Programmers Need
- Multiply-resumable and
- restartable coroutines
- Thats what send/suspend really implements
61(No Transcript)
62(No Transcript)
63(No Transcript)
64(No Transcript)
65(No Transcript)
66(No Transcript)
67(No Transcript)
68(No Transcript)
69(No Transcript)
70(No Transcript)
71(No Transcript)
72(No Transcript)
73Question
74Information Flow
- Operations reveal two kinds of information
- local to each copy of a page
- Orbitz hotel selection
- shared by all pages
- Amazon shopping cart
? lexical scope
? mutable state
75Conclusion
76Interactive Web Programs
- Program structure is mangled
- Web interactions are complex
- Semantics provides good foundations
- APIs matter send/suspend is not alone
77Sample of Other Work
- Continuation-passing has significant downside
- doesnt interact well with foreign language code
- destroys the stack ? hurts tools like debuggers
and stack inspectors - Challenge devise a better compilation algorithm
- Result use lightweight stack inspection ICFP 05
78Parting Thoughts
- JavaScript is changing Web applications
- Declarative languages win on the Web
- Keep eating our own dogfood!
-
79Collaborators
- Faculty
- Matthias Felleisen
- Robby Findler
- Matthew Flatt
- Brown Undergrads
- Pete Hopkins
- PhD Students
- Paul Graunke
- Greg Pettyjohn
80Debugging
81Safety Errors
82Safety Errors
83Stepping Through Code
84Stepping Through Code
85Performance
86PLT Web Server/ApacheStatic Documents
- ratio of connections/second
Clients
87PLT Web Server/ApacheInteractive Content
Clients
Clients
1k files
10k files
88Perceived and Measured Costof CONTINUE Server
- Almost as fast with and without caching
- Measurement
-
89Programming and Verifying the Interactive Web
- Shriram Krishnamurthi
- Brown University
90Web Programs
- Two subtleties
- Program structure is mangled
- User can upset programs control-flow
- Continuation-based programming provides a
baseline for tackling these problems now we can
get to semantic errors
91Verifying Temporal Behavior
92The Orbitz Property
- Orbitz Property the user should receive a
reservation at the hotel that was displayed on
the page he submitted - Should all sites behave thus?
93The Amazon Property
- Amazon property at the end, every book the user
added to his shopping cart is actually in his
shopping cart
94Properties
- These properties are
- not fixed in number
- temporal in nature
- ? model checking
95Model Checking
- From source, generate model that captures
behaviors of interest - Consume developers properties
- Automatically check whether or not the model
satisfies the properties
96Model Checking
- From source, generate model that captures
behaviors of interest - Consume developers properties
- Automatically check whether or not the model
satisfies the properties
97Modelling Web Programs
- Model control-flow graph (CFG)
- What would a model of Orbitz look like?
98Modelling Orbitz
display hotel list
set chosen
use chosen to compute displayed
use chosen to compute reserved
display reservation
display details for displayed
99One Browser
AltTab
- How can we model all these operations?
100User Operation Calculus
- Express all browser operations in terms of
primitive operations - submit form to server
- switch to previously-visited page
101The Orbitz CFG
display hotel list
set chosen
use chosen to compute displayed
use chosen to compute reserved
display reservation
display details for displayed
102The Orbitz WebCFG
display hotel list
set chosen
use chosen to compute displayed
use chosen to compute reserved
display reservation
display details for displayed
103Model Checking
- From source, generate model that captures
behaviors of interest - Consume developers properties
- Automatically check whether or not the model
satisfies the properties
104Atomic Propositions
lthtmlgt ltbody bgcoloryellowgt lttablegt lttdgt
ltpgt Residence Inn by Marriot
Charleston Downtown ... lt/htmlgt
105Relating Web Page Contentto Source
- Parse the text?
- Too hard
- Static-distance coordinates?
- Too brittle
- What else can we do?
106Relating Web Page Contentto Source
lthtmlgt ltbody bgcoloryellowgt lttablegt lttdgt
ltp idreservedgt Residence Inn by
Marriot Charleston Downtown ... lt/htmlgt
107Annotating the WebCFG
Annotate each WebCFG state with the propositions
true in that state
lthtmlgt ltbody bgcoloryellowgt lttablegt lttdgt
ltp idreservedgt Residence Inn by
Marriot Charleston Downtown ... lt/htmlgt
generate reservation page
generate reservation text
tagreserved
108Verification Process
- Annotated WebCFG describes the set of traces that
potentially occur - Property defines traces that may occur
- Verification is containment of the former in the
latter - Vardi and Wolper, 1986
109Example Property
- Before reaching an access-controlled page, the
user must go through a password page
Note In properties,tags label transitions
110The Orbitz Property
- Value of reserved comes from the value of
displayed - Value of chosen does not change between
computation of displayed and computation of
reserved
111Orbitz Subproperty 1
- Value of chosen does not change between
computation of displayed and computation of
reserved - Track value mutations
112Orbitz Subproperty 1
Property chosen does not change between the
computation of displayed and the computation of
reserved
(set,chosen) (join,chosen)
1
2
violation
tagreserved
113Orbitz Subproperty 2
- Value of reserved comes from the value of
displayed - Augment tagged propositions for reasoning about
value flow
114Orbitz Subproperty 2
X
Property the value of reserved comes from the
value of displayed
(tagged,displayed,X)
1
2
(tagged,reserved,?X)
violation
(tagged,reserved,??X)
?X
??X
115Model Checking
- From source, generate model that captures
behaviors of interest - Consume developers properties
- Automatically check whether or not the model
satisfies the properties
116The Orbitz WebCFG
display hotel list
set chosen
use chosen to compute displayed
use chosen to compute reserved
display reservation
display details for displayed
117The Orbitz WebCFG
display hotel list
set chosen
use chosen to compute displayed
use chosen to compute reserved
display reservation
display details for displayed
118Algorithm
- NYSTNYD paths
- make state machine precise
- adapt language containment algorithm
- FLAVERS algorithm has constraint automata to
eliminate infeasible paths
119(No Transcript)
120Representative Feature
121Access-Control
- Policy maps ltsubject, action, resourcegtto a
decision (permit, deny, ) - Representation matters
- matrix gets too large
- people play multiple roles
- policies are distributed
- ? policies are becoming software
- New standards include XACML, EPAL, etc.
122System Structure
123System Structure
124Verifying Information Access
125CONTINUE Properties
- Someone not PC Chair or Admin cannot see reviews
for conflicted papers - PC members may edit reviews they own
- Someone not PC Chair or Admin may not set the PC
Meeting flag
126Gradebook
127Running Example
- Roles
- Faculty, Student
- Actions
- Assign, View, Receive
- Resources
- InternalGrades, ExternalGrades
128Properties
- No Student can Assign ExternalGrades
- Faculty can Assign both InternalGrades and
ExternalGrades - No single person can both Receive and Assign
ExternalGrades
129Basic Policy
- Requests for Students to Receive ExternalGrades
succeed - Requests for Faculty to Assign or View
ExternalGrades succeed
130Verify Basic Policy
- Requests for Students to Receive ExternalGrades
succeed - Requests for Faculty to Assign or View
ExternalGrades succeed
- No Student can Assign ExternalGrades
- Faculty can Assign both InternalGrades and
ExternalGrades - No single person can both Receive and Assign
ExternalGrades
131Verify Constrained Basic Policy
- Requests for Students to Receive ExternalGrades
succeed - Requests for Faculty to Assign or View
ExternalGrades succeed - Faculty are disjoint from Students
- No Student can Assign ExternalGrades
- Faculty can Assign both InternalGrades and
ExternalGrades - No single person can both Receive and Assign
ExternalGrades
132Verify Revised TA Policy
- Requests for Students to Receive ExternalGrades
succeed - Requests for Faculty to Assign or View
ExternalGrades succeed - TAs can View and Assign InternalGrades but not
ExternalGrades - Faculty are disjoint from Students
- No Student can Assign ExternalGrades
- Faculty can Assign both InternalGrades and
ExternalGrades - No single person can both Receive and Assign
ExternalGrades
133Verify Family Policy
- Requests for Students to Receive ExternalGrades
succeed - Requests for Faculty to Assign or View
ExternalGrades succeed - TAs can View and Assign InternalGrades but not
ExternalGrades - FacultyFamily can Receive ExternalGrades
- Disjointness constraint
- No Student can Assign ExternalGrades
- Faculty can Assign both InternalGrades and
ExternalGrades - No single person can both Receive and Assign
ExternalGrades
134Margrave Response
- Fails when someone is both Faculty and
FacultyFamily
- No Student can Assign ExternalGrades
- Faculty can Assign both InternalGrades and
ExternalGrades - No single person can both Receive and Assign
ExternalGrades
Spouses can be faculty too!
135Properties?!?
136Policies Without Properties
- Working policy P1
- Modified policy P2
- Testing reveals intended change
- But
137TA Policy Minus Constrained Basic Policy
- Requests for Students to Receive ExternalGrades
succeed - Requests for Faculty to Assign or View
ExternalGrades succeed - TAs have the same privileges as Faculty
- Faculty are disjoint from Students
- Requests for Students to Receive ExternalGrades
succeed - Requests for Faculty to Assign or View
ExternalGrades succeed - Faculty are disjoint from Students
138Output
- Faculty 0 0 0 0 0 0 0 0
- Student 0 0 0 0 1 1 1 1
- ExtGrades 0 0 1 1 0 0 1 1
- IntGrades 1 1 0 0 1 1 0 0
- Assign 0 1 0 1 0 1 0 1
- View 1 0 1 0 1 0 1 0
- Receive 0 0 0 0 0 0 0 0
- TA 1 1 1 1 1 1 1 1
- N N N N N N N N
- 2 2 2 2 2 2 2 2
- P P P P P P P P
139Output
- Faculty 0 0 0 0 0 0 0 0
- Student 0 0 0 0 1 1 1 1
- ExtGrades 0 0 1 1 0 0 1 1
- IntGrades 1 1 0 0 1 1 0 0
- Assign 0 1 0 1 0 1 0 1
- View 1 0 1 0 1 0 1 0
- Receive 0 0 0 0 0 0 0 0
- TA 1 1 1 1 1 1 1 1
- N N N N N N N N
- 2 2 2 2 2 2 2 2
- P P P P P P P P
- Faculty 0 0 0 0
- Student 0 0 1 1
- ExtGrades 0 1 0 1
- IntGrades 1 0 1 0
- Assign 1 1 1 1
- View 0 0 0 0
- Receive 0 0 0 0
- TA 1 1 1 1
- N N N N
- 2 2 2 2
- P P P P
Show cases involving grade assignment
140Output
- Faculty 0 0 0 0
- Student 0 0 1 1
- ExtGrades 0 1 0 1
- IntGrades 1 0 1 0
- Assign 1 1 1 1
- View 0 0 0 0
- Receive 0 0 0 0
- TA 1 1 1 1
- N N N N
- 2 2 2 2
- P P P P
- Faculty 0 0
- Student 0 1
- ExtGrades 1 1
- IntGrades 0 0
- Assign 1 1
- View 0 0
- Receive 0 0
- TA 1 1
- N N
- 2 2
- P P
Show cases involving external grades
141Output
- Faculty 0 0
- Student 0 1
- ExtGrades 1 1
- IntGrades 0 0
- Assign 1 1
- View 0 0
- Receive 0 0
- TA 1 1
- N N
- 2 2
- P P
Show all roles
142Supported Queries
- Restrict by change type (eg, D-gtP)
- Restrict to boolean combinations of specific
roles, actions, resources - List roles, actions, resources occurring in
change - Emptiness
143Implementation
144Possibilities
- Reasoning is largely propositional
- CNF/DNF
- Prolog
- SAT solving (w/ an interface like Alloy?)
- Decision diagrams
145Multi-TerminalDecision Diagrams
- Faculty (f) can assign (a) grades (g)
- Students (s) can receive (r) grades (g)
146Rules and Rule Combination
147Constraints
- Faculty are disjoint from Students
- Exclude (Faculty ? Students)
X
148Policy Differencing
- Decision diagram with 16 terminals
- permit?permit, permit?deny, deny?permit,
deny?not-applicable, - Built from policies using minor variations of
standard decision diagram combinators - Uniform representation is valuable!
149Back to the Case Study
150CONTINUE Performance
- Policy has 50 MTDD variables
- Policy has 1268 nodes (817 w/ constraints)
- Twelve properties each lt 10ms
- Memory 316,288 bytes over baseline
- Change 2ms, 1133 nodes, 16.3Kb memory
151Context
152Temporal problems
Role problems
Instance problems
153Temporal Policies
- Coarse-grained
- Fine-grained
- Dont allow access to a papers other reviews
until the PC member has submitted their own review
Submit
Review
Respond
Meet
154Temporal problems
Changeanalysis
Programanalysis
Role problems
Instance problems
155One Conference Doesnt Fit All
Submit
Review
Respond
Meet
Submit
Review
Respond
Submit
Review
Deliberate
Feedback
Respond
156Conclusion
157Perspective
- Structure of Web source programs matters
- Change query/verification may become a
lightweight formal method - JavaScript affects both forms of verification
- 10ms is interesting
158Parting Thoughts
- Interesting, important verification arena
- New face of multi-lingual programming
- Creating robust (conference) software
159Collaborators
- Brown Undergrads
- Pete Hopkins
- Dan Licata
- Leo Meyerovich
- Michael Tschantz
160- PLT Scheme (DrScheme Environment)
- http//www.drscheme.org/
- CONTINUE (Conference Manager)
- http//continue.cs.brown.edu/
- Margrave (XACML Analysis)
- http//www.cs.brown.edu/ research/plt/software/
margrave/
161The Amazon Idiom
162The Orbitz Idioms