Skip to content

test(graph-rs): add the fuzz input decoder and the Cypher and JSON fuzz targets - #3442

Merged
vitali87 merged 2 commits into
mainfrom
pr-split/claude-cgr-graph-rs-fuzz/pr-1
Oct 27, 2026
Merged

vitali87 merged 2 commits into
mainfrom
pr-split/claude-cgr-graph-rs-fuzz/pr-1

Conversation

@vitali87

@vitali87 vitali87 commented Oct 24, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • First part of a cargo-fuzz package for rust/cgr_graph_rs. src/lib.rs is the shared input decoder, total over every byte string, and require!, which aborts when a property is false.
  • cypher_parse: the lexer's tokens cover the query in order, and each span holds what its kind says. Lexer errors and deferrals point at the character that caused them. parse returns the lexer's error unchanged, and otherwise only grammar errors within the query.
  • json_string: push_string writes printable ASCII that a JSON parser reads back to the same string, with exactly the escapes json.dumps writes (lowercase hex, surrogate pairs above the BMP).
  • The package's Cargo.toml comes last in this stack, so nothing builds a partial package.

Demo

No user-visible change: fuzz targets only. Nothing in the package, CI or the wheel builds rust/cgr_graph_rs/fuzz.

Type of Change

  • CI/CD or tooling

Related Issues

None.

Test plan

Run on the whole stack, since the package builds once its manifest lands in the last PR:

  • Red: each property in these targets goes red under a one-line change to the library. The property's comment names the change and the input that aborts; each was run against the mutated library, and the property it documents is the one that fired.
  • Green: the unmutated library runs each target with no abort, for 10 minutes from the seed corpus after the shorter runs that built it.
  • Negative tests: every check here is a negative test by construction. It aborts on output the library must not produce, and its mutant shows the abort happens.
  • Coverage: a minimized seed corpus runs every API call and every property check in each target (cargo fuzz coverage).
  • cargo +nightly-2025-07-16 check --bins passes, as well as the current nightly.

Files changed

  • rust/cgr_graph_rs/fuzz/.gitignore
  • rust/cgr_graph_rs/fuzz/src/lib.rs
  • rust/cgr_graph_rs/fuzz/fuzz_targets/json_string.rs
  • rust/cgr_graph_rs/fuzz/fuzz_targets/cypher_parse.rs

Diff stats

+398 additions, -0 deletions (398 LOC)

Dependency graph

Merge in this order:

pr-1: test(graph-rs): add the fuzz input decoder and the Cypher and JSON fuzz targets  <-- this PR
└── pr-2: test(graph-rs): add the graph procedures fuzz target
    └── pr-3: test(graph-rs): add the bulk writer and walk fuzz target
        └── pr-4: test(graph-rs): add the fuzz package manifest

Summary by CodeRabbit

  • Tests
    • Added fuzz testing for Cypher parsing and JSON string escaping, checking that malformed input is handled safely and valid output preserves its content.
    • Expanded randomized input coverage for text, numbers, and other values, with checks for token boundaries, error locations, and formatted syntax errors.
    • Added exclusions for generated fuzzing files so they do not clutter the repository.

@greptile-apps

This comment has been minimized.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-24T23:17:33.093628Z 7a81711 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@vitali87
vitali87 added this pull request to stack #3446 October 24, 2026 23:15
@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration
Commits

Reviewing files that changed from the base of the PR and between 7a81711 and cf1d4e3.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 0db39cb and 7a81711.

Files selected for processing: 4
  • rust/cgr_graph_rs/fuzz/.gitignore
  • rust/cgr_graph_rs/fuzz/fuzz_targets/cypher_parse.rs
  • rust/cgr_graph_rs/fuzz/fuzz_targets/json_string.rs
  • rust/cgr_graph_rs/fuzz/src/lib.rs

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 3 remain after this review.

Walkthrough

The Rust fuzz package adds shared input utilities and fuzz targets for Cypher parsing and JSON string encoding. The targets check parser and lexer invariants, as well as JSON string output and decoding properties.

Changes: Rust fuzz package

Layer / File(s) Summary
Shared fuzz input support
rust/cgr_graph_rs/fuzz/src/lib.rs, rust/cgr_graph_rs/fuzz/.gitignore
Adds the require! macro and Input methods for reading and decoding fuzz input. Adds ignore rules for generated fuzz data.
Cypher lexing and parsing checks
rust/cgr_graph_rs/fuzz/fuzz_targets/cypher_parse.rs
Adds checks for lexer and parser errors, token spans and values, and error positions.
JSON string encoding checks
rust/cgr_graph_rs/fuzz/fuzz_targets/json_string.rs
Adds checks for output prefix preservation, printable-ASCII output, and canonical escape decoding.

Priority: Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Other

Possibly related PRs

Merge Risk: Minimal · up to 7a817

No actionable issue remains in this PR’s fuzz targets; the change is ready to merge after normal checks.

Pre-merge checks: Passed 4
Check name Status Explanation
Title check Passed The title clearly identifies the shared fuzz input decoder and the Cypher and JSON fuzz targets. It is concise, specific, and related to the main changes.
Description check Passed The description provides a clear summary, explains the lack of user-visible changes, identifies the change type, states related issues, and gives detailed test results. The checklist section from the …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description provides a clear summary, explains the lack of user-visible changes, identifies the change type, states related issues, and gives detailed test results. The checklist section from the template is missing, but the description is otherwise complete.

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] Appears safe to merge in the stated stack order, with PR #3445 supplying the fuzz package manifest.

Summary

Adds shared fuzz input helpers and targets for Cypher parsing and JSON string escaping.

  • Cypher fuzz runs check how queries are tokenized and parsed.
  • JSON string fuzz runs check how strings are written.
  • Fuzz targets share input tools and ignore generated files.

Reviews (1) · Last reviewed commit: "test(graph-rs): add the fuzz input decod..." · Reviewed by Greptile

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NVdycfDFvbqaoyHWVWHJ1N
@sonarqubecloud

Copy link
Copy Markdown

@vitali87
vitali87 merged commit 9441a73 into main Oct 27, 2026
62 checks passed
@vitali87
vitali87 deleted the pr-split/claude-cgr-graph-rs-fuzz/pr-1 branch October 27, 2026 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants