Skip to content

Cosmos: Implement Binary Encoding RFC Fuzz - #4977

Draft
Debdatta Kunda (kundadebdatta) wants to merge 3 commits into
mainfrom
users/kundadebdatta/4864_binary_codec_cargo_fuzz
Draft

Cosmos: Implement Binary Encoding RFC Fuzz#4977
Debdatta Kunda (kundadebdatta) wants to merge 3 commits into
mainfrom
users/kundadebdatta/4864_binary_codec_cargo_fuzz

Conversation

@kundadebdatta

@kundadebdatta Debdatta Kunda (kundadebdatta) commented Aug 3, 2026

Copy link
Copy Markdown
Member

Summary

Adds byte-level (wire-format) fuzzing for the binary-JSON codec, plus a draft encoding RFC spec and golden-vector conformance tests. Where #4976 validates that well-formed values survive a live round-trip, this PR hardens the decoder against arbitrary/malformed bytes it must never crash on — a complementary, offline safety check.

How it works

sequenceDiagram
    participant L as libFuzzer
    participant D as Codec (decode / from_slice / transcode)
    L->>L: mutate bytes (seeded from golden vectors)
    L->>D: feed arbitrary buffer
    D-->>L: Ok(Value) or Err(_) — never panic/hang
    Note over L,D: decode → encode → decode idempotence also checked
Loading
  • Targets: decode, from_slice, transcode_to_text, decode_reencode_roundtrip (isolated cargo-fuzz crate, nightly + libFuzzer).
  • Oracle: robustness (no panic/hang/over-allocation) + pinned golden-byte conformance snapshots.
  • CI: weekly Build stage replays the committed golden corpus (-runs=0, ContinueOnError=true); per-PR coverage comes from the offline conformance unit tests.
  • RFC spec (BINARY_ENCODING_RFC.md) documents the wire format and is pending backend-team review.

Validation

  • 4 golden-vector conformance unit tests pass.

Running

rustup toolchain install nightly && cargo install cargo-fuzz
cd sdk/cosmos/azure_data_cosmos_driver
cargo +nightly fuzz run decode          # or from_slice / transcode_to_text / decode_reencode_roundtrip

Byte/wire-format validation for the Cosmos binary JSON codec, independent of
any live account:

- azure_data_cosmos_driver/fuzz: isolated cargo-fuzz crate (nightly/libFuzzer)
  with decode, from_slice, transcode_to_text, decode_reencode_roundtrip targets
- binary_json/conformance.rs: offline golden-vector conformance unit tests
- testdata/binary_json_vectors.json: golden byte vectors
- fuzz-matrix.json + ci.yml MatrixConfigs: weekly Build-stage -runs=0 replay
- Run-BinaryJsonFuzz.ps1 + Invoke-CosmosTestSetup.ps1 fuzz hook
- BINARY_ENCODING_RFC.md: wire-format spec (pending backend-team review)

Split out of the original combined PR (#4898); the live e2e round-trip fuzzer
is delivered separately.
@github-actions github-actions Bot added the Cosmos The azure_cosmos crate label Aug 3, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
2 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@kundadebdatta

Copy link
Copy Markdown
Member Author

/azp run rust - cosmos - weekly

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@kundadebdatta Debdatta Kunda (kundadebdatta) changed the title Cosmos: Implement Binary Encoding RFC Fuzz- #4930 Cosmos: Implement Binary Encoding RFC Fuzz Aug 4, 2026
@kundadebdatta
Debdatta Kunda (kundadebdatta) force-pushed the users/kundadebdatta/4864_binary_codec_cargo_fuzz branch from 056e7ed to 0151dce Compare August 5, 2026 01:07
@kundadebdatta

Copy link
Copy Markdown
Member Author

/azp run rust - cosmos - weekly

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

binary-encoding Cosmos The azure_cosmos crate

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

2 participants