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

Add files using upload-large-folder tool

Browse files
Files changed (50) hide show
  1. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/base-images/base-builder-fuzzbench/Dockerfile +26 -0
  2. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/base-images/base-builder-fuzzbench/fuzzbench_build +28 -0
  3. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/base-images/base-builder-fuzzbench/fuzzbench_install_dependencies +22 -0
  4. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/base-images/base-builder-go/Dockerfile +33 -0
  5. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/base-images/base-builder-python/Dockerfile +20 -0
  6. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/base-images/base-builder/bash_parser.py +235 -0
  7. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/base-images/base-builder/write_labels.py +40 -0
  8. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/base-images/base-runner/Dockerfile +139 -0
  9. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/base-images/base-runner/coverage +549 -0
  10. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/base-images/base-runner/coverage_helper +17 -0
  11. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/base-images/base-runner/download_corpus +30 -0
  12. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/base-images/base-runner/generate_differential_cov_report.py +228 -0
  13. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/base-images/base-runner/install_deps.sh +37 -0
  14. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/base-images/base-runner/install_go.sh +41 -0
  15. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/base-images/base-runner/install_javascript.sh +30 -0
  16. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/base-images/base-runner/jacoco_report_converter.py +174 -0
  17. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/base-images/base-runner/nyc_report_converter.py +80 -0
  18. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/base-images/base-runner/profraw_update.py +182 -0
  19. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/base-images/base-runner/python_coverage_runner_help.py +181 -0
  20. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/base-images/base-runner/rcfilt +21 -0
  21. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/base-images/base-runner/reproduce +34 -0
  22. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/base-images/base-runner/run_fuzzer +228 -0
  23. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/base-images/base-runner/ruzzy +19 -0
  24. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/base-images/base-runner/targets_list +10 -0
  25. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/base-images/base-runner/test_all_test.py +38 -0
  26. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/cifuzz/actions/run_fuzzers/action.yml +82 -0
  27. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/cifuzz/external-actions/build_fuzzers/action.yml +75 -0
  28. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/cifuzz/external-actions/run_fuzzers/action.yml +97 -0
  29. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/cifuzz/filestore/filesystem/__init__.py +107 -0
  30. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/cifuzz/filestore/git/__init__.py +158 -0
  31. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/cifuzz/filestore/github_actions/__init__.py +179 -0
  32. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/cifuzz/filestore/github_actions/github_api.py +109 -0
  33. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/cifuzz/filestore/github_actions/github_api_test.py +41 -0
  34. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/cifuzz/filestore/github_actions/upload.js +45 -0
  35. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/cifuzz/filestore/gitlab/__init__.py +133 -0
  36. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/cifuzz/filestore/gsutil/__init__.py +109 -0
  37. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/cifuzz/filestore/no_filestore/__init__.py +51 -0
  38. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/cifuzz/platform_config/gitlab.py +78 -0
  39. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/cifuzz/test_data/TimeoutFuzzer.cpp +36 -0
  40. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/cifuzz/test_data/example_crash_fuzzer_bug_summary.txt +68 -0
  41. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/cifuzz/test_data/example_crash_fuzzer_output.txt +202 -0
  42. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/cifuzz/test_data/external-project/.clusterfuzzlite/build.sh +24 -0
  43. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/cifuzz/test_data/external-project/do_stuff_fuzzer.dict +6 -0
  44. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/cifuzz/test_data/external-project/standalone_fuzz_target_runner.cpp +47 -0
  45. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/cifuzz/test_data/msan_crash_fuzzer_bug_summary.txt +22 -0
  46. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/cifuzz/test_data/msan_crash_fuzzer_output.txt +39 -0
  47. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/cifuzz/test_data/sarif_utils_msan_stack.txt +62 -0
  48. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/cifuzz/test_data/sarif_utils_only_llvmfuzzer_stack.txt +302 -0
  49. local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/cifuzz/test_data/sarif_utils_systemd_stack.txt +302 -0
  50. local-test-commons-compress-full-01-vuln_5/afc-commons-compress/BUILDING.md +57 -0
