Git Product home page Git Product logo

hopper's Introduction

Build Status

Hopper

Hopper is a goal-directed static analysis tool for languages that run on the JVM. It is a much-improved and more feature-ful version of Thresher written in Scala rather than Java.

Installation

Hopper requires sbt 0.1 or later.

(1) Download Droidel and follow its installation instructions. Publish Droidel to your local Maven repository by running sbt publishLocal in the droidel/ directory.

(2) Download Z3, compile the Java bindings, and copy the produced *.dylib (OSX), *.so (Linux), and *.jar files to hopper/lib:

mkdir lib; cd lib
git clone https://github.com/Z3Prover/z3.git; cd z3
python scripts/mk_make.py --java; cd build
make
cp *.jar ../..
cp *.dylib ../.. || cp *.so ../..
cd ../..

(3) In order to use the Android clients or compile/run the tests, you'll need a Droidel-processed Android framework JAR in lib/: cp ../droidel/stubs/out/droidel_android-4.4.2_r1.jar lib (assuming droidel and hopper are sibling directories).

(4) Build Hopper with sbt one-jar and run with ./hopper.sh.

Usage

Run

./hopper.sh -app <path_to_bytecodes> -<check>

where <path_to_bytecodes> is a path to a JAR or directory containing the Java bytecodes to be checked and <check> is one of check_android_derefs (check nulls for null dereferences with special handling for Android), -check_casts (check safety of downcasts), -check_array_bounds (check for out-of-bounds array accesses), -check_nulls (check for null dereferences), or -check_android_leaks (check for Android memory leaks).

The primary advantage of Hopper over Thresher is the -jumping_execution flag, which enables goal-directed control-flow abstraction. This flag tells Hopper to try to achieve better scalability by "jumping" between relevant code regions rather than strictly following the program's control-flow. For better precision while jumping, use the -control_feasibility flag.

For example, to check for null dereferences in the Android app app.apk, you should run ./hopper.sh -check_android_derefs -jumping_execution -control_feasibility -app app.apk.

Tests

To compile/run the regression tests, do sbt test:compile and then ./hopper.sh -regressions -jumping_execution. To run a single test, you can do ./hopper.sh -regressions -test <test_name>.

About

The core functionality of Hopper is an engine for refuting queries written in separation logic; that is, showing that no concrete execution can satisfy the query. Hopper performs a form of proof by contradiction: it starts from a query representing a bad program state (such as a null dereference or out-of-bounds array access) and works backward in an attempt to derive false.

Hopper has several built-in clients (as described above) but writing your own clients is meant to be easy: just extend the Client class and write a checker that takes a program as input and emits separation logic formulae representing your client.

For more on Hopper and its predecessor tool Thresher, see our OOPSLA '15 paper, our PLDI '13 paper or the Thresher project page.

Bugs found

Here is a selection of bugs found using the assistance of Hopper/Thresher:

Android framework - write into all HashMap's (fixed)

SeriesGuide Android app - null dereference (fixed)

SeriesGuide Android app - null dereference (fixed)

ConnectBot Android app - null dereference (fixed)

ConnectBot Android app - null dereference (fixed)

LastFM Android app - null dereference

K9Mail Android app - memory leak (fixed)

Jython - array out of bounds error

Troubleshooting

Problem: Hopper compilation fails with missing dependency from walautil or droidel. Solution: Your walautil and droidel projects might be out of date. Try git pull; sbt publishLocal in each directory.

Problem: Hopper fails at runtime with a message like: java.lang.NoSuchMethodError: scala.collection.immutable.$colon$colon.hd$1()Ljava/lang/Object;. Solution: This happens when Hopper is run with the wrong version of Scala; make sure you are using Scala 2.10.

Problem: Hopper fails at runtime with a message like: java.lang.UnsupportedClassVersionError: edu/colorado/walautil/cg/ImprovedZeroXContainerCFABuilder : Unsupported major.minor version 52.0. Solution: This happens when Hopper and walautil are built using different JDK versions. You may need to rebuild walautil and sbt publishLocal again.

hopper's People

Contributors

sblackshear avatar bechang avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.