From bbbbad5c078ddbe01afc57056c3f709e12e619e8 Mon Sep 17 00:00:00 2001 From: jonathanmetzman <31354670+jonathanmetzman@users.noreply.github.com> Date: Tue, 23 Aug 2022 17:41:42 -0400 Subject: [PATCH] Prepare for JavaScript fuzzing (#8325) Prepare for JavaScript fuzzing Related: #8324 --- .../base-builder-javascript/Dockerfile | 19 +++++++++++++++++++ infra/base-images/base-builder/Dockerfile | 1 + .../base-builder/install_javascript.sh | 16 ++++++++++++++++ infra/build/functions/base_images.py | 1 + .../functions/build_and_push_test_images.py | 1 + infra/build/functions/build_lib.py | 1 + .../test_data/expected_trial_build_steps.json | 16 ++++++++++++++++ infra/build/functions/trial_build_test.py | 3 +++ infra/ci/build.py | 1 + infra/cifuzz/run_fuzzers_entrypoint.py | 1 + infra/constants.py | 1 + infra/helper.py | 1 + 12 files changed, 62 insertions(+) create mode 100644 infra/base-images/base-builder-javascript/Dockerfile create mode 100755 infra/base-images/base-builder/install_javascript.sh diff --git a/infra/base-images/base-builder-javascript/Dockerfile b/infra/base-images/base-builder-javascript/Dockerfile new file mode 100644 index 000000000..64e4fa529 --- /dev/null +++ b/infra/base-images/base-builder-javascript/Dockerfile @@ -0,0 +1,19 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ + +FROM gcr.io/oss-fuzz-base/base-builder + +RUN install_javascript.sh diff --git a/infra/base-images/base-builder/Dockerfile b/infra/base-images/base-builder/Dockerfile index b082836f7..883b4b78d 100644 --- a/infra/base-images/base-builder/Dockerfile +++ b/infra/base-images/base-builder/Dockerfile @@ -140,6 +140,7 @@ COPY cargo compile compile_afl compile_libfuzzer compile_honggfuzz \ # Go, java, and swift installation scripts. install_go.sh \ install_go_CodeIntelligenceTesting.sh \ + install_javascript.sh \ install_java.sh \ install_python.sh \ install_rust.sh \ diff --git a/infra/base-images/base-builder/install_javascript.sh b/infra/base-images/base-builder/install_javascript.sh new file mode 100755 index 000000000..c8d06c832 --- /dev/null +++ b/infra/base-images/base-builder/install_javascript.sh @@ -0,0 +1,16 @@ +#!/bin/bash -eux +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ diff --git a/infra/build/functions/base_images.py b/infra/build/functions/base_images.py index 50f72a3dc..59dc6942d 100644 --- a/infra/build/functions/base_images.py +++ b/infra/build/functions/base_images.py @@ -27,6 +27,7 @@ BASE_IMAGES = [ 'base-builder', 'base-builder-go', 'base-builder-go-codeintelligencetesting', + 'base-builder-javascript', 'base-builder-jvm', 'base-builder-python', 'base-builder-rust', diff --git a/infra/build/functions/build_and_push_test_images.py b/infra/build/functions/build_and_push_test_images.py index 86568da85..d6baf5576 100755 --- a/infra/build/functions/build_and_push_test_images.py +++ b/infra/build/functions/build_and_push_test_images.py @@ -160,6 +160,7 @@ def build_and_push_images(test_image_suffix): [ 'base-runner-debug', 'base-builder-go', + 'base-builder-javascript', 'base-builder-jvm', 'base-builder-python', 'base-builder-rust', diff --git a/infra/build/functions/build_lib.py b/infra/build/functions/build_lib.py index 8c0ff88e3..98180469d 100644 --- a/infra/build/functions/build_lib.py +++ b/infra/build/functions/build_lib.py @@ -299,6 +299,7 @@ def get_pull_test_images_steps(test_image_suffix): images = [ 'gcr.io/oss-fuzz-base/base-builder', 'gcr.io/oss-fuzz-base/base-builder-swift', + 'gcr.io/oss-fuzz-base/base-builder-javascript', 'gcr.io/oss-fuzz-base/base-builder-jvm', 'gcr.io/oss-fuzz-base/base-builder-go', 'gcr.io/oss-fuzz-base/base-builder-python', diff --git a/infra/build/functions/test_data/expected_trial_build_steps.json b/infra/build/functions/test_data/expected_trial_build_steps.json index 1cd2348dc..246438e09 100644 --- a/infra/build/functions/test_data/expected_trial_build_steps.json +++ b/infra/build/functions/test_data/expected_trial_build_steps.json @@ -42,6 +42,22 @@ "gcr.io/oss-fuzz-base/base-builder-swift" ] }, + { + "name": "gcr.io/cloud-builders/docker", + "args": [ + "pull", + "gcr.io/oss-fuzz-base/base-builder-javascript-testing-mybranch" + ], + "waitFor": "-" + }, + { + "name": "gcr.io/cloud-builders/docker", + "args": [ + "tag", + "gcr.io/oss-fuzz-base/base-builder-javascript-testing-mybranch", + "gcr.io/oss-fuzz-base/base-builder-javascript" + ] + }, { "name": "gcr.io/cloud-builders/docker", "args": [ diff --git a/infra/build/functions/trial_build_test.py b/infra/build/functions/trial_build_test.py index a250b50fa..e5e817ddd 100644 --- a/infra/build/functions/trial_build_test.py +++ b/infra/build/functions/trial_build_test.py @@ -83,5 +83,8 @@ class TrialBuildMainTest(unittest.TestCase): with open(expected_build_steps_path, 'r') as file_handle: expected_build_steps = json.load(file_handle) + # Snippet for updating this: + # f=open('/tmp/a', 'w') + # json.dump(mock_run_build.call_args_list[0][0][1], f); f.close() self.assertEqual(mock_run_build.call_args_list[0][0][1], expected_build_steps) diff --git a/infra/ci/build.py b/infra/ci/build.py index 21c17b3c5..a9538a210 100755 --- a/infra/ci/build.py +++ b/infra/ci/build.py @@ -234,6 +234,7 @@ def build_base_images(): 'base-builder', 'base-builder-go', 'base-builder-go-codeintelligencetesting', + 'base-builder-javascript', 'base-builder-jvm', 'base-builder-python', 'base-builder-rust', diff --git a/infra/cifuzz/run_fuzzers_entrypoint.py b/infra/cifuzz/run_fuzzers_entrypoint.py index 4777786c0..5182c7424 100644 --- a/infra/cifuzz/run_fuzzers_entrypoint.py +++ b/infra/cifuzz/run_fuzzers_entrypoint.py @@ -37,6 +37,7 @@ def delete_unneeded_docker_images(config): project_image, docker.BASE_BUILDER_TAG, docker.BASE_BUILDER_TAG + '-go', + docker.BASE_BUILDER_TAG + '-javascript', docker.BASE_BUILDER_TAG + '-jvm', docker.BASE_BUILDER_TAG + '-python', docker.BASE_BUILDER_TAG + '-rust', diff --git a/infra/constants.py b/infra/constants.py index 3309fb4ba..43a05efcb 100644 --- a/infra/constants.py +++ b/infra/constants.py @@ -25,6 +25,7 @@ LANGUAGES = [ 'c', 'c++', 'go', + 'javascript', 'jvm', 'python', 'rust', diff --git a/infra/helper.py b/infra/helper.py index 8c5befc90..988a93874 100755 --- a/infra/helper.py +++ b/infra/helper.py @@ -46,6 +46,7 @@ BASE_IMAGES = { 'gcr.io/oss-fuzz-base/base-runner-debug', ], 'go': ['gcr.io/oss-fuzz-base/base-builder-go'], + 'javascript': ['gcr.io/oss-fuzz-base/base-builder-javascript'], 'jvm': ['gcr.io/oss-fuzz-base/base-builder-jvm'], 'python': ['gcr.io/oss-fuzz-base/base-builder-python'], 'rust': ['gcr.io/oss-fuzz-base/base-builder-rust'],