Ejemplo n.º 1
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))
Ejemplo n.º 2
0
    def test_afl_rsync_push(self):
        server_config = {
            'remote_path': 'testdata/rsync_output_push',
        }

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

        afl_rsync = AflRsync(server_config, fuzzer_config)
        self.assertIsNone(afl_rsync.push())
        self.assertTrue(
            os.path.exists('testdata/rsync_output_push/fuzz000.sync'))
        self.assertTrue(
            os.path.exists('testdata/rsync_output_push/fuzz001.sync'))
        self.assertFalse(
            os.path.exists('testdata/rsync_output_push/fuzz002.sync'))
        self.assertFalse(
            os.path.exists('testdata/rsync_output_push/fuzz002.sync.sync'))
        self.assertFalse(
            os.path.exists('testdata/rsync_output_push/invalid_fuzz000.sync'))
        self.assertFalse(
            os.path.exists('testdata/rsync_output_push/invalid_fuzz001.sync'))
Ejemplo n.º 3
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,
        }

        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.pull())
        self.assertTrue(os.path.exists('testdata/sync/other_fuzz000.sync'))
        self.assertTrue(os.path.exists('testdata/sync/other_fuzz001.sync'))
        self.assertFalse(
            os.path.exists('testdata/sync/other_fuzz000.sync/.cur_input'))
        self.assertFalse(
            os.path.exists('testdata/sync/other_fuzz001.sync/.cur_input'))
        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'))
Ejemplo n.º 4
0
    def test_afl_rsync_prepare_sync_command(self):
        afl_rsync = AflRsync(None, 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',
                list(afl_sync._rsync_default_options),
                rsync_excludes=['exclude']))
        self.assertListEqual(
            expected_get_cmdline,
            afl_rsync._AflRsync__prepare_rsync_commandline(
                'src',
                'dst',
                list(afl_sync._rsync_default_options),
                rsync_excludes=['exclude'],
                rsync_get=True))
Ejemplo n.º 5
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,
        }

        afl_rsync = AflRsync(server_config, fuzzer_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'))
Ejemplo n.º 6
0
    def test_afl_rsync_get(self):
        local_path = 'testdata/rsync_tmp_store/fuzz000_get'
        remote_path = 'testdata/sync/fuzz000'
        excludes = ['crashes*/', 'hangs*/']

        afl_rsync = AflRsync(None, None)
        self.assertTrue(afl_rsync.rsync_get(remote_path, local_path, rsync_excludes=excludes))
        self.assertTrue(os.path.exists(local_path + '/fuzzer_stats'))
        self.assertFalse(os.path.exists(local_path + '/crashes'))
        self.assertFalse(os.path.exists(local_path + '/hangs'))
Ejemplo n.º 7
0
    def test_afl_rsync_get(self):
        local_path = 'testdata/rsync_tmp_store/fuzz000_get'
        remote_path = 'testdata/sync/fuzz000'
        excludes = ['crashes*/', 'hangs*/']

        afl_rsync = AflRsync(None, None)
        self.assertTrue(
            afl_rsync.rsync_get(remote_path,
                                local_path,
                                rsync_excludes=excludes))
        self.assertTrue(os.path.exists(local_path + '/fuzzer_stats'))
        self.assertFalse(os.path.exists(local_path + '/crashes'))
        self.assertFalse(os.path.exists(local_path + '/hangs'))
Ejemplo n.º 8
0
    def test_afl_rsync_get_fuzzers(self):
        fuzzer_config = {
            'sync_dir': 'testdata/sync',
            'session': 'fuzz',
            'exclude_crashes': True,
            'exclude_hangs': True,
        }

        expected_fuzzers = [
            'fuzz000', 'fuzz001', 'invalid_fuzz000', 'invalid_fuzz001'
        ]

        afl_rsync = AflRsync(None, fuzzer_config)
        self.assertListEqual(sorted(expected_fuzzers),
                             sorted(afl_rsync._AflRsync__get_fuzzers()))
Ejemplo n.º 9
0
    def test_afl_rsync_get_fuzzers(self):
        fuzzer_config = {
            'sync_dir': 'testdata/sync',
            'session': 'fuzz',
            'exclude_crashes': True,
            'exclude_hangs': True,
        }

        expected_fuzzers = [
            'fuzz000',
            'fuzz001',
            'invalid_fuzz000',
            'invalid_fuzz001'
        ]

        afl_rsync = AflRsync(None, fuzzer_config)
        self.assertListEqual(sorted(expected_fuzzers), sorted(afl_rsync._AflRsync__get_fuzzers()))
Ejemplo n.º 10
0
    def test_afl_rsync_get(self):
        local_path = 'testdata/rsync_tmp_store/fuzz000_get'
        remote_path = 'testdata/sync/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_get(remote_path,
                                local_path,
                                afl_rsync.rsync_config['get'],
                                rsync_excludes=excludes))
        self.assertTrue(os.path.exists(local_path + '/fuzzer_stats'))
        self.assertFalse(os.path.exists(local_path + '/crashes'))
        self.assertFalse(os.path.exists(local_path + '/hangs'))
Ejemplo n.º 11
0
    def test_afl_rsync_pull_session(self):
        server_config = {
            'remote_path': 'testdata/rsync_output_pull',
        }

        fuzzer_config = {
            'sync_dir': 'testdata/sync',
            'session': 'other_fuzz',
            '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_fuzz000.sync/crashes'))
        self.assertFalse(os.path.exists('testdata/sync/other_fuzz000.sync/.cur_input'))
        self.assertTrue(os.path.exists('testdata/sync/other_fuzz001.sync'))
        self.assertFalse(os.path.exists('testdata/sync/other_fuzz001.sync/.cur_input'))
        self.assertFalse(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'))
Ejemplo n.º 12
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,
        }

        afl_rsync = AflRsync(server_config, fuzzer_config)

        self.assertDictEqual(server_config, afl_rsync.server_config)
        self.assertDictEqual(fuzzer_config, afl_rsync.fuzzer_config)
Ejemplo n.º 13
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']))
Ejemplo n.º 14
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']))