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

Eliminate deprecated CBOR formats #445

Merged
merged 1 commit into from
Aug 20, 2024
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -421,10 +421,6 @@ In a future version of `test-fuzz`, this behavior will be the default.

- `serde_bincode` - [Bincode] (default)

- `serde_cbor` - [Serde CBOR] (deprecated)

- `serde_cbor4ii` - [CBOR 0x(4+4)9 0x49] (deprecated)

- `serde_postcard` - [Postcard]

## Auto-generated corpus files
Expand Down Expand Up @@ -505,7 +501,6 @@ These options are incompatible in the following sense. If a fuzz target's argume

[Auto-generated corpus files]: #auto-generated-corpus-files
[Bincode]: https://github.com/bincode-org/bincode
[CBOR 0x(4+4)9 0x49]: https://github.com/quininer/cbor4ii
[Components]: #components
[Convenience functions and macros]: #convenience-functions-and-macros
[Environment variables]: #environment-variables
Expand All @@ -515,7 +510,6 @@ These options are incompatible in the following sense. If a fuzz target's argume
[Macros and Inline Functions Exception]: https://spdx.org/licenses/mif-exception.html
[Overview]: #overview
[Postcard]: https://github.com/jamesmunns/postcard
[Serde CBOR]: https://github.com/pyfisch/cbor
[Serde attributes]: https://serde.rs/attributes.html
[Substrate externalities]: https://substrate.dev/docs/en/knowledgebase/runtime/tests#mock-runtime-storage
[The Cargo Book]: https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#choosing-features
Expand Down
5 changes: 3 additions & 2 deletions examples/tests/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ mod primitive {
// https://github.com/pyfisch/cbor/pull/145
// We might use `ciborium` as an alternative to `serde_cbor`. But `ciborium` currently has no
// way to limit the size of an allocation: https://github.com/enarx/ciborium/issues/11
#[test_fuzz::test_fuzz(no_auto_generate)]
// smoelius: `serde_cbor` is no longer a supported format.
// #[test_fuzz::test_fuzz(no_auto_generate)]
fn target(
bool: bool,
i8: i8,
Expand All @@ -33,7 +34,7 @@ mod primitive {
super::consume(i8);
super::consume(i16);
super::consume(i32);
super::consume(u64);
super::consume(i64);
super::consume(i128);
super::consume(u8);
super::consume(u16);
Expand Down
4 changes: 0 additions & 4 deletions internal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,10 @@ serde = { workspace = true }

# smoelius: Serde formats
bincode = "1.3"
cbor4ii = { version = "0.3", features = ["serde1", "use_std"], optional = true }
postcard = { version = "1.0", features = ["use-std"], optional = true }
serde_cbor = { version = "0.11", optional = true }

[features]
__serde_bincode = []
__serde_cbor = ["serde_cbor"]
__serde_cbor4ii = ["cbor4ii"]
__serde_postcard = ["postcard"]

[lints]
Expand Down
7 changes: 1 addition & 6 deletions internal/build.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
fn main() {
#[cfg(not(any(
feature = "__serde_bincode",
feature = "__serde_cbor",
feature = "__serde_cbor4ii",
feature = "__serde_postcard"
)))]
#[cfg(not(any(feature = "__serde_bincode", feature = "__serde_postcard")))]
println!("cargo:rustc-cfg=serde_default");
}
25 changes: 0 additions & 25 deletions internal/src/serde_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ pub fn as_feature() -> &'static str {
#[cfg(any(serde_default, feature = "__serde_bincode"))]
formats.push("serde_bincode");

#[cfg(feature = "__serde_cbor")]
formats.push("serde_cbor");

#[cfg(feature = "__serde_cbor4ii")]
formats.push("serde_cbor4ii");

#[cfg(feature = "__serde_postcard")]
formats.push("serde_postcard");

Expand Down Expand Up @@ -52,16 +46,6 @@ pub fn serialize<T: Serialize>(args: &T) -> Vec<u8> {
.unwrap()
};

#[cfg(feature = "__serde_cbor")]
return serde_cbor::to_vec(args).unwrap();

#[cfg(feature = "__serde_cbor4ii")]
return {
let mut data = Vec::new();
cbor4ii::serde::to_writer(&mut data, args).unwrap();
data
};

#[cfg(feature = "__serde_postcard")]
return {
let mut data = Vec::new();
Expand All @@ -80,15 +64,6 @@ pub fn deserialize<T: DeserializeOwned, R: Read>(reader: R) -> Option<T> {
.ok()
};

#[cfg(feature = "__serde_cbor")]
return serde_cbor::from_reader(reader).ok();

#[cfg(feature = "__serde_cbor4ii")]
return {
let reader = std::io::BufReader::new(reader);
cbor4ii::serde::from_reader(reader).ok()
};

#[cfg(feature = "__serde_postcard")]
return {
let mut buff = [0; SLIDING_BUFFER_SIZE];
Expand Down
2 changes: 0 additions & 2 deletions test-fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ testing = { workspace = true }
cast_checks = ["dep:cast_checks", "test-fuzz-macro/__cast_checks"]
self_ty_in_mod_name = ["test-fuzz-macro/__self_ty_in_mod_name"]
serde_bincode = ["internal/__serde_bincode"]
serde_cbor = ["internal/__serde_cbor"]
serde_cbor4ii = ["internal/__serde_cbor4ii"]
serde_postcard = ["internal/__serde_postcard"]
__persistent = ["afl", "test-fuzz-macro/__persistent"]

Expand Down
7 changes: 1 addition & 6 deletions test-fuzz/build.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
fn main() {
#[cfg(not(any(
feature = "serde_bincode",
feature = "serde_cbor",
feature = "serde_cbor4ii",
feature = "serde_postcard"
)))]
#[cfg(not(any(feature = "serde_bincode", feature = "serde_postcard")))]
println!("cargo:rustc-cfg=serde_default");
}
2 changes: 2 additions & 0 deletions test-fuzz/tests/integration/serde_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ fn serde_format() {
file.read_to_end(&mut buf).unwrap();
// smoelius: CBOR stores the variant name. Hence, this test will fail if CBOR is used as the
// serialization format.
// smoelius: CBOR is no longer a supported format. Still, I see no reason to remove this
// test or the next check.
assert!(!buf.iter().any(u8::is_ascii_uppercase));
}
}