From 0672aa4e1f2cc332f6e6a020259c35007292cd91 Mon Sep 17 00:00:00 2001 From: jonathanmetzman <31354670+jonathanmetzman@users.noreply.github.com> Date: Wed, 30 Jun 2021 07:34:42 -0700 Subject: [CIFuzz] Don't make everything a subdirectory of /out (#5970) Use different subdirectories of workspace for builds, old builds, coverage reports, corpora and artifacts/testscases. --- infra/cifuzz/build_fuzzers_entrypoint.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'infra/cifuzz/build_fuzzers_entrypoint.py') diff --git a/infra/cifuzz/build_fuzzers_entrypoint.py b/infra/cifuzz/build_fuzzers_entrypoint.py index 04f562068..2ab7aa361 100644 --- a/infra/cifuzz/build_fuzzers_entrypoint.py +++ b/infra/cifuzz/build_fuzzers_entrypoint.py @@ -13,11 +13,11 @@ # limitations under the License. """Builds a specific OSS-Fuzz project's fuzzers for CI tools.""" import logging -import os import sys import build_fuzzers import config_utils +import docker # pylint: disable=c-extension-no-member # pylint gets confused because of the relative import of cifuzz. @@ -71,15 +71,13 @@ def main(): config.project_name, config.commit_sha, config.pr_ref) return returncode - out_dir = os.path.join(config.workspace, 'out') - if not config.bad_build_check: # If we've gotten to this point and we don't need to do bad_build_check, # then the build has succeeded. returncode = 0 # yapf: disable elif build_fuzzers.check_fuzzer_build( - out_dir, + docker.Workspace(config), config.sanitizer, config.language, allowed_broken_targets_percentage=config.allowed_broken_targets_percentage -- cgit v1.2.3 From faea660c5e76cf298ae8a2426efc8f37a90d37aa Mon Sep 17 00:00:00 2001 From: Mitchel Herman <58443548+mpherman2@users.noreply.github.com> Date: Wed, 30 Jun 2021 17:19:03 -0700 Subject: Add CIFuzz external entrypoint for cifuzz base (#5906) This is an entrypoint for CIFuzz users that can't build two docker images (e.g. prow users). Co-authored-by: jonathanmetzman <31354670+jonathanmetzman@users.noreply.github.com> --- infra/cifuzz/build_fuzzers_entrypoint.py | 50 +++++++++++++++++--------------- 1 file changed, 26 insertions(+), 24 deletions(-) (limited to 'infra/cifuzz/build_fuzzers_entrypoint.py') diff --git a/infra/cifuzz/build_fuzzers_entrypoint.py b/infra/cifuzz/build_fuzzers_entrypoint.py index 2ab7aa361..024ac60b5 100644 --- a/infra/cifuzz/build_fuzzers_entrypoint.py +++ b/infra/cifuzz/build_fuzzers_entrypoint.py @@ -28,30 +28,8 @@ logging.basicConfig( level=logging.DEBUG) -def main(): - """Build OSS-Fuzz project's fuzzers for CI tools. - This script is used to kick off the Github Actions CI tool. It is the - entrypoint of the Dockerfile in this directory. This action can be added to - any OSS-Fuzz project's workflow that uses Github. - - Note: The resulting clusterfuzz binaries of this build are placed in - the directory: ${GITHUB_WORKSPACE}/out - - Required environment variables: - OSS_FUZZ_PROJECT_NAME: The name of OSS-Fuzz project. - GITHUB_REPOSITORY: The name of the Github repo that called this script. - GITHUB_SHA: The commit SHA that triggered this script. - GITHUB_EVENT_NAME: The name of the hook event that triggered this script. - GITHUB_EVENT_PATH: - The path to the file containing the POST payload of the webhook: - https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners#filesystems-on-github-hosted-runners - GITHUB_WORKSPACE: The shared volume directory where input artifacts are. - DRY_RUN: If true, no failures will surface. - SANITIZER: The sanitizer to use when running fuzzers. - - Returns: - 0 on success or 1 on failure. - """ +def build_fuzzers_entrypoint(): + """Builds OSS-Fuzz project's fuzzers for CI tools.""" config = config_utils.BuildFuzzersConfig() if config.dry_run: @@ -88,5 +66,29 @@ def main(): return returncode +def main(): + """Builds OSS-Fuzz project's fuzzers for CI tools. + + Note: The resulting fuzz target binaries of this build are placed in + the directory: ${GITHUB_WORKSPACE}/out + + Required environment variables: + OSS_FUZZ_PROJECT_NAME: The name of OSS-Fuzz project. + GITHUB_REPOSITORY: The name of the Github repo that called this script. + GITHUB_SHA: The commit SHA that triggered this script. + GITHUB_EVENT_NAME: The name of the hook event that triggered this script. + GITHUB_EVENT_PATH: + The path to the file containing the POST payload of the webhook: + https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners#filesystems-on-github-hosted-runners + GITHUB_WORKSPACE: The shared volume directory where input artifacts are. + DRY_RUN: If true, no failures will surface. + SANITIZER: The sanitizer to use when running fuzzers. + + Returns: + 0 on success or nonzero on failure. + """ + return build_fuzzers_entrypoint() + + if __name__ == '__main__': sys.exit(main()) -- cgit v1.2.3 From c7cab23c207288caa107a5cc6bb33f715929ecb6 Mon Sep 17 00:00:00 2001 From: Oliver Chang Date: Wed, 21 Jul 2021 15:32:32 +1000 Subject: 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. --- infra/cifuzz/build_fuzzers_entrypoint.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'infra/cifuzz/build_fuzzers_entrypoint.py') 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: -- cgit v1.2.3 From 6f0aa82cd149910cb60e0d7d5ab49e47453f8c87 Mon Sep 17 00:00:00 2001 From: jonathanmetzman <31354670+jonathanmetzman@users.noreply.github.com> Date: Tue, 27 Jul 2021 12:11:53 -0700 Subject: [NFC][cifuzz] Move Workspace from docker into config_utils. (#6117) It doesn't really fit into docker. --- infra/cifuzz/build_fuzzers_entrypoint.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'infra/cifuzz/build_fuzzers_entrypoint.py') diff --git a/infra/cifuzz/build_fuzzers_entrypoint.py b/infra/cifuzz/build_fuzzers_entrypoint.py index 505a37415..b391afb99 100644 --- a/infra/cifuzz/build_fuzzers_entrypoint.py +++ b/infra/cifuzz/build_fuzzers_entrypoint.py @@ -17,7 +17,6 @@ import sys import build_fuzzers import config_utils -import docker # pylint: disable=c-extension-no-member # pylint gets confused because of the relative import of cifuzz. @@ -54,7 +53,7 @@ def build_fuzzers_entrypoint(): returncode = 0 # yapf: disable elif build_fuzzers.check_fuzzer_build( - docker.Workspace(config), + config_utils.Workspace(config), config.sanitizer, config.language, allowed_broken_targets_percentage=config.allowed_broken_targets_percentage -- cgit v1.2.3 From 729a8fe695ed583801a639552cc9991dbe21284d Mon Sep 17 00:00:00 2001 From: jonathanmetzman <31354670+jonathanmetzman@users.noreply.github.com> Date: Thu, 29 Jul 2021 08:31:51 -0700 Subject: [NFC][cifuzz] Improve env var handling. (#6137) Also delete useless TODOs. --- infra/cifuzz/build_fuzzers_entrypoint.py | 1 - 1 file changed, 1 deletion(-) (limited to 'infra/cifuzz/build_fuzzers_entrypoint.py') diff --git a/infra/cifuzz/build_fuzzers_entrypoint.py b/infra/cifuzz/build_fuzzers_entrypoint.py index b391afb99..4acbb3622 100644 --- a/infra/cifuzz/build_fuzzers_entrypoint.py +++ b/infra/cifuzz/build_fuzzers_entrypoint.py @@ -21,7 +21,6 @@ import config_utils # pylint: disable=c-extension-no-member # pylint gets confused because of the relative import of cifuzz. -# TODO: Turn default logging to INFO when CIFuzz is stable logging.basicConfig( format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.DEBUG) -- cgit v1.2.3 From c75d1b362f2c21fd0c66cbec2eae6d1195d99142 Mon Sep 17 00:00:00 2001 From: jonathanmetzman <31354670+jonathanmetzman@users.noreply.github.com> Date: Mon, 2 Aug 2021 12:37:37 -0700 Subject: [cifuzz] Create validate method on BaseConfig (#6135) * [cifuzz] Create validate method on BaseConfig Use it to validate that either OSS_FUZZ_PROJECT_NAME or BUILD_INTEGRATION_PATH is set. Also use it to validate that workspace is set (rather than duplicate code). Add tests. * Use env var hack to bypass valdiation * fix * fix * fmt * fix * tmp * fix --- infra/cifuzz/build_fuzzers_entrypoint.py | 4 ---- 1 file changed, 4 deletions(-) (limited to 'infra/cifuzz/build_fuzzers_entrypoint.py') diff --git a/infra/cifuzz/build_fuzzers_entrypoint.py b/infra/cifuzz/build_fuzzers_entrypoint.py index 4acbb3622..c191ca38e 100644 --- a/infra/cifuzz/build_fuzzers_entrypoint.py +++ b/infra/cifuzz/build_fuzzers_entrypoint.py @@ -37,10 +37,6 @@ def build_fuzzers_entrypoint(): # The default return code when an error occurs. returncode = 1 - if not config.workspace: - logging.error('This script needs to be run within Github actions.') - return returncode - if not build_fuzzers.build_fuzzers(config): logging.error('Error building fuzzers for (commit: %s, pr_ref: %s).', config.commit_sha, config.pr_ref) -- cgit v1.2.3 From 432105a31af3f7bfbcf2c0d1a26d4e65f8e98571 Mon Sep 17 00:00:00 2001 From: jonathanmetzman <31354670+jonathanmetzman@users.noreply.github.com> Date: Tue, 3 Aug 2021 17:58:20 -0700 Subject: [cifuzz][NFC] Move Workspace to workspace_utils. (#6158) In hindsight, it doesn't have a lot to do with the rest of config_utils. And config_utils is getting crowded. --- infra/cifuzz/build_fuzzers_entrypoint.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'infra/cifuzz/build_fuzzers_entrypoint.py') diff --git a/infra/cifuzz/build_fuzzers_entrypoint.py b/infra/cifuzz/build_fuzzers_entrypoint.py index c191ca38e..5aed2e615 100644 --- a/infra/cifuzz/build_fuzzers_entrypoint.py +++ b/infra/cifuzz/build_fuzzers_entrypoint.py @@ -17,6 +17,7 @@ import sys import build_fuzzers import config_utils +import workspace_utils # pylint: disable=c-extension-no-member # pylint gets confused because of the relative import of cifuzz. @@ -48,7 +49,7 @@ def build_fuzzers_entrypoint(): returncode = 0 # yapf: disable elif build_fuzzers.check_fuzzer_build( - config_utils.Workspace(config), + workspace_utils.Workspace(config), config.sanitizer, config.language, allowed_broken_targets_percentage=config.allowed_broken_targets_percentage -- cgit v1.2.3 From d01808333d086dd259f6c6fbf07457664faf7bb7 Mon Sep 17 00:00:00 2001 From: jonathanmetzman <31354670+jonathanmetzman@users.noreply.github.com> Date: Thu, 5 Aug 2021 13:27:24 -0700 Subject: [cifuzz] Fuzz in cifuzz-base (#6142) Fixes: #5926 --- infra/cifuzz/build_fuzzers_entrypoint.py | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'infra/cifuzz/build_fuzzers_entrypoint.py') diff --git a/infra/cifuzz/build_fuzzers_entrypoint.py b/infra/cifuzz/build_fuzzers_entrypoint.py index 5aed2e615..c128ae937 100644 --- a/infra/cifuzz/build_fuzzers_entrypoint.py +++ b/infra/cifuzz/build_fuzzers_entrypoint.py @@ -17,7 +17,6 @@ import sys import build_fuzzers import config_utils -import workspace_utils # pylint: disable=c-extension-no-member # pylint gets confused because of the relative import of cifuzz. @@ -47,14 +46,7 @@ def build_fuzzers_entrypoint(): # If we've gotten to this point and we don't need to do bad_build_check, # then the build has succeeded. returncode = 0 - # yapf: disable - elif build_fuzzers.check_fuzzer_build( - workspace_utils.Workspace(config), - config.sanitizer, - config.language, - allowed_broken_targets_percentage=config.allowed_broken_targets_percentage - ): - # yapf: enable + elif build_fuzzers.check_fuzzer_build(config): returncode = 0 return returncode -- cgit v1.2.3 From 1d588e62cdc119f676316fbcab13cc331c7fb08c Mon Sep 17 00:00:00 2001 From: jonathanmetzman <31354670+jonathanmetzman@users.noreply.github.com> Date: Mon, 4 Oct 2021 11:21:28 -0400 Subject: clusterfuzzlite: Upload builds after bad build check. (#6531) Fixes: #6525 Depends on: #6530 --- infra/cifuzz/build_fuzzers_entrypoint.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'infra/cifuzz/build_fuzzers_entrypoint.py') diff --git a/infra/cifuzz/build_fuzzers_entrypoint.py b/infra/cifuzz/build_fuzzers_entrypoint.py index c128ae937..e8e368f1b 100644 --- a/infra/cifuzz/build_fuzzers_entrypoint.py +++ b/infra/cifuzz/build_fuzzers_entrypoint.py @@ -42,14 +42,7 @@ def build_fuzzers_entrypoint(): config.commit_sha, config.pr_ref) return returncode - if not config.bad_build_check: - # If we've gotten to this point and we don't need to do bad_build_check, - # then the build has succeeded. - returncode = 0 - elif build_fuzzers.check_fuzzer_build(config): - returncode = 0 - - return returncode + return 0 def main(): -- cgit v1.2.3