feat(fuzz): add fuzz targets for IPC, blackbox, updater, session, and metrics#56
feat(fuzz): add fuzz targets for IPC, blackbox, updater, session, and metrics#56EffortlessSteven wants to merge 1 commit into
Conversation
… metrics - flight-ipc: add fuzz_message_decode for selector-based protobuf + JSON decoding - flight-blackbox: codec decode fuzzing (postcard + JSON export DTOs) - flight-updater: manifest JSON parsing and semver fuzzing - flight-session: persistence deserialization fuzzing (SessionState + components) - flight-metrics: export formatting fuzzing (Prometheus + JSON with edge-case values) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (10)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Review Summary by QodoAdd fuzz targets for IPC, blackbox, updater, session, and metrics crates
WalkthroughsDescription• Add five new fuzz targets for parser/decoder robustness testing • flight-ipc: selector-based protobuf and JSON message decoding • flight-blackbox: postcard and JSON export DTO deserialization • flight-updater: manifest JSON and SemVer string parsing • flight-session: SessionState and component type JSON deserialization • flight-metrics: Prometheus/JSON export formatting with edge-case values Diagramflowchart LR
A["Fuzz Targets"] --> B["flight-ipc<br/>Message Decode"]
A --> C["flight-blackbox<br/>Codec"]
A --> D["flight-updater<br/>Manifest Parse"]
A --> E["flight-session<br/>State Deserialize"]
A --> F["flight-metrics<br/>Export Format"]
B --> G["Protobuf + JSON"]
C --> H["Postcard + JSON DTOs"]
D --> I["JSON + SemVer"]
E --> J["SessionState + Components"]
F --> K["Prometheus + JSON"]
File Changes1. crates/flight-ipc/fuzz/fuzz_targets/fuzz_message_decode.rs
|
Code Review by Qodo
1. IPC JSON uses wrong bytes
|
There was a problem hiding this comment.
Pull request overview
Adds new libFuzzer targets across several crates to exercise parsers/decoders and formatting paths with arbitrary input, aiming to catch panics and robustness issues early.
Changes:
- Added new fuzz targets for IPC message decoding, blackbox codec deserialization, updater manifest/SemVer parsing, session state deserialization, and metrics export formatting.
- Introduced standalone
cargo-fuzzcrates (edition 2024) forflight-updater,flight-session,flight-blackbox, andflight-metrics. - Extended
flight-ipc’s existing fuzz crate with an additional fuzz target binary.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/flight-updater/fuzz/fuzz_targets/fuzz_manifest_parse.rs | Adds fuzzing for manifest JSON parsing and SemVer parsing paths |
| crates/flight-updater/fuzz/Cargo.toml | Defines standalone cargo-fuzz crate + fuzz target bin |
| crates/flight-session/fuzz/fuzz_targets/fuzz_session_state.rs | Adds fuzzing for session persisted-state JSON deserialization |
| crates/flight-session/fuzz/Cargo.toml | Defines standalone cargo-fuzz crate + fuzz target bin |
| crates/flight-metrics/fuzz/fuzz_targets/fuzz_metrics_export.rs | Adds fuzzing for Prometheus/JSON export formatting with edge-case inputs |
| crates/flight-metrics/fuzz/Cargo.toml | Defines standalone cargo-fuzz crate + fuzz target bin |
| crates/flight-ipc/fuzz/fuzz_targets/fuzz_message_decode.rs | Adds selector-based protobuf decode + JSON IPC decode fuzzing |
| crates/flight-ipc/fuzz/Cargo.toml | Registers the new IPC fuzz target binary |
| crates/flight-blackbox/fuzz/fuzz_targets/fuzz_blackbox_codec.rs | Adds fuzzing for postcard + JSON deserialization of blackbox/export types |
| crates/flight-blackbox/fuzz/Cargo.toml | Defines standalone cargo-fuzz crate + fuzz target bin |
| } | ||
| 4 => { | ||
| let _ = flight_ipc::proto::HealthSubscribeRequest::decode(payload); | ||
| let _ = flight_ipc::proto::GetSupportBundleResponse::decode(payload); |
There was a problem hiding this comment.
The selector 4 arm decodes HealthSubscribeRequest but then decodes GetSupportBundleResponse, which looks like an accidental mismatch and reduces coverage of the intended request/response pair. Consider decoding HealthSubscribeResponse here (and moving support-bundle decode into its own selector arm, or decoding both request+response consistently for the same API).
| let _ = flight_ipc::proto::GetSupportBundleResponse::decode(payload); | |
| let _ = flight_ipc::proto::HealthSubscribeResponse::decode(payload); |
| #![no_main] | ||
|
|
||
| use libfuzzer_sys::fuzz_target; | ||
| use prost::Message; |
There was a problem hiding this comment.
This fuzz target imports prost::Message directly; in Cargo, crates generally must list prost as a direct dependency to use prost::... (transitive deps typically aren’t usable by name). If the crates/flight-ipc/fuzz/Cargo.toml doesn’t already include prost, add it under [dependencies] (aligned to the workspace’s prost/prost-types versions) to avoid a compile failure.
| use prost::Message; |
| fuzz_target!(|data: &[u8]| { | ||
| // Primary: exercise the manifest JSON parser. | ||
| let _ = flight_updater::parse_manifest(data); | ||
|
|
||
| // Also try direct serde deserialization of component types. | ||
| let _ = serde_json::from_slice::<flight_updater::SignedUpdateManifest>(data); | ||
| let _ = serde_json::from_slice::<flight_updater::FileUpdate>(data); | ||
| let _ = serde_json::from_slice::<flight_updater::SemVer>(data); | ||
|
|
||
| // Fuzz the string-based semver parser. | ||
| if let Ok(s) = std::str::from_utf8(data) { | ||
| let _ = flight_updater::SemVer::parse(s); | ||
| } | ||
| }); |
There was a problem hiding this comment.
The fuzz target feeds the full data buffer into multiple parsers (JSON + SemVer). With larger inputs this can tank fuzz throughput and increase timeouts without improving coverage. Consider adding a max-size cap early in the harness (e.g., return if data.len() exceeds some reasonable limit like 64 KiB) and/or cap the UTF-8 string length passed into SemVer::parse.
| registry.register_counter(&name, &help, labels.clone(), value); | ||
| registry.register_gauge(&name, &help, labels, value); |
There was a problem hiding this comment.
Both a counter and a gauge are registered with the exact same metric name. In Prometheus conventions, reusing a metric name across different types is typically invalid and may lead to deterministic 'already registered' behavior (reducing fuzz effectiveness to mostly that error path). Consider deriving distinct names for counter vs gauge (e.g., from different slices or adding a suffix) so the harness explores more of the export/formatting logic.
CI Feedback 🧐A test triggered by this PR failed. Here is an AI-generated analysis of the failure:
|
Summary
Adds fuzz targets for recently implemented crates to catch parser/decoder bugs.
New Fuzz Targets
Notes