diff options
author | Oliver Chang <oliverchang@users.noreply.github.com> | 2021-07-21 15:32:32 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-21 05:32:32 +0000 |
commit | c7cab23c207288caa107a5cc6bb33f715929ecb6 (patch) | |
tree | 43b09b3f42d6eb8d337341a26fa605ab74d37d6d /infra/cifuzz | |
parent | 857e9c27d02213050af6ebd263ac8726bfecc7d5 (diff) | |
download | oss-fuzz-c7cab23c207288caa107a5cc6bb33f715929ecb6.tar.gz |
Make oss-fuzz-project-name optional. (#6071)
Also rename code uses from `project_name` to `oss_fuzz_project_name`, to
be more explicit, and use it to determine whether or not we're running
an OSS-Fuzz project or not.
For external fuzzing #6051.
Diffstat (limited to 'infra/cifuzz')
-rw-r--r-- | infra/cifuzz/actions/run_fuzzers/action.yml | 3 | ||||
-rw-r--r-- | infra/cifuzz/affected_fuzz_targets.py | 1 | ||||
-rw-r--r-- | infra/cifuzz/affected_fuzz_targets_test.py | 7 | ||||
-rw-r--r-- | infra/cifuzz/build_fuzzers.py | 2 | ||||
-rw-r--r-- | infra/cifuzz/build_fuzzers_entrypoint.py | 5 | ||||
-rw-r--r-- | infra/cifuzz/build_fuzzers_test.py | 79 | ||||
-rw-r--r-- | infra/cifuzz/clusterfuzz_deployment.py | 20 | ||||
-rw-r--r-- | infra/cifuzz/clusterfuzz_deployment_test.py | 9 | ||||
-rw-r--r-- | infra/cifuzz/config_utils.py | 12 | ||||
-rw-r--r-- | infra/cifuzz/continuous_integration.py | 31 | ||||
-rw-r--r-- | infra/cifuzz/docker.py | 8 | ||||
-rw-r--r-- | infra/cifuzz/fuzz_target_test.py | 2 | ||||
-rw-r--r-- | infra/cifuzz/generate_coverage_report_test.py | 2 | ||||
-rw-r--r-- | infra/cifuzz/run_fuzzers_entrypoint.py | 2 | ||||
-rw-r--r-- | infra/cifuzz/run_fuzzers_test.py | 42 |
15 files changed, 120 insertions, 105 deletions
diff --git a/infra/cifuzz/actions/run_fuzzers/action.yml b/infra/cifuzz/actions/run_fuzzers/action.yml index da9022214..653beabd1 100644 --- a/infra/cifuzz/actions/run_fuzzers/action.yml +++ b/infra/cifuzz/actions/run_fuzzers/action.yml @@ -48,9 +48,6 @@ runs: DRY_RUN: ${{ inputs.dry-run}} SANITIZER: ${{ inputs.sanitizer }} RUN_FUZZERS_MODE: ${{ inputs.run-fuzzers-mode }} - # TODO(metzman): Even though this param is used for building, it's needed - # for running because we use it to distinguish OSS-Fuzz from non-OSS-Fuzz. - # We should do something explicit instead. BUILD_INTEGRATION_PATH: ${{ inputs.build-integration-path }} GITHUB_TOKEN: ${{ inputs.github-token }} LOW_DISK_SPACE: 'True' diff --git a/infra/cifuzz/affected_fuzz_targets.py b/infra/cifuzz/affected_fuzz_targets.py index 959170c3c..22924bbc8 100644 --- a/infra/cifuzz/affected_fuzz_targets.py +++ b/infra/cifuzz/affected_fuzz_targets.py @@ -27,7 +27,6 @@ def remove_unaffected_fuzz_targets(clusterfuzz_deployment, out_dir, """Removes all non affected fuzz targets in the out directory. Args: - project_name: The name of the relevant OSS-Fuzz project. out_dir: The location of the fuzz target binaries. files_changed: A list of files changed compared to HEAD. repo_path: The location of the OSS-Fuzz repo in the docker image. diff --git a/infra/cifuzz/affected_fuzz_targets_test.py b/infra/cifuzz/affected_fuzz_targets_test.py index c32c27776..d5e948a62 100644 --- a/infra/cifuzz/affected_fuzz_targets_test.py +++ b/infra/cifuzz/affected_fuzz_targets_test.py @@ -60,9 +60,10 @@ class RemoveUnaffectedFuzzTargets(unittest.TestCase): # yapf: enable 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, - project_name=EXAMPLE_PROJECT, - workspace='/workspace') + config = test_helpers.create_run_config( + is_github=True, + oss_fuzz_project_name=EXAMPLE_PROJECT, + workspace='/workspace') workspace = docker.Workspace(config) deployment = clusterfuzz_deployment.get_clusterfuzz_deployment( config, workspace) diff --git a/infra/cifuzz/build_fuzzers.py b/infra/cifuzz/build_fuzzers.py index 931784a21..892d51abd 100644 --- a/infra/cifuzz/build_fuzzers.py +++ b/infra/cifuzz/build_fuzzers.py @@ -89,7 +89,7 @@ class Builder: # pylint: disable=too-many-instance-attributes self.handle_msan_prebuild(docker_container) docker_args.extend([ - docker.get_project_image_name(self.config.project_name), + docker.get_project_image_name(self.config.oss_fuzz_project_name), '/bin/bash', '-c', ]) diff --git a/infra/cifuzz/build_fuzzers_entrypoint.py b/infra/cifuzz/build_fuzzers_entrypoint.py index 024ac60b5..505a37415 100644 --- a/infra/cifuzz/build_fuzzers_entrypoint.py +++ b/infra/cifuzz/build_fuzzers_entrypoint.py @@ -44,9 +44,8 @@ def build_fuzzers_entrypoint(): return returncode if not build_fuzzers.build_fuzzers(config): - logging.error( - 'Error building fuzzers for project %s (commit: %s, pr_ref: %s).', - config.project_name, config.commit_sha, config.pr_ref) + logging.error('Error building fuzzers for (commit: %s, pr_ref: %s).', + config.commit_sha, config.pr_ref) return returncode if not config.bad_build_check: diff --git a/infra/cifuzz/build_fuzzers_test.py b/infra/cifuzz/build_fuzzers_test.py index b88552301..570a7015e 100644 --- a/infra/cifuzz/build_fuzzers_test.py +++ b/infra/cifuzz/build_fuzzers_test.py @@ -69,10 +69,11 @@ class BuildFuzzersTest(unittest.TestCase): with tempfile.TemporaryDirectory() as tmp_dir: build_fuzzers.build_fuzzers( - test_helpers.create_build_config(project_name=EXAMPLE_PROJECT, - project_repo_name=EXAMPLE_PROJECT, - workspace=tmp_dir, - pr_ref='refs/pull/1757/merge')) + test_helpers.create_build_config( + oss_fuzz_project_name=EXAMPLE_PROJECT, + project_repo_name=EXAMPLE_PROJECT, + workspace=tmp_dir, + pr_ref='refs/pull/1757/merge')) docker_run_command = mocked_docker_run.call_args_list[0][0][0] @@ -99,7 +100,7 @@ class InternalGithubBuildTest(unittest.TestCase): def _create_builder(self, tmp_dir): """Creates an InternalGithubBuilder and returns it.""" config = test_helpers.create_build_config( - project_name=self.PROJECT_NAME, + oss_fuzz_project_name=self.PROJECT_NAME, project_repo_name=self.PROJECT_REPO_NAME, workspace=tmp_dir, sanitizer=self.SANITIZER, @@ -144,14 +145,13 @@ class BuildFuzzersIntegrationTest(unittest.TestCase): def test_external_github_project(self): """Tests building fuzzers from an external project on Github.""" - project_name = 'external-project' + oss_fuzz_project_name = 'external-project' build_integration_path = 'fuzzer-build-integration' git_url = 'https://github.com/jonathanmetzman/cifuzz-external-example.git' # This test is dependant on the state of # github.com/jonathanmetzman/cifuzz-external-example. config = test_helpers.create_build_config( - project_name=project_name, - project_repo_name=project_name, + project_repo_name=oss_fuzz_project_name, workspace=self.workspace, build_integration_path=build_integration_path, git_url=git_url, @@ -164,7 +164,7 @@ class BuildFuzzersIntegrationTest(unittest.TestCase): def test_external_generic_project(self): """Tests building fuzzers from an external project not on Github.""" - project_name = 'cifuzz-external-example' + oss_fuzz_project_name = 'cifuzz-external-example' build_integration_path = 'fuzzer-build-integration' git_url = 'https://github.com/jonathanmetzman/cifuzz-external-example.git' # This test is dependant on the state of @@ -174,8 +174,7 @@ class BuildFuzzersIntegrationTest(unittest.TestCase): self.tmp_dir_obj.name) project_src_path = manager.repo_dir config = test_helpers.create_build_config( - project_name=project_name, - project_repo_name=project_name, + project_repo_name=oss_fuzz_project_name, workspace=self.workspace, build_integration_path=build_integration_path, git_url=git_url, @@ -189,7 +188,7 @@ class BuildFuzzersIntegrationTest(unittest.TestCase): def test_valid_commit(self): """Tests building fuzzers with valid inputs.""" config = test_helpers.create_build_config( - project_name=EXAMPLE_PROJECT, + oss_fuzz_project_name=EXAMPLE_PROJECT, project_repo_name='oss-fuzz', workspace=self.workspace, commit_sha='0b95fe1039ed7c38fea1f97078316bfc1030c523', @@ -202,30 +201,32 @@ class BuildFuzzersIntegrationTest(unittest.TestCase): def test_valid_pull_request(self): """Tests building fuzzers with valid pull request.""" # TODO(metzman): What happens when this branch closes? - config = test_helpers.create_build_config(project_name=EXAMPLE_PROJECT, - project_repo_name='oss-fuzz', - workspace=self.workspace, - pr_ref='refs/pull/1757/merge', - base_ref='master', - is_github=True) + config = test_helpers.create_build_config( + oss_fuzz_project_name=EXAMPLE_PROJECT, + project_repo_name='oss-fuzz', + workspace=self.workspace, + pr_ref='refs/pull/1757/merge', + base_ref='master', + is_github=True) self.assertTrue(build_fuzzers.build_fuzzers(config)) self.assertTrue( os.path.exists(os.path.join(self.out_dir, EXAMPLE_BUILD_FUZZER))) def test_invalid_pull_request(self): """Tests building fuzzers with invalid pull request.""" - config = test_helpers.create_build_config(project_name=EXAMPLE_PROJECT, - project_repo_name='oss-fuzz', - workspace=self.workspace, - pr_ref='ref-1/merge', - base_ref='master', - is_github=True) + config = test_helpers.create_build_config( + oss_fuzz_project_name=EXAMPLE_PROJECT, + project_repo_name='oss-fuzz', + workspace=self.workspace, + pr_ref='ref-1/merge', + base_ref='master', + is_github=True) self.assertTrue(build_fuzzers.build_fuzzers(config)) - def test_invalid_project_name(self): + def test_invalid_oss_fuzz_project_name(self): """Tests building fuzzers with invalid project name.""" config = test_helpers.create_build_config( - project_name='not_a_valid_project', + oss_fuzz_project_name='not_a_valid_project', project_repo_name='oss-fuzz', workspace=self.workspace, commit_sha='0b95fe1039ed7c38fea1f97078316bfc1030c523') @@ -234,7 +235,7 @@ class BuildFuzzersIntegrationTest(unittest.TestCase): def test_invalid_repo_name(self): """Tests building fuzzers with invalid repo name.""" config = test_helpers.create_build_config( - project_name=EXAMPLE_PROJECT, + oss_fuzz_project_name=EXAMPLE_PROJECT, project_repo_name='not-real-repo', workspace=self.workspace, commit_sha='0b95fe1039ed7c38fea1f97078316bfc1030c523') @@ -242,18 +243,19 @@ class BuildFuzzersIntegrationTest(unittest.TestCase): def test_invalid_commit_sha(self): """Tests building fuzzers with invalid commit SHA.""" - config = test_helpers.create_build_config(project_name=EXAMPLE_PROJECT, - project_repo_name='oss-fuzz', - workspace=self.workspace, - commit_sha='', - is_github=True) + config = test_helpers.create_build_config( + oss_fuzz_project_name=EXAMPLE_PROJECT, + project_repo_name='oss-fuzz', + workspace=self.workspace, + commit_sha='', + is_github=True) with self.assertRaises(AssertionError): build_fuzzers.build_fuzzers(config) def test_invalid_workspace(self): """Tests building fuzzers with invalid workspace.""" config = test_helpers.create_build_config( - project_name=EXAMPLE_PROJECT, + oss_fuzz_project_name=EXAMPLE_PROJECT, project_repo_name='oss-fuzz', workspace=os.path.join(self.workspace, 'not', 'a', 'dir'), commit_sha='0b95fe1039ed7c38fea1f97078316bfc1030c523') @@ -318,11 +320,12 @@ class BuildSantizerIntegrationTest(unittest.TestCase): @classmethod def _create_config(cls, tmp_dir, sanitizer): - return test_helpers.create_build_config(project_name=cls.PROJECT_NAME, - project_repo_name=cls.PROJECT_NAME, - workspace=tmp_dir, - pr_ref=cls.PR_REF, - sanitizer=sanitizer) + return test_helpers.create_build_config( + oss_fuzz_project_name=cls.PROJECT_NAME, + project_repo_name=cls.PROJECT_NAME, + workspace=tmp_dir, + pr_ref=cls.PR_REF, + sanitizer=sanitizer) @parameterized.parameterized.expand([('memory',), ('undefined',)]) def test_valid_project_curl(self, sanitizer): diff --git a/infra/cifuzz/clusterfuzz_deployment.py b/infra/cifuzz/clusterfuzz_deployment.py index e076eb19e..9d30c6fc0 100644 --- a/infra/cifuzz/clusterfuzz_deployment.py +++ b/infra/cifuzz/clusterfuzz_deployment.py @@ -118,6 +118,7 @@ class ClusterFuzzLite(BaseClusterFuzzDeployment): return None def download_corpus(self, target_name): + print('here') corpus_dir = self.make_empty_corpus_dir(target_name) logging.debug('ClusterFuzzLite: downloading corpus for %s to %s.', target_name, corpus_dir) @@ -210,15 +211,17 @@ class OSSFuzz(BaseClusterFuzzDeployment): Returns: A string with the latest build version or None. """ - version_file = (f'{self.config.project_name}-{self.config.sanitizer}' - '-latest.version') + version_file = ( + f'{self.config.oss_fuzz_project_name}-{self.config.sanitizer}' + '-latest.version') version_url = utils.url_join(utils.GCS_BASE_URL, self.CLUSTERFUZZ_BUILDS, - self.config.project_name, version_file) + self.config.oss_fuzz_project_name, + version_file) try: response = urllib.request.urlopen(version_url) except urllib.error.HTTPError: logging.error('Error getting latest build version for %s from: %s.', - self.config.project_name, version_url) + self.config.oss_fuzz_project_name, version_url) return None return response.read().decode() @@ -241,7 +244,7 @@ class OSSFuzz(BaseClusterFuzzDeployment): oss_fuzz_build_url = utils.url_join(utils.GCS_BASE_URL, self.CLUSTERFUZZ_BUILDS, - self.config.project_name, + self.config.oss_fuzz_project_name, latest_build_name) if http_utils.download_and_unpack_zip(oss_fuzz_build_url, self.workspace.clusterfuzz_build): @@ -269,11 +272,11 @@ class OSSFuzz(BaseClusterFuzzDeployment): """ corpus_dir = self.make_empty_corpus_dir(target_name) project_qualified_fuzz_target_name = target_name - qualified_name_prefix = self.config.project_name + '_' + qualified_name_prefix = self.config.oss_fuzz_project_name + '_' if not target_name.startswith(qualified_name_prefix): project_qualified_fuzz_target_name = qualified_name_prefix + target_name - corpus_url = (f'{utils.GCS_BASE_URL}{self.config.project_name}' + corpus_url = (f'{utils.GCS_BASE_URL}{self.config.oss_fuzz_project_name}' '-backup.clusterfuzz-external.appspot.com/corpus/' f'libFuzzer/{project_qualified_fuzz_target_name}/' f'{self.CORPUS_ZIP_NAME}') @@ -289,7 +292,8 @@ class OSSFuzz(BaseClusterFuzzDeployment): def get_coverage(self, repo_path): """Returns the project coverage object for the project.""" try: - return get_coverage.OSSFuzzCoverage(repo_path, self.config.project_name) + return get_coverage.OSSFuzzCoverage(repo_path, + self.config.oss_fuzz_project_name) except get_coverage.CoverageError: return None diff --git a/infra/cifuzz/clusterfuzz_deployment_test.py b/infra/cifuzz/clusterfuzz_deployment_test.py index c03cd1e51..900d57ceb 100644 --- a/infra/cifuzz/clusterfuzz_deployment_test.py +++ b/infra/cifuzz/clusterfuzz_deployment_test.py @@ -42,7 +42,7 @@ def _create_config(**kwargs): attribute of Config.""" defaults = { 'is_github': True, - 'project_name': EXAMPLE_PROJECT, + 'oss_fuzz_project_name': EXAMPLE_PROJECT, 'workspace': WORKSPACE, } for default_key, default_value in defaults.items(): @@ -131,7 +131,9 @@ class ClusterFuzzLiteTest(fake_filesystem_unittest.TestCase): def setUp(self): self.setUpPyfakefs() self.deployment = _create_deployment(run_fuzzers_mode='batch', - build_integration_path='/') + build_integration_path='/', + oss_fuzz_project_name='', + is_github=True) @mock.patch('filestore.github_actions.GithubActionsFilestore.download_corpus', return_value=True) @@ -180,8 +182,7 @@ class NoClusterFuzzDeploymentTest(fake_filesystem_unittest.TestCase): def setUp(self): self.setUpPyfakefs() - config = test_helpers.create_run_config(project_name=EXAMPLE_PROJECT, - build_integration_path='/', + config = test_helpers.create_run_config(build_integration_path='/', workspace=WORKSPACE, is_github=False) workspace = docker.Workspace(config) diff --git a/infra/cifuzz/config_utils.py b/infra/cifuzz/config_utils.py index 474bda42a..68dcde6a0 100644 --- a/infra/cifuzz/config_utils.py +++ b/infra/cifuzz/config_utils.py @@ -37,11 +37,6 @@ def _get_sanitizer(): return os.getenv('SANITIZER', 'address').lower() -def _get_project_name(): - # TODO(metzman): Remove OSS-Fuzz reference. - return os.getenv('OSS_FUZZ_PROJECT_NAME') - - def _is_dry_run(): """Returns True if configured to do a dry run.""" return environment.get_bool('DRY_RUN', 'false') @@ -94,13 +89,16 @@ class BaseConfig: def __init__(self): self.workspace = os.getenv('GITHUB_WORKSPACE') - self.project_name = _get_project_name() + self.oss_fuzz_project_name = os.getenv('OSS_FUZZ_PROJECT_NAME') self.project_repo_owner, self.project_repo_name = ( _get_project_repo_owner_and_name()) # Check if failures should not be reported. self.dry_run = _is_dry_run() self.sanitizer = _get_sanitizer() + # TODO(ochang): Error out if both oss_fuzz and build_integration_path is not + # set. self.build_integration_path = os.getenv('BUILD_INTEGRATION_PATH') + self.language = _get_language() event_path = os.getenv('GITHUB_EVENT_PATH') self.is_github = bool(event_path) @@ -113,7 +111,7 @@ class BaseConfig: @property def is_internal(self): """Returns True if this is an OSS-Fuzz project.""" - return not self.build_integration_path + return bool(self.oss_fuzz_project_name) @property def platform(self): diff --git a/infra/cifuzz/continuous_integration.py b/infra/cifuzz/continuous_integration.py index c90aca0b1..646826c5d 100644 --- a/infra/cifuzz/continuous_integration.py +++ b/infra/cifuzz/continuous_integration.py @@ -21,6 +21,7 @@ import logging # pylint: disable=wrong-import-position,import-error sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) import build_specified_commit +import docker import helper import repo_manager import retry @@ -132,11 +133,11 @@ class InternalGithub(GithubCiMixin, BaseCi): assert self.config.pr_ref or self.config.commit_sha # detect_main_repo builds the image as a side effect. inferred_url, image_repo_path = (build_specified_commit.detect_main_repo( - self.config.project_name, repo_name=self.config.project_repo_name)) + self.config.oss_fuzz_project_name, + repo_name=self.config.project_repo_name)) if not inferred_url or not image_repo_path: - logging.error('Could not detect repo from project %s.', - self.config.project_name) + logging.error('Could not detect repo.') return BuildPreparationResult(success=False, image_repo_path=None, repo_manager=None) @@ -171,11 +172,11 @@ class InternalGeneric(BaseCi): logging.info('Building OSS-Fuzz project.') # detect_main_repo builds the image as a side effect. _, image_repo_path = (build_specified_commit.detect_main_repo( - self.config.project_name, repo_name=self.config.project_repo_name)) + self.config.oss_fuzz_project_name, + repo_name=self.config.project_repo_name)) if not image_repo_path: - logging.error('Could not detect repo from project %s.', - self.config.project_name) + logging.error('Could not detect repo.') return BuildPreparationResult(success=False, image_repo_path=None, repo_manager=None) @@ -194,13 +195,13 @@ _IMAGE_BUILD_BACKOFF = 2 @retry.wrap(_IMAGE_BUILD_TRIES, _IMAGE_BUILD_BACKOFF) -def build_external_project_docker_image(project_name, project_src, - build_integration_path): +def build_external_project_docker_image(project_src, build_integration_path): """Builds the project builder image for an external (non-OSS-Fuzz) project. Returns True on success.""" dockerfile_path = os.path.join(build_integration_path, 'Dockerfile') - tag = 'gcr.io/oss-fuzz/{project_name}'.format(project_name=project_name) - command = ['-t', tag, '-f', dockerfile_path, project_src] + command = [ + '-t', docker.EXTERNAL_PROJECT_IMAGE, '-f', dockerfile_path, project_src + ] return helper.docker_build(command) @@ -215,10 +216,10 @@ class ExternalGeneric(BaseCi): manager = repo_manager.RepoManager(self.config.project_src_path) build_integration_abs_path = os.path.join( manager.repo_dir, self.config.build_integration_path) - if not build_external_project_docker_image( - self.config.project_name, manager.repo_dir, build_integration_abs_path): + if not build_external_project_docker_image(manager.repo_dir, + build_integration_abs_path): logging.error('Failed to build external project: %s.', - self.config.project_name) + self.config.oss_fuzz_project_name) return BuildPreparationResult(success=False, image_repo_path=None, repo_manager=None) @@ -252,8 +253,8 @@ class ExternalGithub(GithubCiMixin, BaseCi): build_integration_abs_path = os.path.join( manager.repo_dir, self.config.build_integration_path) - if not build_external_project_docker_image( - self.config.project_name, manager.repo_dir, build_integration_abs_path): + if not build_external_project_docker_image(manager.repo_dir, + build_integration_abs_path): logging.error('Failed to build external project.') return BuildPreparationResult(success=False, image_repo_path=None, diff --git a/infra/cifuzz/docker.py b/infra/cifuzz/docker.py index 752f9c017..1a649b189 100644 --- a/infra/cifuzz/docker.py +++ b/infra/cifuzz/docker.py @@ -33,6 +33,8 @@ _DEFAULT_DOCKER_RUN_ARGS = [ 'ARCHITECTURE=' + DEFAULT_ARCHITECTURE, '-e', 'CIFUZZ=True' ] +EXTERNAL_PROJECT_IMAGE = 'external-project' + _DEFAULT_DOCKER_RUN_COMMAND = [ 'docker', 'run', @@ -43,7 +45,11 @@ _DEFAULT_DOCKER_RUN_COMMAND = [ def get_project_image_name(project): """Returns the name of the project builder image for |project_name|.""" - return PROJECT_TAG_PREFIX + project + # TODO(ochang): We may need unique names to support parallel fuzzing. + if project: + return PROJECT_TAG_PREFIX + project + + return EXTERNAL_PROJECT_IMAGE def delete_images(images): diff --git a/infra/cifuzz/fuzz_target_test.py b/infra/cifuzz/fuzz_target_test.py index c760f9fc1..8411a8543 100644 --- a/infra/cifuzz/fuzz_target_test.py +++ b/infra/cifuzz/fuzz_target_test.py @@ -47,7 +47,7 @@ def _create_config(**kwargs): attribute of Config.""" defaults = { 'is_github': True, - 'project_name': EXAMPLE_PROJECT, + 'oss_fuzz_project_name': EXAMPLE_PROJECT, 'workspace': '/workspace' } for default_key, default_value in defaults.items(): diff --git a/infra/cifuzz/generate_coverage_report_test.py b/infra/cifuzz/generate_coverage_report_test.py index 62a4c8c5a..b5f2b489a 100644 --- a/infra/cifuzz/generate_coverage_report_test.py +++ b/infra/cifuzz/generate_coverage_report_test.py @@ -30,7 +30,7 @@ class TestRunCoverageCommand(unittest.TestCase): @mock.patch('helper.docker_run') def test_run_coverage_command(self, mocked_docker_run): # pylint: disable=no-self-use """Tests that run_coverage_command works as intended.""" - config = test_helpers.create_run_config(project_name=PROJECT, + config = test_helpers.create_run_config(oss_fuzz_project_name=PROJECT, sanitizer=SANITIZER) workspace = test_helpers.create_workspace() expected_docker_args = [ diff --git a/infra/cifuzz/run_fuzzers_entrypoint.py b/infra/cifuzz/run_fuzzers_entrypoint.py index 5a66bb47a..4f97df845 100644 --- a/infra/cifuzz/run_fuzzers_entrypoint.py +++ b/infra/cifuzz/run_fuzzers_entrypoint.py @@ -33,7 +33,7 @@ def delete_unneeded_docker_images(config): if not config.low_disk_space: return logging.info('Deleting builder docker images to save disk space.') - project_image = docker.get_project_image_name(config.project_name) + project_image = docker.get_project_image_name(config.oss_fuzz_project_name) images = [ project_image, docker.BASE_RUNNER_TAG, diff --git a/infra/cifuzz/run_fuzzers_test.py b/infra/cifuzz/run_fuzzers_test.py index dfbee8581..b29c6b1a3 100644 --- a/infra/cifuzz/run_fuzzers_test.py +++ b/infra/cifuzz/run_fuzzers_test.py @@ -65,7 +65,7 @@ class RunFuzzerIntegrationTestMixin: # pylint: disable=too-few-public-methods,i with test_helpers.temp_dir_copy(fuzzer_dir) as fuzzer_dir_copy: config = test_helpers.create_run_config(fuzz_seconds=FUZZ_SECONDS, workspace=fuzzer_dir_copy, - project_name='curl', + oss_fuzz_project_name='curl', sanitizer=sanitizer) result = run_fuzzers.run_fuzzers(config) self.assertEqual(result, run_fuzzers.RunFuzzersResult.NO_BUG_FOUND) @@ -101,7 +101,10 @@ class BaseFuzzTargetRunnerTest(unittest.TestCase): """Tests BaseFuzzTargetRunner.""" def _create_runner(self, **kwargs): # pylint: disable=no-self-use - defaults = {'fuzz_seconds': FUZZ_SECONDS, 'project_name': EXAMPLE_PROJECT} + defaults = { + 'fuzz_seconds': FUZZ_SECONDS, + 'oss_fuzz_project_name': EXAMPLE_PROJECT + } for default_key, default_value in defaults.items(): if default_key not in kwargs: kwargs[default_key] = default_value @@ -241,9 +244,10 @@ class CiFuzzTargetRunnerTest(fake_filesystem_unittest.TestCase): workspace = 'workspace' out_path = os.path.join(workspace, 'build-out') self.fs.create_dir(out_path) - config = test_helpers.create_run_config(fuzz_seconds=FUZZ_SECONDS, - workspace=workspace, - project_name=EXAMPLE_PROJECT) + config = test_helpers.create_run_config( + fuzz_seconds=FUZZ_SECONDS, + workspace=workspace, + oss_fuzz_project_name=EXAMPLE_PROJECT) runner = run_fuzzers.CiFuzzTargetRunner(config) mocked_get_fuzz_targets.return_value = ['target1', 'target2'] @@ -280,7 +284,6 @@ class BatchFuzzTargetRunnerTest(fake_filesystem_unittest.TestCase): self.fs.create_file(self.testcase2) self.config = test_helpers.create_run_config(fuzz_seconds=FUZZ_SECONDS, workspace=self.WORKSPACE, - project_name=EXAMPLE_PROJECT, build_integration_path='/', is_github=True) @@ -349,7 +352,7 @@ class CoverageReportIntegrationTest(unittest.TestCase): try: # Do coverage build. build_config = test_helpers.create_build_config( - project_name=EXAMPLE_PROJECT, + oss_fuzz_project_name=EXAMPLE_PROJECT, project_repo_name='oss-fuzz', workspace=workspace, commit_sha='0b95fe1039ed7c38fea1f97078316bfc1030c523', @@ -362,7 +365,7 @@ class CoverageReportIntegrationTest(unittest.TestCase): run_config = test_helpers.create_run_config( fuzz_seconds=FUZZ_SECONDS, workspace=workspace, - project_name=EXAMPLE_PROJECT, + oss_fuzz_project_name=EXAMPLE_PROJECT, sanitizer=self.SANITIZER, run_fuzzers_mode='coverage') result = run_fuzzers.run_fuzzers(run_config) @@ -405,9 +408,10 @@ class RunAddressFuzzersIntegrationTest(RunFuzzerIntegrationTestMixin, with tempfile.TemporaryDirectory() as tmp_dir: workspace = os.path.join(tmp_dir, 'workspace') shutil.copytree(TEST_DATA_PATH, workspace) - config = test_helpers.create_run_config(fuzz_seconds=FUZZ_SECONDS, - workspace=workspace, - project_name=EXAMPLE_PROJECT) + config = test_helpers.create_run_config( + fuzz_seconds=FUZZ_SECONDS, + workspace=workspace, + oss_fuzz_project_name=EXAMPLE_PROJECT) result = run_fuzzers.run_fuzzers(config) self.assertEqual(result, run_fuzzers.RunFuzzersResult.BUG_FOUND) @@ -418,9 +422,10 @@ class RunAddressFuzzersIntegrationTest(RunFuzzerIntegrationTestMixin, with tempfile.TemporaryDirectory() as tmp_dir: workspace = os.path.join(tmp_dir, 'workspace') shutil.copytree(TEST_DATA_PATH, workspace) - config = test_helpers.create_run_config(fuzz_seconds=FUZZ_SECONDS, - workspace=workspace, - project_name=EXAMPLE_PROJECT) + config = test_helpers.create_run_config( + fuzz_seconds=FUZZ_SECONDS, + workspace=workspace, + oss_fuzz_project_name=EXAMPLE_PROJECT) result = run_fuzzers.run_fuzzers(config) self.assertEqual(result, run_fuzzers.RunFuzzersResult.NO_BUG_FOUND) @@ -429,9 +434,10 @@ class RunAddressFuzzersIntegrationTest(RunFuzzerIntegrationTestMixin, with tempfile.TemporaryDirectory() as tmp_dir: out_path = os.path.join(tmp_dir, 'build-out') os.mkdir(out_path) - config = test_helpers.create_run_config(fuzz_seconds=FUZZ_SECONDS, - workspace=tmp_dir, - project_name=EXAMPLE_PROJECT) + config = test_helpers.create_run_config( + fuzz_seconds=FUZZ_SECONDS, + workspace=tmp_dir, + oss_fuzz_project_name=EXAMPLE_PROJECT) result = run_fuzzers.run_fuzzers(config) self.assertEqual(result, run_fuzzers.RunFuzzersResult.ERROR) @@ -452,7 +458,7 @@ class GetFuzzTargetRunnerTest(unittest.TestCase): run_config = test_helpers.create_run_config( fuzz_seconds=FUZZ_SECONDS, workspace=tmp_dir, - project_name='example', + oss_fuzz_project_name='example', run_fuzzers_mode=run_fuzzers_mode) runner = run_fuzzers.get_fuzz_target_runner(run_config) self.assertTrue(isinstance(runner, fuzz_target_runner_cls)) |