Skip to content

Commit c7208e6

Browse files
Merge pull request #54 from cisco-sas/next
version 0.6.8
2 parents f718be6 + afe797d commit c7208e6

33 files changed

+1531
-311
lines changed

CHANGELOG

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,34 @@
1+
Version 0.6.8 (2016-05-04)
2+
==========================
3+
4+
* bugfix: [DataModel] Delimiter field's __init__ didn't receive nor passed an encoder
5+
* bugfix: [DataModel] condition - added copy function and fixed invalidate function
6+
* bugfix: [DataModel] rendering of default values in containers
7+
* enhancement: [WebInterface] html - improvements in index and reports display
8+
* new feature: [DataModel] new field - Float
9+
* new feature: [DataModel] new field - Switch
10+
111
Version 0.6.7 (2016-04-18)
212
==========================
313

4-
* new feature: [KittyActor] a new class, KittyActor, is now the base class for monitors and controllers
5-
* new feature: [KittyActor] a new API is_victim_alive can be used to check if the victim is alive, it is called in a loop in pre-test
6-
* enhancement: [BaseFuzzer] default logging level is now INFO, hence less messages are printed, can be controlled from cmd line args
714
* bugfix: [BaseFuzzer] update test info before the calling target's pre_test
8-
* new feature: [Report] use 'status' field instead of 'failed' field in the report. currently support FAILED, PASSED and ERROR.
9-
* enhancement: [WebInterface] html - improvements of caching, window size, cell overflow
10-
* new feature: [WebInterface] html - report table now shows test status and reason
11-
* bugfix: [kitty-tool] fixed command line option parsing
12-
* new feature: [kitty-tool] added checks for mutation indices in "generate"
13-
* new feature: [kitty-tool] print progress and current field path in "generate"
1415
* bugfix: [DataModel] fixed "field path" in field info
15-
* new feature: [DataModel] new fields - Offset & AbsoluteOffset - can hold the offset of a specific field inside the template
16-
* new feature: [DataModel] new conditions - BitMaskSet and BitMaskNotSet
17-
* new feature: [DataModel] absolute name resolution of fields
16+
* bugfix: [kitty-tool] fixed command line option parsing
17+
* enhancement: [BaseFuzzer] default logging level is now INFO, hence less messages are printed, can be controlled from cmd line args
1818
* enhancement: [DataModel] perform render in two passes when needed, avoid (some) redundant rendering in between
19-
* new feature: [DataModel] new container - List - will perform the standard mutations of each of the internal fields, but will also perform mutations on the order and existence of its elements.
2019
* enhancement: [DataModel] reduce number of mutations for BitField & String field. This cuts the mutation count to about half of the previous count.
20+
* enhancement: [WebInterface] html - improvements of caching, window size, cell overflow
21+
* new feature: [DataModel] new conditions - BitMaskSet and BitMaskNotSet
22+
* new feature: [DataModel] new container - List - will perform the standard mutations of each of the internal fields, but will also perform mutations on the order and existence of its elements.
23+
* new feature: [DataModel] new fields - Offset & AbsoluteOffset - can hold the offset of a specific field inside the template
24+
* new feature: [DataModel] absolute name resolution of fields
2125
* new feature: [DataModel] now String and BitField have a human friendly mutation description in the info
26+
* new feature: [KittyActor] a new class, KittyActor, is now the base class for monitors and controllers
27+
* new feature: [KittyActor] a new API is_victim_alive can be used to check if the victim is alive, it is called in a loop in pre-test
28+
* new feature: [kitty-tool] added checks for mutation indices in "generate"
29+
* new feature: [kitty-tool] print progress and current field path in "generate"
30+
* new feature: [Report] use 'status' field instead of 'failed' field in the report. currently support FAILED, PASSED and ERROR.
31+
* new feature: [WebInterface] html - report table now shows test status and reason
2232

2333
Version 0.6.6 (2016-04-03)
2434
==========================

