Kitxuuu commited on
Commit
2e5b31c
·
verified ·
1 Parent(s): 2b5bdcf

Add files using upload-large-folder tool

Browse files
Files changed (20) hide show
  1. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/cifuzz/cifuzz-base/Dockerfile +44 -0
  2. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/cifuzz/filestore/__init__.py +54 -0
  3. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/cifuzz/platform_config/__init__.py +124 -0
  4. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/cifuzz/platform_config/gcb.py +40 -0
  5. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/cifuzz/platform_config/github.py +146 -0
  6. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/cifuzz/platform_config/github_test.py +87 -0
  7. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/cifuzz/platform_config/platform_config_test.py +82 -0
  8. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/cifuzz/platform_config/prow.py +64 -0
  9. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/cifuzz/platform_config/standalone.py +33 -0
  10. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/experimental/SystemSan/PoEs/node-shell-quote-v1.7.3/Makefile +12 -0
  11. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/experimental/SystemSan/PoEs/node-shell-quote-v1.7.3/target.js +35 -0
  12. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/experimental/SystemSan/PoEs/pytorch-lightning-1.5.10/Dockerfile +32 -0
  13. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/experimental/SystemSan/PoEs/pytorch-lightning-1.5.10/Makefile +12 -0
  14. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/experimental/SystemSan/PoEs/pytorch-lightning-1.5.10/fuzz_pytorch_lightning.py +65 -0
  15. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/experimental/chronos/Dockerfile +18 -0
  16. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/experimental/chronos/README.md +49 -0
  17. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/experimental/chronos/build_on_cloudbuild.sh +26 -0
  18. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/experimental/chronos/chronos.sh +81 -0
  19. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/experimental/chronos/match_artifacts.sh +35 -0
  20. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/experimental/sanitizers/ExecSan/README.md +3 -0
