Kitxuuu commited on
Commit
91255d4
·
verified ·
1 Parent(s): 792e245

Add files using upload-large-folder tool

Browse files
Files changed (20) hide show
  1. local-test-tika-full-01-vuln_1/fuzz-tooling/infra/base-images/base-builder-fuzzbench/Dockerfile +26 -0
  2. local-test-tika-full-01-vuln_1/fuzz-tooling/infra/base-images/base-builder-fuzzbench/fuzzbench_build +28 -0
  3. local-test-tika-full-01-vuln_1/fuzz-tooling/infra/base-images/base-builder-fuzzbench/fuzzbench_run_fuzzer +41 -0
  4. local-test-tika-full-01-vuln_1/fuzz-tooling/infra/base-images/base-builder-go/ossfuzz_coverage_runner.go +80 -0
  5. local-test-tika-full-01-vuln_1/fuzz-tooling/infra/base-images/base-builder-swift/precompile_swift +33 -0
  6. local-test-tika-full-01-vuln_1/fuzz-tooling/infra/base-images/base-runner-debug/Dockerfile +26 -0
  7. local-test-tika-full-01-vuln_1/fuzz-tooling/infra/base-images/base-runner/download_corpus +30 -0
  8. local-test-tika-full-01-vuln_1/fuzz-tooling/infra/base-images/base-runner/generate_differential_cov_report.py +228 -0
  9. local-test-tika-full-01-vuln_1/fuzz-tooling/infra/base-images/base-runner/install_go.sh +41 -0
  10. local-test-tika-full-01-vuln_1/fuzz-tooling/infra/base-images/base-runner/install_java.sh +46 -0
  11. local-test-tika-full-01-vuln_1/fuzz-tooling/infra/base-images/base-runner/jacoco_report_converter.py +174 -0
  12. local-test-tika-full-01-vuln_1/fuzz-tooling/infra/base-images/base-runner/python_coverage_runner_help.py +181 -0
  13. local-test-tika-full-01-vuln_1/fuzz-tooling/infra/base-images/base-runner/rcfilt +21 -0
  14. local-test-tika-full-01-vuln_1/fuzz-tooling/infra/base-images/base-runner/run_fuzzer +228 -0
  15. local-test-tika-full-01-vuln_1/fuzz-tooling/infra/base-images/base-runner/targets_list +10 -0
  16. local-test-tika-full-01-vuln_1/fuzz-tooling/infra/cifuzz/actions/build_fuzzers/action.yml +55 -0
  17. local-test-tika-full-01-vuln_1/fuzz-tooling/infra/cifuzz/filestore/git/git_test.py +122 -0
  18. local-test-tika-full-01-vuln_1/fuzz-tooling/infra/cifuzz/test_data/external-project/.clusterfuzzlite/Dockerfile +22 -0
  19. local-test-tika-full-01-vuln_1/fuzz-tooling/infra/cifuzz/test_data/external-project/do_stuff_fuzzer.dict +6 -0
  20. local-test-tika-full-01-vuln_1/fuzz-tooling/infra/tools/wycheproof/package.bash +18 -0
local-test-tika-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-tika-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-tika-full-01-vuln_1/fuzz-tooling/infra/base-images/base-builder-fuzzbench/fuzzbench_run_fuzzer ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ export RUNNER_NICENESS="-5"
19
+ export EXPERIMENT_FILESTORE=$OUT/filestore
20
+ export EXPERIMENT=oss-fuzz-on-demand
21
+ export OSS_FUZZ_ON_DEMAND=1
22
+ export OUTPUT_CORPUS_DIR=/output-corpus
23
+ export SEED_CORPUS_DIR=/input-corpus
24
+ mkdir $SEED_CORPUS_DIR
25
+ rm -rf $OUTPUT_CORPUS_DIR
26
+ mkdir $OUTPUT_CORPUS_DIR
27
+ export FUZZER=$FUZZING_ENGINE
28
+ # TODO(metzman): Make this configurable.
29
+ export MAX_TOTAL_TIME=120
30
+ export SNAPSHOT_PERIOD=30
31
+ export TRIAL_ID=1
32
+ export FORCE_LOCAL=1
33
+
34
+ # BENCHMARK, FUZZ_TARGET
35
+ cd $OUT
36
+
37
+ # Prevent permissions issues with pyc files and docker.
38
+ cp -r $FUZZBENCH_PATH /tmp/fuzzbench
39
+
40
+ PYTHONPATH=/tmp/fuzzbench nice -n $RUNNER_NICENESS python3 -B -u /tmp/fuzzbench/experiment/runner.py
41
+ cat $EXPERIMENT_FILESTORE/$EXPERIMENT/experiment-folders/$BENCHMARK-$FUZZER/trial-$TRIAL_ID/results/fuzzer-log.txt
local-test-tika-full-01-vuln_1/fuzz-tooling/infra/base-images/base-builder-go/ossfuzz_coverage_runner.go ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ package mypackagebeingfuzzed
16
+
17
+ import (
18
+ "io/fs"
19
+ "io/ioutil"
20
+ "os"
21
+ "path/filepath"
22
+ "runtime/pprof"
23
+ "testing"
24
+ )
25
+
26
+ func TestFuzzCorpus(t *testing.T) {
27
+ dir := os.Getenv("FUZZ_CORPUS_DIR")
28
+ if dir == "" {
29
+ t.Logf("No fuzzing corpus directory set")
30
+ return
31
+ }
32
+ filename := ""
33
+ defer func() {
34
+ if r := recover(); r != nil {
35
+ t.Error("Fuzz panicked in "+filename, r)
36
+ }
37
+ }()
38
+ profname := os.Getenv("FUZZ_PROFILE_NAME")
39
+ if profname != "" {
40
+ f, err := os.Create(profname + ".cpu.prof")
41
+ if err != nil {
42
+ t.Logf("error creating profile file %s\n", err)
43
+ } else {
44
+ _ = pprof.StartCPUProfile(f)
45
+ }
46
+ }
47
+ _, err := ioutil.ReadDir(dir)
48
+ if err != nil {
49
+ t.Logf("Not fuzzing corpus directory %s", err)
50
+ return
51
+ }
52
+ // recurse for regressions subdirectory
53
+ err = filepath.Walk(dir, func(fname string, info fs.FileInfo, err error) error {
54
+ if info.IsDir() {
55
+ return nil
56
+ }
57
+ data, err := ioutil.ReadFile(fname)
58
+ if err != nil {
59
+ t.Error("Failed to read corpus file", err)
60
+ return err
61
+ }
62
+ filename = fname
63
+ FuzzFunction(data)
64
+ return nil
65
+ })
66
+ if err != nil {
67
+ t.Error("Failed to run corpus", err)
68
+ }
69
+ if profname != "" {
70
+ pprof.StopCPUProfile()
71
+ f, err := os.Create(profname + ".heap.prof")
72
+ if err != nil {
73
+ t.Logf("error creating heap profile file %s\n", err)
74
+ }
75
+ if err = pprof.WriteHeapProfile(f); err != nil {
76
+ t.Logf("error writing heap profile file %s\n", err)
77
+ }
78
+ f.Close()
79
+ }
80
+ }
local-test-tika-full-01-vuln_1/fuzz-tooling/infra/base-images/base-builder-swift/precompile_swift ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ cp /usr/local/bin/llvm-symbolizer-swift $OUT/llvm-symbolizer
19
+
20
+ export SWIFTFLAGS="-Xswiftc -parse-as-library -Xswiftc -static-stdlib --static-swift-stdlib"
21
+ if [ "$SANITIZER" = "coverage" ]
22
+ then
23
+ export SWIFTFLAGS="$SWIFTFLAGS -Xswiftc -profile-generate -Xswiftc -profile-coverage-mapping -Xswiftc -sanitize=fuzzer"
24
+ else
25
+ export SWIFTFLAGS="$SWIFTFLAGS -Xswiftc -sanitize=fuzzer,$SANITIZER --sanitize=$SANITIZER"
26
+ for f in $CFLAGS; do
27
+ export SWIFTFLAGS="$SWIFTFLAGS -Xcc=$f"
28
+ done
29
+
30
+ for f in $CXXFLAGS; do
31
+ export SWIFTFLAGS="$SWIFTFLAGS -Xcxx=$f"
32
+ done
33
+ fi
local-test-tika-full-01-vuln_1/fuzz-tooling/infra/base-images/base-runner-debug/Dockerfile ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ ARG IMG_TAG=latest
18
+ FROM ghcr.io/aixcc-finals/base-runner:${IMG_TAG}
19
+ RUN apt-get update && apt-get install -y valgrind zip
20
+
21
+ # Installing GDB 12, re https://github.com/google/oss-fuzz/issues/7513.
22
+ RUN apt-get install -y build-essential libgmp-dev && \
23
+ wget https://ftp.gnu.org/gnu/gdb/gdb-12.1.tar.xz && \
24
+ tar -xf gdb-12.1.tar.xz && cd gdb-12.1 && ./configure && \
25
+ make -j $(expr $(nproc) / 2) && make install && cd .. && \
26
+ rm -rf gdb-12.1* && apt-get remove --purge -y build-essential libgmp-dev
local-test-tika-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-tika-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-tika-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-tika-full-01-vuln_1/fuzz-tooling/infra/base-images/base-runner/install_java.sh ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 java in a platform-aware way.
19
+
20
+ ARCHITECTURE=
21
+ case $(uname -m) in
22
+ x86_64)
23
+ ARCHITECTURE=x64
24
+ ;;
25
+ aarch64)
26
+ ARCHITECTURE=aarch64
27
+ ;;
28
+ *)
29
+ echo "Error: unsupported architecture: $(uname -m)"
30
+ exit 1
31
+ ;;
32
+ esac
33
+
34
+ wget -q https://download.java.net/java/GA/jdk17.0.2/dfd4a8d0985749f896bed50d7138ee7f/8/GPL/openjdk-17.0.2_linux-"$ARCHITECTURE"_bin.tar.gz -O /tmp/openjdk-17.0.2_linux-"$ARCHITECTURE"_bin.tar.gz
35
+ wget -q https://download.java.net/java/GA/jdk15.0.2/0d1cfde4252546c6931946de8db48ee2/7/GPL/openjdk-15.0.2_linux-"$ARCHITECTURE"_bin.tar.gz -O /tmp/openjdk-15.0.2_linux-"$ARCHITECTURE"_bin.tar.gz
36
+ cd /tmp
37
+ mkdir -p $JAVA_HOME
38
+ tar -xz --strip-components=1 -f openjdk-17.0.2_linux-"$ARCHITECTURE"_bin.tar.gz --directory $JAVA_HOME
39
+ rm -f openjdk-17.0.2_linux-"$ARCHITECTURE"_bin.tar.gz
40
+ rm -rf $JAVA_HOME/jmods $JAVA_HOME/lib/src.zip
41
+
42
+ # Install OpenJDK 15 and trim its size by removing unused components. Some projects only run with Java 15.
43
+ mkdir -p $JAVA_15_HOME
44
+ tar -xz --strip-components=1 -f openjdk-15.0.2_linux-"$ARCHITECTURE"_bin.tar.gz --directory $JAVA_15_HOME
45
+ rm -f openjdk-15.0.2_linux-"$ARCHITECTURE"_bin.tar.gz
46
+ rm -rf $JAVA_15_HOME/jmods $JAVA_15_HOME/lib/src.zip
local-test-tika-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-tika-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-tika-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-tika-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-tika-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-tika-full-01-vuln_1/fuzz-tooling/infra/cifuzz/actions/build_fuzzers/action.yml ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # action.yml
2
+ name: 'build-fuzzers'
3
+ description: "Builds an OSS-Fuzz project's fuzzers."
4
+ inputs:
5
+ oss-fuzz-project-name:
6
+ description: 'Name of the corresponding OSS-Fuzz project.'
7
+ required: true
8
+ language:
9
+ description: 'Programming language project is written in.'
10
+ required: false
11
+ default: 'c++'
12
+ dry-run:
13
+ description: 'If set, run the action without actually reporting a failure.'
14
+ default: false
15
+ allowed-broken-targets-percentage:
16
+ description: 'The percentage of broken targets allowed in bad_build_check.'
17
+ required: false
18
+ sanitizer:
19
+ description: 'The sanitizer to build the fuzzers with.'
20
+ default: 'address'
21
+ architecture:
22
+ description: 'The architecture used to build the fuzzers.'
23
+ default: 'x86_64'
24
+ project-src-path:
25
+ description: "The path to the project's source code checkout."
26
+ required: false
27
+ bad-build-check:
28
+ description: "Whether or not OSS-Fuzz's check for bad builds should be done."
29
+ required: false
30
+ default: true
31
+ keep-unaffected-fuzz-targets:
32
+ description: "Whether to keep unaffected fuzzers or delete them."
33
+ required: false
34
+ default: false
35
+ output-sarif:
36
+ description: "Whether to output fuzzing results to SARIF."
37
+ required: false
38
+ default: false
39
+ runs:
40
+ using: 'docker'
41
+ image: '../../../build_fuzzers.Dockerfile'
42
+ env:
43
+ OSS_FUZZ_PROJECT_NAME: ${{ inputs.oss-fuzz-project-name }}
44
+ LANGUAGE: ${{ inputs.language }}
45
+ DRY_RUN: ${{ inputs.dry-run}}
46
+ ALLOWED_BROKEN_TARGETS_PERCENTAGE: ${{ inputs.allowed-broken-targets-percentage}}
47
+ SANITIZER: ${{ inputs.sanitizer }}
48
+ ARCHITECTURE: ${{ inputs.architecture }}
49
+ PROJECT_SRC_PATH: ${{ inputs.project-src-path }}
50
+ LOW_DISK_SPACE: 'True'
51
+ BAD_BUILD_CHECK: ${{ inputs.bad-build-check }}
52
+ CIFUZZ_DEBUG: 'True'
53
+ CFL_PLATFORM: 'github'
54
+ KEEP_UNAFFECTED_FUZZ_TARGETS: ${{ inputs.keep-unaffected-fuzz-targets }}
55
+ OUTPUT_SARIF: ${{ inputs.output-sarif }}
local-test-tika-full-01-vuln_1/fuzz-tooling/infra/cifuzz/filestore/git/git_test.py ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 git."""
15
+ import filecmp
16
+ import os
17
+ import tempfile
18
+ import subprocess
19
+ import sys
20
+ import unittest
21
+ from unittest import mock
22
+
23
+ # pylint: disable=wrong-import-position
24
+ INFRA_DIR = os.path.dirname(
25
+ os.path.dirname(os.path.dirname(os.path.dirname(
26
+ os.path.abspath(__file__)))))
27
+ sys.path.append(INFRA_DIR)
28
+
29
+ from filestore import git
30
+ import test_helpers
31
+
32
+ # pylint: disable=protected-access,no-self-use
33
+
34
+
35
+ class GitFilestoreTest(unittest.TestCase):
36
+ """Tests for GitFilestore."""
37
+
38
+ def setUp(self):
39
+ self.git_dir = tempfile.TemporaryDirectory()
40
+ self.addCleanup(self.git_dir.cleanup)
41
+
42
+ self.local_dir = tempfile.TemporaryDirectory()
43
+ self.addCleanup(self.local_dir.cleanup)
44
+
45
+ self.download_dir = tempfile.TemporaryDirectory()
46
+ self.addCleanup(self.download_dir.cleanup)
47
+
48
+ with open(os.path.join(self.local_dir.name, 'a'), 'w') as handle:
49
+ handle.write('')
50
+
51
+ os.makedirs(os.path.join(self.local_dir.name, 'b'))
52
+
53
+ with open(os.path.join(self.local_dir.name, 'b', 'c'), 'w') as handle:
54
+ handle.write('')
55
+
56
+ self.git_repo = git.git_runner(self.git_dir.name)
57
+ self.git_repo('init', '--bare')
58
+
59
+ self.config = test_helpers.create_run_config(
60
+ git_store_repo='file://' + self.git_dir.name,
61
+ git_store_branch='main',
62
+ git_store_branch_coverage='cov-branch')
63
+
64
+ self.mock_ci_filestore = mock.MagicMock()
65
+ self.git_store = git.GitFilestore(self.config, self.mock_ci_filestore)
66
+
67
+ def assert_dirs_same(self, first, second):
68
+ """Asserts two dirs are the same."""
69
+ dcmp = filecmp.dircmp(first, second)
70
+ if dcmp.diff_files or dcmp.left_only or dcmp.right_only:
71
+ return False
72
+
73
+ return all(
74
+ self.assert_dirs_same(os.path.join(first, subdir),
75
+ os.path.join(second, subdir))
76
+ for subdir in dcmp.common_dirs)
77
+
78
+ def get_repo_filelist(self, branch):
79
+ """Get files in repo."""
80
+ return subprocess.check_output([
81
+ 'git', '-C', self.git_dir.name, 'ls-tree', '-r', '--name-only', branch
82
+ ]).decode().splitlines()
83
+
84
+ def test_upload_download_corpus(self):
85
+ """Tests uploading and downloading corpus."""
86
+ self.git_store.upload_corpus('target', self.local_dir.name)
87
+ self.git_store.download_corpus('target', self.download_dir.name)
88
+ self.assert_dirs_same(self.local_dir.name, self.download_dir.name)
89
+
90
+ self.assertCountEqual([
91
+ 'corpus/target/a',
92
+ 'corpus/target/b/c',
93
+ ], self.get_repo_filelist('main'))
94
+
95
+ def test_upload_download_coverage(self):
96
+ """Tests uploading and downloading corpus."""
97
+ self.git_store.upload_coverage('latest', self.local_dir.name)
98
+ self.git_store.download_coverage('latest', self.download_dir.name)
99
+ self.assert_dirs_same(self.local_dir.name, self.download_dir.name)
100
+
101
+ self.assertCountEqual([
102
+ 'coverage/latest/a',
103
+ 'coverage/latest/b/c',
104
+ ], self.get_repo_filelist('cov-branch'))
105
+
106
+ def test_upload_crashes(self):
107
+ """Tests uploading crashes."""
108
+ self.git_store.upload_crashes('current', self.local_dir.name)
109
+ self.mock_ci_filestore.upload_crashes.assert_called_with(
110
+ 'current', self.local_dir.name)
111
+
112
+ def test_upload_build(self):
113
+ """Tests uploading build."""
114
+ self.git_store.upload_build('sanitizer', self.local_dir.name)
115
+ self.mock_ci_filestore.upload_build.assert_called_with(
116
+ 'sanitizer', self.local_dir.name)
117
+
118
+ def test_download_build(self):
119
+ """Tests downloading build."""
120
+ self.git_store.download_build('sanitizer', self.download_dir.name)
121
+ self.mock_ci_filestore.download_build.assert_called_with(
122
+ 'sanitizer', self.download_dir.name)
local-test-tika-full-01-vuln_1/fuzz-tooling/infra/cifuzz/test_data/external-project/.clusterfuzzlite/Dockerfile ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2020 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ #
15
+ ################################################################################
16
+
17
+ FROM ghcr.io/aixcc-finals/base-builder
18
+ RUN apt-get update && apt-get install -y make
19
+
20
+ COPY . $SRC/external-project
21
+ WORKDIR $SRC/external-project
22
+ COPY .clusterfuzzlite/build.sh $SRC/
local-test-tika-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-tika-full-01-vuln_1/fuzz-tooling/infra/tools/wycheproof/package.bash ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
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
+ # Script for zipping ClusterFuzz's blackbox fuzzer for wycheproof.
18
+ zip wycheproof.zip run.py launcher.py