From 9aa85855b4748b5dfa028e4065f0c17791eb11b8 Mon Sep 17 00:00:00 2001 From: Oliver Chang Date: Wed, 20 Oct 2021 15:02:17 +1100 Subject: [PATCH] cifuzz: Rename run-fuzzers-mode to mode. (#6600) Also change the default value of "ci" to the more consistent and descriptive "code-change". --- infra/cifuzz/actions/run_fuzzers/action.yml | 13 +++++++------ infra/cifuzz/config_utils.py | 5 +++-- infra/cifuzz/config_utils_test.py | 4 ++-- .../cifuzz/external-actions/run_fuzzers/action.yml | 13 +++++++------ infra/cifuzz/run_fuzzers.py | 2 +- infra/cifuzz/run_fuzzers_test.py | 2 +- 6 files changed, 21 insertions(+), 18 deletions(-) diff --git a/infra/cifuzz/actions/run_fuzzers/action.yml b/infra/cifuzz/actions/run_fuzzers/action.yml index b56dbce3d..64f0fe27a 100644 --- a/infra/cifuzz/actions/run_fuzzers/action.yml +++ b/infra/cifuzz/actions/run_fuzzers/action.yml @@ -19,14 +19,15 @@ inputs: sanitizer: description: 'The sanitizer to run the fuzzers with.' default: 'address' - run-fuzzers-mode: + mode: description: | - The mode to run the fuzzers with ("ci" or "batch"). - "ci" is for fuzzing a pull request or commit. + The mode to run the fuzzers with ("code-change", "batch", "coverage", or "prune"). + "code-change" is for fuzzing a pull request or commit. "batch" is for non-interactive fuzzing of an entire project. - "batch" is in alpha and should not be used in production. + "coverage" is for coverage generation. + "prune" is for corpus pruning. required: false - default: 'ci' + default: 'code-change' github-token: description: | Token for GitHub API. WARNING: THIS SHOULD NOT BE USED IN PRODUCTION YET @@ -48,7 +49,7 @@ runs: FUZZ_SECONDS: ${{ inputs.fuzz-seconds }} DRY_RUN: ${{ inputs.dry-run}} SANITIZER: ${{ inputs.sanitizer }} - RUN_FUZZERS_MODE: ${{ inputs.run-fuzzers-mode }} + RUN_FUZZERS_MODE: ${{ inputs.mode }} GITHUB_TOKEN: ${{ inputs.github-token }} LOW_DISK_SPACE: 'True' REPORT_UNREPRODUCIBLE_CRASHES: ${{ inputs.report-unreproducible-crashes }} diff --git a/infra/cifuzz/config_utils.py b/infra/cifuzz/config_utils.py index 0900ca83f..9beef9d52 100644 --- a/infra/cifuzz/config_utils.py +++ b/infra/cifuzz/config_utils.py @@ -26,7 +26,7 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) import constants -RUN_FUZZERS_MODES = ['batch', 'ci', 'coverage', 'prune'] +RUN_FUZZERS_MODES = ['batch', 'code-change', 'coverage', 'prune'] SANITIZERS = ['address', 'memory', 'undefined', 'coverage'] # TODO(metzman): Set these on config objects so there's one source of truth. @@ -307,7 +307,8 @@ class RunFuzzersConfig(BaseConfig): super().__init__() # TODO(metzman): Pick a better default for pruning. self.fuzz_seconds = int(os.environ.get('FUZZ_SECONDS', 600)) - self.run_fuzzers_mode = os.environ.get('RUN_FUZZERS_MODE', 'ci').lower() + self.run_fuzzers_mode = os.environ.get('RUN_FUZZERS_MODE', + 'code-change').lower() if self.is_coverage: self.run_fuzzers_mode = 'coverage' diff --git a/infra/cifuzz/config_utils_test.py b/infra/cifuzz/config_utils_test.py index d4ccd1eb8..87008f50e 100644 --- a/infra/cifuzz/config_utils_test.py +++ b/infra/cifuzz/config_utils_test.py @@ -138,13 +138,13 @@ class RunFuzzersConfigTest(unittest.TestCase): is_coverage.""" # Test that it is overriden when it is supposed to be. os.environ['SANITIZER'] = 'coverage' - os.environ['RUN_FUZZERS_MODE'] = 'ci' + os.environ['RUN_FUZZERS_MODE'] = 'code-change' config = self._create_config() self.assertEqual(config.run_fuzzers_mode, 'coverage') # Test that it isn't overriden when it isn't supposed to be. os.environ['SANITIZER'] = 'address' - run_fuzzers_mode = 'ci' + run_fuzzers_mode = 'code-change' os.environ['RUN_FUZZERS_MODE'] = run_fuzzers_mode config = self._create_config() self.assertEqual(config.run_fuzzers_mode, run_fuzzers_mode) diff --git a/infra/cifuzz/external-actions/run_fuzzers/action.yml b/infra/cifuzz/external-actions/run_fuzzers/action.yml index cdefb5675..a670dfa10 100644 --- a/infra/cifuzz/external-actions/run_fuzzers/action.yml +++ b/infra/cifuzz/external-actions/run_fuzzers/action.yml @@ -16,14 +16,15 @@ inputs: sanitizer: description: 'The sanitizer to run the fuzzers with.' default: 'address' - run-fuzzers-mode: + mode: description: | - The mode to run the fuzzers with ("ci" or "batch"). - "ci" is for fuzzing a pull request or commit. + The mode to run the fuzzers with ("code-change", "batch", "coverage", or "prune"). + "code-change" is for fuzzing a pull request or commit. "batch" is for non-interactive fuzzing of an entire project. - "batch" is in alpha and should not be used in production. + "coverage" is for coverage generation. + "prune" is for corpus pruning. required: false - default: 'ci' + default: 'code-change' github-token: description: | Token for GitHub API. WARNING: THIS SHOULD NOT BE USED IN PRODUCTION YET @@ -60,7 +61,7 @@ runs: FUZZ_SECONDS: ${{ inputs.fuzz-seconds }} DRY_RUN: ${{ inputs.dry-run}} SANITIZER: ${{ inputs.sanitizer }} - RUN_FUZZERS_MODE: ${{ inputs.run-fuzzers-mode }} + RUN_FUZZERS_MODE: ${{ inputs.mode }} GITHUB_TOKEN: ${{ inputs.github-token }} LOW_DISK_SPACE: 'True' GIT_STORE_REPO: ${{ inputs.storage-repo }} diff --git a/infra/cifuzz/run_fuzzers.py b/infra/cifuzz/run_fuzzers.py index 67c4c66fd..f59ef4f89 100644 --- a/infra/cifuzz/run_fuzzers.py +++ b/infra/cifuzz/run_fuzzers.py @@ -267,7 +267,7 @@ _RUN_FUZZERS_MODE_RUNNER_MAPPING = { 'batch': BatchFuzzTargetRunner, 'coverage': CoverageTargetRunner, 'prune': PruneTargetRunner, - 'ci': CiFuzzTargetRunner, + 'code-change': CiFuzzTargetRunner, } diff --git a/infra/cifuzz/run_fuzzers_test.py b/infra/cifuzz/run_fuzzers_test.py index db442b188..1e561c2bb 100644 --- a/infra/cifuzz/run_fuzzers_test.py +++ b/infra/cifuzz/run_fuzzers_test.py @@ -458,7 +458,7 @@ class GetFuzzTargetRunnerTest(unittest.TestCase): @parameterized.parameterized.expand([ ('batch', run_fuzzers.BatchFuzzTargetRunner), - ('ci', run_fuzzers.CiFuzzTargetRunner), + ('code-change', run_fuzzers.CiFuzzTargetRunner), ('coverage', run_fuzzers.CoverageTargetRunner) ]) def test_get_fuzz_target_runner(self, run_fuzzers_mode,