local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/base-images/base-builder-fuzzbench/Dockerfile ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2023 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ #
15
+ ################################################################################
16
+
17
+ ARG IMG_TAG=latest
18
+ FROM ghcr.io/aixcc-finals/base-builder:${IMG_TAG}
19
+
20
+ # Copy/Run this now to make the cache more resilient.
21
+ COPY fuzzbench_install_dependencies /usr/local/bin
22
+ RUN fuzzbench_install_dependencies
23
+
24
+ ENV OSS_FUZZ_ON_DEMAND=1
25
+
26
+ COPY fuzzbench_build fuzzbench_run_fuzzer fuzzbench_measure /usr/local/bin/
local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/base-images/base-builder-fuzzbench/fuzzbench_build ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #! /bin/bash -eux
2
+ # Copyright 2023 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
+ # TODO(metzman): Do this in a docket image so we don't need to waste time
19
+ # reinstalling.
20
+ PYTHONPATH=$FUZZBENCH_PATH python3 -B -u -c "from fuzzers.$FUZZING_ENGINE import fuzzer; fuzzer.build()"
21
+
22
+ if [ "$FUZZING_ENGINE" = "coverage" ]; then
23
+ cd $OUT
24
+ mkdir -p filestore/oss-fuzz-on-demand/coverage-binaries
25
+ # We expect an error regarding leading slashes. Just assume this step succeeds.
26
+ # TODO(metzman): Fix this when I get a chance.
27
+ tar -czvf filestore/oss-fuzz-on-demand/coverage-binaries/coverage-build-$PROJECT.tar.gz * /src /work || exit 0
28
+ fi
local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/base-images/base-builder-fuzzbench/fuzzbench_install_dependencies ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #! /bin/bash -eux
2
+ # Copyright 2023 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
+ apt-get update && apt-get install -y gcc gfortran python-dev libopenblas-dev liblapack-dev cython libpq-dev
19
+ wget -O /tmp/requirements.txt https://raw.githubusercontent.com/google/fuzzbench/master/requirements.txt
20
+ pip3 install pip --upgrade
21
+ CFLAGS= CXXFLAGS= pip3 install -r /tmp/requirements.txt
22
+ rm /tmp/requirements.txt
local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/base-images/base-builder-go/Dockerfile ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ #
15
+ ################################################################################
16
+
17
+ ARG IMG_TAG=latest
18
+ FROM ghcr.io/aixcc-finals/base-builder:${IMG_TAG}
19
+
20
+ # Set up Golang environment variables (copied from /root/.bash_profile).
21
+ ENV GOPATH /root/go
22
+
23
+ # /root/.go/bin is for the standard Go binaries (i.e. go, gofmt, etc).
24
+ # $GOPATH/bin is for the binaries from the dependencies installed via "go get".
25
+ ENV PATH $PATH:/root/.go/bin:$GOPATH/bin
26
+
27
+ COPY gosigfuzz.c $GOPATH/gosigfuzz/
28
+
29
+ RUN install_go.sh
30
+
31
+ # TODO(jonathanmetzman): Install this file using install_go.sh.
32
+ COPY ossfuzz_coverage_runner.go \
33
+ $GOPATH/
local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/base-images/base-builder-python/Dockerfile ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ #
15
+ ################################################################################
16
+
17
+ ARG IMG_TAG=latest
18
+ FROM ghcr.io/aixcc-finals/base-builder:${IMG_TAG}
19
+
20
+ RUN install_python.sh
local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/base-images/base-builder/bash_parser.py ADDED
@@ -0,0 +1,235 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/python3
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
+ import os
17
+ import sys
18
+
19
+ from glob import glob
20
+
21
+ import bashlex
22
+
23
+
24
+ def find_all_bash_scripts_in_src():
25
+ """Finds all bash scripts that exist in SRC/. This is used to idenfiy scripts
26
+ that may be needed for reading during the AST parsing. This is the case
27
+ when a given build script calls another build script, then we need to
28
+ read those."""
29
+ all_local_scripts = [
30
+ y for x in os.walk('/src/') for y in glob(os.path.join(x[0], '*.sh'))
31
+ ]
32
+ scripts_we_care_about = []
33
+ to_ignore = {'aflplusplus', 'honggfuzz', '/fuzztest', '/centipede'}
34
+ for s in all_local_scripts:
35
+ if any([x for x in to_ignore if x in s]):
36
+ continue
37
+ scripts_we_care_about.append(s)
38
+
39
+ print(scripts_we_care_about)
40
+ return scripts_we_care_about
41
+
42
+
43
+ def should_discard_command(ast_tree) -> bool:
44
+ """Returns True if the command shuold be avoided, otherwise False"""
45
+ try:
46
+ first_word = ast_tree.parts[0].word
47
+ except: # pylint: disable=bare-except
48
+ return False
49
+
50
+ if ('cmake' in first_word and
51
+ any('--build' in part.word for part in ast_tree.parts)):
52
+ return False
53
+
54
+ cmds_to_avoid_replaying = {
55
+ 'configure', 'autoheader', 'autoconf', 'autoreconf', 'cmake', 'autogen.sh'
56
+ }
57
+ if any([cmd for cmd in cmds_to_avoid_replaying if cmd in first_word]):
58
+ return True
59
+
60
+ # Avoid all "make clean" calls. We dont want to erase previously build
61
+ # files.
62
+ try:
63
+ second_word = ast_tree.parts[1].word
64
+ except: # pylint: disable=bare-except
65
+ return False
66
+ if 'make' in first_word and 'clean' in second_word:
67
+ return True
68
+
69
+ # No match was found to commands we dont want to build. There is no
70
+ # indication we shuold avoid.
71
+ return False
72
+
73
+
74
+ def is_local_redirection(ast_node, all_local_scripts):
75
+ """Return the list of scripts corresponding to the command, in case
76
+ the command is an execution of a local script."""
77
+ # print("Checking")
78
+
79
+ # Capture local script called with ./random/path/build.sh
80
+
81
+ if len(ast_node.parts) >= 2:
82
+ try:
83
+ ast_node.parts[0].word
84
+ except:
85
+ return []
86
+ if ast_node.parts[0].word == '.':
87
+ suffixes_matching = []
88
+ #print(ast_node.parts[1].word)
89
+ for bash_script in all_local_scripts:
90
+ #print("- %s"%(bash_script))
91
+ cmd_to_exec = ast_node.parts[1].word.replace('$SRC', 'src')
92
+ if bash_script.endswith(cmd_to_exec):
93
+ suffixes_matching.append(bash_script)
94
+ #print(suffixes_matching)
95
+ return suffixes_matching
96
+ # Capture a local script called with $SRC/random/path/build.sh
97
+ if len(ast_node.parts) >= 1:
98
+ if '$SRC' in ast_node.parts[0].word:
99
+ suffixes_matching = []
100
+ print(ast_node.parts[0].word)
101
+ for bash_script in all_local_scripts:
102
+ print("- %s" % (bash_script))
103
+ cmd_to_exec = ast_node.parts[0].word.replace('$SRC', 'src')
104
+ if bash_script.endswith(cmd_to_exec):
105
+ suffixes_matching.append(bash_script)
106
+ print(suffixes_matching)
107
+ return suffixes_matching
108
+
109
+ return []
110
+
111
+
112
+ def handle_ast_command(ast_node, all_scripts_in_fs, raw_script):
113
+ """Generate bash script string for command node"""
114
+ new_script = ''
115
+ if should_discard_command(ast_node):
116
+ return ''
117
+
118
+ matches = is_local_redirection(ast_node, all_scripts_in_fs)
119
+ if len(matches) == 1:
120
+ new_script += parse_script(matches[0], all_scripts_in_fs) + '\n'
121
+ return ''
122
+
123
+ # Extract the command from the script string
124
+ idx_start = ast_node.pos[0]
125
+ idx_end = ast_node.pos[1]
126
+ new_script += raw_script[idx_start:idx_end]
127
+ #new_script += '\n'
128
+
129
+ # If mkdir is used, then ensure that '-p' is provided, as
130
+ # otherwise we will run into failures. We don't have to worry
131
+ # about multiple uses of -p as `mkdir -p -p -p`` is valid.
132
+ new_script = new_script.replace('mkdir', 'mkdir -p')
133
+ return new_script
134
+
135
+
136
+ def handle_ast_list(ast_node, all_scripts_in_fs, raw_script):
137
+ """Handles bashlex AST list."""
138
+ new_script = ''
139
+ try_hard = 1
140
+
141
+ if not try_hard:
142
+ list_start = ast_node.pos[0]
143
+ list_end = ast_node.pos[1]
144
+ new_script += raw_script[list_start:list_end] # + '\n'
145
+ else:
146
+ # This is more refined logic. Ideally, this should work, but it's a bit
147
+ # more intricate to get right due to e.g. white-space between positions
148
+ # and more extensive parsing needed. We don't neccesarily need this
149
+ # level of success rate for what we're trying to achieve, so am disabling
150
+ # this for now.
151
+ for part in ast_node.parts:
152
+ if part.kind == 'list':
153
+ new_script += handle_ast_list(part, all_scripts_in_fs, raw_script)
154
+ elif part.kind == 'command':
155
+ new_script += handle_ast_command(part, all_scripts_in_fs, raw_script)
156
+ else:
157
+ idx_start = part.pos[0]
158
+ idx_end = part.pos[1]
159
+ new_script += raw_script[idx_start:idx_end]
160
+ new_script += ' '
161
+
162
+ # Make sure what was created is valid syntax, and otherwise return empty
163
+ try:
164
+ bashlex.parse(new_script)
165
+ except: # pylint: disable=bare-except
166
+ # Maybe return the original here instead of skipping?
167
+ return ''
168
+ return new_script
169
+
170
+
171
+ def handle_ast_compound(ast_node, all_scripts_in_fs, raw_script):
172
+ """Handles bashlex compound AST node."""
173
+ new_script = ''
174
+ list_start = ast_node.pos[0]
175
+ list_end = ast_node.pos[1]
176
+ new_script += raw_script[list_start:list_end] + '\n'
177
+ return new_script
178
+
179
+
180
+ def handle_node(ast_node, all_scripts_in_fs, build_script):
181
+ """Generates a bash script string for a given node"""
182
+ if ast_node.kind == 'command':
183
+ return handle_ast_command(ast_node, all_scripts_in_fs, build_script)
184
+ elif ast_node.kind == 'list':
185
+ return handle_ast_list(ast_node, all_scripts_in_fs, build_script)
186
+ elif ast_node.kind == 'compound':
187
+ print('todo: handle compound')
188
+ return handle_ast_compound(ast_node, all_scripts_in_fs, build_script)
189
+ elif ast_node.kind == 'pipeline':
190
+ # Not supported
191
+ return ''
192
+ else:
193
+ raise Exception(f'Missing node handling: {ast_node.kind}')
194
+
195
+
196
+ def parse_script(bash_script, all_scripts) -> str:
197
+ """Top-level bash script parser"""
198
+ new_script = ''
199
+ with open(bash_script, 'r', encoding='utf-8') as f:
200
+ build_script = f.read()
201
+ try:
202
+ parts = bashlex.parse(build_script)
203
+ except bashlex.errors.ParsingError:
204
+ return ''
205
+ for part in parts:
206
+ new_script += handle_node(part, all_scripts, build_script)
207
+ new_script += '\n'
208
+ print("-" * 45)
209
+ print(part.kind)
210
+ print(part.dump())
211
+
212
+ return new_script
213
+
214
+
215
+ def main():
216
+ """Main function"""
217
+ all_scripts = find_all_bash_scripts_in_src()
218
+ replay_bash_script = parse_script(sys.argv[1], all_scripts)
219
+
220
+ print("REPLAYABLE BASH SCRIPT")
221
+ print("#" * 60)
222
+ print(replay_bash_script)
223
+ print("#" * 60)
224
+
225
+ out_dir = os.getenv('OUT', '/out')
226
+ with open(f'{out_dir}/replay-build-script.sh', 'w', encoding='utf-8') as f:
227
+ f.write(replay_bash_script)
228
+
229
+ src_dir = os.getenv('SRC', '/src')
230
+ with open(f'{src_dir}/replay_build.sh', 'w', encoding='utf-8') as f:
231
+ f.write(replay_bash_script)
232
+
233
+
234
+ if __name__ == "__main__":
235
+ main()
local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/base-images/base-builder/write_labels.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
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 writing from project.yaml to .labels file."""
16
+
17
+ import os
18
+ import json
19
+ import sys
20
+
21
+
22
+ def main():
23
+ """Writes labels."""
24
+ if len(sys.argv) != 3:
25
+ print('Usage: write_labels.py labels_json out_dir', file=sys.stderr)
26
+ sys.exit(1)
27
+
28
+ labels_by_target = json.loads(sys.argv[1])
29
+ out = sys.argv[2]
30
+
31
+ for target_name, labels in labels_by_target.items():
32
+ # Skip over wildcard value applying to all fuzz targets
33
+ if target_name == '*':
34
+ continue
35
+ with open(os.path.join(out, target_name + '.labels'), 'w') as file_handle:
36
+ file_handle.write('\n'.join(labels))
37
+
38
+
39
+ if __name__ == '__main__':
40
+ main()
local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/base-images/base-runner/Dockerfile ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2016 Google Inc.
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
+ # Build rust stuff in its own image. We only need the resulting binaries.
18
+ # Keeping the rust toolchain in the image wastes 1 GB.
19
+ ARG IMG_TAG=latest
20
+ FROM ghcr.io/aixcc-finals/base-image:${IMG_TAG} as temp-runner-binary-builder
21
+
22
+ RUN apt-get update && apt-get install -y cargo libyaml-dev
23
+ RUN cargo install rustfilt
24
+
25
+ # Using multi-stage build to copy some LLVM binaries needed in the runner image.
26
+ FROM ghcr.io/aixcc-finals/base-clang:${IMG_TAG} AS base-clang
27
+ FROM ghcr.io/aixcc-finals/base-builder-ruby:${IMG_TAG} AS base-ruby
28
+
29
+ # The base builder image compiles a specific Python version. Using a multi-stage build
30
+ # to copy that same Python interpreter into the runner image saves build time and keeps
31
+ # the Python versions in sync.
32
+ FROM ghcr.io/aixcc-finals/base-builder:${IMG_TAG} AS base-builder
33
+
34
+ # Real image that will be used later.
35
+ FROM ghcr.io/aixcc-finals/base-image:${IMG_TAG}
36
+
37
+ COPY --from=temp-runner-binary-builder /root/.cargo/bin/rustfilt /usr/local/bin
38
+
39
+ # Copy the binaries needed for code coverage and crash symbolization.
40
+ COPY --from=base-clang /usr/local/bin/llvm-cov \
41
+ /usr/local/bin/llvm-profdata \
42
+ /usr/local/bin/llvm-symbolizer \
43
+ /usr/local/bin/
44
+
45
+ # Copy the pre-compiled Python binaries and libraries
46
+ COPY --from=base-builder /usr/local/bin/python3.10 /usr/local/bin/python3.10
47
+ COPY --from=base-builder /usr/local/lib/libpython3.10.so.1.0 /usr/local/lib/libpython3.10.so.1.0
48
+ COPY --from=base-builder /usr/local/include/python3.10 /usr/local/include/python3.10
49
+ COPY --from=base-builder /usr/local/lib/python3.10 /usr/local/lib/python3.10
50
+ COPY --from=base-builder /usr/local/bin/pip3 /usr/local/bin/pip3
51
+
52
+ # Create symbolic links to ensure compatibility
53
+ RUN ldconfig && \
54
+ ln -s /usr/local/bin/python3.10 /usr/local/bin/python3 && \
55
+ ln -s /usr/local/bin/python3.10 /usr/local/bin/python
56
+
57
+ COPY install_deps.sh /
58
+ RUN /install_deps.sh && rm /install_deps.sh
59
+
60
+ ENV CODE_COVERAGE_SRC=/opt/code_coverage
61
+ # Pin coverage to the same as in the base builder:
62
+ # https://github.com/google/oss-fuzz/blob/master/infra/base-images/base-builder/install_python.sh#L22
63
+ RUN git clone https://chromium.googlesource.com/chromium/src/tools/code_coverage $CODE_COVERAGE_SRC && \
64
+ cd /opt/code_coverage && \
65
+ git checkout edba4873b5e8a390e977a64c522db2df18a8b27d && \
66
+ pip3 install wheel && \
67
+ # If version "Jinja2==2.10" is in requirements.txt, bump it to a patch version that
68
+ # supports upgrading its MarkupSafe dependency to a Python 3.10 compatible release:
69
+ sed -i 's/Jinja2==2.10/Jinja2==2.10.3/' requirements.txt && \
70
+ pip3 install -r requirements.txt && \
71
+ pip3 install MarkupSafe==2.0.1 && \
72
+ pip3 install coverage==6.3.2
73
+
74
+ # Default environment options for various sanitizers.
75
+ # Note that these match the settings used in ClusterFuzz and
76
+ # shouldn't be changed unless a corresponding change is made on
77
+ # ClusterFuzz side as well.
78
+ ENV ASAN_OPTIONS="alloc_dealloc_mismatch=0:allocator_may_return_null=1:allocator_release_to_os_interval_ms=500:check_malloc_usable_size=0:detect_container_overflow=1:detect_odr_violation=0:detect_leaks=1:detect_stack_use_after_return=1:fast_unwind_on_fatal=0:handle_abort=1:handle_segv=1:handle_sigill=1:max_uar_stack_size_log=16:print_scariness=1:quarantine_size_mb=10:strict_memcmp=1:strip_path_prefix=/workspace/:symbolize=1:use_sigaltstack=1:dedup_token_length=3"
79
+ ENV MSAN_OPTIONS="print_stats=1:strip_path_prefix=/workspace/:symbolize=1:dedup_token_length=3"
80
+ ENV UBSAN_OPTIONS="print_stacktrace=1:print_summary=1:silence_unsigned_overflow=1:strip_path_prefix=/workspace/:symbolize=1:dedup_token_length=3"
81
+ ENV FUZZER_ARGS="-rss_limit_mb=2560 -timeout=25"
82
+ ENV AFL_FUZZER_ARGS="-m none"
83
+
84
+ # Set up Golang environment variables (copied from /root/.bash_profile).
85
+ ENV GOPATH /root/go
86
+
87
+ # /root/.go/bin is for the standard Go binaries (i.e. go, gofmt, etc).
88
+ # $GOPATH/bin is for the binaries from the dependencies installed via "go get".
89
+ ENV PATH $PATH:$GOPATH/bin
90
+ COPY gocoverage $GOPATH/gocoverage
91
+
92
+ COPY install_go.sh /
93
+ RUN /install_go.sh && rm -rf /install_go.sh /root/.go
94
+
95
+ # Install OpenJDK 15 and trim its size by removing unused components.
96
+ ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
97
+ ENV JAVA_15_HOME=/usr/lib/jvm/java-15-openjdk-amd64
98
+ ENV JVM_LD_LIBRARY_PATH=$JAVA_HOME/lib/server
99
+ ENV PATH=$PATH:$JAVA_HOME/bin
100
+
101
+ COPY install_java.sh /
102
+ RUN /install_java.sh && rm /install_java.sh
103
+
104
+ # Install JaCoCo for JVM coverage.
105
+ RUN wget https://repo1.maven.org/maven2/org/jacoco/org.jacoco.cli/0.8.7/org.jacoco.cli-0.8.7-nodeps.jar -O /opt/jacoco-cli.jar && \
106
+ wget https://repo1.maven.org/maven2/org/jacoco/org.jacoco.agent/0.8.7/org.jacoco.agent-0.8.7-runtime.jar -O /opt/jacoco-agent.jar && \
107
+ echo "37df187b76888101ecd745282e9cd1ad4ea508d6 /opt/jacoco-agent.jar" | shasum --check && \
108
+ echo "c1814e7bba5fd8786224b09b43c84fd6156db690 /opt/jacoco-cli.jar" | shasum --check
109
+
110
+ COPY install_javascript.sh /
111
+ RUN /install_javascript.sh && rm /install_javascript.sh
112
+
113
+ # Copy built ruby and ruzzy from builder
114
+ COPY --from=base-ruby /usr/local/rvm /usr/local/rvm
115
+ COPY --from=base-ruby /install/ruzzy /install/ruzzy
116
+ COPY ruzzy /usr/bin/ruzzy
117
+ ENV PATH="$PATH:/usr/local/rvm/rubies/ruby-3.3.1/bin"
118
+ # RubyGems installation directory
119
+ ENV GEM_HOME="$OUT/fuzz-gem"
120
+ ENV GEM_PATH="/install/ruzzy"
121
+
122
+ # Do this last to make developing these files easier/faster due to caching.
123
+ COPY bad_build_check \
124
+ coverage \
125
+ coverage_helper \
126
+ download_corpus \
127
+ jacoco_report_converter.py \
128
+ nyc_report_converter.py \
129
+ rcfilt \
130
+ reproduce \
131
+ run_fuzzer \
132
+ parse_options.py \
133
+ generate_differential_cov_report.py \
134
+ profraw_update.py \
135
+ targets_list \
136
+ test_all.py \
137
+ test_one.py \
138
+ python_coverage_runner_help.py \
139
+ /usr/local/bin/
local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/base-images/base-runner/coverage ADDED
@@ -0,0 +1,549 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash -u
2
+ # Copyright 2018 Google Inc.
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
+ cd $OUT
18
+
19
+ if (( $# > 0 )); then
20
+ FUZZ_TARGETS="$@"
21
+ else
22
+ FUZZ_TARGETS="$(find . -maxdepth 1 -type f -executable -printf '%P\n' | \
23
+ grep -v -x -F \
24
+ -e 'llvm-symbolizer' \
25
+ -e 'jazzer_agent_deploy.jar' \
26
+ -e 'jazzer_driver' \
27
+ -e 'jazzer_driver_with_sanitizer' \
28
+ -e 'sanitizer_with_fuzzer.so')"
29
+ fi
30
+
31
+ COVERAGE_OUTPUT_DIR=${COVERAGE_OUTPUT_DIR:-$OUT}
32
+
33
+ DUMPS_DIR="$COVERAGE_OUTPUT_DIR/dumps"
34
+ FUZZERS_COVERAGE_DUMPS_DIR="$DUMPS_DIR/fuzzers_coverage"
35
+ MERGED_COVERAGE_DIR="$COVERAGE_OUTPUT_DIR/merged_coverage"
36
+ FUZZER_STATS_DIR="$COVERAGE_OUTPUT_DIR/fuzzer_stats"
37
+ TEXTCOV_REPORT_DIR="$COVERAGE_OUTPUT_DIR/textcov_reports"
38
+ LOGS_DIR="$COVERAGE_OUTPUT_DIR/logs"
39
+ REPORT_ROOT_DIR="$COVERAGE_OUTPUT_DIR/report"
40
+ REPORT_BY_TARGET_ROOT_DIR="$COVERAGE_OUTPUT_DIR/report_target"
41
+ PLATFORM=linux
42
+ REPORT_PLATFORM_DIR="$COVERAGE_OUTPUT_DIR/report/$PLATFORM"
43
+
44
+ for directory in $DUMPS_DIR $FUZZER_STATS_DIR $LOGS_DIR $REPORT_ROOT_DIR $TEXTCOV_REPORT_DIR\
45
+ $REPORT_PLATFORM_DIR $REPORT_BY_TARGET_ROOT_DIR $FUZZERS_COVERAGE_DUMPS_DIR $MERGED_COVERAGE_DIR; do
46
+ rm -rf $directory
47
+ mkdir -p $directory
48
+ done
49
+
50
+ PROFILE_FILE="$DUMPS_DIR/merged.profdata"
51
+ SUMMARY_FILE="$REPORT_PLATFORM_DIR/summary.json"
52
+ COVERAGE_TARGET_FILE="$FUZZER_STATS_DIR/coverage_targets.txt"
53
+
54
+ # Use path mapping, as $SRC directory from the builder is copied into $OUT/$SRC.
55
+ PATH_EQUIVALENCE_ARGS="-path-equivalence=/,$OUT"
56
+
57
+ # It's important to use $COVERAGE_EXTRA_ARGS as the last argument, because it
58
+ # can contain paths to source files / directories which are positional args.
59
+ LLVM_COV_COMMON_ARGS="$PATH_EQUIVALENCE_ARGS \
60
+ -ignore-filename-regex=.*src/libfuzzer/.* $COVERAGE_EXTRA_ARGS"
61
+
62
+ # Options to extract branch coverage.
63
+ BRANCH_COV_ARGS="--show-branches=count --show-expansions"
64
+
65
+ # Timeout for running a single fuzz target.
66
+ TIMEOUT=1h
67
+
68
+ # This will be used by llvm-cov command to generate the actual report.
69
+ objects=""
70
+
71
+ # Number of CPUs available, this is needed for running tests in parallel.
72
+ # Set the max number of parallel jobs to be the CPU count and a max of 10.
73
+ NPROC=$(nproc)
74
+ MAX_PARALLEL_COUNT=10
75
+
76
+ CORPUS_DIR=${CORPUS_DIR:-"/corpus"}
77
+
78
+ function run_fuzz_target {
79
+ local target=$1
80
+
81
+ # '%1m' will produce separate dump files for every object. For example, if a
82
+ # fuzz target loads a shared library, we will have dumps for both of them.
83
+ local profraw_file="$DUMPS_DIR/$target.%1m.profraw"
84
+ local profraw_file_mask="$DUMPS_DIR/$target.*.profraw"
85
+ local profdata_file="$DUMPS_DIR/$target.profdata"
86
+ local corpus_real="$CORPUS_DIR/${target}"
87
+
88
+ # -merge=1 requires an output directory, create a new, empty dir for that.
89
+ local corpus_dummy="$OUT/dummy_corpus_dir_for_${target}"
90
+ rm -rf $corpus_dummy && mkdir -p $corpus_dummy
91
+
92
+ # Use -merge=1 instead of -runs=0 because merge is crash resistant and would
93
+ # let to get coverage using all corpus files even if there are crash inputs.
94
+ # Merge should not introduce any significant overhead compared to -runs=0,
95
+ # because (A) corpuses are already minimized; (B) we do not use sancov, and so
96
+ # libFuzzer always finishes merge with an empty output dir.
97
+ # Use 100s timeout instead of 25s as code coverage builds can be very slow.
98
+ local args="-merge=1 -timeout=100 $corpus_dummy $corpus_real"
99
+
100
+ export LLVM_PROFILE_FILE=$profraw_file
101
+ timeout $TIMEOUT $OUT/$target $args &> $LOGS_DIR/$target.log
102
+ if (( $? != 0 )); then
103
+ echo "Error occured while running $target:"
104
+ cat $LOGS_DIR/$target.log
105
+ fi
106
+
107
+ rm -rf $corpus_dummy
108
+ if (( $(du -c $profraw_file_mask | tail -n 1 | cut -f 1) == 0 )); then
109
+ # Skip fuzz targets that failed to produce profile dumps.
110
+ return 0
111
+ fi
112
+
113
+ # If necessary translate to latest profraw version.
114
+ if [[ $target == *"@"* ]]; then
115
+ # Extract fuzztest binary name from fuzztest wrapper script.
116
+ target=(${target//@/ }[0])
117
+ fi
118
+ profraw_update.py $OUT/$target -i $profraw_file_mask
119
+ llvm-profdata merge -j=1 -sparse $profraw_file_mask -o $profdata_file
120
+
121
+ # Delete unnecessary and (potentially) large .profraw files.
122
+ rm $profraw_file_mask
123
+
124
+ shared_libraries=$(coverage_helper shared_libs -build-dir=$OUT -object=$target)
125
+
126
+ llvm-cov export -summary-only -instr-profile=$profdata_file -object=$target \
127
+ $shared_libraries $LLVM_COV_COMMON_ARGS > $FUZZER_STATS_DIR/$target.json
128
+
129
+ # For introspector.
130
+ llvm-cov show -instr-profile=$profdata_file -object=$target -line-coverage-gt=0 $shared_libraries $BRANCH_COV_ARGS $LLVM_COV_COMMON_ARGS > ${TEXTCOV_REPORT_DIR}/$target.covreport
131
+ }
132
+
133
+ function run_go_fuzz_target {
134
+ local target=$1
135
+
136
+ echo "Running go target $target"
137
+ export FUZZ_CORPUS_DIR="$CORPUS_DIR/${target}/"
138
+ export FUZZ_PROFILE_NAME="$DUMPS_DIR/$target.perf"
139
+
140
+ # setup for native go fuzzers
141
+ cd $OUT
142
+ mkdir -p "testdata/fuzz/${target}"
143
+ cp -r "${FUZZ_CORPUS_DIR}" "testdata/fuzz/"
144
+
145
+ # rewrite libFuzzer corpus to Std Go corpus if native fuzzing
146
+ grep "TestFuzzCorpus" $target > /dev/null 2>&1 && $SYSGOPATH/bin/convertcorpus $target "testdata/fuzz/${target}"
147
+ cd -
148
+
149
+ timeout $TIMEOUT $OUT/$target -test.coverprofile $DUMPS_DIR/$target.profdata &> $LOGS_DIR/$target.log
150
+ if (( $? != 0 )); then
151
+ echo "Error occured while running $target:"
152
+ cat $LOGS_DIR/$target.log
153
+ fi
154
+
155
+ # cleanup after native go fuzzers
156
+ rm -r "${OUT}/testdata/fuzz/${target}"
157
+
158
+ # The Go 1.18 fuzzers are renamed to "*_fuzz_.go" during "infra/helper.py build_fuzzers".
159
+ # They are are therefore refered to as "*_fuzz_.go" in the profdata files.
160
+ # Since the copies named "*_fuzz_.go" do not exist in the file tree during
161
+ # the coverage build, we change the references in the .profdata files
162
+ # to the original file names.
163
+ #sed -i "s/_test.go_fuzz_.go/_test.go/g" $DUMPS_DIR/$target.profdata
164
+ # translate from golangish paths to current absolute paths
165
+ cat $OUT/$target.gocovpath | while read i; do sed -i $i $DUMPS_DIR/$target.profdata; done
166
+ # cf PATH_EQUIVALENCE_ARGS
167
+ sed -i 's=/='$OUT'/=' $DUMPS_DIR/$target.profdata
168
+ $SYSGOPATH/bin/gocovsum $DUMPS_DIR/$target.profdata > $FUZZER_STATS_DIR/$target.json
169
+ }
170
+
171
+ function run_python_fuzz_target {
172
+ local target=$1
173
+ local zipped_sources="$DUMPS_DIR/$target.deps.zip"
174
+ local corpus_real="$CORPUS_DIR/${target}"
175
+ # Write dummy stats file
176
+ echo "{}" > "$FUZZER_STATS_DIR/$target.json"
177
+
178
+ # Run fuzzer
179
+ $OUT/$target $corpus_real -atheris_runs=$(ls -la $corpus_real | wc -l) > $LOGS_DIR/$target.log 2>&1
180
+ if (( $? != 0 )); then
181
+ echo "Error happened getting coverage of $target"
182
+ echo "This is likely because Atheris did not exit gracefully"
183
+ cat $LOGS_DIR/$target.log
184
+ return 0
185
+ fi
186
+ mv .coverage $OUT/.coverage_$target
187
+ }
188
+
189
+ function run_java_fuzz_target {
190
+ local target=$1
191
+
192
+ local exec_file="$DUMPS_DIR/$target.exec"
193
+ local class_dump_dir="$DUMPS_DIR/${target}_classes/"
194
+ mkdir "$class_dump_dir"
195
+ local corpus_real="$CORPUS_DIR/${target}"
196
+
197
+ # -merge=1 requires an output directory, create a new, empty dir for that.
198
+ local corpus_dummy="$OUT/dummy_corpus_dir_for_${target}"
199
+ rm -rf $corpus_dummy && mkdir -p $corpus_dummy
200
+
201
+ # Use 100s timeout instead of 25s as code coverage builds can be very slow.
202
+ local jacoco_args="destfile=$exec_file,classdumpdir=$class_dump_dir,excludes=com.code_intelligence.jazzer.*\\:com.sun.tools.attach.VirtualMachine"
203
+ local args="-merge=1 -timeout=100 --nohooks \
204
+ --additional_jvm_args=-javaagent\\:/opt/jacoco-agent.jar=$jacoco_args \
205
+ $corpus_dummy $corpus_real"
206
+
207
+ timeout $TIMEOUT $OUT/$target $args &> $LOGS_DIR/$target.log
208
+ if (( $? != 0 )); then
209
+ echo "Error occured while running $target:"
210
+ cat $LOGS_DIR/$target.log
211
+ fi
212
+
213
+ if (( $(du -c $exec_file | tail -n 1 | cut -f 1) == 0 )); then
214
+ # Skip fuzz targets that failed to produce .exec files.
215
+ echo "$target failed to produce .exec file."
216
+ return 0
217
+ fi
218
+
219
+ # Generate XML report only as input to jacoco_report_converter.
220
+ # Source files are not needed for the summary.
221
+ local xml_report="$DUMPS_DIR/${target}.xml"
222
+ local summary_file="$FUZZER_STATS_DIR/$target.json"
223
+ java -jar /opt/jacoco-cli.jar report $exec_file \
224
+ --xml $xml_report \
225
+ --classfiles $class_dump_dir
226
+
227
+ # Write llvm-cov summary file.
228
+ jacoco_report_converter.py $xml_report $summary_file
229
+ }
230
+
231
+ function run_javascript_fuzz_target {
232
+ local target=$1
233
+ local corpus_real="$CORPUS_DIR/${target}"
234
+
235
+ # -merge=1 requires an output directory, create a new, empty dir for that.
236
+ local corpus_dummy="$OUT/dummy_corpus_dir_for_${target}"
237
+ rm -rf $corpus_dummy && mkdir -p $corpus_dummy
238
+
239
+ # IstanbulJS currently does not work when the tested program creates
240
+ # subprocesses. For this reason, we first minimize the corpus removing
241
+ # any crashing inputs so that we can report source-based code coverage
242
+ # with a single sweep over the minimized corpus
243
+ local merge_args="-merge=1 -timeout=100 $corpus_dummy $corpus_real"
244
+ timeout $TIMEOUT $OUT/$target $merge_args &> $LOGS_DIR/$target.log
245
+
246
+ # nyc saves the coverage reports in a directory with the default name "coverage"
247
+ local coverage_dir="$DUMPS_DIR/coverage_dir_for_${target}"
248
+ rm -rf $coverage_dir && mkdir -p $coverage_dir
249
+
250
+ local nyc_json_coverage_file="$coverage_dir/coverage-final.json"
251
+ local nyc_json_summary_file="$coverage_dir/coverage-summary.json"
252
+
253
+ local args="-runs=0 $corpus_dummy"
254
+ local jazzerjs_args="--coverage --coverageDirectory $coverage_dir --coverageReporters json --coverageReporters json-summary"
255
+
256
+ JAZZERJS_EXTRA_ARGS=$jazzerjs_args $OUT/$target $args &> $LOGS_DIR/$target.log
257
+
258
+ if (( $? != 0 )); then
259
+ echo "Error occured while running $target:"
260
+ cat $LOGS_DIR/$target.log
261
+ fi
262
+
263
+ if [ ! -s $nyc_json_coverage_file ]; then
264
+ # Skip fuzz targets that failed to produce coverage-final.json file.
265
+ echo "$target failed to produce coverage-final.json file."
266
+ return 0
267
+ fi
268
+
269
+ cp $nyc_json_coverage_file $FUZZERS_COVERAGE_DUMPS_DIR/$target.json
270
+
271
+ local summary_file="$FUZZER_STATS_DIR/$target.json"
272
+
273
+ nyc_report_converter.py $nyc_json_summary_file $summary_file
274
+ }
275
+
276
+ function generate_html {
277
+ local profdata=$1
278
+ local shared_libraries=$2
279
+ local objects=$3
280
+ local output_dir=$4
281
+
282
+ rm -rf "$output_dir"
283
+ mkdir -p "$output_dir/$PLATFORM"
284
+
285
+ local llvm_cov_args="-instr-profile=$profdata $objects $LLVM_COV_COMMON_ARGS"
286
+ llvm-cov show -format=html -output-dir=$output_dir -Xdemangler rcfilt $llvm_cov_args
287
+
288
+ # Export coverage summary in JSON format.
289
+ local summary_file=$output_dir/$PLATFORM/summary.json
290
+
291
+ llvm-cov export -summary-only $llvm_cov_args > $summary_file
292
+
293
+ coverage_helper -v post_process -src-root-dir=/ -summary-file=$summary_file \
294
+ -output-dir=$output_dir $PATH_EQUIVALENCE_ARGS
295
+ }
296
+
297
+ export SYSGOPATH=$GOPATH
298
+ export GOPATH=$OUT/$GOPATH
299
+ # Run each fuzz target, generate raw coverage dumps.
300
+ for fuzz_target in $FUZZ_TARGETS; do
301
+ # Test if fuzz target is a golang one.
302
+ if [[ $FUZZING_LANGUAGE == "go" ]]; then
303
+ # Continue if not a fuzz target.
304
+ if [[ $FUZZING_ENGINE != "none" ]]; then
305
+ grep "FUZZ_CORPUS_DIR" $fuzz_target > /dev/null 2>&1 || grep "testing\.T" $fuzz_target > /dev/null 2>&1 || continue
306
+ fi
307
+ # Log the target in the targets file.
308
+ echo ${fuzz_target} >> $COVERAGE_TARGET_FILE
309
+
310
+ # Run the coverage collection.
311
+ run_go_fuzz_target $fuzz_target &
312
+ elif [[ $FUZZING_LANGUAGE == "python" ]]; then
313
+ echo "Entering python fuzzing"
314
+ # Log the target in the targets file.
315
+ echo ${fuzz_target} >> $COVERAGE_TARGET_FILE
316
+
317
+ # Run the coverage collection.
318
+ run_python_fuzz_target $fuzz_target
319
+ elif [[ $FUZZING_LANGUAGE == "jvm" ]]; then
320
+ # Continue if not a fuzz target.
321
+ if [[ $FUZZING_ENGINE != "none" ]]; then
322
+ grep "LLVMFuzzerTestOneInput" $fuzz_target > /dev/null 2>&1 || continue
323
+ fi
324
+
325
+ echo "Running $fuzz_target"
326
+ # Log the target in the targets file.
327
+ echo ${fuzz_target} >> $COVERAGE_TARGET_FILE
328
+
329
+ # Run the coverage collection.
330
+ run_java_fuzz_target $fuzz_target &
331
+ elif [[ $FUZZING_LANGUAGE == "javascript" ]]; then
332
+ # Continue if not a fuzz target.
333
+ if [[ $FUZZING_ENGINE != "none" ]]; then
334
+ grep "LLVMFuzzerTestOneInput" $fuzz_target > /dev/null 2>&1 || continue
335
+ fi
336
+
337
+ echo "Running $fuzz_target"
338
+ # Log the target in the targets file.
339
+ echo ${fuzz_target} >> $COVERAGE_TARGET_FILE
340
+
341
+ # Run the coverage collection.
342
+ run_javascript_fuzz_target $fuzz_target &
343
+ else
344
+ # Continue if not a fuzz target.
345
+ if [[ $FUZZING_ENGINE != "none" ]]; then
346
+ grep "LLVMFuzzerTestOneInput" $fuzz_target > /dev/null 2>&1 || continue
347
+ fi
348
+
349
+ echo "Running $fuzz_target"
350
+ # Log the target in the targets file.
351
+ echo ${fuzz_target} >> $COVERAGE_TARGET_FILE
352
+
353
+ # Run the coverage collection.
354
+ run_fuzz_target $fuzz_target &
355
+
356
+ # Rewrite object if its a FUZZTEST target
357
+ if [[ $fuzz_target == *"@"* ]]; then
358
+ # Extract fuzztest binary name from fuzztest wrapper script.
359
+ fuzz_target=(${fuzz_target//@/ }[0])
360
+ fi
361
+ if [[ -z $objects ]]; then
362
+ # The first object needs to be passed without -object= flag.
363
+ objects="$fuzz_target"
364
+ else
365
+ objects="$objects -object=$fuzz_target"
366
+ fi
367
+ fi
368
+
369
+
370
+ # Limit the number of processes to be spawned.
371
+ n_child_proc=$(jobs -rp | wc -l)
372
+ while [[ "$n_child_proc" -eq "$NPROC" || "$n_child_proc" -gt "$MAX_PARALLEL_COUNT" ]]; do
373
+ sleep 4
374
+ n_child_proc=$(jobs -rp | wc -l)
375
+ done
376
+ done
377
+
378
+ # Wait for background processes to finish.
379
+ wait
380
+
381
+ if [[ $FUZZING_LANGUAGE == "go" ]]; then
382
+ echo $DUMPS_DIR
383
+ $SYSGOPATH/bin/gocovmerge $DUMPS_DIR/*.profdata > fuzz.cov
384
+ gotoolcover -html=fuzz.cov -o $REPORT_ROOT_DIR/index.html
385
+ $SYSGOPATH/bin/gocovsum fuzz.cov > $SUMMARY_FILE
386
+ cp $REPORT_ROOT_DIR/index.html $REPORT_PLATFORM_DIR/index.html
387
+ $SYSGOPATH/bin/pprof-merge $DUMPS_DIR/*.perf.cpu.prof
388
+ mv merged.data $REPORT_ROOT_DIR/cpu.prof
389
+ $SYSGOPATH/bin/pprof-merge $DUMPS_DIR/*.perf.heap.prof
390
+ mv merged.data $REPORT_ROOT_DIR/heap.prof
391
+ #TODO some proxy for go tool pprof -http=127.0.0.1:8001 $DUMPS_DIR/cpu.prof
392
+ echo "Finished generating code coverage report for Go fuzz targets."
393
+ elif [[ $FUZZING_LANGUAGE == "python" ]]; then
394
+ # Extract source files from all dependency zip folders
395
+ mkdir -p /pythoncovmergedfiles/medio
396
+ PYCOVDIR=/pycovdir/
397
+ mkdir $PYCOVDIR
398
+ for fuzzer in $FUZZ_TARGETS; do
399
+ fuzzer_deps=${fuzzer}.pkg.deps.zip
400
+ unzip $OUT/${fuzzer_deps}
401
+ rsync -r ./medio /pythoncovmergedfiles/medio
402
+ rm -rf ./medio
403
+
404
+ # Translate paths in unzipped folders to paths that we can use
405
+ mv $OUT/.coverage_$fuzzer .coverage
406
+ python3 /usr/local/bin/python_coverage_runner_help.py translate /pythoncovmergedfiles/medio
407
+ cp .new_coverage $PYCOVDIR/.coverage_$fuzzer
408
+ cp .new_coverage $OUT/coverage_d_$fuzzer
409
+ done
410
+
411
+ # Combine coverage
412
+ cd $PYCOVDIR
413
+ python3 /usr/local/bin/python_coverage_runner_help.py combine .coverage_*
414
+ python3 /usr/local/bin/python_coverage_runner_help.py html
415
+ # Produce all_cov file used by fuzz introspector.
416
+ python3 /usr/local/bin/python_coverage_runner_help.py json -o ${TEXTCOV_REPORT_DIR}/all_cov.json
417
+
418
+ # Generate .json with similar format to llvm-cov output.
419
+ python3 /usr/local/bin/python_coverage_runner_help.py \
420
+ convert-to-summary-json ${TEXTCOV_REPORT_DIR}/all_cov.json $SUMMARY_FILE
421
+
422
+ # Copy coverage date out
423
+ cp htmlcov/status.json ${TEXTCOV_REPORT_DIR}/html_status.json
424
+
425
+ mv htmlcov/* $REPORT_PLATFORM_DIR/
426
+ mv .coverage_* $REPORT_PLATFORM_DIR/
427
+ elif [[ $FUZZING_LANGUAGE == "jvm" ]]; then
428
+
429
+ # From this point on the script does not tolerate any errors.
430
+ set -e
431
+
432
+ # Merge .exec files from the individual targets.
433
+ jacoco_merged_exec=$DUMPS_DIR/jacoco.merged.exec
434
+ java -jar /opt/jacoco-cli.jar merge $DUMPS_DIR/*.exec \
435
+ --destfile $jacoco_merged_exec
436
+
437
+ # Prepare classes directory for jacoco process
438
+ classes_dir=$DUMPS_DIR/classes
439
+ mkdir $classes_dir
440
+
441
+ # Only copy class files found in $OUT/$SRC to ensure they are
442
+ # lively compiled from the project, avoiding inclusion of
443
+ # dependency classes. This also includes the fuzzer classes.
444
+ find "$OUT/$SRC" -type f -name "*.class" | while read -r class_file; do
445
+ # Skip module-info.class
446
+ if [[ "$(basename "$class_file")" == "module-info.class" ]]; then
447
+ continue
448
+ fi
449
+
450
+ # Use javap to extract the fully qualified name of the class and copy it to $classes_dir
451
+ fqn=$(javap -verbose "$class_file" 2>/dev/null | grep "this_class:" | grep -oP '(?<=// ).*')
452
+ if [ -n "$fqn" ]; then
453
+ mkdir -p $classes_dir/$(dirname $fqn)
454
+ cp $class_file $classes_dir/$fqn.class
455
+ fi
456
+ done
457
+
458
+ # Heuristically determine source directories based on Maven structure.
459
+ # Always include the $SRC root as it likely contains the fuzzer sources.
460
+ sourcefiles_args=(--sourcefiles $OUT/$SRC)
461
+ source_dirs=$(find $OUT/$SRC -type d -name 'java')
462
+ for source_dir in $source_dirs; do
463
+ sourcefiles_args+=(--sourcefiles "$source_dir")
464
+ done
465
+
466
+ # Generate HTML and XML reports.
467
+ xml_report=$REPORT_PLATFORM_DIR/index.xml
468
+ java -jar /opt/jacoco-cli.jar report $jacoco_merged_exec \
469
+ --html $REPORT_PLATFORM_DIR \
470
+ --xml $xml_report \
471
+ --classfiles $classes_dir \
472
+ "${sourcefiles_args[@]}"
473
+
474
+ # Also serve the raw exec file and XML report, which can be useful for
475
+ # automated analysis.
476
+ cp $jacoco_merged_exec $REPORT_PLATFORM_DIR/jacoco.exec
477
+ cp $xml_report $REPORT_PLATFORM_DIR/jacoco.xml
478
+ cp $xml_report $TEXTCOV_REPORT_DIR/jacoco.xml
479
+
480
+ # Write llvm-cov summary file.
481
+ jacoco_report_converter.py $xml_report $SUMMARY_FILE
482
+
483
+ set +e
484
+ elif [[ $FUZZING_LANGUAGE == "javascript" ]]; then
485
+
486
+ # From this point on the script does not tolerate any errors.
487
+ set -e
488
+
489
+ json_report=$MERGED_COVERAGE_DIR/coverage.json
490
+ nyc merge $FUZZERS_COVERAGE_DUMPS_DIR $json_report
491
+
492
+ nyc report -t $MERGED_COVERAGE_DIR --report-dir $REPORT_PLATFORM_DIR --reporter=html --reporter=json-summary
493
+
494
+ nyc_json_summary_file=$REPORT_PLATFORM_DIR/coverage-summary.json
495
+
496
+ # Write llvm-cov summary file.
497
+ nyc_report_converter.py $nyc_json_summary_file $SUMMARY_FILE
498
+
499
+ set +e
500
+ else
501
+
502
+ # From this point on the script does not tolerate any errors.
503
+ set -e
504
+
505
+ # Merge all dumps from the individual targets.
506
+ rm -f $PROFILE_FILE
507
+ llvm-profdata merge -sparse $DUMPS_DIR/*.profdata -o $PROFILE_FILE
508
+
509
+ # TODO(mmoroz): add script from Chromium for rendering directory view reports.
510
+ # The first path in $objects does not have -object= prefix (llvm-cov format).
511
+ shared_libraries=$(coverage_helper shared_libs -build-dir=$OUT -object=$objects)
512
+ objects="$objects $shared_libraries"
513
+
514
+ generate_html $PROFILE_FILE "$shared_libraries" "$objects" "$REPORT_ROOT_DIR"
515
+
516
+ # Per target reports.
517
+ for fuzz_target in $FUZZ_TARGETS; do
518
+ if [[ $fuzz_target == *"@"* ]]; then
519
+ profdata_path=$DUMPS_DIR/$fuzz_target.profdata
520
+ report_dir=$REPORT_BY_TARGET_ROOT_DIR/$fuzz_target
521
+ # Extract fuzztest binary name from fuzztest wrapper script.
522
+ fuzz_target=(${fuzz_target//@/ }[0])
523
+ else
524
+ profdata_path=$DUMPS_DIR/$fuzz_target.profdata
525
+ report_dir=$REPORT_BY_TARGET_ROOT_DIR/$fuzz_target
526
+ fi
527
+ if [[ ! -f "$profdata_path" ]]; then
528
+ echo "WARNING: $fuzz_target has no profdata generated."
529
+ continue
530
+ fi
531
+
532
+ generate_html $profdata_path "$shared_libraries" "$fuzz_target" "$report_dir"
533
+ done
534
+
535
+ set +e
536
+ fi
537
+
538
+ # Make sure report is readable.
539
+ chmod -R +r $REPORT_ROOT_DIR $REPORT_BY_TARGET_ROOT_DIR
540
+ find $REPORT_ROOT_DIR $REPORT_BY_TARGET_ROOT_DIR -type d -exec chmod +x {} +
541
+
542
+ # HTTP_PORT is optional.
543
+ set +u
544
+ if [[ -n $HTTP_PORT ]]; then
545
+ # Serve the report locally.
546
+ echo "Serving the report on http://127.0.0.1:$HTTP_PORT/linux/index.html"
547
+ cd $REPORT_ROOT_DIR
548
+ python3 -m http.server $HTTP_PORT
549
+ fi
local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/base-images/base-runner/coverage_helper ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash -u
2
+ # Copyright 2018 Google Inc.
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
+ python3 $CODE_COVERAGE_SRC/coverage_utils.py $@
local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/base-images/base-runner/download_corpus ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash -u
2
+ # Copyright 2018 Google Inc.
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
+ if (( $# < 1 )); then
19
+ echo "Usage: $0 \"path_download_to url_download_from\" (can be repeated)" >&2
20
+ exit 1
21
+ fi
22
+
23
+ for pair in "$@"; do
24
+ read path url <<< "$pair"
25
+ wget -q -O $path $url
26
+ done
27
+
28
+ # Always exit with 0 as we do not track wget return codes and should not rely
29
+ # on the latest command execution.
30
+ exit 0
local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/base-images/base-runner/generate_differential_cov_report.py ADDED
@@ -0,0 +1,228 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ #
3
+ # Copyright 2023 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
+ """Script for generating differential coverage reports.
19
+ generate_differential_cov_report.py <profdata-dump-directory> \
20
+ <profdata-directory-to-subtract-from-first> <output-directory>
21
+ """
22
+ import os
23
+ import shutil
24
+ import subprocess
25
+ import sys
26
+
27
+
28
+ class ProfData:
29
+ """Class representing a profdata file."""
30
+
31
+ def __init__(self, text):
32
+ self.function_profs = []
33
+ for function_prof in text.split('\n\n'):
34
+ if not function_prof:
35
+ continue
36
+ self.function_profs.append(FunctionProf(function_prof))
37
+
38
+ def to_string(self):
39
+ """Convert back to a string."""
40
+ return '\n'.join(
41
+ [function_prof.to_string() for function_prof in self.function_profs])
42
+
43
+ def find_function(self, function, idx=None):
44
+ """Find the same function in this profdata."""
45
+ if idx is not None:
46
+ try:
47
+ possibility = self.function_profs[idx]
48
+ if function.func_hash == possibility.func_hash:
49
+ return possibility
50
+ except IndexError:
51
+ pass
52
+ for function_prof in self.function_profs:
53
+ if function_prof.func_hash == function.func_hash:
54
+ return function_prof
55
+ return None
56
+
57
+ def subtract(self, subtrahend):
58
+ """Subtract subtrahend from this profdata."""
59
+ for idx, function_prof in enumerate(self.function_profs):
60
+ subtrahend_function_prof = subtrahend.find_function(function_prof, idx)
61
+ function_prof.subtract(subtrahend_function_prof)
62
+
63
+
64
+ class FunctionProf:
65
+ """Profile of a function."""
66
+ FUNC_HASH_COMMENT_LINE = '# Func Hash:'
67
+ NUM_COUNTERS_COMMENT_LINE = '# Num Counters:'
68
+ COUNTER_VALUES_COMMENT_LINE = '# Counter Values:'
69
+
70
+ def __init__(self, text):
71
+ print(text)
72
+ lines = text.splitlines()
73
+ self.function = lines[0]
74
+ assert self.FUNC_HASH_COMMENT_LINE == lines[1]
75
+ self.func_hash = lines[2]
76
+ assert self.NUM_COUNTERS_COMMENT_LINE == lines[3]
77
+ self.num_counters = int(lines[4])
78
+ assert self.COUNTER_VALUES_COMMENT_LINE == lines[5]
79
+ self.counter_values = [1 if int(line) else 0 for line in lines[6:]]
80
+
81
+ def to_string(self):
82
+ """Convert back to text."""
83
+ lines = [
84
+ self.function,
85
+ self.FUNC_HASH_COMMENT_LINE,
86
+ self.func_hash,
87
+ self.NUM_COUNTERS_COMMENT_LINE,
88
+ str(self.num_counters),
89
+ self.COUNTER_VALUES_COMMENT_LINE,
90
+ ] + [str(num) for num in self.counter_values]
91
+ return '\n'.join(lines)
92
+
93
+ def subtract(self, subtrahend_prof):
94
+ """Subtract this other function from this function."""
95
+ if not subtrahend_prof:
96
+ print(self.function, 'has no subtrahend')
97
+ # Nothing to subtract.
98
+ return
99
+ self.counter_values = [
100
+ max(counter1 - counter2, 0) for counter1, counter2 in zip(
101
+ self.counter_values, subtrahend_prof.counter_values)
102
+ ]
103
+
104
+
105
+ def get_profdata_files(directory):
106
+ """Returns profdata files in |directory|."""
107
+ profdatas = []
108
+ for filename in os.listdir(directory):
109
+ filename = os.path.join(directory, filename)
110
+ if filename.endswith('.profdata'):
111
+ profdatas.append(filename)
112
+ return profdatas
113
+
114
+
115
+ def convert_profdata_to_text(profdata):
116
+ """Convert a profdata binary file to a profdata text file."""
117
+ profdata_text = f'{profdata}.txt'
118
+ if os.path.exists(profdata_text):
119
+ os.remove(profdata_text)
120
+ command = [
121
+ 'llvm-profdata', 'merge', '-j=1', '-sparse', profdata, '--text', '-o',
122
+ profdata_text
123
+ ]
124
+ print(command)
125
+ subprocess.run(command, check=True)
126
+ return profdata_text
127
+
128
+
129
+ def convert_text_profdata_to_bin(profdata_text):
130
+ """Convert a profdata text file to a profdata binary file."""
131
+ profdata = profdata_text.replace('.txt', '').replace('.profdata',
132
+ '') + '.profdata'
133
+ print('bin profdata', profdata)
134
+ if os.path.exists(profdata):
135
+ os.remove(profdata)
136
+ command = [
137
+ 'llvm-profdata', 'merge', '-j=1', '-sparse', profdata_text, '-o', profdata
138
+ ]
139
+ print(command)
140
+ subprocess.run(command, check=True)
141
+ return profdata
142
+
143
+
144
+ def get_difference(minuend_filename, subtrahend_filename):
145
+ """Subtract subtrahend_filename from minuend_filename."""
146
+ with open(minuend_filename, 'r', encoding='utf-8') as minuend_file:
147
+ print('minuend', minuend_filename)
148
+ minuend = ProfData(minuend_file.read())
149
+ with open(subtrahend_filename, 'r', encoding='utf-8') as subtrahend_file:
150
+ print('subtrahend', subtrahend_filename)
151
+ subtrahend = ProfData(subtrahend_file.read())
152
+
153
+ minuend.subtract(subtrahend)
154
+ return minuend
155
+
156
+
157
+ def profdatas_to_objects(profdatas):
158
+ """Get the corresponding objects for each profdata."""
159
+ return [
160
+ os.path.splitext(os.path.basename(profdata))[0] for profdata in profdatas
161
+ ]
162
+
163
+
164
+ def generate_differential_cov_reports(minuend_profdatas, subtrahend_profdatas,
165
+ difference_dir):
166
+ """Calculate the differences between all profdatas and generate differential
167
+ coverage reports."""
168
+ profdata_objects = profdatas_to_objects(minuend_profdatas)
169
+ real_profdata_objects = [
170
+ binobject for binobject in profdata_objects if binobject != 'merged'
171
+ ]
172
+ for minuend, subtrahend, binobject in zip(minuend_profdatas,
173
+ subtrahend_profdatas,
174
+ profdata_objects):
175
+ minuend_text = convert_profdata_to_text(minuend)
176
+ subtrahend_text = convert_profdata_to_text(subtrahend)
177
+ difference = get_difference(minuend_text, subtrahend_text)
178
+ basename = os.path.basename(minuend_text)
179
+ difference_text = os.path.join(difference_dir, basename)
180
+ with open(difference_text, 'w', encoding='utf-8') as file_handle:
181
+ file_handle.write(difference.to_string())
182
+ difference_profdata = convert_text_profdata_to_bin(difference_text)
183
+ if not difference_profdata.endswith('merged.profdata'):
184
+ generate_html_report(difference_profdata, [binobject],
185
+ os.path.join(difference_dir, binobject))
186
+ else:
187
+ generate_html_report(difference_profdata, real_profdata_objects,
188
+ os.path.join(difference_dir, 'merged'))
189
+
190
+
191
+ def generate_html_report(profdata, objects, directory):
192
+ """Generate an HTML coverage report."""
193
+ # TODO(metzman): Deal with shared libs.
194
+ html_dir = os.path.join(directory, 'reports')
195
+ if os.path.exists(html_dir):
196
+ os.remove(html_dir)
197
+ os.makedirs(html_dir)
198
+ out_dir = os.getenv('OUT', '/out')
199
+ command = [
200
+ 'llvm-cov', 'show', f'-path-equivalence=/,{out_dir}', '-format=html',
201
+ '-Xdemangler', 'rcfilt', f'-instr-profile={profdata}'
202
+ ]
203
+
204
+ objects = [os.path.join(out_dir, binobject) for binobject in objects]
205
+ command += objects + ['-o', html_dir]
206
+ print(' '.join(command))
207
+ subprocess.run(command, check=True)
208
+
209
+
210
+ def main():
211
+ """Generate differential coverage reports."""
212
+ if len(sys.argv) != 4:
213
+ print(
214
+ f'Usage: {sys.argv[0]} <minuend_dir> <subtrahend_dir> <difference_dir>')
215
+ minuend_dir = sys.argv[1]
216
+ subtrahend_dir = sys.argv[2]
217
+ difference_dir = sys.argv[3]
218
+ if os.path.exists(difference_dir):
219
+ shutil.rmtree(difference_dir)
220
+ os.makedirs(difference_dir, exist_ok=True)
221
+ minuend_profdatas = get_profdata_files(minuend_dir)
222
+ subtrahend_profdatas = get_profdata_files(subtrahend_dir)
223
+ generate_differential_cov_reports(minuend_profdatas, subtrahend_profdatas,
224
+ difference_dir)
225
+
226
+
227
+ if __name__ == '__main__':
228
+ main()
local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/base-images/base-runner/install_deps.sh ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash -eux
2
+ # Copyright 2022 Google LLC
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ ################################################################################
17
+
18
+ # Install dependencies in a platform-aware way.
19
+
20
+ apt-get update && apt-get install -y \
21
+ binutils \
22
+ file \
23
+ ca-certificates \
24
+ fonts-dejavu \
25
+ git \
26
+ libcap2 \
27
+ rsync \
28
+ unzip \
29
+ wget \
30
+ zip --no-install-recommends
31
+
32
+ case $(uname -m) in
33
+ x86_64)
34
+ # We only need to worry about i386 if we are on x86_64.
35
+ apt-get install -y lib32gcc1 libc6-i386
36
+ ;;
37
+ esac
local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/base-images/base-runner/install_go.sh ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash -eux
2
+ # Copyright 2022 Google LLC
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ ################################################################################
17
+
18
+ # Install go on x86_64, don't do anything on ARM.
19
+
20
+ case $(uname -m) in
21
+ x86_64)
22
+ # Download and install Go 1.19.
23
+ wget -q https://storage.googleapis.com/golang/getgo/installer_linux -O $SRC/installer_linux
24
+ chmod +x $SRC/installer_linux
25
+ SHELL="bash" $SRC/installer_linux -version 1.19
26
+ rm $SRC/installer_linux
27
+ # Set up Golang coverage modules.
28
+ printf $(find . -name gocoverage)
29
+ cd $GOPATH/gocoverage && /root/.go/bin/go install ./...
30
+ cd convertcorpus && /root/.go/bin/go install .
31
+ cd /root/.go/src/cmd/cover && /root/.go/bin/go build && mv cover $GOPATH/bin/gotoolcover
32
+ ;;
33
+ aarch64)
34
+ # Don't install go because installer is not provided.
35
+ echo "Not installing go: aarch64."
36
+ ;;
37
+ *)
38
+ echo "Error: unsupported architecture: $(uname -m)"
39
+ exit 1
40
+ ;;
41
+ esac
local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/base-images/base-runner/install_javascript.sh ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash -eux
2
+ # Copyright 2023 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
+ # see installation instructions: https://github.com/nodesource/distributions#available-architectures
18
+ apt-get update
19
+ apt-get install -y ca-certificates curl gnupg
20
+ mkdir -p /etc/apt/keyrings
21
+ curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
22
+
23
+ NODE_MAJOR=20
24
+ echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list
25
+
26
+ apt-get update
27
+ apt-get install nodejs -y
28
+
29
+ # Install latest versions of nyc for source-based coverage reporting
30
+ npm install --global nyc
local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/base-images/base-runner/jacoco_report_converter.py ADDED
@@ -0,0 +1,174 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
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
+ #
16
+ ################################################################################
17
+ """Helper script for creating an llvm-cov style JSON summary from a JaCoCo XML
18
+ report."""
19
+ import json
20
+ import os
21
+ import sys
22
+ import xml.etree.ElementTree as ET
23
+
24
+
25
+ def convert(xml):
26
+ """Turns a JaCoCo XML report into an llvm-cov JSON summary."""
27
+ summary = {
28
+ 'type': 'oss-fuzz.java.coverage.json.export',
29
+ 'version': '1.0.0',
30
+ 'data': [{
31
+ 'totals': {},
32
+ 'files': [],
33
+ }],
34
+ }
35
+
36
+ report = ET.fromstring(xml)
37
+ totals = make_element_summary(report)
38
+ summary['data'][0]['totals'] = totals
39
+
40
+ # Since Java compilation does not track source file location, we match
41
+ # coverage info to source files via the full class name, e.g. we search for
42
+ # a path in /out/src ending in foo/bar/Baz.java for the class foo.bar.Baz.
43
+ # Under the assumptions that a given project only ever contains a single
44
+ # version of a class and that no class name appears as a suffix of another
45
+ # class name, we can assign coverage info to every source file matched in that
46
+ # way.
47
+ src_files = list_src_files()
48
+
49
+ for class_element in report.findall('./package/class'):
50
+ # Skip fuzzer classes
51
+ if is_fuzzer_class(class_element):
52
+ continue
53
+
54
+ # Skip non class elements
55
+ if 'sourcefilename' not in class_element.attrib:
56
+ continue
57
+
58
+ class_name = class_element.attrib['name']
59
+ package_name = os.path.dirname(class_name)
60
+ basename = class_element.attrib['sourcefilename']
61
+ # This path is 'foo/Bar.java' for the class element
62
+ # <class name="foo/Bar" sourcefilename="Bar.java">.
63
+ canonical_path = os.path.join(package_name, basename)
64
+
65
+ class_summary = make_element_summary(class_element)
66
+ for src_file in relative_to_src_path(src_files, canonical_path):
67
+ summary['data'][0]['files'].append({
68
+ 'filename': src_file,
69
+ 'summary': class_summary,
70
+ })
71
+
72
+ return json.dumps(summary)
73
+
74
+
75
+ def list_src_files():
76
+ """Returns a map from basename to full path for all files in $OUT/$SRC."""
77
+ filename_to_paths = {}
78
+ out_path = os.environ['OUT'] + '/'
79
+ src_path = os.environ['SRC']
80
+ src_in_out = out_path + src_path
81
+ for dirpath, _, filenames in os.walk(src_in_out):
82
+ for filename in filenames:
83
+ full_path = dirpath + '/' + filename
84
+ # Map /out//src/... to /src/...
85
+ file_path = full_path[len(out_path):]
86
+ filename_to_paths.setdefault(filename, []).append(file_path)
87
+ return filename_to_paths
88
+
89
+
90
+ def is_fuzzer_class(class_element):
91
+ """Check if the class is fuzzer class."""
92
+ method_elements = class_element.find('./method[@name=\"fuzzerTestOneInput\"]')
93
+ if method_elements:
94
+ return True
95
+
96
+ return False
97
+
98
+
99
+ def relative_to_src_path(src_files, canonical_path):
100
+ """Returns all paths in src_files ending in canonical_path."""
101
+ basename = os.path.basename(canonical_path)
102
+ if basename not in src_files:
103
+ return []
104
+ candidate_paths = src_files[basename]
105
+ return [
106
+ path for path in candidate_paths if path.endswith("/" + canonical_path)
107
+ ]
108
+
109
+
110
+ def make_element_summary(element):
111
+ """Returns a coverage summary for an element in the XML report."""
112
+ summary = {}
113
+
114
+ function_counter = element.find('./counter[@type=\'METHOD\']')
115
+ summary['functions'] = make_counter_summary(function_counter)
116
+
117
+ line_counter = element.find('./counter[@type=\'LINE\']')
118
+ summary['lines'] = make_counter_summary(line_counter)
119
+
120
+ # JaCoCo tracks branch coverage, which counts the covered control-flow edges
121
+ # between llvm-cov's regions instead of the covered regions themselves. For
122
+ # non-trivial code parts, the difference is usually negligible. However, if
123
+ # all methods of a class consist of a single region only (no branches),
124
+ # JaCoCo does not report any branch coverage even if there is instruction
125
+ # coverage. Since this would give incorrect results for CI Fuzz purposes, we
126
+ # increase the regions counter by 1 if there is any amount of instruction
127
+ # coverage.
128
+ instruction_counter = element.find('./counter[@type=\'INSTRUCTION\']')
129
+ has_some_coverage = instruction_counter is not None and int(
130
+ instruction_counter.attrib["covered"]) > 0
131
+ branch_covered_adjustment = 1 if has_some_coverage else 0
132
+ region_counter = element.find('./counter[@type=\'BRANCH\']')
133
+ summary['regions'] = make_counter_summary(
134
+ region_counter, covered_adjustment=branch_covered_adjustment)
135
+
136
+ return summary
137
+
138
+
139
+ def make_counter_summary(counter_element, covered_adjustment=0):
140
+ """Turns a JaCoCo <counter> element into an llvm-cov totals entry."""
141
+ summary = {}
142
+ covered = covered_adjustment
143
+ missed = 0
144
+ if counter_element is not None:
145
+ covered += int(counter_element.attrib['covered'])
146
+ missed += int(counter_element.attrib['missed'])
147
+ summary['covered'] = covered
148
+ summary['notcovered'] = missed
149
+ summary['count'] = summary['covered'] + summary['notcovered']
150
+ if summary['count'] != 0:
151
+ summary['percent'] = (100.0 * summary['covered']) / summary['count']
152
+ else:
153
+ summary['percent'] = 0
154
+ return summary
155
+
156
+
157
+ def main():
158
+ """Produces an llvm-cov style JSON summary from a JaCoCo XML report."""
159
+ if len(sys.argv) != 3:
160
+ sys.stderr.write('Usage: %s <path_to_jacoco_xml> <out_path_json>\n' %
161
+ sys.argv[0])
162
+ return 1
163
+
164
+ with open(sys.argv[1], 'r') as xml_file:
165
+ xml_report = xml_file.read()
166
+ json_summary = convert(xml_report)
167
+ with open(sys.argv[2], 'w') as json_file:
168
+ json_file.write(json_summary)
169
+
170
+ return 0
171
+
172
+
173
+ if __name__ == '__main__':
174
+ sys.exit(main())
local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/base-images/base-runner/nyc_report_converter.py ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ # Copyright 2023 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
+ """Helper script for creating a llvm-cov style JSON summary from a nyc
18
+ JSON summary."""
19
+ import json
20
+ import sys
21
+
22
+
23
+ def convert(nyc_json_summary):
24
+ """Turns a nyc JSON report into a llvm-cov JSON summary."""
25
+ summary = {
26
+ 'type':
27
+ 'oss-fuzz.javascript.coverage.json.export',
28
+ 'version':
29
+ '1.0.0',
30
+ 'data': [{
31
+ 'totals':
32
+ file_summary(nyc_json_summary['total']),
33
+ 'files': [{
34
+ 'filename': src_file,
35
+ 'summary': file_summary(nyc_json_summary[src_file])
36
+ } for src_file in nyc_json_summary if src_file != 'total'],
37
+ }],
38
+ }
39
+
40
+ return json.dumps(summary)
41
+
42
+
43
+ def file_summary(nyc_file_summary):
44
+ """Returns a summary for a given file in the nyc JSON summary report."""
45
+ return {
46
+ 'functions': element_summary(nyc_file_summary['functions']),
47
+ 'lines': element_summary(nyc_file_summary['lines']),
48
+ 'regions': element_summary(nyc_file_summary['branches'])
49
+ }
50
+
51
+
52
+ def element_summary(element):
53
+ """Returns a summary of a coverage element in the nyc JSON summary
54
+ of the file"""
55
+ return {
56
+ 'count': element['total'],
57
+ 'covered': element['covered'],
58
+ 'notcovered': element['total'] - element['covered'] - element['skipped'],
59
+ 'percent': element['pct'] if element['pct'] != 'Unknown' else 0
60
+ }
61
+
62
+
63
+ def main():
64
+ """Produces a llvm-cov style JSON summary from a nyc JSON summary."""
65
+ if len(sys.argv) != 3:
66
+ sys.stderr.write('Usage: %s <path_to_nyc_json_summary> <out_path_json>\n' %
67
+ sys.argv[0])
68
+ return 1
69
+
70
+ with open(sys.argv[1], 'r') as nyc_json_summary_file:
71
+ nyc_json_summary = json.load(nyc_json_summary_file)
72
+ json_summary = convert(nyc_json_summary)
73
+ with open(sys.argv[2], 'w') as json_output_file:
74
+ json_output_file.write(json_summary)
75
+
76
+ return 0
77
+
78
+
79
+ if __name__ == '__main__':
80
+ sys.exit(main())
local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/base-images/base-runner/profraw_update.py ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
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
+ #
16
+ ################################################################################
17
+ """Helper script for upgrading a profraw file to latest version."""
18
+
19
+ from collections import namedtuple
20
+ import struct
21
+ import subprocess
22
+ import sys
23
+
24
+ HeaderGeneric = namedtuple('HeaderGeneric', 'magic version')
25
+ HeaderVersion9 = namedtuple(
26
+ 'HeaderVersion9',
27
+ 'BinaryIdsSize DataSize PaddingBytesBeforeCounters CountersSize \
28
+ PaddingBytesAfterCounters NumBitmapBytes PaddingBytesAfterBitmapBytes NamesSize CountersDelta BitmapDelta NamesDelta ValueKindLast'
29
+ )
30
+
31
+ PROFRAW_MAGIC = 0xff6c70726f667281
32
+
33
+
34
+ def relativize_address(data, offset, databegin, sect_prf_cnts, sect_prf_data):
35
+ """Turns an absolute offset into a relative one."""
36
+ value = struct.unpack('Q', data[offset:offset + 8])[0]
37
+ if sect_prf_cnts <= value < sect_prf_data:
38
+ # If the value is an address in the right section, make it relative.
39
+ value = (value - databegin) & 0xffffffffffffffff
40
+ value = struct.pack('Q', value)
41
+ for i in range(8):
42
+ data[offset + i] = value[i]
43
+ # address was made relative
44
+ return True
45
+ # no changes done
46
+ return False
47
+
48
+
49
+ def upgrade(data, sect_prf_cnts, sect_prf_data):
50
+ """Upgrades profraw data, knowing the sections addresses."""
51
+ generic_header = HeaderGeneric._make(struct.unpack('QQ', data[:16]))
52
+ if generic_header.magic != PROFRAW_MAGIC:
53
+ raise Exception('Bad magic.')
54
+ base_version = generic_header.version
55
+
56
+ if base_version >= 9:
57
+ # Nothing to do.
58
+ return data
59
+ if base_version < 5 or base_version == 6:
60
+ raise Exception('Unhandled version.')
61
+
62
+ if generic_header.version == 5:
63
+ generic_header = generic_header._replace(version=7)
64
+ # Upgrade from version 5 to 7 by adding binaryids field.
65
+ data = data[:8] + struct.pack('Q', generic_header.version) + struct.pack(
66
+ 'Q', 0) + data[16:]
67
+ if generic_header.version == 7:
68
+ # cf https://reviews.llvm.org/D111123
69
+ generic_header = generic_header._replace(version=8)
70
+ data = data[:8] + struct.pack('Q', generic_header.version) + data[16:]
71
+ if generic_header.version == 8:
72
+ # see https://reviews.llvm.org/D138846
73
+ generic_header = generic_header._replace(version=9)
74
+ # Upgrade from version 8 to 9 by adding NumBitmapBytes, PaddingBytesAfterBitmapBytes and BitmapDelta fields.
75
+ data = data[:8] + struct.pack(
76
+ 'Q', generic_header.version) + data[16:56] + struct.pack(
77
+ 'QQ', 0, 0) + data[56:72] + struct.pack('Q', 0) + data[72:]
78
+
79
+ v9_header = HeaderVersion9._make(struct.unpack('QQQQQQQQQQQQ', data[16:112]))
80
+
81
+ if base_version <= 8 and v9_header.BinaryIdsSize % 8 != 0:
82
+ # Adds padding for binary ids.
83
+ # cf commit b9f547e8e51182d32f1912f97a3e53f4899ea6be
84
+ # cf https://reviews.llvm.org/D110365
85
+ padlen = 8 - (v9_header.BinaryIdsSize % 8)
86
+ v7_header = v9_header._replace(BinaryIdsSize=v9_header.BinaryIdsSize +
87
+ padlen)
88
+ data = data[:16] + struct.pack('Q', v9_header.BinaryIdsSize) + data[24:]
89
+ data = data[:112 + v9_header.BinaryIdsSize] + bytes(
90
+ padlen) + data[112 + v9_header.BinaryIdsSize:]
91
+
92
+ if base_version <= 8:
93
+ offset = 112 + v9_header.BinaryIdsSize
94
+ for d in range(v9_header.DataSize):
95
+ # Add BitmapPtr and aligned u32(NumBitmapBytes)
96
+ data = data[:offset + 3 * 8] + struct.pack(
97
+ 'Q', 0) + data[offset + 3 * 8:offset + 6 * 8] + struct.pack(
98
+ 'Q', 0) + data[offset + 6 * 8:]
99
+ value = struct.unpack('Q',
100
+ data[offset + 2 * 8:offset + 3 * 8])[0] - 16 * d
101
+ data = data[:offset + 2 * 8] + struct.pack('Q',
102
+ value) + data[offset + 3 * 8:]
103
+ offset += 8 * 8
104
+
105
+ if base_version >= 8:
106
+ # Nothing more to do.
107
+ return data
108
+
109
+ # Last changes are relaed to bump from 7 to version 8 making CountersPtr relative.
110
+ dataref = sect_prf_data
111
+ # 80 is offset of CountersDelta.
112
+ if not relativize_address(data, 80, dataref, sect_prf_cnts, sect_prf_data):
113
+ return data
114
+
115
+ offset = 112 + v9_header.BinaryIdsSize
116
+ # This also works for C+Rust binaries compiled with
117
+ # clang-14/rust-nightly-clang-13.
118
+ for _ in range(v9_header.DataSize):
119
+ # 16 is the offset of CounterPtr in ProfrawData structure.
120
+ relativize_address(data, offset + 16, dataref, sect_prf_cnts, sect_prf_data)
121
+ # We need this because of CountersDelta -= sizeof(*SrcData);
122
+ # seen in __llvm_profile_merge_from_buffer.
123
+ dataref += 44 + 2 * (v9_header.ValueKindLast + 1)
124
+ if was8:
125
+ #profraw9 added RelativeBitmapPtr and NumBitmapBytes (8+4 rounded up to 16)
126
+ dataref -= 16
127
+ # This is the size of one ProfrawData structure.
128
+ offset += 44 + 2 * (v9_header.ValueKindLast + 1)
129
+
130
+ return data
131
+
132
+
133
+ def main():
134
+ """Helper script for upgrading a profraw file to latest version."""
135
+ if len(sys.argv) < 3:
136
+ sys.stderr.write('Usage: %s <binary> options? <profraw>...\n' % sys.argv[0])
137
+ return 1
138
+
139
+ # First find llvm profile sections addresses in the elf, quick and dirty.
140
+ process = subprocess.Popen(['readelf', '-S', sys.argv[1]],
141
+ stdout=subprocess.PIPE)
142
+ output, err = process.communicate()
143
+ if err:
144
+ print('readelf failed')
145
+ return 2
146
+ for line in iter(output.split(b'\n')):
147
+ if b'__llvm_prf_cnts' in line:
148
+ sect_prf_cnts = int(line.split()[3], 16)
149
+ elif b'__llvm_prf_data' in line:
150
+ sect_prf_data = int(line.split()[3], 16)
151
+
152
+ out_name = "default.profup"
153
+ in_place = False
154
+ start = 2
155
+ if sys.argv[2] == "-i":
156
+ in_place = True
157
+ start = start + 1
158
+ elif sys.argv[2] == "-o":
159
+ out_name = sys.argv[3]
160
+ start = 4
161
+
162
+ if len(sys.argv) < start:
163
+ sys.stderr.write('Usage: %s <binary> options <profraw>...\n' % sys.argv[0])
164
+ return 1
165
+
166
+ for i in range(start, len(sys.argv)):
167
+ # Then open and read the input profraw file.
168
+ with open(sys.argv[i], 'rb') as input_file:
169
+ profraw_base = bytearray(input_file.read())
170
+ # Do the upgrade, returning a bytes object.
171
+ profraw_latest = upgrade(profraw_base, sect_prf_cnts, sect_prf_data)
172
+ # Write the output to the file given to the command line.
173
+ if in_place:
174
+ out_name = sys.argv[i]
175
+ with open(out_name, 'wb') as output_file:
176
+ output_file.write(profraw_latest)
177
+
178
+ return 0
179
+
180
+
181
+ if __name__ == '__main__':
182
+ sys.exit(main())
local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/base-images/base-runner/python_coverage_runner_help.py ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ Helper to manage coverage.py related operations. Does two main
16
+ things: (1) pass commands into the coverage.py library and (2)
17
+ translate .coverage created from a pyinstaller executable into
18
+ paths that match local files. This is needed for html report creation.
19
+ """
20
+ import os
21
+ import re
22
+ import json
23
+ import sys
24
+ from coverage.cmdline import main as coverage_main
25
+ from coverage.data import CoverageData
26
+
27
+
28
+ def should_exclude_file(filepath):
29
+ """Returns whether the path should be excluded from the coverage report."""
30
+ # Skip all atheris code
31
+ if "atheris" in filepath:
32
+ return True
33
+
34
+ # Filter out all standard python libraries
35
+ if ('/usr/local/lib/python' in filepath and
36
+ 'site-packages' not in filepath and 'dist-packages' not in filepath):
37
+ return True
38
+
39
+ # Avoid all PyInstaller modules.
40
+ if 'PyInstaller' in filepath:
41
+ return True
42
+
43
+ return False
44
+
45
+
46
+ def translate_lines(cov_data, new_cov_data, all_file_paths):
47
+ """
48
+ Translate lines in a .coverage file created by coverage.py such that
49
+ the file paths points to local files instead. This is needed when collecting
50
+ coverage from executables created by pyinstaller.
51
+ """
52
+ for pyinstaller_file_path in cov_data.measured_files():
53
+ stripped_py_file_path = pyinstaller_file_path
54
+ if stripped_py_file_path.startswith('/tmp/_MEI'):
55
+ stripped_py_file_path = '/'.join(stripped_py_file_path.split('/')[3:])
56
+ if stripped_py_file_path.startswith('/out/'):
57
+ stripped_py_file_path = stripped_py_file_path.replace('/out/', '')
58
+
59
+ # Check if this file exists in our file paths:
60
+ for local_file_path in all_file_paths:
61
+ if should_exclude_file(local_file_path):
62
+ continue
63
+ if local_file_path.endswith(stripped_py_file_path):
64
+ print('Found matching: %s' % (local_file_path))
65
+ new_cov_data.add_lines(
66
+ {local_file_path: cov_data.lines(pyinstaller_file_path)})
67
+
68
+
69
+ def translate_coverage(all_file_paths):
70
+ """
71
+ Translate pyinstaller-generated file paths in .coverage (produced by
72
+ coverage.py) into local file paths. Place result in .new_coverage.
73
+ """
74
+ covdata_pre_translation = CoverageData('.coverage')
75
+ covdata_post_translation = CoverageData('.new_coverage')
76
+
77
+ covdata_pre_translation.read()
78
+ translate_lines(covdata_pre_translation, covdata_post_translation,
79
+ all_file_paths)
80
+ covdata_post_translation.write()
81
+
82
+
83
+ def convert_coveragepy_cov_to_summary_json(src, dst):
84
+ """
85
+ Converts a json file produced by coveragepy into a summary.json file
86
+ similary to llvm-cov output. `src` is the source coveragepy json file,
87
+ `dst` is the destination json file, which will be overwritten.
88
+ """
89
+ dst_dict = {'data': [{'files': {}}]}
90
+ lines_covered = 0
91
+ lines_count = 0
92
+ with open(src, "r") as src_f:
93
+ src_json = json.loads(src_f.read())
94
+ if 'files' in src_json:
95
+ for elem in src_json.get('files'):
96
+ if 'summary' not in src_json['files'][elem]:
97
+ continue
98
+ src_dict = src_json['files'][elem]['summary']
99
+ count = src_dict['covered_lines'] + src_dict['missing_lines']
100
+ covered = src_dict['covered_lines']
101
+ notcovered = src_dict['missing_lines']
102
+ percent = src_dict['percent_covered']
103
+
104
+ # Accumulate line coverage
105
+ lines_covered += covered
106
+ lines_count += count
107
+
108
+ dst_dict['data'][0]['files'][elem] = {
109
+ 'summary': {
110
+ 'lines': {
111
+ 'count': count,
112
+ 'covered': covered,
113
+ 'notcovered': notcovered,
114
+ 'percent': percent
115
+ }
116
+ }
117
+ }
118
+ if lines_count > 0:
119
+ lines_covered_percent = lines_covered / lines_count
120
+ else:
121
+ lines_covered_percent = 0.0
122
+ dst_dict['data'][0]['totals'] = {
123
+ 'branches': {
124
+ 'count': 0,
125
+ 'covered': 0,
126
+ 'notcovered': 0,
127
+ 'percent': 0.0
128
+ },
129
+ 'functions': {
130
+ 'count': 0,
131
+ 'covered': 0,
132
+ 'percent': 0.0
133
+ },
134
+ 'instantiations': {
135
+ 'count': 0,
136
+ 'covered': 0,
137
+ 'percent': 0.0
138
+ },
139
+ 'lines': {
140
+ 'count': lines_count,
141
+ 'covered': lines_covered,
142
+ 'percent': lines_covered_percent
143
+ },
144
+ 'regions': {
145
+ 'count': 0,
146
+ 'covered': 0,
147
+ 'notcovered': 0,
148
+ 'percent': 0.0
149
+ }
150
+ }
151
+
152
+ with open(dst, 'w') as dst_f:
153
+ dst_f.write(json.dumps(dst_dict))
154
+
155
+
156
+ def main():
157
+ """
158
+ Main handler.
159
+ """
160
+ if sys.argv[1] == 'translate':
161
+ print('Translating the coverage')
162
+ files_path = sys.argv[2]
163
+ all_file_paths = list()
164
+ for root, _, files in os.walk(files_path):
165
+ for relative_file_path in files:
166
+ abs_file_path = os.path.abspath(os.path.join(root, relative_file_path))
167
+ all_file_paths.append(abs_file_path)
168
+ print('Done with path walk')
169
+ translate_coverage(all_file_paths)
170
+ elif sys.argv[1] == 'convert-to-summary-json':
171
+ src = sys.argv[2]
172
+ dst = sys.argv[3]
173
+ convert_coveragepy_cov_to_summary_json(src, dst)
174
+ else:
175
+ # Pass commands into coverage package
176
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
177
+ sys.exit(coverage_main())
178
+
179
+
180
+ if __name__ == '__main__':
181
+ main()
local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/base-images/base-runner/rcfilt ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash -u
2
+ # Copyright 2020 Google Inc.
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
+ # Symbol demangling for both C++ and Rust
17
+ #
18
+ ################################################################################
19
+
20
+ # simply pipe
21
+ rustfilt | c++filt -n
local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/base-images/base-runner/reproduce ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash -eux
2
+ # Copyright 2016 Google Inc.
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
+ FUZZER=$1
19
+ shift
20
+
21
+ if [ ! -v TESTCASE ]; then
22
+ TESTCASE="/testcase"
23
+ fi
24
+
25
+ if [ ! -f $TESTCASE ]; then
26
+ echo "Error: $TESTCASE not found, use: docker run -v <path>:$TESTCASE ..."
27
+ exit 1
28
+ fi
29
+
30
+ export RUN_FUZZER_MODE="interactive"
31
+ export FUZZING_ENGINE="libfuzzer"
32
+ export SKIP_SEED_CORPUS="1"
33
+
34
+ run_fuzzer $FUZZER $@ $TESTCASE
local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/base-images/base-runner/run_fuzzer ADDED
@@ -0,0 +1,228 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ # Fuzzer runner. Appends .options arguments and seed corpus to users args.
19
+ # Usage: $0 <fuzzer_name> <fuzzer_args>
20
+
21
+ sysctl -w vm.mmap_rnd_bits=28
22
+
23
+ export PATH=$OUT:$PATH
24
+ cd $OUT
25
+
26
+ DEBUGGER=${DEBUGGER:-}
27
+
28
+ FUZZER=$1
29
+ shift
30
+
31
+ # This env var is set by CIFuzz. CIFuzz fills this directory with the corpus
32
+ # from ClusterFuzz.
33
+ CORPUS_DIR=${CORPUS_DIR:-}
34
+ if [ -z "$CORPUS_DIR" ]
35
+ then
36
+ CORPUS_DIR="/tmp/${FUZZER}_corpus"
37
+ rm -rf $CORPUS_DIR && mkdir -p $CORPUS_DIR
38
+ fi
39
+
40
+ SANITIZER=${SANITIZER:-}
41
+ if [ -z $SANITIZER ]; then
42
+ # If $SANITIZER is not specified (e.g. calling from `reproduce` command), it
43
+ # is not important and can be set to any value.
44
+ SANITIZER="default"
45
+ fi
46
+
47
+ if [[ "$RUN_FUZZER_MODE" = interactive ]]; then
48
+ FUZZER_OUT="$OUT/${FUZZER}_${FUZZING_ENGINE}_${SANITIZER}_out"
49
+ else
50
+ FUZZER_OUT="/tmp/${FUZZER}_${FUZZING_ENGINE}_${SANITIZER}_out"
51
+ fi
52
+
53
+ function get_dictionary() {
54
+ local options_file="$FUZZER.options"
55
+ local dict_file="$FUZZER.dict"
56
+ local dict=""
57
+ if [[ -f "$options_file" ]]; then
58
+ dict=$(sed -n 's/^\s*dict\s*=\s*\(.*\)/\1/p' "$options_file" | tail -1)
59
+ fi
60
+ if [[ -z "$dict" && -f "$dict_file" ]]; then
61
+ dict="$dict_file"
62
+ fi
63
+ [[ -z "$dict" ]] && return
64
+ if [[ "$FUZZING_ENGINE" = "libfuzzer" ]]; then
65
+ printf -- "-dict=%s" "$dict"
66
+ elif [[ "$FUZZING_ENGINE" = "afl" ]]; then
67
+ printf -- "-x %s" "$dict"
68
+ elif [[ "$FUZZING_ENGINE" = "honggfuzz" ]]; then
69
+ printf -- "--dict %s" "$dict"
70
+ elif [[ "$FUZZING_ENGINE" = "centipede" ]]; then
71
+ printf -- "--dictionary %s" "$dict"
72
+ else
73
+ printf "Unexpected FUZZING_ENGINE: $FUZZING_ENGINE, ignoring\n" >&2
74
+ fi
75
+ }
76
+
77
+ function get_extra_binaries() {
78
+ [[ "$FUZZING_ENGINE" != "centipede" ]] && return
79
+
80
+ extra_binaries="$OUT/__centipede_${SANITIZER}/${FUZZER}"
81
+ if compgen -G "$extra_binaries" >> /dev/null; then
82
+ printf -- "--extra_binaries %s" \""$extra_binaries\""
83
+ fi
84
+
85
+ }
86
+
87
+ rm -rf $FUZZER_OUT && mkdir -p $FUZZER_OUT
88
+
89
+ SEED_CORPUS="${FUZZER}_seed_corpus.zip"
90
+
91
+ # TODO: Investigate why this code block is skipped
92
+ # by all default fuzzers in bad_build_check.
93
+ # They all set SKIP_SEED_CORPUS=1.
94
+ if [ -f $SEED_CORPUS ] && [ -z ${SKIP_SEED_CORPUS:-} ]; then
95
+ echo "Using seed corpus: $SEED_CORPUS"
96
+ unzip -o -d ${CORPUS_DIR}/ $SEED_CORPUS > /dev/null
97
+ fi
98
+
99
+ OPTIONS_FILE="${FUZZER}.options"
100
+ CUSTOM_LIBFUZZER_OPTIONS=""
101
+
102
+ if [ -f $OPTIONS_FILE ]; then
103
+ custom_asan_options=$(parse_options.py $OPTIONS_FILE asan)
104
+ if [ ! -z $custom_asan_options ]; then
105
+ export ASAN_OPTIONS="$ASAN_OPTIONS:$custom_asan_options"
106
+ fi
107
+
108
+ custom_msan_options=$(parse_options.py $OPTIONS_FILE msan)
109
+ if [ ! -z $custom_msan_options ]; then
110
+ export MSAN_OPTIONS="$MSAN_OPTIONS:$custom_msan_options"
111
+ fi
112
+
113
+ custom_ubsan_options=$(parse_options.py $OPTIONS_FILE ubsan)
114
+ if [ ! -z $custom_ubsan_options ]; then
115
+ export UBSAN_OPTIONS="$UBSAN_OPTIONS:$custom_ubsan_options"
116
+ fi
117
+
118
+ CUSTOM_LIBFUZZER_OPTIONS=$(parse_options.py $OPTIONS_FILE libfuzzer)
119
+ fi
120
+
121
+ if [[ "$FUZZING_ENGINE" = afl ]]; then
122
+
123
+ # Set afl++ environment options.
124
+ export ASAN_OPTIONS="$ASAN_OPTIONS:abort_on_error=1:symbolize=0:detect_odr_violation=0:"
125
+ export MSAN_OPTIONS="$MSAN_OPTIONS:exit_code=86:symbolize=0"
126
+ export UBSAN_OPTIONS="$UBSAN_OPTIONS:symbolize=0"
127
+ export AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES=1
128
+ export AFL_SKIP_CPUFREQ=1
129
+ export AFL_TRY_AFFINITY=1
130
+ export AFL_FAST_CAL=1
131
+ export AFL_CMPLOG_ONLY_NEW=1
132
+ export AFL_FORKSRV_INIT_TMOUT=30000
133
+ export AFL_IGNORE_PROBLEMS=1
134
+ export AFL_IGNORE_UNKNOWN_ENVS=1
135
+
136
+ # If $OUT/afl_cmplog.txt is present this means the target was compiled for
137
+ # CMPLOG. So we have to add the proper parameters to afl-fuzz.
138
+ test -e "$OUT/afl_cmplog.txt" && AFL_FUZZER_ARGS="$AFL_FUZZER_ARGS -c $OUT/$FUZZER"
139
+
140
+ # If $OUT/afl++.dict we load it as a dictionary for afl-fuzz.
141
+ test -e "$OUT/afl++.dict" && AFL_FUZZER_ARGS="$AFL_FUZZER_ARGS -x $OUT/afl++.dict"
142
+
143
+ # Ensure timeout is a bit larger than 1sec as some of the OSS-Fuzz fuzzers
144
+ # are slower than this.
145
+ AFL_FUZZER_ARGS="$AFL_FUZZER_ARGS -t 5000+"
146
+
147
+ # AFL expects at least 1 file in the input dir.
148
+ echo input > ${CORPUS_DIR}/input
149
+
150
+ CMD_LINE="$OUT/afl-fuzz $AFL_FUZZER_ARGS -i $CORPUS_DIR -o $FUZZER_OUT $(get_dictionary) $* -- $OUT/$FUZZER"
151
+
152
+ echo afl++ setup:
153
+ env|grep AFL_
154
+ cat "$OUT/afl_options.txt"
155
+
156
+ elif [[ "$FUZZING_ENGINE" = honggfuzz ]]; then
157
+
158
+ # Honggfuzz expects at least 1 file in the input dir.
159
+ echo input > $CORPUS_DIR/input
160
+ # --exit_upon_crash: exit whith a first crash seen
161
+ # -V: verify crashes
162
+ # -R (report): save report file to this location
163
+ # -W (working dir): where the crashes go
164
+ # -v (verbose): don't use VTE UI, just stderr
165
+ # -z: use software-instrumentation of clang (trace-pc-guard....)
166
+ # -P: use persistent mode of fuzzing (i.e. LLVMFuzzerTestOneInput)
167
+ # -f: location of the initial (and destination) file corpus
168
+ # -n: number of fuzzing threads (and processes)
169
+ CMD_LINE="$OUT/honggfuzz -n 1 --exit_upon_crash -V -R /tmp/${FUZZER}_honggfuzz.report -W $FUZZER_OUT -v -z -P -f \"$CORPUS_DIR\" $(get_dictionary) $* -- \"$OUT/$FUZZER\""
170
+
171
+ if [[ $(LC_ALL=C grep -P "\x01_LIBHFUZZ_NETDRIVER_BINARY_SIGNATURE_\x02\xFF" "$FUZZER" ) ]]; then
172
+ # Honggfuzz Netdriver port. This must match the port in Clusterfuzz.
173
+ export HFND_TCP_PORT=8666
174
+ fi
175
+ elif [[ "$FUZZING_ENGINE" = centipede ]]; then
176
+
177
+ # Create the work and corpus directory for Centipede.
178
+ CENTIPEDE_WORKDIR="${CENTIPEDE_WORKDIR:-$OUT}"
179
+
180
+ # Centipede only saves crashes to crashes/ in workdir.
181
+ rm -rf $FUZZER_OUT
182
+
183
+ # --workdir: Dir that stores corpus&features in Centipede's own format.
184
+ # --corpus_dir: Location of the initial (and destination) file corpus.
185
+ # --fork_server: Execute the target(s) via the fork server.
186
+ # Run in fork mode to continue fuzzing indefinitely in case of
187
+ # OOMs, timeouts, and crashes.
188
+ # --exit_on_crash=0: Do not exit on crash.
189
+ # --timeout=1200: The process that executes target binary will abort
190
+ # if an input runs >= 1200s.
191
+ # --rss_limit_mb=0: Disable RSS limit.
192
+ # --address_space_limit_mb=0: No address space limit.
193
+ # --binary: The target binary under test without sanitizer.
194
+ # --extra_binary: The target binaries under test with sanitizers.
195
+ CMD_LINE="$OUT/centipede --workdir=$CENTIPEDE_WORKDIR --corpus_dir=\"$CORPUS_DIR\" --fork_server=1 --exit_on_crash=1 --timeout=1200 --rss_limit_mb=4096 --address_space_limit_mb=5120 $(get_dictionary) --binary=\"$OUT/${FUZZER}\" $(get_extra_binaries) $*"
196
+ else
197
+
198
+ CMD_LINE="$OUT/$FUZZER $FUZZER_ARGS $*"
199
+
200
+ if [ -z ${SKIP_SEED_CORPUS:-} ]; then
201
+ CMD_LINE="$CMD_LINE $CORPUS_DIR"
202
+ fi
203
+
204
+ if [[ ! -z ${CUSTOM_LIBFUZZER_OPTIONS} ]]; then
205
+ CMD_LINE="$CMD_LINE $CUSTOM_LIBFUZZER_OPTIONS"
206
+ fi
207
+
208
+ if [[ ! "$CMD_LINE" =~ "-dict=" ]]; then
209
+ if [ -f "$FUZZER.dict" ]; then
210
+ CMD_LINE="$CMD_LINE -dict=$FUZZER.dict"
211
+ fi
212
+ fi
213
+
214
+ CMD_LINE="$CMD_LINE < /dev/null"
215
+
216
+ fi
217
+
218
+ echo $CMD_LINE
219
+
220
+ # Unset OUT so the fuzz target can't rely on it.
221
+ unset OUT
222
+
223
+ if [ ! -z "$DEBUGGER" ]; then
224
+ CMD_LINE="$DEBUGGER $CMD_LINE"
225
+ fi
226
+
227
+ bash -c "$CMD_LINE"
228
+
local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/base-images/base-runner/ruzzy ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ # Copyright 2024 Google LLC
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ ################################################################################
17
+
18
+ ASAN_OPTIONS="allocator_may_return_null=1:detect_leaks=0:use_sigaltstack=0" LD_PRELOAD=$(ruby -e 'require "ruzzy"; print Ruzzy::ASAN_PATH') \
19
+ ruby $@
local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/base-images/base-runner/targets_list ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ for binary in $(find $OUT/ -executable -type f); do
4
+ [[ "$binary" != *.so ]] || continue
5
+ [[ $(basename "$binary") != jazzer_driver* ]] || continue
6
+ file "$binary" | grep -e ELF -e "shell script" > /dev/null 2>&1 || continue
7
+ grep "LLVMFuzzerTestOneInput" "$binary" > /dev/null 2>&1 || continue
8
+
9
+ basename "$binary"
10
+ done
local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/base-images/base-runner/test_all_test.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ """Tests test_all.py"""
17
+ import unittest
18
+ from unittest import mock
19
+
20
+ import test_all
21
+
22
+
23
+ class TestTestAll(unittest.TestCase):
24
+ """Tests for the test_all_function."""
25
+
26
+ @mock.patch('test_all.find_fuzz_targets', return_value=[])
27
+ @mock.patch('builtins.print')
28
+ def test_test_all_no_fuzz_targets(self, mock_print, _):
29
+ """Tests that test_all returns False when there are no fuzz targets."""
30
+ outdir = '/out'
31
+ allowed_broken_targets_percentage = 0
32
+ self.assertFalse(
33
+ test_all.test_all(outdir, allowed_broken_targets_percentage))
34
+ mock_print.assert_called_with('ERROR: No fuzz targets found.')
35
+
36
+
37
+ if __name__ == '__main__':
38
+ unittest.main()
local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/cifuzz/actions/run_fuzzers/action.yml ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # action.yml
2
+ name: 'run-fuzzers'
3
+ description: 'Runs fuzz target binaries for a specified length of time.'
4
+ inputs:
5
+ oss-fuzz-project-name:
6
+ description: 'The OSS-Fuzz project name.'
7
+ required: true
8
+ language:
9
+ description: 'Programming language project is written in.'
10
+ required: false
11
+ default: 'c++'
12
+ fuzz-seconds:
13
+ description: 'The total time allotted for fuzzing in seconds.'
14
+ required: true
15
+ default: 600
16
+ dry-run:
17
+ description: 'If set, run the action without actually reporting a failure.'
18
+ default: false
19
+ sanitizer:
20
+ description: 'The sanitizer to run the fuzzers with.'
21
+ default: 'address'
22
+ mode:
23
+ description: |
24
+ The mode to run the fuzzers with ("code-change", "batch", "coverage", or "prune").
25
+ "code-change" is for fuzzing a pull request or commit.
26
+ "batch" is for non-interactive fuzzing of an entire project.
27
+ "coverage" is for coverage generation.
28
+ "prune" is for corpus pruning.
29
+ required: false
30
+ default: 'code-change'
31
+ github-token:
32
+ description: |
33
+ Token for GitHub API. WARNING: THIS SHOULD NOT BE USED IN PRODUCTION YET
34
+ You should use "secrets.GITHUB_TOKEN" in your workflow file, do not
35
+ hardcode the token.
36
+ TODO(https://github.com/google/oss-fuzz/pull/5841#discussion_r639393361):
37
+ Document locking this down.
38
+ required: false
39
+ report-unreproducible-crashes:
40
+ description: 'If True, then unreproducible crashes will be reported.'
41
+ required: false
42
+ default: False
43
+ minimize-crashes:
44
+ description: 'If True, reportable crashes will be minimized.'
45
+ required: false
46
+ default: False
47
+ parallel-fuzzing:
48
+ description: "Whether to use all available cores for fuzzing."
49
+ required: false
50
+ default: false
51
+ output-sarif:
52
+ description: "Whether to output fuzzing results to SARIF."
53
+ required: false
54
+ default: false
55
+ report-timeouts:
56
+ description: "Whether to report fails due to timeout."
57
+ required: false
58
+ default: true
59
+ report-ooms:
60
+ description: "Whether to report fails due to OOM."
61
+ required: false
62
+ default: true
63
+ runs:
64
+ using: 'docker'
65
+ image: '../../../run_fuzzers.Dockerfile'
66
+ env:
67
+ OSS_FUZZ_PROJECT_NAME: ${{ inputs.oss-fuzz-project-name }}
68
+ LANGUAGE: ${{ inputs.language }}
69
+ FUZZ_SECONDS: ${{ inputs.fuzz-seconds }}
70
+ DRY_RUN: ${{ inputs.dry-run}}
71
+ SANITIZER: ${{ inputs.sanitizer }}
72
+ MODE: ${{ inputs.mode }}
73
+ GITHUB_TOKEN: ${{ inputs.github-token }}
74
+ LOW_DISK_SPACE: 'True'
75
+ REPORT_UNREPRODUCIBLE_CRASHES: ${{ inputs.report-unreproducible-crashes }}
76
+ MINIMIZE_CRASHES: ${{ inputs.minimize-crashes }}
77
+ CIFUZZ_DEBUG: 'True'
78
+ CFL_PLATFORM: 'github'
79
+ PARALLEL_FUZZING: ${{ inputs.parallel-fuzzing }}
80
+ OUTPUT_SARIF: ${{ inputs.output-sarif }}
81
+ REPORT_TIMEOUTS: ${{ inputs.report-timeouts }}
82
+ REPORT_OOMS: ${{ inputs.report-ooms}}
local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/cifuzz/external-actions/build_fuzzers/action.yml ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # action.yml
2
+ name: 'build-fuzzers'
3
+ description: "Builds an OSS-Fuzz project's fuzzers."
4
+ inputs:
5
+ language:
6
+ description: 'Programming language project is written in.'
7
+ required: false
8
+ default: 'c++'
9
+ dry-run:
10
+ description: 'If set, run the action without actually reporting a failure.'
11
+ default: false
12
+ allowed-broken-targets-percentage:
13
+ description: 'The percentage of broken targets allowed in bad_build_check.'
14
+ required: false
15
+ sanitizer:
16
+ description: 'The sanitizer to build the fuzzers with.'
17
+ default: 'address'
18
+ project-src-path:
19
+ description: "The path to the project's source code checkout."
20
+ required: false
21
+ bad-build-check:
22
+ description: "Whether or not OSS-Fuzz's check for bad builds should be done."
23
+ required: false
24
+ default: true
25
+ keep-unaffected-fuzz-targets:
26
+ description: "Whether to keep unaffected fuzzers or delete them."
27
+ required: false
28
+ default: false
29
+ storage-repo:
30
+ description: |
31
+ The git repo to use for storing certain artifacts from fuzzing.
32
+ required: false
33
+ storage-repo-branch:
34
+ description: |
35
+ The branch of the git repo to use for storing certain artifacts from
36
+ fuzzing.
37
+ required: false
38
+ storage-repo-branch-coverage:
39
+ description: |
40
+ The branch of the git repo to use for storing coverage reports.
41
+ required: false
42
+ upload-build:
43
+ description: |
44
+ If set, will upload the build.
45
+ default: false
46
+ github-token:
47
+ description: |
48
+ Token for GitHub API. WARNING: THIS SHOULD NOT BE USED IN PRODUCTION YET
49
+ You should use "secrets.GITHUB_TOKEN" in your workflow file, do not
50
+ hardcode the token.
51
+ TODO(https://github.com/google/oss-fuzz/pull/5841#discussion_r639393361):
52
+ Document locking this down.
53
+ required: false
54
+ output-sarif:
55
+ description: "Whether to output fuzzing results to SARIF."
56
+ required: false
57
+ default: false
58
+ runs:
59
+ using: 'docker'
60
+ image: '../../../build_fuzzers.Dockerfile'
61
+ env:
62
+ OSS_FUZZ_PROJECT_NAME: ${{ inputs.oss-fuzz-project-name }}
63
+ LANGUAGE: ${{ inputs.language }}
64
+ DRY_RUN: ${{ inputs.dry-run}}
65
+ ALLOWED_BROKEN_TARGETS_PERCENTAGE: ${{ inputs.allowed-broken-targets-percentage}}
66
+ SANITIZER: ${{ inputs.sanitizer }}
67
+ PROJECT_SRC_PATH: ${{ inputs.project-src-path }}
68
+ GITHUB_TOKEN: ${{ inputs.github-token }}
69
+ LOW_DISK_SPACE: 'True'
70
+ BAD_BUILD_CHECK: ${{ inputs.bad-build-check }}
71
+ UPLOAD_BUILD: ${{ inputs.upload-build }}
72
+ CIFUZZ_DEBUG: 'True'
73
+ CFL_PLATFORM: 'github'
74
+ KEEP_UNAFFECTED_FUZZ_TARGETS: ${{ inputs.keep-unaffected-fuzz-targets }}
75
+ OUTPUT_SARIF: ${{ inputs.output-sarif }}
local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/cifuzz/external-actions/run_fuzzers/action.yml ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # action.yml
2
+ name: 'run-fuzzers'
3
+ description: 'Runs fuzz target binaries for a specified length of time.'
4
+ inputs:
5
+ language:
6
+ description: 'Programming language project is written in.'
7
+ required: false
8
+ default: 'c++'
9
+ fuzz-seconds:
10
+ description: 'The total time allotted for fuzzing in seconds.'
11
+ required: true
12
+ default: 600
13
+ dry-run:
14
+ description: 'If set, run the action without actually reporting a failure.'
15
+ default: false
16
+ sanitizer:
17
+ description: 'The sanitizer to run the fuzzers with.'
18
+ default: 'address'
19
+ mode:
20
+ description: |
21
+ The mode to run the fuzzers with ("code-change", "batch", "coverage", or "prune").
22
+ "code-change" is for fuzzing a pull request or commit.
23
+ "batch" is for non-interactive fuzzing of an entire project.
24
+ "coverage" is for coverage generation.
25
+ "prune" is for corpus pruning.
26
+ required: false
27
+ default: 'code-change'
28
+ github-token:
29
+ description: |
30
+ Token for GitHub API. WARNING: THIS SHOULD NOT BE USED IN PRODUCTION YET
31
+ You should use "secrets.GITHUB_TOKEN" in your workflow file, do not
32
+ hardcode the token.
33
+ TODO(https://github.com/google/oss-fuzz/pull/5841#discussion_r639393361):
34
+ Document locking this down.
35
+ required: true
36
+ storage-repo:
37
+ description: |
38
+ The git repo to use for storing certain artifacts from fuzzing.
39
+ required: false
40
+ storage-repo-branch:
41
+ description: |
42
+ The branch of the git repo to use for storing certain artifacts from
43
+ fuzzing.
44
+ default: main
45
+ required: false
46
+ storage-repo-branch-coverage:
47
+ description: |
48
+ The branch of the git repo to use for storing coverage reports.
49
+ default: gh-pages
50
+ required: false
51
+ report-unreproducible-crashes:
52
+ description: 'If True, then unreproducible crashes will be reported.'
53
+ required: false
54
+ default: false
55
+ minimize-crashes:
56
+ description: 'If True, reportable crashes will be minimized.'
57
+ required: false
58
+ default: False
59
+ parallel-fuzzing:
60
+ description: "Whether to use all available cores for fuzzing."
61
+ required: false
62
+ default: false
63
+ output-sarif:
64
+ description: "Whether to output fuzzing results to SARIF."
65
+ required: false
66
+ default: false
67
+ report-timeouts:
68
+ description: "Whether to report fails due to timeout."
69
+ required: false
70
+ default: true
71
+ report-ooms:
72
+ description: "Whether to report fails due to OOM."
73
+ required: false
74
+ default: true
75
+ runs:
76
+ using: 'docker'
77
+ image: '../../../run_fuzzers.Dockerfile'
78
+ env:
79
+ OSS_FUZZ_PROJECT_NAME: ${{ inputs.oss-fuzz-project-name }}
80
+ LANGUAGE: ${{ inputs.language }}
81
+ FUZZ_SECONDS: ${{ inputs.fuzz-seconds }}
82
+ DRY_RUN: ${{ inputs.dry-run}}
83
+ SANITIZER: ${{ inputs.sanitizer }}
84
+ MODE: ${{ inputs.mode }}
85
+ GITHUB_TOKEN: ${{ inputs.github-token }}
86
+ LOW_DISK_SPACE: 'True'
87
+ GIT_STORE_REPO: ${{ inputs.storage-repo }}
88
+ GIT_STORE_BRANCH: ${{ inputs.storage-repo-branch }}
89
+ GIT_STORE_BRANCH_COVERAGE: ${{ inputs.storage-repo-branch-coverage }}
90
+ REPORT_UNREPRODUCIBLE_CRASHES: ${{ inputs.report-unreproducible-crashes }}
91
+ MINIMIZE_CRASHES: ${{ inputs.minimize-crashes }}
92
+ CIFUZZ_DEBUG: 'True'
93
+ CFL_PLATFORM: 'github'
94
+ PARALLEL_FUZZING: ${{ inputs.parallel-fuzzing }}
95
+ OUTPUT_SARIF: ${{ inputs.output-sarif }}
96
+ REPORT_TIMEOUTS: ${{ inputs.report-timeouts }}
97
+ REPORT_OOMS: ${{ inputs.report-ooms}}
local-test-commons-compress-full-01-vuln_1/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-commons-compress-full-01-vuln_1/fuzz-tooling/infra/cifuzz/filestore/git/__init__.py ADDED
@@ -0,0 +1,158 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 git based filestore."""
15
+
16
+ import logging
17
+ import os
18
+ import shutil
19
+ import subprocess
20
+ import sys
21
+ import tempfile
22
+
23
+ import filestore
24
+
25
+ # pylint: disable=wrong-import-position
26
+ INFRA_DIR = os.path.dirname(
27
+ os.path.dirname(os.path.dirname(os.path.dirname(
28
+ os.path.abspath(__file__)))))
29
+ sys.path.append(INFRA_DIR)
30
+
31
+ import retry
32
+
33
+ _PUSH_RETRIES = 3
34
+ _PUSH_BACKOFF = 1
35
+ _GIT_EMAIL = 'cifuzz@clusterfuzz.com'
36
+ _GIT_NAME = 'CIFuzz'
37
+ _CORPUS_DIR = 'corpus'
38
+ _COVERAGE_DIR = 'coverage'
39
+
40
+
41
+ def git_runner(repo_path):
42
+ """Returns a gits runner for the repo_path."""
43
+
44
+ def func(*args):
45
+ return subprocess.check_call(('git', '-C', repo_path) + args)
46
+
47
+ return func
48
+
49
+
50
+ # pylint: disable=unused-argument,no-self-use
51
+ class GitFilestore(filestore.BaseFilestore):
52
+ """Generic git filestore. This still relies on another filestore provided by
53
+ the CI for larger artifacts or artifacts which make sense to be included as
54
+ the result of a workflow run."""
55
+
56
+ def __init__(self, config, ci_filestore):
57
+ super().__init__(config)
58
+ self.repo_path = tempfile.mkdtemp()
59
+ self._git = git_runner(self.repo_path)
60
+ self._clone(self.config.git_store_repo)
61
+
62
+ self._ci_filestore = ci_filestore
63
+
64
+ def __del__(self):
65
+ shutil.rmtree(self.repo_path)
66
+
67
+ def _clone(self, repo_url):
68
+ """Clones repo URL."""
69
+ self._git('clone', repo_url, '.')
70
+ self._git('config', '--local', 'user.email', _GIT_EMAIL)
71
+ self._git('config', '--local', 'user.name', _GIT_NAME)
72
+
73
+ def _reset_git(self, branch):
74
+ """Resets the git repo."""
75
+ self._git('fetch', 'origin')
76
+ try:
77
+ self._git('checkout', '-B', branch, 'origin/' + branch)
78
+ self._git('reset', '--hard', 'HEAD')
79
+ except subprocess.CalledProcessError:
80
+ self._git('checkout', '--orphan', branch)
81
+
82
+ self._git('clean', '-fxd')
83
+
84
+ # pylint: disable=too-many-arguments
85
+ @retry.wrap(_PUSH_RETRIES, _PUSH_BACKOFF)
86
+ def _upload_to_git(self,
87
+ message,
88
+ branch,
89
+ upload_path,
90
+ local_path,
91
+ replace=False):
92
+ """Uploads a directory to git. If `replace` is True, then existing contents
93
+ in the upload_path is deleted."""
94
+ self._reset_git(branch)
95
+
96
+ full_repo_path = os.path.join(self.repo_path, upload_path)
97
+ if replace and os.path.exists(full_repo_path):
98
+ shutil.rmtree(full_repo_path)
99
+
100
+ shutil.copytree(local_path, full_repo_path, dirs_exist_ok=True)
101
+ self._git('add', '.')
102
+ try:
103
+ self._git('commit', '-m', message)
104
+ except subprocess.CalledProcessError:
105
+ logging.debug('No changes, skipping git push.')
106
+ return
107
+
108
+ self._git('push', 'origin', branch)
109
+
110
+ def upload_crashes(self, name, directory):
111
+ """Uploads the crashes at |directory| to |name|."""
112
+ return self._ci_filestore.upload_crashes(name, directory)
113
+
114
+ def upload_corpus(self, name, directory, replace=False):
115
+ """Uploads the corpus at |directory| to |name|."""
116
+ self._upload_to_git('Corpus upload',
117
+ self.config.git_store_branch,
118
+ os.path.join(_CORPUS_DIR, name),
119
+ directory,
120
+ replace=replace)
121
+
122
+ def upload_build(self, name, directory):
123
+ """Uploads the build at |directory| to |name|."""
124
+ return self._ci_filestore.upload_build(name, directory)
125
+
126
+ def upload_coverage(self, name, directory):
127
+ """Uploads the coverage report at |directory| to |name|."""
128
+ self._upload_to_git('Coverage upload',
129
+ self.config.git_store_branch_coverage,
130
+ os.path.join(_COVERAGE_DIR, name),
131
+ directory,
132
+ replace=True)
133
+
134
+ def download_corpus(self, name, dst_directory):
135
+ """Downloads the corpus located at |name| to |dst_directory|."""
136
+ self._reset_git(self.config.git_store_branch)
137
+ path = os.path.join(self.repo_path, _CORPUS_DIR, name)
138
+ if not os.path.exists(path):
139
+ logging.debug('Corpus does not exist at %s.', path)
140
+ return False
141
+
142
+ shutil.copytree(path, dst_directory, dirs_exist_ok=True)
143
+ return True
144
+
145
+ def download_build(self, name, dst_directory):
146
+ """Downloads the build with |name| to |dst_directory|."""
147
+ return self._ci_filestore.download_build(name, dst_directory)
148
+
149
+ def download_coverage(self, name, dst_directory):
150
+ """Downloads the latest project coverage report."""
151
+ self._reset_git(self.config.git_store_branch_coverage)
152
+ path = os.path.join(self.repo_path, _COVERAGE_DIR, name)
153
+ if not os.path.exists(path):
154
+ logging.debug('Coverage does not exist at %s.', path)
155
+ return False
156
+
157
+ shutil.copytree(path, dst_directory, dirs_exist_ok=True)
158
+ return True
local-test-commons-compress-full-01-vuln_1/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-commons-compress-full-01-vuln_1/fuzz-tooling/infra/cifuzz/filestore/github_actions/github_api.py ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 dealing with the GitHub API. This is different from
15
+ github_actions_toolkit which only deals with the actions API. We need to use
16
+ both."""
17
+ import logging
18
+ import os
19
+ import sys
20
+
21
+ import requests
22
+
23
+ import filestore
24
+
25
+ # pylint: disable=wrong-import-position,import-error
26
+
27
+ sys.path.append(
28
+ os.path.join(__file__, os.path.pardir, os.path.pardir, os.path.pardir,
29
+ os.path.pardir))
30
+ import retry
31
+
32
+ _MAX_ITEMS_PER_PAGE = 100
33
+
34
+ _GET_ATTEMPTS = 3
35
+ _GET_BACKOFF = 1
36
+
37
+
38
+ def get_http_auth_headers(config):
39
+ """Returns HTTP headers for authentication to the API."""
40
+ authorization = f'token {config.token}'
41
+ return {
42
+ 'Authorization': authorization,
43
+ 'Accept': 'application/vnd.github.v3+json'
44
+ }
45
+
46
+
47
+ def _get_artifacts_list_api_url(repo_owner, repo_name):
48
+ """Returns the artifacts_api_url for |repo_name| owned by |repo_owner|."""
49
+ github_api_url = os.getenv('GITHUB_API_URL', 'https://api.github.com')
50
+ return (f'{github_api_url}/repos/{repo_owner}/'
51
+ f'{repo_name}/actions/artifacts')
52
+
53
+
54
+ @retry.wrap(_GET_ATTEMPTS, _GET_BACKOFF)
55
+ def _do_get_request(*args, **kwargs):
56
+ """Wrapped version of requests.get that does retries."""
57
+ return requests.get(*args, **kwargs)
58
+
59
+
60
+ def _get_items(url, headers):
61
+ """Generator that gets and yields items from a GitHub API endpoint (specified
62
+ by |URL|) sending |headers| with the get request."""
63
+ # Github API response pages are 1-indexed.
64
+ page_counter = 1
65
+
66
+ # Set to infinity so we run loop at least once.
67
+ total_num_items = float('inf')
68
+
69
+ item_num = 0
70
+ while item_num < total_num_items:
71
+ params = {'per_page': _MAX_ITEMS_PER_PAGE, 'page': str(page_counter)}
72
+ response = _do_get_request(url, params=params, headers=headers)
73
+ response_json = response.json()
74
+ if not response.status_code == 200:
75
+ # Check that request was successful.
76
+ logging.error('Request to %s failed. Code: %d. Response: %s',
77
+ response.request.url, response.status_code, response_json)
78
+ raise filestore.FilestoreError('Github API request failed.')
79
+
80
+ if total_num_items == float('inf'):
81
+ # Set proper total_num_items
82
+ total_num_items = response_json['total_count']
83
+
84
+ # Get the key for the items we are after.
85
+ keys = [key for key in response_json.keys() if key != 'total_count']
86
+ assert len(keys) == 1, keys
87
+ items_key = keys[0]
88
+
89
+ for item in response_json[items_key]:
90
+ yield item
91
+ item_num += 1
92
+
93
+ page_counter += 1
94
+
95
+
96
+ def find_artifact(artifact_name, artifacts):
97
+ """Find the artifact with the name |artifact_name| in |artifacts|."""
98
+ for artifact in artifacts:
99
+ # TODO(metzman): Handle multiple by making sure we download the latest.
100
+ if artifact['name'] == artifact_name and not artifact['expired']:
101
+ return artifact
102
+ return None
103
+
104
+
105
+ def list_artifacts(owner, repo, headers):
106
+ """Returns a generator of all the artifacts for |owner|/|repo|."""
107
+ url = _get_artifacts_list_api_url(owner, repo)
108
+ logging.debug('Getting artifacts from: %s', url)
109
+ return _get_items(url, headers)
local-test-commons-compress-full-01-vuln_1/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-commons-compress-full-01-vuln_1/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-commons-compress-full-01-vuln_1/fuzz-tooling/infra/cifuzz/filestore/gitlab/__init__.py ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ """GitLab filestore implementation."""
15
+ import logging
16
+
17
+ import json
18
+ import os
19
+ import shutil
20
+ import tempfile
21
+
22
+ import filestore
23
+ import http_utils
24
+
25
+ # pylint: disable=no-self-use,unused-argument
26
+
27
+
28
+ class GitlabFilestore(filestore.BaseFilestore):
29
+ """Implementation of BaseFilestore using GitLab.
30
+ Needs a cache to upload and download builds.
31
+ Needs a git repository for corpus and coverage.
32
+ """
33
+
34
+ BUILD_PREFIX = 'build-'
35
+ CORPUS_PREFIX = 'corpus-'
36
+ COVERAGE_PREFIX = 'coverage-'
37
+ CRASHES_PREFIX = 'crashes-'
38
+
39
+ def __init__(self, config):
40
+ super().__init__(config)
41
+ self.artifacts_dir = self.config.platform_conf.artifacts_dir
42
+ self.cache_dir = self.config.platform_conf.cache_dir
43
+ if self.config.git_store_repo:
44
+ self.git_filestore = filestore.git.GitFilestore(config, None)
45
+ else:
46
+ self.git_filestore = None
47
+
48
+ def upload_crashes(self, name, directory):
49
+ """GitLab artifacts implementation of upload_crashes."""
50
+ # Upload crashes as job artifacts.
51
+ if os.listdir(directory):
52
+ dest_dir_artifacts = os.path.join(self.config.project_src_path,
53
+ self.artifacts_dir,
54
+ self.CRASHES_PREFIX + name)
55
+ logging.info('Uploading artifacts to %s.', dest_dir_artifacts)
56
+ shutil.copytree(directory, dest_dir_artifacts)
57
+
58
+ def upload_corpus(self, name, directory, replace=False):
59
+ """GitLab artifacts implementation of upload_corpus."""
60
+ # Use the git filestore if any.
61
+ if self.git_filestore:
62
+ self.git_filestore.upload_corpus(name, directory, replace)
63
+ return
64
+ # Fall back to cache.
65
+ dest_dir_cache = os.path.join(self.config.project_src_path, self.cache_dir,
66
+ self.CORPUS_PREFIX + name)
67
+ logging.info('Copying from %s to cache %s.', directory, dest_dir_cache)
68
+ # Remove previous corpus from cache if any.
69
+ shutil.rmtree(dest_dir_cache, ignore_errors=True)
70
+ shutil.copytree(directory, dest_dir_cache, dirs_exist_ok=True)
71
+
72
+ def upload_build(self, name, directory):
73
+ """GitLab artifacts implementation of upload_build."""
74
+ # Puts build into the cache.
75
+ dest_dir_cache = os.path.join(self.config.project_src_path, self.cache_dir,
76
+ self.BUILD_PREFIX + name)
77
+ logging.info('Copying from %s to cache %s.', directory, dest_dir_cache)
78
+ shutil.copytree(directory, dest_dir_cache, dirs_exist_ok=True)
79
+
80
+ def upload_coverage(self, name, directory):
81
+ """GitLab artifacts implementation of upload_coverage."""
82
+ # Use the git filestore.
83
+ if self.git_filestore:
84
+ self.git_filestore.upload_coverage(name, directory)
85
+ return
86
+ # Fall back to cache.
87
+ dest_dir_cache = os.path.join(self.config.project_src_path, self.cache_dir,
88
+ self.COVERAGE_PREFIX + name)
89
+ logging.info('Copying from %s to cache %s.', directory, dest_dir_cache)
90
+ shutil.copytree(directory, dest_dir_cache, dirs_exist_ok=True)
91
+ # And also updates coverage reports as artifacts
92
+ # as it should not be too big.
93
+ dest_dir_artifacts = os.path.join(self.config.project_src_path,
94
+ self.artifacts_dir,
95
+ self.COVERAGE_PREFIX + name)
96
+ logging.info('Uploading artifacts to %s.', dest_dir_artifacts)
97
+ shutil.copytree(directory, dest_dir_artifacts)
98
+
99
+ def _copy_from_cache(self, src_dir_cache, dst_directory):
100
+ if not os.path.exists(src_dir_cache):
101
+ logging.info('Cache %s does not exist.', src_dir_cache)
102
+ return False
103
+ logging.info('Copying %s from cache to %s.', src_dir_cache, dst_directory)
104
+ shutil.copytree(src_dir_cache, dst_directory, dirs_exist_ok=True)
105
+ return True
106
+
107
+ def download_corpus(self, name, dst_directory):
108
+ """GitLab artifacts implementation of download_corpus."""
109
+ # Use the git filestore if any.
110
+ if self.git_filestore:
111
+ self.git_filestore.download_corpus(name, dst_directory)
112
+ return
113
+ # Fall back to cache.
114
+ src_dir_cache = os.path.join(self.config.project_src_path, self.cache_dir,
115
+ self.CORPUS_PREFIX + name)
116
+ self._copy_from_cache(src_dir_cache, dst_directory)
117
+
118
+ def download_build(self, name, dst_directory):
119
+ """GitLab artifacts implementation of download_build."""
120
+ # Gets build from the cache.
121
+ src_dir_cache = os.path.join(self.config.project_src_path, self.cache_dir,
122
+ self.BUILD_PREFIX + name)
123
+ return self._copy_from_cache(src_dir_cache, dst_directory)
124
+
125
+ def download_coverage(self, name, dst_directory):
126
+ """GitLab artifacts implementation of download_coverage."""
127
+ # Use the git filestore if any.
128
+ if self.git_filestore:
129
+ return self.git_filestore.download_coverage(name, dst_directory)
130
+ # Fall back to cache.
131
+ src_dir_cache = os.path.join(self.config.project_src_path, self.cache_dir,
132
+ self.COVERAGE_PREFIX + name)
133
+ return self._copy_from_cache(src_dir_cache, dst_directory)
local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/cifuzz/filestore/gsutil/__init__.py ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ """Filestore implementation using gsutil."""
15
+ import logging
16
+ import os
17
+ import posixpath
18
+ import subprocess
19
+ import sys
20
+
21
+ # pylint: disable=wrong-import-position,import-error
22
+ sys.path.append(
23
+ os.path.join(os.path.dirname(os.path.abspath(__file__)), os.pardir,
24
+ os.pardir, os.pardir))
25
+ import filestore
26
+ import utils
27
+
28
+
29
+ def _gsutil_execute(*args, parallel=True):
30
+ """Executes a gsutil command, passing |*args| to gsutil and returns the
31
+ stdout, stderr and returncode. Exceptions on failure."""
32
+ command = ['gsutil']
33
+ if parallel:
34
+ command.append('-m')
35
+ command += list(args)
36
+ logging.info('Executing gsutil command: %s', command)
37
+ return utils.execute(command, check_result=True)
38
+
39
+
40
+ def _rsync(src, dst, recursive=True, delete=False):
41
+ """Executes gsutil rsync on |src| and |dst|"""
42
+ args = ['rsync']
43
+ if recursive:
44
+ args.append('-r')
45
+ if delete:
46
+ args.append('-d')
47
+ args += [src, dst]
48
+ return _gsutil_execute(*args)
49
+
50
+
51
+ class GSUtilFilestore(filestore.BaseFilestore):
52
+ """Filestore implementation using gsutil."""
53
+ BUILD_DIR = 'build'
54
+ CRASHES_DIR = 'crashes'
55
+ CORPUS_DIR = 'corpus'
56
+ COVERAGE_DIR = 'coverage'
57
+
58
+ def __init__(self, config):
59
+ super().__init__(config)
60
+ self._cloud_bucket = self.config.cloud_bucket
61
+
62
+ def _get_gsutil_url(self, name, prefix_dir):
63
+ """Returns the gsutil URL for |name| and |prefix_dir|."""
64
+ if not prefix_dir:
65
+ return posixpath.join(self._cloud_bucket, name)
66
+ return posixpath.join(self._cloud_bucket, prefix_dir, name)
67
+
68
+ def _upload_directory(self, name, directory, prefix, delete=False):
69
+ gsutil_url = self._get_gsutil_url(name, prefix)
70
+ return _rsync(directory, gsutil_url, delete=delete)
71
+
72
+ def _download_directory(self, name, dst_directory, prefix):
73
+ gsutil_url = self._get_gsutil_url(name, prefix)
74
+ return _rsync(gsutil_url, dst_directory)
75
+
76
+ def upload_crashes(self, name, directory):
77
+ """Uploads the crashes at |directory| to |name|."""
78
+ # Name is going to be "current". I don't know if this makes sense outside of
79
+ # GitHub Actions.
80
+ gsutil_url = self._get_gsutil_url(name, self.CRASHES_DIR)
81
+ logging.info('Uploading crashes to %s.', gsutil_url)
82
+ return _rsync(directory, gsutil_url)
83
+
84
+ def upload_corpus(self, name, directory, replace=False):
85
+ """Uploads the crashes at |directory| to |name|."""
86
+ return self._upload_directory(name,
87
+ directory,
88
+ self.CORPUS_DIR,
89
+ delete=replace)
90
+
91
+ def upload_build(self, name, directory):
92
+ """Uploads the build located at |directory| to |name|."""
93
+ return self._upload_directory(name, directory, self.BUILD_DIR)
94
+
95
+ def upload_coverage(self, name, directory):
96
+ """Uploads the coverage report at |directory| to |name|."""
97
+ return self._upload_directory(name, directory, self.COVERAGE_DIR)
98
+
99
+ def download_corpus(self, name, dst_directory):
100
+ """Downloads the corpus located at |name| to |dst_directory|."""
101
+ return self._download_directory(name, dst_directory, self.CORPUS_DIR)
102
+
103
+ def download_build(self, name, dst_directory):
104
+ """Downloads the build with |name| to |dst_directory|."""
105
+ return self._download_directory(name, dst_directory, self.BUILD_DIR)
106
+
107
+ def download_coverage(self, name, dst_directory):
108
+ """Downloads the latest project coverage report."""
109
+ return self._download_directory(name, dst_directory, self.COVERAGE_DIR)
local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/cifuzz/filestore/no_filestore/__init__.py ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ """Empty filestore implementation for platforms that haven't implemented it."""
15
+ import logging
16
+
17
+ import filestore
18
+
19
+ # pylint:disable=no-self-use,unused-argument
20
+
21
+
22
+ class NoFilestore(filestore.BaseFilestore):
23
+ """Empty Filestore implementation."""
24
+
25
+ def upload_crashes(self, name, directory):
26
+ """Noop implementation of upload_crashes."""
27
+ logging.info('Not uploading crashes because no Filestore.')
28
+
29
+ def upload_corpus(self, name, directory, replace=False):
30
+ """Noop implementation of upload_corpus."""
31
+ logging.info('Not uploading corpus because no Filestore.')
32
+
33
+ def upload_build(self, name, directory):
34
+ """Noop implementation of upload_build."""
35
+ logging.info('Not uploading build because no Filestore.')
36
+
37
+ def upload_coverage(self, name, directory):
38
+ """Noop implementation of upload_coverage."""
39
+ logging.info('Not uploading coverage because no Filestore.')
40
+
41
+ def download_corpus(self, name, dst_directory):
42
+ """Noop implementation of download_corpus."""
43
+ logging.info('Not downloading corpus because no Filestore.')
44
+
45
+ def download_build(self, name, dst_directory):
46
+ """Noop implementation of download_build."""
47
+ logging.info('Not downloading build because no Filestore.')
48
+
49
+ def download_coverage(self, name, dst_directory):
50
+ """Noop implementation of download_coverage."""
51
+ logging.info('Not downloading coverage because no Filestore.')
local-test-commons-compress-full-01-vuln_1/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-commons-compress-full-01-vuln_1/fuzz-tooling/infra/cifuzz/test_data/TimeoutFuzzer.cpp ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
15
+ // Example of a standalone runner for "fuzz targets".
16
+ // It reads all files passed as parameters and feeds their contents
17
+ // one by one into the fuzz target (LLVMFuzzerTestOneInput).
18
+ // This runner does not do any fuzzing, but allows us to run the fuzz target
19
+ // on the test corpus (e.g. "do_stuff_test_data") or on a single file,
20
+ // e.g. the one that comes from a bug report.
21
+
22
+ // This is a fuzz target that times out on every input by infinite looping.
23
+ // This is used for testing.
24
+ // Build instructions:
25
+ // 1. clang++ -fsanitize=fuzzer TimeoutFuzzer.cpp -o timeout_fuzzer
26
+ // 2. strip timeout_fuzzer
27
+ // The binary is stripped to save space in the git repo.
28
+
29
+ #include <stddef.h>
30
+ #include <stdint.h>
31
+
32
+ extern "C" int LLVMFuzzerTestOneInput(uint8_t* data, size_t size) {
33
+ while (true)
34
+ ;
35
+ return 0;
36
+ }
local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/cifuzz/test_data/example_crash_fuzzer_bug_summary.txt ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ AddressSanitizer: heap-buffer-overflow on address 0x62500001b530 at pc 0x00000052138a bp 0x7ffe62db2c10 sp 0x7ffe62db23d8
2
+ READ of size 52 at 0x62500001b530 thread T0
3
+ SCARINESS: 26 (multi-byte-read-heap-buffer-overflow)
4
+ #0 0x521389 in __asan_memcpy /src/llvm-project/compiler-rt/lib/asan/asan_interceptors_memintrinsics.cpp:22:3
5
+ #1 0x567590 in yr_object_set_string /src/yara/libyara/object.c:1122:5
6
+ #2 0x5afced in dex_parse /src/yara/libyara/modules/dex/dex.c:781:5
7
+ #3 0x5b4a8b in dex__load /src/yara/libyara/modules/dex/dex.c:1218:7
8
+ #4 0x56537c in yr_modules_load /src/yara/libyara/modules.c:179:16
9
+ #5 0x5d6583 in yr_execute_code /src/yara/libyara/exec.c:1276:18
10
+ #6 0x56f5c0 in yr_scanner_scan_mem_blocks /src/yara/libyara/scanner.c:444:3
11
+ #7 0x56bf23 in yr_rules_scan_mem_blocks /src/yara/libyara/rules.c:235:12
12
+ #8 0x56c182 in yr_rules_scan_mem /src/yara/libyara/rules.c:285:10
13
+ #9 0x5548d2 in LLVMFuzzerTestOneInput /src/yara/tests/oss-fuzz/dex_fuzzer.cc:40:3
14
+ #10 0x45a3b1 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:556:15
15
+ #11 0x459ad5 in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:470:3
16
+ #12 0x45be77 in fuzzer::Fuzzer::MutateAndTestOne() /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:698:19
17
+ #13 0x45cc05 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:830:5
18
+ #14 0x44ac88 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:824:6
19
+ #15 0x474ab2 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:19:10
20
+ #16 0x7f4409b7a82f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
21
+ #17 0x41e348 in _start (out/dex_fuzzer+0x41e348)
22
+
23
+ 0x62500001b530 is located 0 bytes to the right of 9264-byte region [0x625000019100,0x62500001b530)
24
+ allocated by thread T0 here:
25
+ #0 0x521f4d in malloc /src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:145:3
26
+ #1 0x4331b7 in operator new(unsigned long) (out/dex_fuzzer+0x4331b7)
27
+ #2 0x459ad5 in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:470:3
28
+ #3 0x45be77 in fuzzer::Fuzzer::MutateAndTestOne() /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:698:19
29
+ #4 0x45cc05 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:830:5
30
+ #5 0x44ac88 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:824:6
31
+ #6 0x474ab2 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:19:10
32
+ #7 0x7f4409b7a82f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
33
+
34
+ SUMMARY: AddressSanitizer: heap-buffer-overflow /src/llvm-project/compiler-rt/lib/asan/asan_interceptors_memintrinsics.cpp:22:3 in __asan_memcpy
35
+ Shadow bytes around the buggy address:
36
+ 0x0c4a7fffb650: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
37
+ 0x0c4a7fffb660: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
38
+ 0x0c4a7fffb670: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
39
+ 0x0c4a7fffb680: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
40
+ 0x0c4a7fffb690: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
41
+ =>0x0c4a7fffb6a0: 00 00 00 00 00 00[fa]fa fa fa fa fa fa fa fa fa
42
+ 0x0c4a7fffb6b0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
43
+ 0x0c4a7fffb6c0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
44
+ 0x0c4a7fffb6d0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
45
+ 0x0c4a7fffb6e0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
46
+ 0x0c4a7fffb6f0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
47
+
48
+ Shadow byte legend (one shadow byte represents 8 application bytes):
49
+ Addressable: 00
50
+ Partially addressable: 01 02 03 04 05 06 07
51
+ Heap left redzone: fa
52
+ Freed heap region: fd
53
+ Stack left redzone: f1
54
+ Stack mid redzone: f2
55
+ Stack right redzone: f3
56
+ Stack after return: f5
57
+ Stack use after scope: f8
58
+ Global redzone: f9
59
+ Global init order: f6
60
+ Poisoned by user: f7
61
+ Container overflow: fc
62
+ Array cookie: ac
63
+ Intra object redzone: bb
64
+ ASan internal: fe
65
+ Left alloca redzone: ca
66
+ Right alloca redzone: cb
67
+ Shadow gap: cc
68
+ ==12==ABORTING
local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/cifuzz/test_data/example_crash_fuzzer_output.txt ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /github/workspace/build-out/do_stuff_fuzzer -timeout=25 -rss_limit_mb=2560 -dict=/github/workspace/build-out/do_stuff_fuzzer.dict -len_control=0 -seed=1337 -artifact_prefix=/tmp/tmp9p1w4p8r/ -max_total_time=600 -print_final_stats=1 /github/workspace/cifuzz-corpus/do_stuff_fuzzer >fuzz-0.log 2>&1
2
+ ================== Job 0 exited with exit code 77 ============
3
+ Dictionary: 3 entries
4
+ INFO: Running with entropic power schedule (0xFF, 100).
5
+ INFO: Seed: 1337
6
+ INFO: Loaded 1 modules (86 inline 8-bit counters): 86 [0x6150e0, 0x615136),
7
+ INFO: Loaded 1 PC tables (86 PCs): 86 [0x5c8b08,0x5c9068),
8
+ INFO: 5 files found in /github/workspace/cifuzz-corpus/do_stuff_fuzzer
9
+ INFO: -max_len is not provided; libFuzzer will not generate inputs larger than 4096 bytes
10
+ INFO: seed corpus: files: 5 min: 3b max: 44b total: 64b rss: 31Mb
11
+ #6 INITED cov: 64 ft: 70 corp: 5/64b exec/s: 0 rss: 32Mb
12
+ #9 NEW cov: 64 ft: 72 corp: 6/74b lim: 4096 exec/s: 0 rss: 32Mb L: 10/44 MS: 3 ChangeBit-InsertByte-ManualDict- DE: "foo"-
13
+ #17 NEW cov: 64 ft: 74 corp: 7/86b lim: 4096 exec/s: 0 rss: 32Mb L: 12/44 MS: 3 ChangeBit-ManualDict-PersAutoDict- DE: "ouch"-"foo"-
14
+ #18 NEW cov: 64 ft: 76 corp: 8/100b lim: 4096 exec/s: 0 rss: 32Mb L: 14/44 MS: 1 CrossOver-
15
+ #22 NEW cov: 64 ft: 78 corp: 9/141b lim: 4096 exec/s: 0 rss: 32Mb L: 41/44 MS: 4 InsertRepeatedBytes-CopyPart-ChangeBinInt-ChangeBit-
16
+ #24 NEW cov: 64 ft: 80 corp: 10/151b lim: 4096 exec/s: 0 rss: 32Mb L: 10/44 MS: 2 CrossOver-CopyPart-
17
+ #28 NEW cov: 64 ft: 81 corp: 11/171b lim: 4096 exec/s: 0 rss: 32Mb L: 20/44 MS: 4 InsertByte-PersAutoDict-ShuffleBytes-ManualDict- DE: "foo"-"ouch"-
18
+ #43 NEW cov: 65 ft: 83 corp: 12/175b lim: 4096 exec/s: 0 rss: 32Mb L: 4/44 MS: 5 InsertByte-ChangeBit-ManualDict-ManualDict-EraseBytes- DE: "bar"-"bar"-
19
+ #54 NEW cov: 65 ft: 84 corp: 13/191b lim: 4096 exec/s: 0 rss: 32Mb L: 16/44 MS: 1 CrossOver-
20
+ #64 NEW cov: 65 ft: 86 corp: 14/209b lim: 4096 exec/s: 0 rss: 32Mb L: 18/44 MS: 5 InsertByte-ChangeBinInt-CMP-PersAutoDict-CopyPart- DE: "\000\000"-"foo"-
21
+ #75 REDUCE cov: 65 ft: 86 corp: 14/203b lim: 4096 exec/s: 0 rss: 32Mb L: 35/44 MS: 1 EraseBytes-
22
+ #76 REDUCE cov: 65 ft: 86 corp: 14/195b lim: 4096 exec/s: 0 rss: 32Mb L: 36/36 MS: 1 EraseBytes-
23
+ =================================================================
24
+ ==26==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x603000003114 at pc 0x00000056d1db bp 0x7fffd6a72bf0 sp 0x7fffd6a72be8
25
+ READ of size 4 at 0x603000003114 thread T0
26
+ SCARINESS: 17 (4-byte-read-heap-buffer-overflow)
27
+ #0 0x56d1da in DoStuff(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) /src/cifuzz-example/my_api.cpp:26:10
28
+ #1 0x56c5d6 in LLVMFuzzerTestOneInput /src/cifuzz-example/do_stuff_fuzzer.cpp:15:3
29
+ #2 0x43de23 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:611:15
30
+ #3 0x43d60a in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:514:3
31
+ #4 0x43ecd9 in fuzzer::Fuzzer::MutateAndTestOne() /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:757:19
32
+ #5 0x43f9a5 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:895:5
33
+ #6 0x42ed0f in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:912:6
34
+ #7 0x458362 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
35
+ #8 0x7fcfaa2aa082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 1878e6b475720c7c51969e69ab2d276fae6d1dee)
36
+ #9 0x41f74d in _start (build-out/do_stuff_fuzzer+0x41f74d)
37
+
38
+ DEDUP_TOKEN: DoStuff(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)--LLVMFuzzerTestOneInput--fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long)
39
+ 0x603000003114 is located 0 bytes to the right of 20-byte region [0x603000003100,0x603000003114)
40
+ allocated by thread T0 here:
41
+ #0 0x569dfd in operator new(unsigned long) /src/llvm-project/compiler-rt/lib/asan/asan_new_delete.cpp:95:3
42
+ #1 0x56c9d4 in __libcpp_operator_new<unsigned long> /usr/local/bin/../include/c++/v1/new:245:10
43
+ #2 0x56c9d4 in __libcpp_allocate /usr/local/bin/../include/c++/v1/new:271:10
44
+ #3 0x56c9d4 in allocate /usr/local/bin/../include/c++/v1/__memory/allocator.h:105:38
45
+ #4 0x56c9d4 in allocate /usr/local/bin/../include/c++/v1/__memory/allocator_traits.h:262:20
46
+ #5 0x56c9d4 in __vallocate /usr/local/bin/../include/c++/v1/vector:931:37
47
+ #6 0x56c9d4 in vector /usr/local/bin/../include/c++/v1/vector:1236:9
48
+ #7 0x56c9d4 in DoStuff(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) /src/cifuzz-example/my_api.cpp:14:20
49
+ #8 0x56c5d6 in LLVMFuzzerTestOneInput /src/cifuzz-example/do_stuff_fuzzer.cpp:15:3
50
+ #9 0x43de23 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:611:15
51
+ #10 0x43d60a in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:514:3
52
+ #11 0x43ecd9 in fuzzer::Fuzzer::MutateAndTestOne() /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:757:19
53
+ #12 0x43f9a5 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:895:5
54
+ #13 0x42ed0f in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:912:6
55
+ #14 0x458362 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
56
+ #15 0x7fcfaa2aa082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 1878e6b475720c7c51969e69ab2d276fae6d1dee)
57
+
58
+ DEDUP_TOKEN: operator new(unsigned long)--__libcpp_operator_new<unsigned long>--__libcpp_allocate
59
+ SUMMARY: AddressSanitizer: heap-buffer-overflow /src/cifuzz-example/my_api.cpp:26:10 in DoStuff(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)
60
+ Shadow bytes around the buggy address:
61
+ 0x0c067fff85d0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
62
+ 0x0c067fff85e0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
63
+ 0x0c067fff85f0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
64
+ 0x0c067fff8600: fa fa fd fd fd fa fa fa fd fd fd fa fa fa fd fd
65
+ 0x0c067fff8610: fd fa fa fa fd fd fd fa fa fa 00 00 00 00 fa fa
66
+ =>0x0c067fff8620: 00 00[04]fa fa fa fa fa fa fa fa fa fa fa fa fa
67
+ 0x0c067fff8630: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
68
+ 0x0c067fff8640: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
69
+ 0x0c067fff8650: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
70
+ 0x0c067fff8660: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
71
+ 0x0c067fff8670: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
72
+ Shadow byte legend (one shadow byte represents 8 application bytes):
73
+ Addressable: 00
74
+ Partially addressable: 01 02 03 04 05 06 07
75
+ Heap left redzone: fa
76
+ Freed heap region: fd
77
+ Stack left redzone: f1
78
+ Stack mid redzone: f2
79
+ Stack right redzone: f3
80
+ Stack after return: f5
81
+ Stack use after scope: f8
82
+ Global redzone: f9
83
+ Global init order: f6
84
+ Poisoned by user: f7
85
+ Container overflow: fc
86
+ Array cookie: ac
87
+ Intra object redzone: bb
88
+ ASan internal: fe
89
+ Left alloca redzone: ca
90
+ Right alloca redzone: cb
91
+ ==26==ABORTING
92
+ MS: 4 PersAutoDict-ManualDict-CrossOver-PersAutoDict- DE: "foo"-"ouch"-"bar"-; base unit: 1a25c32303e03f997166aee1c665b5ae9f66ec7d
93
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x66,0x6f,0x6f,0xff,0x1,0x62,0x61,0x72,0x63,0x68,0x6f,0x75,0x63,0x68,0x66,0x6f,0x66,0x6e,0x6f,0x6d,0x67,0x6d,
94
+ \377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377foo\377\001barchouchfofnomgm
95
+ artifact_prefix='/tmp/tmp9p1w4p8r/'; Test unit written to /tmp/tmp9p1w4p8r/crash-1c750df432fe458b738987ba69cd20a598708775
96
+ Base64: //////////////////////9mb2//AWJhcmNob3VjaGZvZm5vbWdt
97
+ stat::number_of_executed_units: 90
98
+ stat::average_exec_per_sec: 0
99
+ stat::new_units_added: 11
100
+ stat::slowest_unit_time_sec: 0
101
+ stat::peak_rss_mb: 33
102
+ /github/workspace/build-out/do_stuff_fuzzer -timeout=25 -rss_limit_mb=2560 -dict=/github/workspace/build-out/do_stuff_fuzzer.dict -len_control=0 -seed=1337 -artifact_prefix=/tmp/tmp9p1w4p8r/ -max_total_time=600 -print_final_stats=1 /github/workspace/cifuzz-corpus/do_stuff_fuzzer >fuzz-1.log 2>&1
103
+ ================== Job 1 exited with exit code 77 ============
104
+ Dictionary: 3 entries
105
+ INFO: Running with entropic power schedule (0xFF, 100).
106
+ INFO: Seed: 1337
107
+ INFO: Loaded 1 modules (86 inline 8-bit counters): 86 [0x6150e0, 0x615136),
108
+ INFO: Loaded 1 PC tables (86 PCs): 86 [0x5c8b08,0x5c9068),
109
+ INFO: 15 files found in /github/workspace/cifuzz-corpus/do_stuff_fuzzer
110
+ INFO: -max_len is not provided; libFuzzer will not generate inputs larger than 4096 bytes
111
+ INFO: seed corpus: files: 15 min: 3b max: 44b total: 239b rss: 31Mb
112
+ #16 INITED cov: 65 ft: 86 corp: 13/159b exec/s: 0 rss: 32Mb
113
+ #38 NEW cov: 65 ft: 88 corp: 14/188b lim: 4096 exec/s: 0 rss: 32Mb L: 29/35 MS: 2 InsertByte-CopyPart-
114
+ #43 REDUCE cov: 65 ft: 88 corp: 14/187b lim: 4096 exec/s: 0 rss: 32Mb L: 2/35 MS: 5 InsertByte-ChangeByte-ChangeBinInt-EraseBytes-EraseBytes-
115
+ #64 NEW cov: 66 ft: 89 corp: 15/191b lim: 4096 exec/s: 0 rss: 32Mb L: 4/35 MS: 1 ChangeByte-
116
+ #78 REDUCE cov: 66 ft: 89 corp: 15/190b lim: 4096 exec/s: 0 rss: 32Mb L: 15/35 MS: 4 ChangeBinInt-CopyPart-EraseBytes-EraseBytes-
117
+ #95 REDUCE cov: 66 ft: 89 corp: 15/188b lim: 4096 exec/s: 0 rss: 32Mb L: 16/35 MS: 2 ChangeBinInt-EraseBytes-
118
+ #110 REDUCE cov: 66 ft: 89 corp: 15/184b lim: 4096 exec/s: 0 rss: 32Mb L: 31/31 MS: 5 CrossOver-ChangeByte-ShuffleBytes-InsertByte-EraseBytes-
119
+ #146 REDUCE cov: 66 ft: 89 corp: 15/183b lim: 4096 exec/s: 0 rss: 32Mb L: 1/31 MS: 1 EraseBytes-
120
+ #157 NEW cov: 66 ft: 90 corp: 16/210b lim: 4096 exec/s: 0 rss: 32Mb L: 27/31 MS: 1 CrossOver-
121
+ #230 REDUCE cov: 66 ft: 92 corp: 17/318b lim: 4096 exec/s: 0 rss: 32Mb L: 108/108 MS: 3 CopyPart-InsertRepeatedBytes-CrossOver-
122
+ #277 NEW cov: 66 ft: 94 corp: 18/429b lim: 4096 exec/s: 0 rss: 32Mb L: 111/111 MS: 2 ManualDict-CMP- DE: "bar"-"\000\000\000\000"-
123
+ #337 NEW cov: 67 ft: 95 corp: 19/439b lim: 4096 exec/s: 0 rss: 32Mb L: 10/111 MS: 5 ChangeByte-ChangeBit-ManualDict-CopyPart-EraseBytes- DE: "bar"-
124
+ =================================================================
125
+ ==30==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x603000007d94 at pc 0x00000056d1db bp 0x7ffdb9da4b50 sp 0x7ffdb9da4b48
126
+ READ of size 4 at 0x603000007d94 thread T0
127
+ SCARINESS: 17 (4-byte-read-heap-buffer-overflow)
128
+ #0 0x56d1da in DoStuff(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) /src/cifuzz-example/my_api.cpp:26:10
129
+ #1 0x56c5d6 in LLVMFuzzerTestOneInput /src/cifuzz-example/do_stuff_fuzzer.cpp:15:3
130
+ #2 0x43de23 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:611:15
131
+ #3 0x43d60a in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:514:3
132
+ #4 0x43ecd9 in fuzzer::Fuzzer::MutateAndTestOne() /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:757:19
133
+ #5 0x43f9a5 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:895:5
134
+ #6 0x42ed0f in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:912:6
135
+ #7 0x458362 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
136
+ #8 0x7fc2c6bd3082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 1878e6b475720c7c51969e69ab2d276fae6d1dee)
137
+ #9 0x41f74d in _start (build-out/do_stuff_fuzzer+0x41f74d)
138
+
139
+ DEDUP_TOKEN: DoStuff(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)--LLVMFuzzerTestOneInput--fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long)
140
+ 0x603000007d94 is located 0 bytes to the right of 20-byte region [0x603000007d80,0x603000007d94)
141
+ allocated by thread T0 here:
142
+ #0 0x569dfd in operator new(unsigned long) /src/llvm-project/compiler-rt/lib/asan/asan_new_delete.cpp:95:3
143
+ #1 0x56c9d4 in __libcpp_operator_new<unsigned long> /usr/local/bin/../include/c++/v1/new:245:10
144
+ #2 0x56c9d4 in __libcpp_allocate /usr/local/bin/../include/c++/v1/new:271:10
145
+ #3 0x56c9d4 in allocate /usr/local/bin/../include/c++/v1/__memory/allocator.h:105:38
146
+ #4 0x56c9d4 in allocate /usr/local/bin/../include/c++/v1/__memory/allocator_traits.h:262:20
147
+ #5 0x56c9d4 in __vallocate /usr/local/bin/../include/c++/v1/vector:931:37
148
+ #6 0x56c9d4 in vector /usr/local/bin/../include/c++/v1/vector:1236:9
149
+ #7 0x56c9d4 in DoStuff(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) /src/cifuzz-example/my_api.cpp:14:20
150
+ #8 0x56c5d6 in LLVMFuzzerTestOneInput /src/cifuzz-example/do_stuff_fuzzer.cpp:15:3
151
+ #9 0x43de23 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:611:15
152
+ #10 0x43d60a in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:514:3
153
+ #11 0x43ecd9 in fuzzer::Fuzzer::MutateAndTestOne() /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:757:19
154
+ #12 0x43f9a5 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:895:5
155
+ #13 0x42ed0f in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:912:6
156
+ #14 0x458362 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
157
+ #15 0x7fc2c6bd3082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 1878e6b475720c7c51969e69ab2d276fae6d1dee)
158
+
159
+ DEDUP_TOKEN: operator new(unsigned long)--__libcpp_operator_new<unsigned long>--__libcpp_allocate
160
+ SUMMARY: AddressSanitizer: heap-buffer-overflow /src/cifuzz-example/my_api.cpp:26:10 in DoStuff(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)
161
+ Shadow bytes around the buggy address:
162
+ 0x0c067fff8f60: fa fa fd fd fd fa fa fa fd fd fd fa fa fa fd fd
163
+ 0x0c067fff8f70: fd fa fa fa fd fd fd fa fa fa fd fd fd fa fa fa
164
+ 0x0c067fff8f80: fd fd fd fa fa fa fd fd fd fa fa fa fd fd fd fa
165
+ 0x0c067fff8f90: fa fa fd fd fd fa fa fa fd fd fd fa fa fa fd fd
166
+ 0x0c067fff8fa0: fd fa fa fa fd fd fd fa fa fa fd fd fd fa fa fa
167
+ =>0x0c067fff8fb0: 00 00[04]fa fa fa fa fa fa fa fa fa fa fa fa fa
168
+ 0x0c067fff8fc0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
169
+ 0x0c067fff8fd0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
170
+ 0x0c067fff8fe0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
171
+ 0x0c067fff8ff0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
172
+ 0x0c067fff9000: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
173
+ Shadow byte legend (one shadow byte represents 8 application bytes):
174
+ Addressable: 00
175
+ Partially addressable: 01 02 03 04 05 06 07
176
+ Heap left redzone: fa
177
+ Freed heap region: fd
178
+ Stack left redzone: f1
179
+ Stack mid redzone: f2
180
+ Stack right redzone: f3
181
+ Stack after return: f5
182
+ Stack use after scope: f8
183
+ Global redzone: f9
184
+ Global init order: f6
185
+ Poisoned by user: f7
186
+ Container overflow: fc
187
+ Array cookie: ac
188
+ Intra object redzone: bb
189
+ ASan internal: fe
190
+ Left alloca redzone: ca
191
+ Right alloca redzone: cb
192
+ ==30==ABORTING
193
+ MS: 4 ShuffleBytes-ManualDict-CrossOver-PersAutoDict- DE: "foo"-"bar"-; base unit: 8fc7da8d952ed1aa5c7415e21b3d52b42402973d
194
+ 0x66,0x6f,0x6f,0x63,0x6f,0x75,0x6f,0x75,0x63,0x68,0x63,0x68,0x66,0x62,0x61,0x72,0x6f,0x6f,0x6d,0x67,0x66,0x6f,0x6f,0x2f,0x99,0x6f,0x6f,0x90,0x6f,0x6f,0x6d,0x0,0x0,0x67,0x2f,
195
+ foocououchchfbaroomgfoo/\231oo\220oom\000\000g/
196
+ artifact_prefix='/tmp/tmp9p1w4p8r/'; Test unit written to /tmp/tmp9p1w4p8r/crash-f8a2a1e84f58a2d676e5ad8078119a39b78df901
197
+ Base64: Zm9vY291b3VjaGNoZmJhcm9vbWdmb28vmW9vkG9vbQAAZy8=
198
+ stat::number_of_executed_units: 366
199
+ stat::average_exec_per_sec: 0
200
+ stat::new_units_added: 11
201
+ stat::slowest_unit_time_sec: 0
202
+ stat::peak_rss_mb: 33
local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/cifuzz/test_data/external-project/.clusterfuzzlite/build.sh ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash -eu
2
+ # Copyright 2020 Google Inc.
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
+ make clean # Not strictly necessary, since we are building in a fresh dir.
19
+ make -j$(nproc) all # Build the fuzz targets.
20
+
21
+ # Copy the fuzzer executables, zip-ed corpora, option and dictionary files to $OUT
22
+ find . -name '*_fuzzer' -exec cp -v '{}' $OUT ';'
23
+ find . -name '*_fuzzer.dict' -exec cp -v '{}' $OUT ';' # If you have dictionaries.
24
+ find . -name '*_fuzzer.options' -exec cp -v '{}' $OUT ';' # If you have custom options.
local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/cifuzz/test_data/external-project/do_stuff_fuzzer.dict ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ # A dictionary for more efficient fuzzing of DoStuff().
2
+ # If the inputs contain multi-byte tokens, list them here.
3
+ # See https://llvm.org/docs/LibFuzzer.html#dictionaries
4
+ "foo"
5
+ "bar"
6
+ "ouch"
local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/cifuzz/test_data/external-project/standalone_fuzz_target_runner.cpp ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ // Example of a standalone runner for "fuzz targets".
16
+ // It reads all files passed as parameters and feeds their contents
17
+ // one by one into the fuzz target (LLVMFuzzerTestOneInput).
18
+ // This runner does not do any fuzzing, but allows us to run the fuzz target
19
+ // on the test corpus (e.g. "do_stuff_test_data") or on a single file,
20
+ // e.g. the one that comes from a bug report.
21
+
22
+ #include <cassert>
23
+ #include <iostream>
24
+ #include <fstream>
25
+ #include <vector>
26
+
27
+ // Forward declare the "fuzz target" interface.
28
+ // We deliberately keep this inteface simple and header-free.
29
+ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
30
+
31
+ int main(int argc, char **argv) {
32
+ for (int i = 1; i < argc; i++) {
33
+ std::ifstream in(argv[i]);
34
+ in.seekg(0, in.end);
35
+ size_t length = in.tellg();
36
+ in.seekg (0, in.beg);
37
+ std::cout << "Reading " << length << " bytes from " << argv[i] << std::endl;
38
+ // Allocate exactly length bytes so that we reliably catch buffer overflows.
39
+ std::vector<char> bytes(length);
40
+ in.read(bytes.data(), bytes.size());
41
+ assert(in);
42
+ LLVMFuzzerTestOneInput(reinterpret_cast<const uint8_t *>(bytes.data()),
43
+ bytes.size());
44
+ std::cout << "Execution successful" << std::endl;
45
+ }
46
+ return 0;
47
+ }
local-test-commons-compress-full-01-vuln_1/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-commons-compress-full-01-vuln_1/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-commons-compress-full-01-vuln_1/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-commons-compress-full-01-vuln_1/fuzz-tooling/infra/cifuzz/test_data/sarif_utils_only_llvmfuzzer_stack.txt ADDED
@@ -0,0 +1,302 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /github/workspace/build-out/fuzz-bus-label -timeout=25 -rss_limit_mb=2560 -len_control=0 -seed=1337 -artifact_prefix=/tmp/tmpsngf52cy/ -max_total_time=13 -print_final_stats=1 /github/workspace/cifuzz-corpus/fuzz-bus-label >fuzz-0.log 2>&1
2
+ ================== Job 0 exited with exit code 0 ============
3
+ INFO: Running with entropic power schedule (0xFF, 100).
4
+ INFO: Seed: 1337
5
+ INFO: Loaded 2 modules (82577 inline 8-bit counters): 82573 [0x7fc55e6bedf0, 0x7fc55e6d307d), 4 [0x5e9c28, 0x5e9c2c),
6
+ 2023-05-04 01:02:55,065 - root - INFO - Not reporting crash in fuzz-bus-label because process timed out.
7
+ 2023-05-04 01:02:55,069 - root - INFO - Deleting corpus and seed corpus of fuzz-bus-label to save disk.
8
+ INFO: Loaded 2 PC tables (82577 PCs): 82573 [0x7fc55e6d3080,0x7fc55e815950), 4 [0x5a6c78,0x5a6cb8),
9
+ INFO: 256 files found in /github/workspace/cifuzz-corpus/fuzz-bus-label
10
+ INFO: -max_len is not provided; libFuzzer will not generate inputs larger than 1048576 bytes
11
+ INFO: seed corpus: files: 256 min: 1b max: 5242880b total: 30968483b rss: 48Mb
12
+ #257 INITED cov: 41 ft: 230 corp: 111/4360b exec/s: 0 rss: 73Mb
13
+ #131072 pulse cov: 41 ft: 230 corp: 111/4360b lim: 1048576 exec/s: 43690 rss: 76Mb
14
+ #262144 pulse cov: 41 ft: 230 corp: 111/4360b lim: 1048576 exec/s: 43690 rss: 76Mb
15
+ #524288 pulse cov: 41 ft: 230 corp: 111/4360b lim: 1048576 exec/s: 43690 rss: 77Mb
16
+ #609082 DONE cov: 41 ft: 230 corp: 111/4360b lim: 1048576 exec/s: 43505 rss: 77Mb
17
+ Done 609082 runs in 14 second(s)
18
+ stat::number_of_executed_units: 609082
19
+ stat::average_exec_per_sec: 43505
20
+ stat::new_units_added: 0
21
+ stat::slowest_unit_time_sec: 0
22
+ stat::peak_rss_mb: 77
23
+ /github/workspace/build-out/fuzz-bus-label -timeout=25 -rss_limit_mb=2560 -len_control=0 -seed=1337 -artifact_prefix=/tmp/tmpsngf52cy/ -max_total_time=13 -print_final_stats=1 /github/workspace/cifuzz-corpus/fuzz-bus-label >fuzz-1.log 2>&1
24
+ 2023-05-04 01:02:55,082 - root - INFO - Deleting fuzz target: fuzz-bus-label.
25
+ 2023-05-04 01:02:55,083 - root - INFO - Done deleting.
26
+ 2023-05-04 01:02:55,084 - root - INFO - Fuzzer fuzz-bus-label finished running without reportable crashes.
27
+ 2023-05-04 01:02:55,084 - root - INFO - Running fuzzer: fuzz-dhcp-server.
28
+ 2023-05-04 01:02:55,085 - root - INFO - Downloading corpus from OSS-Fuzz: https://storage.googleapis.com/systemd-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/systemd_fuzz-dhcp-server/public.zip
29
+ 2023-05-04 01:02:55,088 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): storage.googleapis.com:443
30
+ 2023-05-04 01:02:55,145 - urllib3.connectionpool - DEBUG - https://storage.googleapis.com:443 "GET /systemd-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/systemd_fuzz-dhcp-server/public.zip HTTP/1.1" 200 806749
31
+ 2023-05-04 01:02:55,350 - root - INFO - Starting fuzzing
32
+ Fuzzing logs:
33
+ /github/workspace/build-out/fuzz-dhcp-server -timeout=25 -rss_limit_mb=2560 -len_control=0 -seed=1337 -artifact_prefix=/tmp/tmpyxgwwsvr/ -max_total_time=13 -print_final_stats=1 /github/workspace/cifuzz-corpus/fuzz-dhcp-server >fuzz-0.log 2>&1
34
+ ================== Job 0 exited with exit code 0 ============
35
+ INFO: Running with entropic power schedule (0xFF, 100).
36
+ INFO: Seed: 1337
37
+ INFO: Loaded 2 modules (83640 inline 8-bit counters): 82573 [0x7fe86ff70df0, 0x7fe86ff8507d), 1067 [0x60c638, 0x60ca63),
38
+ INFO: Loaded 2 PC tables (83640 PCs): 82573 [0x7fe86ff85080,0x7fe8700c7950), 1067 [0x60ca68,0x610d18),
39
+ INFO: 1153 files found in /github/workspace/cifuzz-corpus/fuzz-dhcp-server
40
+ INFO: -max_len is not provided; libFuzzer will not generate inputs larger than 1048576 bytes
41
+ INFO: seed corpus: files: 1153 min: 1b max: 5242879b total: 17056071b rss: 50Mb
42
+ #1155 INITED cov: 577 ft: 1116 corp: 203/54Kb exec/s: 0 rss: 86Mb
43
+ #1167 NEW cov: 577 ft: 1117 corp: 204/54Kb lim: 1048576 exec/s: 0 rss: 86Mb L: 243/1071 MS: 2 ChangeASCIIInt-CrossOver-
44
+ #1509 NEW cov: 577 ft: 1118 corp: 205/54Kb lim: 1048576 exec/s: 0 rss: 86Mb L: 243/1071 MS: 2 ChangeBit-CopyPart-
45
+ #63018 NEW cov: 577 ft: 1119 corp: 206/55Kb lim: 1048576 exec/s: 21006 rss: 86Mb L: 245/1071 MS: 4 InsertByte-ChangeByte-CMP-InsertByte- DE: "2\000\000\000\000\000\000\000"-
46
+ #65536 pulse cov: 577 ft: 1119 corp: 206/55Kb lim: 1048576 exec/s: 21845 rss: 86Mb
47
+ Loaded 1024/1155 files from /github/workspace/cifuzz-corpus/fuzz-dhcp-server
48
+ #99784 NEW cov: 577 ft: 1120 corp: 207/55Kb lim: 1048576 exec/s: 19956 rss: 105Mb L: 243/1071 MS: 2 ChangeASCIIInt-ChangeBinInt-
49
+ #131072 pulse cov: 577 ft: 1120 corp: 207/55Kb lim: 1048576 exec/s: 21845 rss: 105Mb
50
+ #262144 pulse cov: 577 ft: 1120 corp: 207/55Kb lim: 1048576 exec/s: 20164 rss: 105Mb
51
+ #275639 DONE cov: 577 ft: 1120 corp: 207/55Kb lim: 1048576 exec/s: 19688 rss: 105Mb
52
+ ###### Recommended dictionary. ######
53
+ "2\000\000\000\000\000\000\000" # Uses: 17879
54
+ ###### End of recommended dictionary. ######
55
+ Done 275639 runs in 14 second(s)
56
+ stat::number_of_executed_units: 275639
57
+ stat::average_exec_per_sec: 19688
58
+ stat::new_units_added: 4
59
+ stat::slowest_unit_time_sec: 0
60
+ stat::peak_rss_mb: 105
61
+ /github/workspace/build-out/fuzz-dhcp-server -timeout=25 -rss_limit_mb=2560 -len_control=0 -seed=1337 -artifact_prefix=/tmp/tmpyxgwwsvr/ -max_total_time=13 -print_final_stats=1 /github/workspace/cifuzz-corpus/fuzz-dhcp-server >fuzz-1.log 2>&1
62
+ 2023-05-04 01:03:18,374 - root - INFO - Not reporting crash in fuzz-dhcp-server because process timed out.
63
+ 2023-05-04 01:03:18,377 - root - INFO - Deleting corpus and seed corpus of fuzz-dhcp-server to save disk.
64
+ 2023-05-04 01:03:18,399 - root - INFO - Deleting fuzz target: fuzz-dhcp-server.
65
+ 2023-05-04 01:03:18,400 - root - INFO - Done deleting.
66
+ 2023-05-04 01:03:18,400 - root - INFO - Fuzzer fuzz-dhcp-server finished running without reportable crashes.
67
+ 2023-05-04 01:03:18,401 - root - INFO - Running fuzzer: fuzz-bcd.
68
+ 2023-05-04 01:03:18,401 - root - INFO - Downloading corpus from OSS-Fuzz: https://storage.googleapis.com/systemd-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/systemd_fuzz-bcd/public.zip
69
+ 2023-05-04 01:03:18,404 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): storage.googleapis.com:443
70
+ 2023-05-04 01:03:18,582 - urllib3.connectionpool - DEBUG - https://storage.googleapis.com:443 "GET /systemd-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/systemd_fuzz-bcd/public.zip HTTP/1.1" 200 2293254
71
+ 2023-05-04 01:03:18,804 - root - INFO - Starting fuzzing
72
+ Fuzzing logs:
73
+ /github/workspace/build-out/fuzz-bcd -timeout=25 -rss_limit_mb=2560 -len_control=0 -seed=1337 -artifact_prefix=/tmp/tmpgvqlyr8q/ -max_total_time=13 -print_final_stats=1 /github/workspace/cifuzz-corpus/fuzz-bcd >fuzz-0.log 2>&1
74
+ ================== Job 0 exited with exit code 0 ============
75
+ INFO: Running with entropic power schedule (0xFF, 100).
76
+ INFO: Seed: 1337
77
+ INFO: Loaded 2 modules (83175 inline 8-bit counters): 82573 [0x7f1b5387edf0, 0x7f1b5389307d), 602 [0x5f8718, 0x5f8972),
78
+ INFO: Loaded 2 PC tables (83175 PCs): 82573 [0x7f1b53893080,0x7f1b539d5950), 602 [0x5f8978,0x5faf18),
79
+ INFO: 1260 files found in /github/workspace/cifuzz-corpus/fuzz-bcd
80
+ INFO: -max_len is not provided; libFuzzer will not generate inputs larger than 946175 bytes
81
+ INFO: seed corpus: files: 1260 min: 1b max: 946175b total: 10373697b rss: 48Mb
82
+ #1261 INITED cov: 137 ft: 653 corp: 282/1416Kb exec/s: 0 rss: 91Mb
83
+ #65536 pulse cov: 137 ft: 653 corp: 282/1416Kb lim: 946175 exec/s: 32768 rss: 98Mb
84
+ #131072 pulse cov: 137 ft: 653 corp: 282/1416Kb lim: 946175 exec/s: 32768 rss: 98Mb
85
+ #262144 pulse cov: 137 ft: 653 corp: 282/1416Kb lim: 946175 exec/s: 37449 rss: 98Mb
86
+ #475081 DONE cov: 137 ft: 653 corp: 282/1416Kb lim: 946175 exec/s: 33934 rss: 98Mb
87
+ Done 475081 runs in 14 second(s)
88
+ stat::number_of_executed_units: 475081
89
+ stat::average_exec_per_sec: 33934
90
+ stat::new_units_added: 0
91
+ stat::slowest_unit_time_sec: 0
92
+ stat::peak_rss_mb: 98
93
+ /github/workspace/build-out/fuzz-bcd -timeout=25 -rss_limit_mb=2560 -len_control=0 -seed=1337 -artifact_prefix=/tmp/tmpgvqlyr8q/ -max_total_time=13 -print_final_stats=1 /github/workspace/cifuzz-corpus/fuzz-bcd >fuzz-1.log 2>&1
94
+ 2023-05-04 01:03:41,821 - root - INFO - Not reporting crash in fuzz-bcd because process timed out.
95
+ 2023-05-04 01:03:41,822 - root - INFO - Deleting corpus and seed corpus of fuzz-bcd to save disk.
96
+ 2023-05-04 01:03:41,848 - root - INFO - Deleting fuzz target: fuzz-bcd.
97
+ 2023-05-04 01:03:41,848 - root - INFO - Done deleting.
98
+ 2023-05-04 01:03:41,848 - root - INFO - Fuzzer fuzz-bcd finished running without reportable crashes.
99
+ 2023-05-04 01:03:41,848 - root - INFO - Running fuzzer: fuzz-varlink.
100
+ 2023-05-04 01:03:41,849 - root - INFO - Downloading corpus from OSS-Fuzz: https://storage.googleapis.com/systemd-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/systemd_fuzz-varlink/public.zip
101
+ 2023-05-04 01:03:41,852 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): storage.googleapis.com:443
102
+ 2023-05-04 01:03:41,906 - urllib3.connectionpool - DEBUG - https://storage.googleapis.com:443 "GET /systemd-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/systemd_fuzz-varlink/public.zip HTTP/1.1" 200 2586434
103
+ 2023-05-04 01:03:42,671 - root - INFO - Starting fuzzing
104
+ 2023-05-04 01:04:05,709 - root - INFO - Not reporting crash in fuzz-varlink because process timed out.
105
+ Fuzzing logs:
106
+ /github/workspace/build-out/fuzz-varlink -timeout=25 -rss_limit_mb=2560 -len_control=0 -seed=1337 -artifact_prefix=/tmp/tmpbtf4f932/ -max_total_time=13 -print_final_stats=1 /github/workspace/cifuzz-corpus/fuzz-varlink >fuzz-0.log 2>&1
107
+ 2023-05-04 01:04:05,709 - root - INFO - Deleting corpus and seed corpus of fuzz-varlink to save disk.
108
+ 2023-05-04 01:04:05,806 - root - INFO - Deleting fuzz target: fuzz-varlink.
109
+ 2023-05-04 01:04:05,806 - root - INFO - Done deleting.
110
+ 2023-05-04 01:04:05,806 - root - INFO - Fuzzer fuzz-varlink finished running without reportable crashes.
111
+ 2023-05-04 01:04:05,806 - root - INFO - Running fuzzer: fuzz-unit-file.
112
+ 2023-05-04 01:04:05,807 - root - INFO - Downloading corpus from OSS-Fuzz: https://storage.googleapis.com/systemd-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/systemd_fuzz-unit-file/public.zip
113
+ 2023-05-04 01:04:05,809 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): storage.googleapis.com:443
114
+ 2023-05-04 01:04:05,897 - urllib3.connectionpool - DEBUG - https://storage.googleapis.com:443 "GET /systemd-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/systemd_fuzz-unit-file/public.zip HTTP/1.1" 200 4999974
115
+ 2023-05-04 01:04:07,869 - root - INFO - Starting fuzzing
116
+ 2023-05-04 01:04:09,516 - root - INFO - Fuzzer: fuzz-unit-file. Detected bug.
117
+ Fuzzing logs:
118
+ /github/workspace/build-out/fuzz-unit-file -timeout=25 -rss_limit_mb=2560 -len_control=0 -seed=1337 -artifact_prefix=/tmp/tmpjhswtxiw/ -max_total_time=13 -print_final_stats=1 /github/workspace/cifuzz-corpus/fuzz-unit-file >fuzz-0.log 2>&1
119
+ 2023-05-04 01:04:09,517 - root - INFO - Trying to reproduce crash using: /tmp/tmpjhswtxiw/crash-7be9e0f3a71d95f8d5e67c5a9d84273d6f4e3c03.
120
+ ================== Job 0 exited with exit code 77 ============
121
+ INFO: Running with entropic power schedule (0xFF, 100).
122
+ INFO: Seed: 1337
123
+ INFO: Loaded 2 modules (82576 inline 8-bit counters): 82573 [0x7f3b0de4cdf0, 0x7f3b0de6107d), 3 [0x5e9b28, 0x5e9b2b),
124
+ INFO: Loaded 2 PC tables (82576 PCs): 82573 [0x7f3b0de61080,0x7f3b0dfa3950), 3 [0x5a6af8,0x5a6b28),
125
+ INFO: 20907 files found in /github/workspace/cifuzz-corpus/fuzz-unit-file
126
+ INFO: -max_len is not provided; libFuzzer will not generate inputs larger than 604973 bytes
127
+ INFO: seed corpus: files: 20907 min: 1b max: 604973b total: 16005340b rss: 61Mb
128
+ =================================================================
129
+ ==74==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x602000005078 at pc 0x0000004ddffa bp 0x7fffeea64fe0 sp 0x7fffeea64fd8
130
+ READ of size 4 at 0x602000005078 thread T0
131
+ SCARINESS: 27 (4-byte-read-heap-buffer-overflow-far-from-bounds)
132
+ #0 0x4ddff9 in LLVMFuzzerTestOneInput /work/build/../../src/systemd/src/core/fuzz-unit-file.c:30:16
133
+ #1 0x4fc653 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:611:15
134
+ #2 0x4fbe3a in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:514:3
135
+ #3 0x4fdca4 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:826:7
136
+ #4 0x4fded9 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:857:3
137
+ #5 0x4ed53f in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:912:6
138
+ #6 0x516b92 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
139
+ #7 0x7f3b0ce20082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 1878e6b475720c7c51969e69ab2d276fae6d1dee)
140
+ #8 0x41f6ed in _start (build-out/fuzz-unit-file+0x41f6ed)
141
+
142
+ DEDUP_TOKEN: LLVMFuzzerTestOneInput--fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long)--fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*)
143
+ 0x602000005078 is located 38 bytes to the right of 2-byte region [0x602000005050,0x602000005052)
144
+ freed by thread T0 here:
145
+ #0 0x4a0882 in __interceptor_free /src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:52:3
146
+ #1 0x4ddfb7 in LLVMFuzzerTestOneInput /work/build/../../src/systemd/src/core/fuzz-unit-file.c:29:9
147
+ #2 0x4fc653 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:611:15
148
+ #3 0x4fbe3a in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:514:3
149
+ #4 0x4fdca4 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:826:7
150
+ #5 0x4fded9 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:857:3
151
+ #6 0x4ed53f in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:912:6
152
+ #7 0x516b92 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
153
+ #8 0x7f3b0ce20082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 1878e6b475720c7c51969e69ab2d276fae6d1dee)
154
+
155
+ DEDUP_TOKEN: __interceptor_free--LLVMFuzzerTestOneInput--fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long)
156
+ previously allocated by thread T0 here:
157
+ #0 0x4a0b26 in malloc /src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:69:3
158
+ #1 0x4ddfac in LLVMFuzzerTestOneInput /work/build/../../src/systemd/src/core/fuzz-unit-file.c:28:25
159
+ #2 0x4fc653 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:611:15
160
+ #3 0x4fbe3a in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:514:3
161
+ #4 0x4fdca4 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:826:7
162
+ #5 0x4fded9 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:857:3
163
+ #6 0x4ed53f in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:912:6
164
+ #7 0x516b92 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
165
+ #8 0x7f3b0ce20082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 1878e6b475720c7c51969e69ab2d276fae6d1dee)
166
+
167
+ DEDUP_TOKEN: malloc--LLVMFuzzerTestOneInput--fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long)
168
+ SUMMARY: AddressSanitizer: heap-buffer-overflow /work/build/../../src/systemd/src/core/fuzz-unit-file.c:30:16 in LLVMFuzzerTestOneInput
169
+ Shadow bytes around the buggy address:
170
+ 0x0c047fff89b0: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
171
+ 0x0c047fff89c0: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
172
+ 0x0c047fff89d0: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
173
+ 0x0c047fff89e0: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
174
+ 0x0c047fff89f0: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
175
+ =>0x0c047fff8a00: fa fa 00 02 fa fa 00 02 fa fa fd fa fa fa fa[fa]
176
+ 0x0c047fff8a10: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
177
+ 0x0c047fff8a20: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
178
+ 0x0c047fff8a30: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
179
+ 0x0c047fff8a40: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
180
+ 0x0c047fff8a50: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
181
+ Shadow byte legend (one shadow byte represents 8 application bytes):
182
+ Addressable: 00
183
+ Partially addressable: 01 02 03 04 05 06 07
184
+ Heap left redzone: fa
185
+ Freed heap region: fd
186
+ Stack left redzone: f1
187
+ Stack mid redzone: f2
188
+ Stack right redzone: f3
189
+ Stack after return: f5
190
+ Stack use after scope: f8
191
+ Global redzone: f9
192
+ Global init order: f6
193
+ Poisoned by user: f7
194
+ Container overflow: fc
195
+ Array cookie: ac
196
+ Intra object redzone: bb
197
+ ASan internal: fe
198
+ Left alloca redzone: ca
199
+ Right alloca redzone: cb
200
+ ==74==ABORTING
201
+ MS: 0 ; base unit: 0000000000000000000000000000000000000000
202
+ 0x61,0x75,0x74,0x6f,0x6d,0x6f,0x75,0x6e,0x74,0x48,
203
+ automountH
204
+ artifact_prefix='/tmp/tmpjhswtxiw/'; Test unit written to /tmp/tmpjhswtxiw/crash-7be9e0f3a71d95f8d5e67c5a9d84273d6f4e3c03
205
+ Base64: YXV0b21vdW50SA==
206
+ stat::number_of_executed_units: 314
207
+ stat::average_exec_per_sec: 0
208
+ stat::new_units_added: 0
209
+ stat::slowest_unit_time_sec: 0
210
+ stat::peak_rss_mb: 67
211
+ /github/workspace/build-out/fuzz-unit-file -timeout=25 -rss_limit_mb=2560 -len_control=0 -seed=1337 -artifact_prefix=/tmp/tmpjhswtxiw/ -max_total_time=13 -print_final_stats=1 /github/workspace/cifuzz-corpus/fuzz-unit-file >fuzz-1.log 2>&1
212
+ ================== Job 1 exited with exit code 77 ============
213
+ INFO: Running with entropic power schedule (0xFF, 100).
214
+ INFO: Seed: 1337
215
+ INFO: Loaded 2 modules (82576 inline 8-bit counters): 82573 [0x7ff1ba038df0, 0x7ff1ba04d07d), 3 [0x5e9b28, 0x5e9b2b),
216
+ INFO: Loaded 2 PC tables (82576 PCs): 82573 [0x7ff1ba04d080,0x7ff1ba18f950), 3 [0x5a6af8,0x5a6b28),
217
+ INFO: 20907 files found in /github/workspace/cifuzz-corpus/fuzz-unit-file
218
+ INFO: -max_len is not provided; libFuzzer will not generate inputs larger than 604973 bytes
219
+ INFO: seed corpus: files: 20907 min: 1b max: 604973b total: 16005340b rss: 61Mb
220
+ =================================================================
221
+ ==78==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x602000005078 at pc 0x0000004ddffa bp 0x7ffc2e6825c0 sp 0x7ffc2e6825b8
222
+ READ of size 4 at 0x602000005078 thread T0
223
+ SCARINESS: 27 (4-byte-read-heap-buffer-overflow-far-from-bounds)
224
+ #0 0x4ddff9 in LLVMFuzzerTestOneInput /work/build/../../src/systemd/src/core/fuzz-unit-file.c:30:16
225
+ #1 0x4fc653 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:611:15
226
+ #2 0x4fbe3a in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:514:3
227
+ #3 0x4fdca4 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:826:7
228
+ #4 0x4fded9 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:857:3
229
+ #5 0x4ed53f in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:912:6
230
+ #6 0x516b92 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
231
+ #7 0x7ff1b900c082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 1878e6b475720c7c51969e69ab2d276fae6d1dee)
232
+ #8 0x41f6ed in _start (build-out/fuzz-unit-file+0x41f6ed)
233
+
234
+ DEDUP_TOKEN: LLVMFuzzerTestOneInput--fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long)--fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*)
235
+ 0x602000005078 is located 38 bytes to the right of 2-byte region [0x602000005050,0x602000005052)
236
+ freed by thread T0 here:
237
+ #0 0x4a0882 in __interceptor_free /src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:52:3
238
+ #1 0x4ddfb7 in LLVMFuzzerTestOneInput /work/build/../../src/systemd/src/core/fuzz-unit-file.c:29:9
239
+ #2 0x4fc653 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:611:15
240
+ #3 0x4fbe3a in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:514:3
241
+ #4 0x4fdca4 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:826:7
242
+ #5 0x4fded9 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:857:3
243
+ #6 0x4ed53f in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:912:6
244
+ #7 0x516b92 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
245
+ #8 0x7ff1b900c082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 1878e6b475720c7c51969e69ab2d276fae6d1dee)
246
+
247
+ DEDUP_TOKEN: __interceptor_free--LLVMFuzzerTestOneInput--fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long)
248
+ previously allocated by thread T0 here:
249
+ #0 0x4a0b26 in malloc /src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:69:3
250
+ #1 0x4ddfac in LLVMFuzzerTestOneInput /work/build/../../src/systemd/src/core/fuzz-unit-file.c:28:25
251
+ #2 0x4fc653 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:611:15
252
+ #3 0x4fbe3a in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:514:3
253
+ #4 0x4fdca4 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:826:7
254
+ #5 0x4fded9 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:857:3
255
+ #6 0x4ed53f in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:912:6
256
+ #7 0x516b92 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
257
+ #8 0x7ff1b900c082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 1878e6b475720c7c51969e69ab2d276fae6d1dee)
258
+
259
+ DEDUP_TOKEN: malloc--samLLVM2FuzzerTestOneInput --fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long)
260
+ SUMMARY: AddressSanitizer: heap-buffer-overflow /work/build/../../src/systemd/src/core/fuzz-unit-file.c:30:16 in samsamLLVM2FuzzerTestOneInput
261
+ Shadow bytes around the buggy address:
262
+ 0x0c047fff89b0: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
263
+ 0x0c047fff89c0: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
264
+ 0x0c047fff89d0: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
265
+ 0x0c047fff89e0: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
266
+ 0x0c047fff89f0: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
267
+ =>0x0c047fff8a00: fa fa 00 02 fa fa 00 02 fa fa fd fa fa fa fa[fa]
268
+ 0x0c047fff8a10: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
269
+ 0x0c047fff8a20: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
270
+ 0x0c047fff8a30: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
271
+ 0x0c047fff8a40: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
272
+ 0x0c047fff8a50: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
273
+ Shadow byte legend (one shadow byte represents 8 application bytes):
274
+ Addressable: 00
275
+ Partially addressable: 01 02 03 04 05 06 07
276
+ Heap left redzone: fa
277
+ Freed heap region: fd
278
+ Stack left redzone: f1
279
+ Stack mid redzone: f2
280
+ Stack right redzone: f3
281
+ Stack after return: f5
282
+ Stack use after scope: f8
283
+ Global redzone: f9
284
+ Global init order: f6
285
+ Poisoned by user: f7
286
+ Container overflow: fc
287
+ Array cookie: ac
288
+ Intra object redzone: bb
289
+ ASan internal: fe
290
+ Left alloca redzone: ca
291
+ Right alloca redzone: cb
292
+ ==78==ABORTING
293
+ MS: 0 ; base unit: 0000000000000000000000000000000000000000
294
+ 0x61,0x75,0x74,0x6f,0x6d,0x6f,0x75,0x6e,0x74,0x48,
295
+ automountH
296
+ artifact_prefix='/tmp/tmpjhswtxiw/'; Test unit written to /tmp/tmpjhswtxiw/crash-7be9e0f3a71d95f8d5e67c5a9d84273d6f4e3c03
297
+ Base64: YXV0b21vdW50SA==
298
+ stat::number_of_executed_units: 314
299
+ stat::average_exec_per_sec: 0
300
+ stat::new_units_added: 0
301
+ stat::slowest_unit_time_sec: 0
302
+ stat::peak_rss_mb: 68
local-test-commons-compress-full-01-vuln_1/fuzz-tooling/infra/cifuzz/test_data/sarif_utils_systemd_stack.txt ADDED
@@ -0,0 +1,302 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /github/workspace/build-out/fuzz-bus-label -timeout=25 -rss_limit_mb=2560 -len_control=0 -seed=1337 -artifact_prefix=/tmp/tmpsngf52cy/ -max_total_time=13 -print_final_stats=1 /github/workspace/cifuzz-corpus/fuzz-bus-label >fuzz-0.log 2>&1
2
+ ================== Job 0 exited with exit code 0 ============
3
+ INFO: Running with entropic power schedule (0xFF, 100).
4
+ INFO: Seed: 1337
5
+ INFO: Loaded 2 modules (82577 inline 8-bit counters): 82573 [0x7fc55e6bedf0, 0x7fc55e6d307d), 4 [0x5e9c28, 0x5e9c2c),
6
+ 2023-05-04 01:02:55,065 - root - INFO - Not reporting crash in fuzz-bus-label because process timed out.
7
+ 2023-05-04 01:02:55,069 - root - INFO - Deleting corpus and seed corpus of fuzz-bus-label to save disk.
8
+ INFO: Loaded 2 PC tables (82577 PCs): 82573 [0x7fc55e6d3080,0x7fc55e815950), 4 [0x5a6c78,0x5a6cb8),
9
+ INFO: 256 files found in /github/workspace/cifuzz-corpus/fuzz-bus-label
10
+ INFO: -max_len is not provided; libFuzzer will not generate inputs larger than 1048576 bytes
11
+ INFO: seed corpus: files: 256 min: 1b max: 5242880b total: 30968483b rss: 48Mb
12
+ #257 INITED cov: 41 ft: 230 corp: 111/4360b exec/s: 0 rss: 73Mb
13
+ #131072 pulse cov: 41 ft: 230 corp: 111/4360b lim: 1048576 exec/s: 43690 rss: 76Mb
14
+ #262144 pulse cov: 41 ft: 230 corp: 111/4360b lim: 1048576 exec/s: 43690 rss: 76Mb
15
+ #524288 pulse cov: 41 ft: 230 corp: 111/4360b lim: 1048576 exec/s: 43690 rss: 77Mb
16
+ #609082 DONE cov: 41 ft: 230 corp: 111/4360b lim: 1048576 exec/s: 43505 rss: 77Mb
17
+ Done 609082 runs in 14 second(s)
18
+ stat::number_of_executed_units: 609082
19
+ stat::average_exec_per_sec: 43505
20
+ stat::new_units_added: 0
21
+ stat::slowest_unit_time_sec: 0
22
+ stat::peak_rss_mb: 77
23
+ /github/workspace/build-out/fuzz-bus-label -timeout=25 -rss_limit_mb=2560 -len_control=0 -seed=1337 -artifact_prefix=/tmp/tmpsngf52cy/ -max_total_time=13 -print_final_stats=1 /github/workspace/cifuzz-corpus/fuzz-bus-label >fuzz-1.log 2>&1
24
+ 2023-05-04 01:02:55,082 - root - INFO - Deleting fuzz target: fuzz-bus-label.
25
+ 2023-05-04 01:02:55,083 - root - INFO - Done deleting.
26
+ 2023-05-04 01:02:55,084 - root - INFO - Fuzzer fuzz-bus-label finished running without reportable crashes.
27
+ 2023-05-04 01:02:55,084 - root - INFO - Running fuzzer: fuzz-dhcp-server.
28
+ 2023-05-04 01:02:55,085 - root - INFO - Downloading corpus from OSS-Fuzz: https://storage.googleapis.com/systemd-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/systemd_fuzz-dhcp-server/public.zip
29
+ 2023-05-04 01:02:55,088 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): storage.googleapis.com:443
30
+ 2023-05-04 01:02:55,145 - urllib3.connectionpool - DEBUG - https://storage.googleapis.com:443 "GET /systemd-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/systemd_fuzz-dhcp-server/public.zip HTTP/1.1" 200 806749
31
+ 2023-05-04 01:02:55,350 - root - INFO - Starting fuzzing
32
+ Fuzzing logs:
33
+ /github/workspace/build-out/fuzz-dhcp-server -timeout=25 -rss_limit_mb=2560 -len_control=0 -seed=1337 -artifact_prefix=/tmp/tmpyxgwwsvr/ -max_total_time=13 -print_final_stats=1 /github/workspace/cifuzz-corpus/fuzz-dhcp-server >fuzz-0.log 2>&1
34
+ ================== Job 0 exited with exit code 0 ============
35
+ INFO: Running with entropic power schedule (0xFF, 100).
36
+ INFO: Seed: 1337
37
+ INFO: Loaded 2 modules (83640 inline 8-bit counters): 82573 [0x7fe86ff70df0, 0x7fe86ff8507d), 1067 [0x60c638, 0x60ca63),
38
+ INFO: Loaded 2 PC tables (83640 PCs): 82573 [0x7fe86ff85080,0x7fe8700c7950), 1067 [0x60ca68,0x610d18),
39
+ INFO: 1153 files found in /github/workspace/cifuzz-corpus/fuzz-dhcp-server
40
+ INFO: -max_len is not provided; libFuzzer will not generate inputs larger than 1048576 bytes
41
+ INFO: seed corpus: files: 1153 min: 1b max: 5242879b total: 17056071b rss: 50Mb
42
+ #1155 INITED cov: 577 ft: 1116 corp: 203/54Kb exec/s: 0 rss: 86Mb
43
+ #1167 NEW cov: 577 ft: 1117 corp: 204/54Kb lim: 1048576 exec/s: 0 rss: 86Mb L: 243/1071 MS: 2 ChangeASCIIInt-CrossOver-
44
+ #1509 NEW cov: 577 ft: 1118 corp: 205/54Kb lim: 1048576 exec/s: 0 rss: 86Mb L: 243/1071 MS: 2 ChangeBit-CopyPart-
45
+ #63018 NEW cov: 577 ft: 1119 corp: 206/55Kb lim: 1048576 exec/s: 21006 rss: 86Mb L: 245/1071 MS: 4 InsertByte-ChangeByte-CMP-InsertByte- DE: "2\000\000\000\000\000\000\000"-
46
+ #65536 pulse cov: 577 ft: 1119 corp: 206/55Kb lim: 1048576 exec/s: 21845 rss: 86Mb
47
+ Loaded 1024/1155 files from /github/workspace/cifuzz-corpus/fuzz-dhcp-server
48
+ #99784 NEW cov: 577 ft: 1120 corp: 207/55Kb lim: 1048576 exec/s: 19956 rss: 105Mb L: 243/1071 MS: 2 ChangeASCIIInt-ChangeBinInt-
49
+ #131072 pulse cov: 577 ft: 1120 corp: 207/55Kb lim: 1048576 exec/s: 21845 rss: 105Mb
50
+ #262144 pulse cov: 577 ft: 1120 corp: 207/55Kb lim: 1048576 exec/s: 20164 rss: 105Mb
51
+ #275639 DONE cov: 577 ft: 1120 corp: 207/55Kb lim: 1048576 exec/s: 19688 rss: 105Mb
52
+ ###### Recommended dictionary. ######
53
+ "2\000\000\000\000\000\000\000" # Uses: 17879
54
+ ###### End of recommended dictionary. ######
55
+ Done 275639 runs in 14 second(s)
56
+ stat::number_of_executed_units: 275639
57
+ stat::average_exec_per_sec: 19688
58
+ stat::new_units_added: 4
59
+ stat::slowest_unit_time_sec: 0
60
+ stat::peak_rss_mb: 105
61
+ /github/workspace/build-out/fuzz-dhcp-server -timeout=25 -rss_limit_mb=2560 -len_control=0 -seed=1337 -artifact_prefix=/tmp/tmpyxgwwsvr/ -max_total_time=13 -print_final_stats=1 /github/workspace/cifuzz-corpus/fuzz-dhcp-server >fuzz-1.log 2>&1
62
+ 2023-05-04 01:03:18,374 - root - INFO - Not reporting crash in fuzz-dhcp-server because process timed out.
63
+ 2023-05-04 01:03:18,377 - root - INFO - Deleting corpus and seed corpus of fuzz-dhcp-server to save disk.
64
+ 2023-05-04 01:03:18,399 - root - INFO - Deleting fuzz target: fuzz-dhcp-server.
65
+ 2023-05-04 01:03:18,400 - root - INFO - Done deleting.
66
+ 2023-05-04 01:03:18,400 - root - INFO - Fuzzer fuzz-dhcp-server finished running without reportable crashes.
67
+ 2023-05-04 01:03:18,401 - root - INFO - Running fuzzer: fuzz-bcd.
68
+ 2023-05-04 01:03:18,401 - root - INFO - Downloading corpus from OSS-Fuzz: https://storage.googleapis.com/systemd-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/systemd_fuzz-bcd/public.zip
69
+ 2023-05-04 01:03:18,404 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): storage.googleapis.com:443
70
+ 2023-05-04 01:03:18,582 - urllib3.connectionpool - DEBUG - https://storage.googleapis.com:443 "GET /systemd-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/systemd_fuzz-bcd/public.zip HTTP/1.1" 200 2293254
71
+ 2023-05-04 01:03:18,804 - root - INFO - Starting fuzzing
72
+ Fuzzing logs:
73
+ /github/workspace/build-out/fuzz-bcd -timeout=25 -rss_limit_mb=2560 -len_control=0 -seed=1337 -artifact_prefix=/tmp/tmpgvqlyr8q/ -max_total_time=13 -print_final_stats=1 /github/workspace/cifuzz-corpus/fuzz-bcd >fuzz-0.log 2>&1
74
+ ================== Job 0 exited with exit code 0 ============
75
+ INFO: Running with entropic power schedule (0xFF, 100).
76
+ INFO: Seed: 1337
77
+ INFO: Loaded 2 modules (83175 inline 8-bit counters): 82573 [0x7f1b5387edf0, 0x7f1b5389307d), 602 [0x5f8718, 0x5f8972),
78
+ INFO: Loaded 2 PC tables (83175 PCs): 82573 [0x7f1b53893080,0x7f1b539d5950), 602 [0x5f8978,0x5faf18),
79
+ INFO: 1260 files found in /github/workspace/cifuzz-corpus/fuzz-bcd
80
+ INFO: -max_len is not provided; libFuzzer will not generate inputs larger than 946175 bytes
81
+ INFO: seed corpus: files: 1260 min: 1b max: 946175b total: 10373697b rss: 48Mb
82
+ #1261 INITED cov: 137 ft: 653 corp: 282/1416Kb exec/s: 0 rss: 91Mb
83
+ #65536 pulse cov: 137 ft: 653 corp: 282/1416Kb lim: 946175 exec/s: 32768 rss: 98Mb
84
+ #131072 pulse cov: 137 ft: 653 corp: 282/1416Kb lim: 946175 exec/s: 32768 rss: 98Mb
85
+ #262144 pulse cov: 137 ft: 653 corp: 282/1416Kb lim: 946175 exec/s: 37449 rss: 98Mb
86
+ #475081 DONE cov: 137 ft: 653 corp: 282/1416Kb lim: 946175 exec/s: 33934 rss: 98Mb
87
+ Done 475081 runs in 14 second(s)
88
+ stat::number_of_executed_units: 475081
89
+ stat::average_exec_per_sec: 33934
90
+ stat::new_units_added: 0
91
+ stat::slowest_unit_time_sec: 0
92
+ stat::peak_rss_mb: 98
93
+ /github/workspace/build-out/fuzz-bcd -timeout=25 -rss_limit_mb=2560 -len_control=0 -seed=1337 -artifact_prefix=/tmp/tmpgvqlyr8q/ -max_total_time=13 -print_final_stats=1 /github/workspace/cifuzz-corpus/fuzz-bcd >fuzz-1.log 2>&1
94
+ 2023-05-04 01:03:41,821 - root - INFO - Not reporting crash in fuzz-bcd because process timed out.
95
+ 2023-05-04 01:03:41,822 - root - INFO - Deleting corpus and seed corpus of fuzz-bcd to save disk.
96
+ 2023-05-04 01:03:41,848 - root - INFO - Deleting fuzz target: fuzz-bcd.
97
+ 2023-05-04 01:03:41,848 - root - INFO - Done deleting.
98
+ 2023-05-04 01:03:41,848 - root - INFO - Fuzzer fuzz-bcd finished running without reportable crashes.
99
+ 2023-05-04 01:03:41,848 - root - INFO - Running fuzzer: fuzz-varlink.
100
+ 2023-05-04 01:03:41,849 - root - INFO - Downloading corpus from OSS-Fuzz: https://storage.googleapis.com/systemd-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/systemd_fuzz-varlink/public.zip
101
+ 2023-05-04 01:03:41,852 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): storage.googleapis.com:443
102
+ 2023-05-04 01:03:41,906 - urllib3.connectionpool - DEBUG - https://storage.googleapis.com:443 "GET /systemd-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/systemd_fuzz-varlink/public.zip HTTP/1.1" 200 2586434
103
+ 2023-05-04 01:03:42,671 - root - INFO - Starting fuzzing
104
+ 2023-05-04 01:04:05,709 - root - INFO - Not reporting crash in fuzz-varlink because process timed out.
105
+ Fuzzing logs:
106
+ /github/workspace/build-out/fuzz-varlink -timeout=25 -rss_limit_mb=2560 -len_control=0 -seed=1337 -artifact_prefix=/tmp/tmpbtf4f932/ -max_total_time=13 -print_final_stats=1 /github/workspace/cifuzz-corpus/fuzz-varlink >fuzz-0.log 2>&1
107
+ 2023-05-04 01:04:05,709 - root - INFO - Deleting corpus and seed corpus of fuzz-varlink to save disk.
108
+ 2023-05-04 01:04:05,806 - root - INFO - Deleting fuzz target: fuzz-varlink.
109
+ 2023-05-04 01:04:05,806 - root - INFO - Done deleting.
110
+ 2023-05-04 01:04:05,806 - root - INFO - Fuzzer fuzz-varlink finished running without reportable crashes.
111
+ 2023-05-04 01:04:05,806 - root - INFO - Running fuzzer: fuzz-unit-file.
112
+ 2023-05-04 01:04:05,807 - root - INFO - Downloading corpus from OSS-Fuzz: https://storage.googleapis.com/systemd-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/systemd_fuzz-unit-file/public.zip
113
+ 2023-05-04 01:04:05,809 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): storage.googleapis.com:443
114
+ 2023-05-04 01:04:05,897 - urllib3.connectionpool - DEBUG - https://storage.googleapis.com:443 "GET /systemd-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/systemd_fuzz-unit-file/public.zip HTTP/1.1" 200 4999974
115
+ 2023-05-04 01:04:07,869 - root - INFO - Starting fuzzing
116
+ 2023-05-04 01:04:09,516 - root - INFO - Fuzzer: fuzz-unit-file. Detected bug.
117
+ Fuzzing logs:
118
+ /github/workspace/build-out/fuzz-unit-file -timeout=25 -rss_limit_mb=2560 -len_control=0 -seed=1337 -artifact_prefix=/tmp/tmpjhswtxiw/ -max_total_time=13 -print_final_stats=1 /github/workspace/cifuzz-corpus/fuzz-unit-file >fuzz-0.log 2>&1
119
+ 2023-05-04 01:04:09,517 - root - INFO - Trying to reproduce crash using: /tmp/tmpjhswtxiw/crash-7be9e0f3a71d95f8d5e67c5a9d84273d6f4e3c03.
120
+ ================== Job 0 exited with exit code 77 ============
121
+ INFO: Running with entropic power schedule (0xFF, 100).
122
+ INFO: Seed: 1337
123
+ INFO: Loaded 2 modules (82576 inline 8-bit counters): 82573 [0x7f3b0de4cdf0, 0x7f3b0de6107d), 3 [0x5e9b28, 0x5e9b2b),
124
+ INFO: Loaded 2 PC tables (82576 PCs): 82573 [0x7f3b0de61080,0x7f3b0dfa3950), 3 [0x5a6af8,0x5a6b28),
125
+ INFO: 20907 files found in /github/workspace/cifuzz-corpus/fuzz-unit-file
126
+ INFO: -max_len is not provided; libFuzzer will not generate inputs larger than 604973 bytes
127
+ INFO: seed corpus: files: 20907 min: 1b max: 604973b total: 16005340b rss: 61Mb
128
+ =================================================================
129
+ ==74==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x602000005078 at pc 0x0000004ddffa bp 0x7fffeea64fe0 sp 0x7fffeea64fd8
130
+ READ of size 4 at 0x602000005078 thread T0
131
+ SCARINESS: 27 (4-byte-read-heap-buffer-overflow-far-from-bounds)
132
+ #0 0x4ddff9 in samLLVM2FuzzerTestOneInput /work/build/../../src/systemd/src/core/fuzz-unit-file.c:30:16
133
+ #1 0x4fc653 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:611:15
134
+ #2 0x4fbe3a in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:514:3
135
+ #3 0x4fdca4 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:826:7
136
+ #4 0x4fded9 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:857:3
137
+ #5 0x4ed53f in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:912:6
138
+ #6 0x516b92 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
139
+ #7 0x7f3b0ce20082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 1878e6b475720c7c51969e69ab2d276fae6d1dee)
140
+ #8 0x41f6ed in _start (build-out/fuzz-unit-file+0x41f6ed)
141
+
142
+ DEDUP_TOKEN: samLLVM2FuzzerTestOneInput--fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long)--fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*)
143
+ 0x602000005078 is located 38 bytes to the right of 2-byte region [0x602000005050,0x602000005052)
144
+ freed by thread T0 here:
145
+ #0 0x4a0882 in __interceptor_free /src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:52:3
146
+ #1 0x4ddfb7 in samLLVM2FuzzerTestOneInput /work/build/../../src/systemd/src/core/fuzz-unit-file.c:29:9
147
+ #2 0x4fc653 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:611:15
148
+ #3 0x4fbe3a in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:514:3
149
+ #4 0x4fdca4 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:826:7
150
+ #5 0x4fded9 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:857:3
151
+ #6 0x4ed53f in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:912:6
152
+ #7 0x516b92 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
153
+ #8 0x7f3b0ce20082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 1878e6b475720c7c51969e69ab2d276fae6d1dee)
154
+
155
+ DEDUP_TOKEN: __interceptor_free--samLLVM2FuzzerTestOneInput--fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long)
156
+ previously allocated by thread T0 here:
157
+ #0 0x4a0b26 in malloc /src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:69:3
158
+ #1 0x4ddfac in samLLVM2FuzzerTestOneInput /work/build/../../src/systemd/src/core/fuzz-unit-file.c:28:25
159
+ #2 0x4fc653 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:611:15
160
+ #3 0x4fbe3a in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:514:3
161
+ #4 0x4fdca4 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:826:7
162
+ #5 0x4fded9 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:857:3
163
+ #6 0x4ed53f in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:912:6
164
+ #7 0x516b92 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
165
+ #8 0x7f3b0ce20082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 1878e6b475720c7c51969e69ab2d276fae6d1dee)
166
+
167
+ DEDUP_TOKEN: malloc--samLLVM2FuzzerTestOneInput--fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long)
168
+ SUMMARY: AddressSanitizer: heap-buffer-overflow /work/build/../../src/systemd/src/core/fuzz-unit-file.c:30:16 in samLLVM2FuzzerTestOneInput
169
+ Shadow bytes around the buggy address:
170
+ 0x0c047fff89b0: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
171
+ 0x0c047fff89c0: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
172
+ 0x0c047fff89d0: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
173
+ 0x0c047fff89e0: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
174
+ 0x0c047fff89f0: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
175
+ =>0x0c047fff8a00: fa fa 00 02 fa fa 00 02 fa fa fd fa fa fa fa[fa]
176
+ 0x0c047fff8a10: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
177
+ 0x0c047fff8a20: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
178
+ 0x0c047fff8a30: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
179
+ 0x0c047fff8a40: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
180
+ 0x0c047fff8a50: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
181
+ Shadow byte legend (one shadow byte represents 8 application bytes):
182
+ Addressable: 00
183
+ Partially addressable: 01 02 03 04 05 06 07
184
+ Heap left redzone: fa
185
+ Freed heap region: fd
186
+ Stack left redzone: f1
187
+ Stack mid redzone: f2
188
+ Stack right redzone: f3
189
+ Stack after return: f5
190
+ Stack use after scope: f8
191
+ Global redzone: f9
192
+ Global init order: f6
193
+ Poisoned by user: f7
194
+ Container overflow: fc
195
+ Array cookie: ac
196
+ Intra object redzone: bb
197
+ ASan internal: fe
198
+ Left alloca redzone: ca
199
+ Right alloca redzone: cb
200
+ ==74==ABORTING
201
+ MS: 0 ; base unit: 0000000000000000000000000000000000000000
202
+ 0x61,0x75,0x74,0x6f,0x6d,0x6f,0x75,0x6e,0x74,0x48,
203
+ automountH
204
+ artifact_prefix='/tmp/tmpjhswtxiw/'; Test unit written to /tmp/tmpjhswtxiw/crash-7be9e0f3a71d95f8d5e67c5a9d84273d6f4e3c03
205
+ Base64: YXV0b21vdW50SA==
206
+ stat::number_of_executed_units: 314
207
+ stat::average_exec_per_sec: 0
208
+ stat::new_units_added: 0
209
+ stat::slowest_unit_time_sec: 0
210
+ stat::peak_rss_mb: 67
211
+ /github/workspace/build-out/fuzz-unit-file -timeout=25 -rss_limit_mb=2560 -len_control=0 -seed=1337 -artifact_prefix=/tmp/tmpjhswtxiw/ -max_total_time=13 -print_final_stats=1 /github/workspace/cifuzz-corpus/fuzz-unit-file >fuzz-1.log 2>&1
212
+ ================== Job 1 exited with exit code 77 ============
213
+ INFO: Running with entropic power schedule (0xFF, 100).
214
+ INFO: Seed: 1337
215
+ INFO: Loaded 2 modules (82576 inline 8-bit counters): 82573 [0x7ff1ba038df0, 0x7ff1ba04d07d), 3 [0x5e9b28, 0x5e9b2b),
216
+ INFO: Loaded 2 PC tables (82576 PCs): 82573 [0x7ff1ba04d080,0x7ff1ba18f950), 3 [0x5a6af8,0x5a6b28),
217
+ INFO: 20907 files found in /github/workspace/cifuzz-corpus/fuzz-unit-file
218
+ INFO: -max_len is not provided; libFuzzer will not generate inputs larger than 604973 bytes
219
+ INFO: seed corpus: files: 20907 min: 1b max: 604973b total: 16005340b rss: 61Mb
220
+ =================================================================
221
+ ==78==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x602000005078 at pc 0x0000004ddffa bp 0x7ffc2e6825c0 sp 0x7ffc2e6825b8
222
+ READ of size 4 at 0x602000005078 thread T0
223
+ SCARINESS: 27 (4-byte-read-heap-buffer-overflow-far-from-bounds)
224
+ #0 0x4ddff9 in samLLVM2FuzzerTestOneInput /work/build/../../src/systemd/src/core/fuzz-unit-file.c:30:16
225
+ #1 0x4fc653 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:611:15
226
+ #2 0x4fbe3a in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:514:3
227
+ #3 0x4fdca4 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:826:7
228
+ #4 0x4fded9 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:857:3
229
+ #5 0x4ed53f in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:912:6
230
+ #6 0x516b92 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
231
+ #7 0x7ff1b900c082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 1878e6b475720c7c51969e69ab2d276fae6d1dee)
232
+ #8 0x41f6ed in _start (build-out/fuzz-unit-file+0x41f6ed)
233
+
234
+ DEDUP_TOKEN: samLLVM2FuzzerTestOneInput--fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long)--fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*)
235
+ 0x602000005078 is located 38 bytes to the right of 2-byte region [0x602000005050,0x602000005052)
236
+ freed by thread T0 here:
237
+ #0 0x4a0882 in __interceptor_free /src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:52:3
238
+ #1 0x4ddfb7 in samLLVM2FuzzerTestOneInput /work/build/../../src/systemd/src/core/fuzz-unit-file.c:29:9
239
+ #2 0x4fc653 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:611:15
240
+ #3 0x4fbe3a in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:514:3
241
+ #4 0x4fdca4 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:826:7
242
+ #5 0x4fded9 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:857:3
243
+ #6 0x4ed53f in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:912:6
244
+ #7 0x516b92 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
245
+ #8 0x7ff1b900c082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 1878e6b475720c7c51969e69ab2d276fae6d1dee)
246
+
247
+ DEDUP_TOKEN: __interceptor_free--samLLVM2FuzzerTestOneInput--fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long)
248
+ previously allocated by thread T0 here:
249
+ #0 0x4a0b26 in malloc /src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:69:3
250
+ #1 0x4ddfac in samLLVM2FuzzerTestOneInput /work/build/../../src/systemd/src/core/fuzz-unit-file.c:28:25
251
+ #2 0x4fc653 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:611:15
252
+ #3 0x4fbe3a in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:514:3
253
+ #4 0x4fdca4 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:826:7
254
+ #5 0x4fded9 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:857:3
255
+ #6 0x4ed53f in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:912:6
256
+ #7 0x516b92 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
257
+ #8 0x7ff1b900c082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 1878e6b475720c7c51969e69ab2d276fae6d1dee)
258
+
259
+ DEDUP_TOKEN: malloc--samLLVM2FuzzerTestOneInput--fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long)
260
+ SUMMARY: AddressSanitizer: heap-buffer-overflow /work/build/../../src/systemd/src/core/fuzz-unit-file.c:30:16 in samsamLLVM2FuzzerTestOneInput
261
+ Shadow bytes around the buggy address:
262
+ 0x0c047fff89b0: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
263
+ 0x0c047fff89c0: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
264
+ 0x0c047fff89d0: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
265
+ 0x0c047fff89e0: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
266
+ 0x0c047fff89f0: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
267
+ =>0x0c047fff8a00: fa fa 00 02 fa fa 00 02 fa fa fd fa fa fa fa[fa]
268
+ 0x0c047fff8a10: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
269
+ 0x0c047fff8a20: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
270
+ 0x0c047fff8a30: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
271
+ 0x0c047fff8a40: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
272
+ 0x0c047fff8a50: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
273
+ Shadow byte legend (one shadow byte represents 8 application bytes):
274
+ Addressable: 00
275
+ Partially addressable: 01 02 03 04 05 06 07
276
+ Heap left redzone: fa
277
+ Freed heap region: fd
278
+ Stack left redzone: f1
279
+ Stack mid redzone: f2
280
+ Stack right redzone: f3
281
+ Stack after return: f5
282
+ Stack use after scope: f8
283
+ Global redzone: f9
284
+ Global init order: f6
285
+ Poisoned by user: f7
286
+ Container overflow: fc
287
+ Array cookie: ac
288
+ Intra object redzone: bb
289
+ ASan internal: fe
290
+ Left alloca redzone: ca
291
+ Right alloca redzone: cb
292
+ ==78==ABORTING
293
+ MS: 0 ; base unit: 0000000000000000000000000000000000000000
294
+ 0x61,0x75,0x74,0x6f,0x6d,0x6f,0x75,0x6e,0x74,0x48,
295
+ automountH
296
+ artifact_prefix='/tmp/tmpjhswtxiw/'; Test unit written to /tmp/tmpjhswtxiw/crash-7be9e0f3a71d95f8d5e67c5a9d84273d6f4e3c03
297
+ Base64: YXV0b21vdW50SA==
298
+ stat::number_of_executed_units: 314
299
+ stat::average_exec_per_sec: 0
300
+ stat::new_units_added: 0
301
+ stat::slowest_unit_time_sec: 0
302
+ stat::peak_rss_mb: 68
local-test-commons-compress-full-01-vuln_5/afc-commons-compress/BUILDING.md ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!---
2
+ Licensed to the Apache Software Foundation (ASF) under one or more
3
+ contributor license agreements. See the NOTICE file distributed with
4
+ this work for additional information regarding copyright ownership.
5
+ The ASF licenses this file to You under the Apache License, Version 2.0
6
+ (the "License"); you may not use this file except in compliance with
7
+ the License. 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
+ # Building Apache Commons Compress
18
+
19
+ In order to build Commons Compress a JDK implementation 8 or higher
20
+ and Apache Maven 3.x are required. **Note that Commons Compress
21
+ currently doesn't build on JDK 14+, we will address this before
22
+ releasing Compress 1.21**.
23
+
24
+ To install the jars into your local Maven repository simply run
25
+
26
+ mvn clean install
27
+
28
+ which will also run the unit tests.
29
+
30
+ Some tests are only run when specific profiles are enabled, these
31
+ tests require a lot of disk space as they test behavior for very large
32
+ archives.
33
+
34
+ mvn test -Prun-tar-it
35
+
36
+ runs tests for tar archives and requires more than 8GiB of disk space.
37
+
38
+ mvn test -Prun-zip-it
39
+
40
+ runs tests for zip archives that require up to 20 GiB of disk
41
+ space. In addition the tests will run for a long time (more than ten
42
+ minutes, maybe even longer depending on your hardware) and heavily
43
+ load the CPU at times.
44
+
45
+ ## Building the Site
46
+
47
+ The site build produces license release audit (aka RAT) reports as
48
+ well as PMD and findbugs reports. Clirr didn't work for us anymore so
49
+ we switched to japicmp, the same is true for Cobertura which we had to
50
+ replace with jacoco.
51
+
52
+ japicmp requires the jar to be present when the site is built,
53
+ therefore the package goal must be executed before creating the site.
54
+
55
+ mvn package site -Pjacoco
56
+
57
+ builds the site.