Software Analysis for the Web: Achievements and Prospects
AliMesbah1
1,183 views
45 slides
Mar 14, 2016
Slide 1 of 45
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
About This Presentation
Future of Software Engineering (FoSE) at SANER'16
Size: 6.25 MB
Language: en
Added: Mar 14, 2016
Slides: 45 pages
Slide Content
Software Analysis for the Web:
Achievements and Prospects
Ali Mesbah
University of British Columbia
http://ece.ubc.ca/~amesbah/
2
Web Evolution Challenges
Achievements Prospects
STATIC WEBSITES
File ServerBrowser
HTML
HTTP
Request
Response
HTML
HTML
HTML
HTML
Internet
HTML
DYNAMIC WEBSITES
ServerBrowser
HTML
HTTP
Request
Response
Internet
HTML
Generate
HTML
RESTFUL WEBSITES
Stateless ServerBrowser
HTML
HTTP
Request
Response
Internet
HTML
Generate
HTML
“Principled design of the modern Web architecture”, Fielding and Tylor, ICSE 2000
RICH INTERNET APPS
ServerBrowser
Flash
HTTP
Request
Response
Internet
Flash
Generate
Flash
RIA Plugin
MODERN WEB APPS
Stateless ServerBrowser
Async HTTP
Request
Response
Internet
JSON
Generate
JSON
DOMCSS
JS
Web Apps
9
“write once, run
anywhere”
Instantaneous
software delivery
Web-based services such as and
have changed how people develop
software
10
11
Web Evolution Challenges
Achievements Prospects
JavaScript: the Difficult Parts
1.Dynamic and weakly-typed
•types can change dynamically
•objects/functions can change
•First-class functions
2.Event-driven
3.Asynchronous callbacks
4.Prototype-based
•objects inherent from objects
•can be redefined at runtime
5.Constructs such as eval
6.Interactions with DOM
7.Interpreted (not compiled)
8.…
Make Software
Analysis Challenging
13
14
Web Evolution Challenges
Achievements Prospects
18
checkPrice()
XHR
updateItem()
suggestItem()
getUpdatedPrice() calculateTax()
addTaxToPrice()
Function
XHR object
DOM
element
Directed and
labeled edge
Static analysis
Dynamic analysis
checkPrice()
XHR
updateItem()
suggestItem()
getUpdatedPrice() calculateTax()
#item231
#price-ca
.price
displaySuggesCon()
Function
XHR object
DOM
element
Directed and
labeled edge
Hybrid analysis
checkPrice()
XHR
updateItem()
suggestItem()
getUpdatedPrice() calculateTax()
addTaxToPrice()
#item231
#price-ca
.price
displaySuggesDon()
Function
XHR object
DOM
element
Directed and
labeled edge
24
Web Evolution Challenges
Achievements Prospects
Cross-Language Analysis
We don’t know how to infer proper
control flow graphs for web code.
Stateless ServerBrowser
Async HTTP
Request
Response
Internet
JSON
JS, Java,
PHP, Ruby,
etc
DOMCSS
JS
Cross-Language Program Slicing
Nguyen et al, FSE’14
Cross-Language Bug Detection
Ocariza et al, ICSE’15
Programmer Support in IDEs
•Code completion
•Refactoring
•Bug alerts
•Smell detection
Web Programmer Support in IDEs
•Code completion
•Refactoring
•Bug alerts
•Smell detection
Callback Hell
Refactoring to Promises
Test Case Maintenance
We need better:
Web element locators
Repair techniques
Benchmarks for Comparison
33
SIR
Defect4J
BugBench
?
DroidBench
Empirical Studies
Web analysis tools mainly built by reading best
practices or through developer intuition and
anecdotal observation
Example: what are the most common cross-project bug
patterns in web code?
40
@Test
public void testAddNote(){
get("http://localhost:8080/theorganizer/");
findElement(By.id("logon_username")). sendKeys("user");
findElement(By.id("logon_password")). sendKeys("pswd");
findElement(By. cssSelector("input type ="image"")).click();
assertEquals("Welcome to The Organizer!", closeAlertAndGetItsText());
findElement(By.id("newNote")). click();
findElement(By.id("noteCreateShow_subject")).sendKeys("Running Example");
findElement(By.id("noteCreateShow_text")).sendKeys("Create a simple running example");
findElement(By. cssSelector("input type ="image"")).click();
assertEquals("Note has been created.", findElement(By.id("mainContent")). getText());
findElement(By.id("logoff")).click();
} +PKVKCN/QFGN
'ZVGPFGF/QFGN
@Test
public void testAddNote(){
get("http://localhost:8080/theorganizer/");
findElement(By.id("logon_username")). sendKeys("user");
findElement(By.id("logon_password")). sendKeys("pswd");
findElement(By. cssSelector("input type ="image"")).click();
assertEquals("Welcome to The Organizer!", closeAlertAndGetItsText());
findElement(By.id("newNote")). click();
findElement(By.id("noteCreateShow_subject")).sendKeys("Running Example");
findElement(By.id("noteCreateShow_text")).sendKeys("Create a simple running example");
findElement(By. cssSelector("input type ="image"")).click();
assertEquals("Note has been created.", findElement(By.id("mainContent")). getText());
findElement(By.id("logoff")).click();
}
+&'#
@Test
public void testAddNote(){
get("http://localhost:8080/theorganizer/");
findElement(By.id("logon_username")). sendKeys("user");
findElement(By.id("logon_password")). sendKeys("pswd");
findElement(By. cssSelector("input type ="image"")).click();
assertEquals("Welcome to The Organizer!", closeAlertAndGetItsText());
findElement(By.id("newNote")). click();
findElement(By.id("noteCreateShow_subject")).sendKeys("Running Example");
findElement(By.id("noteCreateShow_text")).sendKeys("Create a simple running example");
findElement(By. cssSelector("input type ="image"")).click();
assertEquals("Note has been created.", findElement(By.id("mainContent")). getText());
findElement(By.id("logoff")).click();
}
@Test
public void testAddNote(){
get("http://localhost:8080/theorganizer/");
findElement(By.id("logon_username")). sendKeys("user");
findElement(By.id("logon_password")). sendKeys("pswd");
findElement(By. cssSelector("input type ="image"")).click();
assertEquals("Welcome to The Organizer!", closeAlertAndGetItsText());
findElement(By.id("newNote")). click();
findElement(By.id("noteCreateShow_subject")).sendKeys("Running Example");
findElement(By.id("noteCreateShow_text")).sendKeys("Create a simple running example");
findElement(By. cssSelector("input type ="image"")).click();
assertEquals("Note has been created.", findElement(By.id("mainContent")). getText());
findElement(By.id("logoff")).click();
}
@Test
public void testAddNote(){
get("http://localhost:8080/theorganizer/");
findElement(By.id("logon_username")). sendKeys("user");
findElement(By.id("logon_password")). sendKeys("pswd");
findElement(By. cssSelector("input type ="image"")).click();
assertEquals("Welcome to The Organizer!", closeAlertAndGetItsText());
findElement(By.id("newNote")). click();
findElement(By.id("noteCreateShow_subject")).sendKeys("Running Example");
findElement(By.id("noteCreateShow_text")).sendKeys("Create a simple running example");
findElement(By. cssSelector("input type ="image"")).click();
assertEquals("Note has been created.", findElement(By.id("mainContent")). getText());
findElement(By.id("logoff")).click();
}
@Test
public void testAddNote(){
get("http://localhost:8080/theorganizer/");
findElement(By.id("logon_username")). sendKeys("user");
findElement(By.id("logon_password")). sendKeys("pswd");
findElement(By. cssSelector("input type ="image"")).click();
assertEquals("Welcome to The Organizer!", closeAlertAndGetItsText());
findElement(By.id("newNote")). click();
findElement(By.id("noteCreateShow_subject")).sendKeys("Running Example");
findElement(By.id("noteCreateShow_text")).sendKeys("Create a simple running example");
findElement(By. cssSelector("input type ="image"")).click();
assertEquals("Note has been created.", findElement(By.id("mainContent")). getText());
findElement(By.id("logoff")).click();
}
@Test
public void testAddNote(){
get("http://localhost:8080/theorganizer/");
findElement(By.id("logon_username")). sendKeys("user");
findElement(By.id("logon_password")). sendKeys("pswd");
findElement(By. cssSelector("input type ="image"")).click();
assertEquals("Welcome to The Organizer!", closeAlertAndGetItsText());
findElement(By.id("newNote")). click();
findElement(By.id("noteCreateShow_subject")).sendKeys("Running Example");
findElement(By.id("noteCreateShow_text")).sendKeys("Create a simple running example");
findElement(By. cssSelector("input type ="image"")).click();
assertEquals("Note has been created.", findElement(By.id("mainContent")). getText());
findElement(By.id("logoff")).click();
}
@Test
public void testAddNote(){
get("http://localhost:8080/theorganizer/");
findElement(By.id("logon_username")). sendKeys("user");
findElement(By.id("logon_password")). sendKeys("pswd");
findElement(By. cssSelector("input type ="image"")).click();
assertEquals("Welcome to The Organizer!", closeAlertAndGetItsText());
findElement(By.id("newNote")). click();
findElement(By.id("noteCreateShow_subject")).sendKeys("Running Example");
findElement(By.id("noteCreateShow_text")).sendKeys("Create a simple running example");
findElement(By. cssSelector("input type ="image"")).click();
assertEquals("Note has been created.", findElement(By.id("mainContent")). getText());
findElement(By.id("logoff")).click();
}
@Test
public void testAddNote(){
get("http://localhost:8080/theorganizer/");
findElement(By.id("logon_username")). sendKeys("user");
findElement(By.id("logon_password")). sendKeys("pswd");
findElement(By. cssSelector("input type ="image"")).click();
assertEquals("Welcome to The Organizer!", closeAlertAndGetItsText());
findElement(By.id("newNote")). click();
findElement(By.id("noteCreateShow_subject")).sendKeys("Running Example");
findElement(By.id("noteCreateShow_text")).sendKeys("Create a simple running example");
findElement(By. cssSelector("input type ="image"")).click();
assertEquals("Note has been created.", findElement(By.id("mainContent")). getText());
findElement(By.id("logoff")).click();
}
@Test
public void testAddNote(){
get("http://localhost:8080/theorganizer/");
findElement(By.id("logon_username")). sendKeys("user");
findElement(By.id("logon_password")). sendKeys("pswd");
findElement(By. cssSelector("input type ="image"")).click();
assertEquals("Welcome to The Organizer!", closeAlertAndGetItsText());
findElement(By.id("newNote")). click();
findElement(By.id("noteCreateShow_subject")).sendKeys("Running Example");
findElement(By.id("noteCreateShow_text")).sendKeys("Create a simple running example");
findElement(By. cssSelector("input type ="image"")).click();
assertEquals("Note has been created.", findElement(By.id("mainContent")). getText());
findElement(By.id("logoff")).click();
}
@Test
public void testAddNote(){
get("http://localhost:8080/theorganizer/");
findElement(By.id("logon_username")). sendKeys("user");
findElement(By.id("logon_password")). sendKeys("pswd");
findElement(By. cssSelector("input type ="image"")).click();
assertEquals("Welcome to The Organizer!", closeAlertAndGetItsText());
findElement(By.id("newNote")). click();
findElement(By.id("noteCreateShow_subject")).sendKeys("Running Example");
findElement(By.id("noteCreateShow_text")).sendKeys("Create a simple running example");
findElement(By. cssSelector("input type ="image"")).click();
assertEquals("Note has been created.", findElement(By.id("mainContent")). getText());
findElement(By.id("logoff")).click();
}
*WOCPYTKVVGP
VGUVECUGU
)GPGTCVGF
VGUVECUGU
Learning Assertions
A classification problem:
•Is a web element important to be checked by an assertion?
Apply machine learning to train a classier
•Features: position, size, page-rank, LinkNum, ChildNum, …
FROM MONOLITHIC APPS
Stateless ServerBrowser
Async HTTP
Request
Response
Internet
JSON
Generate
JSON
DOMCSS
JS
42
TO MICRO SERVICES
Micro ServicesBrowser
Restful HTTP
Request
Response
Internet
JSON
DOMCSS
JS
Micro
Service
Micro
Service
Micro
Service
Micro
Service
Micro
Service
Micro
Service
Micro
Service
Micro
Service
Micro
Service
Micro
Service
Micro
Service
Micro
Service
44
On the client Even in hardware! On the server
JavaScript is everywhere
45
“write once, run
anywhere”
Instantaneous
software delivery
Anything that can be written as a web
app, will be written as a web app
(eventually)