Skip to content

Add fuzzing dictionaries and document them in FUZZING.md - #1191

Merged
tomtau merged 7 commits into
pest-parser:masterfrom
estr3llas:fuzz-grammar-dicts
Aug 11, 2026
Merged

Add fuzzing dictionaries and document them in FUZZING.md#1191
tomtau merged 7 commits into
pest-parser:masterfrom
estr3llas:fuzz-grammar-dicts

Conversation

@estr3llas

@estr3llas estr3llas commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Adding dictionaries for dictionary-guided fuzzing for the following fuzz targets:

  • JSON
  • TOML
  • HTTP
  • SQL

Also, updating the FUZZING.md file with the latests contributions.

estrellas@ubuntu:~/pest/grammars/fuzz$ cargo fuzz run json -- -dict=dict/json.dict -runs=0
    Finished `release` profile [optimized + debuginfo] target(s) in 0.01s
    Finished `release` profile [optimized + debuginfo] target(s) in 0.01s
     Running `target/x86_64-unknown-linux-gnu/release/json -artifact_prefix=/home/estrellas/pest/grammars/fuzz/artifacts/json/ -dict=dict/json.dict -runs=0 /home/estrellas/pest/grammars/fuzz/corpus/json`
Dictionary: 56 entries
INFO: Seed: 403833159
INFO: Loaded 1 modules   (8989 inline 8-bit counters): 8989 [0x5c89b290a540, 0x5c89b290c85d),
INFO: Loaded 1 PC tables (8989 PCs): 8989 [0x5c89b290c860,0x5c89b292fa30),
INFO:     1034 files found in /home/estrellas/pest/grammars/fuzz/corpus/json
INFO: -max_len is not provided; libFuzzer will not generate inputs larger than 4096 bytes
INFO: seed corpus: files: 1034 min: 1b max: 518b total: 54137b rss: 32Mb
#1035   INITED cov: 1231 ft: 5680 corp: 609/31Kb exec/s: 0 rss: 81Mb
#1035   DONE   cov: 1231 ft: 5680 corp: 609/31Kb lim: 518 exec/s: 0 rss: 81Mb
Done 1035 runs in 0 second(s)
estrellas@ubuntu:~/pest/grammars/fuzz$ cargo fuzz run toml -- -dict=dict/toml.dict -runs=0
    Finished `release` profile [optimized + debuginfo] target(s) in 0.01s
    Finished `release` profile [optimized + debuginfo] target(s) in 0.01s
     Running `target/x86_64-unknown-linux-gnu/release/toml -artifact_prefix=/home/estrellas/pest/grammars/fuzz/artifacts/toml/ -dict=dict/toml.dict -runs=0 /home/estrellas/pest/grammars/fuzz/corpus/toml`
Dictionary: 51 entries
INFO: Seed: 561897703
INFO: Loaded 1 modules   (14726 inline 8-bit counters): 14726 [0x63d9b0a362a0, 0x63d9b0a39c26),
INFO: Loaded 1 PC tables (14726 PCs): 14726 [0x63d9b0a39c28,0x63d9b0a73488),
INFO:     1452 files found in /home/estrellas/pest/grammars/fuzz/corpus/toml
INFO: -max_len is not provided; libFuzzer will not generate inputs larger than 4096 bytes
INFO: seed corpus: files: 1452 min: 1b max: 305b total: 71181b rss: 33Mb
#1453   INITED cov: 2601 ft: 11827 corp: 878/43Kb exec/s: 0 rss: 109Mb
#1453   DONE   cov: 2601 ft: 11827 corp: 878/43Kb lim: 305 exec/s: 0 rss: 109Mb
Done 1453 runs in 0 second(s)
estrellas@ubuntu:~/pest/grammars/fuzz$ cargo fuzz run http -- -dict=dict/http.dict -runs=0
    Finished `release` profile [optimized + debuginfo] target(s) in 0.01s
    Finished `release` profile [optimized + debuginfo] target(s) in 0.01s
     Running `target/x86_64-unknown-linux-gnu/release/http -artifact_prefix=/home/estrellas/pest/grammars/fuzz/artifacts/http/ -dict=dict/http.dict -runs=0 /home/estrellas/pest/grammars/fuzz/corpus/http`
