Skip to content

Commit fec48ea

Browse files
committed
request fuzzing. test stability fixes
1 parent 8e36945 commit fec48ea

27 files changed

+369
-315
lines changed

Cargo.lock

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[workspace]
22
resolver = "3"
33
members = [
4+
"fuzz",
45
"tansu",
56
"tansu-broker",
67
"tansu-cat",
@@ -102,6 +103,7 @@ iceberg-catalog-rest = "0.8"
102103
iceberg-datafusion = "0.8"
103104
jsonschema = "0.41.0"
104105
lazy_static = "1.4.0"
106+
libfuzzer-sys = "0.4"
105107
libsql = { version = "0.9.18", default-features = false, features = ["core"] }
106108
lz4 = "1.28.1"
107109
nanoid = "0.4.0"

codebook.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ words = [
22
"clippy",
33
"rustfmt",
44
"temporality",
5+
"topition",
56
]

fuzz/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
target
2+
corpus
3+
artifacts
4+
coverage
Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,45 @@
11
[package]
2-
name = "tansu-sans-io-fuzz"
3-
version = "0.0.0"
2+
name = "fuzz"
3+
version.workspace = true
44
publish = false
5-
edition = "2024"
5+
edition.workspace = true
66

77
[package.metadata]
88
cargo-fuzz = true
99

10-
[workspace]
11-
1210
[dependencies]
13-
libfuzzer-sys = "0.4"
14-
tansu-sans-io = { path = ".." }
15-
bytes = "1"
11+
bytes.workspace = true
12+
libfuzzer-sys.workspace = true
13+
tansu-sans-io.workspace = true
14+
15+
[[bin]]
16+
name = "generate_seeds"
17+
path = "fuzz_targets/generate_seeds.rs"
1618

1719
[[bin]]
1820
name = "fuzz_request_decode"
1921
path = "fuzz_targets/fuzz_request_decode.rs"
22+
test = false
23+
doc = false
24+
bench = false
2025

2126
[[bin]]
2227
name = "fuzz_response_decode"
2328
path = "fuzz_targets/fuzz_response_decode.rs"
29+
test = false
30+
doc = false
31+
bench = false
2432

2533
[[bin]]
2634
name = "fuzz_deflated_batch"
2735
path = "fuzz_targets/fuzz_deflated_batch.rs"
36+
test = false
37+
doc = false
38+
bench = false
2839

2940
[[bin]]
3041
name = "fuzz_varint"
3142
path = "fuzz_targets/fuzz_varint.rs"
43+
test = false
44+
doc = false
45+
bench = false
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright ⓒ 2024-2026 Peter Morgan <peter.james.morgan@gmail.com>
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#![no_main]
16+
use bytes::Bytes;
17+
use libfuzzer_sys::fuzz_target;
18+
use tansu_sans_io::record::deflated;
19+
20+
fuzz_target!(|data: &[u8]| {
21+
let _ = deflated::Batch::try_from(Bytes::copy_from_slice(data));
22+
});
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright ⓒ 2024-2026 Peter Morgan <peter.james.morgan@gmail.com>
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#![no_main]
16+
use bytes::Bytes;
17+
use libfuzzer_sys::fuzz_target;
18+
use tansu_sans_io::Frame;
19+
20+
fuzz_target!(|data: &[u8]| {
21+
let _ = Frame::request_from_bytes(Bytes::copy_from_slice(data));
22+
});
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright ⓒ 2024-2026 Peter Morgan <peter.james.morgan@gmail.com>
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#![no_main]
16+
use bytes::Bytes;
17+
use libfuzzer_sys::fuzz_target;
18+
use tansu_sans_io::Frame;
19+
20+
fuzz_target!(|data: &[u8]| {
21+
if data.len() < 4 {
22+
return;
23+
}
24+
let api_key = i16::from_be_bytes([data[0], data[1]]);
25+
let api_version = i16::from_be_bytes([data[2], data[3]]);
26+
let payload = Bytes::copy_from_slice(&data[4..]);
27+
let _ = Frame::response_from_bytes(payload, api_key, api_version);
28+
});

fuzz/fuzz_targets/fuzz_varint.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright ⓒ 2024-2026 Peter Morgan <peter.james.morgan@gmail.com>
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#![no_main]
16+
use bytes::Bytes;
17+
use libfuzzer_sys::fuzz_target;
18+
use tansu_sans_io::Decode;
19+
use tansu_sans_io::primitive::varint::{LongVarInt, VarInt};
20+
21+
fuzz_target!(|data: &[u8]| {
22+
let mut buf = Bytes::copy_from_slice(data);
23+
let _ = VarInt::decode(&mut buf);
24+
25+
let mut buf = Bytes::copy_from_slice(data);
26+
let _ = LongVarInt::decode(&mut buf);
27+
});

tansu-sans-io/fuzz/fuzz_targets/generate_seeds.rs renamed to fuzz/fuzz_targets/generate_seeds.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright ⓒ 2024-2026 Peter Morgan <peter.james.morgan@gmail.com>
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
//! Seed corpus generator for fuzz targets.
216
//!
317
//! Run with: cargo +nightly run --manifest-path fuzz/Cargo.toml --bin generate_seeds

0 commit comments

Comments
 (0)