Statically Checking Web API Requests in JavaScript
Authors:
- Erik WitternEWErik Wittern
- Annie T.T. YingAYAnnie T.T. Ying
- Yunhui ZhengYZYunhui Zheng
- Julian DolbyJDJulian Dolby
- Jim A. LaredoJLJim A. Laredo
- 1 May 2017
- conference paper
- Published by Institute of Electrical and Electronics Engineers (IEEE)
- p. 244-254
Abstract
Many JavaScript applications perform HTTP requests to web APIs, relying on the request URL, HTTP method, and request data to be constructed correctly by string operations. Traditional compile-time error checking, such as calling a non-existent method in Java, are not available for checking whether such requests comply with the requirements of a web API. In this paper, we propose an approach to statically check web API requests in JavaScript. Our approach first extracts a request's URL string, HTTP method, and the corresponding request data using an inter-procedural string analysis, and then checks whether the request conforms to given web API specifications. We evaluated our approach by checking whether web API requests in JavaScript files mined from GitHub are consistent or inconsistent with publicly available API specifications. From the 6575 requests in scope, our approach determined whether the request's URL and HTTP method was consistent or inconsistent with web API specifications with a precision of 96.0%. Our approach also correctly determined whether extracted request data was consistent or inconsistent with the data requirements with a precision of 87.9% for payload data and 99.9% for query data. In a systematic analysis of the inconsistent cases, we found that many of them were due to errors in the client code. The here proposed checker can be integrated with code editors or with continuous integration tools to warn programmers about code containing potentially erroneous requests.Keywords
All Related Versions
This publication has 18 references indexed in Scilit:
- Are RESTful APIs Well-Designed? Detection of their Linguistic (Anti)Patterns2015
- Static Analysis of JavaScript Web Applications in the Wild via Practical DOM Modeling (T)2015
- Inferring Web API Descriptions from Usage Data2015
- Effective Search-Space Pruning for Solvers of String Equations, Regular Expressions and Length Constraints2015
- Web API Fragility: How Robust is Your Mobile Application?2015
- SAFEWAPI: web API misuse detector for web applications2014
- Jalangi: a selective record-replay and dynamic analysis framework for JavaScript2013
- Z3-str: a z3-based string solver for web application analysis2013
- Dynamic determinacy analysis2013
- Efficient construction of approximate call graphs for JavaScript IDE services2013