Dictionary: 44 entries
INFO: Seed: 4242666603
INFO: Loaded 1 modules   (6503 inline 8-bit counters): 6503 [0x5ef07f6884a0, 0x5ef07f689e07),
INFO: Loaded 1 PC tables (6503 PCs): 6503 [0x5ef07f689e08,0x5ef07f6a3478),
INFO:      578 files found in /home/estrellas/pest/grammars/fuzz/corpus/http
INFO: -max_len is not provided; libFuzzer will not generate inputs larger than 4096 bytes
INFO: seed corpus: files: 578 min: 1b max: 552b total: 43464b rss: 31Mb
#579    INITED cov: 1166 ft: 4026 corp: 377/25Kb exec/s: 0 rss: 54Mb
#579    DONE   cov: 1166 ft: 4026 corp: 377/25Kb lim: 552 exec/s: 0 rss: 54Mb
Done 579 runs in 0 second(s)
estrellas@ubuntu:~/pest/grammars/fuzz$ cargo fuzz run sql -- -dict=dict/sql.dict -runs=0
    Finished `release` profile [optimized + debuginfo] target(s) in 0.01s
    Finished `release` profile [optimized + debuginfo] target(s) in 0.01s
     Running `target/x86_64-unknown-linux-gnu/release/sql -artifact_prefix=/home/estrellas/pest/grammars/fuzz/artifacts/sql/ -dict=dict/sql.dict -runs=0 /home/estrellas/pest/grammars/fuzz/corpus/sql`
Dictionary: 76 entries
INFO: Seed: 3423327090
INFO: Loaded 1 modules   (38282 inline 8-bit counters): 38282 [0x55d8dbc4ba60, 0x55d8dbc54fea),
INFO: Loaded 1 PC tables (38282 PCs): 38282 [0x55d8dbc54ff0,0x55d8dbcea890),
INFO:      357 files found in /home/estrellas/pest/grammars/fuzz/corpus/sql
INFO: -max_len is not provided; libFuzzer will not generate inputs larger than 4096 bytes
INFO: seed corpus: files: 357 min: 1b max: 1461b total: 39274b rss: 33Mb
#358    INITED cov: 279 ft: 669 corp: 132/13343b exec/s: 0 rss: 43Mb
#358    DONE   cov: 279 ft: 669 corp: 132/13343b lim: 1461 exec/s: 0 rss: 43Mb
Done 358 runs in 0 second(s)

Summary by CodeRabbit

  • Documentation

    • Added guidance for running SQL fuzzing with its corresponding token dictionary.
    • Documented grammar token dictionaries and the fourth SQL fuzz target.
  • Testing

    • Added syntax dictionaries for HTTP, JSON, SQL, and TOML fuzzing.
    • Expanded coverage of common valid, malformed, and edge-case inputs.
    • Added coverage output to the fuzzing ignore rules.

@estr3llas
estr3llas requested a review from a team as a code owner August 10, 2026 18:42
@estr3llas
estr3llas requested review from tomtau and removed request for a team August 10, 2026 18:42
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 3abc0081-8d90-4179-877f-ff41e5805a84

📥 Commits

Reviewing files that changed from the base of the PR and between b1d9a6d and 80e3d96.

📒 Files selected for processing (1)
  • FUZZING.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • FUZZING.md

📝 Walkthrough

Walkthrough

The PR adds HTTP, JSON, SQL, and TOML libFuzzer dictionaries. It documents the SQL fuzz target, dictionary usage, dictionary paths, and libFuzzer startup reporting. It also ignores fuzzing coverage output.

Changes

Fuzzing dictionaries

