Hello community, here is the log from the commit of package python-python-afl for openSUSE:Leap:15.2 checked in at 2020-02-19 18:49:16 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Leap:15.2/python-python-afl (Old) and /work/SRC/openSUSE:Leap:15.2/.python-python-afl.new.26092 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-python-afl" Wed Feb 19 18:49:16 2020 rev:11 rq:777034 version:0.7.2 Changes: -------- --- /work/SRC/openSUSE:Leap:15.2/python-python-afl/python-python-afl.changes 2020-01-15 15:52:20.819560199 +0100 +++ /work/SRC/openSUSE:Leap:15.2/.python-python-afl.new.26092/python-python-afl.changes 2020-02-19 18:49:17.155067910 +0100 @@ -1,0 +2,42 @@ +Sat Mar 16 12:55:38 UTC 2019 - Sebastian Wagner <[email protected]> + +- update to version 0.7.2: + * Document that multi-threaded code is not supported. + * Update URLs in the trophy-case. +- update Use-setuptools-and-use-test-command-for-setup.patch + +------------------------------------------------------------------- +Sat Jul 7 08:50:22 UTC 2018 - [email protected] + +- update Use-setuptools-and-use-test-command-for-setup.patch +- update to version 0.7.1: + * Reset the SIGCHLD signal handler in the forkserver. + Thanks to Kuang-che Wu for the bug report. + * Document that sys.stdin rewinding is necessary in persistent mode. + * Improve the test suite. + + Improve error messages for missing command-line tools. + * Explicitly set Cython's Python language level to 2. + This might fix build failures with future versions of Cython. + +------------------------------------------------------------------- +Sun May 6 08:36:28 UTC 2018 - [email protected] + +- update to version 0.7: + * Fix stability issues in persistent mode. + * Capitalize “American Fuzzy Lop” in documentation. + * Speed up integer division and modulo operators. + * Improve the build system: + + Declare build-dependencies (as per PEP-518). + + Add the bdist_wheel command. + * Improve the test suite. + + Print helpful error message when the required command-line tools are + missing. + + Fix stability of the persistent target. + + Rewind stdin in the persistent target. + Thanks to Alex Groce for the bug report. + * Improve documentation: + + Add another “Further reading” link to README. + + Update PyPI URLs. + * Add the PYTHON_AFL_TSTL environment variable. + +------------------------------------------------------------------- Old: ---- python-afl-0.6.1.tar.gz New: ---- python-afl-0.7.2.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-python-afl.spec ++++++ --- /var/tmp/diff_new_pack.FTs8vG/_old 2020-02-19 18:49:17.531068311 +0100 +++ /var/tmp/diff_new_pack.FTs8vG/_new 2020-02-19 18:49:17.531068311 +0100 @@ -1,7 +1,7 @@ # # spec file for package python-python-afl # -# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -12,29 +12,30 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# Please submit bugfixes or comments via https://bugs.opensuse.org/ +# %{?!python_module:%define python_module() python-%{**} python3-%{**}} %bcond_without test Name: python-python-afl -Version: 0.6.1 +Version: 0.7.2 Release: 0 -License: MIT Summary: American fuzzy lop fork server and instrumentation for pure-Python code -Url: http://jwilk.net/software/python-afl +License: MIT Group: Development/Languages/Python +Url: http://jwilk.net/software/python-afl Source: https://files.pythonhosted.org/packages/source/p/python-afl/python-afl-%{version}.tar.gz # PATCH-FIX-OPENSUSE -Patch0: https://github.com/jwilk/python-afl/compare/master...sebix:fix-setup-tests.patch#/Use-setuptools-and-use-test-command-for-setup.patch -BuildRequires: python-rpm-macros -BuildRequires: %{python_module devel} +Patch0: https://github.com/jwilk/python-afl/compare/%{version}...sebix:%{version}-fix-setup-tests.patch#/Use-setuptools-and-use-test-command-for-setup.patch BuildRequires: %{python_module Cython >= 0.19} +BuildRequires: %{python_module devel} BuildRequires: %{python_module setuptools} +BuildRequires: python-rpm-macros %if %{with test} -BuildRequires: procps -BuildRequires: afl >= 2 BuildRequires: %{python_module nose} +BuildRequires: afl >= 2 +BuildRequires: procps %endif BuildRequires: fdupes Requires: afl >= 2 ++++++ Use-setuptools-and-use-test-command-for-setup.patch ++++++ --- /var/tmp/diff_new_pack.FTs8vG/_old 2020-02-19 18:49:17.547068328 +0100 +++ /var/tmp/diff_new_pack.FTs8vG/_new 2020-02-19 18:49:17.547068328 +0100 @@ -1,15 +1,14 @@ -From 8ed58064a967c88b1b568b24d1690fbfd60340a2 Mon Sep 17 00:00:00 2001 +From 4e34831c88b6034bd4218fa3e9368662072b8aa4 Mon Sep 17 00:00:00 2001 From: Sebastian Wagner <[email protected]> Date: Fri, 14 Oct 2016 09:54:20 +0200 Subject: [PATCH] Use setuptools and use test command for setup -Signed-off-by: Sebastian Wagner <[email protected]> --- - setup.py | 61 ++++++++++++++----------------------------------------------- - 1 file changed, 14 insertions(+), 47 deletions(-) + setup.py | 69 ++++++++++++-------------------------------------------- + 1 file changed, 14 insertions(+), 55 deletions(-) diff --git a/setup.py b/setup.py -index 5c617e0..c1a08d2 100644 +index 67cb5f8..d43b3d3 100644 --- a/setup.py +++ b/setup.py @@ -32,9 +32,9 @@ @@ -24,8 +23,8 @@ +from Cython.Build import cythonize try: - import distutils644 -@@ -62,6 +62,13 @@ def get_version(): + from wheel.bdist_wheel import bdist_wheel +@@ -67,6 +67,13 @@ def get_version(): Topic :: Software Development :: Testing '''.strip().splitlines() @@ -39,7 +38,7 @@ meta = dict( name='python-afl', version=get_version(), -@@ -72,53 +79,13 @@ def get_version(): +@@ -77,61 +84,13 @@ def get_version(): url='http://jwilk.net/software/python-afl', author='Jakub Wilk', author_email='[email protected]', @@ -48,22 +47,21 @@ + ext_modules = cythonize(extensions), ) --if 'setuptools' in sys.modules and sys.argv[1] == 'egg_info': -- # We wouldn't normally want setuptools; but pip forces it upon us anyway, -- # so let's abuse it to instruct pip to install Cython if it's missing. -- distutils.core.setup( -- install_requires=['Cython>=0.19'], -- # Conceptually, “setup_requires” would make more sense than -- # “install_requires”, but the former is not supported by pip: -- # https://github.com/pypa/pip/issues/1820 -- **meta -- ) -- sys.exit(0) -- +-min_cython_version = '0.19' -try: - import Cython -except ImportError: -- raise RuntimeError('Cython >= 0.19 is required') +- # This shouldn't happen with pip >= 10, thanks to PEP-518 support. +- # For older versions, we use this hack to trick it into installing Cython: +- if 'setuptools' in sys.modules and sys.argv[1] == 'egg_info': +- distutils.core.setup( +- install_requires=['Cython>={v}'.format(v=min_cython_version)], +- # Conceptually, “setup_requires” would make more sense than +- # “install_requires”, but the former is not supported by pip. +- **meta +- ) +- sys.exit(0) +- raise RuntimeError('Cython >= {v} is required'.format(v=min_cython_version)) - -try: - cython_version = Cython.__version__ @@ -72,8 +70,8 @@ - # Oh well. We don't support such old versions anyway. - cython_version = '0' -cython_version = distutils.version.LooseVersion(cython_version) --if cython_version < '0.19': -- raise RuntimeError('Cython >= 0.19 is required') +-if cython_version < min_cython_version: +- raise RuntimeError('Cython >= {v} is required'.format(v=min_cython_version)) - -import Cython.Build # pylint: disable=wrong-import-position - @@ -89,11 +87,20 @@ - distutils_sdist.make_release_tree(self, base_dir, files) - self.maybe_move_file(base_dir, 'LICENSE', 'doc/LICENSE') - +-def d(**kwargs): +- return dict( +- (k, v) for k, v in kwargs.items() +- if v is not None +- ) +- -distutils.core.setup( - ext_modules=Cython.Build.cythonize('afl.pyx'), +setup( scripts=glob.glob('py-afl-*'), -- cmdclass=dict(sdist=cmd_sdist), +- cmdclass=d( +- bdist_wheel=bdist_wheel, +- sdist=cmd_sdist, +- ), **meta ) ++++++ python-afl-0.6.1.tar.gz -> python-afl-0.7.2.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-afl-0.6.1/MANIFEST.in new/python-afl-0.7.2/MANIFEST.in --- old/python-afl-0.6.1/MANIFEST.in 2017-04-05 13:00:32.000000000 +0200 +++ new/python-afl-0.7.2/MANIFEST.in 2018-11-27 23:26:46.000000000 +0100 @@ -1,5 +1,5 @@ exclude *.c -exclude README +exclude README.rst include *.pyx include LICENSE include MANIFEST.in diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-afl-0.6.1/PKG-INFO new/python-afl-0.7.2/PKG-INFO --- old/python-afl-0.6.1/PKG-INFO 2017-07-28 16:48:21.000000000 +0200 +++ new/python-afl-0.7.2/PKG-INFO 2019-02-15 15:38:22.000000000 +0100 @@ -1,15 +1,15 @@ Metadata-Version: 1.1 Name: python-afl -Version: 0.6.1 -Summary: American fuzzy lop fork server and instrumentation for pure-Python code +Version: 0.7.2 +Summary: American Fuzzy Lop fork server and instrumentation for pure-Python code Home-page: http://jwilk.net/software/python-afl Author: Jakub Wilk Author-email: [email protected] License: MIT Description: *python-afl* is an experimental module that enables - `American fuzzy lop`_ fork server and instrumentation for pure-Python code. + `American Fuzzy Lop`_ fork server and instrumentation for pure-Python code. - .. _American fuzzy lop: http://lcamtuf.coredump.cx/afl/ + .. _American Fuzzy Lop: http://lcamtuf.coredump.cx/afl/ Platform: UNKNOWN Classifier: Development Status :: 3 - Alpha Classifier: Intended Audience :: Developers diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-afl-0.6.1/afl.pyx new/python-afl-0.7.2/afl.pyx --- old/python-afl-0.6.1/afl.pyx 2017-04-08 21:26:41.000000000 +0200 +++ new/python-afl-0.7.2/afl.pyx 2018-11-27 23:26:46.000000000 +0100 @@ -1,4 +1,4 @@ -# Copyright © 2014-2016 Jakub Wilk <[email protected]> +# Copyright © 2014-2018 Jakub Wilk <[email protected]> # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the “Software”), to deal @@ -20,12 +20,14 @@ #cython: autotestdict=False #cython: c_string_encoding=default +#cython: cdivision=True +#cython: language_level=2 ''' -American fuzzy lop fork server and instrumentation for pure-Python code +American Fuzzy Lop fork server and instrumentation for pure-Python code ''' -__version__ = '0.6.1' +__version__ = '0.7.2' cdef object os, signal, struct, sys, warnings import os @@ -42,11 +44,27 @@ from cpython.exc cimport PyErr_SetFromErrno from libc cimport errno +from libc.signal cimport SIG_DFL from libc.stddef cimport size_t from libc.stdint cimport uint32_t from libc.stdlib cimport getenv from libc.string cimport strlen +cdef extern from 'signal.h': + # We could use definitions from posix/signal.pxd, + # but these were broken before Cython 0.24. + ctypedef struct siginfo_t: + pass + ctypedef struct sigset_t: + pass + cdef struct sigaction_t 'sigaction': + void sa_handler(int) + void sa_sigaction(int, siginfo_t *, void *) + sigset_t sa_mask + int sa_flags + int sigaction(int, const sigaction_t *, sigaction_t *) + int sigemptyset(sigset_t *) + cdef extern from 'sys/shm.h': unsigned char *shmat(int shmid, void *shmaddr, int shmflg) @@ -58,12 +76,12 @@ cdef size_t len = strlen(key) cdef uint32_t h = 0x811C9DC5 while len > 0: - h ^= <unsigned char> key[0]; + h ^= <unsigned char> key[0] h *= 0x01000193 len -= 1 key += 1 while offset > 0: - h ^= <unsigned char> offset; + h ^= <unsigned char> offset h *= 0x01000193 offset >>= 8 return h @@ -75,10 +93,13 @@ cdef object trace def trace(frame, event, arg): - global prev_location + global prev_location, tstl_mode cdef unsigned int location, offset + cdef object filename = frame.f_code.co_filename + if tstl_mode and (filename[-7:] in ['sut.py', '/sut.py']): + return None location = ( - lhash(frame.f_code.co_filename, frame.f_lineno) + lhash(filename, frame.f_lineno) % MAP_SIZE ) offset = location ^ prev_location @@ -101,9 +122,11 @@ os.kill(os.getpid(), except_signal_id) cdef bint init_done = False +cdef bint tstl_mode = False cdef int _init(bint persistent_mode) except -1: - global afl_area, init_done + global afl_area, init_done, tstl_mode + tstl_mode = os.getenv('PYTHON_AFL_TSTL') is not None use_forkserver = True try: os.write(FORKSRV_FD + 1, b'\0\0\0\0') @@ -117,6 +140,16 @@ init_done = True child_stopped = False child_pid = 0 + cdef sigaction_t old_sigchld + cdef sigaction_t dfl_sigchld + dfl_sigchld.sa_handler = SIG_DFL + dfl_sigchld.sa_sigaction = NULL + dfl_sigchld.sa_flags = 0 + sigemptyset(&dfl_sigchld.sa_mask) + if use_forkserver: + rc = sigaction(signal.SIGCHLD, &dfl_sigchld, &old_sigchld) + if rc: + PyErr_SetFromErrno(OSError) while use_forkserver: [child_killed] = struct.unpack('I', os.read(FORKSRV_FD, 4)) if child_stopped and child_killed: @@ -136,6 +169,9 @@ child_stopped = os.WIFSTOPPED(status) os.write(FORKSRV_FD + 1, struct.pack('I', status)) if use_forkserver: + rc = sigaction(signal.SIGCHLD, &old_sigchld, NULL) + if rc: + PyErr_SetFromErrno(OSError) os.close(FORKSRV_FD) os.close(FORKSRV_FD + 1) if except_signal_id != 0: @@ -155,8 +191,8 @@ Start the fork server and enable instrumentation. - This function should be called as late as possible, but before the input is - read, and before any threads are started. + This function should be called as late as possible, + but before the input is read. ''' _init(persistent_mode=False) @@ -180,7 +216,8 @@ afl-fuzz >= 1.82b is required for this feature. ''' - global persistent_allowed, persistent_counter + global persistent_allowed, persistent_counter, prev_location + prev_location = 0 if persistent_counter == 0: persistent_allowed = os.getenv('PYTHON_AFL_PERSISTENT') is not None _init(persistent_mode=persistent_allowed) @@ -195,6 +232,7 @@ persistent_counter += 1 return True else: + sys.settrace(None) return False __all__ = [ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-afl-0.6.1/doc/LICENSE new/python-afl-0.7.2/doc/LICENSE --- old/python-afl-0.6.1/doc/LICENSE 2017-03-26 22:00:14.000000000 +0200 +++ new/python-afl-0.7.2/doc/LICENSE 2019-01-29 17:05:37.000000000 +0100 @@ -1,4 +1,4 @@ -Copyright © 2013-2017 Jakub Wilk <[email protected]> +Copyright © 2013-2019 Jakub Wilk <[email protected]> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-afl-0.6.1/doc/README new/python-afl-0.7.2/doc/README --- old/python-afl-0.6.1/doc/README 2017-04-04 19:05:19.000000000 +0200 +++ new/python-afl-0.7.2/doc/README 2019-02-13 17:48:59.000000000 +0100 @@ -1,7 +1,7 @@ This is experimental module that enables -`American fuzzy lop`_ fork server and instrumentation for pure-Python code. +`American Fuzzy Lop`_ fork server and instrumentation for pure-Python code. -.. _American fuzzy lop: http://lcamtuf.coredump.cx/afl/ +.. _American Fuzzy Lop: http://lcamtuf.coredump.cx/afl/ HOWTO ----- @@ -42,6 +42,13 @@ You shouldn't call ``afl.init()`` in this case. + If you read input from ``sys.stdin``, + you must rewind it in every loop iteration: + + .. code:: python + + sys.stdin.seek(0) + afl-fuzz ≥ 1.82b is required for this feature. * Use *py-afl-fuzz* instead of *afl-fuzz*:: @@ -76,9 +83,21 @@ *py-afl-fuzz* sets this variable automatically, so there should normally no need to set it manually. +``PYTHON_AFL_TSTL`` + `TSTL`_ test harness code is ignored if this variable is set; + relevant only to users of TSTL interface to python-afl. + +.. _TSTL: https://github.com/agroce/tstl + +Bugs +---- + +Multi-threaded code is not supported. + Further reading --------------- +* `Taking a look at python-afl <https://barro.github.io/2018/01/taking-a-look-at-python-afl/>`_ by Jussi Judin * `Introduction to Fuzzing in Python with AFL <https://alexgaynor.net/2015/apr/13/introduction-to-fuzzing-in-python-with-afl/>`_ by Alex Gaynor * `AFL's README <http://lcamtuf.coredump.cx/afl/README.txt>`_ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-afl-0.6.1/doc/changelog new/python-afl-0.7.2/doc/changelog --- old/python-afl-0.6.1/doc/changelog 2017-07-28 16:43:08.000000000 +0200 +++ new/python-afl-0.7.2/doc/changelog 2019-02-15 15:31:24.000000000 +0100 @@ -1,7 +1,52 @@ +python-afl (0.7.2) unstable; urgency=low + + * Document that multi-threaded code is not supported. + * Update URLs in the trophy-case. + + -- Jakub Wilk <[email protected]> Fri, 15 Feb 2019 15:31:23 +0100 + +python-afl (0.7.1) unstable; urgency=low + + * Reset the SIGCHLD signal handler in the forkserver. + Thanks to Kuang-che Wu for the bug report. + * Document that sys.stdin rewinding is necessary in persistent mode. + * Improve the test suite. + + Improve error messages for missing command-line tools. + * Explicitly set Cython's Python language level to 2. + This might fix build failures with future versions of Cython. + + -- Jakub Wilk <[email protected]> Thu, 21 Jun 2018 23:17:56 +0200 + +python-afl (0.7) unstable; urgency=low + + [ Jakub Wilk ] + * Fix stability issues in persistent mode. + * Capitalize “American Fuzzy Lop” in documentation. + * Speed up integer division and modulo operators. + * Improve the build system: + + Declare build-dependencies (as per PEP-518). + + Add the bdist_wheel command. + * Improve the test suite. + + Print helpful error message when the required command-line tools are + missing. + + Fix stability of the persistent target. + + Rewind stdin in the persistent target. + Thanks to Alex Groce for the bug report. + * Improve documentation: + + Add another “Further reading” link to README. + + Update PyPI URLs. + + [ Alex Groce ] + * Add the PYTHON_AFL_TSTL environment variable. + + -- Jakub Wilk <[email protected]> Mon, 30 Apr 2018 10:42:18 +0200 + python-afl (0.6.1) unstable; urgency=low * Improve the test suite. + Make the py-afl-cmin test pass when run in a subdirectory of /tmp. + * Improve the build system: + + Use distutils644 to normalize source tarball permissions etc. -- Jakub Wilk <[email protected]> Fri, 28 Jul 2017 16:43:06 +0200 @@ -14,7 +59,7 @@ Bare afl-showmap and afl-tmin were broken since 0.5. * Put license into a separate file. * Improve the test suite. - * Update URLs in trophy-case. + * Update URLs in the trophy-case. -- Jakub Wilk <[email protected]> Wed, 05 Apr 2017 13:28:37 +0200 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-afl-0.6.1/doc/trophy-case new/python-afl-0.7.2/doc/trophy-case --- old/python-afl-0.6.1/doc/trophy-case 2017-03-29 12:47:12.000000000 +0200 +++ new/python-afl-0.7.2/doc/trophy-case 2019-02-15 15:28:08.000000000 +0100 @@ -43,26 +43,26 @@ .. __: https://github.com/Diaoul/enzyme -PyASN.1__ ---------- +PyASN1__ +-------- | https://github.com/pyca/cryptography/issues/1838 -.. __: http://pyasn1.sourceforge.net/ +.. __: http://snmplabs.com/pyasn1/ gunicorn__ ---------- | https://github.com/benoitc/gunicorn/issues/1023 -.. __: http://gunicorn.org/ +.. __: https://gunicorn.org/ dateutil__ ---------- | https://github.com/dateutil/dateutil/issues/82 -.. __: https://pypi.python.org/pypi/python-dateutil +.. __: https://pypi.org/project/python-dateutil/ regex__ ------- @@ -72,6 +72,6 @@ | https://bitbucket.org/mrabarnett/mrab-regex/issues/199/segfault-in-recompile | https://bitbucket.org/mrabarnett/mrab-regex/issues/200/attributeerror-in-regexcompile-with-latest -.. __: https://pypi.python.org/pypi/regex +.. __: https://pypi.org/project/regex/ .. vim:ft=rst ts=3 sts=3 sw=3 et diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-afl-0.6.1/private/build-and-test new/python-afl-0.7.2/private/build-and-test --- old/python-afl-0.6.1/private/build-and-test 2017-04-05 13:25:30.000000000 +0200 +++ new/python-afl-0.7.2/private/build-and-test 2018-11-27 23:26:46.000000000 +0100 @@ -1,6 +1,6 @@ #!/bin/sh -# Copyright © 2015-2017 Jakub Wilk <[email protected]> +# Copyright © 2015-2018 Jakub Wilk <[email protected]> # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the “Software”), to deal @@ -20,13 +20,14 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. +set -e -u + usage() { printf 'Usage: %s [--no-build] [pythonX.Y...]\n' "$0" } -args=$(getopt -n "$0" -o 'hj:' --long 'help,jobs:,no-build' -- "$@") -if [ $? -ne 0 ] +if ! args=$(getopt -n "$0" -o 'hj:' --long 'help,jobs:,no-build' -- "$@") then usage >&2 exit 1 @@ -45,15 +46,13 @@ esac done -set -e [ $# = 0 ] && set -- python [ -z $opt_build ] || printf '%s\n' "$@" \ | xargs -P"$opt_jobs" -t -I'{python}' env '{python}' setup.py build --build-lib 'build/{python}' cd tests -nosetests=$(command -v nosetests) || { echo nosetests not found >&2; exit 1; } export PATH="$PWD/..:$PATH" printf '%s\n' "$@" \ -| xargs -t -I'{python}' env PYTHONPATH="$PWD/../build/{python}" '{python}' "$nosetests" --verbose +| xargs -t -I'{python}' env PYTHONPATH="$PWD/../build/{python}" '{python}' -c 'import nose; nose.main()' --verbose # vim:ts=4 sts=4 sw=4 et diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-afl-0.6.1/private/check-rst new/python-afl-0.7.2/private/check-rst --- old/python-afl-0.6.1/private/check-rst 2017-04-03 23:33:06.000000000 +0200 +++ new/python-afl-0.7.2/private/check-rst 2018-11-27 23:26:46.000000000 +0100 @@ -1,6 +1,6 @@ #!/bin/sh -# Copyright © 2016-2017 Jakub Wilk <[email protected]> +# Copyright © 2016-2018 Jakub Wilk <[email protected]> # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the “Software”), to deal @@ -20,14 +20,25 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -here=$(dirname "$0") +set -e -u +here=${0%/*} +here=${here#./} +root="$here/../" +root=${root#private/../} rst2xml=$(command -v rst2xml) \ || rst2xml=$(command -v rst2xml.py) \ || { printf 'rst2xml not found\n' >&2; exit 1; } -options='--input-encoding=UTF-8 --output-encoding=UTF-8 --strict' +rst2xml=${rst2xml##*/} +options='--input-encoding=UTF-8 --strict' if [ $# -eq 0 ] then - grep -rwl 'ft[=]rst' "$here/.." + print_desc='python setup.py --long-description' + echo "(cd ${root:-.} && $print_desc) | $rst2xml $options - /dev/null" >&2 + (cd "${root:-.}" && $print_desc) | "$rst2xml" $options - /dev/null || exit 1 +fi +if [ $# -eq 0 ] +then + grep -rwl 'ft=rst' "${root}doc" else printf '%s\n' "$@" fi | diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-afl-0.6.1/private/run-pydiatra new/python-afl-0.7.2/private/run-pydiatra --- old/python-afl-0.6.1/private/run-pydiatra 2017-04-14 00:04:16.000000000 +0200 +++ new/python-afl-0.7.2/private/run-pydiatra 1970-01-01 01:00:00.000000000 +0100 @@ -1,30 +0,0 @@ -#!/bin/sh - -# Copyright © 2016-2017 Jakub Wilk <[email protected]> -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the “Software”), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -PYTHON=${PYTHON:-python} -if [ $# -eq 0 ] -then - set -- $(find . -name '*.py') -fi -exec "$PYTHON" -m pydiatra "$@" - -# vim:ts=4 sts=4 sw=4 et diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-afl-0.6.1/private/run-pyflakes new/python-afl-0.7.2/private/run-pyflakes --- old/python-afl-0.6.1/private/run-pyflakes 2017-04-04 21:34:21.000000000 +0200 +++ new/python-afl-0.7.2/private/run-pyflakes 1970-01-01 01:00:00.000000000 +0100 @@ -1,33 +0,0 @@ -#!/bin/sh - -# Copyright © 2016-2017 Jakub Wilk <[email protected]> -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the “Software”), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -PYTHON=${PYTHON:-python} -pyflakes=$(command -v pyflakes) || { echo pyflakes not found >&2; exit 1; } -if [ $# -eq 0 ] -then - set -- $(find . -name '*.py') -fi -# It would be tempting to use "python -m pyflakes" here, -# but that doesn't work in Python 2.6. -exec "$PYTHON" "$pyflakes" "$@" - -# vim:ts=4 sts=4 sw=4 et diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-afl-0.6.1/private/run-pylint new/python-afl-0.7.2/private/run-pylint --- old/python-afl-0.6.1/private/run-pylint 2017-04-04 23:03:14.000000000 +0200 +++ new/python-afl-0.7.2/private/run-pylint 2018-12-13 22:24:14.000000000 +0100 @@ -1,6 +1,6 @@ #!/bin/sh -# Copyright © 2015-2017 Jakub Wilk <[email protected]> +# Copyright © 2015-2018 Jakub Wilk <[email protected]> # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the “Software”), to deal @@ -28,17 +28,15 @@ then set -- setup.py tests/*.py fi -if [ -n "${TRAVIS_PYTHON_VERSION:-}" ] +if [ -n "${VIRTUAL_ENV:-}" ] then # https://github.com/PyCQA/pylint/issues/73 set -- --ignored-modules=distutils "$@" fi -set -- --load-plugins=pylint.extensions.check_elif "$@" log=$(mktemp -t pylint.XXXXXX) "$PYTHON" -m pylint "$@" > "$log" || [ $? != 1 ] -! grep '^\w:' "$log" \ +! grep -P '^\S+:' "$log" \ | grep -v -P ": redefined-builtin \\[.*\\] Redefining built-in '(file|dir|input)'$" \ -| grep -v -P ": redundant-unittest-assert \\[.*\\] Redundant use of assertTrue with constant value False$" \ | grep -v -P ": superfluous-parens \\[.*\\] Unnecessary parens after u?'print' keyword$" \ | LC_ALL=C sort -k2 \ | grep '.' || exit 1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-afl-0.6.1/private/update-version new/python-afl-0.7.2/private/update-version --- old/python-afl-0.6.1/private/update-version 2017-06-17 17:53:18.000000000 +0200 +++ new/python-afl-0.7.2/private/update-version 2018-11-27 23:26:46.000000000 +0100 @@ -1,6 +1,6 @@ #!/bin/sh -version=${1:?"no version number provided"} +export version=${1:?"no version number provided"} set -e set -x dch -m -v "$version" -u low -c doc/changelog -sed -i -E -e "s/^(__version__) = '[0-9.]+'$/\1 = '$version'/" afl.pyx +perl -pi -e 's/^__version__ = '"'"'\K[\w.]+/$ENV{version}/' afl.pyx diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-afl-0.6.1/setup.cfg new/python-afl-0.7.2/setup.cfg --- old/python-afl-0.6.1/setup.cfg 1970-01-01 01:00:00.000000000 +0100 +++ new/python-afl-0.7.2/setup.cfg 2018-11-27 23:26:46.000000000 +0100 @@ -0,0 +1,5 @@ +[pycodestyle] +filename = *.py,*.pyx +ignore = E12,E21,E22,E265,E3,E4,E722,W504 +max-line-length = 120 +show-source = true diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-afl-0.6.1/setup.py new/python-afl-0.7.2/setup.py --- old/python-afl-0.6.1/setup.py 2017-04-19 19:05:29.000000000 +0200 +++ new/python-afl-0.7.2/setup.py 2018-11-27 23:26:46.000000000 +0100 @@ -1,6 +1,6 @@ # encoding=UTF-8 -# Copyright © 2014-2017 Jakub Wilk <[email protected]> +# Copyright © 2014-2018 Jakub Wilk <[email protected]> # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the “Software”), to deal @@ -22,9 +22,9 @@ ''' *python-afl* is an experimental module that enables -`American fuzzy lop`_ fork server and instrumentation for pure-Python code. +`American Fuzzy Lop`_ fork server and instrumentation for pure-Python code. -.. _American fuzzy lop: http://lcamtuf.coredump.cx/afl/ +.. _American Fuzzy Lop: http://lcamtuf.coredump.cx/afl/ ''' import glob @@ -37,6 +37,11 @@ from distutils.command.sdist import sdist as distutils_sdist try: + from wheel.bdist_wheel import bdist_wheel +except ImportError: + bdist_wheel = None + +try: import distutils644 except ImportError: pass @@ -66,7 +71,7 @@ name='python-afl', version=get_version(), license='MIT', - description='American fuzzy lop fork server and instrumentation for pure-Python code', + description='American Fuzzy Lop fork server and instrumentation for pure-Python code', long_description=__doc__.strip(), classifiers=classifiers, url='http://jwilk.net/software/python-afl', @@ -74,22 +79,21 @@ author_email='[email protected]', ) -if 'setuptools' in sys.modules and sys.argv[1] == 'egg_info': - # We wouldn't normally want setuptools; but pip forces it upon us anyway, - # so let's abuse it to instruct pip to install Cython if it's missing. - distutils.core.setup( - install_requires=['Cython>=0.19'], - # Conceptually, “setup_requires” would make more sense than - # “install_requires”, but the former is not supported by pip: - # https://github.com/pypa/pip/issues/1820 - **meta - ) - sys.exit(0) - +min_cython_version = '0.19' try: import Cython except ImportError: - raise RuntimeError('Cython >= 0.19 is required') + # This shouldn't happen with pip >= 10, thanks to PEP-518 support. + # For older versions, we use this hack to trick it into installing Cython: + if 'setuptools' in sys.modules and sys.argv[1] == 'egg_info': + distutils.core.setup( + install_requires=['Cython>={v}'.format(v=min_cython_version)], + # Conceptually, “setup_requires” would make more sense than + # “install_requires”, but the former is not supported by pip. + **meta + ) + sys.exit(0) + raise RuntimeError('Cython >= {v} is required'.format(v=min_cython_version)) try: cython_version = Cython.__version__ @@ -98,8 +102,8 @@ # Oh well. We don't support such old versions anyway. cython_version = '0' cython_version = distutils.version.LooseVersion(cython_version) -if cython_version < '0.19': - raise RuntimeError('Cython >= 0.19 is required') +if cython_version < min_cython_version: + raise RuntimeError('Cython >= {v} is required'.format(v=min_cython_version)) import Cython.Build # pylint: disable=wrong-import-position @@ -115,10 +119,19 @@ distutils_sdist.make_release_tree(self, base_dir, files) self.maybe_move_file(base_dir, 'LICENSE', 'doc/LICENSE') +def d(**kwargs): + return dict( + (k, v) for k, v in kwargs.items() + if v is not None + ) + distutils.core.setup( ext_modules=Cython.Build.cythonize('afl.pyx'), scripts=glob.glob('py-afl-*'), - cmdclass=dict(sdist=cmd_sdist), + cmdclass=d( + bdist_wheel=bdist_wheel, + sdist=cmd_sdist, + ), **meta ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-afl-0.6.1/tests/target.py new/python-afl-0.7.2/tests/target.py --- old/python-afl-0.6.1/tests/target.py 2017-04-04 21:58:11.000000000 +0200 +++ new/python-afl-0.7.2/tests/target.py 2018-11-27 23:26:46.000000000 +0100 @@ -1,10 +1,33 @@ +# encoding=UTF-8 + +# Copyright © 2015-2018 Jakub Wilk <[email protected]> +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the “Software”), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +import signal import sys import afl def main(): s = sys.stdin.read() - if len(s) < 1: + if not s: print('Hum?') sys.exit(1) s.encode('ASCII') @@ -14,6 +37,7 @@ print('A non-zero value? How quaint!') if __name__ == '__main__': + signal.signal(signal.SIGCHLD, signal.SIG_IGN) # this should have no effect on the forkserver afl.init() main() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-afl-0.6.1/tests/target_persistent.py new/python-afl-0.7.2/tests/target_persistent.py --- old/python-afl-0.6.1/tests/target_persistent.py 2017-04-04 21:58:11.000000000 +0200 +++ new/python-afl-0.7.2/tests/target_persistent.py 2018-11-27 23:26:46.000000000 +0100 @@ -1,10 +1,34 @@ +# encoding=UTF-8 + +# Copyright © 2015-2018 Jakub Wilk <[email protected]> +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the “Software”), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +import signal import sys import afl def main(): + sys.stdin.seek(0) # work-around for C stdio caching EOF status s = sys.stdin.read() - if len(s) < 1: + if not s: print('Hum?') sys.exit(1) s.encode('ASCII') @@ -14,6 +38,8 @@ print('A non-zero value? How quaint!') if __name__ == '__main__': + signal.signal(signal.SIGCHLD, signal.SIG_IGN) # this should have no effect on the forkserver + ''.encode('ASCII') # make sure the codec module is loaded before the loop while afl.loop(): main() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-afl-0.6.1/tests/test_cmin.py new/python-afl-0.7.2/tests/test_cmin.py --- old/python-afl-0.6.1/tests/test_cmin.py 2017-04-04 19:05:40.000000000 +0200 +++ new/python-afl-0.7.2/tests/test_cmin.py 2018-11-27 23:26:46.000000000 +0100 @@ -1,6 +1,6 @@ # encoding=UTF-8 -# Copyright © 2015-2017 Jakub Wilk <[email protected]> +# Copyright © 2015-2018 Jakub Wilk <[email protected]> # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the “Software”), to deal @@ -25,6 +25,7 @@ from .tools import ( assert_equal, + require_commands, run, tempdir, ) @@ -33,6 +34,7 @@ target = here + '/target.py' def run_afl_cmin(input, xoutput, crashes_only=False): + require_commands('py-afl-cmin', 'afl-cmin') input = sorted(input) xoutput = sorted(xoutput) with tempdir() as workdir: @@ -62,7 +64,7 @@ run_afl_cmin([ b'0' * 6, b'0', b'X' * 7, b'1', - b'\xcf\x87', + b'\xCF\x87', ], [ b'0', b'1', @@ -72,9 +74,9 @@ run_afl_cmin([ b'0' * 6, b'0', b'X' * 7, b'1', - b'\xcf\x87', + b'\xCF\x87', ], [ - b'\xcf\x87', + b'\xCF\x87', ], crashes_only=True) # vim:ts=4 sts=4 sw=4 et diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-afl-0.6.1/tests/test_fuzz.py new/python-afl-0.7.2/tests/test_fuzz.py --- old/python-afl-0.6.1/tests/test_fuzz.py 2017-04-03 22:54:26.000000000 +0200 +++ new/python-afl-0.7.2/tests/test_fuzz.py 2018-11-27 23:26:46.000000000 +0100 @@ -1,6 +1,6 @@ # encoding=UTF-8 -# Copyright © 2015-2017 Jakub Wilk <[email protected]> +# Copyright © 2015-2018 Jakub Wilk <[email protected]> # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the “Software”), to deal @@ -45,6 +45,7 @@ SkipTest, assert_true, clean_environ, + require_commands, tempdir, ) @@ -55,13 +56,14 @@ token = token.decode('ASCII') def get_afl_version(): + require_commands('afl-fuzz') child = ipc.Popen(['afl-fuzz'], stdout=ipc.PIPE) version = child.stdout.readline() child.stdout.close() child.wait() if str is not bytes: version = version.decode('ASCII') - version = re.sub(r'\x1b\[[^m]+m', '', version) + version = re.sub(r'\x1B\[[^m]+m', '', version) match = re.match(r'^afl-fuzz\s+([0-9.]+)b?\b', version) version = match.group(1) return distutils.version.StrictVersion(version) @@ -80,6 +82,7 @@ raise SkipTest('/proc/sys/kernel/core_pattern = ' + pattern) def _test_fuzz(workdir, target, dumb=False): + require_commands('py-afl-fuzz', 'afl-fuzz') input_dir = workdir + '/in' output_dir = workdir + '/out' os.mkdir(input_dir) @@ -134,6 +137,7 @@ def stray_process_cleanup(): # afl-fuzz doesn't always kill the target process: # https://groups.google.com/d/topic/afl-users/E37s4YDti7o + require_commands('ps') try: yield finally: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-afl-0.6.1/tests/test_hash.py new/python-afl-0.7.2/tests/test_hash.py --- old/python-afl-0.6.1/tests/test_hash.py 2017-04-04 22:51:43.000000000 +0200 +++ new/python-afl-0.7.2/tests/test_hash.py 2018-11-27 23:26:46.000000000 +0100 @@ -1,6 +1,6 @@ # encoding=UTF-8 -# Copyright © 2015 Jakub Wilk <[email protected]> +# Copyright © 2015-2017 Jakub Wilk <[email protected]> # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the “Software”), to deal diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-afl-0.6.1/tests/test_import.py new/python-afl-0.7.2/tests/test_import.py --- old/python-afl-0.6.1/tests/test_import.py 2017-04-05 13:25:52.000000000 +0200 +++ new/python-afl-0.7.2/tests/test_import.py 2018-12-13 22:05:22.000000000 +0100 @@ -1,6 +1,6 @@ # encoding=UTF-8 -# Copyright © 2015-2017 Jakub Wilk <[email protected]> +# Copyright © 2015-2018 Jakub Wilk <[email protected]> # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the “Software”), to deal @@ -35,6 +35,8 @@ 'start', ] +# pylint: disable=exec-used + def wildcard_import(mod): ns = {} exec('from {mod} import *'.format(mod=mod), {}, ns) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-afl-0.6.1/tests/test_showmap.py new/python-afl-0.7.2/tests/test_showmap.py --- old/python-afl-0.6.1/tests/test_showmap.py 2017-04-03 23:22:54.000000000 +0200 +++ new/python-afl-0.7.2/tests/test_showmap.py 2018-11-27 23:26:46.000000000 +0100 @@ -1,6 +1,6 @@ # encoding=UTF-8 -# Copyright © 2015-2017 Jakub Wilk <[email protected]> +# Copyright © 2015-2018 Jakub Wilk <[email protected]> # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the “Software”), to deal @@ -26,6 +26,7 @@ from .tools import ( assert_equal, assert_not_equal, + require_commands, run, tempdir, ) @@ -34,6 +35,7 @@ target = here + '/target.py' def run_afl_showmap(stdin, xstdout=None, xstatus=0): + require_commands('py-afl-showmap', 'afl-showmap') with tempdir() as workdir: outpath = workdir + '/out' (stdout, stderr) = run( @@ -53,7 +55,7 @@ assert_not_equal(out1, out2) def test_exception(): - out = run_afl_showmap(b'\xff', + out = run_afl_showmap(b'\xFF', xstatus=2, ) assert_not_equal(out, b'') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-afl-0.6.1/tests/test_tmin.py new/python-afl-0.7.2/tests/test_tmin.py --- old/python-afl-0.6.1/tests/test_tmin.py 2017-04-04 19:01:06.000000000 +0200 +++ new/python-afl-0.7.2/tests/test_tmin.py 2018-11-27 23:26:46.000000000 +0100 @@ -1,6 +1,6 @@ # encoding=UTF-8 -# Copyright © 2015-2017 Jakub Wilk <[email protected]> +# Copyright © 2015-2018 Jakub Wilk <[email protected]> # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the “Software”), to deal @@ -25,6 +25,7 @@ from .tools import ( assert_equal, + require_commands, run, tempdir, ) @@ -33,6 +34,7 @@ target = here + '/target.py' def run_afl_tmin(input, xoutput, xstatus=0): + require_commands('py-afl-tmin', 'afl-tmin') with tempdir() as workdir: inpath = workdir + '/in' with open(inpath, 'wb') as file: @@ -51,6 +53,6 @@ run_afl_tmin(b'X' * 7, b'X') def test_exc(): - run_afl_tmin(b'\xcf\x87', b'\x87') + run_afl_tmin(b'\xCF\x87', b'\x87') # vim:ts=4 sts=4 sw=4 et diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-afl-0.6.1/tests/tools.py new/python-afl-0.7.2/tests/tools.py --- old/python-afl-0.6.1/tests/tools.py 2017-07-28 16:33:21.000000000 +0200 +++ new/python-afl-0.7.2/tests/tools.py 2019-01-29 16:37:17.000000000 +0100 @@ -1,6 +1,6 @@ # encoding=UTF-8 -# Copyright © 2013-2017 Jakub Wilk <[email protected]> +# Copyright © 2013-2019 Jakub Wilk <[email protected]> # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the “Software”), to deal @@ -41,6 +41,9 @@ assert_true, ) +def assert_fail(msg): + assert_true(False, msg=msg) # pylint: disable=redundant-unittest-assert + def noseimport(vmaj, vmin, name=None): def wrapper(f): if f.__module__ == 'unittest.case': @@ -59,7 +62,7 @@ return self def __exit__(self, exc_type, exc_value, tb): if exc_type is None: - assert_true(False, '{0} not raised'.format(self._exc_type.__name__)) + assert_fail('{0} not raised'.format(self._exc_type.__name__)) if not issubclass(exc_type, self._exc_type): return False if isinstance(exc_value, exc_type): @@ -92,7 +95,7 @@ regex = re.compile(regex) if not regex.search(text): message = "Regex didn't match: {0!r} not found in {1!r}".format(regex.pattern, text) - assert_true(False, msg=message) + assert_fail(msg=message) @noseimport(3, 2) @contextlib.contextmanager @@ -110,11 +113,11 @@ if re.search(regex, str(w)): return if firstw is None: - assert_true(False, msg='{exc} not triggered'.format(exc=exc_type.__name__)) + assert_fail(msg='{exc} not triggered'.format(exc=exc_type.__name__)) else: - assert_true(False, msg='{exc!r} does not match {re!r}'.format(exc=str(firstw), re=regex)) + assert_fail(msg='{exc!r} does not match {re!r}'.format(exc=str(firstw), re=regex)) -class IsolatedError(Exception): +class IsolatedException(Exception): pass def _n_relevant_tb_levels(tb): @@ -134,6 +137,24 @@ os.environ['AFL_ALLOW_TMP'] = '1' # AFL >= 2.48b os.environ['PWD'] = '//' + os.getcwd() # poor man's AFL_ALLOW_TMP for AFL << 2.48b +def require_commands(*cmds): + PATH = os.environ.get('PATH', os.defpath) + PATH = PATH.split(os.pathsep) + for cmd in cmds: + for dir in PATH: + path = os.path.join(dir, cmd) + if os.access(path, os.X_OK): + break + else: + if cmd == 'ps': + cmd = 'ps(1)' + reason = 'procps installed' + elif cmd.startswith('afl-'): + reason = 'AFL installed' + else: + reason = 'PATH set correctly' + raise RuntimeError('{cmd} not found; is {reason}?'.format(cmd=cmd, reason=reason)) + def run(cmd, stdin='', xstatus=0): child = ipc.Popen( list(cmd), @@ -197,7 +218,7 @@ msg = msg.rstrip('\n') pid, status = os.waitpid(pid, 0) if status == (EXIT_EXCEPTION << 8): - raise IsolatedError('\n\n' + msg) + raise IsolatedException('\n\n' + msg) elif status == (EXIT_SKIP_TEST << 8): raise SkipTest(msg) elif status == 0 and msg == '': @@ -225,6 +246,7 @@ 'assert_true', 'assert_warns_regex', 'fork_isolation', + 'require_commands', 'run', 'tempdir', ]
