Skip to content
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

Fuzz cairo compiled programs #1236

Merged
merged 31 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
c3a30e6
Create fuzzer
Jun 13, 2023
d85b25d
Merge branch 'main' of https://github.com/lambdaclass/cairo-rs into c…
Jun 13, 2023
b04e55c
Remove cli
Jun 13, 2023
11eaf85
Update fuzzer
Jun 14, 2023
dcd5e96
Change fuzzer name
Jun 14, 2023
406a53c
Move functions to utils; Create new fuzzer
Jun 14, 2023
9ddd363
Remove file and update readme
Jun 14, 2023
181c2b9
Change filename
Jun 14, 2023
06153e6
Fix filenames
Jun 14, 2023
5bceae7
update fuzzer and merge
dafifynn Jun 30, 2023
351d6e3
delete extra changes
dafifynn Jun 30, 2023
3f7cc27
delete extra changes
dafifynn Jun 30, 2023
60fbefa
Move to fuzzing dir
Jul 12, 2023
6a4fb33
update and refactor cairo compiled programs fuzzer
dafifynn Jul 14, 2023
9f0b7a8
merge with main
dafifynn Jul 14, 2023
8c3d4de
fmt
dafifynn Jul 14, 2023
ad0310e
add cairo_programs folder
dafifynn Jul 14, 2023
3c9ff7f
fix warnings
dafifynn Jul 14, 2023
edd9274
Merge branch 'main' into fuzz-cairo-compiled-programs
pefontana Jul 15, 2023
82194e8
Merge branch 'main' into fuzz-cairo-compiled-programs
dafifynn Jul 17, 2023
5e0a9fe
fix formatting
dafifynn Jul 17, 2023
f67aac7
add felt arbitrary
dafifynn Jul 18, 2023
7a6b1ee
add felt arbitrary
dafifynn Jul 18, 2023
f9920f7
add info to readme
dafifynn Jul 18, 2023
7da7d72
Merge branch 'main' into fuzz-cairo-compiled-programs
dafifynn Jul 18, 2023
7575a1b
add fuzzer makefile command
dafifynn Jul 18, 2023
affab55
Merge branch 'main' into fuzz-cairo-compiled-programs
dafifynn Jul 18, 2023
d4de948
fix corrections
dafifynn Jul 18, 2023
0b0e142
Merge branch 'main' into fuzz-cairo-compiled-programs
dafifynn Jul 19, 2023
d33f6ef
Merge branch 'main' into fuzz-cairo-compiled-programs
pefontana Jul 20, 2023
8f75685
Merge branch 'main' into fuzz-cairo-compiled-programs
pefontana Jul 24, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -303,3 +303,10 @@ clean:
rm -rf cairo-vm-env
rm -rf cairo-vm-pypy-env
rm -rf cairo

fuzzer-deps:
cargo +nightly install cargo-fuzz

run-cairo-compiled-fuzzer:
cd fuzzer
cargo +nightly fuzz run --fuzz-dir . cairo_compiled_programs_fuzzer
11 changes: 11 additions & 0 deletions fuzzer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,29 @@ edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[package.metadata]
cargo-fuzz = true

[workspace]
members = ["."]

[dependencies]
arbitrary = { version = "1.3.0", features = ["derive"] }
honggfuzz = "0.5.55"
libfuzzer-sys = "0.4"
bincode = { version = "2.0.0-rc.3", tag = "v2.0.0-rc.3", git = "https://github.com/bincode-org/bincode.git" }
cairo-vm = { path = "../vm", features = ["arbitrary"] }
mimalloc = { version = "0.1.29", default-features = false, optional = true }
nom = "7"
thiserror = { version = "1.0.32" }
cairo-felt = { path = "../felt", features = ["arbitrary"] }
proptest = "1.2.0"

[dev-dependencies]
assert_matches = "1.5.0"
rstest = "0.17.0"


[features]
default = ["with_mimalloc"]
with_mimalloc = ["cairo-vm/with_mimalloc", "mimalloc"]
Expand All @@ -29,6 +36,10 @@ with_mimalloc = ["cairo-vm/with_mimalloc", "mimalloc"]
name = "fuzz_json"
path = "src/fuzz_json.rs"

[[bin]]
name = "cairo_compiled_programs_fuzzer"
path = "src/cairo_compiled_programs_fuzzer.rs"

[[bin]]
name = "fuzz_program"
path = "src/fuzz_program.rs"
9 changes: 9 additions & 0 deletions fuzzer/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## fuzz_json
This fuzzer creates a json file directly from bytes.
`HFUZZ_RUN_ARGS="--dict=json.dict" cargo hfuzz run fuzz_json`

## cairo_compiled_programs_fuzzer
To run this fuzzer you need to be able to run cairo-compile command from the fuzzer folder beforehand.

To run the fuzzer you need to have installed `cargo-fuzz`. If not, use the command `cargo +nightly install cargo-fuzz`

To run simply use `cargo +nightly fuzz run --fuzz-dir . cairo_compiled_programs_fuzzer`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran cargo +nightly install fuzz, the execute this command and got

[should i run ](error: no such command: fuzz)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would guess it depends on cargo-fuzz and it needs to be installed first? In that case, we need to add it to the dependencies and document that need.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to work (well, it's compiling right now at least) after running cargo install cargo-fuzz, FWIW.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, it would be desirable to document why exactly we need to use nightly here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the command to install the tool to run this fuzzer is cargo +nightly install cargo-fuzz, i can add a command in the makefile to install the tool and other to run the fuzzer

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added the documentation and the makefile commands!


We use nightly for this fuzzer because cargo fuzz runs with the -Z flag, which only works with +nightly.
Empty file.
Loading