Giter Club home page Giter Club logo

fuzz-fun's Introduction

Fun with Fuzzing

This repository demonstrate two things:

  • How use cargo-fuzz to fuzz test your Rust code.

  • How to use the Seasoned Software service to continuous fuzz test your code in the cloud.

How to use cargo-fuzz

  • See the cargo-fuzz tutorial

  • To set up fuzz testing for this project

    1. Install cargo-fuzz:

      cargo install cargo-fuzz

    2. Change the project to use nightly Rust:

      rustup override set nightly

    3. Initialise cargo-fuzz

      cargo fuzz init

    4. Add a new fuzz target:

      cargo fuzz add quicksort

    5. Edit the file fuzz/fuzz_targets/quicksort.rs to contain your fuzz harness

    6. Start fuzzing

      cargo fuzz run quicksort

    7. Optionally delete the file fuzz/fuzz_target_1.rs and clean up fuzz/Cargo.toml

  • Make sure that cargo fuzz works for you locally.

  • Make the file seasoned-software.sh in the root of your repository. This file should specify how to compile all the cargo fuzz targets in your project, and then it should call register-binary for each target you want to use as fuzz harness.

    In this project we only have one target, quicksort, thus our script is just:

    #!/bin/bash
    
    # Cargo-fuzz needs nightly rust, so switch this project to nightly
    rustup override set nightly
    
    # Build the quicksort fuzz target in release mode, and run it once
    cargo fuzz run quicksort --release -- -help=1
    
    # Find the executable for the fuzz target
    EXE="$(find fuzz/target -iname quicksort -executable)"
    
    # Register the fuzz target
    register-binary "quicksort" "$EXE"
    

    If you have multiple fuzz targets you can use the following snippet of code instead of the last four steps in the script:

    # Build and register all tests known to Cargo-fuzz.
    for t in $(cargo fuzz list|sed 's@\x1b[^m]*m@@g'); do
       echo "Building test: $t"
       cargo fuzz run $t --release -- -help=1
       EXE="$(find fuzz/target -iname $t -executable)"
    
       echo "Registering: $EXE"
       register-binary "$t" "$EXE"
    done
    
  • Now go to https://app.seasoned.software and add your project.

    When you add your project you need to tell which git branch to use (master in our case) and which harness to use, the harness is the name of one of the binaries we registered with register-binary. In this project we only have one harness quicksort.

fuzz-fun's People

Contributors

kfl avatar brinchj avatar

Watchers

 avatar James Cloos avatar  avatar

Forkers

brinchj

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.