Kitxuuu commited on
Commit
1960c82
·
verified ·
1 Parent(s): e05e869

Add files using upload-large-folder tool

Browse files
Files changed (20) hide show
  1. local-test-tika-delta-04/fuzz-tooling/infra/cifuzz/actions/build_fuzzers/action.yml +55 -0
  2. local-test-tika-delta-04/fuzz-tooling/infra/cifuzz/cifuzz-base/Dockerfile +44 -0
  3. local-test-tika-delta-04/fuzz-tooling/infra/cifuzz/filestore/filesystem/__init__.py +107 -0
  4. local-test-tika-delta-04/fuzz-tooling/infra/cifuzz/filestore/github_actions/__init__.py +179 -0
  5. local-test-tika-delta-04/fuzz-tooling/infra/cifuzz/filestore/github_actions/github_api_test.py +41 -0
  6. local-test-tika-delta-04/fuzz-tooling/infra/cifuzz/filestore/github_actions/upload.js +45 -0
  7. local-test-tika-delta-04/fuzz-tooling/infra/cifuzz/platform_config/__init__.py +124 -0
  8. local-test-tika-delta-04/fuzz-tooling/infra/cifuzz/platform_config/gcb.py +40 -0
  9. local-test-tika-delta-04/fuzz-tooling/infra/cifuzz/platform_config/github.py +146 -0
  10. local-test-tika-delta-04/fuzz-tooling/infra/cifuzz/platform_config/gitlab.py +78 -0
  11. local-test-tika-delta-04/fuzz-tooling/infra/cifuzz/platform_config/platform_config_test.py +82 -0
  12. local-test-tika-delta-04/fuzz-tooling/infra/cifuzz/platform_config/prow.py +64 -0
  13. local-test-tika-delta-04/fuzz-tooling/infra/cifuzz/platform_config/standalone.py +33 -0
  14. local-test-tika-delta-04/fuzz-tooling/infra/cifuzz/test_data/msan_crash_fuzzer_bug_summary.txt +22 -0
  15. local-test-tika-delta-04/fuzz-tooling/infra/cifuzz/test_data/msan_crash_fuzzer_output.txt +39 -0
  16. local-test-tika-delta-04/fuzz-tooling/infra/cifuzz/test_data/sarif_utils_msan_stack.txt +62 -0
  17. local-test-tika-delta-04/fuzz-tooling/infra/experimental/SystemSan/PoEs/pytorch-lightning-1.5.10/Dockerfile +32 -0
  18. local-test-tika-delta-04/fuzz-tooling/infra/experimental/SystemSan/PoEs/pytorch-lightning-1.5.10/Makefile +12 -0
  19. local-test-tika-delta-04/fuzz-tooling/infra/experimental/chronos/build_cache_local.sh +163 -0
  20. local-test-tika-delta-04/fuzz-tooling/infra/experimental/sanitizers/ExecSan/README.md +3 -0
