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

Commit dc4d6ac

Browse files
committed
Fixed a bug in afl-sync that caused some directories to not be pulled
from the remote location when a session name was specified. Added afl's .cur_input to the rsync exclude list in afl-sync.
1 parent 5136465 commit dc4d6ac

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

afl_utils/afl_sync.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ def __init__(self, server_config, fuzzer_config):
3232

3333

3434
class AflRsync(AflBaseSync):
35+
def __init__(self, server_config, fuzzer_config):
36+
# default excludes
37+
self.__excludes = ['*.cur_input']
38+
super(AflRsync, self).__init__(server_config, fuzzer_config)
39+
3540
def __prepare_rsync_commandline(self, local_path, remote_path, rsync_options=list(_rsync_default_options),
3641
rsync_excludes=list([]), rsync_get=False):
3742
cmd = ['rsync']
@@ -76,7 +81,7 @@ def push(self):
7681
if self.fuzzer_config['session'] is not None:
7782
fuzzers = (fuzzer for fuzzer in fuzzers if fuzzer.startswith(self.fuzzer_config['session']))
7883

79-
excludes = []
84+
excludes = self.__excludes
8085

8186
if self.fuzzer_config['exclude_crashes']:
8287
excludes += ['crashes*/']
@@ -97,7 +102,7 @@ def pull(self):
97102
remote_path = self.server_config['remote_path']
98103

99104
options = list(_rsync_default_options)
100-
excludes = []
105+
excludes = self.__excludes
101106

102107
# exclude our previously pushed fuzzer states from being pulled again
103108
# and avoid to overwrite our local fuzz data
@@ -106,7 +111,13 @@ def pull(self):
106111

107112
# restrict to certain session, if requested
108113
if self.fuzzer_config['session'] is not None:
114+
# make sure defaults are excluded from explicitly included locations
115+
for exclude_rule in self.__excludes:
116+
options += ['--exclude=\"/{}*/{}\"'.format(self.fuzzer_config['session'], exclude_rule)]
117+
# recursively include everything that does match the session name
109118
options += ['--include=\"/{}*/\"'.format(self.fuzzer_config['session'])]
119+
options += ['--include=\"/{}*/*\"'.format(self.fuzzer_config['session'])]
120+
# exclude everything else
110121
excludes += ['*']
111122

112123
print_ok('Pulling {}/* <- {}/'.format(local_path, remote_path))

docs/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ Version 1.30a
55
- Parsing of slightly different modified 'fuzzer_stats' file fixed
66
in afl-stats.
77
- Delayed startup added to afl-multicore.
8+
- Fixed a bug in afl-sync that caused some directories to not be pulled
9+
from the remote location when a session name was specified.
10+
- Added afl's .cur_input to the rsync exclude list in afl-sync.
811

912
Version 1.29a
1013

tests/test_afl_sync.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ def setUp(self):
1313
os.makedirs('testdata/rsync_tmp_store', exist_ok=True)
1414
os.makedirs('testdata/sync/fuzz000/crashes', exist_ok=True)
1515
os.makedirs('testdata/sync/fuzz000/hangs', exist_ok=True)
16+
os.makedirs('testdata/sync/fuzz000/.cur_input', exist_ok=True)
17+
os.makedirs('testdata/sync/fuzz001/.cur_input', exist_ok=True)
1618
os.makedirs('testdata/sync/fuzz002.sync', exist_ok=True)
1719
os.makedirs('testdata/sync/invalid_fuzz000', exist_ok=True)
1820
os.makedirs('testdata/sync/invalid_fuzz001', exist_ok=True)
@@ -22,7 +24,10 @@ def setUp(self):
2224
os.makedirs('testdata/rsync_output_pull/fuzz000.sync', exist_ok=True)
2325
os.makedirs('testdata/rsync_output_pull/fuzz001.sync', exist_ok=True)
2426
os.makedirs('testdata/rsync_output_pull/other_fuzz000.sync', exist_ok=True)
27+
os.makedirs('testdata/rsync_output_pull/other_fuzz000.sync/.cur_input', exist_ok=True)
28+
os.makedirs('testdata/rsync_output_pull/other_fuzz000.sync/crashes', exist_ok=True)
2529
os.makedirs('testdata/rsync_output_pull/other_fuzz001.sync', exist_ok=True)
30+
os.makedirs('testdata/rsync_output_pull/other_fuzz001.sync/.cur_input', exist_ok=True)
2631
os.makedirs('testdata/rsync_output_pull/other_invalid_fuzz000.sync', exist_ok=True)
2732
# sync
2833
os.makedirs('testdata/rsync_output_sync/other_fuzz000.sync', exist_ok=True)
@@ -34,6 +39,8 @@ def tearDown(self):
3439
self.clean_remove_dir('testdata/rsync_tmp_store')
3540
self.clean_remove_dir('testdata/sync/fuzz000/crashes')
3641
self.clean_remove_dir('testdata/sync/fuzz000/hangs')
42+
self.clean_remove_dir('testdata/sync/fuzz000/.cur_input')
43+
self.clean_remove_dir('testdata/sync/fuzz001/.cur_input')
3744
self.clean_remove_dir('testdata/sync/fuzz002.sync')
3845
self.clean_remove_dir('testdata/sync/invalid_fuzz000')
3946
self.clean_remove_dir('testdata/sync/invalid_fuzz001')
@@ -134,6 +141,7 @@ def test_afl_rsync_put(self):
134141
afl_rsync = AflRsync(None, None)
135142
self.assertTrue(afl_rsync.rsync_put(local_path, remote_path, rsync_excludes=excludes))
136143
self.assertTrue(os.path.exists(remote_path + '.sync/fuzzer_stats'))
144+
self.assertTrue(os.path.exists(remote_path + '.sync/.cur_input'))
137145
self.assertFalse(os.path.exists(remote_path + '.sync/crashes'))
138146
self.assertFalse(os.path.exists(remote_path + '.sync/hangs'))
139147

