Add files using upload-large-folder tool
Browse files- local-test-zookeeper-full-01/fuzz-tooling/infra/cifuzz/cloudbuild.yaml +52 -0
- local-test-zookeeper-full-01/fuzz-tooling/infra/cifuzz/http_utils.py +118 -0
- local-test-zookeeper-full-01/fuzz-tooling/infra/cifuzz/sarif_utils_test.py +128 -0
- local-test-zookeeper-full-01/fuzz-tooling/infra/experimental/SystemSan/PoEs/node-shell-quote-v1.7.3/Dockerfile +35 -0
- local-test-zookeeper-full-01/fuzz-tooling/infra/experimental/SystemSan/PoEs/node-shell-quote-v1.7.3/build.sh +22 -0
- local-test-zookeeper-full-01/fuzz-tooling/infra/experimental/SystemSan/PoEs/pytorch-lightning-1.5.10/Dockerfile +32 -0
- local-test-zookeeper-full-01/fuzz-tooling/infra/experimental/SystemSan/PoEs/pytorch-lightning-1.5.10/Makefile +12 -0
- local-test-zookeeper-full-01/fuzz-tooling/infra/experimental/SystemSan/PoEs/pytorch-lightning-1.5.10/vuln.dict +1 -0
- local-test-zookeeper-full-01/fuzz-tooling/infra/experimental/SystemSan/inspect_utils.h +39 -0
- local-test-zookeeper-full-01/fuzz-tooling/infra/experimental/SystemSan/target_file.cpp +32 -0
- local-test-zookeeper-full-01/fuzz-tooling/infra/experimental/chronos/Dockerfile +18 -0
- local-test-zookeeper-full-01/fuzz-tooling/infra/experimental/chronos/README.md +49 -0
- local-test-zookeeper-full-01/fuzz-tooling/infra/experimental/chronos/build_all.sh +33 -0
- local-test-zookeeper-full-01/fuzz-tooling/infra/experimental/chronos/build_cache_local.sh +163 -0
- local-test-zookeeper-full-01/fuzz-tooling/infra/experimental/chronos/build_on_cloudbuild.sh +26 -0
- local-test-zookeeper-full-01/fuzz-tooling/infra/experimental/chronos/chronos.sh +81 -0
- local-test-zookeeper-full-01/fuzz-tooling/infra/experimental/chronos/cloudbuild.yaml +58 -0
- local-test-zookeeper-full-01/fuzz-tooling/infra/experimental/chronos/e2e-replay-build.sh +63 -0
- local-test-zookeeper-full-01/fuzz-tooling/infra/experimental/chronos/match_artifacts.sh +35 -0
- local-test-zookeeper-full-01/fuzz-tooling/infra/experimental/chronos/prepare-ccache +22 -0
local-test-zookeeper-full-01/fuzz-tooling/infra/cifuzz/cloudbuild.yaml
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# TODO(metzman): Get rid of cifuzz-build-fuzzers and cifuzz-run-fuzzers.
|
| 2 |
+
steps:
|
| 3 |
+
- name: 'gcr.io/cloud-builders/docker'
|
| 4 |
+
args:
|
| 5 |
+
- build
|
| 6 |
+
- '-t'
|
| 7 |
+
- ghcr.io/aixcc-finals/cifuzz-base
|
| 8 |
+
- '-t'
|
| 9 |
+
- ghcr.io/aixcc-finals/cifuzz-base:v1
|
| 10 |
+
- '-f'
|
| 11 |
+
- infra/cifuzz/cifuzz-base/Dockerfile
|
| 12 |
+
- .
|
| 13 |
+
- name: 'gcr.io/cloud-builders/docker'
|
| 14 |
+
args:
|
| 15 |
+
- build
|
| 16 |
+
- '-t'
|
| 17 |
+
- ghcr.io/aixcc-finals/cifuzz-build-fuzzers
|
| 18 |
+
- '-t'
|
| 19 |
+
- ghcr.io/aixcc-finals/cifuzz-build-fuzzers:v1
|
| 20 |
+
- '-t'
|
| 21 |
+
- ghcr.io/aixcc-finals/clusterfuzzlite-build-fuzzers
|
| 22 |
+
- '-t'
|
| 23 |
+
- ghcr.io/aixcc-finals/clusterfuzzlite-build-fuzzers:v1
|
| 24 |
+
- '-f'
|
| 25 |
+
- infra/build_fuzzers.Dockerfile
|
| 26 |
+
- infra
|
| 27 |
+
- name: 'gcr.io/cloud-builders/docker'
|
| 28 |
+
args:
|
| 29 |
+
- build
|
| 30 |
+
- '-t'
|
| 31 |
+
- ghcr.io/aixcc-finals/cifuzz-run-fuzzers
|
| 32 |
+
- '-t'
|
| 33 |
+
- ghcr.io/aixcc-finals/cifuzz-run-fuzzers:v1
|
| 34 |
+
- '-t'
|
| 35 |
+
- ghcr.io/aixcc-finals/clusterfuzzlite-run-fuzzers
|
| 36 |
+
- '-t'
|
| 37 |
+
- ghcr.io/aixcc-finals/clusterfuzzlite-run-fuzzers:v1
|
| 38 |
+
- '-f'
|
| 39 |
+
- infra/run_fuzzers.Dockerfile
|
| 40 |
+
- infra
|
| 41 |
+
images:
|
| 42 |
+
- ghcr.io/aixcc-finals/cifuzz-base
|
| 43 |
+
- ghcr.io/aixcc-finals/cifuzz-base:v1
|
| 44 |
+
- ghcr.io/aixcc-finals/cifuzz-run-fuzzers
|
| 45 |
+
- ghcr.io/aixcc-finals/cifuzz-run-fuzzers:v1
|
| 46 |
+
- ghcr.io/aixcc-finals/cifuzz-build-fuzzers
|
| 47 |
+
- ghcr.io/aixcc-finals/cifuzz-build-fuzzers:v1
|
| 48 |
+
- ghcr.io/aixcc-finals/clusterfuzzlite-build-fuzzers
|
| 49 |
+
- ghcr.io/aixcc-finals/clusterfuzzlite-build-fuzzers:v1
|
| 50 |
+
- ghcr.io/aixcc-finals/clusterfuzzlite-run-fuzzers
|
| 51 |
+
- ghcr.io/aixcc-finals/clusterfuzzlite-run-fuzzers:v1
|
| 52 |
+
timeout: 1800s
|
local-test-zookeeper-full-01/fuzz-tooling/infra/cifuzz/http_utils.py
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2021 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
"""Utility module for HTTP."""
|
| 15 |
+
import json
|
| 16 |
+
import logging
|
| 17 |
+
import os
|
| 18 |
+
import sys
|
| 19 |
+
import tempfile
|
| 20 |
+
import zipfile
|
| 21 |
+
|
| 22 |
+
import requests
|
| 23 |
+
|
| 24 |
+
# pylint: disable=wrong-import-position,import-error
|
| 25 |
+
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
| 26 |
+
import retry
|
| 27 |
+
|
| 28 |
+
_DOWNLOAD_URL_RETRIES = 3
|
| 29 |
+
_DOWNLOAD_URL_BACKOFF = 1
|
| 30 |
+
_HTTP_REQUEST_TIMEOUT = 10
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
def download_and_unpack_zip(url, extract_directory, headers=None):
|
| 34 |
+
"""Downloads and unpacks a zip file from an HTTP URL.
|
| 35 |
+
|
| 36 |
+
Args:
|
| 37 |
+
url: A url to the zip file to be downloaded and unpacked.
|
| 38 |
+
extract_directory: The path where the zip file should be extracted to.
|
| 39 |
+
headers: (Optional) HTTP headers to send with the download request.
|
| 40 |
+
|
| 41 |
+
Returns:
|
| 42 |
+
True on success.
|
| 43 |
+
"""
|
| 44 |
+
if headers is None:
|
| 45 |
+
headers = {}
|
| 46 |
+
|
| 47 |
+
if not os.path.exists(extract_directory):
|
| 48 |
+
logging.error('Extract directory: %s does not exist.', extract_directory)
|
| 49 |
+
return False
|
| 50 |
+
|
| 51 |
+
# Gives the temporary zip file a unique identifier in the case that
|
| 52 |
+
# that download_and_unpack_zip is done in parallel.
|
| 53 |
+
with tempfile.NamedTemporaryFile(suffix='.zip') as tmp_file:
|
| 54 |
+
if not download_url(url, tmp_file.name, headers=headers):
|
| 55 |
+
return False
|
| 56 |
+
|
| 57 |
+
try:
|
| 58 |
+
with zipfile.ZipFile(tmp_file.name, 'r') as zip_file:
|
| 59 |
+
zip_file.extractall(extract_directory)
|
| 60 |
+
except zipfile.BadZipFile:
|
| 61 |
+
logging.error('Error unpacking zip from %s. Bad Zipfile.', url)
|
| 62 |
+
return False
|
| 63 |
+
|
| 64 |
+
return True
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
def download_url(*args, **kwargs):
|
| 68 |
+
"""Wrapper around _download_url that returns False if _download_url
|
| 69 |
+
exceptions."""
|
| 70 |
+
try:
|
| 71 |
+
return _download_url(*args, **kwargs)
|
| 72 |
+
except Exception: # pylint: disable=broad-except
|
| 73 |
+
return False
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
def get_json_from_url(url):
|
| 77 |
+
"""Gets a json object from a specified HTTP URL.
|
| 78 |
+
|
| 79 |
+
Args:
|
| 80 |
+
url: The url of the json to be downloaded.
|
| 81 |
+
|
| 82 |
+
Returns:
|
| 83 |
+
A dictionary deserialized from JSON or None on failure.
|
| 84 |
+
"""
|
| 85 |
+
try:
|
| 86 |
+
return requests.get(url, timeout=_HTTP_REQUEST_TIMEOUT).json()
|
| 87 |
+
except (ValueError, TypeError, json.JSONDecodeError,
|
| 88 |
+
requests.exceptions.ReadTimeout) as err:
|
| 89 |
+
logging.error('Loading json from url %s failed with: %s.', url, str(err))
|
| 90 |
+
return None
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
@retry.wrap(_DOWNLOAD_URL_RETRIES, _DOWNLOAD_URL_BACKOFF)
|
| 94 |
+
def _download_url(url, filename, headers=None):
|
| 95 |
+
"""Downloads the file located at |url|, using HTTP to |filename|.
|
| 96 |
+
|
| 97 |
+
Args:
|
| 98 |
+
url: A url to a file to download.
|
| 99 |
+
filename: The path the file should be downloaded to.
|
| 100 |
+
headers: (Optional) HTTP headers to send with the download request.
|
| 101 |
+
|
| 102 |
+
Returns:
|
| 103 |
+
True on success.
|
| 104 |
+
"""
|
| 105 |
+
if headers is None:
|
| 106 |
+
headers = {}
|
| 107 |
+
|
| 108 |
+
response = requests.get(url, headers=headers)
|
| 109 |
+
|
| 110 |
+
if response.status_code != 200:
|
| 111 |
+
logging.error('Unable to download from: %s. Code: %d. Content: %s.', url,
|
| 112 |
+
response.status_code, response.content)
|
| 113 |
+
return False
|
| 114 |
+
|
| 115 |
+
with open(filename, 'wb') as file_handle:
|
| 116 |
+
file_handle.write(response.content)
|
| 117 |
+
|
| 118 |
+
return True
|
local-test-zookeeper-full-01/fuzz-tooling/infra/cifuzz/sarif_utils_test.py
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2023 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
"""Tests for sarif_utils.py"""
|
| 15 |
+
import os
|
| 16 |
+
import unittest
|
| 17 |
+
from unittest import mock
|
| 18 |
+
|
| 19 |
+
import sarif_utils
|
| 20 |
+
|
| 21 |
+
CRASH_INFO_FILELINE = 403
|
| 22 |
+
|
| 23 |
+
TEST_DATA = os.path.join(os.path.dirname(__file__), 'test_data')
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
class GetSarifDataTest(unittest.TestCase):
|
| 27 |
+
"""Tests for get_sarif_data."""
|
| 28 |
+
|
| 29 |
+
def setUp(self):
|
| 30 |
+
self.maxDiff = None # pylint: disable=invalid-name
|
| 31 |
+
|
| 32 |
+
def test_get_sarif_data_none(self):
|
| 33 |
+
"""Tests get_sarif_data when there was no crash."""
|
| 34 |
+
self.assertEqual(sarif_utils.get_sarif_data(None, '/root/target'),
|
| 35 |
+
sarif_utils.SARIF_DATA)
|
| 36 |
+
|
| 37 |
+
def test_ordinary_case(self):
|
| 38 |
+
stacktrace_filename = os.path.join(TEST_DATA,
|
| 39 |
+
'sarif_utils_systemd_stack.txt')
|
| 40 |
+
with open(stacktrace_filename, 'r') as fp:
|
| 41 |
+
stacktrace = fp.read()
|
| 42 |
+
expected_result = {
|
| 43 |
+
'level': 'error',
|
| 44 |
+
'message': {
|
| 45 |
+
'text': 'Heap-buffer-overflow\nREAD 4'
|
| 46 |
+
},
|
| 47 |
+
'locations': [{
|
| 48 |
+
'physicalLocation': {
|
| 49 |
+
'artifactLocation': {
|
| 50 |
+
'uri': 'src/core/fuzz-unit-file.c',
|
| 51 |
+
'index': 0
|
| 52 |
+
},
|
| 53 |
+
'region': {
|
| 54 |
+
'startLine': 30,
|
| 55 |
+
# We don't have this granualarity fuzzing.
|
| 56 |
+
'startColumn': 1,
|
| 57 |
+
}
|
| 58 |
+
}
|
| 59 |
+
}],
|
| 60 |
+
'ruleId': 'heap-buffer-overflow',
|
| 61 |
+
'ruleIndex': 2
|
| 62 |
+
}
|
| 63 |
+
actual_result = sarif_utils.get_sarif_data(
|
| 64 |
+
stacktrace, '/root/target')['runs'][0]['results'][0]
|
| 65 |
+
self.assertEqual(actual_result, expected_result)
|
| 66 |
+
|
| 67 |
+
def test_llvmfuzzertestoneinput_case(self):
|
| 68 |
+
stacktrace_filename = os.path.join(TEST_DATA,
|
| 69 |
+
'sarif_utils_only_llvmfuzzer_stack.txt')
|
| 70 |
+
with open(stacktrace_filename, 'r') as fp:
|
| 71 |
+
stacktrace = fp.read()
|
| 72 |
+
actual_result = sarif_utils.get_sarif_data(
|
| 73 |
+
stacktrace, '/root/target')['runs'][0]['results']
|
| 74 |
+
self.assertEqual(actual_result, [])
|
| 75 |
+
|
| 76 |
+
def test_msan(self):
|
| 77 |
+
"""Tests that MSAN stacktraces don't exception."""
|
| 78 |
+
stacktrace_filename = os.path.join(TEST_DATA, 'sarif_utils_msan_stack.txt')
|
| 79 |
+
with open(stacktrace_filename, 'r') as fp:
|
| 80 |
+
stacktrace = fp.read()
|
| 81 |
+
|
| 82 |
+
actual_result = sarif_utils.get_sarif_data(stacktrace, '/root/target')
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
class RedactSrcPathTest(unittest.TestCase):
|
| 86 |
+
"""Tests for redact_src_path."""
|
| 87 |
+
|
| 88 |
+
def test_redact_src_path(self):
|
| 89 |
+
"""Tests redact_src_path."""
|
| 90 |
+
path = '/src/src-repo/subdir/file'
|
| 91 |
+
self.assertEqual(sarif_utils.redact_src_path(path), 'subdir/file')
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
def _get_mock_crash_info():
|
| 95 |
+
"""Returns a mock crash_info to be used in tests."""
|
| 96 |
+
stack_frame = mock.MagicMock()
|
| 97 |
+
stack_frame.filename = '/src/repo-dir/sub/vuln.cc'
|
| 98 |
+
stack_frame.function_name = 'vuln_func'
|
| 99 |
+
stack_frame.fileline = CRASH_INFO_FILELINE
|
| 100 |
+
crash1_frames = [stack_frame, stack_frame]
|
| 101 |
+
frames = [crash1_frames]
|
| 102 |
+
crash_info = mock.MagicMock()
|
| 103 |
+
crash_info.frames = frames
|
| 104 |
+
crash_info.crash_state = 'vuln_func\nvuln_func0\nvuln_func1'
|
| 105 |
+
return crash_info
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
class GetErrorSourceInfoTest(unittest.TestCase):
|
| 109 |
+
"""Tests for get_error_source_info."""
|
| 110 |
+
|
| 111 |
+
def test_redact_src_path(self):
|
| 112 |
+
"""Tests that get_error_source_info finds the right source info."""
|
| 113 |
+
crash_info = _get_mock_crash_info()
|
| 114 |
+
source_info = sarif_utils.get_error_source_info(crash_info)
|
| 115 |
+
expected_source_info = ('sub/vuln.cc', CRASH_INFO_FILELINE)
|
| 116 |
+
self.assertEqual(source_info, expected_source_info)
|
| 117 |
+
|
| 118 |
+
|
| 119 |
+
class GetRuleIndexTest(unittest.TestCase):
|
| 120 |
+
"""Tests for get_rule_index."""
|
| 121 |
+
CRASH_INFO_CRASH_TYPE = 'Heap-use-after-free READ 8'
|
| 122 |
+
|
| 123 |
+
def test_get_rule_index(self):
|
| 124 |
+
"""Tests that get_rule_index finds the right rule index."""
|
| 125 |
+
index = sarif_utils.get_rule_index(self.CRASH_INFO_CRASH_TYPE)
|
| 126 |
+
self.assertEqual(sarif_utils.SARIF_RULES[index]['id'],
|
| 127 |
+
'heap-use-after-free')
|
| 128 |
+
self.assertEqual(sarif_utils.get_rule_index('no-crashes'), 0)
|
local-test-zookeeper-full-01/fuzz-tooling/infra/experimental/SystemSan/PoEs/node-shell-quote-v1.7.3/Dockerfile
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2022 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
#
|
| 15 |
+
# Build and run the proof of error in shell-quote v1.7.3.
|
| 16 |
+
|
| 17 |
+
FROM ghcr.io/aixcc-finals/base-builder
|
| 18 |
+
|
| 19 |
+
RUN apt update && \
|
| 20 |
+
apt install -y \
|
| 21 |
+
vim \
|
| 22 |
+
npm && \
|
| 23 |
+
git clone \
|
| 24 |
+
--depth 1 \
|
| 25 |
+
https://github.com/substack/node-shell-quote.git && \
|
| 26 |
+
npm config set @gitlab-org:registry \
|
| 27 |
+
https://gitlab.com/api/v4/packages/npm/
|
| 28 |
+
|
| 29 |
+
COPY ./build.sh $SRC
|
| 30 |
+
RUN ./build.sh
|
| 31 |
+
|
| 32 |
+
COPY . $SRC
|
| 33 |
+
RUN make SystemSan
|
| 34 |
+
|
| 35 |
+
CMD ["make", "run"]
|
local-test-zookeeper-full-01/fuzz-tooling/infra/experimental/SystemSan/PoEs/node-shell-quote-v1.7.3/build.sh
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash -eu
|
| 2 |
+
# Copyright 2022 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
################################################################################
|
| 17 |
+
|
| 18 |
+
# Build and install project (using current CFLAGS, CXXFLAGS).
|
| 19 |
+
npm install ./node-shell-quote/
|
| 20 |
+
|
| 21 |
+
# Build fuzzers.
|
| 22 |
+
npm i -g @gitlab-org/jsfuzz
|
local-test-zookeeper-full-01/fuzz-tooling/infra/experimental/SystemSan/PoEs/pytorch-lightning-1.5.10/Dockerfile
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2022 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
#
|
| 15 |
+
# Build and run the proof of error in pytorch-lightning.
|
| 16 |
+
|
| 17 |
+
FROM ghcr.io/aixcc-finals/base-builder-python
|
| 18 |
+
|
| 19 |
+
RUN apt update && \
|
| 20 |
+
apt install -y vim && \
|
| 21 |
+
git clone \
|
| 22 |
+
--depth 1 \
|
| 23 |
+
--branch 1.5.10 \
|
| 24 |
+
https://github.com/PyTorchLightning/pytorch-lightning.git
|
| 25 |
+
|
| 26 |
+
COPY ./build.sh $SRC
|
| 27 |
+
RUN ./build.sh
|
| 28 |
+
|
| 29 |
+
COPY . $SRC
|
| 30 |
+
RUN make SystemSan
|
| 31 |
+
|
| 32 |
+
CMD ["make", "run"]
|
local-test-zookeeper-full-01/fuzz-tooling/infra/experimental/SystemSan/PoEs/pytorch-lightning-1.5.10/Makefile
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.POSIX:
|
| 2 |
+
CXX = clang++
|
| 3 |
+
CFLAGS = -std=c++17 -Wall -Wextra -O3 -g3
|
| 4 |
+
|
| 5 |
+
SystemSan: SystemSan.cpp
|
| 6 |
+
$(CXX) $(CFLAGS) -lpthread -o $@ $^
|
| 7 |
+
|
| 8 |
+
run: clean SystemSan fuzz_pytorch_lightning.py
|
| 9 |
+
./SystemSan ./fuzz_pytorch_lightning.py -dict=vuln.dict
|
| 10 |
+
|
| 11 |
+
clean:
|
| 12 |
+
rm -f SystemSan /tmp/tripwire
|
local-test-zookeeper-full-01/fuzz-tooling/infra/experimental/SystemSan/PoEs/pytorch-lightning-1.5.10/vuln.dict
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
"os.system('/tmp/tripwire')"
|
local-test-zookeeper-full-01/fuzz-tooling/infra/experimental/SystemSan/inspect_utils.h
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2022 Google LLC
|
| 3 |
+
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
/* A detector that uses ptrace to identify DNS arbitrary resolutions. */
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
/* POSIX */
|
| 20 |
+
#include <unistd.h>
|
| 21 |
+
|
| 22 |
+
#include <string>
|
| 23 |
+
#include <vector>
|
| 24 |
+
|
| 25 |
+
// Structure to know which thread id triggered the bug.
|
| 26 |
+
struct ThreadParent {
|
| 27 |
+
// Parent thread ID, ie creator.
|
| 28 |
+
pid_t parent_tid;
|
| 29 |
+
// Current thread ID ran exec to become another process.
|
| 30 |
+
bool ran_exec = false;
|
| 31 |
+
|
| 32 |
+
ThreadParent() : parent_tid(0) {}
|
| 33 |
+
ThreadParent(pid_t tid) : parent_tid(tid) {}
|
| 34 |
+
};
|
| 35 |
+
|
| 36 |
+
std::vector<std::byte> read_memory(pid_t pid, unsigned long long address,
|
| 37 |
+
size_t size);
|
| 38 |
+
|
| 39 |
+
void report_bug(std::string bug_type, pid_t tid);
|
local-test-zookeeper-full-01/fuzz-tooling/infra/experimental/SystemSan/target_file.cpp
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2022 Google LLC
|
| 3 |
+
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
/* A sample target program under test,
|
| 17 |
+
* /tmp/tripwire or other commands will be injected into its shell command */
|
| 18 |
+
|
| 19 |
+
#include <stdlib.h>
|
| 20 |
+
#include <stdio.h>
|
| 21 |
+
#include <string>
|
| 22 |
+
#include <iostream>
|
| 23 |
+
|
| 24 |
+
extern "C" int LLVMFuzzerTestOneInput(char* data, size_t size) {
|
| 25 |
+
std::string str(data, size);
|
| 26 |
+
std::cout << "INPUT" << str << std::endl;
|
| 27 |
+
FILE *fp = fopen(str.c_str(), "r");
|
| 28 |
+
if (fp) {
|
| 29 |
+
fclose(fp);
|
| 30 |
+
}
|
| 31 |
+
return 0;
|
| 32 |
+
}
|
local-test-zookeeper-full-01/fuzz-tooling/infra/experimental/chronos/Dockerfile
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2024 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
#
|
| 15 |
+
################################################################################
|
| 16 |
+
FROM gcr.io/cloud-builders/gcloud
|
| 17 |
+
|
| 18 |
+
RUN apt-get update && apt-get install -y jq
|
local-test-zookeeper-full-01/fuzz-tooling/infra/experimental/chronos/README.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Chronos: rebuilding OSS-Fuzz harnesses using cached builds
|
| 2 |
+
|
| 3 |
+
## Pre-built images.
|
| 4 |
+
|
| 5 |
+
Daily pre-built images are available at:
|
| 6 |
+
|
| 7 |
+
- `us-central1-docker.pkg.dev/oss-fuzz/oss-fuzz-gen/<PROJECT>-ofg-cached-address`
|
| 8 |
+
- `us-central1-docker.pkg.dev/oss-fuzz/oss-fuzz-gen/<PROJECT>-ofg-cached-coverage`
|
| 9 |
+
|
| 10 |
+
They can be used as drop-in replacements for the usual `gcr.io/oss-fuzz/<PROJECT>` images.
|
| 11 |
+
|
| 12 |
+
These images are generated in 2 ways:
|
| 13 |
+
- (Preferred) [Generate](https://github.com/google/oss-fuzz/blob/master/infra/base-images/base-builder/bash_parser.py)
|
| 14 |
+
a replay build script that can be re-run alongside existing build artifacts,
|
| 15 |
+
leveraging existing build system mechanisms to avoid rebuilding (e.g. running
|
| 16 |
+
`make` twice should not actually rebuild everything). This is error-prone, so
|
| 17 |
+
we validate the script works by running it.
|
| 18 |
+
- (Fallback, if the replay build script didn't work). We leverage
|
| 19 |
+
[ccache](https://ccache.dev/), to provide a compiler cache. This is often not
|
| 20 |
+
as fast as the replay build script, because some project builds spend
|
| 21 |
+
significant time doing non-compiler tasks (e.g. checking out submodules,
|
| 22 |
+
running configure scripts).
|
| 23 |
+
|
| 24 |
+
Note: this mechanism does not work for every single OSS-Fuzz project today. The
|
| 25 |
+
resulting image may either:
|
| 26 |
+
- Not provide much performance improvement compared with a normal image, or
|
| 27 |
+
- Not exist at all (if neither approach worked).
|
| 28 |
+
|
| 29 |
+
Stats from a recent run: <https://gist.github.com/oliverchang/abaf3a1106a2b923c0ac3a577410aaaa>
|
| 30 |
+
(Feb 3 2025).
|
| 31 |
+
|
| 32 |
+
## Usage locally
|
| 33 |
+
|
| 34 |
+
**Example 1: htslib**
|
| 35 |
+
|
| 36 |
+
From the OSS-Fuzz root
|
| 37 |
+
|
| 38 |
+
```sh
|
| 39 |
+
$ RUN_ALL=1 ./infra/experimental/chronos/build_cache_local.sh htslib c address
|
| 40 |
+
...
|
| 41 |
+
...
|
| 42 |
+
Vanilla compile time:
|
| 43 |
+
17
|
| 44 |
+
Replay worked
|
| 45 |
+
Replay compile time:
|
| 46 |
+
2
|
| 47 |
+
Ccache compile time:
|
| 48 |
+
9
|
| 49 |
+
```
|
local-test-zookeeper-full-01/fuzz-tooling/infra/experimental/chronos/build_all.sh
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Copyright 2024 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
################################################################################
|
| 17 |
+
|
| 18 |
+
# Build all C/C++ projects.
|
| 19 |
+
c_project_yaml=$(find projects/ -name project.yaml -exec grep -l 'language: c' {} \;)
|
| 20 |
+
projs=$(echo $c_project_yaml | xargs dirname | xargs basename -a | sort)
|
| 21 |
+
|
| 22 |
+
cd infra/experimental/chronos
|
| 23 |
+
|
| 24 |
+
for proj in $projs; do
|
| 25 |
+
if [ ! -f ../../../projects/$proj/Dockerfile ]; then
|
| 26 |
+
# Incomplete integration.
|
| 27 |
+
echo "Skipping $proj as it's incomplete."
|
| 28 |
+
continue
|
| 29 |
+
fi
|
| 30 |
+
|
| 31 |
+
echo ./build_on_cloudbuild.sh $proj c
|
| 32 |
+
./build_on_cloudbuild.sh $proj c
|
| 33 |
+
done
|
local-test-zookeeper-full-01/fuzz-tooling/infra/experimental/chronos/build_cache_local.sh
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash -eu
|
| 2 |
+
# Copyright 2024 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
################################################################################
|
| 17 |
+
|
| 18 |
+
_PROJECT=$1
|
| 19 |
+
_FUZZING_LANGUAGE=$2
|
| 20 |
+
_SANITIZER=${3:-address}
|
| 21 |
+
|
| 22 |
+
BASE=$PWD
|
| 23 |
+
|
| 24 |
+
# Final image is either ccache or replay script, depending on which worked.
|
| 25 |
+
FINAL_IMAGE_NAME=us-central1-docker.pkg.dev/oss-fuzz/oss-fuzz-gen/${_PROJECT}-ofg-cached-${_SANITIZER}
|
| 26 |
+
|
| 27 |
+
# Always build an image with ccache.
|
| 28 |
+
CCACHE_IMAGE_NAME=us-central1-docker.pkg.dev/oss-fuzz/oss-fuzz-gen/${_PROJECT}-ofg-ccache-${_SANITIZER}
|
| 29 |
+
|
| 30 |
+
# Step 1: build the base image
|
| 31 |
+
cd projects/${_PROJECT}
|
| 32 |
+
docker build -t gcr.io/oss-fuzz/${_PROJECT} .
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
# Step 2: create a container where `compile` has run which enables ccaching
|
| 36 |
+
# and also generates a replay build script.
|
| 37 |
+
cd ${BASE}
|
| 38 |
+
mkdir -p ccaches/${_PROJECT}
|
| 39 |
+
mkdir -p build/out/${_PROJECT}
|
| 40 |
+
B_START=$SECONDS
|
| 41 |
+
|
| 42 |
+
docker container rm -f ${_PROJECT}-origin-${_SANITIZER}
|
| 43 |
+
|
| 44 |
+
docker run \
|
| 45 |
+
--env=SANITIZER=${_SANITIZER} \
|
| 46 |
+
--env=CCACHE_DIR=/workspace/ccache \
|
| 47 |
+
--env=FUZZING_LANGUAGE=${_FUZZING_LANGUAGE} \
|
| 48 |
+
--env=CAPTURE_REPLAY_SCRIPT=1 \
|
| 49 |
+
--name=${_PROJECT}-origin-${_SANITIZER} \
|
| 50 |
+
-v=$PWD/ccaches/${_PROJECT}/ccache:/workspace/ccache \
|
| 51 |
+
-v=$PWD/build/out/${_PROJECT}/:/out/ \
|
| 52 |
+
gcr.io/oss-fuzz/${_PROJECT} \
|
| 53 |
+
/bin/bash -c \
|
| 54 |
+
"export PATH=/ccache/bin:\$PATH && compile"
|
| 55 |
+
B_TIME=$(($SECONDS - $B_START))
|
| 56 |
+
|
| 57 |
+
# Step 3: save (commit, locally) the cached container as an image
|
| 58 |
+
docker container commit -c "ENV REPLAY_ENABLED=1" -c "ENV CAPTURE_REPLAY_SCRIPT=" ${_PROJECT}-origin-${_SANITIZER} $FINAL_IMAGE_NAME
|
| 59 |
+
|
| 60 |
+
# Step 4: save the list of executables created from a vanilla build. This is
|
| 61 |
+
# needed for validating if replay and ccaching works.
|
| 62 |
+
# notes: run a shell the container with e.g.
|
| 63 |
+
# `docker run --entrypoint /bin/bash -it local/ossfuzz/htslib-origin-address`
|
| 64 |
+
executables_vanilla="$(find ./build/out/${_PROJECT} -executable -type f | sort)"
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
# Step 5: Build with replay enabled, and validate the executables are the same
|
| 68 |
+
# in terms of naming.
|
| 69 |
+
# Note that an important step is removing everything in $OUT/ which is done
|
| 70 |
+
# in the docker command.
|
| 71 |
+
R_START=$SECONDS
|
| 72 |
+
docker run \
|
| 73 |
+
--rm \
|
| 74 |
+
--env=SANITIZER=${_SANITIZER} \
|
| 75 |
+
--env=FUZZING_LANGUAGE=${_FUZZING_LANGUAGE} \
|
| 76 |
+
-v=$PWD/build/out/${_PROJECT}/:/out/ \
|
| 77 |
+
--name=${_PROJECT}-origin-${_SANITIZER}-replay-recached \
|
| 78 |
+
$FINAL_IMAGE_NAME \
|
| 79 |
+
/bin/bash -c \
|
| 80 |
+
"export PATH=/ccache/bin:\$PATH && rm -rf /out/* && compile"
|
| 81 |
+
R_TIME=$(($SECONDS - $R_START))
|
| 82 |
+
|
| 83 |
+
# Step 6: Extract the newly build executables
|
| 84 |
+
executables_replay="$(find ./build/out/${_PROJECT}/ -executable -type f | sort)"
|
| 85 |
+
|
| 86 |
+
echo "Executables vanilla: "
|
| 87 |
+
echo ${executables_vanilla}
|
| 88 |
+
|
| 89 |
+
echo "------------------------------------------------------"
|
| 90 |
+
echo "Executables replay: "
|
| 91 |
+
echo ${executables_replay}
|
| 92 |
+
|
| 93 |
+
REPLAY_WORKED=
|
| 94 |
+
|
| 95 |
+
# Step 7: match executables from vanilla builds and replay builds.
|
| 96 |
+
# If this step is successful, then the process can exit as it's ready.
|
| 97 |
+
if [[ "$executables_replay" == "$executables_vanilla" ]]
|
| 98 |
+
then
|
| 99 |
+
REPLAY_WORKED=1
|
| 100 |
+
|
| 101 |
+
if [ -z "${RUN_ALL+1}" ]; then
|
| 102 |
+
echo "${_PROJECT}: Replay worked."
|
| 103 |
+
echo "${_PROJECT}: Compile times: Vanilla=${B_TIME}; Replay=${R_TIME};"
|
| 104 |
+
exit 0
|
| 105 |
+
fi
|
| 106 |
+
else
|
| 107 |
+
echo "${_PROJECT}: Replay did not work"
|
| 108 |
+
R_TIME="N/A"
|
| 109 |
+
fi
|
| 110 |
+
|
| 111 |
+
# Step 8: prepare Dockerfile for ccache
|
| 112 |
+
cp -rf ccaches/${_PROJECT}/ccache ./projects/${_PROJECT}/ccache-cache
|
| 113 |
+
|
| 114 |
+
infra/experimental/chronos/prepare-ccache ${_PROJECT}
|
| 115 |
+
|
| 116 |
+
cd projects/${_PROJECT}
|
| 117 |
+
|
| 118 |
+
# Step 9: Build an image with CCache's new items (modifications are done on the
|
| 119 |
+
# dockerfile)
|
| 120 |
+
docker build -t $CCACHE_IMAGE_NAME .
|
| 121 |
+
|
| 122 |
+
cd ${BASE}
|
| 123 |
+
|
| 124 |
+
# Step 10: Run a `compile` with ccache's image.
|
| 125 |
+
# Run the ccache build
|
| 126 |
+
A_START=$SECONDS
|
| 127 |
+
docker run \
|
| 128 |
+
--rm \
|
| 129 |
+
--env=SANITIZER=${_SANITIZER} \
|
| 130 |
+
--env=FUZZING_LANGUAGE=${_FUZZING_LANGUAGE} \
|
| 131 |
+
--name=${_PROJECT}-origin-${_SANITIZER}-recached \
|
| 132 |
+
-v=$PWD/build/out/${_PROJECT}/:/out/ \
|
| 133 |
+
$CCACHE_IMAGE_NAME \
|
| 134 |
+
/bin/bash -c \
|
| 135 |
+
"export PATH=/ccache/bin:\$PATH && rm -rf /out/* && compile"
|
| 136 |
+
A_TIME=$(($SECONDS - $A_START))
|
| 137 |
+
|
| 138 |
+
# Step 11: extract the executables from the ccache build
|
| 139 |
+
executables_ccache="$(find ./build/out/${_PROJECT}/ -executable -type f | sort)"
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
# Step 12: validate the ccache builds are successful
|
| 143 |
+
if [[ "$executables_ccache" == "$executables_vanilla" ]]
|
| 144 |
+
then
|
| 145 |
+
echo "${_PROJECT}: Compile times: Vanilla=${B_TIME}; Replay=${R_TIME}; CCache=${A_TIME};"
|
| 146 |
+
|
| 147 |
+
if [[ -z "${REPLAY_WORKED}" || ${R_TIME} -gt ${A_TIME} ]]; then
|
| 148 |
+
if [ ${R_TIME} -gt ${A_TIME} ]; then
|
| 149 |
+
echo "Replay was slower than ccache."
|
| 150 |
+
fi
|
| 151 |
+
|
| 152 |
+
# Replay didn't work or was slower, so make the default "cached" image use the ccache one.
|
| 153 |
+
docker image tag \
|
| 154 |
+
$CCACHE_IMAGE_NAME \
|
| 155 |
+
$FINAL_IMAGE_NAME
|
| 156 |
+
fi
|
| 157 |
+
|
| 158 |
+
exit 0
|
| 159 |
+
else
|
| 160 |
+
echo "${_PROJECT}: Replay and ccaching did not work."
|
| 161 |
+
exit 1
|
| 162 |
+
fi
|
| 163 |
+
|
local-test-zookeeper-full-01/fuzz-tooling/infra/experimental/chronos/build_on_cloudbuild.sh
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Copyright 2024 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
################################################################################
|
| 17 |
+
PROJECT=$1
|
| 18 |
+
FUZZING_LANGUAGE=$2
|
| 19 |
+
|
| 20 |
+
gcloud builds submit "https://github.com/google/oss-fuzz" \
|
| 21 |
+
--async \
|
| 22 |
+
--git-source-revision=master \
|
| 23 |
+
--config=cloudbuild.yaml \
|
| 24 |
+
--substitutions=_PROJECT=$PROJECT,_FUZZING_LANGUAGE=$FUZZING_LANGUAGE \
|
| 25 |
+
--project=oss-fuzz \
|
| 26 |
+
--region=us-central1
|
local-test-zookeeper-full-01/fuzz-tooling/infra/experimental/chronos/chronos.sh
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2024 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
#
|
| 15 |
+
################################################################################
|
| 16 |
+
|
| 17 |
+
# This script records the ENV and commands needed for fuzz target recompilation.
|
| 18 |
+
# It intercepts bash commands to save: 1) the ENV variable values before
|
| 19 |
+
# building the fuzz target (`recompile_env.sh`) and 2) all subsequent bash
|
| 20 |
+
# commands from that point (`recompile`). Combined with Docker, this setup
|
| 21 |
+
# allows for recompiling the fuzz target without rebuilding the entire project.
|
| 22 |
+
# Usage:
|
| 23 |
+
# 1. Set FUZZ_TARGET (e.g., in project's Dockerfile)
|
| 24 |
+
# 2. Source this file before compiling the fuzz target (e.g., source chronos.sh
|
| 25 |
+
# at the beginning of project's build.sh).
|
| 26 |
+
|
| 27 |
+
export START_RECORDING="false"
|
| 28 |
+
RECOMPILE_ENV="/usr/local/bin/recompile_env.sh"
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
# Initialize the recompile script as compile in case Chronos did not trap any
|
| 32 |
+
# command containing the fuzz target.
|
| 33 |
+
initialize_recompile_script() {
|
| 34 |
+
export RECOMPILE_SCRIPT="/usr/local/bin/recompile"
|
| 35 |
+
cp "/usr/local/bin/compile" "$RECOMPILE_SCRIPT"
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
reset_recompile_script() {
|
| 39 |
+
rm "$RECOMPILE_SCRIPT"
|
| 40 |
+
echo "#!/bin/bash" > "$RECOMPILE_SCRIPT"
|
| 41 |
+
echo "source $RECOMPILE_ENV" >> "$RECOMPILE_SCRIPT"
|
| 42 |
+
chmod +x "$RECOMPILE_SCRIPT"
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
# Execute or record command for recompilation.
|
| 47 |
+
execute_or_record_command() {
|
| 48 |
+
record_command() {
|
| 49 |
+
echo "cd \"$(pwd)\"" >> "$RECOMPILE_SCRIPT"
|
| 50 |
+
echo "$@" >> "$RECOMPILE_SCRIPT"
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
# Check if any element in the command array contains the FUZZ_TARGET.
|
| 54 |
+
if [[ "$BASH_COMMAND" == *"$FUZZ_TARGET"* ]]; then
|
| 55 |
+
export START_RECORDING="true"
|
| 56 |
+
# Save all environment variables, excluding read-only ones
|
| 57 |
+
reset_recompile_script
|
| 58 |
+
declare -p | grep -Ev 'declare -[^ ]*r[^ ]*' > "$RECOMPILE_ENV"
|
| 59 |
+
fi
|
| 60 |
+
|
| 61 |
+
if [[ "$START_RECORDING" == "true" ]]; then
|
| 62 |
+
record_command "$BASH_COMMAND"
|
| 63 |
+
echo "Recorded execution of: $BASH_COMMAND"
|
| 64 |
+
fi
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
main() {
|
| 69 |
+
# Initialize.
|
| 70 |
+
initialize_recompile_script
|
| 71 |
+
|
| 72 |
+
# Set up trap for DEBUG to intercept commands.
|
| 73 |
+
trap 'execute_or_record_command' DEBUG
|
| 74 |
+
|
| 75 |
+
# Enable extended debugging mode
|
| 76 |
+
shopt -s extdebug
|
| 77 |
+
# Ensure trap works in subshells and functions.
|
| 78 |
+
set -T
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
main
|
local-test-zookeeper-full-01/fuzz-tooling/infra/experimental/chronos/cloudbuild.yaml
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2024 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
#
|
| 15 |
+
################################################################################
|
| 16 |
+
# CloudBuild for generating Chronos-cached images.
|
| 17 |
+
# Supports building by way of ccache now.
|
| 18 |
+
# High-level steps:
|
| 19 |
+
# 1) Build image for project
|
| 20 |
+
# 2) Run an ASAN build and store ccache
|
| 21 |
+
# 3) Copy ccache cache to host and copy into project's OSS-Fuzz folder
|
| 22 |
+
# 4) Build image for project and copy ccache in, storing image as *-ofg-cache-address
|
| 23 |
+
# 5) Run an coverage build and store ccache
|
| 24 |
+
# 6) Copy ccache cache to host and copy into project's OSS-Fuzz folder
|
| 25 |
+
# 7) Build image for project and copy ccache in, storing image as *-ofg-cache-coverage
|
| 26 |
+
# TODO (David): add support for use of dedicated replay_build.sh
|
| 27 |
+
steps:
|
| 28 |
+
- name: 'gcr.io/cloud-builders/docker'
|
| 29 |
+
entrypoint: /bin/bash
|
| 30 |
+
args:
|
| 31 |
+
- /workspace/infra/experimental/chronos/build_cache_local.sh
|
| 32 |
+
- ${_PROJECT}
|
| 33 |
+
- ${_FUZZING_LANGUAGE}
|
| 34 |
+
- address
|
| 35 |
+
env:
|
| 36 |
+
- RUN_ALL=1
|
| 37 |
+
- name: 'gcr.io/cloud-builders/docker'
|
| 38 |
+
entrypoint: /bin/bash
|
| 39 |
+
args:
|
| 40 |
+
- /workspace/infra/experimental/chronos/build_cache_local.sh
|
| 41 |
+
- ${_PROJECT}
|
| 42 |
+
- ${_FUZZING_LANGUAGE}
|
| 43 |
+
- coverage
|
| 44 |
+
env:
|
| 45 |
+
- RUN_ALL=1
|
| 46 |
+
images:
|
| 47 |
+
- us-central1-docker.pkg.dev/oss-fuzz/oss-fuzz-gen/${_PROJECT}-ofg-cached-address
|
| 48 |
+
- us-central1-docker.pkg.dev/oss-fuzz/oss-fuzz-gen/${_PROJECT}-ofg-cached-coverage
|
| 49 |
+
- us-central1-docker.pkg.dev/oss-fuzz/oss-fuzz-gen/${_PROJECT}-ofg-ccache-address
|
| 50 |
+
- us-central1-docker.pkg.dev/oss-fuzz/oss-fuzz-gen/${_PROJECT}-ofg-ccache-coverage
|
| 51 |
+
timeout: 72000s # 20 hours, same as build_lib.py
|
| 52 |
+
logsBucket: oss-fuzz-gcb-logs
|
| 53 |
+
tags:
|
| 54 |
+
- ${_PROJECT}
|
| 55 |
+
- chronos
|
| 56 |
+
options:
|
| 57 |
+
pool:
|
| 58 |
+
name: projects/oss-fuzz/locations/us-central1/workerPools/buildpool-chronos
|
local-test-zookeeper-full-01/fuzz-tooling/infra/experimental/chronos/e2e-replay-build.sh
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/bash
|
| 2 |
+
# Copyright 2024 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
################################################################################
|
| 17 |
+
|
| 18 |
+
# Sample projects: simd, wt, libheif, htslib
|
| 19 |
+
PROJECT=liblouis
|
| 20 |
+
LOG=replay-${PROJECT}.txt
|
| 21 |
+
OUT1=replay-out-${PROJECT}-1
|
| 22 |
+
OUT2=replay-out-${PROJECT}-2
|
| 23 |
+
python infra/helper.py build_image --no-pull "$PROJECT"
|
| 24 |
+
|
| 25 |
+
# AddressSanitizer.
|
| 26 |
+
mkdir -p build/out/${PROJECT}
|
| 27 |
+
echo "start" >> ${LOG}
|
| 28 |
+
echo $(date +%Y:%m:%d:%H:%M:%S) >> ${LOG}
|
| 29 |
+
# Remove container name we are about to use.
|
| 30 |
+
docker container rm "${PROJECT}-origin-asan"
|
| 31 |
+
|
| 32 |
+
# Build once, clean container if needed
|
| 33 |
+
docker run -v $PWD/build/out/${PROJECT}:/out \
|
| 34 |
+
-ti --entrypoint="/bin/sh" \
|
| 35 |
+
--env FUZZING_LANGUAGE=c --env SANITIZER="address" \
|
| 36 |
+
--name "${PROJECT}-origin-asan" \
|
| 37 |
+
"gcr.io/oss-fuzz/${PROJECT}" -c "compile"
|
| 38 |
+
|
| 39 |
+
# Copy outs and log data
|
| 40 |
+
cp -rf $PWD/build/out/${PROJECT} ${OUT1}
|
| 41 |
+
rm -rf $PWD/build/out/${PROJECT}
|
| 42 |
+
ls -la $PWD/build/out/ >> ${LOG}
|
| 43 |
+
echo "next" >> ${LOG}
|
| 44 |
+
echo $(date +%Y:%m:%d:%H:%M:%S) >> ${LOG}
|
| 45 |
+
docker commit "${PROJECT}-origin-asan" "gcr.io/oss-fuzz/${PROJECT}-ofg-cached-asan"
|
| 46 |
+
|
| 47 |
+
# Run the replay command
|
| 48 |
+
docker run -v $PWD/build/out/${PROJECT}:/out \
|
| 49 |
+
-e REPLAY_ENABLED=1 -ti --entrypoint="/bin/sh" \
|
| 50 |
+
--env FUZZING_LANGUAGE=c --env SANITIZER="address" \
|
| 51 |
+
"gcr.io/oss-fuzz/${PROJECT}-ofg-cached-asan" -c "compile"
|
| 52 |
+
echo "finish" >> ${LOG}
|
| 53 |
+
echo $(date +%Y:%m:%d:%H:%M:%S) >> ${LOG}
|
| 54 |
+
cp -rf $PWD/build/out/${PROJECT} ${OUT2}
|
| 55 |
+
|
| 56 |
+
# Now match the artifacts
|
| 57 |
+
SUCCESS=$(infra/experimental/chronos/match_artifacts $OUT1 $OUT2)
|
| 58 |
+
|
| 59 |
+
if [[ $SUCCESS -eq 0 ]]; then
|
| 60 |
+
echo "SUCCESS REPLAY" >> ${LOG}
|
| 61 |
+
else
|
| 62 |
+
echo "FAIL REPLAY" >> ${LOG}
|
| 63 |
+
fi
|
local-test-zookeeper-full-01/fuzz-tooling/infra/experimental/chronos/match_artifacts.sh
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/bash -eux
|
| 2 |
+
# Copyright 2024 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
################################################################################
|
| 17 |
+
|
| 18 |
+
CMP1=$1
|
| 19 |
+
CMP2=$2
|
| 20 |
+
|
| 21 |
+
for exec1 in $(find $CMP1/ -type f -executable); do
|
| 22 |
+
base=$(basename $exec1)
|
| 23 |
+
|
| 24 |
+
exec2=$CMP2/${base}
|
| 25 |
+
if [ ! -f ${exec2} ]; then
|
| 26 |
+
exit 1
|
| 27 |
+
fi
|
| 28 |
+
|
| 29 |
+
comparison=$(cmp --silent $exec1 $exec2; echo $?)
|
| 30 |
+
if [[ $comparison -ne 0 ]]; then
|
| 31 |
+
exit 1
|
| 32 |
+
fi
|
| 33 |
+
done
|
| 34 |
+
|
| 35 |
+
exit 0
|
local-test-zookeeper-full-01/fuzz-tooling/infra/experimental/chronos/prepare-ccache
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/bash
|
| 2 |
+
# Copyright 2024 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
################################################################################
|
| 17 |
+
|
| 18 |
+
PROJECT=$1
|
| 19 |
+
{
|
| 20 |
+
echo "COPY ccache-cache/ /ccache/cache";
|
| 21 |
+
echo "ENV PATH=\"/ccache/bin:\$PATH\""
|
| 22 |
+
} >> "projects/$PROJECT/Dockerfile"
|