Stefan Holderbach 55c7246830
Fuzz more realistically with keyword const eval (#15036)
# Description
The parsing logic for several of our keywords is conditional on the
particular commands for those keywords being in scope:


942030199d/crates/nu-parser/src/parse_keywords.rs (L272-L279)

Thus the following involved parsing logic was not fuzzed by the existing
`parse` fuzz target so far.

This adds an additional fuzz target `parse_with_keywords` that loads the
commands from `nu-cmd-lang`. Those are primarily the keyword
implementations, thus the relevant code paths in the parser that depend
on those `DeclId`s and the potential const eval of `if` etc. get
unlocked.

The existing `parse` target is preserved if you have concerns about the
fuzzing breaking containment in some form due to those commands.

# Tests + Formatting
Found https://github.com/nushell/nushell/issues/14972 with this target
2025-02-07 23:50:47 +01:00

37 lines
584 B
TOML

[package]
name = "nu-parser-fuzz"
version = "0.0.0"
publish = false
edition = "2021"
[package.metadata]
cargo-fuzz = true
[dependencies]
libfuzzer-sys = "0.4"
nu-protocol = { path = "../../nu-protocol" }
nu-cmd-lang = { path = "../../nu-cmd-lang" }
[dependencies.nu-parser]
path = ".."
# Prevent this from interfering with workspaces
[workspace]
members = ["."]
[profile.release]
debug = 1
[[bin]]
name = "parse"
path = "fuzz_targets/parse.rs"
test = false
doc = false
[[bin]]
name = "parse_with_keywords"
path = "fuzz_targets/parse_with_keywords.rs"
test = false
doc = false