Skip to content
This repository has been archived by the owner on Jun 7, 2018. It is now read-only.

Commit

Permalink
afl-collect tests improved. Changelog updated.
Browse files Browse the repository at this point in the history
  • Loading branch information
rc0r committed Apr 13, 2016
1 parent e21da7e commit 6dede11
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 9 deletions.
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# afl-utils Changelog

Version 1.27a

- Basic version of afl-sync added.

Version 1.26a

- afl-minimize now supports reseeding original afl queues with an optimized
Expand Down
2 changes: 1 addition & 1 deletion docs/TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ provide appropriate test cases for it!
# Feature Ideas / ToDo

- [ ] implement configurable timeout for afl-collect, afl-minimize (like `-t` flag in `afl-vcrash`)
- [ ] increase test coverage
- [x] increase test coverage
- [x] submit classification data into some sort of database
- [x] basic sqlite3 database support added
- [ ] want more db connectors? Drop me a line!
Expand Down
1 change: 1 addition & 0 deletions testdata/collection/dummy_sample3
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nullptr_read
1 change: 1 addition & 0 deletions testdata/collection/dummy_sample4
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nullptr_write
10 changes: 10 additions & 0 deletions testdata/crash_process/crash.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ int main(int argc, char *argv[])
char str[1024];
gets(str);

if(strstr(str, "nullptr_read")) {
char *nullptr = NULL;
printf("%s\n", nullptr);
}

if(strstr(str, "nullptr_write")) {
char *nullptr = NULL;
strcpy(nullptr, str);
}

if(strlen(str) > 100) {
while(1);
}
Expand Down
1 change: 1 addition & 0 deletions testdata/queue/sample3
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nullptr_read
1 change: 1 addition & 0 deletions testdata/queue/sample4
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nullptr_write
28 changes: 22 additions & 6 deletions tests/test_afl_collect.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,23 @@ def test_get_queue_directories(self):

def test_get_samples_from_dir(self):
sample_dir = 'testdata/queue'
expected_result = (3, [
expected_result = (5, [
'sample0',
'sample1',
'sample2'
'sample2',
'sample3',
'sample4'
])
result = afl_collect.get_samples_from_dir(sample_dir)
self.assertEqual(expected_result[0], result[0])
self.assertListEqual(expected_result[1], sorted(result[1]))

expected_result = (3, [
expected_result = (5, [
os.path.join(sample_dir, 'sample0'),
os.path.join(sample_dir, 'sample1'),
os.path.join(sample_dir, 'sample2'),
os.path.join(sample_dir, 'sample3'),
os.path.join(sample_dir, 'sample4'),
])
result = afl_collect.get_samples_from_dir(sample_dir, abs_path=True)
self.assertEqual(expected_result[0], result[0])
Expand All @@ -126,19 +130,23 @@ def test_collect_samples(self):
('fuzz000', ['queue']),
('fuzz001', ['queue'])
]
expected_result = (6, [
expected_result = (10, [
('fuzz000', [
('queue', [
'sample0',
'sample1',
'sample2'
'sample2',
'sample3',
'sample4'
]
)]),
('fuzz001', [
('queue', [
'sample0',
'sample1',
'sample2'
'sample2',
'sample3',
'sample4'
]
)])
])
Expand All @@ -160,12 +168,20 @@ def test_build_sample_index(self):
'output': 'fuzz000:sample1'},
{'input': os.path.abspath('testdata/sync/fuzz000/queue/sample2'), 'fuzzer': 'fuzz000',
'output': 'fuzz000:sample2'},
{'input': os.path.abspath('testdata/sync/fuzz000/queue/sample3'), 'fuzzer': 'fuzz000',
'output': 'fuzz000:sample3'},
{'input': os.path.abspath('testdata/sync/fuzz000/queue/sample4'), 'fuzzer': 'fuzz000',
'output': 'fuzz000:sample4'},
{'input': os.path.abspath('testdata/sync/fuzz001/queue/sample0'), 'fuzzer': 'fuzz001',
'output': 'fuzz001:sample0'},
{'input': os.path.abspath('testdata/sync/fuzz001/queue/sample1'), 'fuzzer': 'fuzz001',
'output': 'fuzz001:sample1'},
{'input': os.path.abspath('testdata/sync/fuzz001/queue/sample2'), 'fuzzer': 'fuzz001',
'output': 'fuzz001:sample2'},
{'input': os.path.abspath('testdata/sync/fuzz001/queue/sample3'), 'fuzzer': 'fuzz001',
'output': 'fuzz001:sample3'},
{'input': os.path.abspath('testdata/sync/fuzz001/queue/sample4'), 'fuzzer': 'fuzz001',
'output': 'fuzz001:sample4'},
]
result = afl_collect.build_sample_index(sync_dir, out_dir, fuzzer_inst)
self.assertListEqual(expected_index, result.index)
Expand Down
8 changes: 6 additions & 2 deletions tests/test_afl_minimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,18 @@ def test_afl_reseed(self):
'.state',
'sample0',
'sample1',
'sample2'
'sample2',
'sample3',
'sample4'
]

queue_ls = [
'.state',
'dummy_sample0',
'dummy_sample1',
'dummy_sample2'
'dummy_sample2',
'dummy_sample3',
'dummy_sample4'
]

self.assertListEqual(dir_ls, sorted(os.listdir(os.path.join(test_sync_dir, 'fuzz000'))))
Expand Down

0 comments on commit 6dede11

Please sign in to comment.