mirror of
https://github.com/openharmony/third_party_rust_http.git
synced 2026-07-01 20:44:03 -04:00
Initial fuzzer set up. (#478)
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
[package]
|
||||
name = "http-fuzz"
|
||||
version = "0.0.0"
|
||||
authors = ["David Korczynski <david@adalogics.com>"]
|
||||
publish = false
|
||||
edition = "2018"
|
||||
|
||||
[package.metadata]
|
||||
cargo-fuzz = true
|
||||
|
||||
[dependencies]
|
||||
arbitrary = { version = "1", features = ["derive"] }
|
||||
libfuzzer-sys = { version = "0.4.0", features = ["arbitrary-derive"] }
|
||||
|
||||
[dependencies.http]
|
||||
path = ".."
|
||||
|
||||
[[bin]]
|
||||
name = "fuzz_http"
|
||||
path = "src/fuzz_http.rs"
|
||||
|
||||
[workspace]
|
||||
@@ -0,0 +1,27 @@
|
||||
#![no_main]
|
||||
|
||||
use http::Request;
|
||||
use http::Response;
|
||||
use http::StatusCode;
|
||||
use libfuzzer_sys::arbitrary::Arbitrary;
|
||||
use libfuzzer_sys::fuzz_target;
|
||||
|
||||
#[derive(Debug, Arbitrary)]
|
||||
struct HttpSpec {
|
||||
uri: Vec<u8>,
|
||||
header_name: Vec<u8>,
|
||||
header_value: Vec<u8>,
|
||||
status_codes: Vec<u8>,
|
||||
}
|
||||
|
||||
fuzz_target!(|inp: HttpSpec| {
|
||||
let _ = Request::builder()
|
||||
.uri(&inp.uri[..])
|
||||
.header(&inp.header_name[..], &inp.header_value[..])
|
||||
.body(());
|
||||
|
||||
let _ = Response::builder()
|
||||
.header(&inp.header_name[..], &inp.header_value[..])
|
||||
.body(());
|
||||
let _ = StatusCode::from_bytes(&inp.status_codes[..]);
|
||||
});
|
||||
Reference in New Issue
Block a user