update the filter parser and some code for the fuzzer

This commit is contained in:
Tamo 2021-11-04 14:22:35 +01:00
parent 5d3af5f273
commit 54aec7ac5f
No known key found for this signature in database
GPG key ID: 20CD8020AFA88D69
50 changed files with 406 additions and 51 deletions

3
filter_parser/fuzz/.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
target
corpus
artifacts

View file

@ -0,0 +1,25 @@
[package]
name = "filter_parser-fuzz"
version = "0.0.0"
authors = ["Automatically generated"]
publish = false
edition = "2018"
[package.metadata]
cargo-fuzz = true
[dependencies]
libfuzzer-sys = "0.4"
[dependencies.filter_parser]
path = ".."
# Prevent this from interfering with workspaces
[workspace]
members = ["."]
[[bin]]
name = "parse"
path = "fuzz_targets/parse.rs"
test = false
doc = false

View file

@ -0,0 +1 @@
channel = Ponce

View file

@ -0,0 +1 @@
channel != ponce

View file

@ -0,0 +1 @@
NOT channel = ponce

View file

@ -0,0 +1 @@
subscribers < 1000

View file

@ -0,0 +1 @@
subscribers > 1000

View file

@ -0,0 +1 @@
subscribers <= 1000

View file

@ -0,0 +1 @@
subscribers >= 1000

View file

@ -0,0 +1 @@
NOT subscribers < 1000

View file

@ -0,0 +1 @@
NOT subscribers > 1000

View file

@ -0,0 +1 @@
NOT subscribers <= 1000

View file

@ -0,0 +1 @@
NOT subscribers >= 1000

View file

@ -0,0 +1 @@
subscribers = 12

View file

@ -0,0 +1 @@
subscribers 100 TO 1000

View file

@ -0,0 +1 @@
NOT subscribers 100 TO 1000

View file

@ -0,0 +1 @@
_geoRadius(12, 13, 14)

View file

@ -0,0 +1 @@
NOT _geoRadius(12, 13, 14)

View file

@ -0,0 +1 @@
channel = ponce AND 'dog race' != 'bernese mountain'

View file

@ -0,0 +1 @@
channel = ponce OR 'dog race' != 'bernese mountain'

View file

@ -0,0 +1 @@
channel = ponce AND 'dog race' != 'bernese mountain' OR subscribers > 1000

View file

@ -0,0 +1 @@
channel = ponce AND ( 'dog race' != 'bernese mountain' OR subscribers > 1000 )

View file

@ -0,0 +1 @@
(channel = ponce AND 'dog race' != 'bernese mountain' OR subscribers > 1000) AND _geoRadius(12, 13, 14)

View file

@ -0,0 +1 @@
channel = Ponce = 12

View file

@ -0,0 +1 @@
channel = 'Mister Mv'

View file

@ -0,0 +1 @@
channel =

View file

@ -0,0 +1 @@
channel = 🐻

View file

@ -0,0 +1 @@
OR

View file

@ -0,0 +1 @@
AND

View file

@ -0,0 +1 @@
channel Ponce

View file

@ -0,0 +1 @@
channel = Ponce OR

View file

@ -0,0 +1 @@
_geoRadius

View file

@ -0,0 +1 @@
_geoRadius = 12

View file

@ -0,0 +1 @@
_geoPoint(12, 13, 14)

View file

@ -0,0 +1 @@
position <= _geoPoint(12, 13, 14)

View file

@ -0,0 +1 @@
channel = "Mister Mv"

View file

@ -0,0 +1 @@
position <= _geoRadius(12, 13, 14)

View file

@ -0,0 +1 @@
channel = 'ponce

View file

@ -0,0 +1 @@
channel = "ponce

View file

@ -0,0 +1 @@
channel = mv OR (followers >= 1000

View file

@ -0,0 +1 @@
'dog race' = Borzoi

View file

@ -0,0 +1 @@
"dog race" = Chusky

View file

@ -0,0 +1 @@
"dog race" = "Bernese Mountain"

View file

@ -0,0 +1 @@
'dog race' = 'Bernese Mountain'

View file

@ -0,0 +1 @@
"dog race" = 'Bernese Mountain'

View file

@ -0,0 +1,13 @@
#![no_main]
use filter_parser::FilterCondition;
use libfuzzer_sys::fuzz_target;
fuzz_target!(|data: &[u8]| {
if let Ok(s) = std::str::from_utf8(data) {
// When we are fuzzing the parser we can get stack overflow really easily.
// But since this doesn't happens with a normal build we are just going to limit the fuzzer to 500 characters.
if s.len() < 500 {
let _ = FilterCondition::parse(s);
}
}
});