local-test-tika-delta-04/fuzz-tooling/infra/cifuzz/actions/build_fuzzers/action.yml ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # action.yml
2
+ name: 'build-fuzzers'
3
+ description: "Builds an OSS-Fuzz project's fuzzers."
4
+ inputs:
5
+ oss-fuzz-project-name:
6
+ description: 'Name of the corresponding OSS-Fuzz project.'
7
+ required: true
8
+ language:
9
+ description: 'Programming language project is written in.'
10
+ required: false
11
+ default: 'c++'
12
+ dry-run:
13
+ description: 'If set, run the action without actually reporting a failure.'
14
+ default: false
15
+ allowed-broken-targets-percentage:
16
+ description: 'The percentage of broken targets allowed in bad_build_check.'
17
+ required: false
18
+ sanitizer:
19
+ description: 'The sanitizer to build the fuzzers with.'
20
+ default: 'address'
21
+ architecture:
22
+ description: 'The architecture used to build the fuzzers.'
23
+ default: 'x86_64'
24
+ project-src-path:
25
+ description: "The path to the project's source code checkout."
26
+ required: false
27
+ bad-build-check:
28
+ description: "Whether or not OSS-Fuzz's check for bad builds should be done."
29
+ required: false
30
+ default: true
31
+ keep-unaffected-fuzz-targets:
32
+ description: "Whether to keep unaffected fuzzers or delete them."
33
+ required: false
34
+ default: false
35
+ output-sarif:
36
+ description: "Whether to output fuzzing results to SARIF."
37
+ required: false
38
+ default: false
39
+ runs:
40
+ using: 'docker'
41
+ image: '../../../build_fuzzers.Dockerfile'
42
+ env:
43
+ OSS_FUZZ_PROJECT_NAME: ${{ inputs.oss-fuzz-project-name }}
44
+ LANGUAGE: ${{ inputs.language }}
45
+ DRY_RUN: ${{ inputs.dry-run}}
46
+ ALLOWED_BROKEN_TARGETS_PERCENTAGE: ${{ inputs.allowed-broken-targets-percentage}}
47
+ SANITIZER: ${{ inputs.sanitizer }}
48
+ ARCHITECTURE: ${{ inputs.architecture }}
49
+ PROJECT_SRC_PATH: ${{ inputs.project-src-path }}
50
+ LOW_DISK_SPACE: 'True'
51
+ BAD_BUILD_CHECK: ${{ inputs.bad-build-check }}
52
+ CIFUZZ_DEBUG: 'True'
53
+ CFL_PLATFORM: 'github'
54
+ KEEP_UNAFFECTED_FUZZ_TARGETS: ${{ inputs.keep-unaffected-fuzz-targets }}
55
+ OUTPUT_SARIF: ${{ inputs.output-sarif }}
local-test-tika-delta-04/fuzz-tooling/infra/cifuzz/cifuzz-base/Dockerfile ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2020 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
+ FROM ghcr.io/aixcc-finals/base-runner
18
+
19
+ RUN apt-get update && \
20
+ apt-get install -y systemd && \
21
+ wget https://download.docker.com/linux/ubuntu/dists/focal/pool/stable/amd64/docker-ce-cli_20.10.8~3-0~ubuntu-focal_amd64.deb -O /tmp/docker-ce.deb && \
22
+ dpkg -i /tmp/docker-ce.deb && \
23
+ rm /tmp/docker-ce.deb
24
+
25
+ ENV PATH=/opt/gcloud/google-cloud-sdk/bin/:$PATH
26
+ ENV OSS_FUZZ_ROOT=/opt/oss-fuzz
27
+
28
+ # Do this step before copying to make rebuilding faster when developing.
29
+ COPY ./infra/cifuzz/requirements.txt /tmp/requirements.txt
30
+ RUN python3 -m pip install -r /tmp/requirements.txt && rm /tmp/requirements.txt
31
+
32
+ ADD . ${OSS_FUZZ_ROOT}
33
+ # Don't use the default npm location since jazzer.js can break us.
34
+ # This means javascript needed by cifuzz/clusterfuzzlite must be executed in
35
+ # OSS_FUZZ_ROOT.
36
+ RUN cd ${OSS_FUZZ_ROOT} && npm install ${OSS_FUZZ_ROOT}/infra/cifuzz
37
+
38
+
39
+ ENV PYTHONUNBUFFERED=1
40
+
41
+ # Python file to execute when the docker container starts up.
42
+ # We can't use the env var $OSS_FUZZ_ROOT here. Since it's a constant env var,
43
+ # just expand to '/opt/oss-fuzz'.
44
+ ENTRYPOINT ["python3", "/opt/oss-fuzz/infra/cifuzz/cifuzz_combined_entrypoint.py"]
local-test-tika-delta-04/fuzz-tooling/infra/cifuzz/filestore/filesystem/__init__.py ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ """Filestore implementation using a filesystem directory."""
15
+ import logging
16
+ import os
17
+ import shutil
18
+ import subprocess
19
+ import sys
20
+
21
+ from distutils import dir_util
22
+
23
+ # pylint: disable=wrong-import-position,import-error
24
+ sys.path.append(
25
+ os.path.join(os.path.dirname(os.path.abspath(__file__)), os.pardir,
26
+ os.pardir, os.pardir))
27
+ import filestore
28
+
29
+
30
+ def recursive_list_dir(directory):
31
+ """Returns list of all files in |directory|, including those in
32
+ subdirectories."""
33
+ files = []
34
+ for root, _, filenames in os.walk(directory):
35
+ for filename in filenames:
36
+ files.append(os.path.join(root, filename))
37
+ return files
38
+
39
+
40
+ class FilesystemFilestore(filestore.BaseFilestore):
41
+ """Filesystem implementation using a filesystem directory."""
42
+ BUILD_DIR = 'build'
43
+ CRASHES_DIR = 'crashes'
44
+ CORPUS_DIR = 'corpus'
45
+ COVERAGE_DIR = 'coverage'
46
+
47
+ def __init__(self, config):
48
+ super().__init__(config)
49
+ self._filestore_root_dir = self.config.platform_conf.filestore_root_dir
50
+
51
+ def _get_filestore_path(self, name, prefix_dir):
52
+ """Returns the filesystem path in the filestore for |name| and
53
+ |prefix_dir|."""
54
+ return os.path.join(self._filestore_root_dir, prefix_dir, name)
55
+
56
+ def _upload_directory(self, name, directory, prefix, delete=False):
57
+ filestore_path = self._get_filestore_path(name, prefix)
58
+ if os.path.exists(filestore_path):
59
+ initial_files = set(recursive_list_dir(filestore_path))
60
+ else:
61
+ initial_files = set()
62
+
63
+ # Make directory and any parents.
64
+ os.makedirs(filestore_path, exist_ok=True)
65
+ copied_files = set(dir_util.copy_tree(directory, filestore_path))
66
+ if not delete:
67
+ return True
68
+
69
+ files_to_delete = initial_files - copied_files
70
+ for file_path in files_to_delete:
71
+ os.remove(file_path)
72
+ return True
73
+
74
+ def _download_directory(self, name, dst_directory, prefix):
75
+ filestore_path = self._get_filestore_path(name, prefix)
76
+ return dir_util.copy_tree(filestore_path, dst_directory)
77
+
78
+ def upload_crashes(self, name, directory):
79
+ """Uploads the crashes at |directory| to |name|."""
80
+ return self._upload_directory(name, directory, self.CRASHES_DIR)
81
+
82
+ def upload_corpus(self, name, directory, replace=False):
83
+ """Uploads the crashes at |directory| to |name|."""
84
+ return self._upload_directory(name,
85
+ directory,
86
+ self.CORPUS_DIR,
87
+ delete=replace)
88
+
89
+ def upload_build(self, name, directory):
90
+ """Uploads the build located at |directory| to |name|."""
91
+ return self._upload_directory(name, directory, self.BUILD_DIR)
92
+
93
+ def upload_coverage(self, name, directory):
94
+ """Uploads the coverage report at |directory| to |name|."""
95
+ return self._upload_directory(name, directory, self.COVERAGE_DIR)
96
+
97
+ def download_corpus(self, name, dst_directory):
98
+ """Downloads the corpus located at |name| to |dst_directory|."""
99
+ return self._download_directory(name, dst_directory, self.CORPUS_DIR)
100
+
101
+ def download_build(self, name, dst_directory):
102
+ """Downloads the build with |name| to |dst_directory|."""
103
+ return self._download_directory(name, dst_directory, self.BUILD_DIR)
104
+
105
+ def download_coverage(self, name, dst_directory):
106
+ """Downloads the latest project coverage report."""
107
+ return self._download_directory(name, dst_directory, self.COVERAGE_DIR)
local-test-tika-delta-04/fuzz-tooling/infra/cifuzz/filestore/github_actions/__init__.py ADDED
@@ -0,0 +1,179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ """Implementation of a filestore using Github actions artifacts."""
15
+ import logging
16
+ import os
17
+ import shutil
18
+ import sys
19
+ import tarfile
20
+ import tempfile
21
+
22
+ # pylint: disable=wrong-import-position,import-error
23
+ INFRA_DIR = os.path.abspath(
24
+ os.path.join(os.path.dirname(__file__), os.path.pardir, os.path.pardir,
25
+ os.path.pardir))
26
+ sys.path.append(INFRA_DIR)
27
+ OSS_FUZZ_ROOT_DIR = os.path.dirname(INFRA_DIR)
28
+
29
+ import utils
30
+ import http_utils
31
+ import filestore
32
+ from filestore.github_actions import github_api
33
+
34
+ UPLOAD_JS = os.path.join(os.path.dirname(__file__), 'upload.js')
35
+
36
+
37
+ def tar_directory(directory, archive_path):
38
+ """Tars a |directory| and stores archive at |archive_path|. |archive_path|
39
+ must end in .tar"""
40
+ assert archive_path.endswith('.tar')
41
+ # Do this because make_archive will append the extension to archive_path.
42
+ archive_path = os.path.splitext(archive_path)[0]
43
+
44
+ root_directory = os.path.abspath(directory)
45
+ shutil.make_archive(archive_path,
46
+ 'tar',
47
+ root_dir=root_directory,
48
+ base_dir='./')
49
+
50
+
51
+ class GithubActionsFilestore(filestore.BaseFilestore):
52
+ """Implementation of BaseFilestore using Github actions artifacts. Relies on
53
+ github_actions_toolkit for using the GitHub actions API and the github_api
54
+ module for using GitHub's standard API. We need to use both because the GitHub
55
+ actions API is the only way to upload an artifact but it does not support
56
+ downloading artifacts from other runs. The standard GitHub API does support
57
+ this however."""
58
+
59
+ ARTIFACT_PREFIX = 'cifuzz-'
60
+ BUILD_PREFIX = 'build-'
61
+ CRASHES_PREFIX = 'crashes-'
62
+ CORPUS_PREFIX = 'corpus-'
63
+ COVERAGE_PREFIX = 'coverage-'
64
+
65
+ def __init__(self, config):
66
+ super().__init__(config)
67
+ self.github_api_http_headers = github_api.get_http_auth_headers(config)
68
+
69
+ def _get_artifact_name(self, name):
70
+ """Returns |name| prefixed with |self.ARITFACT_PREFIX| if it isn't already
71
+ prefixed. Otherwise returns |name|."""
72
+ if name.startswith(self.ARTIFACT_PREFIX):
73
+ return name
74
+ return f'{self.ARTIFACT_PREFIX}{name}'
75
+
76
+ def _upload_directory(self, name, directory): # pylint: disable=no-self-use
77
+ """Uploads |directory| as artifact with |name|."""
78
+ name = self._get_artifact_name(name)
79
+ with tempfile.TemporaryDirectory() as temp_dir:
80
+ archive_path = os.path.join(temp_dir, name + '.tar')
81
+ tar_directory(directory, archive_path)
82
+ _raw_upload_directory(name, temp_dir)
83
+
84
+ def upload_crashes(self, name, directory):
85
+ """Uploads the crashes at |directory| to |name|."""
86
+ return _raw_upload_directory(self.CRASHES_PREFIX + name, directory)
87
+
88
+ def upload_corpus(self, name, directory, replace=False):
89
+ """Uploads the corpus at |directory| to |name|."""
90
+ # Not applicable as the the entire corpus is uploaded under a single
91
+ # artifact name.
92
+ del replace
93
+ return self._upload_directory(self.CORPUS_PREFIX + name, directory)
94
+
95
+ def upload_build(self, name, directory):
96
+ """Uploads the build at |directory| to |name|."""
97
+ return self._upload_directory(self.BUILD_PREFIX + name, directory)
98
+
99
+ def upload_coverage(self, name, directory):
100
+ """Uploads the coverage report at |directory| to |name|."""
101
+ return self._upload_directory(self.COVERAGE_PREFIX + name, directory)
102
+
103
+ def download_corpus(self, name, dst_directory): # pylint: disable=unused-argument,no-self-use
104
+ """Downloads the corpus located at |name| to |dst_directory|."""
105
+ return self._download_artifact(self.CORPUS_PREFIX + name, dst_directory)
106
+
107
+ def _find_artifact(self, name):
108
+ """Finds an artifact using the GitHub API and returns it."""
109
+ logging.debug('Listing artifacts.')
110
+ artifacts = self._list_artifacts()
111
+ artifact = github_api.find_artifact(name, artifacts)
112
+ logging.debug('Artifact: %s.', artifact)
113
+ return artifact
114
+
115
+ def _download_artifact(self, name, dst_directory):
116
+ """Downloads artifact with |name| to |dst_directory|. Returns True on
117
+ success."""
118
+ name = self._get_artifact_name(name)
119
+
120
+ with tempfile.TemporaryDirectory() as temp_dir:
121
+ if not self._raw_download_artifact(name, temp_dir):
122
+ logging.warning('Could not download artifact: %s.', name)
123
+ return False
124
+
125
+ artifact_tarfile_path = os.path.join(temp_dir, name + '.tar')
126
+ if not os.path.exists(artifact_tarfile_path):
127
+ logging.error('Artifact zip did not contain a tarfile.')
128
+ return False
129
+
130
+ # TODO(jonathanmetzman): Replace this with archive.unpack from
131
+ # libClusterFuzz so we can avoid path traversal issues.
132
+ with tarfile.TarFile(artifact_tarfile_path) as artifact_tarfile:
133
+ artifact_tarfile.extractall(dst_directory)
134
+ return True
135
+
136
+ def _raw_download_artifact(self, name, dst_directory):
137
+ """Downloads the artifact with |name| to |dst_directory|. Returns True on
138
+ success. Does not do any untarring or adding prefix to |name|."""
139
+ artifact = self._find_artifact(name)
140
+ if not artifact:
141
+ logging.warning('Could not find artifact: %s.', name)
142
+ return False
143
+ download_url = artifact['archive_download_url']
144
+ return http_utils.download_and_unpack_zip(
145
+ download_url, dst_directory, headers=self.github_api_http_headers)
146
+
147
+ def _list_artifacts(self):
148
+ """Returns a list of artifacts."""
149
+ return github_api.list_artifacts(self.config.project_repo_owner,
150
+ self.config.project_repo_name,
151
+ self.github_api_http_headers)
152
+
153
+ def download_build(self, name, dst_directory):
154
+ """Downloads the build with name |name| to |dst_directory|."""
155
+ return self._download_artifact(self.BUILD_PREFIX + name, dst_directory)
156
+
157
+ def download_coverage(self, name, dst_directory):
158
+ """Downloads the latest project coverage report."""
159
+ return self._download_artifact(self.COVERAGE_PREFIX + name, dst_directory)
160
+
161
+
162
+ def _upload_artifact_with_upload_js(name, artifact_paths, directory):
163
+ """Uploads the artifacts in |artifact_paths| that are located in |directory|
164
+ to |name|, using the upload.js script."""
165
+ command = [UPLOAD_JS, name, directory] + artifact_paths
166
+ _, _, retcode = utils.execute(command, location=OSS_FUZZ_ROOT_DIR)
167
+ return retcode == 0
168
+
169
+
170
+ def _raw_upload_directory(name, directory):
171
+ """Uploads the artifacts located in |directory| to |name|. Does not do any
172
+ tarring or adding prefixes to |name|."""
173
+ # Get file paths.
174
+ artifact_paths = []
175
+ for root, _, curr_file_paths in os.walk(directory):
176
+ for file_path in curr_file_paths:
177
+ artifact_paths.append(os.path.join(root, file_path))
178
+ logging.debug('Artifact paths: %s.', artifact_paths)
179
+ return _upload_artifact_with_upload_js(name, artifact_paths, directory)
local-test-tika-delta-04/fuzz-tooling/infra/cifuzz/filestore/github_actions/github_api_test.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ """Tests for github_api."""
15
+ import os
16
+ import sys
17
+ import unittest
18
+
19
+ # pylint: disable=wrong-import-position,import-error
20
+ sys.path.append(
21
+ os.path.abspath(
22
+ os.path.join(os.path.dirname(__file__), os.path.pardir, os.path.pardir,
23
+ os.path.pardir)))
24
+
25
+ from filestore.github_actions import github_api
26
+ import test_helpers
27
+
28
+
29
+ class GetHttpAuthHeaders(unittest.TestCase):
30
+ """Tests for get_http_auth_headers."""
31
+
32
+ def test_get_http_auth_headers(self):
33
+ """Tests that get_http_auth_headers returns the correct result."""
34
+ token = 'example githubtoken'
35
+ run_config = test_helpers.create_run_config(token=token)
36
+ expected_headers = {
37
+ 'Authorization': f'token {token}',
38
+ 'Accept': 'application/vnd.github.v3+json',
39
+ }
40
+ self.assertEqual(expected_headers,
41
+ github_api.get_http_auth_headers(run_config))
local-test-tika-delta-04/fuzz-tooling/infra/cifuzz/filestore/github_actions/upload.js ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env node
2
+ // Copyright 2021 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
+ // Script for uploading an artifact. Returns 0 on success.
16
+ // Usage: upload.js <artifactName> <rootDirectory> <file 1>...<file N>
17
+
18
+ const fs = require('fs');
19
+ const { DefaultArtifactClient } = require('@actions/artifact');
20
+
21
+ const artifactClient = new DefaultArtifactClient();
22
+ const artifactName = process.argv[2];
23
+ const rootDirectory = process.argv[3]
24
+ const files = process.argv.slice(4);
25
+ const options = {
26
+ continueOnError: true
27
+ };
28
+
29
+ async function uploadArtifact() {
30
+ try {
31
+ const uploadResult = await artifactClient.uploadArtifact(artifactName, files, rootDirectory, options);
32
+ console.log(uploadResult);
33
+ if (uploadResult.failedItems.length > 0) {
34
+ return 1;
35
+ }
36
+ return 0;
37
+ } catch (error) {
38
+ console.error('Error uploading artifact:', error);
39
+ return 1;
40
+ }
41
+ }
42
+
43
+ uploadArtifact().then(exitCode => {
44
+ process.exit(exitCode);
45
+ });
local-test-tika-delta-04/fuzz-tooling/infra/cifuzz/platform_config/__init__.py ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ """Module for getting the configuration CIFuzz needs to run."""
15
+ import logging
16
+ import os
17
+
18
+ import environment
19
+
20
+
21
+ class BasePlatformConfig:
22
+ """Base class for PlatformConfig subclasses."""
23
+
24
+ @property
25
+ def project_src_path(self):
26
+ """Returns the manually checked out path of the project's source if
27
+ specified or None."""
28
+ path = os.getenv('PROJECT_SRC_PATH')
29
+ if not path:
30
+ logging.debug('No PROJECT_SRC_PATH.')
31
+ return path
32
+
33
+ logging.debug('PROJECT_SRC_PATH: %s.', path)
34
+ return path
35
+
36
+ @property
37
+ def workspace(self):
38
+ """Returns the workspace."""
39
+ return os.getenv('WORKSPACE')
40
+
41
+ # Optional config variables.
42
+
43
+ @property
44
+ def git_sha(self):
45
+ """Returns the Git SHA to checkout and fuzz. This is used only by GitHub
46
+ projects when commit fuzzing. It is not used when PR fuzzing. It is
47
+ definitely needed by OSS-Fuzz on GitHub since they have no copy of the repo
48
+ on the host and the repo on the builder image is a clone from main/master.
49
+ Right now it is needed by external on GitHub because we need to clone a new
50
+ repo because the copy they give us doesn't work for diffing.
51
+
52
+ TODO(metzman): Try to eliminate the need for this by 1. Making the clone
53
+ from external github projects usable. 2. Forcing OSS-Fuzz on Github to clone
54
+ before starting CIFuzz."""
55
+ return None
56
+
57
+ @property
58
+ def base_commit(self):
59
+ """Returns the base commit to diff against (commit fuzzing)."""
60
+ # TODO(metzman) Rename base_commit to git_base_commit.
61
+ return os.getenv('GIT_BASE_COMMIT')
62
+
63
+ @property
64
+ def base_ref(self):
65
+ """Returns the base branch to diff against (pr fuzzing)."""
66
+ # TODO(metzman) Rename base_ref to git_base_ref.
67
+ return os.getenv('GIT_BASE_REF')
68
+
69
+ @property
70
+ def pr_ref(self):
71
+ """Returns the pull request to checkout and fuzz. This is used only by
72
+ GitHub projects when PR fuzzing. It is not used when commit fuzzing. It is
73
+ definitely needed by OSS-Fuzz on GitHub since they have no copy of the repo
74
+ on the host and the repo on the builder image is a clone from main/master.
75
+ Right now it is needed by external on GitHub because we need to clone a new
76
+ repo because the copy they give us doesn't work for diffing.
77
+
78
+ TODO(metzman): Try to eliminate the need for this by 1. Making the clone
79
+ from external github projects usable. 2. Forcing OSS-Fuzz on Github to clone
80
+ before starting CIFuzz."""
81
+ return None
82
+
83
+ @property
84
+ def project_repo_owner(self):
85
+ """Returns the project repo owner (githubism)."""
86
+ return None
87
+
88
+ @property
89
+ def project_repo_name(self):
90
+ """Returns the project repo name."""
91
+ return os.environ.get('REPOSITORY')
92
+
93
+ @property
94
+ def actor(self):
95
+ """Name of the actor for the CI."""
96
+ return None
97
+
98
+ @property
99
+ def token(self):
100
+ """Returns the CI API token."""
101
+ return None
102
+
103
+ @property
104
+ def docker_in_docker(self):
105
+ """Returns whether or not CFL is running using Docker in Docker."""
106
+ return environment.get_bool('DOCKER_IN_DOCKER', False)
107
+
108
+ @property
109
+ def filestore(self):
110
+ """Returns the filestore used to store persistent data."""
111
+ return os.environ.get('FILESTORE')
112
+
113
+ @property
114
+ def git_url(self):
115
+ """Returns the repo URL. This is only used by GitHub users. Right now it is
116
+ needed by external on GitHub because we need to clone a new repo because the
117
+ copy they give us doesn't work for diffing. It isn't used by OSS-Fuzz on
118
+ github users since the Git URL is determined using repo detection.
119
+
120
+ TODO(metzman): Try to eliminate the need for this by making the clone
121
+ from external github projects usable.
122
+ TODO(metzman): As an easier goal, maybe make OSS-Fuzz GitHub use this too
123
+ for: 1. Consistency 2. Maybe it will allow use on forks."""
124
+ return None
local-test-tika-delta-04/fuzz-tooling/infra/cifuzz/platform_config/gcb.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ """Module for getting the configuration CIFuzz needs to run on Github."""
15
+ import logging
16
+ import os
17
+
18
+ import platform_config
19
+
20
+
21
+ class PlatformConfig(platform_config.BasePlatformConfig):
22
+ """CI environment for Google Cloud Build."""
23
+
24
+ @property
25
+ def project_src_path(self):
26
+ """Returns the manually checked out path of the project's source if
27
+ specified or the default."""
28
+ project_src_path = os.getenv('PROJECT_SRC_PATH', '/workspace')
29
+ logging.debug('PROJECT_SRC_PATH: %s.', project_src_path)
30
+ return project_src_path
31
+
32
+ @property
33
+ def workspace(self):
34
+ """Returns the workspace."""
35
+ return os.getenv('WORKSPACE', '/builder/home')
36
+
37
+ @property
38
+ def filestore(self):
39
+ """Returns the filestore used to store persistent data."""
40
+ return os.environ.get('FILESTORE', 'gsutil')
local-test-tika-delta-04/fuzz-tooling/infra/cifuzz/platform_config/github.py ADDED
@@ -0,0 +1,146 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ """Module for getting the configuration CIFuzz needs to run on Github."""
15
+ import json
16
+ import logging
17
+ import os
18
+
19
+ import platform_config
20
+
21
+
22
+ def _get_github_event_path():
23
+ return os.getenv('GITHUB_EVENT_PATH')
24
+
25
+
26
+ def _get_event_data():
27
+ """Returns the GitHub event data."""
28
+ github_event_path = _get_github_event_path()
29
+ with open(github_event_path, encoding='utf-8') as file_handle:
30
+ return json.load(file_handle)
31
+
32
+
33
+ class PlatformConfig(platform_config.BasePlatformConfig):
34
+ """CI environment for GitHub."""
35
+
36
+ def __init__(self):
37
+ self._event_data = _get_event_data()
38
+ self._event = os.getenv('GITHUB_EVENT_NAME')
39
+
40
+ @property
41
+ def workspace(self):
42
+ """Returns the workspace."""
43
+ return os.getenv('GITHUB_WORKSPACE')
44
+
45
+ @property
46
+ def git_sha(self):
47
+ """Returns the Git SHA to checkout and fuzz. This is used only by GitHub
48
+ projects when commit fuzzing. It is not used when PR fuzzing. It is
49
+ definitely needed by OSS-Fuzz on GitHub since they have no copy of the repo
50
+ on the host and the repo on the builder image is a clone from main/master.
51
+ Right now it is needed by external on GitHub because we need to clone a new
52
+ repo because the copy they give us doesn't work for diffing.
53
+
54
+ TODO(metzman): Try to eliminate the need for this by 1. Making the clone
55
+ from external github projects usable. 2. Forcing OSS-Fuzz on Github to clone
56
+ before starting CIFuzz."""
57
+ return os.getenv('GITHUB_SHA')
58
+
59
+ @property
60
+ def actor(self):
61
+ """Name of the actor for the CI."""
62
+ return os.getenv('GITHUB_ACTOR')
63
+
64
+ @property
65
+ def token(self):
66
+ """Returns the CI API token."""
67
+ return os.getenv('GITHUB_TOKEN')
68
+
69
+ @property
70
+ def project_src_path(self):
71
+ """Returns the manually checked out path of the project's source if
72
+ specified or None. The path returned is relative to |self.workspace| since
73
+ on github the checkout will be relative to there."""
74
+ project_src_path = super().project_src_path
75
+ if project_src_path is None:
76
+ # Not set for internal GitHub users.
77
+ return project_src_path
78
+ # On GitHub (external users), this path is relative to |workspace|.
79
+ return os.path.join(self.workspace, project_src_path)
80
+
81
+ @property
82
+ def _project_repo_owner_and_name(self):
83
+ """Returns a tuple containing the project repo owner and the name of the
84
+ repo."""
85
+ # On GitHub this includes owner and repo name.
86
+ repository = os.getenv('GITHUB_REPOSITORY')
87
+ # Use os.path.split to split owner from repo.
88
+ return os.path.split(repository)
89
+
90
+ @property
91
+ def project_repo_owner(self):
92
+ """Returns the project repo owner (githubism)."""
93
+ return self._project_repo_owner_and_name[0]
94
+
95
+ @property
96
+ def project_repo_name(self):
97
+ """Returns the project repo name."""
98
+ return self._project_repo_owner_and_name[1]
99
+
100
+ @property
101
+ def git_url(self):
102
+ """Returns the repo URL. This is only used by GitHub users. Right now it is
103
+ needed by external on GitHub because we need to clone a new repo because the
104
+ copy they give us doesn't work for diffing. It isn't used by OSS-Fuzz on
105
+ github users since the Git URL is determined using repo detection.
106
+
107
+ TODO(metzman): Try to eliminate the need for this by making the clone
108
+ from external github projects usable.
109
+ TODO(metzman): As an easier goal, maybe make OSS-Fuzz GitHub use this too
110
+ for: 1. Consistency 2. Maybe it will allow use on forks."""
111
+ repository = os.getenv('GITHUB_REPOSITORY')
112
+ github_server_url = os.getenv('GITHUB_SERVER_URL', 'https://github.com')
113
+ # TODO(metzman): Probably need to change this to github.server_url.
114
+ return os.path.join(github_server_url, repository)
115
+
116
+ @property
117
+ def base_commit(self):
118
+ """Returns the base commit to diff against (commit fuzzing)."""
119
+ base_commit = None
120
+ if self._event == 'push':
121
+ base_commit = self._event_data['before']
122
+ logging.debug('base_commit: %s', base_commit)
123
+ return base_commit
124
+
125
+ @property
126
+ def pr_ref(self):
127
+ """Returns the pull request to checkout and fuzz. This is used only by
128
+ GitHub projects when PR fuzzing. It is not used when commit fuzzing. It is
129
+ definitely needed by OSS-Fuzz on GitHub since they have no copy of the repo
130
+ on the host and the repo on the builder image is a clone from main/master.
131
+ Right now it is needed by external on GitHub because we need to clone a new
132
+ repo because the copy they give us doesn't work for diffing.
133
+
134
+ TODO(metzman): Try to eliminate the need for this by 1. Making the clone
135
+ from external github projects usable. 2. Forcing OSS-Fuzz on Github to clone
136
+ before starting CIFuzz."""
137
+ if self._event == 'pull_request':
138
+ pr_ref = f'refs/pull/{self._event_data["pull_request"]["number"]}/merge'
139
+ logging.debug('pr_ref: %s', pr_ref)
140
+ return pr_ref
141
+ return None
142
+
143
+ @property
144
+ def base_ref(self):
145
+ """Returns the base branch to diff against (pr fuzzing)."""
146
+ return os.getenv('GITHUB_BASE_REF')
local-test-tika-delta-04/fuzz-tooling/infra/cifuzz/platform_config/gitlab.py ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ """Module for getting the configuration CIFuzz needs to run on GitLab."""
15
+ import logging
16
+ import os
17
+
18
+ import environment
19
+ import platform_config
20
+
21
+
22
+ class PlatformConfig(platform_config.BasePlatformConfig):
23
+ """CI environment for GitLab."""
24
+
25
+ @property
26
+ def workspace(self):
27
+ """Returns the workspace."""
28
+ return os.path.join(os.getenv('CI_BUILDS_DIR'), os.getenv('CI_JOB_ID'))
29
+
30
+ @property
31
+ def git_sha(self):
32
+ """Returns the Git SHA to checkout and fuzz."""
33
+ return os.getenv('CI_COMMIT_SHA')
34
+
35
+ @property
36
+ def project_src_path(self):
37
+ """Returns the directory with the source of the project"""
38
+ return os.getenv('CI_PROJECT_DIR')
39
+
40
+ @property
41
+ def token(self):
42
+ """Returns the job token"""
43
+ return os.getenv('CI_JOB_TOKEN')
44
+
45
+ @property
46
+ def project_repo_name(self):
47
+ """Returns the project's name"""
48
+ return os.getenv('CI_PROJECT_NAME')
49
+
50
+ @property
51
+ def base_commit(self):
52
+ """Returns the previous commit sha for commit-fuzzing"""
53
+ base_commit = None
54
+ if os.getenv('CI_PIPELINE_SOURCE') == 'push':
55
+ base_commit = os.getenv('CI_COMMIT_BEFORE_SHA')
56
+ logging.debug('base_commit: %s.', base_commit)
57
+ return base_commit
58
+
59
+ @property
60
+ def base_ref(self):
61
+ """Returns the base commit sha for a merge request"""
62
+ # Could also be CI_MERGE_REQUEST_TARGET_BRANCH_NAME.
63
+ return os.getenv('CI_MERGE_REQUEST_DIFF_BASE_SHA')
64
+
65
+ @property
66
+ def filestore(self):
67
+ """Returns the filestore used to store persistent data."""
68
+ return os.environ.get('FILESTORE', 'gitlab')
69
+
70
+ @property
71
+ def artifacts_dir(self):
72
+ """Gitlab: returns the directory to put artifacts"""
73
+ return environment.get('CFL_ARTIFACTS_DIR', 'artifacts')
74
+
75
+ @property
76
+ def cache_dir(self):
77
+ """Gitlab: returns the directory to use as cache"""
78
+ return environment.get('CFL_CACHE_DIR', 'cache')
local-test-tika-delta-04/fuzz-tooling/infra/cifuzz/platform_config/platform_config_test.py ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ """Tests for platform_config."""
15
+ import os
16
+ import unittest
17
+
18
+ import platform_config
19
+ import test_helpers
20
+
21
+
22
+ class GetProjectRepoOwnerAndNameTest(unittest.TestCase):
23
+ """Tests for get_project_repo_owner and get_project_repo_name."""
24
+
25
+ def setUp(self):
26
+ test_helpers.patch_environ(self)
27
+ self.repo_owner = 'repo-owner'
28
+ self.repo_name = 'repo-name'
29
+ self.env = platform_config.BasePlatformConfig()
30
+
31
+ def test_unset_repository(self):
32
+ """Tests that the correct result is returned when repository is not set."""
33
+ self.assertIsNone(self.env.project_repo_name)
34
+
35
+ def test_owner(self):
36
+ """Tests that the correct result is returned for owner."""
37
+ self.assertIsNone(self.env.project_repo_owner)
38
+
39
+ def test_empty_repository(self):
40
+ """Tests that the correct result is returned when repository is an empty
41
+ string."""
42
+ os.environ['REPOSITORY'] = ''
43
+ self.assertEqual(self.env.project_repo_name, '')
44
+
45
+ def test_repository(self):
46
+ """Tests that the correct result is returned when repository contains the
47
+ just the repo name (as it does outside of GitHub)."""
48
+ os.environ['REPOSITORY'] = self.repo_name
49
+ self.assertEqual(self.env.project_repo_name, self.repo_name)
50
+
51
+
52
+ class ProjectSrcPathTest(unittest.TestCase):
53
+ """Tests for project_src_path."""
54
+
55
+ def setUp(self):
56
+ test_helpers.patch_environ(self)
57
+
58
+ def test_not_github(self):
59
+ """Tests that project_src_path returns the correct result not on
60
+ GitHub."""
61
+ project_src_path = 'project-src'
62
+ os.environ['PROJECT_SRC_PATH'] = project_src_path
63
+ generic_ci_env = platform_config.BasePlatformConfig()
64
+ self.assertEqual(generic_ci_env.project_src_path, project_src_path)
65
+
66
+
67
+ class GetGitUrlTest(unittest.TestCase):
68
+ """Tests for BasePlatformConfig.git_url."""
69
+
70
+ def setUp(self):
71
+ test_helpers.patch_environ(self)
72
+ self.env = platform_config.BasePlatformConfig()
73
+
74
+ def test_unset_repository(self):
75
+ """Tests that the correct result is returned when repository is not set."""
76
+ self.assertEqual(self.env.git_url, None)
77
+
78
+ def test_repository(self):
79
+ """Tests that the correct result is returned when GITHUB_REPOSITORY is
80
+ set."""
81
+ os.environ['GITHUB_REPOSITORY'] = 'repo/owner'
82
+ self.assertIsNone(self.env.git_url)
local-test-tika-delta-04/fuzz-tooling/infra/cifuzz/platform_config/prow.py ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ """Module for getting the configuration CIFuzz needs to run on prow."""
15
+ import logging
16
+ import os
17
+
18
+ import platform_config
19
+
20
+ # pylint: disable=too-few-public-methods
21
+
22
+
23
+ class PlatformConfig(platform_config.BasePlatformConfig):
24
+ """CI environment for Prow."""
25
+
26
+ @property
27
+ def project_src_path(self):
28
+ """Returns the manually checked out path of the project's source if
29
+ specified or the current directory if not. Prow will run ClusterfuzzLite
30
+ at the directory head for the repo."""
31
+ project_src_path = os.getenv('PROJECT_SRC_PATH', os.getcwd())
32
+ logging.debug('PROJECT_SRC_PATH: %s.', project_src_path)
33
+ return project_src_path
34
+
35
+ @property
36
+ def workspace(self):
37
+ """Returns the workspace."""
38
+ # Let Prow user override workspace, but default to using artifacts dir
39
+ return os.getenv('WORKSPACE', os.getenv('ARTIFACTS'))
40
+
41
+ @property
42
+ def base_ref(self):
43
+ """Returns the base branch to diff against (pr fuzzing)."""
44
+ return os.getenv('PULL_BASE_REF')
45
+
46
+ @property
47
+ def project_repo_name(self):
48
+ """Returns the project repo name."""
49
+ return os.getenv('REPO_NAME')
50
+
51
+ @property
52
+ def base_commit(self):
53
+ """Returns the base commit to diff against (commit fuzzing)."""
54
+ return os.getenv('PULL_BASE_SHA')
55
+
56
+ @property
57
+ def docker_in_docker(self):
58
+ """Returns True if using Docker in Docker."""
59
+ return True
60
+
61
+ @property
62
+ def filestore(self):
63
+ """Returns the filestore used to store persistent data."""
64
+ return os.environ.get('FILESTORE', 'gsutil')
local-test-tika-delta-04/fuzz-tooling/infra/cifuzz/platform_config/standalone.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ """Module for getting the configuration CIFuzz needs to run standalone."""
15
+ import os
16
+
17
+ import platform_config
18
+
19
+ # pylint: disable=too-few-public-methods
20
+
21
+
22
+ class PlatformConfig(platform_config.BasePlatformConfig):
23
+ """CI environment for Standalone."""
24
+
25
+ @property
26
+ def filestore(self):
27
+ """Returns the filestore used to store persistent data."""
28
+ return os.environ.get('FILESTORE', 'filesystem')
29
+
30
+ @property
31
+ def filestore_root_dir(self):
32
+ """Returns the filestore used to store persistent data."""
33
+ return os.environ['FILESTORE_ROOT_DIR']
local-test-tika-delta-04/fuzz-tooling/infra/cifuzz/test_data/msan_crash_fuzzer_bug_summary.txt ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MemorySanitizer: use-of-uninitialized-value
2
+ #0 0x52675f in LLVMFuzzerTestOneInput /src/cifuzz-example/do_stuff_fuzzer.cpp:13:7
3
+ #1 0x45a431 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:599:15
4
+ #2 0x45ba46 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:792:3
5
+ #3 0x45bed9 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:845:3
6
+ #4 0x44a4bc in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:906:6
7
+ #5 0x474432 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
8
+ #6 0x7eff5562683f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2083f)
9
+ #7 0x41eab8 in _start (out/do_stuff_fuzzer+0x41eab8)
10
+
11
+ DEDUP_TOKEN: LLVMFuzzerTestOneInput--fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long)--fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&)
12
+ Uninitialized value was created by a heap allocation
13
+ #0 0x4d57ad in malloc /src/llvm-project/compiler-rt/lib/msan/msan_interceptors.cpp:901:3
14
+ #1 0x437c07 in operator new(unsigned long) (out/do_stuff_fuzzer+0x437c07)
15
+ #2 0x45ba46 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:792:3
16
+ #3 0x45bed9 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:845:3
17
+ #4 0x44a4bc in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:906:6
18
+ #5 0x474432 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
19
+ #6 0x7eff5562683f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2083f)
20
+ DEDUP_TOKEN: malloc--operator new(unsigned long)--fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&)
21
+
22
+ SUMMARY:
local-test-tika-delta-04/fuzz-tooling/infra/cifuzz/test_data/msan_crash_fuzzer_output.txt ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Dictionary: 3 entries
2
+ INFO: Running with entropic power schedule (0xFF, 100).
3
+ INFO: Seed: 1337
4
+ INFO: Loaded 1 modules (184 inline 8-bit counters): 184 [0x829300, 0x8293b8),
5
+ INFO: Loaded 1 PC tables (184 PCs): 184 [0x5dc910,0x5dd490),
6
+ INFO: 5 files found in /tmp/do_stuff_fuzzer_corpus
7
+ INFO: -max_len is not provided; libFuzzer will not generate inputs larger than 4096 bytes
8
+ ==13==WARNING: MemorySanitizer: use-of-uninitialized-value
9
+ #0 0x52675f in LLVMFuzzerTestOneInput /src/cifuzz-example/do_stuff_fuzzer.cpp:13:7
10
+ #1 0x45a431 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:599:15
11
+ #2 0x45ba46 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:792:3
12
+ #3 0x45bed9 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:845:3
13
+ #4 0x44a4bc in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:906:6
14
+ #5 0x474432 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
15
+ #6 0x7eff5562683f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2083f)
16
+ #7 0x41eab8 in _start (out/do_stuff_fuzzer+0x41eab8)
17
+
18
+ DEDUP_TOKEN: LLVMFuzzerTestOneInput--fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long)--fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&)
19
+ Uninitialized value was created by a heap allocation
20
+ #0 0x4d57ad in malloc /src/llvm-project/compiler-rt/lib/msan/msan_interceptors.cpp:901:3
21
+ #1 0x437c07 in operator new(unsigned long) (out/do_stuff_fuzzer+0x437c07)
22
+ #2 0x45ba46 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:792:3
23
+ #3 0x45bed9 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:845:3
24
+ #4 0x44a4bc in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:906:6
25
+ #5 0x474432 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
26
+ #6 0x7eff5562683f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2083f)
27
+ DEDUP_TOKEN: malloc--operator new(unsigned long)--fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&)
28
+
29
+ SUMMARY: MemorySanitizer: use-of-uninitialized-value /src/cifuzz-example/do_stuff_fuzzer.cpp:13:7 in LLVMFuzzerTestOneInput
30
+ Unique heap origins: 65
31
+ Stack depot allocated bytes: 4424
32
+ Unique origin histories: 29
33
+ History depot allocated bytes: 696
34
+ Exiting
35
+ MS: 0 ; base unit: 0000000000000000000000000000000000000000
36
+
37
+
38
+ artifact_prefix='./'; Test unit written to ./crash-da39a3ee5e6b4b0d3255bfef95601890afd80709
39
+ Base64:
local-test-tika-delta-04/fuzz-tooling/infra/cifuzz/test_data/sarif_utils_msan_stack.txt ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Dictionary: 3 entries
2
+ 2024-05-07 18:49:02,343 - root - INFO - Fuzzer: do_stuff_fuzzer. Detected bug.
3
+ INFO: Running with entropic power schedule (0xFF, 100).
4
+ INFO: Seed: 1337
5
+ INFO: Loaded 1 modules (83 inline 8-bit counters): 83 [0x563ff0e03e98, 0x563ff0e03eeb),
6
+ INFO: Loaded 1 PC tables (83 PCs): 83 [0x563ff0e03ef0,0x563ff0e04420),
7
+ INFO: 0 files found in /github/workspace/cifuzz-corpus/do_stuff_fuzzer
8
+ INFO: -max_len is not provided; libFuzzer will not generate inputs larger than 4096 bytes
9
+ INFO: A corpus is not provided, starting from an empty corpus
10
+ #2 INITED cov: 2 ft: 2 corp: 1/1b exec/s: 0 rss: 69Mb
11
+ #4 NEW cov: 3 ft: 3 corp: 2/3b lim: 4096 exec/s: 0 rss: 69Mb L: 2/2 MS: 2 ChangeBit-InsertByte-
12
+ ==23==WARNING: MemorySanitizer: use-of-uninitialized-value
13
+ #0 0x563ff0d278f0 in LLVMFuzzerTestOneInput /src/cifuzz-external-example/do_stuff_fuzzer.cpp:24:1
14
+ #1 0x563ff0c24340 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:614:13
15
+ #2 0x563ff0c23b65 in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:516:7
16
+ #3 0x563ff0c25335 in fuzzer::Fuzzer::MutateAndTestOne() /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:760:19
17
+ #4 0x563ff0c26125 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile>>&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:905:5
18
+ #5 0x563ff0c14436 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:914:6
19
+ #6 0x563ff0c40962 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
20
+ #7 0x7f4c156ed082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 87b331c034a6458c64ce09c03939e947212e18ce)
21
+ #8 0x563ff0c055ad in _start (build-out/do_stuff_fuzzer+0x4a5ad)
22
+
23
+ DEDUP_TOKEN: LLVMFuzzerTestOneInput--fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long)--fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*)
24
+ Uninitialized value was stored to memory at
25
+ #0 0x563ff0d278e9 in LLVMFuzzerTestOneInput /src/cifuzz-external-example/do_stuff_fuzzer.cpp
26
+ #1 0x563ff0c24340 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:614:13
27
+ #2 0x563ff0c23b65 in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:516:7
28
+ #3 0x563ff0c25335 in fuzzer::Fuzzer::MutateAndTestOne() /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:760:19
29
+ #4 0x563ff0c26125 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile>>&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:905:5
30
+ #5 0x563ff0c14436 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:914:6
31
+ #6 0x563ff0c40962 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
32
+ #7 0x7f4c156ed082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 87b331c034a6458c64ce09c03939e947212e18ce)
33
+
34
+ DEDUP_TOKEN: LLVMFuzzerTestOneInput--fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long)--fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*)
35
+ Uninitialized value was created by a heap deallocation
36
+ #0 0x563ff0cc7480 in free /src/llvm-project/compiler-rt/lib/msan/msan_interceptors.cpp:218:3
37
+ #1 0x563ff0d27800 in LLVMFuzzerTestOneInput /src/cifuzz-external-example/do_stuff_fuzzer.cpp:21:5
38
+ #2 0x563ff0c24340 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:614:13
39
+ #3 0x563ff0c23b65 in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:516:7
40
+ #4 0x563ff0c25335 in fuzzer::Fuzzer::MutateAndTestOne() /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:760:19
41
+ #5 0x563ff0c26125 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile>>&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:905:5
42
+ #6 0x563ff0c14436 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:914:6
43
+ #7 0x563ff0c40962 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
44
+ #8 0x7f4c156ed082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 87b331c034a6458c64ce09c03939e947212e18ce)
45
+
46
+ DEDUP_TOKEN: __interceptor_free--LLVMFuzzerTestOneInput--fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long)
47
+ SUMMARY: MemorySanitizer: use-of-uninitialized-value /src/cifuzz-external-example/do_stuff_fuzzer.cpp:24:1 in LLVMFuzzerTestOneInput
48
+ Unique heap origins: 201
49
+ Stack depot allocated bytes: 9764880
50
+ Unique origin histories: 181
51
+ History depot allocated bytes: 196608
52
+ Exiting
53
+ MS: 5 ShuffleBytes-CopyPart-InsertByte-CopyPart-ManualDict- DE: "bar"-; base unit: adc83b19e793491b1c6ea0fd8b46cd9f32e592fc
54
+ 0xa,0x62,0x61,0x72,0xa,
55
+ \012bar\012
56
+ artifact_prefix='/tmp/tmp1tc5b3m2/'; Test unit written to /tmp/tmp1tc5b3m2/crash-c935b6724d7e27401ac9af3773700ca86ac38dea
57
+ Base64: CmJhcgo=
58
+ stat::number_of_executed_units: 159
59
+ stat::average_exec_per_sec: 0
60
+ stat::new_units_added: 1
61
+ stat::slowest_unit_time_sec: 0
62
+ stat::peak_rss_mb: 69
local-test-tika-delta-04/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-tika-delta-04/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-tika-delta-04/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-tika-delta-04/fuzz-tooling/infra/experimental/sanitizers/ExecSan/README.md ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ # Moved
2
+
3
+ This has moved to <https://github.com/google/oss-fuzz/tree/master/infra/experimental/SystemSan>.