Comments (7)
Hi!
I tested it on two machines with a more recent version of my distro (Debian 10) and it works like a charm (just needed to do the .py edit again):
psyconauta@insulaanglia ᐓ ~/Grammar-Mutator |stable⚡ ᐓ cat seeds/6
<?php
try {
try {
class Class02 {
test02;
}
} catch (Exception $e){}} catch(Error $e){}
try {
try {
class Class04 {
test03;
}
} catch (Exception $e){}} catch(Error $e){}
?>%
So it's highly probable the problem is in my side. Let me upgrade the VM (currently is running Debian 9) and test it to confirm it.
from grammar-mutator.
Hi @X-C3LL ,
Your grammar looks fine. the generated test cases are good as well, except for your last example. The generator does produce different results every time due to randomness. You may want to set a fixed random seed, as shown in the last argument of the command below, for the grammar generator.
May I know your expected outputs? I tried your grammar on my side, using the latest dev
branch and the following command. The generator works as I expected.
./grammar_generator-phpexcept 100 1000 ./seeds ./trees 1641180035
from grammar-mutator.
Hi!
Setting your default value:
psyconauta@insulaalchimia ᐓ ~/Grammar-Mutator |stable⚡ ᐓ ./grammar_generator-phpexcept 100 1000 ./seeds ./trees 1641180035
Using seed 100
psyconauta@insulaalchimia ᐓ ~/Grammar-Mutator |stable⚡ ᐓ cat seeds/*
Class05Class03Class04Class04Class05Class03Class05Class03Class05Class02Class04Class05Class03Class05Class04Class02Class03Class01Class01Class05Class02Class05Class03Class01Class03Class01Class04Class03Class01Class01Class05Class05Class04Class05Class03Class04Class02Class03Class01Class03Class01Class02Class02Class05Class02Class05Class01Class04Class05Class04Class01Class05Class02Class03Class01Class04Class02Class02Class02Class01Class04Class03Class04Class03Class02Class05Class04Class01Class05Class04Class05Class03Class01Class02Class05Class01Class02Class02Class05Class04Class05Class05Class05Class04Class05Class05Class01Class05Class04Class05Class05Class04Class05Class03Class03Class03Class01Class02Class03Class02
If I change the fixed value, the result it's the same:
psyconauta@insulaalchimia ᐓ ~/Grammar-Mutator |stable⚡ ᐓ sudo rm seeds/* && sudo rm trees/*
psyconauta@insulaalchimia ᐓ ~/Grammar-Mutator |stable⚡ ᐓ ./grammar_generator-phpexcept 100 1000 ./seeds ./trees 1337180035
Using seed 100
psyconauta@insulaalchimia ᐓ ~/Grammar-Mutator |stable⚡ ᐓ cat seeds/*
psyconauta@insulaalchimia ᐓ ~/Grammar-Mutator |stable⚡ ᐓ ./grammar_generator-phpexcept 100 1000 ./seeds ./trees 1337181337
Using seed 100
psyconauta@insulaalchimia ᐓ ~/Grammar-Mutator |stable⚡ ᐓ cat seeds/*
Class05Class03Class04Class04Class05Class03Class05Class03Class05Class02Class04Class05Class03Class05Class04Class02Class03Class01Class01Class05Class02Class05Class03Class01Class03Class01Class04Class03Class01Class01Class05Class05Class04Class05Class03Class04Class02Class03Class01Class03Class01Class02Class02Class05Class02Class05Class01Class04Class05Class04Class01Class05Class02Class03Class01Class04Class02Class02Class02Class01Class04Class03Class04Class03Class02Class05Class04Class01Class05Class04Class05Class03Class01Class02Class05Class01Class02Class02Class05Class04Class05Class05Class05Class04Class05Class05Class01Class05Class04Class05Class05Class04Class05Class03Class03Class03Class01Class02Class03Class02%
Looks like it is taking the number of seeds (first arg) as parameter instead of the last arg (Just saw your last commit). But even changing the fixed value, all the seeds generated contains only the rule <CLASSNAME>
. If I recompile and try the same seed value, it picks another rule or a small chain of rules, but rarely applies all of them.
What I was expecting is generating a batch of variants of the next example (or the same with recursion at <FUZZ>
level) where all the rules were applied:
<?php
try {
try {
class Class04 {
test03;
}
} catch (Exception $e){}} catch(Error $e){}
?>
The PHP logic does not matter, I was using a bigger file with all the rules, just created this small grammar to illustrate the issue
OTOH I had to edit `grammars/f1_c_gen.py`:
import sys
import itertools
import random
import os
import string
import json
from f1_common import LimitFuzzer
class TreeNode:
#node_type: int = 0
#rule_id: int = 0
#val: str = ''
#parent: 'TreeNode' = None
#subnodes: list = None
I had to comment it to avoid this error:
File "grammars/f1_c_gen.py", line 39
node_type: int = 0
^
SyntaxError: invalid syntax
File "grammars/f1_c_gen.py", line 39
node_type: int = 0
^
SyntaxError: invalid syntax
from grammar-mutator.
Looks like it is taking the number of seeds (first arg) as parameter instead of the last arg(Just saw your last commit). But even changing the fixed value, all the seeds generated contains only the rule<CLASSNAME>
. If I recompile and try the same seed value, it picks another rule or a small chain of rules, but rarely applies all of them.What I was expecting is generating a batch of variants of the next example (or the same with recursion at
<FUZZ>
level) where all the rules were applied
That is weird. I did generate test cases with recursive <FUZZ>
rule, like:
<?php
try {
try {
class Class04 {
test01;
}
} catch (Exception $e){}} catch(Error $e){}
try {
try {
} catch (Exception $e){}} catch(Error $e){}
try {
try {
class Class05 {
test02;
}
} catch (Exception $e){}} catch(Error $e){}
try {
try {
} catch (Exception $e){}} catch(Error $e){}
?>
File "grammars/f1_c_gen.py", line 39 node_type: int = 0 ^ SyntaxError: invalid syntax File "grammars/f1_c_gen.py", line 39 node_type: int = 0 ^ SyntaxError: invalid syntax
This error did not show up as well. May I know your python3
version?
from grammar-mutator.
Hi
My version:
Python 3.7.3
from grammar-mutator.
Thanks. The python
version looks fine.
One possible reason for your issue (no recursive <FUZZ>
rule) might be that <CLASSNAME>
is wrongly identified as the entry rule for the grammar. Can you share with me the generated f1_c_fuzz.h
in include
directory?
from grammar-mutator.
Yep, the problem was on my side. Upgrading to Debian 10 solved the issue: every time the whole chain of rules is used.
psyconauta@insulaalchimia ᐓ ~/Grammar-Mutator |stable⚡ ᐓ lsb_release -d
Description: Debian GNU/Linux 10 (buster)
psyconauta@insulaalchimia ᐓ ~/Grammar-Mutator |stable⚡ ᐓ ./grammar_generator-phpexcept 100 1000 ./seeds ./trees
Using seed 1641239392
psyconauta@insulaalchimia ᐓ ~/Grammar-Mutator |stable⚡ ᐓ cat seeds/1
<?php
try {
try {
class Class01 {
test03;
}
} catch (Exception $e){}} catch(Error $e){}
try {
try {
class Class05 {
test02;
}
} catch (Exception $e){}} catch(Error $e){}
try {
try {
} catch (Exception $e){}} catch(Error $e){}
try {
try {
} catch (Exception $e){}} catch(Error $e){}
?>%
from grammar-mutator.
Related Issues (20)
- Idea list HOT 9
- Enhancement: name lib and grammar generator with name of the grammar type HOT 4
- Grammar Mutator crashes due to null pointer dereference on write_tree_to_file HOT 14
- Wasteful rebuilding of non-terminal trees HOT 4
- Long recursive calls cause afl to segfault HOT 8
- Memory leaks in `splicing_mutation`
- Test compilation error HOT 1
- incorrect rule index deduction from ANTLR HOT 3
- A question about convert the ASCII HOT 9
- A question about data length HOT 2
- Issue with recursive javascript grammar HOT 6
- How to add extras dynamically during fuzzing HOT 2
- Grammar mutator issue : _pick_non_term_node HOT 5
- `tree_from_buf` hangs when parsing a small test case HOT 4
- Segmentation fault when dealing with hex-ANSII conversion HOT 12
- Is it possible to automatically eliminate indirect left-recursion HOT 1
- Does this mutator uses genetic algorithm? HOT 1
- optimized syntax '+' cause 'random_recursive_mutation' error HOT 5
- json to g4 only with "parser" cause some syntax error HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grammar-mutator.