Skip to content

Commit

Permalink
Deprecate CBOR as a serialization format
Browse files Browse the repository at this point in the history
  • Loading branch information
smoelius committed Apr 12, 2024
1 parent 5bda6c3 commit 1d0aab5
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ jobs:
strategy:
fail-fast: false
matrix:
serde_format: [bincode, cbor, cbor4ii, postcard]
serde_format: [bincode, postcard]
toolchain: [stable, nightly]
self_ty_in_mod_name: [false, true]

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -407,9 +407,9 @@ The `test-fuzz` package currently supports the following features:

- `serde_bincode` - [Bincode] (default)

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

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

- `serde_postcard` - [Postcard]

Expand Down
11 changes: 2 additions & 9 deletions cargo-test-fuzz/tests/fuzz_generic.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use internal::{dirs::corpus_directory_from_target, serde_format};
use internal::dirs::corpus_directory_from_target;
use predicates::prelude::*;
use std::{fs::remove_dir_all, sync::Mutex};
use testing::{examples, retry, CommandExt};
Expand All @@ -10,14 +10,7 @@ const MAX_TOTAL_TIME: &str = "60";
fn fuzz_foo_qwerty() {
// smoelius: When `bincode` is enabled, `cargo-afl` fails because "the program crashed with one
// of the test cases provided."
fuzz(
"test_foo_qwerty",
if serde_format::serializes_variant_names() {
1
} else {
2
},
);
fuzz("test_foo_qwerty", 2);
}

#[cfg_attr(dylint_lib = "general", allow(non_thread_safe_call_in_test))]
Expand Down
15 changes: 0 additions & 15 deletions internal/src/serde_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,6 @@ pub fn as_feature() -> &'static str {
formats.pop().expect("No serde format selected")
}

#[must_use]
pub const fn serializes_variant_names() -> bool {
#[cfg(any(serde_default, feature = "__serde_bincode"))]
return false;

#[cfg(feature = "__serde_cbor")]
return true;

#[cfg(feature = "__serde_cbor4ii")]
return true;

#[cfg(feature = "__serde_postcard")]
return false;
}

pub fn serialize<T: Serialize>(args: &T) -> Vec<u8> {
#[cfg(any(serde_default, feature = "__serde_bincode"))]
return {
Expand Down
8 changes: 3 additions & 5 deletions test-fuzz/tests/serde_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@ fn serde_format() {
let mut file = File::open(path).unwrap();
let mut buf = Vec::new();
file.read_to_end(&mut buf).unwrap();
// smoelius: CBOR stores the variant name.
assert_eq!(
cfg!(any(feature = "serde_cbor", feature = "serde_cbor4ii")),
buf.iter().any(u8::is_ascii_uppercase)
);
// smoelius: CBOR stores the variant name. Hence, this test will fail if CBOR is used as the
// serialization format.
assert!(!buf.iter().any(u8::is_ascii_uppercase));
}
}

0 comments on commit 1d0aab5

Please sign in to comment.