Skip to content

Commit 7305578

Browse files
committedJun 14, 2022
docs: adds documentationt to readme
1 parent b615fa2 commit 7305578

File tree

8 files changed

+295
-2713
lines changed

8 files changed

+295
-2713
lines changed
 

‎.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,7 @@ pyvenv.cfg
6060
pip-selfcheck.json
6161

6262
# Sensitive or high-churn files:
63-
*.key
63+
*.key
64+
65+
### llvm
66+
llvm-project

‎CREDITS.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Thanks to:
2+
- [atheris](github/google/atheris) by google
3+
- [pytezos](https://github.com/baking-bad/pytezos) by Baking bad

‎README.md

+267-87
Large diffs are not rendered by default.

‎chinfuzz/__init__.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def chinfuzzStartFuzzer(args, env):
4444

4545
spinner.succeed(text="Fuzzer initialized")
4646

47-
_fuzz.runOneFuzzer()
47+
_fuzz.runOneFuzzer(lib_fuzzer_args=lib_fuzzer_args)
4848

4949

5050
def chinfuzzReplayFuzzer(args, env):
@@ -126,7 +126,15 @@ def main(args, env=os.environ):
126126
parser.print_help()
127127
exit(1)
128128

129-
args = parser.parse_args(args[1:])
129+
# this is an 'internal' method
130+
args, unknown = parser.parse_known_args()
131+
global lib_fuzzer_args
132+
lib_fuzzer_args = []
133+
for arg in unknown:
134+
if arg == "--":
135+
lib_fuzzer_args = unknown[unknown.index(arg)+1:]
136+
break
137+
130138
return args.func(args, env)
131139

132140
if __name__ == "__main__":

‎chinfuzz/core/fuzz.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -85,18 +85,19 @@ def getDataProvider(self, data, **kwargs):
8585
"""
8686
return atheris.FuzzedDataProvider(data)
8787

88-
def runOneFuzzer(self):
88+
def runOneFuzzer(self, lib_fuzzer_args=[]):
8989
sys.path.append(f"fuzz")
9090
name = pathlib.Path(self.args.fuzz).stem
9191
with io.StringIO() as buff:
9292
with contextlib.redirect_stderr(buff):
9393
with atheris.instrument_imports():
9494
fuzz = __import__(name)
9595

96-
self.callChinfuzzFuzzerTestOneInput(fuzz, self.args.fuzz)
96+
self.callChinfuzzFuzzerTestOneInput(fuzz, self.args.fuzz, lib_fuzzer_args)
9797

98-
def callChinfuzzFuzzerTestOneInput(self, fuzz, fuzzer):
99-
args = [fuzzer]
98+
def callChinfuzzFuzzerTestOneInput(self, fuzz, fuzzer, lib_fuzzer_args=[]):
99+
args = [fuzzer] + lib_fuzzer_args
100+
100101
if self.args.corpus:
101102
args.append(self.args.corpus)
102103

‎chinfuzz/resources/fuzz/SampleContractFuzzer.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@
77
def ChinfuzzFuzzerTestOneInput(data):
88
# convert data (bytes) to required data type using FuzzedDataProvider
99
fdp = fuzz.FuzzedDataProvider(data)
10-
# we generate
11-
data = fdp.ConsumeInt(10000000)
10+
11+
# we generate numbers of size `10000`
12+
data = fdp.ConsumeInt(10000)
1213

14+
# we get the contract interface as we do in Chinstrap tests
1315
contract = getContractInterface("SampleContract")
16+
17+
# we initialise the storate and call the entrypoint we would like to fuzz
1418
storage = {"owner": owner, "counter": 0}
1519
contract.increment(data).interpret(storage=storage, source=owner)

‎docs/imgs/fuzz.png

295 KB
Loading

‎poetry.lock

-2,617
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.