Layer / File(s) Summary
Grammar token dictionaries and workspace ignore rules
grammars/fuzz/dict/*, grammars/fuzz/.gitignore
Adds syntax tokens for HTTP, JSON, SQL, and TOML fuzzing. Adds duplicate coverage/ ignore entries.
Fuzz target and dictionary instructions
FUZZING.md
Documents the fourth SQL fuzz target, target-specific dictionary commands, dictionary paths, and libFuzzer startup reporting.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: tomtau

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the added fuzzing dictionaries and their documentation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@FUZZING.md`:
- Line 34: Update the fuzzing guide’s dictionary command to use the
crate-relative path fuzz/dict/[target].dict when run from the fuzz directory,
and limit the documented targets to pest_grammars’ http, json, sql, and toml
targets.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 9dd1c7de-55af-4f05-9790-ba08724335d4

📥 Commits

Reviewing files that changed from the base of the PR and between c3a6956 and b1d9a6d.

📒 Files selected for processing (6)
  • FUZZING.md
  • grammars/fuzz/.gitignore
  • grammars/fuzz/dict/http.dict
  • grammars/fuzz/dict/json.dict
  • grammars/fuzz/dict/sql.dict
  • grammars/fuzz/dict/toml.dict

Comment thread FUZZING.md

## Dictionaries

Dictionaries of syntax tokens for the `pest_grammars` fuzz targets live in `grammars/fuzz/dict`. Passing one dictionary to libFuzzer lets it splice whole keywords and punctuation into inputs instead of rediscovering them one byte at a time.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== files =="
git ls-files | rg '(^|/)FUZZING\.md$|fuzz|grammars' | sed -n '1,200p'

echo
echo "== FUZZING.md relevant lines =="
if [ -f FUZZING.md ]; then
  nl -ba FUZZING.md | sed -n '1,90p'
fi

echo
echo "== target/dict references =="
rg -n "pest_grammars|fuzz/dict|grammars/fuzz/dict|fuzz run|dict=|toml|http|json|sql" FUZZING.md grammars fuzz 2>/dev/null | sed -n '1,240p'

echo
echo "== cargo fuzz files =="
if [ -d grammars ]; then
  find grammars -maxdepth 3 -type f \( -path '*Cargo.toml*' -o -name 'fuzz'* \) | sort | sed -n '1,200p'
fi
if [ -d fuzz ]; then
  find fuzz -maxdepth 3 -type f | sort | sed -n '1,200p'
fi

Repository: pest-parser/pest

Length of output: 1670


🏁 Script executed:

#!/bin/bash
set -euo pipefail

python3 - <<'PY'
from pathlib import Path
for p in [Path("FUZZING.md"), Path("grammars/FUZZING.md")]:
    if p.exists():
        txt = p.read_text()
        print(f"\n== {p} ==")
        print(f"has grammars/fuzz/dict: {'grammars/fuzz/dict' in txt}")
        print(f"has fuzz/dict: {'fuzz/dict' in txt}")
PY

Repository: pest-parser/pest

Length of output: 221


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== FUZZING.md line numbers and content =="
awk '{printf "%5d\t%s\n", NR, $0}' FUZZING.md | sed -n '1,120p'

echo
echo "== directory indicators in FUZZING.md =="
awk '{printf "%5d\t%s\n", NR, $0}' FUZZING.md | rg -i "dir|directory|crate|grammars|cargo fuzz|dict" -C2 || true

echo
echo "== repository path setup =="
awk '{printf "%5d\t%s\n", NR, $0}' FUZZING.md | sed -n '1,20p'

echo
echo "== fuzz target list =="
find grammars/fuzz/fuzz_targets -maxdepth 1 -type f -name '*.rs' | sort | xargs -r -n1 basename
find grammars/fuzz/dict -maxdepth 1 -type f -name '*.dict' | sort | xargs -r -n1 basename

Repository: pest-parser/pest

Length of output: 6678


Use the crate-relative dictionary path for pest_grammars.

When users run the command from the crate’s fuzz directory as the guide describes, grammars/fuzz/dict/[target].dict points to fuzz/grammars/fuzz/dict/[target].dict. Use fuzz/dict/[target].dict instead, or state that the command must be run from the repository root.

The dictionary command only supports the pest_grammars targets: http, json, sql, and toml.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@FUZZING.md` at line 34, Update the fuzzing guide’s dictionary command to use
the crate-relative path fuzz/dict/[target].dict when run from the fuzz
directory, and limit the documented targets to pest_grammars’ http, json, sql,
and toml targets.

Source: MCP tools

@tomtau
tomtau merged commit fa9e187 into pest-parser:master Aug 11, 2026
10 checks passed
@estr3llas
estr3llas deleted the fuzz-grammar-dicts branch August 11, 2026 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants