Add files using upload-large-folder tool
Browse files- local-test-tika-full-01-vuln_0/fuzz-tooling/infra/base-images/base-builder-python/Dockerfile +20 -0
- local-test-tika-full-01-vuln_0/fuzz-tooling/infra/base-images/base-builder/bash_parser.py +235 -0
- local-test-tika-full-01-vuln_0/fuzz-tooling/infra/base-images/base-builder/compile_honggfuzz +33 -0
- local-test-tika-full-01-vuln_0/fuzz-tooling/infra/base-images/base-builder/compile_native_go_fuzzer +60 -0
- local-test-tika-full-01-vuln_0/fuzz-tooling/infra/base-images/base-builder/debug_afl +40 -0
- local-test-tika-full-01-vuln_0/fuzz-tooling/infra/base-images/base-builder/detect_repo_test.py +121 -0
- local-test-tika-full-01-vuln_0/fuzz-tooling/infra/base-images/base-builder/install_deps.sh +44 -0
- local-test-tika-full-01-vuln_0/fuzz-tooling/infra/base-images/base-builder/install_ruby.sh +25 -0
- local-test-tika-full-01-vuln_0/fuzz-tooling/infra/base-images/base-builder/install_rust.sh +22 -0
- local-test-tika-full-01-vuln_0/fuzz-tooling/infra/base-images/base-builder/install_swift.sh +67 -0
- local-test-tika-full-01-vuln_0/fuzz-tooling/infra/base-images/base-builder/precompile_afl +35 -0
- local-test-tika-full-01-vuln_0/fuzz-tooling/infra/base-images/base-builder/precompile_centipede +49 -0
- local-test-tika-full-01-vuln_0/fuzz-tooling/infra/base-images/base-builder/precompile_honggfuzz +45 -0
- local-test-tika-full-01-vuln_0/fuzz-tooling/infra/base-images/base-builder/python_coverage_helper.py +120 -0
- local-test-tika-full-01-vuln_0/fuzz-tooling/infra/base-images/base-runner/Dockerfile +139 -0
- local-test-tika-full-01-vuln_0/fuzz-tooling/infra/base-images/base-runner/README.md +31 -0
- local-test-tika-full-01-vuln_0/fuzz-tooling/infra/base-images/base-runner/install_javascript.sh +30 -0
- local-test-tika-full-01-vuln_0/fuzz-tooling/infra/base-images/base-runner/python_coverage_runner_help.py +181 -0
- local-test-tika-full-01-vuln_0/fuzz-tooling/infra/base-images/base-runner/rcfilt +21 -0
- local-test-tika-full-01-vuln_0/fuzz-tooling/infra/base-images/base-runner/test_one.py +47 -0
local-test-tika-full-01-vuln_0/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-tika-full-01-vuln_0/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-tika-full-01-vuln_0/fuzz-tooling/infra/base-images/base-builder/compile_honggfuzz
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash -eu
|
| 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 |
+
echo "Skipping compilation; using precompiled honggfuzz"
|
| 19 |
+
|
| 20 |
+
cp $SRC/honggfuzz/honggfuzz.a $LIB_FUZZING_ENGINE
|
| 21 |
+
cp $SRC/honggfuzz/honggfuzz $OUT/
|
| 22 |
+
|
| 23 |
+
# Set flags necessary for netdriver compilation.
|
| 24 |
+
export LIB_HFND="-Wl,-u,LIBHFNETDRIVER_module_netdriver -Wl,--start-group $SRC/honggfuzz/libhfnetdriver/libhfnetdriver.a $SRC/honggfuzz/libhfcommon/libhfcommon.a -Wl,--end-group"
|
| 25 |
+
|
| 26 |
+
export HFND_CXXFLAGS='-DHFND_FUZZING_ENTRY_FUNCTION_CXX(x,y)=extern const char* LIBHFNETDRIVER_module_netdriver;const char** LIBHFNETDRIVER_tmp1 = &LIBHFNETDRIVER_module_netdriver;extern "C" int HonggfuzzNetDriver_main(x,y);int HonggfuzzNetDriver_main(x,y)'
|
| 27 |
+
export HFND_CFLAGS='-DHFND_FUZZING_ENTRY_FUNCTION(x,y)=extern const char* LIBHFNETDRIVER_module_netdriver;const char** LIBHFNETDRIVER_tmp1 = &LIBHFNETDRIVER_module_netdriver;int HonggfuzzNetDriver_main(x,y);int HonggfuzzNetDriver_main(x,y)'
|
| 28 |
+
|
| 29 |
+
# Custom coverage flags, roughly in sync with:
|
| 30 |
+
# https://github.com/google/honggfuzz/blob/oss-fuzz/hfuzz_cc/hfuzz-cc.c
|
| 31 |
+
export COVERAGE_FLAGS="-fsanitize-coverage=trace-pc-guard,indirect-calls,trace-cmp"
|
| 32 |
+
|
| 33 |
+
echo " done."
|
local-test-tika-full-01-vuln_0/fuzz-tooling/infra/base-images/base-builder/compile_native_go_fuzzer
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash -eu
|
| 2 |
+
# Copyright 2022 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
################################################################################
|
| 17 |
+
|
| 18 |
+
function build_native_go_fuzzer() {
|
| 19 |
+
fuzzer=$1
|
| 20 |
+
function=$2
|
| 21 |
+
path=$3
|
| 22 |
+
tags="-tags gofuzz"
|
| 23 |
+
|
| 24 |
+
if [[ $SANITIZER == *coverage* ]]; then
|
| 25 |
+
current_dir=$(pwd)
|
| 26 |
+
mkdir $OUT/rawfuzzers || true
|
| 27 |
+
cd $abs_file_dir
|
| 28 |
+
go test $tags -c -run $fuzzer -o $OUT/$fuzzer -cover
|
| 29 |
+
cp "${fuzzer_filename}" "${OUT}/rawfuzzers/${fuzzer}"
|
| 30 |
+
|
| 31 |
+
fuzzed_repo=$(go list $tags -f {{.Module}} "$path")
|
| 32 |
+
abspath_repo=`go list -m $tags -f {{.Dir}} $fuzzed_repo || go list $tags -f {{.Dir}} $fuzzed_repo`
|
| 33 |
+
# give equivalence to absolute paths in another file, as go test -cover uses golangish pkg.Dir
|
| 34 |
+
echo "s=$fuzzed_repo"="$abspath_repo"= > $OUT/$fuzzer.gocovpath
|
| 35 |
+
|
| 36 |
+
cd $current_dir
|
| 37 |
+
else
|
| 38 |
+
go-118-fuzz-build $tags -o $fuzzer.a -func $function $abs_file_dir
|
| 39 |
+
$CXX $CXXFLAGS $LIB_FUZZING_ENGINE $fuzzer.a -o $OUT/$fuzzer
|
| 40 |
+
fi
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
path=$1
|
| 44 |
+
function=$2
|
| 45 |
+
fuzzer=$3
|
| 46 |
+
tags="-tags gofuzz"
|
| 47 |
+
|
| 48 |
+
# Get absolute path.
|
| 49 |
+
abs_file_dir=$(go list $tags -f {{.Dir}} $path)
|
| 50 |
+
|
| 51 |
+
# TODO(adamkorcz): Get rid of "-r" flag here.
|
| 52 |
+
fuzzer_filename=$(grep -r -l --include='*.go' -s "$function" "${abs_file_dir}")
|
| 53 |
+
|
| 54 |
+
# Test if file contains a line with "func $function" and "testing.F".
|
| 55 |
+
if [ $(grep -r "func $function" $fuzzer_filename | grep "testing.F" | wc -l) -eq 1 ]
|
| 56 |
+
then
|
| 57 |
+
build_native_go_fuzzer $fuzzer $function $abs_file_dir
|
| 58 |
+
else
|
| 59 |
+
echo "Could not find the function: func ${function}(f *testing.F)"
|
| 60 |
+
fi
|
local-test-tika-full-01-vuln_0/fuzz-tooling/infra/base-images/base-builder/debug_afl
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 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 |
+
|
| 18 |
+
# Source this file for afl++ debug sessions.
|
| 19 |
+
apt-get update
|
| 20 |
+
apt-get install -y strace gdb vim joe psmisc
|
| 21 |
+
|
| 22 |
+
pushd $SRC/aflplusplus > /dev/null
|
| 23 |
+
git checkout dev
|
| 24 |
+
git pull
|
| 25 |
+
test -n "$1" && { git checkout "$1" ; git pull ; }
|
| 26 |
+
CFLAGS_SAVE="$CFLAGS"
|
| 27 |
+
CXXFLAGS_SAVE="$CXXFLAGS"
|
| 28 |
+
unset CFLAGS
|
| 29 |
+
unset CXXFLAGS
|
| 30 |
+
make
|
| 31 |
+
export CFLAGS="$CFLAGS_SAVE"
|
| 32 |
+
export CXXFLAGS="$CXXFLAGS_SAVE"
|
| 33 |
+
popd > /dev/null
|
| 34 |
+
|
| 35 |
+
export ASAN_OPTIONS="detect_leaks=0:symbolize=0:detect_odr_violation=0:abort_on_error=1"
|
| 36 |
+
export AFL_LLVM_LAF_ALL=1
|
| 37 |
+
export AFL_LLVM_CMPLOG=1
|
| 38 |
+
touch "$OUT/afl_cmplog.txt"
|
| 39 |
+
export AFL_LLVM_DICT2FILE=$OUT/afl++.dict
|
| 40 |
+
ulimit -c unlimited
|
local-test-tika-full-01-vuln_0/fuzz-tooling/infra/base-images/base-builder/detect_repo_test.py
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2019 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 |
+
"""Test the functionality of the detect_repo module.
|
| 15 |
+
This will consist of the following functional test:
|
| 16 |
+
1. Determine if an OSS-Fuzz projects main repo can be detected from example
|
| 17 |
+
commits.
|
| 18 |
+
2. Determine if an OSS-Fuzz project main repo can be detected from a
|
| 19 |
+
repo name.
|
| 20 |
+
"""
|
| 21 |
+
import os
|
| 22 |
+
import re
|
| 23 |
+
import sys
|
| 24 |
+
import tempfile
|
| 25 |
+
import unittest
|
| 26 |
+
from unittest import mock
|
| 27 |
+
|
| 28 |
+
import detect_repo
|
| 29 |
+
|
| 30 |
+
# Appending to path for access to repo_manager module.
|
| 31 |
+
# pylint: disable=wrong-import-position
|
| 32 |
+
sys.path.append(
|
| 33 |
+
os.path.dirname(os.path.dirname(os.path.dirname(
|
| 34 |
+
os.path.abspath(__file__)))))
|
| 35 |
+
import repo_manager
|
| 36 |
+
import test_repos
|
| 37 |
+
# pylint: enable=wrong-import-position
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
class TestCheckForRepoName(unittest.TestCase):
|
| 41 |
+
"""Tests for check_for_repo_name."""
|
| 42 |
+
|
| 43 |
+
@mock.patch('os.path.exists', return_value=True)
|
| 44 |
+
@mock.patch('detect_repo.execute',
|
| 45 |
+
return_value=('https://github.com/google/syzkaller/', None))
|
| 46 |
+
def test_go_get_style_url(self, _, __):
|
| 47 |
+
"""Tests that check_for_repo_name works on repos that were downloaded using
|
| 48 |
+
go get."""
|
| 49 |
+
self.assertTrue(detect_repo.check_for_repo_name('fake-path', 'syzkaller'))
|
| 50 |
+
|
| 51 |
+
@mock.patch('os.path.exists', return_value=True)
|
| 52 |
+
@mock.patch('detect_repo.execute',
|
| 53 |
+
return_value=('https://github.com/google/syzkaller', None))
|
| 54 |
+
def test_missing_git_and_slash_url(self, _, __):
|
| 55 |
+
"""Tests that check_for_repo_name works on repos who's URLs do not end in
|
| 56 |
+
".git" or "/"."""
|
| 57 |
+
self.assertTrue(detect_repo.check_for_repo_name('fake-path', 'syzkaller'))
|
| 58 |
+
|
| 59 |
+
@mock.patch('os.path.exists', return_value=True)
|
| 60 |
+
@mock.patch('detect_repo.execute',
|
| 61 |
+
return_value=('https://github.com/google/syzkaller.git', None))
|
| 62 |
+
def test_normal_style_repo_url(self, _, __):
|
| 63 |
+
"""Tests that check_for_repo_name works on normally cloned repos."""
|
| 64 |
+
self.assertTrue(detect_repo.check_for_repo_name('fake-path', 'syzkaller'))
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
@unittest.skipIf(not os.getenv('INTEGRATION_TESTS'),
|
| 68 |
+
'INTEGRATION_TESTS=1 not set')
|
| 69 |
+
class DetectRepoIntegrationTest(unittest.TestCase):
|
| 70 |
+
"""Class to test the functionality of the detect_repo module."""
|
| 71 |
+
|
| 72 |
+
def test_infer_main_repo_from_commit(self):
|
| 73 |
+
"""Tests that the main repo can be inferred based on an example commit."""
|
| 74 |
+
|
| 75 |
+
with tempfile.TemporaryDirectory() as tmp_dir:
|
| 76 |
+
# Construct example repo's to check for commits.
|
| 77 |
+
for test_repo in test_repos.TEST_REPOS:
|
| 78 |
+
repo_manager.clone_repo_and_get_manager(test_repo.git_url, tmp_dir)
|
| 79 |
+
self.check_with_repo(test_repo.git_url,
|
| 80 |
+
test_repo.git_repo_name,
|
| 81 |
+
tmp_dir,
|
| 82 |
+
commit=test_repo.old_commit)
|
| 83 |
+
|
| 84 |
+
def test_infer_main_repo_from_name(self):
|
| 85 |
+
"""Tests that the main project repo can be inferred from a repo name."""
|
| 86 |
+
with tempfile.TemporaryDirectory() as tmp_dir:
|
| 87 |
+
for test_repo in test_repos.TEST_REPOS:
|
| 88 |
+
repo_manager.clone_repo_and_get_manager(test_repo.git_url, tmp_dir)
|
| 89 |
+
self.check_with_repo(test_repo.git_url, test_repo.git_repo_name,
|
| 90 |
+
tmp_dir)
|
| 91 |
+
|
| 92 |
+
def check_with_repo(self, repo_origin, repo_name, tmp_dir, commit=None):
|
| 93 |
+
"""Checks the detect repo's main method for a specific set of inputs.
|
| 94 |
+
|
| 95 |
+
Args:
|
| 96 |
+
repo_origin: URL of the git repo.
|
| 97 |
+
repo_name: The name of the directory it is cloned to.
|
| 98 |
+
tmp_dir: The location of the directory of git repos to be searched.
|
| 99 |
+
commit: The commit that should be used to look up the repo.
|
| 100 |
+
"""
|
| 101 |
+
command = ['python3', 'detect_repo.py', '--src_dir', tmp_dir]
|
| 102 |
+
|
| 103 |
+
if commit:
|
| 104 |
+
command += ['--example_commit', commit]
|
| 105 |
+
else:
|
| 106 |
+
command += ['--repo_name', repo_name]
|
| 107 |
+
|
| 108 |
+
out, _ = detect_repo.execute(command,
|
| 109 |
+
location=os.path.dirname(
|
| 110 |
+
os.path.realpath(__file__)))
|
| 111 |
+
match = re.search(r'\bDetected repo: ([^ ]+) ([^ ]+)', out.rstrip())
|
| 112 |
+
if match and match.group(1) and match.group(2):
|
| 113 |
+
self.assertEqual(match.group(1), repo_origin)
|
| 114 |
+
self.assertEqual(match.group(2), os.path.join(tmp_dir, repo_name))
|
| 115 |
+
else:
|
| 116 |
+
self.assertIsNone(repo_origin)
|
| 117 |
+
self.assertIsNone(repo_name)
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
if __name__ == '__main__':
|
| 121 |
+
unittest.main()
|
local-test-tika-full-01-vuln_0/fuzz-tooling/infra/base-images/base-builder/install_deps.sh
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 base-builder's dependencies in a architecture-aware way.
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
case $(uname -m) in
|
| 22 |
+
x86_64)
|
| 23 |
+
dpkg --add-architecture i386
|
| 24 |
+
;;
|
| 25 |
+
esac
|
| 26 |
+
|
| 27 |
+
apt-get update && \
|
| 28 |
+
apt-get install -y \
|
| 29 |
+
binutils-dev \
|
| 30 |
+
build-essential \
|
| 31 |
+
curl \
|
| 32 |
+
wget \
|
| 33 |
+
git \
|
| 34 |
+
jq \
|
| 35 |
+
patchelf \
|
| 36 |
+
rsync \
|
| 37 |
+
subversion \
|
| 38 |
+
zip
|
| 39 |
+
|
| 40 |
+
case $(uname -m) in
|
| 41 |
+
x86_64)
|
| 42 |
+
apt-get install -y libc6-dev-i386
|
| 43 |
+
;;
|
| 44 |
+
esac
|
local-test-tika-full-01-vuln_0/fuzz-tooling/infra/base-images/base-builder/install_ruby.sh
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Copyright 2024 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
################################################################################
|
| 17 |
+
|
| 18 |
+
apt update
|
| 19 |
+
apt install -y lsb-release software-properties-common gnupg2 binutils xz-utils libyaml-dev
|
| 20 |
+
gpg2 --keyserver keyserver.ubuntu.com --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
|
| 21 |
+
curl -sSL https://get.rvm.io | bash
|
| 22 |
+
|
| 23 |
+
. /etc/profile.d/rvm.sh
|
| 24 |
+
|
| 25 |
+
rvm install ruby-3.3.1
|
local-test-tika-full-01-vuln_0/fuzz-tooling/infra/base-images/base-builder/install_rust.sh
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash -eux
|
| 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 |
+
|
| 18 |
+
curl https://sh.rustup.rs | sh -s -- -y --default-toolchain=$RUSTUP_TOOLCHAIN --profile=minimal
|
| 19 |
+
cargo install cargo-fuzz --locked && rm -rf /rust/registry
|
| 20 |
+
# Needed to recompile rust std library for MSAN
|
| 21 |
+
rustup component add rust-src
|
| 22 |
+
cp -r /usr/local/lib/x86_64-unknown-linux-gnu/* /usr/local/lib/
|
local-test-tika-full-01-vuln_0/fuzz-tooling/infra/base-images/base-builder/install_swift.sh
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash -eux
|
| 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 |
+
|
| 18 |
+
|
| 19 |
+
SWIFT_PACKAGES="wget \
|
| 20 |
+
binutils \
|
| 21 |
+
git \
|
| 22 |
+
gnupg2 \
|
| 23 |
+
libc6-dev \
|
| 24 |
+
libcurl4 \
|
| 25 |
+
libedit2 \
|
| 26 |
+
libgcc-9-dev \
|
| 27 |
+
libpython2.7 \
|
| 28 |
+
libsqlite3-0 \
|
| 29 |
+
libstdc++-9-dev \
|
| 30 |
+
libxml2 \
|
| 31 |
+
libz3-dev \
|
| 32 |
+
pkg-config \
|
| 33 |
+
tzdata \
|
| 34 |
+
zlib1g-dev"
|
| 35 |
+
SWIFT_SYMBOLIZER_PACKAGES="build-essential make cmake ninja-build git python3 g++-multilib binutils-dev zlib1g-dev"
|
| 36 |
+
apt-get update && apt install -y $SWIFT_PACKAGES && \
|
| 37 |
+
apt install -y $SWIFT_SYMBOLIZER_PACKAGES --no-install-recommends
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
wget -q https://download.swift.org/swift-5.10.1-release/ubuntu2004/swift-5.10.1-RELEASE/swift-5.10.1-RELEASE-ubuntu20.04.tar.gz
|
| 41 |
+
tar xzf swift-5.10.1-RELEASE-ubuntu20.04.tar.gz
|
| 42 |
+
cp -r swift-5.10.1-RELEASE-ubuntu20.04/usr/* /usr/
|
| 43 |
+
rm -rf swift-5.10.1-RELEASE-ubuntu20.04.tar.gz swift-5.10.1-RELEASE-ubuntu20.04/
|
| 44 |
+
# TODO: Move to a seperate work dir
|
| 45 |
+
git clone https://github.com/llvm/llvm-project.git
|
| 46 |
+
cd llvm-project
|
| 47 |
+
git checkout 63bf228450b8403e0c5e828d276be47ffbcd00d0 # TODO: Keep in sync with base-clang.
|
| 48 |
+
git apply ../llvmsymbol.diff --verbose
|
| 49 |
+
cmake -G "Ninja" \
|
| 50 |
+
-DLIBCXX_ENABLE_SHARED=OFF \
|
| 51 |
+
-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON \
|
| 52 |
+
-DLIBCXXABI_ENABLE_SHARED=OFF \
|
| 53 |
+
-DCMAKE_BUILD_TYPE=Release \
|
| 54 |
+
-DLLVM_TARGETS_TO_BUILD=X86 \
|
| 55 |
+
-DCMAKE_C_COMPILER=clang \
|
| 56 |
+
-DCMAKE_CXX_COMPILER=clang++ \
|
| 57 |
+
-DLLVM_BUILD_TESTS=OFF \
|
| 58 |
+
-DLLVM_INCLUDE_TESTS=OFF llvm
|
| 59 |
+
ninja -j$(nproc) llvm-symbolizer
|
| 60 |
+
cp bin/llvm-symbolizer /usr/local/bin/llvm-symbolizer-swift
|
| 61 |
+
|
| 62 |
+
cd $SRC
|
| 63 |
+
rm -rf llvm-project llvmsymbol.diff
|
| 64 |
+
|
| 65 |
+
# TODO: Cleanup packages
|
| 66 |
+
apt-get remove --purge -y wget zlib1g-dev
|
| 67 |
+
apt-get autoremove -y
|
local-test-tika-full-01-vuln_0/fuzz-tooling/infra/base-images/base-builder/precompile_afl
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash -eu
|
| 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 |
+
|
| 18 |
+
echo "Precompiling AFLplusplus"
|
| 19 |
+
|
| 20 |
+
pushd $SRC/aflplusplus > /dev/null
|
| 21 |
+
make clean
|
| 22 |
+
# Unset CFLAGS and CXXFLAGS while building AFL since we don't want to slow it
|
| 23 |
+
# down with sanitizers.
|
| 24 |
+
SAVE_CXXFLAGS=$CXXFLAGS
|
| 25 |
+
SAVE_CFLAGS=$CFLAGS
|
| 26 |
+
unset CXXFLAGS
|
| 27 |
+
unset CFLAGS
|
| 28 |
+
export AFL_IGNORE_UNKNOWN_ENVS=1
|
| 29 |
+
make clean
|
| 30 |
+
AFL_NO_X86=1 PYTHON_INCLUDE=/ make
|
| 31 |
+
make -C utils/aflpp_driver
|
| 32 |
+
|
| 33 |
+
popd > /dev/null
|
| 34 |
+
|
| 35 |
+
echo "Done."
|
local-test-tika-full-01-vuln_0/fuzz-tooling/infra/base-images/base-builder/precompile_centipede
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash -eu
|
| 2 |
+
# Copyright 2022 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
################################################################################
|
| 17 |
+
|
| 18 |
+
echo -n "Precompiling centipede"
|
| 19 |
+
|
| 20 |
+
# Build Centipede with bazel.
|
| 21 |
+
cd "$SRC/fuzztest/centipede/"
|
| 22 |
+
apt-get update && apt-get install libssl-dev -y
|
| 23 |
+
unset CXXFLAGS CFLAGS
|
| 24 |
+
# We need to use an older version of BAZEL because fuzztest relies on WORKSPACE
|
| 25 |
+
# Ref: https://github.com/google/oss-fuzz/pull/12838#issue-2733821058
|
| 26 |
+
export USE_BAZEL_VERSION=7.4.0
|
| 27 |
+
echo 'build --cxxopt=-stdlib=libc++ --linkopt=-lc++' >> /tmp/centipede.bazelrc
|
| 28 |
+
bazel --bazelrc=/tmp/centipede.bazelrc build -c opt :all
|
| 29 |
+
unset USE_BAZEL_VERSION
|
| 30 |
+
|
| 31 |
+
# Prepare the weak symbols:
|
| 32 |
+
# This is necessary because we compile the target binary and the intermediate
|
| 33 |
+
# auxiliary binaries with the same cflags. The auxiliary binaries do not need
|
| 34 |
+
# data-flow tracing flags, but will still throw errors when they cannot find
|
| 35 |
+
# the corresponding functions.
|
| 36 |
+
# The weak symbols provides fake implementations for intermediate binaries.
|
| 37 |
+
$CXX "$SRC/fuzztest/centipede/weak_sancov_stubs.cc" -c -o "$SRC/fuzztest/centipede/weak.o"
|
| 38 |
+
|
| 39 |
+
echo 'Removing extra stuff leftover to avoid bloating image.'
|
| 40 |
+
|
| 41 |
+
rm -rf /clang-*.tgz /clang
|
| 42 |
+
|
| 43 |
+
BAZEL_BIN_REAL_DIR=$(readlink -f $CENTIPEDE_BIN_DIR)
|
| 44 |
+
rm -rf $CENTIPEDE_BIN_DIR
|
| 45 |
+
mkdir -p $CENTIPEDE_BIN_DIR
|
| 46 |
+
mv $BAZEL_BIN_REAL_DIR/centipede/{centipede,libcentipede_runner.pic.a} $CENTIPEDE_BIN_DIR
|
| 47 |
+
rm -rf /root/.cache
|
| 48 |
+
|
| 49 |
+
echo 'Done.'
|
local-test-tika-full-01-vuln_0/fuzz-tooling/infra/base-images/base-builder/precompile_honggfuzz
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash -eu
|
| 2 |
+
# Copyright 2019 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 |
+
echo "Precompiling honggfuzz"
|
| 19 |
+
export BUILD_OSSFUZZ_STATIC=true
|
| 20 |
+
|
| 21 |
+
PACKAGES=(
|
| 22 |
+
libunwind8-dev
|
| 23 |
+
libblocksruntime-dev
|
| 24 |
+
liblzma-dev
|
| 25 |
+
libiberty-dev
|
| 26 |
+
zlib1g-dev
|
| 27 |
+
pkg-config)
|
| 28 |
+
|
| 29 |
+
apt-get update && apt-get install -y ${PACKAGES[@]}
|
| 30 |
+
|
| 31 |
+
pushd $SRC/honggfuzz > /dev/null
|
| 32 |
+
make clean
|
| 33 |
+
# These CFLAGs match honggfuzz's default, with the exception of -mtune to
|
| 34 |
+
# improve portability and `-D_HF_LINUX_NO_BFD` to remove assembly instructions
|
| 35 |
+
# from the filenames.
|
| 36 |
+
CC=clang CFLAGS="-O3 -funroll-loops -D_HF_LINUX_NO_BFD" make
|
| 37 |
+
|
| 38 |
+
# libhfuzz.a will be added by CC/CXX linker directly during linking,
|
| 39 |
+
# but it's defined here to satisfy the build infrastructure
|
| 40 |
+
ar rcs honggfuzz.a libhfuzz/*.o libhfcommon/*.o
|
| 41 |
+
popd > /dev/null
|
| 42 |
+
|
| 43 |
+
apt-get remove -y --purge ${PACKAGES[@]}
|
| 44 |
+
apt-get autoremove -y
|
| 45 |
+
echo "Done."
|
local-test-tika-full-01-vuln_0/fuzz-tooling/infra/base-images/base-builder/python_coverage_helper.py
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
"""Extracts file paths to copy files from pyinstaller-generated executables"""
|
| 15 |
+
import os
|
| 16 |
+
import sys
|
| 17 |
+
import shutil
|
| 18 |
+
import zipfile
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
# Finds all *.toc files in ./workpath and reads these files in order to
|
| 22 |
+
# identify Python files associated with a pyinstaller packaged executable.
|
| 23 |
+
# Copies all of the Python files to a temporary directory (/medio) following
|
| 24 |
+
# the original directory structure.
|
| 25 |
+
def get_all_files_from_toc(toc_file, file_path_set):
|
| 26 |
+
"""
|
| 27 |
+
Extract filepaths from a .toc file and add to file_path_set
|
| 28 |
+
"""
|
| 29 |
+
with open(toc_file, 'rb') as toc_file_fd:
|
| 30 |
+
for line in toc_file_fd:
|
| 31 |
+
try:
|
| 32 |
+
line = line.decode()
|
| 33 |
+
except: # pylint:disable=bare-except
|
| 34 |
+
continue
|
| 35 |
+
if '.py' not in line:
|
| 36 |
+
continue
|
| 37 |
+
|
| 38 |
+
split_line = line.split(' ')
|
| 39 |
+
for word in split_line:
|
| 40 |
+
word = word.replace('\'', '').replace(',', '').replace('\n', '')
|
| 41 |
+
if '.py' not in word:
|
| 42 |
+
continue
|
| 43 |
+
# Check if .egg is in the path and if so we need to split it
|
| 44 |
+
if os.path.isfile(word):
|
| 45 |
+
file_path_set.add(word)
|
| 46 |
+
elif '.egg' in word: # check if this is an egg
|
| 47 |
+
egg_path_split = word.split('.egg')
|
| 48 |
+
if len(egg_path_split) != 2:
|
| 49 |
+
continue
|
| 50 |
+
egg_path = egg_path_split[0] + '.egg'
|
| 51 |
+
if not os.path.isfile(egg_path):
|
| 52 |
+
continue
|
| 53 |
+
|
| 54 |
+
print('Unzipping contents of %s' % egg_path)
|
| 55 |
+
|
| 56 |
+
# We have an egg. This needs to be unzipped and then replaced
|
| 57 |
+
# with the unzipped data.
|
| 58 |
+
tmp_dir_name = 'zipdcontents'
|
| 59 |
+
if os.path.isdir(tmp_dir_name):
|
| 60 |
+
shutil.rmtree(tmp_dir_name)
|
| 61 |
+
|
| 62 |
+
# unzip egg and replace path with unzipped content
|
| 63 |
+
with zipfile.ZipFile(egg_path, 'r') as zip_f:
|
| 64 |
+
zip_f.extractall(tmp_dir_name)
|
| 65 |
+
os.remove(egg_path)
|
| 66 |
+
shutil.copytree(tmp_dir_name, egg_path)
|
| 67 |
+
|
| 68 |
+
# Now the lines should be accessible, so check again
|
| 69 |
+
if os.path.isfile(word):
|
| 70 |
+
file_path_set.add(word)
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
def create_file_structure_from_tocs(work_path, out_path):
|
| 74 |
+
"""
|
| 75 |
+
Extract the Python files that are added as paths in the output of
|
| 76 |
+
a pyinstaller operation. The files are determined by reading through
|
| 77 |
+
all of the *.toc files in the workpath of pyinstaller.
|
| 78 |
+
|
| 79 |
+
The files will be copied into the out_path using a similar file path
|
| 80 |
+
as they originally are. If any archive (.egg) files are present in the
|
| 81 |
+
.toc files, then unzip the archives and substitute the archive for the
|
| 82 |
+
unzipped content, i.e. we will extract the archives and collect the source
|
| 83 |
+
files.
|
| 84 |
+
"""
|
| 85 |
+
print('Extracts files from the pyinstaller workpath')
|
| 86 |
+
file_path_set = set()
|
| 87 |
+
for path1 in os.listdir(work_path):
|
| 88 |
+
full_path = os.path.join(work_path, path1)
|
| 89 |
+
if not os.path.isdir(full_path):
|
| 90 |
+
continue
|
| 91 |
+
|
| 92 |
+
# We have a directory
|
| 93 |
+
for path2 in os.listdir(full_path):
|
| 94 |
+
if not '.toc' in path2:
|
| 95 |
+
continue
|
| 96 |
+
full_toc_file = os.path.join(full_path, path2)
|
| 97 |
+
get_all_files_from_toc(full_toc_file, file_path_set)
|
| 98 |
+
|
| 99 |
+
for file_path in file_path_set:
|
| 100 |
+
relative_src = file_path[1:] if file_path[0] == '/' else file_path
|
| 101 |
+
dst_path = os.path.join(out_path, relative_src)
|
| 102 |
+
os.makedirs(os.path.dirname(dst_path), exist_ok=True)
|
| 103 |
+
shutil.copy(file_path, dst_path)
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
def main():
|
| 107 |
+
"""
|
| 108 |
+
Main handler.
|
| 109 |
+
"""
|
| 110 |
+
if len(sys.argv) != 3:
|
| 111 |
+
print('Use: python3 python_coverage_helper.py pyinstaller_workpath '
|
| 112 |
+
'destination_for_output')
|
| 113 |
+
sys.exit(1)
|
| 114 |
+
work_path = sys.argv[1]
|
| 115 |
+
out_path = sys.argv[2]
|
| 116 |
+
create_file_structure_from_tocs(work_path, out_path)
|
| 117 |
+
|
| 118 |
+
|
| 119 |
+
if __name__ == '__main__':
|
| 120 |
+
main()
|
local-test-tika-full-01-vuln_0/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-tika-full-01-vuln_0/fuzz-tooling/infra/base-images/base-runner/README.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# base-runner
|
| 2 |
+
> Base image for fuzzer runners.
|
| 3 |
+
|
| 4 |
+
```bash
|
| 5 |
+
docker run -ti ghcr.io/aixcc-finals/base-runner <command> <args>
|
| 6 |
+
```
|
| 7 |
+
|
| 8 |
+
## Commands
|
| 9 |
+
|
| 10 |
+
| Command | Description |
|
| 11 |
+
|---------|-------------|
|
| 12 |
+
| `reproduce <fuzzer_name> <fuzzer_options>` | build all fuzz targets and run specified one with testcase `/testcase` and given options.
|
| 13 |
+
| `run_fuzzer <fuzzer_name> <fuzzer_options>` | runs specified fuzzer combining options with `.options` file |
|
| 14 |
+
| `test_all.py` | runs every binary in `/out` as a fuzzer for a while to ensure it works. |
|
| 15 |
+
| `coverage <fuzzer_name>` | generate a coverage report for the given fuzzer. |
|
| 16 |
+
|
| 17 |
+
# Examples
|
| 18 |
+
|
| 19 |
+
- *Reproduce using latest OSS-Fuzz build:*
|
| 20 |
+
|
| 21 |
+
<pre>
|
| 22 |
+
docker run --rm -ti -v <b><i><testcase_path></i></b>:/testcase gcr.io/oss-fuzz/<b><i>$PROJECT_NAME</i></b> reproduce <b><i><fuzzer_name></i></b>
|
| 23 |
+
</pre>
|
| 24 |
+
|
| 25 |
+
- *Reproduce using local source checkout:*
|
| 26 |
+
|
| 27 |
+
<pre>
|
| 28 |
+
docker run --rm -ti -v <b><i><source_path></i></b>:/src/<b><i>$PROJECT_NAME</i></b> \
|
| 29 |
+
-v <b><i><testcase_path></i></b>:/testcase gcr.io/oss-fuzz/<b><i>$PROJECT_NAME</i></b> \
|
| 30 |
+
reproduce <b><i><fuzzer_name></i></b>
|
| 31 |
+
</pre>
|
local-test-tika-full-01-vuln_0/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-tika-full-01-vuln_0/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-tika-full-01-vuln_0/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-tika-full-01-vuln_0/fuzz-tooling/infra/base-images/base-runner/test_one.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
"""Does bad_build_check on a fuzz target in $OUT."""
|
| 18 |
+
import os
|
| 19 |
+
import sys
|
| 20 |
+
|
| 21 |
+
import test_all
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
def test_one(fuzz_target):
|
| 25 |
+
"""Does bad_build_check on one fuzz target. Returns True on success."""
|
| 26 |
+
with test_all.use_different_out_dir():
|
| 27 |
+
fuzz_target_path = os.path.join(os.environ['OUT'], fuzz_target)
|
| 28 |
+
result = test_all.do_bad_build_check(fuzz_target_path)
|
| 29 |
+
if result.returncode != 0:
|
| 30 |
+
sys.stdout.buffer.write(result.stdout + result.stderr + b'\n')
|
| 31 |
+
return False
|
| 32 |
+
return True
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
def main():
|
| 36 |
+
"""Does bad_build_check on one fuzz target. Returns 1 on failure, 0 on
|
| 37 |
+
success."""
|
| 38 |
+
if len(sys.argv) != 2:
|
| 39 |
+
print('Usage: %d <fuzz_target>', sys.argv[0])
|
| 40 |
+
return 1
|
| 41 |
+
|
| 42 |
+
fuzz_target_binary = sys.argv[1]
|
| 43 |
+
return 0 if test_one(fuzz_target_binary) else 1
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
if __name__ == '__main__':
|
| 47 |
+
sys.exit(main())
|