Skip to content

Move existing crates to ./crates #3318

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Jun 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
26 changes: 13 additions & 13 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ jobs:
if: runner.os != 'Windows'
run: cargo test -- --test-threads 1
- name: Test libafl no_std
run: cd libafl && cargo test --no-default-features
run: cd crates/libafl && cargo test --no-default-features
- name: Test libafl_bolts no_std no_alloc
run: cd libafl_bolts && cargo test --no-default-features
run: cd crates/libafl_bolts && cargo test --no-default-features
- name: Test libafl_targets no_std
run: cd libafl_targets && cargo test --no-default-features
run: cd crates/libafl_targets && cargo test --no-default-features

ubuntu-doc-build:
runs-on: ubuntu-24.04
Expand Down Expand Up @@ -135,9 +135,9 @@ jobs:
- name: Run a normal build
run: cargo build --verbose
# - name: Run libafl_qemu usermode tests
# run: cd libafl_qemu && cargo test
# run: cd crates/libafl_qemu && cargo test
# - name: Run libafl_qemu systemmode tests
# run: cd libafl_qemu && cargo test --no-default-features --features x86_64,systemmode
# run: cd crates/libafl_qemu && cargo test --no-default-features --features x86_64,systemmode
- name: Build examples
run: cargo build --examples --verbose

Expand Down Expand Up @@ -196,9 +196,9 @@ jobs:
- uses: Swatinem/rust-cache@v2
with: { shared-key: "ubuntu" }
- name: Install smoke test deps
run: sudo ./libafl_concolic/test/smoke_test_ubuntu_deps.sh
run: sudo ./crates/libafl_concolic/test/smoke_test_ubuntu_deps.sh
- name: Run smoke test
run: ./libafl_concolic/test/smoke_test.sh
run: ./crates/libafl_concolic/test/smoke_test.sh

python-bindings:
runs-on: ubuntu-24.04
Expand Down Expand Up @@ -653,7 +653,7 @@ jobs:
RUSTC_BOOTSTRAP=1 \
LLVM_CONFIG=llvm-config-${{env.MAIN_LLVM_VERSION}} \
just \
-f ./libafl_asan/Justfile \
-f ./crates/libafl_asan/Justfile \
test_everything

libafl_qemu_asan:
Expand Down Expand Up @@ -691,7 +691,7 @@ jobs:
RUSTC_BOOTSTRAP=1 \
LLVM_CONFIG=llvm-config-${{env.MAIN_LLVM_VERSION}} \
just \
-f ./libafl_qemu/libafl_qemu_asan/Justfile \
-f ./crates/libafl_qemu/libafl_qemu_asan/Justfile \
build_everything_dev \
build_x86_64_release

Expand All @@ -712,7 +712,7 @@ jobs:
- name: run x86_64 until panic!
run: cd fuzzers/fuzz_anything/baby_no_std && cargo run || test $? -ne 0 || exit 1
- name: no_std tests
run: cd ./libafl && cargo test --no-default-features
run: cd ./crates/libafl && cargo test --no-default-features

nostd-clippy:
runs-on: ubuntu-24.04
Expand All @@ -727,9 +727,9 @@ jobs:
with:
shared-key: no-std-clippy
- name: libafl armv6m-none-eabi (32 bit no_std) clippy
run: cd ./libafl && cargo clippy --target thumbv6m-none-eabi --no-default-features
run: cd ./crates/libafl && cargo clippy --target thumbv6m-none-eabi --no-default-features
- name: libafl_bolts armv6m-none-eabi (32 bit no_std) clippy
run: cd ./libafl_bolts && cargo clippy --target thumbv6m-none-eabi --no-default-features
run: cd ./crates/libafl_bolts && cargo clippy --target thumbv6m-none-eabi --no-default-features

