From 56f9667cc4b870e3b7f9a5804757648c05b50fa6 Mon Sep 17 00:00:00 2001 From: Samuel Moelius Date: Tue, 20 Aug 2024 00:26:50 +0000 Subject: [PATCH] Eliminate deprecated CBOR formats --- README.md | 6 ----- examples/tests/serde.rs | 5 +++-- internal/Cargo.toml | 4 ---- internal/build.rs | 7 +----- internal/src/serde_format.rs | 25 --------------------- test-fuzz/Cargo.toml | 2 -- test-fuzz/build.rs | 7 +----- test-fuzz/tests/integration/serde_format.rs | 2 ++ 8 files changed, 7 insertions(+), 51 deletions(-) diff --git a/README.md b/README.md index b23fa446..e10376fa 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 @@ -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 diff --git a/examples/tests/serde.rs b/examples/tests/serde.rs index eae1a5fb..0adc76a5 100644 --- a/examples/tests/serde.rs +++ b/examples/tests/serde.rs @@ -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, @@ -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); diff --git a/internal/Cargo.toml b/internal/Cargo.toml index dcbbf241..e124c9f2 100644 --- a/internal/Cargo.toml +++ b/internal/Cargo.toml @@ -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] diff --git a/internal/build.rs b/internal/build.rs index d96f2def..b91814ef 100644 --- a/internal/build.rs +++ b/internal/build.rs @@ -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"); } diff --git a/internal/src/serde_format.rs b/internal/src/serde_format.rs index f3f88e1b..1143c4ae 100644 --- a/internal/src/serde_format.rs +++ b/internal/src/serde_format.rs @@ -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"); @@ -52,16 +46,6 @@ pub fn serialize(args: &T) -> Vec { .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(); @@ -80,15 +64,6 @@ pub fn deserialize(reader: R) -> Option { .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]; diff --git a/test-fuzz/Cargo.toml b/test-fuzz/Cargo.toml index e3f6abe0..599882ef 100644 --- a/test-fuzz/Cargo.toml +++ b/test-fuzz/Cargo.toml @@ -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"] diff --git a/test-fuzz/build.rs b/test-fuzz/build.rs index 94894bc1..37cdea9f 100644 --- a/test-fuzz/build.rs +++ b/test-fuzz/build.rs @@ -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"); } diff --git a/test-fuzz/tests/integration/serde_format.rs b/test-fuzz/tests/integration/serde_format.rs index 1ac09ab3..bf0b6aa4 100644 --- a/test-fuzz/tests/integration/serde_format.rs +++ b/test-fuzz/tests/integration/serde_format.rs @@ -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)); } }