CONTRIBUTING.rst

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
Contributing to Kitty
2+
=====================
3+
4+
If you look here - thanks!
5+
6+
This document describes the guidelines for contribution for Kitty.
7+
This is not to discourage you from contributing -
8+
we only benefit from contribution.
9+
However, we want to keep Kitty stable, documented and easy to read.
10+
11+
At this point, this guide is rather short, so please read it from start to end.
12+
it will
13+
14+
Code
15+
----
16+
17+
- **Python 3 compatibility**
18+
19+
Kitty is written in Python 2.7, we do plan to add python3 compatibility
20+
at some point, so please make any new addition python 2 and python 3
21+
compatible.
22+
23+
- **Coding conventions**
24+
25+
We do try to make the pass pylint checks (although it is still far from it)
26+
don't make it harder for us, check your code with pylint before you issue
27+
a pull request.
28+
Specifically, you should not have redundant spaces/line breaks in your code,
29+
nor lines longer than 160 characters.
30+
31+
- **Comments**
32+
33+
We do try not to comment the code, in most cases, comments tell us that the
34+
code is not clear enough to begin with.
35+
If this is the case - please refactor your code.
36+
Of course, if the code is unclear but there's no way to make it better,
37+
put a comment there.
38+
39+
- **logging**
40+
41+
There should be no calls to ``print()`` in your code.
42+
Kitty uses python's logging infrastructure,
43+
and every object that derives from ``KittyObject`` have a member ``self.logger``
44+
just for you.
45+
Kitty's default logging level is ``INFO``,
46+
and in this mode there shouldn't be too much logging to the terminal,
47+
Please use the appropriate logger functions.
48+
49+
Tests
50+
-----
51+
52+
We try to keep Kitty tested, tests run on each push and pull request.
53+
The tests are located at the **tests** directory,
54+
and ``python runner.py`` should run all of them.
55+
We have two requests:
56+
57+
- Run the tests before you open a pull requests.
58+
- Add tests for every new module, feature, class or code that you create.
59+
if your pull request is meant to fix a bug in Kitty,
60+
it means that we are missing a test there.
61+
Add such a test with your fix.
62+
- If you create a new test file, add it to the runner,
63+
so it will run with the rest of the tests.
64+
65+
Documentation
66+
-------------
67+
68+
We also try to keep Kitty documented.
69+
We use Sphinx to generate the documentation.
70+
Sphinx generates documentation from both code and documentation files.
71+
So we require a few things in pull requests.
72+
73+
- **Docstrings**
74+
75+
Add docstrings to your code - modules, classes and public methods.
76+
Take a look at other modules (mainly in **kitty/model/low_level**)
77+
to get an idea of how we document the code.
78+
79+
- **New modules**
80+
81+
If you add a new file to kitty, you should:
82+
83+
- Add a class description file to **docs/source**.
84+
Take a look at **kitty.model.low_level.aliases.rst**
85+
as an example.
86+
87+
Your file name should match the ``import`` of this file,
88+
for example,
89+
if you add the file **kitty/model/low_level/mymodule.py**
90+
the documentation file will be called **kitty.model.low_level.mymodule.rst**
91+
92+
- Add this description file to the TOC of the package.
93+
If we keep the example from the last bullet,
94+
Open the file **kitty.model.low_level.rst** and add
95+
the line **kitty.model.low_level.mymodule** to the TOC tree.
96+
97+
- **New features**
98+
99+
If you add a new feature to kitty,
100+
consider adding a more thorough documentation and a tutorial.
101+
Add them to the TOC tree of **index.rst** and **tutorials/index.rst**
102+
(respectively).
103+
104+
105+
That's it, and thanks for your help!

README.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,10 @@ What's Next?
101101

102102
pip install kittyfuzzer
103103

104-
- Read some of the documentation at `ReadTheDocs <https://kitty.readthedocs.org>`_.
104+
- Read some of the documentation at `ReadTheDocs <https://kitty.readthedocs.io>`_.
105105
- Build your fuzzer :-)
106106
- Need some help - ask at our google group: kitty-fuzzer@googlegroups.com
107+
- You can also find us on freenode #kittyfuzzer
107108

108109
Contribution FAQ
109110
----------------
@@ -126,7 +127,7 @@ Contribution FAQ
126127
.. |docs| image:: https://readthedocs.org/projects/kitty/badge/?version=latest
127128
:alt: Documentation Status
128129
:scale: 100%
129-
:target: https://kitty.readthedocs.org/en/latest/?badge=latest
130+
:target: https://kitty.readthedocs.io/en/latest/?badge=latest
130131

131132
.. |travis| image:: https://travis-ci.org/cisco-sas/kitty.svg?branch=master
132133
:alt: Build Status

