TitleVerifying Object Construction
Publication TypeConference Paper
Year of Publication2020
AuthorsKellogg M, Ran M, Sridharan M, Schäf M, Ernst MD
Conference NameICSE 2020, Proceedings of the 42nd International Conference on Software Engineering
Pagination1447-1458
Date or Month PublishedMay
Conference LocationSeoul, Korea
AbstractIn object-oriented languages, constructors often have a combination of required and optional formal parameters. It is tedious and inconvenient for programmers to write a constructor by hand for each combination. The multitude of constructors is error-prone for clients, and client code is difficult to read due to the large number of constructor arguments. Therefore, programmers often use design patterns that enable more flexible object construction–-the builder pattern, dependency injection, or factory methods. \par However, these design patterns can be \emphtoo flexible: not all combinations of logical parameters lead to the construction of well-formed objects. When a client uses the builder pattern to construct an object, the compiler does not check that a valid set of values was provided. Incorrect use of builders can lead to security vulnerabilities, run-time crashes, and other problems. \par This work shows how to statically verify uses of object construction, such as the builder pattern. Using a simple specification language, programmers specify which combinations of logical arguments are permitted. Our compile-time analysis detects client code that may construct objects unsafely. Our analysis is based on a novel special case of typestate checking, \emphaccumulation analysis, that modularly reasons about accumulations of method calls. Because accumulation analysis does not require precise aliasing information for soundness, our analysis scales to industrial programs. We evaluated it on over 9 million lines of code, discovering defects which included previously-unknown security vulnerabilities and potential null-pointer violations in heavily-used open-source codebases. Our analysis has a low false positive rate and low annotation burden. \par Our implementation and experimental data are publicly available.
Downloadshttps://docs.google.com/presentation/d/16aeJkvQqFqFkfs6Y1X6iwvGCsus37muE... slides (Google Slides) https://checkerframework.org/ implementation https://doi.org/10.5281/zenodo.3634993 scripts and data
Citation KeyKelloggRSSE2020