Skip to content

Commit

Permalink
fix: decrease a call limit on the toml fuzzer
Browse files Browse the repository at this point in the history
closes #697
  • Loading branch information
Tomas Tauber committed Aug 18, 2022
1 parent abb1972 commit 2059a3c
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 7 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/ci.yml
Expand Up @@ -93,7 +93,12 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: test
args: --all --verbose
args: --all --verbose --release
- name: Cargo test (run ignored)
uses: actions-rs/cargo@v1
with:
command: test
args: -p pest_grammars --lib --verbose --release -- --ignored tests::toml_handles_deep_nesting_unstable

coverage:
name: Test Coverage
Expand Down
2 changes: 1 addition & 1 deletion grammars/fuzz/fuzz_targets/toml.rs
Expand Up @@ -11,7 +11,7 @@ fuzz_target!(|data: &[u8]| {
use pest_grammars::Parser;

if let Ok(s) = std::str::from_utf8(data) {
pest::set_call_limit(Some(100_000usize.try_into().unwrap()));
pest::set_call_limit(Some(5_000usize.try_into().unwrap()));
let _ = toml::TomlParser::parse(toml::Rule::toml, s);
}
});
5 changes: 5 additions & 0 deletions grammars/resources/test/tomlfuzzsample2.toml
@@ -0,0 +1,5 @@
[1]O=[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[{x=1,O=[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[{x=1,O=8,x=6,O=5,z=8,Ox4=[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[{x=0,O=8,x=6,O=5,z=8,Ox3=[[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[[[[1,5,

[1,5
,5
,170141183460469231731687303715916988704O=8
24 changes: 19 additions & 5 deletions grammars/src/lib.rs
Expand Up @@ -41,17 +41,31 @@ mod tests {

use crate::{json, toml};

fn test_toml_deep_nesting(input: &str) {
const ERROR: &str = "call limit reached";
pest::set_call_limit(Some(5_000usize.try_into().unwrap()));
let s = toml::TomlParser::parse(toml::Rule::toml, input);
assert!(s.is_err());
assert_eq!(s.unwrap_err().variant.message(), ERROR);
}

#[test]
fn toml_handles_deep_nesting() {
let sample1 = include_str!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/resources/test/tomlfuzzsample1.toml"
));
const ERROR: &str = "call limit reached";
pest::set_call_limit(Some(100_000usize.try_into().unwrap()));
let s1 = toml::TomlParser::parse(toml::Rule::toml, sample1);
assert!(s1.is_err());
assert_eq!(s1.unwrap_err().variant.message(), ERROR);
test_toml_deep_nesting(sample1);
}

#[test]
#[ignore = "this sometimes crashes in the debug mode"]
fn toml_handles_deep_nesting_unstable() {
let sample2 = include_str!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/resources/test/tomlfuzzsample2.toml"
));
test_toml_deep_nesting(sample2);
}

#[test]
Expand Down

0 comments on commit 2059a3c

Please sign in to comment.