image-fuzzer: Initial image generator and extended runner
cover image-fuzzer: Initial image generator and extended runner
These patches relate to qcow2 image fuzzer project at OPW.
Overall fix: Current license for all files are GPLv2 Runner:
Fixes (based on reviews):
* added mandatory parameter for image generator
* removed image size parameter from call of an image generator
* removed seed as argument for image generator
* left core dump enabling as non-optional functionality
* added '--verbose' parameter turning on passes logging
* made 'Error' test statuses less talkative
* unified handling of incorrect parameters
* various formatting and doc enhancements
Features:
* infinite test executions until keyboard interruption
* supported relative paths in runner.py parameters
Docs:
Fixes (based on reviews):
* removed requirements to seed being sent to image generator
* added support for external image generators
* added requirement to core dumps configuration
Features:
* description for qcow2 image generator
* description for SUT calls
Qcow2:
Features:
* creation of random valid header fields
* fuzzing of header fields
* supported fuzzing of integer and bit mask field values
* random amount of fields to be fuzzed (20%-50% of all fields)
* random selection of fields to be fuzzed
*** BLURB HERE ***
Maria Kustova (3):
image-fuzzer: Added execution of multiple tests to the test runner
image-fuzzer: Initial generator of qcow2 fuzzed images
image-fuzzer: Added description for the qcow2 image generator
tests/image-fuzzer/docs/image-fuzzer.txt | 178 ++++++++++++++++++++ tests/image-fuzzer/qcow2/__init__.py | 1 + tests/image-fuzzer/qcow2/fuzz.py | 271 +++++++++++++++++++++++++++++++ tests/image-fuzzer/qcow2/layout.py | 125 ++++++++++++++ tests/image-fuzzer/runner/runner.py | 260 +++++++++++++++++++++++++++++ 5 files changed, 835 insertions(+) create mode 100644 tests/image-fuzzer/docs/image-fuzzer.txt create mode 100644 tests/image-fuzzer/qcow2/__init__.py create mode 100644 tests/image-fuzzer/qcow2/fuzz.py create mode 100644 tests/image-fuzzer/qcow2/layout.py create mode 100644 tests/image-fuzzer/runner/runner.py
Signature · 1 line
1.9.3
RFC 1/3 image-fuzzer: Added execution of multiple tests to the test runner
Apart from fixes this patch allows to run multiple tests in a row. If 'seed' argument is not specified the runner generates and executes new tests one by one till keyboard interruption. Specified seed forces the runner to execute only one test with current seed and exit.
--- tests/image-fuzzer/runner/runner.py | 260 ++++++++++++++++++++++++++++++++++++ 1 file changed, 260 insertions(+) create mode 100644 tests/image-fuzzer/runner/runner.py
tests/image-fuzzer/runner/runner.py new file +260 -0
@@ -0,0 +1,260 @@ +# Tool for running fuzz tests +# +# Copyright (C) 2014 Maria Kustova <[email protected]> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +import sys, os, signal +from time import time +import subprocess +import random +from itertools import count +from shutil import rmtree +import getopt +import resource +resource.setrlimit(resource.RLIMIT_CORE, (-1, -1)) + + +def multilog(msg, *output): + """ Write an object to all of specified file descriptors + """ + + for fd in output: + fd.write(msg) + fd.flush() + + +def str_signal(sig): + """ Convert a numeric value of a system signal to the string one + defined by the current operational system + """ + + for k, v in signal.__dict__.items(): + if v == sig: + return k + + +class TestException(Exception): + """Exception for errors risen by TestEnv objects""" + pass + + +class TestEnv(object): + """ Trivial test object + + The class sets up test environment, generates a test image and executes + application under tests with specified arguments and a test image provided. + All logs are collected. + Summary log will contain short descriptions and statuses of tests in + a run. + Test log will include application (e.g. 'qemu-img') logs besides info sent + to the summary log. + """ + + def __init__(self, test_id, seed, work_dir, run_log, exec_bin=None, + cleanup=True, log_all=False): + """Set test environment in a specified work directory. + + Path to qemu_img will be retrieved from 'QEMU_IMG' environment + variable, if a test binary is not specified. + """ + + if seed is not None: + self.seed = seed + else: + self.seed = hash(time()) + + self.init_path = os.getcwd() + self.work_dir = work_dir + self.current_dir = os.path.join(work_dir, 'test-' + test_id) + if exec_bin is not None: + self.exec_bin = exec_bin.strip().split(' ') + else: + self.exec_bin = \ + os.environ.get('QEMU_IMG', 'qemu-img').strip().split(' ') + + try: + os.makedirs(self.current_dir) + except OSError: + e = sys.exc_info()[1] + print >>sys.stderr, \ + "Error: The working directory '%s' cannot be used. Reason: %s"\ + % (self.work_dir, e[1]) + raise TestException + self.log = open(os.path.join(self.current_dir, "test.log"), "w") + self.parent_log = open(run_log, "a") + self.result = False + self.cleanup = cleanup + self.log_all = log_all + + def _test_app(self, q_args): + """ Start application under test with specified arguments and return + an exit code or a kill signal depending on result of an execution. + """ + devnull = open('/dev/null', 'r+') + return subprocess.call(self.exec_bin + q_args + ['test_image'], + stdin=devnull, stdout=self.log, stderr=self.log) + + def execute(self, q_args): + """ Execute a test. + + The method creates a test image, runs test app and analyzes its exit + status. If the application was killed by a signal, the test is marked + as failed. + """ + os.chdir(self.current_dir) + # Seed initialization should be as close to image generation call + # as posssible to avoid a corruption of random sequence + random.seed(self.seed) + image_generator.create_image('test_image') + test_summary = "Seed: %s\nCommand: %s\nTest directory: %s\n" \ + % (self.seed, " ".join(q_args), self.current_dir) + try: + retcode = self._test_app(q_args) + except OSError: + e = sys.exc_info()[1] + multilog(test_summary + "Error: Start of '%s' failed. " \ + "Reason: %s\n\n" % (os.path.basename(self.exec_bin[0]), + e[1]), + sys.stderr, self.log, self.parent_log) + raise TestException + + if retcode < 0: + multilog(test_summary + "FAIL: Test terminated by signal %s\n\n" + % str_signal(-retcode), sys.stderr, self.log, + self.parent_log) + elif self.log_all: + multilog(test_summary + "PASS: Application exited with the code" + + " '%d'\n\n" % retcode, sys.stdout, self.log, + self.parent_log) + self.result = True + else: + self.result = True + + def finish(self): + """ Restore environment after a test execution. Remove folders of + passed tests + """ + self.log.close() + self.parent_log.close() + os.chdir(self.init_path) + if self.result and self.cleanup: + rmtree(self.current_dir) + +if __name__ == '__main__': + + def usage(): + print """ + Usage: runner.py [OPTION...] DIRECTORY PATH + + Set up test environment in DIRECTORY and run a test in it. Test image + generator should be specified via PATH to it. + + Optional arguments: + -h, --help display this help and exit + -b, --binary=PATH path to the application under test, + by default "qemu-img" in PATH or + QEMU_IMG environment variables + -c, --command=STRING execute the tested application + with arguments specified, + by default STRING="check" + -s, --seed=STRING seed for a test image generation, + by default will be generated randomly + -k, --keep_passed don't remove folders of passed tests + -v, --verbose log information about passed tests + """ + + def run_test(test_id, seed, work_dir, run_log, test_bin, cleanup, log_all, + command): + """Setup environment for one test and execute this test""" + try: + test = TestEnv(test_id, seed, work_dir, run_log, test_bin, cleanup, + log_all) + except TestException: + sys.exit(1) + + # Python 2.4 doesn't support 'finally' and 'except' in the same 'try' + # block + try: + try: + test.execute(command) + # Silent exit on user break + except TestException: + sys.exit(1) + finally: + test.finish() + + try: + opts, args = getopt.gnu_getopt(sys.argv[1:], 'c:hb:s:kv', + ['command=', 'help', 'binary=', 'seed=', + 'keep_passed', 'verbose']) + except getopt.error: + e = sys.exc_info()[1] + print "Error: %s\n\nTry 'runner.py --help' for more information" % e + sys.exit(1) + + command = ['check'] + cleanup = True + log_all = False + test_bin = None + seed = None + for opt, arg in opts: + if opt in ('-h', '--help'): + usage() + sys.exit() + elif opt in ('-c', '--command'): + command = arg.split(" ") + elif opt in ('-k', '--keep_passed'): + cleanup = False + elif opt in ('-v', '--verbose'): + log_all = True + elif opt in ('-b', '--binary'): + test_bin = os.path.realpath(arg) + elif opt in ('-s', '--seed'): + seed = arg + + if not len(args) == 2: + print "Missed parameter\nTry 'runner.py --help' " \ + "for more information" + sys.exit(1) + + work_dir = os.path.realpath(args[0]) + # run_log is created in 'main', because multiple tests are expected to \ + # log in it + run_log = os.path.join(work_dir, 'run.log') + + # Add the module path to sys.path + sys.path.append(os.path.dirname(os.path.realpath(args[1]))) + # Remove a script extension if any + generator_name = os.path.splitext(os.path.basename(args[1]))[0] + try: + image_generator = __import__(generator_name) + except ImportError: + e = sys.exc_info()[1] + print "Error: The image generator '%s' cannot be imported.\n" \ + "Reason: %s" % (generator_name, e) + sys.exit(1) + + # If a seed is specified, only one test will be executed. + # Otherwise runner will terminate after a keyboard interruption + for test_id in count(1): + try: + run_test(str(test_id), seed, work_dir, run_log, test_bin, cleanup, + log_all, command) + except (KeyboardInterrupt, SystemExit): + sys.exit(1) + + if seed is not None: + break
Signature · 1 line
1.9.3
Re: [Qemu-devel] [RFC 1/3] image-fuzzer: Added execution of multiple tests to the test runner
tests/image-fuzzer/runner/runner.py
Quoted 13 lines · Maria Kustova
Apart from fixes this patch allows to run multiple tests in a row. If 'seed' argument is not specified the runner generates and executes new tests one by one till keyboard interruption. Specified seed forces the runner to execute only one test with current seed and exit.
Signed-off-by Maria Kustova <[email protected]>--- tests/image-fuzzer/runner/runner.py | 260 ++++++++++++++++++++++++++++++++++++ 1 file changed, 260 insertions(+) create mode 100644 tests/image-fuzzer/runner/runner.pytests/image-fuzzer/runner/runner.py new file +0
-0
Could chmod +x on this file :)
Quoted 154 lines
index 0000000..5d09b2e
tests/image-fuzzer/runner/runner.py new file +150
-0@@ -0,0 +1,260 @@ +# Tool for running fuzz tests +# +# Copyright (C) 2014 Maria Kustova <[email protected]> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +import sys, os, signal +from time import time +import subprocess +import random +from itertools import count +from shutil import rmtree +import getopt +import resource +resource.setrlimit(resource.RLIMIT_CORE, (-1, -1)) + + +def multilog(msg, *output): + """ Write an object to all of specified file descriptors + """ + + for fd in output: + fd.write(msg) + fd.flush() + + +def str_signal(sig): + """ Convert a numeric value of a system signal to the string one + defined by the current operational system + """ + + for k, v in signal.__dict__.items(): + if v == sig: + return k + + +class TestException(Exception): + """Exception for errors risen by TestEnv objects""" + pass + + +class TestEnv(object): + """ Trivial test object + + The class sets up test environment, generates a test image and executes + application under tests with specified arguments and a test image provided. + All logs are collected. + Summary log will contain short descriptions and statuses of tests in + a run. + Test log will include application (e.g. 'qemu-img') logs besides info sent + to the summary log. + """ + + def __init__(self, test_id, seed, work_dir, run_log, exec_bin=None, + cleanup=True, log_all=False): + """Set test environment in a specified work directory. + + Path to qemu_img will be retrieved from 'QEMU_IMG' environment + variable, if a test binary is not specified. + """ + + if seed is not None: + self.seed = seed + else: + self.seed = hash(time()) + + self.init_path = os.getcwd() + self.work_dir = work_dir + self.current_dir = os.path.join(work_dir, 'test-' + test_id) + if exec_bin is not None: + self.exec_bin = exec_bin.strip().split(' ') + else: + self.exec_bin = \ + os.environ.get('QEMU_IMG', 'qemu-img').strip().split(' ') + + try: + os.makedirs(self.current_dir) + except OSError: + e = sys.exc_info()[1] + print >>sys.stderr, \ + "Error: The working directory '%s' cannot be used. Reason: %s"\ + % (self.work_dir, e[1]) + raise TestException + self.log = open(os.path.join(self.current_dir, "test.log"), "w") + self.parent_log = open(run_log, "a") + self.result = False + self.cleanup = cleanup + self.log_all = log_all + + def _test_app(self, q_args): + """ Start application under test with specified arguments and return + an exit code or a kill signal depending on result of an execution. + """ + devnull = open('/dev/null', 'r+') + return subprocess.call(self.exec_bin + q_args + ['test_image'], + stdin=devnull, stdout=self.log, stderr=self.log) + + def execute(self, q_args): + """ Execute a test. + + The method creates a test image, runs test app and analyzes its exit + status. If the application was killed by a signal, the test is marked + as failed. + """ + os.chdir(self.current_dir) + # Seed initialization should be as close to image generation call + # as posssible to avoid a corruption of random sequence + random.seed(self.seed) + image_generator.create_image('test_image') + test_summary = "Seed: %s\nCommand: %s\nTest directory: %s\n" \ + % (self.seed, " ".join(q_args), self.current_dir) + try: + retcode = self._test_app(q_args) + except OSError: + e = sys.exc_info()[1] + multilog(test_summary + "Error: Start of '%s' failed. " \ + "Reason: %s\n\n" % (os.path.basename(self.exec_bin[0]), + e[1]), + sys.stderr, self.log, self.parent_log) + raise TestException + + if retcode < 0: + multilog(test_summary + "FAIL: Test terminated by signal %s\n\n" + % str_signal(-retcode), sys.stderr, self.log, + self.parent_log) + elif self.log_all: + multilog(test_summary + "PASS: Application exited with the code" + + " '%d'\n\n" % retcode, sys.stdout, self.log, + self.parent_log) + self.result = True + else: + self.result = True + + def finish(self): + """ Restore environment after a test execution. Remove folders of + passed tests + """ + self.log.close()
tests/image-fuzzer/runner/runner.py line 160
Quoted 10 lines
tests/image-fuzzer/runner/runner.py new file +10
-0+ self.parent_log.close() + os.chdir(self.init_path) + if self.result and self.cleanup: + rmtree(self.current_dir) + +if __name__ == '__main__': + + def usage(): + print """ + Usage: runner.py [OPTION...] DIRECTORY PATH
I suggest rename DIRECTORY to TEST_DIR and PATH to GENERATOR_MOD. Because these two required arguments are not very intuitive, maybe showing an example to run qcow2 in $TEST_DIR may help as well.
Otherwise looks good!
For the next step, it would be convinient to allow running a common set of test commands, for a better coverage:
qemu-img check
qemu-img info
qemu-img convert
qemu-io $TEST_IMG -c "read $start $end"
qemu-io $TEST_IMG -c "write $start $end"
qemu-io $TEST_IMG -c "aio_read $start $end"
qemu-io $TEST_IMG -c "aio_write $start $end"
qemu-io $TEST_IMG -c "flush $start $end"
...
...
The reason is that "qemu-img check" doesn't involve much of read/write/flush code paths. So we should think about making the commands extendable as well, maybe in a similar way as the image generators.
Fam
Quoted 103 lines
tests/image-fuzzer/runner/runner.py new file +100
-0+ + Set up test environment in DIRECTORY and run a test in it. Test image + generator should be specified via PATH to it. + + Optional arguments: + -h, --help display this help and exit + -b, --binary=PATH path to the application under test, + by default "qemu-img" in PATH or + QEMU_IMG environment variables + -c, --command=STRING execute the tested application + with arguments specified, + by default STRING="check" + -s, --seed=STRING seed for a test image generation, + by default will be generated randomly + -k, --keep_passed don't remove folders of passed tests + -v, --verbose log information about passed tests + """ + + def run_test(test_id, seed, work_dir, run_log, test_bin, cleanup, log_all, + command): + """Setup environment for one test and execute this test""" + try: + test = TestEnv(test_id, seed, work_dir, run_log, test_bin, cleanup, + log_all) + except TestException: + sys.exit(1) + + # Python 2.4 doesn't support 'finally' and 'except' in the same 'try' + # block + try: + try: + test.execute(command) + # Silent exit on user break + except TestException: + sys.exit(1) + finally: + test.finish() + + try: + opts, args = getopt.gnu_getopt(sys.argv[1:], 'c:hb:s:kv', + ['command=', 'help', 'binary=', 'seed=', + 'keep_passed', 'verbose']) + except getopt.error: + e = sys.exc_info()[1] + print "Error: %s\n\nTry 'runner.py --help' for more information" % e + sys.exit(1) + + command = ['check'] + cleanup = True + log_all = False + test_bin = None + seed = None + for opt, arg in opts: + if opt in ('-h', '--help'): + usage() + sys.exit() + elif opt in ('-c', '--command'): + command = arg.split(" ") + elif opt in ('-k', '--keep_passed'): + cleanup = False + elif opt in ('-v', '--verbose'): + log_all = True + elif opt in ('-b', '--binary'): + test_bin = os.path.realpath(arg) + elif opt in ('-s', '--seed'): + seed = arg + + if not len(args) == 2: + print "Missed parameter\nTry 'runner.py --help' " \ + "for more information" + sys.exit(1) + + work_dir = os.path.realpath(args[0]) + # run_log is created in 'main', because multiple tests are expected to \ + # log in it + run_log = os.path.join(work_dir, 'run.log') + + # Add the module path to sys.path + sys.path.append(os.path.dirname(os.path.realpath(args[1]))) + # Remove a script extension if any + generator_name = os.path.splitext(os.path.basename(args[1]))[0] + try: + image_generator = __import__(generator_name) + except ImportError: + e = sys.exc_info()[1] + print "Error: The image generator '%s' cannot be imported.\n" \ + "Reason: %s" % (generator_name, e) + sys.exit(1) + + # If a seed is specified, only one test will be executed. + # Otherwise runner will terminate after a keyboard interruption + for test_id in count(1): + try: + run_test(str(test_id), seed, work_dir, run_log, test_bin, cleanup, + log_all, command) + except (KeyboardInterrupt, SystemExit): + sys.exit(1) + + if seed is not None: + breakSignature · 1 line
1.9.3
RFC 2/3 image-fuzzer: Initial generator of qcow2 fuzzed images
In reply to Maria KustovaQcow2 image generator is a python package providing create_image(img_path) method required by the test runner.
It generates files containing fuzzed qcow2 image headers. Files are randomly variable not only in fuzzed fields but in valid structure elements like image and cluster size.
--- tests/image-fuzzer/qcow2/__init__.py | 1 + tests/image-fuzzer/qcow2/fuzz.py | 271 +++++++++++++++++++++++++++++++++++ tests/image-fuzzer/qcow2/layout.py | 125 ++++++++++++++++ 3 files changed, 397 insertions(+) create mode 100644 tests/image-fuzzer/qcow2/__init__.py create mode 100644 tests/image-fuzzer/qcow2/fuzz.py create mode 100644 tests/image-fuzzer/qcow2/layout.py
tests/image-fuzzer/qcow2/__init__.py new file +1 -0
@@ -0,0 +1 @@ +from layout import create_image
tests/image-fuzzer/qcow2/fuzz.py new file +271 -0
271 lines not on this page · raw message
tests/image-fuzzer/qcow2/layout.py new file +125 -0
125 lines not on this page · raw message
Signature · 1 line
1.9.3
RFC 3/3 image-fuzzer: Added description for the qcow2 image generator
In reply to Maria KustovaApart from fixes the description for image generator was added.
--- tests/image-fuzzer/docs/image-fuzzer.txt | 178 +++++++++++++++++++++++++++++++ 1 file changed, 178 insertions(+) create mode 100644 tests/image-fuzzer/docs/image-fuzzer.txt
tests/image-fuzzer/docs/image-fuzzer.txt new file +178 -0
@@ -0,0 +1,178 @@ +Image fuzzer +============ + +Description +----------- + +The goal of the image fuzzer is to catch crashes of qemu-io/qemu-img providing +to them randomly corrupted images. +Test images are generated from scratch and have valid inner structure with some +elements, e.g. L1/L2 tables, having random invalid values. + + +Test runner +----------- + +The test runner generates test images, executes tests utilizing generated +images, indicates their results and collect all test related artifacts (logs, +core dumps, test image). +The test means one start of a system under test (SUT), e.g. qemu-io, with +specified arguments and one test image. +By default, the test runner generates new tests and executes them until +keyboard interruption. But if a test seed is specified via '-s' runner +parameter, then only one test with this seed will be executed, after its finish +the runner will exit. + +The runner uses an external image fuzzer to generate test images. An image +generator should be specified as a mandatory parameter of the test runner. +Details about interactions between the runner and fuzzers see "Module +interfaces". + +The runner activates generation of core dumps during test executions, but it +assumes that core dumps will be generated in the current working directory. +For comprehensive test results, please, set up your test environment +properly. + +Path to a binary under test can be specified via environment variables (for now +only qemu-img) or the runner parameter. For details about environment variables +see qemu-iotests/check. + + +Qcow2 image generator +--------------------- + +The 'qcow2' generator is a Python package providing +'create_image(test_img_path)' method as a single public API. Other methods can +be accessed by specifying a submodule prefix, e.g. + + import qcow2 + + qcow2.create_image('test_image') + qcow2.fuzz.version()' + + +Qcow2 contains two submodules: fuzz.py and layout.py. + +'fuzz.py' contains all fuzzing functions one per image field. It's assumed that +after code analysis every field will have own constraints for its value. + +'layout.py' creates a random valid image, fuzzes a random subset of the image +fields based on their already generated valid values and writes the fuzzed +image to the file specified. + +For now only header fields are generated, the remaining file is filled with +zeros. + + +Module interfaces +----------------- + +* Test runner/image fuzzer + +The runner calls an image generator specifying path to a test image file. +An image generator is expected to provide 'create_image(test_img_path)' method +that creates a test image and writes it to the specified file. The file should +be created if it doesn't exist or overwritten otherwise. +Random seed is set by the runner at every test execution for the regression +purpose, so an image generator is not recommended to modify it internally. + +* Test runner/SUT + +For now a full test command is composed from the SUT, SUT arguments specified +via '-c' runner parameter and the name of generated image, e.g. for qemu-img +as a SUT and 'check' command the result call will be + + qemu-img check test_image + +where 'test_image' is predefined name for any generated image. + + +Overall fuzzer requirements +=========================== + +Input data: +---------- + + - image structure template + - test run duration (optional) + - action vector (optional) + - seed (optional) + - fuzzing type (optional) + - qemu-img arguments (optional) + + +Fuzzer requirements: +------------------- + +1. Should be able to inject random data +2. Should be able to permutate part of specified data +3. Should be able to select a random value from the manually pregenerated + vector (boundary values, e.g. max/min cluster size) +4. Image template should describe a general structure invariant for all + test images (image format description) +5. Image template should be autonomous and other fuzzer parts should not + relate on it +6. Image template should contain reference rules (not only block+size + description) +7. Should generate the test image with the correct structure based on an image + template +8. Should accept a seed as an argument (for regression purpose) +9. Should generate a seed if it is not specified as an input parameter. +10. The same seed should generate the same image, if no or the same action + vector and fuzzing type are specified +11. Should accept a vector of actions as an argument (for test reproducing and + for test case specification, e.g. group of tests for header structure, + group of test for snapshots, etc) +12. Action vector should be randomly generated from the pool of available + actions, if it is not specified as an input parameter +13. Pool of actions should be defined automatically based on an image template +14. Should accept a fuzzing type: random values or pregenerated ones + (if possible). +15. Should accept qemu-img call parameters as an argument and select them + randomly otherwise. As far as it's expected to be rarely changed, the list + of possible values will be available in the test runner internally. +16. Should accept a test run duration as an argument. Tests should be executed + during a minimum period from a test run duration and time while fuzzer can + generate different test images +17. Should support an external cancellation of a test run +18. Seed, action vector and fuzzing type should be logged (for regression + purpose) +19. All files related to test result should be collected: a test image, + qemu logs, fuzzer logs and crash dumps +20. Should be compatible with python version 2.4-2.7 +21. Usage of external libraries should be limited as much as possible. + + +Image formats: +------------- + +Main target image format is qcow2, but support of image templates should +provide an ability to add any other image format. + + +Effectiveness: +------------- + +Fuzzer can be controlled via template, seed and action vector; +this make the fuzzer itself invariant to an image format and test logic. +It should be able to perform rather complex and precise tests, that can be +specified via action vector. Otherwise, knowledge about an image structure +allows the fuzzer to generate the pool of all available areas can be fuzzed +and randomly select some of them and so compose its own action vector. +Also complexity of a template defines complexity of the fuzzer, so its +functionality can be varied from simple model-independent fuzzing to smart +model-based one. + + +Glossary: +-------- + +Action vector is a sequence of structure elements retrieved from an image +format, each of which will be fuzzed for the test image. It's a subset of +elements of the action pool. Example: header, refcount block, etc. +Action pool is all available elements of an image structure that generated +automatically from an image template. +Image template is a formal description of an image structure and relations +between image blocks +Test image is an output image of fuzzer defined by the current seed, fuzz type +and action vector.
Signature · 1 line
1.9.3
Should be v2 in the subject?
Quoted 36 lines · Maria Kustova
These patches relate to qcow2 image fuzzer project at OPW.
Overall fix: Current license for all files are GPLv2 Runner:
Fixes (based on reviews):
* added mandatory parameter for image generator
* removed image size parameter from call of an image generator
* removed seed as argument for image generator
* left core dump enabling as non-optional functionality
* added '--verbose' parameter turning on passes logging
* made 'Error' test statuses less talkative
* unified handling of incorrect parameters
* various formatting and doc enhancementsFeatures:
* infinite test executions until keyboard interruption
* supported relative paths inrunner.pyparametersDocs:
Fixes (based on reviews):
* removed requirements to seed being sent to image generator
* added support for external image generators
* added requirement to core dumps configurationFeatures:
* description for qcow2 image generator
* description for SUT callsQcow2:
Features:
* creation of random valid header fields
* fuzzing of header fields
* supported fuzzing of integer and bit mask field values
* random amount of fields to be fuzzed (20%-50% of all fields)
* random selection of fields to be fuzzed
Quoted 1 line
*** BLURB HERE ***
Not necessary :)
Fam
Quoted 22 lines
Maria Kustova (3):
image-fuzzer: Added execution of multiple tests to the test runner
image-fuzzer: Initial generator of qcow2 fuzzed images
image-fuzzer: Added description for the qcow2 image generatortests/image-fuzzer/docs/image-fuzzer.txt | 178 ++++++++++++++++++++ tests/image-fuzzer/qcow2/__init__.py | 1 + tests/image-fuzzer/qcow2/fuzz.py | 271 +++++++++++++++++++++++++++++++ tests/image-fuzzer/qcow2/layout.py | 125 ++++++++++++++ tests/image-fuzzer/runner/runner.py | 260 +++++++++++++++++++++++++++++ 5 files changed, 835 insertions(+) create mode 100644 tests/image-fuzzer/docs/image-fuzzer.txt create mode 100644 tests/image-fuzzer/qcow2/__init__.py create mode 100644 tests/image-fuzzer/qcow2/fuzz.py create mode 100644 tests/image-fuzzer/qcow2/layout.py create mode 100644 tests/image-fuzzer/runner/runner.pySignature · 1 line
1.9.3