• Home
  • Raw
  • Download

Lines Matching +full:oss +full:- +full:fuzz

1 ---
7 permalink: /getting-started/new-project-guide/rust-lang/
8 ---
13 - TOC
15 ---
17 The process of integrating a project written in Rust with OSS-Fuzz is very
19 }}/getting-started/new-project-guide/) process. The key specifics of integrating
22 ## cargo-fuzz support
24 Rust integration with OSS-Fuzz is expected to use [`cargo
25 fuzz`](https://github.com/rust-fuzz/cargo-fuzz) to build fuzzers. The `cargo
26 fuzz` tool will build code with required compiler flags as well as link to the
27 correct libFuzzer on OSS-Fuzz itself. Note that using `cargo fuzz` also makes it
32 First you'll want to follow the [setup instructions for `cargo fuzz`
33 itself](https://rust-fuzz.github.io/book/). Afterwards your project should have:
35 * A top-level `fuzz` directory.
36 * A `fuzz/Cargo.toml` manifest which pulls in necessary dependencies to fuzz.
37 * Some `fuzz/fuzz_targets/*.rs` files which are the fuzz targets that will be
38 compiled and run on OSS-Fuzz.
41 the scripts below to integrate into OSS-Fuzz.
53 …ple](https://github.com/google/oss-fuzz/blob/12ef3654b3e9adfd20b5a6afdde54819ba71493d/projects/ser…
57 - address
59 - libfuzzer
64 The Dockerfile should start by `FROM gcr.io/oss-fuzz-base/base-builder-rust`
66 The OSS-Fuzz builder image has the latest nightly release of Rust as well as
67 `cargo fuzz` pre-installed and in `PATH`. In the `Dockerfile` for your project
70 …ple](https://github.com/google/oss-fuzz/blob/12ef3654b3e9adfd20b5a6afdde54819ba71493d/projects/ser…
73 RUN git clone --depth 1 https://github.com/serde-rs/json json
78 Here it's expected that you'll build the fuzz targets for your project and then
80 [Example](https://github.com/google/oss-fuzz/blob/12ef3654b3e9adfd20b5a6afdde54819ba71493d/projects…
84 cargo fuzz build -O
85 cp fuzz/target/x86_64-unknown-linux-gnu/release/from_slice $OUT/
88 Note that you likely want to pass the `-O` flag to `cargo fuzz build` which
90 `--debug-assertions` flag to enable more checks while fuzzing. In this example
91 the `from_slice` binary is the fuzz target.
93 With some bash-fu you can also automatically copy over all fuzz targets into
94 the output directory so when you add a fuzz target to your project it's
95 automatically integrated into OSS-Fuzz:
98 FUZZ_TARGET_OUTPUT_DIR=target/x86_64-unknown-linux-gnu/release
99 for f in fuzz/fuzz_targets/*.rs
106 ## Writing fuzzers using a test-style strategy
109 compiled into the final binary when build in test-mode. This is, achieved by
119 Cargo-fuzz automatically enables the `fuzzing` feature, which means you can
131 Furthermore, within your `.toml` files, you can then specify fuzzing-specific
136 similar to how you wrap test-dependencies as follows:
138 [dev-dependencies]
141 Finally, you can also combine the testing logic you have and the fuzz logic. This
147 A project that follows this structure is Linkerd2-proxy and the project files can be
148 seen [here](https://github.com/google/oss-fuzz/tree/master/projects/linkerd2-proxy).