local-test-commons-compress-full-01-vuln_1/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-commons-compress-full-01-vuln_1/fuzz-tooling/infra/cifuzz/filestore/__init__.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 a generic filestore."""
15
+
16
+
17
+ class FilestoreError(Exception):
18
+ """Error using the filestore."""
19
+
20
+
21
+ # pylint: disable=unused-argument,no-self-use
22
+ class BaseFilestore:
23
+ """Base class for a filestore."""
24
+
25
+ def __init__(self, config):
26
+ self.config = config
27
+
28
+ def upload_crashes(self, name, directory):
29
+ """Uploads the crashes at |directory| to |name|."""
30
+ raise NotImplementedError('Child class must implement method.')
31
+
32
+ def upload_corpus(self, name, directory, replace=False):
33
+ """Uploads the corpus at |directory| to |name|."""
34
+ raise NotImplementedError('Child class must implement method.')
35
+
36
+ def upload_build(self, name, directory):
37
+ """Uploads the build at |directory| to |name|."""
38
+ raise NotImplementedError('Child class must implement method.')
39
+
40
+ def upload_coverage(self, name, directory):
41
+ """Uploads the coverage report at |directory| to |name|."""
42
+ raise NotImplementedError('Child class must implement method.')
43
+
44
+ def download_corpus(self, name, dst_directory):
45
+ """Downloads the corpus located at |name| to |dst_directory|."""
46
+ raise NotImplementedError('Child class must implement method.')
47
+
48
+ def download_build(self, name, dst_directory):
49
+ """Downloads the build with |name| to |dst_directory|."""
50
+ raise NotImplementedError('Child class must implement method.')
51
+
52
+ def download_coverage(self, name, dst_directory):
53
+ """Downloads the latest project coverage report."""
54
+ raise NotImplementedError('Child class must implement method.')
local-test-commons-compress-full-01-vuln_1/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-commons-compress-full-01-vuln_1/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-commons-compress-full-01-vuln_1/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-commons-compress-full-01-vuln_1/fuzz-tooling/infra/cifuzz/platform_config/github_test.py ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.github."""
15
+ import os
16
+ import unittest
17
+ from unittest import mock
18
+
19
+ import platform_config.github
20
+ import test_helpers
21
+
22
+ # pylint: disable=arguments-differ
23
+
24
+
25
+ class GetProjectRepoOwnerAndNameTest(unittest.TestCase):
26
+ """Tests for get_project_repo_owner and get_project_repo_name."""
27
+
28
+ @mock.patch('platform_config.github._get_event_data', return_value={})
29
+ def setUp(self, _):
30
+ test_helpers.patch_environ(self)
31
+ self.repo_owner = 'repo-owner'
32
+ self.repo_name = 'repo-name'
33
+ os.environ['GITHUB_REPOSITORY'] = f'{self.repo_owner}/{self.repo_name}'
34
+ self.platform_conf = platform_config.github.PlatformConfig()
35
+
36
+ def test_github_repository_owner(self):
37
+ """Tests that the correct result is returned when repository contains the
38
+ owner and repo name (as it does on GitHub)."""
39
+ self.assertEqual(self.platform_conf.project_repo_owner, self.repo_owner)
40
+
41
+ def test_github_repository_name(self):
42
+ """Tests that the correct result is returned when repository contains the
43
+ owner and repo name (as it does on GitHub)."""
44
+ os.environ['GITHUB_REPOSITORY'] = f'{self.repo_owner}/{self.repo_name}'
45
+ self.assertEqual(self.platform_conf.project_repo_name, self.repo_name)
46
+
47
+
48
+ class ProjectSrcPathTest(unittest.TestCase):
49
+ """Tests for project_src_path."""
50
+
51
+ def setUp(self):
52
+ test_helpers.patch_environ(self)
53
+ self.workspace = '/workspace'
54
+ os.environ['GITHUB_WORKSPACE'] = self.workspace
55
+ self.project_src_dir_name = 'project-src'
56
+
57
+ @mock.patch('platform_config.github._get_event_data', return_value={})
58
+ def test_github_unset(self, _):
59
+ """Tests that project_src_path returns None when no PROJECT_SRC_PATH is
60
+ set."""
61
+ github_env = platform_config.github.PlatformConfig()
62
+ self.assertIsNone(github_env.project_src_path)
63
+
64
+ @mock.patch('platform_config.github._get_event_data', return_value={})
65
+ def test_github(self, _):
66
+ """Tests that project_src_path returns the correct result on GitHub."""
67
+ os.environ['PROJECT_SRC_PATH'] = self.project_src_dir_name
68
+ expected_project_src_path = os.path.join(self.workspace,
69
+ self.project_src_dir_name)
70
+ github_env = platform_config.github.PlatformConfig()
71
+ self.assertEqual(github_env.project_src_path, expected_project_src_path)
72
+
73
+
74
+ class GetGitUrlTest(unittest.TestCase):
75
+ """Tests for GenericPlatformConfig.git_url."""
76
+
77
+ @mock.patch('platform_config.github._get_event_data', return_value={})
78
+ def setUp(self, _):
79
+ test_helpers.patch_environ(self)
80
+ self.platform_conf = platform_config.github.PlatformConfig()
81
+
82
+ def test_repository(self):
83
+ """Tests that the correct result is returned when repository contains the
84
+ owner and repo name (as it does on GitHub)."""
85
+ os.environ['GITHUB_REPOSITORY'] = 'repo/owner'
86
+ self.assertEqual('https://github.com/repo/owner',
87
+ self.platform_conf.git_url)
local-test-commons-compress-full-01-vuln_1/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-commons-compress-full-01-vuln_1/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-commons-compress-full-01-vuln_1/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-commons-compress-full-01-vuln_1/fuzz-tooling/infra/experimental/SystemSan/PoEs/node-shell-quote-v1.7.3/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 target.js
9
+ ./SystemSan jsfuzz ./target.js
10
+
11
+ clean:
12
+ rm -f SystemSan /tmp/tripwire
local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/experimental/SystemSan/PoEs/node-shell-quote-v1.7.3/target.js ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ /* Exploit shell quote with fuzzer's input as a parameter of echo.
17
+ * This PoC is extended from a report in GitHub Advisory Database:
18
+ * https://github.com/advisories/GHSA-g4rg-993r-mgx7
19
+ * The original report records a shell injection exploit in shell-quote v1.7.2,
20
+ * we show that a similar shell corruption exploit still persists in v1.7.3,
21
+ * after a commit that intends to fix the original exploit.
22
+ * */
23
+
24
+ /* Fuzz the target program with buf generated by Jsfuzz. */
25
+ function fuzz(buf) {
26
+ buf = String(buf)
27
+ const childProcess = require('child_process');
28
+ const shellQuote = require('shell-quote');
29
+ childProcess.execSync(shellQuote.quote(['echo', buf]));
30
+ }
31
+
32
+ /* Run Jsfuzz. */
33
+ module.exports = {
34
+ fuzz
35
+ };
local-test-commons-compress-full-01-vuln_1/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-commons-compress-full-01-vuln_1/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-commons-compress-full-01-vuln_1/fuzz-tooling/infra/experimental/SystemSan/PoEs/pytorch-lightning-1.5.10/fuzz_pytorch_lightning.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/local/bin/python3
2
+ #
3
+ # Copyright 2022 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+ ################################################################################
18
+ """Exploit pytorch lightning with fuzzer's input as a random env variable.
19
+
20
+ This PoC is extended from a report in GitHub Advisory Database:
21
+ https://github.com/advisories/GHSA-r5qj-cvf9-p85h
22
+ The original report documents an exploit using a specific environment variable,
23
+ we show a way to achieve the same exploit with an arbitrary env variable.
24
+ """
25
+
26
+ import os
27
+ import sys
28
+ import atheris
29
+
30
+ with atheris.instrument_imports():
31
+ from pytorch_lightning import Trainer
32
+ from pytorch_lightning.utilities.argparse import parse_env_variables
33
+
34
+
35
+ def prepare_fuzzing_input(data):
36
+ """Prepare the data needed by the exploit with input data from fuzzers."""
37
+ data = data.replace(b'\0', b'')
38
+ env_name = 'AN_ARBITRARY_ENV_NAME'
39
+ return data, env_name
40
+
41
+
42
+ def exploit_target(env_value, env_name):
43
+ """This target is based on a snippet from the official documentation of
44
+ `parse_env_variables`:
45
+ https://pytorch-lightning.readthedocs.io/en/stable/api/pytorch_lightning.utilities.argparse.html # pylint: disable=line-too-long
46
+ It might not be the most realistic example,
47
+ but serves as a PoC to show that SystemSan works for Python."""
48
+ os.environb[env_name.encode()] = env_value
49
+ parse_env_variables(Trainer, template=env_name)
50
+
51
+
52
+ def TestOneInput(data): # pylint: disable=invalid-name
53
+ """Exploit the target only with input data from fuzzers."""
54
+ env_value, env_name = prepare_fuzzing_input(data)
55
+ exploit_target(env_value, env_name)
56
+
57
+
58
+ def main():
59
+ """Fuzz target with atheris."""
60
+ atheris.Setup(sys.argv, TestOneInput)
61
+ atheris.Fuzz()
62
+
63
+
64
+ if __name__ == '__main__':
65
+ main()
local-test-commons-compress-full-01-vuln_1/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-commons-compress-full-01-vuln_1/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-commons-compress-full-01-vuln_1/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-commons-compress-full-01-vuln_1/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-commons-compress-full-01-vuln_1/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-commons-compress-full-01-vuln_1/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>.