<commit_before># Tutorial

For this tutorial, we are going to fuzz the URL parser [rust-url](https://github.com/servo/rust-url).

## Clone

Clone the repository and navigate inside:

```
git clone https://github.com/servo/rust-url
cd rust-url
```

## Dependencies

Modify `Cargo.toml` and add the following lines to the `[dependencies]` section:

```toml
afl = "0.1"
afl-plugin = "0.1"
```

The `afl-plugin` crate includes a compiler plugin that will be used to instrument the rust-url crate. The `afl` crate will be used to setup the necessary runtime afl expects during afl-fuzz. Also, it has a few other utilities.

## Instrumentation

Open up `src/lib.rs` and add these two lines before all other non-documentation/non-comment lines:

```
#![feature(plugin)]
#![plugin(afl_plugin)]
```

These will instrument.

## Driver

AFL requires an executable that will read from stdin. Create a new file `src/main.rs` and add the following contents:

```rust<commit_msg>Complete unfinished sentence.<commit_after># Tutorial

For this tutorial, we are going to fuzz the URL parser [rust-url](https://github.com/servo/rust-url).

## Clone

Clone the repository and navigate inside:

```
git clone https://github.com/servo/rust-url
cd rust-url
```

## Dependencies

Modify `Cargo.toml` and add the following lines to the `[dependencies]` section:

```toml
afl = "0.1"
afl-plugin = "0.1"
```

The `afl-plugin` crate includes a compiler plugin that will be used to instrument the rust-url crate. The `afl` crate will be used to setup the necessary runtime afl expects during afl-fuzz. Also, it has a few other utilities.

## Instrumentation

Open up `src/lib.rs` and add these two lines before all other non-documentation/non-comment lines:

```
#![feature(plugin)]
#![plugin(afl_plugin)]
```

The first line indicates to the compiler that we are opting-in to an unstable Rust feature: [compiler plugins](https://doc.rust-lang.org/book/compiler-plugins.html). The second line specifies which compiler plugin we want to use. This particular compiler plugin will add the AFL instrumentation to the rust-url crate.

## Driver

AFL requires an executable that will read from stdin. Create a new file `src/main.rs` and add the following contents:

```rust
{'fraction_non_alphanumeric': 0.10808396605627513, 'fraction_numerical': 0.003573023671281822, 'mean_word_length': 4.384615384615385, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 5, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2930255', 'n_tokens_mistral': 699, 'n_tokens_neox': 668, 'n_words': 282}