format-toml:
runs-on: ubuntu-24.04
Expand Down Expand Up @@ -914,7 +914,7 @@ jobs:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
- name: Build Android
run: cd libafl && PYO3_CROSS_PYTHON_VERSION=$(python3 -c "print('{}.{}'.format(__import__('sys').version_info.major, __import__('sys').version_info.minor))") cargo ndk -t arm64-v8a build --release
run: cd crates/libafl && PYO3_CROSS_PYTHON_VERSION=$(python3 -c "print('{}.{}'.format(__import__('sys').version_info.major, __import__('sys').version_info.minor))") cargo ndk -t arm64-v8a build --release

ubuntu-cross-android-x86_64:
runs-on: ubuntu-24.04
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ cur_input

crashes
corpus
!**/src/corpus

callgrind.out.*
perf.data
Expand All @@ -48,6 +49,7 @@ test.dict
# Ignore all built fuzzers
AFLplusplus
test_*
!test_harness.cpp
*_fuzzer

# Ignore common dummy and logfiles
Expand Down
29 changes: 26 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ Once the package is installed, simply run `pre-commit install` to enable the hoo
Before making your pull requests, try to see if your code follows these rules.

- Wherever possible, use `Cow<'static, str>` instead of String.
- `PhantomData` should have the smallest set of types needed. Try not adding `PhantomData` to your struct unless it is really necessary. Also even when you really need `PhantomData`, try to keep the types `T` used in `PhantomData` as smallest as possible
- `PhantomData` should have the smallest set of types needed. Try not adding `PhantomData` to your struct unless it is really necessary. Also even when you really need `PhantomData`, try to keep the types `T` used in `PhantomData` as smallest as possible
- Wherever possible, trait implementations with lifetime specifiers should use '_ lifetime elision.
- Complex constructors should be replaced with `typed_builder`, or write code in the builder pattern for yourself.


## Rules for Generics and Associated Types

1. Remove generic restrictions at the definitions (e.g., we do not need to specify that types impl `Serialize`, `Deserialize`, or `Debug` anymore at the struct definitions). Therefore, try avoiding code like this unless the constraint is really necessary.

```rust
pub struct X<A>
where
Expand All @@ -41,7 +42,9 @@ pub struct X<A>
fn ...
}
```

2. Reduce generics to the least restrictive necessary. __Never overspecify the constraints__. There's no automated tool to check the useless constraints, so you have to verify this manually.

