GithubHelp home page GithubHelp logo

jerry-zhxf / saw-script Goto Github PK

View Code? Open in Web Editor NEW

This project forked from galoisinc/saw-script

0.0 0.0 0.0 53.73 MB

The SAW scripting language.

License: BSD 3-Clause "New" or "Revised" License

Haskell 77.59% Shell 0.40% Makefile 0.23% Java 0.17% C 1.29% XSLT 0.01% LLVM 2.99% Yacc 0.75% Emacs Lisp 0.61% Rust 0.85% Dockerfile 0.17% Assembly 0.02% Lex 0.27% Python 3.36% Coq 11.08% TeX 0.08% Vim Script 0.12%

saw-script's Introduction

Build Status

SAWScript

This repository contains the code for SAWScript, the scripting language that forms the primary user interface to the Software Analysis Workbench (SAW). It provides the ability to reason about formal models describing the denotation of programs written in languages such as C, Java, and Cryptol.

Documentation

The SAWScript tutorial gives an introduction to using the SAWScript interpreter. A longer manual describes the breadth of SAWScript's features.

Precompiled Binaries

Precompiled SAWScript binaries for a variety of platforms are available on the releases page.

Getting Z3

SAW can use many theorem provers, but because of its use of Cryptol it always needs to have Microsoft Research's Z3 SMT solver installed. You can download Z3 binaries for a variety of platforms from their releases page.

We currently recommend Z3 4.8.10. If you plan to use path satisfiability checking, you'll also need Yices version 2.6.1 or newer.

After installation, make sure that z3 (or z3.exe on Windows) is on your PATH.

Manual Installation

To build SAWScript and related utilities from source:

  • Ensure that you have the cabal and ghc executables in your PATH. If you don't already have them, we recommend using ghcup to install them: https://www.haskell.org/ghcup/. We recommend Cabal 3.4 or newer, and GHC 8.8 or 8.10.

  • Ensure that you have the C libraries and header files for terminfo, which generally comes as part of ncurses on most platforms. On Fedora, it is part of the ncurses-compat-libs package. You will also need the C headers for zlib.

  • Ensure that you have the programs javac and z3 on your PATH. Z3 binaries are available at https://github.com/Z3Prover/z3/releases

  • Optionally, put in place dependency version freeze files:

    ln -s cabal.<ghc version>.config cabal.project.freeze
    
  • Build SAWScript by running

    ./build.sh
    

    The SAWScript executables will be available in the bin directory.

  • Optionally, run ./stage.sh to create a binary tarball.

Notes on LLVM

SAW can analyze LLVM programs (usually derived from C, but potentially for other languages). The only tool strictly required for this is a compiler that can generate LLVM bitcode, such as clang. However, having the full LLVM tool suite available can be useful. We have tested SAW with LLVM and clang versions from 3.5 to 12.0, as well as the version of clang bundled with Apple Xcode. We welcome bug reports on any failure to parse bitcode from LLVM versions in that range.

Note that successful parsing doesn't necessarily mean that verification will be possible for all language constructs. There are various instructions that are not supported during verification. However, any failure during llvm_load_module should be considered a bug.

Notes on Windows

If you have trouble loading the SAW REPL on Windows, try invoking it with the --no-color option.

Related Packages

Many dependencies are automatically downloaded into deps/ when you build using build.sh; see Manual Installation above. Key automatically downloaded dependencies include:

For SAW developers

Presently, the saw-script main executable cannot be loaded into GHCi due to a linker issue. However, the rest of the library can be manipulated in GHCi, with a little convincing.

If you are using cabal to build, select the saw-script target:

$ cabal new-repl saw-script

In order to use interactive tools like intero, you need to configure them with this target. You can configure intero-mode in Emacs to use the saw-script library target by setting the variable intero-targets to the string "saw-script:lib". To make this setting persistent for all files in this project, place the following snippet in the file src/.dir-locals.el:

((haskell-mode
  (intero-targets "saw-script:lib")))

Notes on Freeze Files

We use the cabal.GHC-*.config files to constrain dependency versions in CI, and recommend using the following command for best results before building locally:

ln -s cabal.GHC-<VER>.config cabal.project.freeze

These configuration files were generated using cabal freeze, but with some manual changes to allow cross-platfom builds, since Unix-like systems and Windows systems end up with different package dependencies. Specifically, we remove lines for the following packages or flags:

cryptol-saw-core
regex-posix
saw-remote-api
saw-script
tasty +unix
unix
unix-compat
unix-time

Acknowledgements

Much of the work on SAW has been funded by, and lots of design input was provided by the team at the NSA's Laboratory for Advanced Cybersecurity Research, including Brad Martin, Frank Taylor, and Sean Weaver.

Portions of SAW are also based upon work supported by the Office of Naval Research under Contract No. N68335-17-C-0452. Any opinions, findings and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the Office of Naval Research.

saw-script's People

Contributors

robdockins avatar eddywestbrook avatar chameco avatar mergify[bot] avatar ntc2 avatar langston-barrett avatar yav avatar chrisephifer avatar atomb avatar m-yac avatar ptival avatar andreistefanescu avatar spernsteiner avatar glguy avatar ryanglscott avatar kquick avatar david-christiansen avatar jpaykin avatar achudnov avatar nano-o avatar jldodds avatar msaaltink avatar tommd avatar ajayeeralla avatar brianhuffman avatar dmzimmerman avatar lisanna-dettwyler avatar bbarenblat avatar robby-phd avatar travitch 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.