Skip to content

Commit beb7deb

Browse files
authored
Move existing crates to ./crates (#3318)
* Move all crates to ./crates * cleanup md * more md * cleaned up readmes * remove unused stuff from scripts * fixup readmes * Reamdes * md * more commit * fmt * win * more fun * more moving * more move * works?
1 parent c604d2d commit beb7deb

File tree

806 files changed

+2305
-2228
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

806 files changed

+2305
-2228
lines changed

.github/workflows/build_and_test.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ jobs:
7474
if: runner.os != 'Windows'
7575
run: cargo test -- --test-threads 1
7676
- name: Test libafl no_std
77-
run: cd libafl && cargo test --no-default-features
77+
run: cd crates/libafl && cargo test --no-default-features
7878
- name: Test libafl_bolts no_std no_alloc
79-
run: cd libafl_bolts && cargo test --no-default-features
79+
run: cd crates/libafl_bolts && cargo test --no-default-features
8080
- name: Test libafl_targets no_std
81-
run: cd libafl_targets && cargo test --no-default-features
81+
run: cd crates/libafl_targets && cargo test --no-default-features
8282

8383
ubuntu-doc-build:
8484
runs-on: ubuntu-24.04
@@ -135,9 +135,9 @@ jobs:
135135
- name: Run a normal build
136136
run: cargo build --verbose
137137
# - name: Run libafl_qemu usermode tests
138-
# run: cd libafl_qemu && cargo test
138+
# run: cd crates/libafl_qemu && cargo test
139139
# - name: Run libafl_qemu systemmode tests
140-
# run: cd libafl_qemu && cargo test --no-default-features --features x86_64,systemmode
140+
# run: cd crates/libafl_qemu && cargo test --no-default-features --features x86_64,systemmode
141141
- name: Build examples
142142
run: cargo build --examples --verbose
143143

@@ -196,9 +196,9 @@ jobs:
196196
- uses: Swatinem/rust-cache@v2
197197
with: { shared-key: "ubuntu" }
198198
- name: Install smoke test deps
199-
run: sudo ./libafl_concolic/test/smoke_test_ubuntu_deps.sh
199+
run: sudo ./crates/libafl_concolic/test/smoke_test_ubuntu_deps.sh
200200
- name: Run smoke test
201-
run: ./libafl_concolic/test/smoke_test.sh
201+
run: ./crates/libafl_concolic/test/smoke_test.sh
202202

203203
python-bindings:
204204
runs-on: ubuntu-24.04
@@ -653,7 +653,7 @@ jobs:
653653
RUSTC_BOOTSTRAP=1 \
654654
LLVM_CONFIG=llvm-config-${{env.MAIN_LLVM_VERSION}} \
655655
just \
656-
-f ./libafl_asan/Justfile \
656+
-f ./crates/libafl_asan/Justfile \
657657
test_everything
658658
659659
libafl_qemu_asan:
@@ -691,7 +691,7 @@ jobs:
691691
RUSTC_BOOTSTRAP=1 \
692692
LLVM_CONFIG=llvm-config-${{env.MAIN_LLVM_VERSION}} \
693693
just \
694-
-f ./libafl_qemu/libafl_qemu_asan/Justfile \
694+
-f ./crates/libafl_qemu/libafl_qemu_asan/Justfile \
695695
build_everything_dev \
696696
build_x86_64_release
697697
@@ -712,7 +712,7 @@ jobs:
712712
- name: run x86_64 until panic!
713713
run: cd fuzzers/fuzz_anything/baby_no_std && cargo run || test $? -ne 0 || exit 1
714714
- name: no_std tests
715-
run: cd ./libafl && cargo test --no-default-features
715+
run: cd ./crates/libafl && cargo test --no-default-features
716716

717717
nostd-clippy:
718718
runs-on: ubuntu-24.04
@@ -727,9 +727,9 @@ jobs:
727727
with:
728728
shared-key: no-std-clippy
729729
- name: libafl armv6m-none-eabi (32 bit no_std) clippy
730-
run: cd ./libafl && cargo clippy --target thumbv6m-none-eabi --no-default-features
730+
run: cd ./crates/libafl && cargo clippy --target thumbv6m-none-eabi --no-default-features
731731
- name: libafl_bolts armv6m-none-eabi (32 bit no_std) clippy
732-
run: cd ./libafl_bolts && cargo clippy --target thumbv6m-none-eabi --no-default-features
732+
run: cd ./crates/libafl_bolts && cargo clippy --target thumbv6m-none-eabi --no-default-features
733733

734734
format-toml:
735735
runs-on: ubuntu-24.04
@@ -914,7 +914,7 @@ jobs:
914914
- uses: actions/checkout@v4
915915
- uses: Swatinem/rust-cache@v2
916916
- name: Build Android
917-
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
917+
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
918918

919919
ubuntu-cross-android-x86_64:
920920
runs-on: ubuntu-24.04

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ cur_input
3535

3636
crashes
3737
corpus
38+
!**/src/corpus
3839

3940
callgrind.out.*
4041
perf.data
@@ -48,6 +49,7 @@ test.dict
4849
# Ignore all built fuzzers
4950
AFLplusplus
5051
test_*
52+
!test_harness.cpp
5153
*_fuzzer
5254

5355
# Ignore common dummy and logfiles

CONTRIBUTING.md

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,14 @@ Once the package is installed, simply run `pre-commit install` to enable the hoo
2626
Before making your pull requests, try to see if your code follows these rules.
2727

2828
- Wherever possible, use `Cow<'static, str>` instead of String.
29-
- `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
29+
- `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
3030
- Wherever possible, trait implementations with lifetime specifiers should use '_ lifetime elision.
3131
- Complex constructors should be replaced with `typed_builder`, or write code in the builder pattern for yourself.
3232

33-
3433
## Rules for Generics and Associated Types
34+
3535
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.
36+
3637
```rust
3738
pub struct X<A>
3839
where
@@ -41,7 +42,9 @@ pub struct X<A>
4142
fn ...
4243
}
4344
```
45+
4446
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.
47+
4548
```rust
4649
pub struct X<A>
4750
where
@@ -53,6 +56,7 @@ pub struct X<A>
5356

5457
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.
5558
Try not to write this:
59+
5660
```rust
5761
pub trait X
5862
{
@@ -61,7 +65,9 @@ pub trait X
6165
fn a(&self) -> Self::A;
6266
}
6367
```
68+
6469
Try to write this instead:
70+
6571
```rust
6672
pub trait X<A>
6773
{
@@ -70,6 +76,7 @@ pub trait X<A>
7076
```
7177

7278
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.
79+
7380
```rust
7481
pub trait X
7582
{
@@ -78,23 +85,29 @@ pub trait X
7885
fn a(&self) -> Self::A;
7986
}
8087
```
88+
8189
5. Generic naming should be consistent. Do NOT use multiple name for the same generic, it just makes things more confusing. Do:
90+
8291
```rust
8392
pub struct X<A> {
8493
phantom: PhanomData<A>,
8594
}
8695

8796
impl<A> X<A> {}
8897
```
98+
8999
But not:
100+
90101
```rust
91102
pub struct X<A> {
92103
phantom: PhanomData<A>,
93104
}
94105

95106
impl<B> X<B> {} // <- Do NOT do that, use A instead of B
96107
```
108+
97109
6. __Ideally__ the types used in the arguments of methods in traits should have the same as the types defined on the traits.
110+
98111
```rust
99112
pub trait X<A, B, C> // <- this trait have 3 generics, A, B, and C
100113
{
@@ -103,7 +116,9 @@ pub trait X<A, B, C> // <- this trait have 3 generics, A, B, and C
103116
fn do_other_stuff(&self, a: A, b: B); // <- this is not ideal because it does not have C.
104117
}
105118
```
119+
106120
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.
121+
107122
```rust
108123
pub struct X {}
109124
pub struct Y {}
@@ -121,20 +136,26 @@ pub trait EventManager: Sized {
121136
fn do_stuff<Z>(&self, fuzzer: &Z); // <- This function signature should not take fuzzer
122137
}
123138
```
124-
trait `EventManager` should not implement any method that takes fuzzer, any object that could implement `Fuzzer` trait.
125139

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

127142
## Formatting
143+
128144
1. Always alphabetically order the type generics. Therefore,
145+
129146
```rust
130147
pub struct X<E, EM, OT, S, Z> {}; // <- Generics are alphabetically ordered
131148
```
149+
132150
But not,
151+
133152
```rust
134153
pub struct X<S, OT, Z, EM, E> {}; // <- Generics are not ordered
135154
```
155+
136156
2. Similarly, generic bounds in `where` clauses should be alphabetically sorted.
137157
Prefer:
158+
138159
```rust
139160
pub trait FooA {}
140161
pub trait FooB {}
@@ -147,7 +168,9 @@ where
147168
B: FooB,
148169
{}
149170
```
171+
150172
Over:
173+
151174
```rust
152175
pub trait FooA {}
153176
pub trait FooB {}

Cargo.toml

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
[workspace]
22
resolver = "2"
33
members = [
4-
"libafl",
5-
"libafl_asan",
6-
"libafl_asan/libafl_asan_fuzz",
7-
"libafl_asan/libafl_asan_libc",
8-
"libafl_bolts",
9-
"libafl_cc",
10-
"libafl_concolic/symcc_runtime",
11-
"libafl_concolic/symcc_libafl",
12-
"libafl_derive",
13-
"libafl_frida",
14-
"libafl_intelpt",
15-
"libafl_libfuzzer",
16-
"libafl_nyx",
17-
"libafl_unicorn",
18-
"libafl_targets",
19-
"libafl_tinyinst",
20-
"libafl_qemu",
21-
"libafl_qemu/libafl_qemu_build",
22-
"libafl_qemu/libafl_qemu_runner",
23-
"libafl_qemu/libafl_qemu_sys",
24-
"libafl_sugar",
25-
"libafl_concolic/test/dump_constraints",
26-
"libafl_concolic/test/runtime_test",
4+
"crates/libafl",
5+
"crates/libafl_asan",
6+
"crates/libafl_asan/libafl_asan_fuzz",
7+
"crates/libafl_asan/libafl_asan_libc",
8+
"crates/libafl_bolts",
9+
"crates/libafl_cc",
10+
"crates/libafl_concolic/symcc_runtime",
11+
"crates/libafl_concolic/symcc_libafl",
12+
"crates/libafl_derive",
13+
"crates/libafl_frida",
14+
"crates/libafl_intelpt",
15+
"crates/libafl_libfuzzer",
16+
"crates/libafl_nyx",
17+
"crates/libafl_unicorn",
18+
"crates/libafl_targets",
19+
"crates/libafl_tinyinst",
20+
"crates/libafl_qemu",
21+
"crates/libafl_qemu/libafl_qemu_build",
22+
"crates/libafl_qemu/libafl_qemu_runner",
23+
"crates/libafl_qemu/libafl_qemu_sys",
24+
"crates/libafl_sugar",
25+
"crates/libafl_concolic/test/dump_constraints",
26+
"crates/libafl_concolic/test/runtime_test",
2727
"utils/build_and_test_fuzzers",
2828
"utils/deexit",
2929
"utils/drcov_utils",
@@ -35,25 +35,25 @@ members = [
3535
]
3636

3737
default-members = [
38-
"libafl",
39-
"libafl_bolts",
40-
"libafl_cc",
41-
"libafl_derive",
42-
"libafl_targets",
38+
"crates/libafl",
39+
"crates/libafl_bolts",
40+
"crates/libafl_cc",
41+
"crates/libafl_derive",
42+
"crates/libafl_targets",
4343
]
4444

4545
exclude = [
4646
"bindings/pylibafl",
4747
"docs",
4848
"fuzzers",
49-
"libafl_libfuzzer_runtime",
49+
"crates/libafl_libfuzzer_runtime",
5050
"utils/noaslr",
5151
"utils/gdb_qemu",
5252
"utils/libafl_repo_tools",
5353
"utils/multi_machine_generator",
5454
"scripts",
5555
# additional crates
56-
"libafl_concolic/test/symcc/util/symcc_fuzzing_helper",
56+
"crates/libafl_concolic/test/symcc/util/symcc_fuzzing_helper",
5757
]
5858

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

6565
[workspace.dependencies]
6666
# Internal deps
67-
libafl = { path = "./libafl", version = "0.15.3", default-features = false }
68-
libafl_bolts = { path = "./libafl_bolts", version = "0.15.3", default-features = false }
69-
libafl_cc = { path = "./libafl_cc", version = "0.15.3", default-features = false }
70-
symcc_runtime = { path = "./libafl_concolic/symcc_runtime", version = "0.15.2", default-features = false }
71-
symcc_libafl = { path = "./libafl_concolic/symcc_libafl", version = "0.15.3", default-features = false }
72-
libafl_derive = { path = "./libafl_derive", version = "0.15.3", default-features = false }
73-
libafl_frida = { path = "./libafl_frida", version = "0.15.3", default-features = false }
74-
libafl_intelpt = { path = "./libafl_intelpt", version = "0.15.3", default-features = false }
75-
libafl_libfuzzer = { path = "./libafl_libfuzzer", version = "0.15.3", default-features = false }
76-
libafl_nyx = { path = "./libafl_nyx", version = "0.15.3", default-features = false }
77-
libafl_targets = { path = "./libafl_targets", version = "0.15.3", default-features = false }
78-
libafl_tinyinst = { path = "./libafl_tinyinst", version = "0.15.3", default-features = false }
79-
libafl_qemu = { path = "./libafl_qemu", version = "0.15.3", default-features = false }
80-
libafl_qemu_build = { path = "./libafl_qemu/libafl_qemu_build", version = "0.15.3", default-features = false }
81-
libafl_qemu_sys = { path = "./libafl_qemu/libafl_qemu_sys", version = "0.15.3", default-features = false }
82-
libafl_sugar = { path = "./libafl_sugar", version = "0.15.3", default-features = false }
83-
dump_constraints = { path = "./libafl_concolic/test/dump_constraints", version = "0.15.2", default-features = false }
84-
runtime_test = { path = "./libafl_concolic/test/runtime_test", version = "0.15.2", default-features = false }
67+
libafl = { path = "./crates/libafl", version = "0.15.3", default-features = false }
68+
libafl_bolts = { path = "./crates/libafl_bolts", version = "0.15.3", default-features = false }
69+
libafl_cc = { path = "./crates/libafl_cc", version = "0.15.3", default-features = false }
70+
symcc_runtime = { path = "./crates/libafl_concolic/symcc_runtime", version = "0.15.2", default-features = false }
71+
symcc_libafl = { path = "./crates/libafl_concolic/symcc_libafl", version = "0.15.3", default-features = false }
72+
libafl_derive = { path = "./crates/libafl_derive", version = "0.15.3", default-features = false }
73+
libafl_frida = { path = "./crates/libafl_frida", version = "0.15.3", default-features = false }
74+
libafl_intelpt = { path = "./crates/libafl_intelpt", version = "0.15.3", default-features = false }
75+
libafl_libfuzzer = { path = "./crates/libafl_libfuzzer", version = "0.15.3", default-features = false }
76+
libafl_nyx = { path = "./crates/libafl_nyx", version = "0.15.3", default-features = false }
77+
libafl_targets = { path = "./crates/libafl_targets", version = "0.15.3", default-features = false }
78+
libafl_tinyinst = { path = "./crates/libafl_tinyinst", version = "0.15.3", default-features = false }
79+
libafl_qemu = { path = "./crates/libafl_qemu", version = "0.15.3", default-features = false }
80+
libafl_qemu_build = { path = "./crates/libafl_qemu/libafl_qemu_build", version = "0.15.3", default-features = false }
81+
libafl_qemu_sys = { path = "./crates/libafl_qemu/libafl_qemu_sys", version = "0.15.3", default-features = false }
82+
libafl_sugar = { path = "./crates/libafl_sugar", version = "0.15.3", default-features = false }
83+
dump_constraints = { path = "./crates/libafl_concolic/test/dump_constraints", version = "0.15.2", default-features = false }
84+
runtime_test = { path = "./crates/libafl_concolic/test/runtime_test", version = "0.15.2", default-features = false }
8585
build_and_test_fuzzers = { path = "./utils/build_and_test_fuzzers", version = "0.15.2", default-features = false }
8686
deexit = { path = "./utils/deexit", version = "0.15.2", default-features = false }
8787
drcov_utils = { path = "./utils/drcov_utils", version = "0.15.2", default-features = false }

0 commit comments

Comments
 (0)