bin/kitty_template_tester.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,21 @@ def process(self, t):
5050

5151
class TemplateTreePrinter(TemplateProcessor):
5252

53+
def _pad(self):
54+
return ' ' * self.depth
55+
56+
def _print_structure(self, structure):
57+
print('%s%s(name="%s")' % (self._pad(), structure['field_type'], structure['name']))
58+
if 'fields' in structure:
59+
self.depth += 1
60+
for field in structure['fields']:
61+
self._print_structure(field)
62+
self.depth -= 1
63+
5364
def process(self, t):
54-
t.num_mutations()
55-
print(t.get_tree())
65+
self.depth = 0
66+
structure = t.get_structure()
67+
self._print_structure(structure)
5668

5769

5870
class TemplateTester(TemplateProcessor):

bin/kitty_tool.py

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,11 @@
1919
Tools for testing and manipulating kitty templates.
2020
2121
Usage:
22-
kitty-tool generate [--verbose] [-s SKIP] [-c COUNT] [-o OUTDIR] [-f FORMAT] <FILE> <TEMPLATE> ...
22+
kitty-tool generate [options] <FILE> <TEMPLATE> ...
2323
kitty-tool list <FILE>
2424
kitty-tool --version
2525
2626
Commands:
27-
2827
generate generate files with mutated payload
2928
list list templates in a file
3029
@@ -34,6 +33,7 @@
3433
--out -o OUTDIR output directory for the generated mutations [default: out]
3534
--skip -s SKIP how many mutations to skip [default: 0]
3635
--count -c COUNT end index to generate
36+
--path -p FIELDPATH generate mutations only for the field with the given path
3737
--verbose -v verbose output
3838
--filename-format -f FORMAT format for generated file names [default: %(template)s.%(index)s.bin]
3939
--version print version and exit
@@ -114,31 +114,31 @@ def handle(self, template):
114114

115115
class FileGeneratorHandler(Handler):
116116

117-
def __init__(self, outdir, skip, count, template_names, filename_template, logger):
117+
def __init__(self, opts, logger):
118118
super(FileGeneratorHandler, self).__init__(logger)
119-
self.outdir = outdir or 'out'
120-
if skip is not None:
119+
self.outdir = opts['--out'] or 'out'
120+
if opts['--skip'] is not None:
121121
try:
122-
self.skip = int(skip)
122+
self.skip = int(opts['--skip'])
123123
except:
124124
raise Exception('skip should be a number')
125125
else:
126126
self.skip = 0
127-
self.count = count
127+
self.count = opts['--count']
128128
if self.count:
129129
try:
130-
self.count = int(count)
130+
self.count = int(self.count)
131131
except:
132132
raise Exception('count should be a number')
133-
self.template_names = template_names
134-
self.filename_template = filename_template
133+
self.template_names = opts['<TEMPLATE>']
134+
self.filename_format = opts['--filename-format']
135135
try:
136-
self.filename_template % {
136+
self.filename_format % {
137137
'template': 'hello',
138138
'index': 1
139139
}
140140
except:
141-
raise Exception('invalid filename template: %s' % (self.filename_template))
141+
raise Exception('invalid filename template: %s' % (self.filename_format))
142142

143143
def start(self):
144144
if os.path.exists(self.outdir):
@@ -162,7 +162,7 @@ def handle(self, template):
162162
# step = max(step, 2)
163163
max_line_length = 0
164164
while template.mutate():
165-
template_filename = self.filename_template % {'template': template_name, 'index': template._current_index}
165+
template_filename = self.filename_format % {'template': template_name, 'index': template._current_index}
166166
with open(os.path.join(self.outdir, template_filename), 'wb') as f:
167167
f.write(template.render().tobytes())
168168
metadata_filename = template_filename + '.metadata'
@@ -200,11 +200,7 @@ def _main():
200200
file_iter = FileIterator(
201201
opts['<FILE>'],
202202
FileGeneratorHandler(
203-
outdir=opts['--out'],
204-
skip=opts['--skip'],
205-
count=opts['--count'],
206-
template_names=opts['<TEMPLATE>'],
207-
filename_template=opts['--filename-format'],
203+
opts,
208204
logger=logger
209205
),
210206
logger

0 commit comments

Comments
 (0)