Skip to content
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

Merged
merged 15 commits into from Jan 19, 2020
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Rework the mutators into separate classes.

The mutators were supplied inline with the corpus mutation loop. This
makes it tedious to extend, and difficult to filter out mutations
which are not interesting.

The code has been reworked here so that...

* Each mutator is its own class.
* Each class can provide information about what it does, such as its
  name and the types of mutations it performs.
* Each class is registered into a list of classes that are available.
* The Corpus instantiates these classes when it is intialised, and
  could (but does not at this time) filter the list as necessary.
  The name isn't even used yet.
* Mutators can return None to say that they're not appropriate.

This means that adding a new mutator is a matter of creating a new
class, in the same style as the existing ones, and giving information
on what the mutator does. Mutators could be based on one another -
so for example the 'swap' mutator could be reworked to exchange
variable lengths of values, rather than only bytes, and then subclassed
to produce short, long and longlong variants. This has not been done
here.

Previously, the code attempted to retry applying mutators if they
were not deemed appropriate; this was ineffective because they merely
tried to decrement the iteration count, which did not affect the
iterations at all - it looks like the code was originally using
C-style for loops where the variable controls the termination, whilst
in Python the range controls the iteration of this loop. This has
been replaced by the mutator returning None to signal that it is
inappropriate, and a loop in the caller repeats the selection of
a new mutator.
  • Loading branch information
gerph committed Jan 6, 2020
commit d685d2de0be43c5b1745807be4350a371e4421ca
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.