Example #1
0
    def test_afl_rsync_pull_all(self):
        server_config = {
            'remote_path': 'testdata/rsync_output_pull',
        }

        fuzzer_config = {
            'sync_dir': 'testdata/sync',
            'session': None,
            'exclude_crashes': True,
            'exclude_hangs': True,
        }

        afl_rsync = AflRsync(server_config, fuzzer_config)
        self.assertIsNone(afl_rsync.pull())
        self.assertTrue(os.path.exists('testdata/sync/other_fuzz000.sync'))
        self.assertTrue(os.path.exists('testdata/sync/other_fuzz001.sync'))
        self.assertTrue(
            os.path.exists('testdata/sync/other_invalid_fuzz000.sync'))
        self.assertFalse(os.path.exists('testdata/sync/fuzz000.sync'))
        self.assertFalse(os.path.exists('testdata/sync/fuzz001.sync'))
Example #2
0
    def test_afl_rsync_put(self):
        local_path = 'testdata/sync/fuzz000'
        remote_path = 'testdata/rsync_tmp_store/fuzz000'
        excludes = ['crashes*/', 'hangs*/']

        rsync_config = {
            'get': afl_sync._rsync_default_options[:],
            'put': afl_sync._rsync_default_options[:],
        }

        afl_rsync = AflRsync(None, None, rsync_config)
        self.assertTrue(
            afl_rsync.rsync_put(local_path,
                                remote_path,
                                afl_rsync.rsync_config['put'],
                                rsync_excludes=excludes))
        self.assertTrue(os.path.exists(remote_path + '.sync/fuzzer_stats'))
        self.assertTrue(os.path.exists(remote_path + '.sync/.cur_input'))
        self.assertFalse(os.path.exists(remote_path + '.sync/crashes'))
        self.assertFalse(os.path.exists(remote_path + '.sync/hangs'))
Example #3
0
    def test_afl_rsync_sync(self):
        server_config = {
            'remote_path': 'testdata/rsync_output_sync',
        }

        fuzzer_config = {
            'sync_dir': 'testdata/sync',
            'session': None,
            'exclude_crashes': True,
            'exclude_hangs': True,
        }

        rsync_config = {
            'get': afl_sync._rsync_default_options[:],
            'put': afl_sync._rsync_default_options[:],
        }

        afl_rsync = AflRsync(server_config, fuzzer_config, rsync_config)
        self.assertIsNone(afl_rsync.sync())

        # pull assertions
        self.assertTrue(os.path.exists('testdata/sync/other_fuzz000.sync'))
        self.assertTrue(os.path.exists('testdata/sync/other_fuzz001.sync'))
        self.assertTrue(
            os.path.exists('testdata/sync/other_invalid_fuzz000.sync'))
        self.assertFalse(os.path.exists('testdata/sync/fuzz000.sync'))
        self.assertFalse(os.path.exists('testdata/sync/fuzz001.sync'))

        # push assertions
        self.assertTrue(
            os.path.exists('testdata/rsync_output_sync/fuzz000.sync'))
        self.assertTrue(
            os.path.exists('testdata/rsync_output_sync/fuzz001.sync'))
        self.assertFalse(
            os.path.exists('testdata/rsync_output_sync/fuzz002.sync'))
        self.assertFalse(
            os.path.exists('testdata/rsync_output_sync/fuzz002.sync.sync'))
        self.assertTrue(
            os.path.exists('testdata/rsync_output_sync/invalid_fuzz000.sync'))
        self.assertTrue(
            os.path.exists('testdata/rsync_output_sync/invalid_fuzz001.sync'))
Example #4
0
    def test_afl_rsync_prepare_sync_command(self):
        afl_rsync = AflRsync(None, None)

        expected_put_cmdline = [
            'rsync', afl_sync._rsync_default_options[0],
            '--exclude=\"exclude\"', 'src/', 'dst.sync/'
        ]

        expected_get_cmdline = [
            'rsync', afl_sync._rsync_default_options[0],
            '--exclude=\"exclude\"', 'dst/*', 'src/'
        ]

        self.assertListEqual(
            expected_put_cmdline,
            afl_rsync._AflRsync__prepare_rsync_commandline(
                'src', 'dst', rsync_excludes=['exclude']))
        self.assertListEqual(
            expected_get_cmdline,
            afl_rsync._AflRsync__prepare_rsync_commandline(
                'src', 'dst', rsync_excludes=['exclude'], rsync_get=True))
Example #5
0
    def test_afl_rsync_init(self):
        server_config = {
            'remote_path': 'testdata/rsync_output',
        }

        fuzzer_config = {
            'sync_dir': 'testdata/sync',
            'session': 'fuzz',
            'exclude_crashes': True,
            'exclude_hangs': True,
        }

        rsync_config = {
            'get': afl_sync._rsync_default_options[:],
            'put': afl_sync._rsync_default_options[:],
        }

        afl_rsync = AflRsync(server_config, fuzzer_config, rsync_config)

        self.assertDictEqual(server_config, afl_rsync.server_config)
        self.assertDictEqual(fuzzer_config, afl_rsync.fuzzer_config)
        self.assertDictEqual(rsync_config, afl_rsync.rsync_config)
Example #6
0
    def test_afl_rsync_invoke_rsync(self):
        rsync_cmdline = ['rsync', '--help']
        afl_rsync = AflRsync(None, None)

        self.assertTrue(afl_rsync._AflRsync__invoke_rsync(rsync_cmdline))
        self.assertFalse(afl_rsync._AflRsync__invoke_rsync(['rsync']))