def setUp(self):
     self.setUpPyfakefs()
     config = test_helpers.create_run_config(workspace=WORKSPACE,
                                             is_github=False)
     workspace = workspace_utils.Workspace(config)
     self.deployment = clusterfuzz_deployment.get_clusterfuzz_deployment(
         config, workspace)
Exemplo n.º 2
0
    def test_remove_unaffected_fuzz_targets(self, side_effect,
                                            expected_dir_len):
        """Tests that remove_unaffected_fuzzers has the intended effect."""
        config = test_helpers.create_run_config(
            is_github=True,
            oss_fuzz_project_name=EXAMPLE_PROJECT,
            workspace='/workspace')
        workspace = workspace_utils.Workspace(config)
        deployment = clusterfuzz_deployment.get_clusterfuzz_deployment(
            config, workspace)
        # We can't use fakefs in this test because this test executes
        # utils.is_fuzz_target_local. This function relies on the executable bit
        # being set, which doesn't work properly in fakefs.
        with tempfile.TemporaryDirectory() as tmp_dir, mock.patch(
                'get_coverage.OSSFuzzCoverage.get_files_covered_by_target'
        ) as mocked_get_files:
            with mock.patch('get_coverage._get_oss_fuzz_fuzzer_stats_dir_url',
                            return_value=1):
                mocked_get_files.side_effect = side_effect
                shutil.copy(self.TEST_FUZZER_1, tmp_dir)
                shutil.copy(self.TEST_FUZZER_2, tmp_dir)

                affected_fuzz_targets.remove_unaffected_fuzz_targets(
                    deployment, tmp_dir, [EXAMPLE_FILE_CHANGED], '')
                self.assertEqual(expected_dir_len, len(os.listdir(tmp_dir)))
Exemplo n.º 3
0
 def setUp(self):
     self.setUpPyfakefs()
     config = test_helpers.create_run_config(workspace=WORKSPACE,
                                             is_github=False)
     workspace = workspace_utils.Workspace(config)
     self.deployment = clusterfuzz_deployment.get_clusterfuzz_deployment(
         config, workspace)
     self.corpus_dir = os.path.join(workspace.corpora, EXAMPLE_FUZZER)
Exemplo n.º 4
0
 def __init__(self, config):
   self.config = config
   self.clusterfuzz_deployment = (
       clusterfuzz_deployment.get_clusterfuzz_deployment(self.config))
   # Set by the initialize method.
   self.out_dir = None
   self.fuzz_target_paths = None
   self.crashes_dir = None
Exemplo n.º 5
0
 def setUp(self):
     self.setUpPyfakefs()
     config = test_helpers.create_run_config(build_integration_path='/',
                                             workspace=WORKSPACE,
                                             is_github=False)
     workspace = config_utils.Workspace(config)
     self.deployment = clusterfuzz_deployment.get_clusterfuzz_deployment(
         config, workspace)
Exemplo n.º 6
0
 def setUp(self):
     self.setUpPyfakefs()
     config = test_helpers.create_run_config(project_name=EXAMPLE_PROJECT,
                                             build_integration_path='/',
                                             workspace=WORKSPACE,
                                             is_github=False)
     workspace = docker.Workspace(config)
     self.deployment = clusterfuzz_deployment.get_clusterfuzz_deployment(
         config, workspace)
Exemplo n.º 7
0
  def __init__(self, config):
    self.config = config
    self.workspace = config_utils.Workspace(config)
    self.clusterfuzz_deployment = (
        clusterfuzz_deployment.get_clusterfuzz_deployment(
            self.config, self.workspace))

    # Set by the initialize method.
    self.fuzz_target_paths = None
Exemplo n.º 8
0
    def setUp(self):
        self.setUpPyfakefs()
        config = test_helpers.create_run_config(workspace=WORKSPACE,
                                                cfl_platform='other',
                                                filestore='no_filestore',
                                                no_clusterfuzz_deployment=True)
        workspace = workspace_utils.Workspace(config)
        self.deployment = clusterfuzz_deployment.get_clusterfuzz_deployment(
            config, workspace)

        self.corpus_dir = os.path.join(workspace.corpora, EXAMPLE_FUZZER)
Exemplo n.º 9
0
 def __init__(self, config, ci_system):
     self.config = config
     self.ci_system = ci_system
     self.workspace = workspace_utils.Workspace(config)
     self.workspace.initialize_dir(self.workspace.out)
     self.workspace.initialize_dir(self.workspace.work)
     self.clusterfuzz_deployment = (
         clusterfuzz_deployment.get_clusterfuzz_deployment(
             self.config, self.workspace))
     self.image_repo_path = None
     self.host_repo_path = None
     self.repo_manager = None
Exemplo n.º 10
0
  def test_get_clusterfuzz_deployment(self, platform, expected_deployment_cls):
    """Tests that get_clusterfuzz_deployment returns the correct value."""
    with mock.patch('config_utils.BaseConfig.platform',
                    return_value=platform,
                    new_callable=mock.PropertyMock):
      with mock.patch('filestore_utils.get_filestore', return_value=None):
        config = _create_config()
        workspace = workspace_utils.Workspace(config)

        self.assertIsInstance(
            clusterfuzz_deployment.get_clusterfuzz_deployment(
                config, workspace), expected_deployment_cls)
Exemplo n.º 11
0
def _create_deployment(**kwargs):
    config = _create_config(**kwargs)
    workspace = workspace_utils.Workspace(config)
    return clusterfuzz_deployment.get_clusterfuzz_deployment(config, workspace)
Exemplo n.º 12
0
def _create_deployment(**kwargs):
  config = _create_config(**kwargs)
  return clusterfuzz_deployment.get_clusterfuzz_deployment(config)