```rust
pub struct X<A>
where
Expand All @@ -53,6 +56,7 @@ pub struct X<A>

3. Prefer generic to associated types in traits definition as much as possible. They are much easier to use around, and avoid tricky caveats / type repetition in the code. It is also much easier to have unconstrained struct definitions.
Try not to write this:

```rust
pub trait X
{
Expand All @@ -61,7 +65,9 @@ pub trait X
fn a(&self) -> Self::A;
}
```

Try to write this instead:

```rust
pub trait X<A>
{
Expand All @@ -70,6 +76,7 @@ pub trait X<A>
```

4. Traits which have an associated type (if you have made sure you cannot use a generic instead) should refer to the associated type, not the concrete/generic. In other words, you should only have the associated type when you can define a getter to it. For example, in the following code, you can define a associate type.

```rust
pub trait X
{
Expand All @@ -78,23 +85,29 @@ pub trait X
fn a(&self) -> Self::A;
}
```

5. Generic naming should be consistent. Do NOT use multiple name for the same generic, it just makes things more confusing. Do:

```rust
pub struct X<A> {
phantom: PhanomData<A>,
}

impl<A> X<A> {}
```

But not:

```rust
pub struct X<A> {
phantom: PhanomData<A>,
}

impl<B> X<B> {} // <- Do NOT do that, use A instead of B
```

6. __Ideally__ the types used in the arguments of methods in traits should have the same as the types defined on the traits.

```rust
pub trait X<A, B, C> // <- this trait have 3 generics, A, B, and C
{
Expand All @@ -103,7 +116,9 @@ pub trait X<A, B, C> // <- this trait have 3 generics, A, B, and C
fn do_other_stuff(&self, a: A, b: B); // <- this is not ideal because it does not have C.
}
```

7. Try to avoid cyclical dependency if possible. Sometimes it is necessary but try to avoid it. For example, The following code is a bad example.

```rust
pub struct X {}
pub struct Y {}
Expand All @@ -121,20 +136,26 @@ pub trait EventManager: Sized {
fn do_stuff<Z>(&self, fuzzer: &Z); // <- This function signature should not take fuzzer
}
```
trait `EventManager` should not implement any method that takes fuzzer, any object that could implement `Fuzzer` trait.

trait `EventManager` should not implement any method that takes fuzzer, any object that could implement `Fuzzer` trait.

## Formatting

1. Always alphabetically order the type generics. Therefore,

```rust
pub struct X<E, EM, OT, S, Z> {}; // <- Generics are alphabetically ordered
```

But not,

```rust
pub struct X<S, OT, Z, EM, E> {}; // <- Generics are not ordered
```

2. Similarly, generic bounds in `where` clauses should be alphabetically sorted.
Prefer:

```rust
pub trait FooA {}
pub trait FooB {}
Expand All @@ -147,7 +168,9 @@ where
B: FooB,
{}
```

Over:

```rust
pub trait FooA {}
pub trait FooB {}
Expand Down
96 changes: 48 additions & 48 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
[workspace]
resolver = "2"
members = [
"libafl",
"libafl_asan",
"libafl_asan/libafl_asan_fuzz",
"libafl_asan/libafl_asan_libc",
"libafl_bolts",
"libafl_cc",
"libafl_concolic/symcc_runtime",
"libafl_concolic/symcc_libafl",
"libafl_derive",
"libafl_frida",
"libafl_intelpt",
"libafl_libfuzzer",
"libafl_nyx",
"libafl_unicorn",
"libafl_targets",
"libafl_tinyinst",
"libafl_qemu",
"libafl_qemu/libafl_qemu_build",
"libafl_qemu/libafl_qemu_runner",
"libafl_qemu/libafl_qemu_sys",
"libafl_sugar",
"libafl_concolic/test/dump_constraints",
"libafl_concolic/test/runtime_test",
"crates/libafl",
"crates/libafl_asan",
"crates/libafl_asan/libafl_asan_fuzz",
"crates/libafl_asan/libafl_asan_libc",
"crates/libafl_bolts",
"crates/libafl_cc",
"crates/libafl_concolic/symcc_runtime",
"crates/libafl_concolic/symcc_libafl",
"crates/libafl_derive",
"crates/libafl_frida",
"crates/libafl_intelpt",
"crates/libafl_libfuzzer",
"crates/libafl_nyx",
"crates/libafl_unicorn",
"crates/libafl_targets",
"crates/libafl_tinyinst",
"crates/libafl_qemu",
"crates/libafl_qemu/libafl_qemu_build",
"crates/libafl_qemu/libafl_qemu_runner",
"crates/libafl_qemu/libafl_qemu_sys",
"crates/libafl_sugar",
"crates/libafl_concolic/test/dump_constraints",
"crates/libafl_concolic/test/runtime_test",
"utils/build_and_test_fuzzers",
"utils/deexit",
"utils/drcov_utils",
Expand All @@ -35,25 +35,25 @@ members = [
]

default-members = [
"libafl",
"libafl_bolts",
"libafl_cc",
"libafl_derive",
"libafl_targets",
"crates/libafl",
"crates/libafl_bolts",
"crates/libafl_cc",
"crates/libafl_derive",
"crates/libafl_targets",
]

exclude = [
"bindings/pylibafl",
"docs",
"fuzzers",
"libafl_libfuzzer_runtime",
"crates/libafl_libfuzzer_runtime",
"utils/noaslr",
"utils/gdb_qemu",
"utils/libafl_repo_tools",
"utils/multi_machine_generator",
"scripts",
# additional crates
"libafl_concolic/test/symcc/util/symcc_fuzzing_helper",
"crates/libafl_concolic/test/symcc/util/symcc_fuzzing_helper",
]

[workspace.package]
Expand All @@ -64,24 +64,24 @@ readme = "./README.md"

[workspace.dependencies]
# Internal deps
libafl = { path = "./libafl", version = "0.15.3", default-features = false }
libafl_bolts = { path = "./libafl_bolts", version = "0.15.3", default-features = false }
libafl_cc = { path = "./libafl_cc", version = "0.15.3", default-features = false }
symcc_runtime = { path = "./libafl_concolic/symcc_runtime", version = "0.15.2", default-features = false }
symcc_libafl = { path = "./libafl_concolic/symcc_libafl", version = "0.15.3", default-features = false }
libafl_derive = { path = "./libafl_derive", version = "0.15.3", default-features = false }
libafl_frida = { path = "./libafl_frida", version = "0.15.3", default-features = false }
libafl_intelpt = { path = "./libafl_intelpt", version = "0.15.3", default-features = false }
libafl_libfuzzer = { path = "./libafl_libfuzzer", version = "0.15.3", default-features = false }
libafl_nyx = { path = "./libafl_nyx", version = "0.15.3", default-features = false }
libafl_targets = { path = "./libafl_targets", version = "0.15.3", default-features = false }
libafl_tinyinst = { path = "./libafl_tinyinst", version = "0.15.3", default-features = false }
libafl_qemu = { path = "./libafl_qemu", version = "0.15.3", default-features = false }
libafl_qemu_build = { path = "./libafl_qemu/libafl_qemu_build", version = "0.15.3", default-features = false }
libafl_qemu_sys = { path = "./libafl_qemu/libafl_qemu_sys", version = "0.15.3", default-features = false }
libafl_sugar = { path = "./libafl_sugar", version = "0.15.3", default-features = false }
dump_constraints = { path = "./libafl_concolic/test/dump_constraints", version = "0.15.2", default-features = false }
runtime_test = { path = "./libafl_concolic/test/runtime_test", version = "0.15.2", default-features = false }
libafl = { path = "./crates/libafl", version = "0.15.3", default-features = false }
libafl_bolts = { path = "./crates/libafl_bolts", version = "0.15.3", default-features = false }
libafl_cc = { path = "./crates/libafl_cc", version = "0.15.3", default-features = false }
symcc_runtime = { path = "./crates/libafl_concolic/symcc_runtime", version = "0.15.2", default-features = false }
symcc_libafl = { path = "./crates/libafl_concolic/symcc_libafl", version = "0.15.3", default-features = false }
libafl_derive = { path = "./crates/libafl_derive", version = "0.15.3", default-features = false }
libafl_frida = { path = "./crates/libafl_frida", version = "0.15.3", default-features = false }
libafl_intelpt = { path = "./crates/libafl_intelpt", version = "0.15.3", default-features = false }
libafl_libfuzzer = { path = "./crates/libafl_libfuzzer", version = "0.15.3", default-features = false }
libafl_nyx = { path = "./crates/libafl_nyx", version = "0.15.3", default-features = false }
libafl_targets = { path = "./crates/libafl_targets", version = "0.15.3", default-features = false }
libafl_tinyinst = { path = "./crates/libafl_tinyinst", version = "0.15.3", default-features = false }
libafl_qemu = { path = "./crates/libafl_qemu", version = "0.15.3", default-features = false }
libafl_qemu_build = { path = "./crates/libafl_qemu/libafl_qemu_build", version = "0.15.3", default-features = false }
libafl_qemu_sys = { path = "./crates/libafl_qemu/libafl_qemu_sys", version = "0.15.3", default-features = false }
libafl_sugar = { path = "./crates/libafl_sugar", version = "0.15.3", default-features = false }
dump_constraints = { path = "./crates/libafl_concolic/test/dump_constraints", version = "0.15.2", default-features = false }
runtime_test = { path = "./crates/libafl_concolic/test/runtime_test", version = "0.15.2", default-features = false }
build_and_test_fuzzers = { path = "./utils/build_and_test_fuzzers", version = "0.15.2", default-features = false }
deexit = { path = "./utils/deexit", version = "0.15.2", default-features = false }
drcov_utils = { path = "./utils/drcov_utils", version = "0.15.2", default-features = false }
Expand Down
Loading
Loading