@@ -163,7 +171,9 @@ def test_afl_rsync_push(self):
163171
afl_rsync = AflRsync(server_config, fuzzer_config)
164172
self.assertIsNone(afl_rsync.push())
165173
self.assertTrue(os.path.exists('testdata/rsync_output_push/fuzz000.sync'))
174+
self.assertFalse(os.path.exists('testdata/rsync_output_push/fuzz000.sync/.cur_input'))
166175
self.assertTrue(os.path.exists('testdata/rsync_output_push/fuzz001.sync'))
176+
self.assertFalse(os.path.exists('testdata/rsync_output_push/fuzz000.sync/.cur_input'))
167177
self.assertFalse(os.path.exists('testdata/rsync_output_push/fuzz002.sync'))
168178
self.assertFalse(os.path.exists('testdata/rsync_output_push/fuzz002.sync.sync'))
169179
self.assertFalse(os.path.exists('testdata/rsync_output_push/invalid_fuzz000.sync'))
@@ -184,7 +194,10 @@ def test_afl_rsync_pull_session(self):
184194
afl_rsync = AflRsync(server_config, fuzzer_config)
185195
self.assertIsNone(afl_rsync.pull())
186196
self.assertTrue(os.path.exists('testdata/sync/other_fuzz000.sync'))
197+
self.assertTrue(os.path.exists('testdata/sync/other_fuzz000.sync/crashes'))
198+
self.assertFalse(os.path.exists('testdata/sync/other_fuzz000.sync/.cur_input'))
187199
self.assertTrue(os.path.exists('testdata/sync/other_fuzz001.sync'))
200+
self.assertFalse(os.path.exists('testdata/sync/other_fuzz001.sync/.cur_input'))
188201
self.assertFalse(os.path.exists('testdata/sync/other_invalid_fuzz000.sync'))
189202
self.assertFalse(os.path.exists('testdata/sync/fuzz000.sync'))
190203
self.assertFalse(os.path.exists('testdata/sync/fuzz001.sync'))
@@ -205,6 +218,8 @@ def test_afl_rsync_pull_all(self):
205218
self.assertIsNone(afl_rsync.pull())
206219
self.assertTrue(os.path.exists('testdata/sync/other_fuzz000.sync'))
207220
self.assertTrue(os.path.exists('testdata/sync/other_fuzz001.sync'))
221+
self.assertFalse(os.path.exists('testdata/sync/other_fuzz000.sync/.cur_input'))
222+
self.assertFalse(os.path.exists('testdata/sync/other_fuzz001.sync/.cur_input'))
208223
self.assertTrue(os.path.exists('testdata/sync/other_invalid_fuzz000.sync'))
209224
self.assertFalse(os.path.exists('testdata/sync/fuzz000.sync'))
210225
self.assertFalse(os.path.exists('testdata/sync/fuzz001.sync'))

0 commit comments

Comments
 (0)