Skip to content
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
21 changes: 21 additions & 0 deletions fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,24 @@ path = "fuzz_targets/manifest_parser.rs"
test = false
doc = false
bench = false

[[bin]]
name = "block_parser"
path = "fuzz_targets/block_parser.rs"
test = false
doc = false
bench = false

[[bin]]
name = "mark_parser"
path = "fuzz_targets/mark_parser.rs"
test = false
doc = false
bench = false

[[bin]]
name = "content_parser"
path = "fuzz_targets/content_parser.rs"
test = false
doc = false
bench = false
17 changes: 17 additions & 0 deletions fuzz/fuzz_targets/block_parser.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//! Fuzz target for Block deserialization.
//!
//! This target tests the custom `Deserialize` impl for `Block` which
//! dispatches on the `"type"` field to construct the correct variant.
//! Exercises all 20+ block type code paths with arbitrary JSON input.

#![no_main]

use libfuzzer_sys::fuzz_target;

fuzz_target!(|data: &[u8]| {
// Try parsing as a single Block
let _ = serde_json::from_slice::<cdx_core::content::Block>(data);

// Also try parsing as a Vec<Block> (nested children)
let _ = serde_json::from_slice::<Vec<cdx_core::content::Block>>(data);
});
15 changes: 15 additions & 0 deletions fuzz/fuzz_targets/content_parser.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//! Fuzz target for Content deserialization.
//!
//! This target tests parsing of the full `Content` structure which
//! contains a version field and a blocks array. Exercises the complete
//! content deserialization pipeline including nested blocks and text
//! nodes with marks.

#![no_main]

use libfuzzer_sys::fuzz_target;

fuzz_target!(|data: &[u8]| {
// Try parsing as a full Content structure
let _ = serde_json::from_slice::<cdx_core::content::Content>(data);
});
18 changes: 18 additions & 0 deletions fuzz/fuzz_targets/mark_parser.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//! Fuzz target for Mark deserialization.
//!
//! This target tests the custom `Deserialize` impl for `Mark` which
//! handles both simple string marks (e.g., `"bold"`) and complex object
//! marks (e.g., `{"type": "link", "href": "..."}`). Exercises all 15+
//! mark type code paths with arbitrary input.

#![no_main]

use libfuzzer_sys::fuzz_target;

fuzz_target!(|data: &[u8]| {
// Try parsing as a single Mark
let _ = serde_json::from_slice::<cdx_core::content::Mark>(data);

// Also try parsing as a Vec<Mark> (text node marks array)
let _ = serde_json::from_slice::<Vec<cdx_core::content::Mark>>(data);
});