New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple changes; python 2 support, dictionary, mutator refactor #26
Changes from 1 commit
9aa183f
a7b7264
d685d2d
895ee2f
ef2e1cf
acc996f
3a6fac5
b0cd504
ae27ac9
faa8e5f
beb0ce3
ecebfff
26d1e0e
0f78a24
6daa2b5
File filter...
Jump to…
Updates for running on Python 2.
The tool is now able to run on Python 2 with a suitable LRU Cache. Obviously Python 2 isn't as useful to many people, but when working with libraries that are Python 2-only, it's necessary to make the tools work with it.
- Loading branch information
| @@ -16,6 +16,13 @@ | ||
|
|
||
| SAMPLING_WINDOW = 5 # IN SECONDS | ||
|
|
||
| try: | ||
| lru_cache = functools.lru_cache | ||
| except: | ||
| import functools32 | ||
| lru_cache = functools32.lru_cache | ||
|
|
||
|
|
||
| if coverage.version.version_info <= (5, ): | ||
| # Since we're using an old version of coverage.py, | ||
| # we're monkey patching it a bit to improve the performances. | ||
| @@ -24,7 +31,7 @@ | ||
| # function triggers a lot of syscalls. | ||
| # See the benchmarks here: | ||
| # - https://github.com/fuzzitdev/pythonfuzz/issues/9 | ||
| @functools.lru_cache(None) | ||
| @lru_cache(None) | ||
| def abs_file_cache(path): | ||
| """Return the absolute normalized form of `path`.""" | ||
| try: | ||
| @@ -59,6 +66,7 @@ def write(self, x): | ||
| try: | ||
| target(buf) | ||
| except Exception as e: | ||
| print("Exception: %r\n" % (e,)) | ||
| logging.exception(e) | ||
| child_conn.send(e) | ||
| break | ||
| @@ -114,11 +122,14 @@ def write_sample(self, buf, prefix='crash-'): | ||
| crash_path = self._exact_artifact_path | ||
| else: | ||
| crash_path = prefix + m.hexdigest() | ||
| logging.info('sample written to {}'.format(crash_path)) | ||
| if len(buf) < 200: | ||
| try: | ||
| logging.info('sample = {}'.format(buf.hex())) | ||
| except AttributeError: | ||
| logging.info('sample = {!r}'.format(buf)) | ||
| with open(crash_path, 'wb') as f: | ||
| f.write(buf) | ||
| logging.info('sample was written to {}'.format(crash_path)) | ||
| if len(buf) < 200: | ||
| logging.info('sample = {}'.format(buf.hex())) | ||
|
|
||
| def start(self): | ||
| logging.info("#0 READ units: {}".format(self._corpus.length)) | ||
| @@ -134,7 +145,7 @@ def start(self): | ||
| break | ||
|
|
||
| buf = self._corpus.generate_input() | ||
| parent_conn.send_bytes(buf) | ||
| parent_conn.send_bytes(bytes(buf)) | ||
gerph
Author
Contributor
|
||
| if not parent_conn.poll(self._timeout): | ||
| self._p.kill() | ||
| logging.info("=================================================================") | ||
Isn't it bytes already? I think this might slow down the fuzzer if it's an unnecessary copy.