MeiliSearch/filter-parser
unvalley c7322f704c Fix cargo clippy errors
Dont apply clippy for tests for now

Fix clippy warnings of filter-parser package

parent 8352febd646ec4bcf56a44161e5c4dce0e55111f
author unvalley <38400669+unvalley@users.noreply.github.com> 1666325847 +0900
committer unvalley <kirohi.code@gmail.com> 1666791316 +0900

Update .github/workflows/rust.yml

Co-authored-by: Clémentine Urquizar - curqui <clementine@meilisearch.com>

Allow clippy lint too_many_argments

Allow clippy lint needless_collect

Allow clippy lint too_many_arguments and type_complexity

Fix for clippy warnings comparison_chains

Fix for clippy warnings vec_init_then_push

Allow clippy lint should_implement_trait

Allow clippy lint drop_non_drop

Fix lifetime clipy warnings in filter-paprser

Execute cargo fmt

Fix clippy remaining warnings

Fix clippy remaining warnings again and allow lint on each place
2022-10-27 01:04:23 +09:00
..
fuzz Update filter-parser/fuzz/.gitignore 2022-07-21 16:12:01 +02:00
src Fix cargo clippy errors 2022-10-27 01:04:23 +09:00
Cargo.toml Update version for the next release (v0.35.0) in Cargo.toml files 2022-10-26 11:43:54 +00:00
README.md Replace MeiliSearch by Meilisearch 2022-01-26 17:49:55 +01:00

Filter parser

This workspace is dedicated to the parsing of the Meilisearch filters.

Most of the code and explanation are in the lib.rs. Especially, the BNF of the filters at the top of this file.

The parser use nom to do most of its work and nom-locate to keep track of what we were doing when we encountered an error.

Cli

A simple main is provided to quick-test if a filter can be parsed or not without bringing milli. It takes one argument and try to parse it.

cargo run -- 'field = value' # success
cargo run -- 'field = "doggo' # error => missing closing delimiter "

Fuzz

The workspace have been fuzzed with cargo-fuzz.

Setup

You'll need rust-nightly to execute the fuzzer.

cargo install cargo-fuzz

Run

When the filter parser is executed by the fuzzer it's triggering a stackoverflow really fast. We can avoid this problem by limiting the max_len of libfuzzer at 500 characters.

cargo fuzz run parse -- -max_len=500

What to do if you find a bug in the parser

  • Write a test at the end of the lib.rs to ensure it never happens again.
  • Add a file in the corpus directory with your filter to help the fuzzer find new bugs. Since this directory is going to be heavily polluted by the execution of the fuzzer it's in the gitignore and you'll need to force push your new test.