Add files using upload-large-folder tool
Browse files- local-test-tika-full-01-vuln_7/fuzz-tooling/infra/base-images/base-builder-fuzzbench/fuzzbench_build +28 -0
- local-test-tika-full-01-vuln_7/fuzz-tooling/infra/base-images/base-builder-fuzzbench/fuzzbench_install_dependencies +22 -0
- local-test-tika-full-01-vuln_7/fuzz-tooling/infra/base-images/base-builder-fuzzbench/fuzzbench_run_fuzzer +41 -0
- local-test-tika-full-01-vuln_7/fuzz-tooling/infra/base-images/base-builder-go/Dockerfile +33 -0
- local-test-tika-full-01-vuln_7/fuzz-tooling/infra/base-images/base-builder-go/gosigfuzz.c +47 -0
- local-test-tika-full-01-vuln_7/fuzz-tooling/infra/base-images/base-builder-go/ossfuzz_coverage_runner.go +80 -0
- local-test-tika-full-01-vuln_7/fuzz-tooling/infra/base-images/base-builder-swift/Dockerfile +22 -0
- local-test-tika-full-01-vuln_7/fuzz-tooling/infra/base-images/base-builder-swift/precompile_swift +33 -0
- local-test-tika-full-01-vuln_7/fuzz-tooling/infra/base-images/base-runner/coverage_helper +17 -0
- local-test-tika-full-01-vuln_7/fuzz-tooling/infra/base-images/base-runner/download_corpus +30 -0
- local-test-tika-full-01-vuln_7/fuzz-tooling/infra/base-images/base-runner/generate_differential_cov_report.py +228 -0
- local-test-tika-full-01-vuln_7/fuzz-tooling/infra/base-images/base-runner/install_java.sh +46 -0
- local-test-tika-full-01-vuln_7/fuzz-tooling/infra/base-images/base-runner/jacoco_report_converter.py +174 -0
- local-test-tika-full-01-vuln_7/fuzz-tooling/infra/base-images/base-runner/rcfilt +21 -0
- local-test-tika-full-01-vuln_7/fuzz-tooling/infra/base-images/base-runner/reproduce +34 -0
- local-test-tika-full-01-vuln_7/fuzz-tooling/infra/base-images/base-runner/ruzzy +19 -0
- local-test-tika-full-01-vuln_7/fuzz-tooling/infra/cifuzz/actions/build_fuzzers/action.yml +55 -0
- local-test-tika-full-01-vuln_7/fuzz-tooling/infra/cifuzz/actions/run_fuzzers/action.yml +82 -0
- local-test-tika-full-01-vuln_7/fuzz-tooling/infra/cifuzz/cifuzz-base/Dockerfile +44 -0
- local-test-tika-full-01-vuln_7/fuzz-tooling/infra/cifuzz/external-actions/build_fuzzers/action.yml +75 -0
- local-test-tika-full-01-vuln_7/fuzz-tooling/infra/cifuzz/external-actions/run_fuzzers/action.yml +97 -0
- local-test-tika-full-01-vuln_7/fuzz-tooling/infra/cifuzz/filestore/__init__.py +54 -0
- local-test-tika-full-01-vuln_7/fuzz-tooling/infra/cifuzz/filestore/filesystem/__init__.py +107 -0
- local-test-tika-full-01-vuln_7/fuzz-tooling/infra/cifuzz/filestore/git/__init__.py +158 -0
- local-test-tika-full-01-vuln_7/fuzz-tooling/infra/cifuzz/filestore/git/git_test.py +122 -0
- local-test-tika-full-01-vuln_7/fuzz-tooling/infra/cifuzz/filestore/github_actions/__init__.py +179 -0
- local-test-tika-full-01-vuln_7/fuzz-tooling/infra/cifuzz/filestore/github_actions/github_actions_test.py +283 -0
- local-test-tika-full-01-vuln_7/fuzz-tooling/infra/cifuzz/filestore/github_actions/github_api.py +109 -0
- local-test-tika-full-01-vuln_7/fuzz-tooling/infra/cifuzz/filestore/github_actions/github_api_test.py +41 -0
- local-test-tika-full-01-vuln_7/fuzz-tooling/infra/cifuzz/filestore/github_actions/upload.js +45 -0
- local-test-tika-full-01-vuln_7/fuzz-tooling/infra/cifuzz/filestore/gitlab/__init__.py +133 -0
- local-test-tika-full-01-vuln_7/fuzz-tooling/infra/cifuzz/filestore/gsutil/__init__.py +109 -0
- local-test-tika-full-01-vuln_7/fuzz-tooling/infra/cifuzz/filestore/no_filestore/__init__.py +51 -0
- local-test-tika-full-01-vuln_7/fuzz-tooling/infra/cifuzz/platform_config/gitlab.py +78 -0
- local-test-tika-full-01-vuln_7/fuzz-tooling/infra/cifuzz/platform_config/standalone.py +33 -0
- local-test-tika-full-01-vuln_7/fuzz-tooling/infra/cifuzz/test_data/external-project/.clusterfuzzlite/Dockerfile +22 -0
- local-test-tika-full-01-vuln_7/fuzz-tooling/infra/cifuzz/test_data/external-project/.clusterfuzzlite/build.sh +24 -0
- local-test-tika-full-01-vuln_7/fuzz-tooling/infra/cifuzz/test_data/external-project/Makefile +44 -0
- local-test-tika-full-01-vuln_7/fuzz-tooling/infra/cifuzz/test_data/external-project/do_stuff_fuzzer.cpp +24 -0
- local-test-tika-full-01-vuln_7/fuzz-tooling/infra/cifuzz/test_data/external-project/do_stuff_fuzzer.dict +6 -0
- local-test-tika-full-01-vuln_7/fuzz-tooling/infra/cifuzz/test_data/external-project/my_api.cpp +36 -0
- local-test-tika-full-01-vuln_7/fuzz-tooling/infra/cifuzz/test_data/external-project/my_api.h +19 -0
- local-test-tika-full-01-vuln_7/fuzz-tooling/infra/cifuzz/test_data/external-project/standalone_fuzz_target_runner.cpp +47 -0
- local-test-tika-full-01-vuln_7/fuzz-tooling/infra/cifuzz/test_data/msan_crash_fuzzer_bug_summary.txt +22 -0
- local-test-tika-full-01-vuln_7/fuzz-tooling/infra/cifuzz/test_data/msan_crash_fuzzer_output.txt +39 -0
- local-test-tika-full-01-vuln_7/fuzz-tooling/infra/tools/wycheproof/.gitignore +1 -0
- local-test-tika-full-01-vuln_7/fuzz-tooling/infra/tools/wycheproof/generate_job.py +50 -0
- local-test-tika-full-01-vuln_7/fuzz-tooling/infra/tools/wycheproof/launcher.py +34 -0
- local-test-tika-full-01-vuln_7/fuzz-tooling/infra/tools/wycheproof/package.bash +18 -0
- local-test-tika-full-01-vuln_7/fuzz-tooling/infra/tools/wycheproof/run.py +50 -0
local-test-tika-full-01-vuln_7/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_7/fuzz-tooling/infra/base-images/base-builder-fuzzbench/fuzzbench_install_dependencies
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#! /bin/bash -eux
|
| 2 |
+
# Copyright 2023 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
################################################################################
|
| 17 |
+
|
| 18 |
+
apt-get update && apt-get install -y gcc gfortran python-dev libopenblas-dev liblapack-dev cython libpq-dev
|
| 19 |
+
wget -O /tmp/requirements.txt https://raw.githubusercontent.com/google/fuzzbench/master/requirements.txt
|
| 20 |
+
pip3 install pip --upgrade
|
| 21 |
+
CFLAGS= CXXFLAGS= pip3 install -r /tmp/requirements.txt
|
| 22 |
+
rm /tmp/requirements.txt
|
local-test-tika-full-01-vuln_7/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_7/fuzz-tooling/infra/base-images/base-builder-go/Dockerfile
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2021 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
#
|
| 15 |
+
################################################################################
|
| 16 |
+
|
| 17 |
+
ARG IMG_TAG=latest
|
| 18 |
+
FROM ghcr.io/aixcc-finals/base-builder:${IMG_TAG}
|
| 19 |
+
|
| 20 |
+
# Set up Golang environment variables (copied from /root/.bash_profile).
|
| 21 |
+
ENV GOPATH /root/go
|
| 22 |
+
|
| 23 |
+
# /root/.go/bin is for the standard Go binaries (i.e. go, gofmt, etc).
|
| 24 |
+
# $GOPATH/bin is for the binaries from the dependencies installed via "go get".
|
| 25 |
+
ENV PATH $PATH:/root/.go/bin:$GOPATH/bin
|
| 26 |
+
|
| 27 |
+
COPY gosigfuzz.c $GOPATH/gosigfuzz/
|
| 28 |
+
|
| 29 |
+
RUN install_go.sh
|
| 30 |
+
|
| 31 |
+
# TODO(jonathanmetzman): Install this file using install_go.sh.
|
| 32 |
+
COPY ossfuzz_coverage_runner.go \
|
| 33 |
+
$GOPATH/
|
local-test-tika-full-01-vuln_7/fuzz-tooling/infra/base-images/base-builder-go/gosigfuzz.c
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 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 |
+
#include<stdlib.h>
|
| 18 |
+
#include<signal.h>
|
| 19 |
+
|
| 20 |
+
static void fixSignalHandler(int signum) {
|
| 21 |
+
struct sigaction new_action;
|
| 22 |
+
struct sigaction old_action;
|
| 23 |
+
sigemptyset (&new_action.sa_mask);
|
| 24 |
+
sigaction (signum, NULL, &old_action);
|
| 25 |
+
new_action.sa_flags = old_action.sa_flags | SA_ONSTACK;
|
| 26 |
+
new_action.sa_sigaction = old_action.sa_sigaction;
|
| 27 |
+
new_action.sa_handler = old_action.sa_handler;
|
| 28 |
+
sigaction (signum, &new_action, NULL);
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
static void FixStackSignalHandler() {
|
| 32 |
+
fixSignalHandler(SIGSEGV);
|
| 33 |
+
fixSignalHandler(SIGABRT);
|
| 34 |
+
fixSignalHandler(SIGALRM);
|
| 35 |
+
fixSignalHandler(SIGINT);
|
| 36 |
+
fixSignalHandler(SIGTERM);
|
| 37 |
+
fixSignalHandler(SIGBUS);
|
| 38 |
+
fixSignalHandler(SIGFPE);
|
| 39 |
+
fixSignalHandler(SIGXFSZ);
|
| 40 |
+
fixSignalHandler(SIGUSR1);
|
| 41 |
+
fixSignalHandler(SIGUSR2);
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
int LLVMFuzzerInitialize(int *argc, char ***argv) {
|
| 45 |
+
FixStackSignalHandler();
|
| 46 |
+
return 0;
|
| 47 |
+
}
|
local-test-tika-full-01-vuln_7/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_7/fuzz-tooling/infra/base-images/base-builder-swift/Dockerfile
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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_swift.sh
|
| 21 |
+
|
| 22 |
+
COPY precompile_swift /usr/local/bin/
|
local-test-tika-full-01-vuln_7/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_7/fuzz-tooling/infra/base-images/base-runner/coverage_helper
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash -u
|
| 2 |
+
# Copyright 2018 Google Inc.
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
################################################################################
|
| 17 |
+
python3 $CODE_COVERAGE_SRC/coverage_utils.py $@
|
local-test-tika-full-01-vuln_7/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_7/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_7/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_7/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_7/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_7/fuzz-tooling/infra/base-images/base-runner/reproduce
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash -eux
|
| 2 |
+
# Copyright 2016 Google Inc.
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
################################################################################
|
| 17 |
+
|
| 18 |
+
FUZZER=$1
|
| 19 |
+
shift
|
| 20 |
+
|
| 21 |
+
if [ ! -v TESTCASE ]; then
|
| 22 |
+
TESTCASE="/testcase"
|
| 23 |
+
fi
|
| 24 |
+
|
| 25 |
+
if [ ! -f $TESTCASE ]; then
|
| 26 |
+
echo "Error: $TESTCASE not found, use: docker run -v <path>:$TESTCASE ..."
|
| 27 |
+
exit 1
|
| 28 |
+
fi
|
| 29 |
+
|
| 30 |
+
export RUN_FUZZER_MODE="interactive"
|
| 31 |
+
export FUZZING_ENGINE="libfuzzer"
|
| 32 |
+
export SKIP_SEED_CORPUS="1"
|
| 33 |
+
|
| 34 |
+
run_fuzzer $FUZZER $@ $TESTCASE
|
local-test-tika-full-01-vuln_7/fuzz-tooling/infra/base-images/base-runner/ruzzy
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
# Copyright 2024 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
################################################################################
|
| 17 |
+
|
| 18 |
+
ASAN_OPTIONS="allocator_may_return_null=1:detect_leaks=0:use_sigaltstack=0" LD_PRELOAD=$(ruby -e 'require "ruzzy"; print Ruzzy::ASAN_PATH') \
|
| 19 |
+
ruby $@
|
local-test-tika-full-01-vuln_7/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_7/fuzz-tooling/infra/cifuzz/actions/run_fuzzers/action.yml
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# action.yml
|
| 2 |
+
name: 'run-fuzzers'
|
| 3 |
+
description: 'Runs fuzz target binaries for a specified length of time.'
|
| 4 |
+
inputs:
|
| 5 |
+
oss-fuzz-project-name:
|
| 6 |
+
description: 'The OSS-Fuzz project name.'
|
| 7 |
+
required: true
|
| 8 |
+
language:
|
| 9 |
+
description: 'Programming language project is written in.'
|
| 10 |
+
required: false
|
| 11 |
+
default: 'c++'
|
| 12 |
+
fuzz-seconds:
|
| 13 |
+
description: 'The total time allotted for fuzzing in seconds.'
|
| 14 |
+
required: true
|
| 15 |
+
default: 600
|
| 16 |
+
dry-run:
|
| 17 |
+
description: 'If set, run the action without actually reporting a failure.'
|
| 18 |
+
default: false
|
| 19 |
+
sanitizer:
|
| 20 |
+
description: 'The sanitizer to run the fuzzers with.'
|
| 21 |
+
default: 'address'
|
| 22 |
+
mode:
|
| 23 |
+
description: |
|
| 24 |
+
The mode to run the fuzzers with ("code-change", "batch", "coverage", or "prune").
|
| 25 |
+
"code-change" is for fuzzing a pull request or commit.
|
| 26 |
+
"batch" is for non-interactive fuzzing of an entire project.
|
| 27 |
+
"coverage" is for coverage generation.
|
| 28 |
+
"prune" is for corpus pruning.
|
| 29 |
+
required: false
|
| 30 |
+
default: 'code-change'
|
| 31 |
+
github-token:
|
| 32 |
+
description: |
|
| 33 |
+
Token for GitHub API. WARNING: THIS SHOULD NOT BE USED IN PRODUCTION YET
|
| 34 |
+
You should use "secrets.GITHUB_TOKEN" in your workflow file, do not
|
| 35 |
+
hardcode the token.
|
| 36 |
+
TODO(https://github.com/google/oss-fuzz/pull/5841#discussion_r639393361):
|
| 37 |
+
Document locking this down.
|
| 38 |
+
required: false
|
| 39 |
+
report-unreproducible-crashes:
|
| 40 |
+
description: 'If True, then unreproducible crashes will be reported.'
|
| 41 |
+
required: false
|
| 42 |
+
default: False
|
| 43 |
+
minimize-crashes:
|
| 44 |
+
description: 'If True, reportable crashes will be minimized.'
|
| 45 |
+
required: false
|
| 46 |
+
default: False
|
| 47 |
+
parallel-fuzzing:
|
| 48 |
+
description: "Whether to use all available cores for fuzzing."
|
| 49 |
+
required: false
|
| 50 |
+
default: false
|
| 51 |
+
output-sarif:
|
| 52 |
+
description: "Whether to output fuzzing results to SARIF."
|
| 53 |
+
required: false
|
| 54 |
+
default: false
|
| 55 |
+
report-timeouts:
|
| 56 |
+
description: "Whether to report fails due to timeout."
|
| 57 |
+
required: false
|
| 58 |
+
default: true
|
| 59 |
+
report-ooms:
|
| 60 |
+
description: "Whether to report fails due to OOM."
|
| 61 |
+
required: false
|
| 62 |
+
default: true
|
| 63 |
+
runs:
|
| 64 |
+
using: 'docker'
|
| 65 |
+
image: '../../../run_fuzzers.Dockerfile'
|
| 66 |
+
env:
|
| 67 |
+
OSS_FUZZ_PROJECT_NAME: ${{ inputs.oss-fuzz-project-name }}
|
| 68 |
+
LANGUAGE: ${{ inputs.language }}
|
| 69 |
+
FUZZ_SECONDS: ${{ inputs.fuzz-seconds }}
|
| 70 |
+
DRY_RUN: ${{ inputs.dry-run}}
|
| 71 |
+
SANITIZER: ${{ inputs.sanitizer }}
|
| 72 |
+
MODE: ${{ inputs.mode }}
|
| 73 |
+
GITHUB_TOKEN: ${{ inputs.github-token }}
|
| 74 |
+
LOW_DISK_SPACE: 'True'
|
| 75 |
+
REPORT_UNREPRODUCIBLE_CRASHES: ${{ inputs.report-unreproducible-crashes }}
|
| 76 |
+
MINIMIZE_CRASHES: ${{ inputs.minimize-crashes }}
|
| 77 |
+
CIFUZZ_DEBUG: 'True'
|
| 78 |
+
CFL_PLATFORM: 'github'
|
| 79 |
+
PARALLEL_FUZZING: ${{ inputs.parallel-fuzzing }}
|
| 80 |
+
OUTPUT_SARIF: ${{ inputs.output-sarif }}
|
| 81 |
+
REPORT_TIMEOUTS: ${{ inputs.report-timeouts }}
|
| 82 |
+
REPORT_OOMS: ${{ inputs.report-ooms}}
|
local-test-tika-full-01-vuln_7/fuzz-tooling/infra/cifuzz/cifuzz-base/Dockerfile
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2020 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
#
|
| 15 |
+
################################################################################
|
| 16 |
+
|
| 17 |
+
FROM ghcr.io/aixcc-finals/base-runner
|
| 18 |
+
|
| 19 |
+
RUN apt-get update && \
|
| 20 |
+
apt-get install -y systemd && \
|
| 21 |
+
wget https://download.docker.com/linux/ubuntu/dists/focal/pool/stable/amd64/docker-ce-cli_20.10.8~3-0~ubuntu-focal_amd64.deb -O /tmp/docker-ce.deb && \
|
| 22 |
+
dpkg -i /tmp/docker-ce.deb && \
|
| 23 |
+
rm /tmp/docker-ce.deb
|
| 24 |
+
|
| 25 |
+
ENV PATH=/opt/gcloud/google-cloud-sdk/bin/:$PATH
|
| 26 |
+
ENV OSS_FUZZ_ROOT=/opt/oss-fuzz
|
| 27 |
+
|
| 28 |
+
# Do this step before copying to make rebuilding faster when developing.
|
| 29 |
+
COPY ./infra/cifuzz/requirements.txt /tmp/requirements.txt
|
| 30 |
+
RUN python3 -m pip install -r /tmp/requirements.txt && rm /tmp/requirements.txt
|
| 31 |
+
|
| 32 |
+
ADD . ${OSS_FUZZ_ROOT}
|
| 33 |
+
# Don't use the default npm location since jazzer.js can break us.
|
| 34 |
+
# This means javascript needed by cifuzz/clusterfuzzlite must be executed in
|
| 35 |
+
# OSS_FUZZ_ROOT.
|
| 36 |
+
RUN cd ${OSS_FUZZ_ROOT} && npm install ${OSS_FUZZ_ROOT}/infra/cifuzz
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
ENV PYTHONUNBUFFERED=1
|
| 40 |
+
|
| 41 |
+
# Python file to execute when the docker container starts up.
|
| 42 |
+
# We can't use the env var $OSS_FUZZ_ROOT here. Since it's a constant env var,
|
| 43 |
+
# just expand to '/opt/oss-fuzz'.
|
| 44 |
+
ENTRYPOINT ["python3", "/opt/oss-fuzz/infra/cifuzz/cifuzz_combined_entrypoint.py"]
|
local-test-tika-full-01-vuln_7/fuzz-tooling/infra/cifuzz/external-actions/build_fuzzers/action.yml
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# action.yml
|
| 2 |
+
name: 'build-fuzzers'
|
| 3 |
+
description: "Builds an OSS-Fuzz project's fuzzers."
|
| 4 |
+
inputs:
|
| 5 |
+
language:
|
| 6 |
+
description: 'Programming language project is written in.'
|
| 7 |
+
required: false
|
| 8 |
+
default: 'c++'
|
| 9 |
+
dry-run:
|
| 10 |
+
description: 'If set, run the action without actually reporting a failure.'
|
| 11 |
+
default: false
|
| 12 |
+
allowed-broken-targets-percentage:
|
| 13 |
+
description: 'The percentage of broken targets allowed in bad_build_check.'
|
| 14 |
+
required: false
|
| 15 |
+
sanitizer:
|
| 16 |
+
description: 'The sanitizer to build the fuzzers with.'
|
| 17 |
+
default: 'address'
|
| 18 |
+
project-src-path:
|
| 19 |
+
description: "The path to the project's source code checkout."
|
| 20 |
+
required: false
|
| 21 |
+
bad-build-check:
|
| 22 |
+
description: "Whether or not OSS-Fuzz's check for bad builds should be done."
|
| 23 |
+
required: false
|
| 24 |
+
default: true
|
| 25 |
+
keep-unaffected-fuzz-targets:
|
| 26 |
+
description: "Whether to keep unaffected fuzzers or delete them."
|
| 27 |
+
required: false
|
| 28 |
+
default: false
|
| 29 |
+
storage-repo:
|
| 30 |
+
description: |
|
| 31 |
+
The git repo to use for storing certain artifacts from fuzzing.
|
| 32 |
+
required: false
|
| 33 |
+
storage-repo-branch:
|
| 34 |
+
description: |
|
| 35 |
+
The branch of the git repo to use for storing certain artifacts from
|
| 36 |
+
fuzzing.
|
| 37 |
+
required: false
|
| 38 |
+
storage-repo-branch-coverage:
|
| 39 |
+
description: |
|
| 40 |
+
The branch of the git repo to use for storing coverage reports.
|
| 41 |
+
required: false
|
| 42 |
+
upload-build:
|
| 43 |
+
description: |
|
| 44 |
+
If set, will upload the build.
|
| 45 |
+
default: false
|
| 46 |
+
github-token:
|
| 47 |
+
description: |
|
| 48 |
+
Token for GitHub API. WARNING: THIS SHOULD NOT BE USED IN PRODUCTION YET
|
| 49 |
+
You should use "secrets.GITHUB_TOKEN" in your workflow file, do not
|
| 50 |
+
hardcode the token.
|
| 51 |
+
TODO(https://github.com/google/oss-fuzz/pull/5841#discussion_r639393361):
|
| 52 |
+
Document locking this down.
|
| 53 |
+
required: false
|
| 54 |
+
output-sarif:
|
| 55 |
+
description: "Whether to output fuzzing results to SARIF."
|
| 56 |
+
required: false
|
| 57 |
+
default: false
|
| 58 |
+
runs:
|
| 59 |
+
using: 'docker'
|
| 60 |
+
image: '../../../build_fuzzers.Dockerfile'
|
| 61 |
+
env:
|
| 62 |
+
OSS_FUZZ_PROJECT_NAME: ${{ inputs.oss-fuzz-project-name }}
|
| 63 |
+
LANGUAGE: ${{ inputs.language }}
|
| 64 |
+
DRY_RUN: ${{ inputs.dry-run}}
|
| 65 |
+
ALLOWED_BROKEN_TARGETS_PERCENTAGE: ${{ inputs.allowed-broken-targets-percentage}}
|
| 66 |
+
SANITIZER: ${{ inputs.sanitizer }}
|
| 67 |
+
PROJECT_SRC_PATH: ${{ inputs.project-src-path }}
|
| 68 |
+
GITHUB_TOKEN: ${{ inputs.github-token }}
|
| 69 |
+
LOW_DISK_SPACE: 'True'
|
| 70 |
+
BAD_BUILD_CHECK: ${{ inputs.bad-build-check }}
|
| 71 |
+
UPLOAD_BUILD: ${{ inputs.upload-build }}
|
| 72 |
+
CIFUZZ_DEBUG: 'True'
|
| 73 |
+
CFL_PLATFORM: 'github'
|
| 74 |
+
KEEP_UNAFFECTED_FUZZ_TARGETS: ${{ inputs.keep-unaffected-fuzz-targets }}
|
| 75 |
+
OUTPUT_SARIF: ${{ inputs.output-sarif }}
|
local-test-tika-full-01-vuln_7/fuzz-tooling/infra/cifuzz/external-actions/run_fuzzers/action.yml
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# action.yml
|
| 2 |
+
name: 'run-fuzzers'
|
| 3 |
+
description: 'Runs fuzz target binaries for a specified length of time.'
|
| 4 |
+
inputs:
|
| 5 |
+
language:
|
| 6 |
+
description: 'Programming language project is written in.'
|
| 7 |
+
required: false
|
| 8 |
+
default: 'c++'
|
| 9 |
+
fuzz-seconds:
|
| 10 |
+
description: 'The total time allotted for fuzzing in seconds.'
|
| 11 |
+
required: true
|
| 12 |
+
default: 600
|
| 13 |
+
dry-run:
|
| 14 |
+
description: 'If set, run the action without actually reporting a failure.'
|
| 15 |
+
default: false
|
| 16 |
+
sanitizer:
|
| 17 |
+
description: 'The sanitizer to run the fuzzers with.'
|
| 18 |
+
default: 'address'
|
| 19 |
+
mode:
|
| 20 |
+
description: |
|
| 21 |
+
The mode to run the fuzzers with ("code-change", "batch", "coverage", or "prune").
|
| 22 |
+
"code-change" is for fuzzing a pull request or commit.
|
| 23 |
+
"batch" is for non-interactive fuzzing of an entire project.
|
| 24 |
+
"coverage" is for coverage generation.
|
| 25 |
+
"prune" is for corpus pruning.
|
| 26 |
+
required: false
|
| 27 |
+
default: 'code-change'
|
| 28 |
+
github-token:
|
| 29 |
+
description: |
|
| 30 |
+
Token for GitHub API. WARNING: THIS SHOULD NOT BE USED IN PRODUCTION YET
|
| 31 |
+
You should use "secrets.GITHUB_TOKEN" in your workflow file, do not
|
| 32 |
+
hardcode the token.
|
| 33 |
+
TODO(https://github.com/google/oss-fuzz/pull/5841#discussion_r639393361):
|
| 34 |
+
Document locking this down.
|
| 35 |
+
required: true
|
| 36 |
+
storage-repo:
|
| 37 |
+
description: |
|
| 38 |
+
The git repo to use for storing certain artifacts from fuzzing.
|
| 39 |
+
required: false
|
| 40 |
+
storage-repo-branch:
|
| 41 |
+
description: |
|
| 42 |
+
The branch of the git repo to use for storing certain artifacts from
|
| 43 |
+
fuzzing.
|
| 44 |
+
default: main
|
| 45 |
+
required: false
|
| 46 |
+
storage-repo-branch-coverage:
|
| 47 |
+
description: |
|
| 48 |
+
The branch of the git repo to use for storing coverage reports.
|
| 49 |
+
default: gh-pages
|
| 50 |
+
required: false
|
| 51 |
+
report-unreproducible-crashes:
|
| 52 |
+
description: 'If True, then unreproducible crashes will be reported.'
|
| 53 |
+
required: false
|
| 54 |
+
default: false
|
| 55 |
+
minimize-crashes:
|
| 56 |
+
description: 'If True, reportable crashes will be minimized.'
|
| 57 |
+
required: false
|
| 58 |
+
default: False
|
| 59 |
+
parallel-fuzzing:
|
| 60 |
+
description: "Whether to use all available cores for fuzzing."
|
| 61 |
+
required: false
|
| 62 |
+
default: false
|
| 63 |
+
output-sarif:
|
| 64 |
+
description: "Whether to output fuzzing results to SARIF."
|
| 65 |
+
required: false
|
| 66 |
+
default: false
|
| 67 |
+
report-timeouts:
|
| 68 |
+
description: "Whether to report fails due to timeout."
|
| 69 |
+
required: false
|
| 70 |
+
default: true
|
| 71 |
+
report-ooms:
|
| 72 |
+
description: "Whether to report fails due to OOM."
|
| 73 |
+
required: false
|
| 74 |
+
default: true
|
| 75 |
+
runs:
|
| 76 |
+
using: 'docker'
|
| 77 |
+
image: '../../../run_fuzzers.Dockerfile'
|
| 78 |
+
env:
|
| 79 |
+
OSS_FUZZ_PROJECT_NAME: ${{ inputs.oss-fuzz-project-name }}
|
| 80 |
+
LANGUAGE: ${{ inputs.language }}
|
| 81 |
+
FUZZ_SECONDS: ${{ inputs.fuzz-seconds }}
|
| 82 |
+
DRY_RUN: ${{ inputs.dry-run}}
|
| 83 |
+
SANITIZER: ${{ inputs.sanitizer }}
|
| 84 |
+
MODE: ${{ inputs.mode }}
|
| 85 |
+
GITHUB_TOKEN: ${{ inputs.github-token }}
|
| 86 |
+
LOW_DISK_SPACE: 'True'
|
| 87 |
+
GIT_STORE_REPO: ${{ inputs.storage-repo }}
|
| 88 |
+
GIT_STORE_BRANCH: ${{ inputs.storage-repo-branch }}
|
| 89 |
+
GIT_STORE_BRANCH_COVERAGE: ${{ inputs.storage-repo-branch-coverage }}
|
| 90 |
+
REPORT_UNREPRODUCIBLE_CRASHES: ${{ inputs.report-unreproducible-crashes }}
|
| 91 |
+
MINIMIZE_CRASHES: ${{ inputs.minimize-crashes }}
|
| 92 |
+
CIFUZZ_DEBUG: 'True'
|
| 93 |
+
CFL_PLATFORM: 'github'
|
| 94 |
+
PARALLEL_FUZZING: ${{ inputs.parallel-fuzzing }}
|
| 95 |
+
OUTPUT_SARIF: ${{ inputs.output-sarif }}
|
| 96 |
+
REPORT_TIMEOUTS: ${{ inputs.report-timeouts }}
|
| 97 |
+
REPORT_OOMS: ${{ inputs.report-ooms}}
|
local-test-tika-full-01-vuln_7/fuzz-tooling/infra/cifuzz/filestore/__init__.py
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2021 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
"""Module for a generic filestore."""
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
class FilestoreError(Exception):
|
| 18 |
+
"""Error using the filestore."""
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
# pylint: disable=unused-argument,no-self-use
|
| 22 |
+
class BaseFilestore:
|
| 23 |
+
"""Base class for a filestore."""
|
| 24 |
+
|
| 25 |
+
def __init__(self, config):
|
| 26 |
+
self.config = config
|
| 27 |
+
|
| 28 |
+
def upload_crashes(self, name, directory):
|
| 29 |
+
"""Uploads the crashes at |directory| to |name|."""
|
| 30 |
+
raise NotImplementedError('Child class must implement method.')
|
| 31 |
+
|
| 32 |
+
def upload_corpus(self, name, directory, replace=False):
|
| 33 |
+
"""Uploads the corpus at |directory| to |name|."""
|
| 34 |
+
raise NotImplementedError('Child class must implement method.')
|
| 35 |
+
|
| 36 |
+
def upload_build(self, name, directory):
|
| 37 |
+
"""Uploads the build at |directory| to |name|."""
|
| 38 |
+
raise NotImplementedError('Child class must implement method.')
|
| 39 |
+
|
| 40 |
+
def upload_coverage(self, name, directory):
|
| 41 |
+
"""Uploads the coverage report at |directory| to |name|."""
|
| 42 |
+
raise NotImplementedError('Child class must implement method.')
|
| 43 |
+
|
| 44 |
+
def download_corpus(self, name, dst_directory):
|
| 45 |
+
"""Downloads the corpus located at |name| to |dst_directory|."""
|
| 46 |
+
raise NotImplementedError('Child class must implement method.')
|
| 47 |
+
|
| 48 |
+
def download_build(self, name, dst_directory):
|
| 49 |
+
"""Downloads the build with |name| to |dst_directory|."""
|
| 50 |
+
raise NotImplementedError('Child class must implement method.')
|
| 51 |
+
|
| 52 |
+
def download_coverage(self, name, dst_directory):
|
| 53 |
+
"""Downloads the latest project coverage report."""
|
| 54 |
+
raise NotImplementedError('Child class must implement method.')
|
local-test-tika-full-01-vuln_7/fuzz-tooling/infra/cifuzz/filestore/filesystem/__init__.py
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2022 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
"""Filestore implementation using a filesystem directory."""
|
| 15 |
+
import logging
|
| 16 |
+
import os
|
| 17 |
+
import shutil
|
| 18 |
+
import subprocess
|
| 19 |
+
import sys
|
| 20 |
+
|
| 21 |
+
from distutils import dir_util
|
| 22 |
+
|
| 23 |
+
# pylint: disable=wrong-import-position,import-error
|
| 24 |
+
sys.path.append(
|
| 25 |
+
os.path.join(os.path.dirname(os.path.abspath(__file__)), os.pardir,
|
| 26 |
+
os.pardir, os.pardir))
|
| 27 |
+
import filestore
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
def recursive_list_dir(directory):
|
| 31 |
+
"""Returns list of all files in |directory|, including those in
|
| 32 |
+
subdirectories."""
|
| 33 |
+
files = []
|
| 34 |
+
for root, _, filenames in os.walk(directory):
|
| 35 |
+
for filename in filenames:
|
| 36 |
+
files.append(os.path.join(root, filename))
|
| 37 |
+
return files
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
class FilesystemFilestore(filestore.BaseFilestore):
|
| 41 |
+
"""Filesystem implementation using a filesystem directory."""
|
| 42 |
+
BUILD_DIR = 'build'
|
| 43 |
+
CRASHES_DIR = 'crashes'
|
| 44 |
+
CORPUS_DIR = 'corpus'
|
| 45 |
+
COVERAGE_DIR = 'coverage'
|
| 46 |
+
|
| 47 |
+
def __init__(self, config):
|
| 48 |
+
super().__init__(config)
|
| 49 |
+
self._filestore_root_dir = self.config.platform_conf.filestore_root_dir
|
| 50 |
+
|
| 51 |
+
def _get_filestore_path(self, name, prefix_dir):
|
| 52 |
+
"""Returns the filesystem path in the filestore for |name| and
|
| 53 |
+
|prefix_dir|."""
|
| 54 |
+
return os.path.join(self._filestore_root_dir, prefix_dir, name)
|
| 55 |
+
|
| 56 |
+
def _upload_directory(self, name, directory, prefix, delete=False):
|
| 57 |
+
filestore_path = self._get_filestore_path(name, prefix)
|
| 58 |
+
if os.path.exists(filestore_path):
|
| 59 |
+
initial_files = set(recursive_list_dir(filestore_path))
|
| 60 |
+
else:
|
| 61 |
+
initial_files = set()
|
| 62 |
+
|
| 63 |
+
# Make directory and any parents.
|
| 64 |
+
os.makedirs(filestore_path, exist_ok=True)
|
| 65 |
+
copied_files = set(dir_util.copy_tree(directory, filestore_path))
|
| 66 |
+
if not delete:
|
| 67 |
+
return True
|
| 68 |
+
|
| 69 |
+
files_to_delete = initial_files - copied_files
|
| 70 |
+
for file_path in files_to_delete:
|
| 71 |
+
os.remove(file_path)
|
| 72 |
+
return True
|
| 73 |
+
|
| 74 |
+
def _download_directory(self, name, dst_directory, prefix):
|
| 75 |
+
filestore_path = self._get_filestore_path(name, prefix)
|
| 76 |
+
return dir_util.copy_tree(filestore_path, dst_directory)
|
| 77 |
+
|
| 78 |
+
def upload_crashes(self, name, directory):
|
| 79 |
+
"""Uploads the crashes at |directory| to |name|."""
|
| 80 |
+
return self._upload_directory(name, directory, self.CRASHES_DIR)
|
| 81 |
+
|
| 82 |
+
def upload_corpus(self, name, directory, replace=False):
|
| 83 |
+
"""Uploads the crashes at |directory| to |name|."""
|
| 84 |
+
return self._upload_directory(name,
|
| 85 |
+
directory,
|
| 86 |
+
self.CORPUS_DIR,
|
| 87 |
+
delete=replace)
|
| 88 |
+
|
| 89 |
+
def upload_build(self, name, directory):
|
| 90 |
+
"""Uploads the build located at |directory| to |name|."""
|
| 91 |
+
return self._upload_directory(name, directory, self.BUILD_DIR)
|
| 92 |
+
|
| 93 |
+
def upload_coverage(self, name, directory):
|
| 94 |
+
"""Uploads the coverage report at |directory| to |name|."""
|
| 95 |
+
return self._upload_directory(name, directory, self.COVERAGE_DIR)
|
| 96 |
+
|
| 97 |
+
def download_corpus(self, name, dst_directory):
|
| 98 |
+
"""Downloads the corpus located at |name| to |dst_directory|."""
|
| 99 |
+
return self._download_directory(name, dst_directory, self.CORPUS_DIR)
|
| 100 |
+
|
| 101 |
+
def download_build(self, name, dst_directory):
|
| 102 |
+
"""Downloads the build with |name| to |dst_directory|."""
|
| 103 |
+
return self._download_directory(name, dst_directory, self.BUILD_DIR)
|
| 104 |
+
|
| 105 |
+
def download_coverage(self, name, dst_directory):
|
| 106 |
+
"""Downloads the latest project coverage report."""
|
| 107 |
+
return self._download_directory(name, dst_directory, self.COVERAGE_DIR)
|
local-test-tika-full-01-vuln_7/fuzz-tooling/infra/cifuzz/filestore/git/__init__.py
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2021 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
"""Module for a git based filestore."""
|
| 15 |
+
|
| 16 |
+
import logging
|
| 17 |
+
import os
|
| 18 |
+
import shutil
|
| 19 |
+
import subprocess
|
| 20 |
+
import sys
|
| 21 |
+
import tempfile
|
| 22 |
+
|
| 23 |
+
import filestore
|
| 24 |
+
|
| 25 |
+
# pylint: disable=wrong-import-position
|
| 26 |
+
INFRA_DIR = os.path.dirname(
|
| 27 |
+
os.path.dirname(os.path.dirname(os.path.dirname(
|
| 28 |
+
os.path.abspath(__file__)))))
|
| 29 |
+
sys.path.append(INFRA_DIR)
|
| 30 |
+
|
| 31 |
+
import retry
|
| 32 |
+
|
| 33 |
+
_PUSH_RETRIES = 3
|
| 34 |
+
_PUSH_BACKOFF = 1
|
| 35 |
+
_GIT_EMAIL = 'cifuzz@clusterfuzz.com'
|
| 36 |
+
_GIT_NAME = 'CIFuzz'
|
| 37 |
+
_CORPUS_DIR = 'corpus'
|
| 38 |
+
_COVERAGE_DIR = 'coverage'
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
def git_runner(repo_path):
|
| 42 |
+
"""Returns a gits runner for the repo_path."""
|
| 43 |
+
|
| 44 |
+
def func(*args):
|
| 45 |
+
return subprocess.check_call(('git', '-C', repo_path) + args)
|
| 46 |
+
|
| 47 |
+
return func
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
# pylint: disable=unused-argument,no-self-use
|
| 51 |
+
class GitFilestore(filestore.BaseFilestore):
|
| 52 |
+
"""Generic git filestore. This still relies on another filestore provided by
|
| 53 |
+
the CI for larger artifacts or artifacts which make sense to be included as
|
| 54 |
+
the result of a workflow run."""
|
| 55 |
+
|
| 56 |
+
def __init__(self, config, ci_filestore):
|
| 57 |
+
super().__init__(config)
|
| 58 |
+
self.repo_path = tempfile.mkdtemp()
|
| 59 |
+
self._git = git_runner(self.repo_path)
|
| 60 |
+
self._clone(self.config.git_store_repo)
|
| 61 |
+
|
| 62 |
+
self._ci_filestore = ci_filestore
|
| 63 |
+
|
| 64 |
+
def __del__(self):
|
| 65 |
+
shutil.rmtree(self.repo_path)
|
| 66 |
+
|
| 67 |
+
def _clone(self, repo_url):
|
| 68 |
+
"""Clones repo URL."""
|
| 69 |
+
self._git('clone', repo_url, '.')
|
| 70 |
+
self._git('config', '--local', 'user.email', _GIT_EMAIL)
|
| 71 |
+
self._git('config', '--local', 'user.name', _GIT_NAME)
|
| 72 |
+
|
| 73 |
+
def _reset_git(self, branch):
|
| 74 |
+
"""Resets the git repo."""
|
| 75 |
+
self._git('fetch', 'origin')
|
| 76 |
+
try:
|
| 77 |
+
self._git('checkout', '-B', branch, 'origin/' + branch)
|
| 78 |
+
self._git('reset', '--hard', 'HEAD')
|
| 79 |
+
except subprocess.CalledProcessError:
|
| 80 |
+
self._git('checkout', '--orphan', branch)
|
| 81 |
+
|
| 82 |
+
self._git('clean', '-fxd')
|
| 83 |
+
|
| 84 |
+
# pylint: disable=too-many-arguments
|
| 85 |
+
@retry.wrap(_PUSH_RETRIES, _PUSH_BACKOFF)
|
| 86 |
+
def _upload_to_git(self,
|
| 87 |
+
message,
|
| 88 |
+
branch,
|
| 89 |
+
upload_path,
|
| 90 |
+
local_path,
|
| 91 |
+
replace=False):
|
| 92 |
+
"""Uploads a directory to git. If `replace` is True, then existing contents
|
| 93 |
+
in the upload_path is deleted."""
|
| 94 |
+
self._reset_git(branch)
|
| 95 |
+
|
| 96 |
+
full_repo_path = os.path.join(self.repo_path, upload_path)
|
| 97 |
+
if replace and os.path.exists(full_repo_path):
|
| 98 |
+
shutil.rmtree(full_repo_path)
|
| 99 |
+
|
| 100 |
+
shutil.copytree(local_path, full_repo_path, dirs_exist_ok=True)
|
| 101 |
+
self._git('add', '.')
|
| 102 |
+
try:
|
| 103 |
+
self._git('commit', '-m', message)
|
| 104 |
+
except subprocess.CalledProcessError:
|
| 105 |
+
logging.debug('No changes, skipping git push.')
|
| 106 |
+
return
|
| 107 |
+
|
| 108 |
+
self._git('push', 'origin', branch)
|
| 109 |
+
|
| 110 |
+
def upload_crashes(self, name, directory):
|
| 111 |
+
"""Uploads the crashes at |directory| to |name|."""
|
| 112 |
+
return self._ci_filestore.upload_crashes(name, directory)
|
| 113 |
+
|
| 114 |
+
def upload_corpus(self, name, directory, replace=False):
|
| 115 |
+
"""Uploads the corpus at |directory| to |name|."""
|
| 116 |
+
self._upload_to_git('Corpus upload',
|
| 117 |
+
self.config.git_store_branch,
|
| 118 |
+
os.path.join(_CORPUS_DIR, name),
|
| 119 |
+
directory,
|
| 120 |
+
replace=replace)
|
| 121 |
+
|
| 122 |
+
def upload_build(self, name, directory):
|
| 123 |
+
"""Uploads the build at |directory| to |name|."""
|
| 124 |
+
return self._ci_filestore.upload_build(name, directory)
|
| 125 |
+
|
| 126 |
+
def upload_coverage(self, name, directory):
|
| 127 |
+
"""Uploads the coverage report at |directory| to |name|."""
|
| 128 |
+
self._upload_to_git('Coverage upload',
|
| 129 |
+
self.config.git_store_branch_coverage,
|
| 130 |
+
os.path.join(_COVERAGE_DIR, name),
|
| 131 |
+
directory,
|
| 132 |
+
replace=True)
|
| 133 |
+
|
| 134 |
+
def download_corpus(self, name, dst_directory):
|
| 135 |
+
"""Downloads the corpus located at |name| to |dst_directory|."""
|
| 136 |
+
self._reset_git(self.config.git_store_branch)
|
| 137 |
+
path = os.path.join(self.repo_path, _CORPUS_DIR, name)
|
| 138 |
+
if not os.path.exists(path):
|
| 139 |
+
logging.debug('Corpus does not exist at %s.', path)
|
| 140 |
+
return False
|
| 141 |
+
|
| 142 |
+
shutil.copytree(path, dst_directory, dirs_exist_ok=True)
|
| 143 |
+
return True
|
| 144 |
+
|
| 145 |
+
def download_build(self, name, dst_directory):
|
| 146 |
+
"""Downloads the build with |name| to |dst_directory|."""
|
| 147 |
+
return self._ci_filestore.download_build(name, dst_directory)
|
| 148 |
+
|
| 149 |
+
def download_coverage(self, name, dst_directory):
|
| 150 |
+
"""Downloads the latest project coverage report."""
|
| 151 |
+
self._reset_git(self.config.git_store_branch_coverage)
|
| 152 |
+
path = os.path.join(self.repo_path, _COVERAGE_DIR, name)
|
| 153 |
+
if not os.path.exists(path):
|
| 154 |
+
logging.debug('Coverage does not exist at %s.', path)
|
| 155 |
+
return False
|
| 156 |
+
|
| 157 |
+
shutil.copytree(path, dst_directory, dirs_exist_ok=True)
|
| 158 |
+
return True
|
local-test-tika-full-01-vuln_7/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_7/fuzz-tooling/infra/cifuzz/filestore/github_actions/__init__.py
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2021 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
"""Implementation of a filestore using Github actions artifacts."""
|
| 15 |
+
import logging
|
| 16 |
+
import os
|
| 17 |
+
import shutil
|
| 18 |
+
import sys
|
| 19 |
+
import tarfile
|
| 20 |
+
import tempfile
|
| 21 |
+
|
| 22 |
+
# pylint: disable=wrong-import-position,import-error
|
| 23 |
+
INFRA_DIR = os.path.abspath(
|
| 24 |
+
os.path.join(os.path.dirname(__file__), os.path.pardir, os.path.pardir,
|
| 25 |
+
os.path.pardir))
|
| 26 |
+
sys.path.append(INFRA_DIR)
|
| 27 |
+
OSS_FUZZ_ROOT_DIR = os.path.dirname(INFRA_DIR)
|
| 28 |
+
|
| 29 |
+
import utils
|
| 30 |
+
import http_utils
|
| 31 |
+
import filestore
|
| 32 |
+
from filestore.github_actions import github_api
|
| 33 |
+
|
| 34 |
+
UPLOAD_JS = os.path.join(os.path.dirname(__file__), 'upload.js')
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
def tar_directory(directory, archive_path):
|
| 38 |
+
"""Tars a |directory| and stores archive at |archive_path|. |archive_path|
|
| 39 |
+
must end in .tar"""
|
| 40 |
+
assert archive_path.endswith('.tar')
|
| 41 |
+
# Do this because make_archive will append the extension to archive_path.
|
| 42 |
+
archive_path = os.path.splitext(archive_path)[0]
|
| 43 |
+
|
| 44 |
+
root_directory = os.path.abspath(directory)
|
| 45 |
+
shutil.make_archive(archive_path,
|
| 46 |
+
'tar',
|
| 47 |
+
root_dir=root_directory,
|
| 48 |
+
base_dir='./')
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
class GithubActionsFilestore(filestore.BaseFilestore):
|
| 52 |
+
"""Implementation of BaseFilestore using Github actions artifacts. Relies on
|
| 53 |
+
github_actions_toolkit for using the GitHub actions API and the github_api
|
| 54 |
+
module for using GitHub's standard API. We need to use both because the GitHub
|
| 55 |
+
actions API is the only way to upload an artifact but it does not support
|
| 56 |
+
downloading artifacts from other runs. The standard GitHub API does support
|
| 57 |
+
this however."""
|
| 58 |
+
|
| 59 |
+
ARTIFACT_PREFIX = 'cifuzz-'
|
| 60 |
+
BUILD_PREFIX = 'build-'
|
| 61 |
+
CRASHES_PREFIX = 'crashes-'
|
| 62 |
+
CORPUS_PREFIX = 'corpus-'
|
| 63 |
+
COVERAGE_PREFIX = 'coverage-'
|
| 64 |
+
|
| 65 |
+
def __init__(self, config):
|
| 66 |
+
super().__init__(config)
|
| 67 |
+
self.github_api_http_headers = github_api.get_http_auth_headers(config)
|
| 68 |
+
|
| 69 |
+
def _get_artifact_name(self, name):
|
| 70 |
+
"""Returns |name| prefixed with |self.ARITFACT_PREFIX| if it isn't already
|
| 71 |
+
prefixed. Otherwise returns |name|."""
|
| 72 |
+
if name.startswith(self.ARTIFACT_PREFIX):
|
| 73 |
+
return name
|
| 74 |
+
return f'{self.ARTIFACT_PREFIX}{name}'
|
| 75 |
+
|
| 76 |
+
def _upload_directory(self, name, directory): # pylint: disable=no-self-use
|
| 77 |
+
"""Uploads |directory| as artifact with |name|."""
|
| 78 |
+
name = self._get_artifact_name(name)
|
| 79 |
+
with tempfile.TemporaryDirectory() as temp_dir:
|
| 80 |
+
archive_path = os.path.join(temp_dir, name + '.tar')
|
| 81 |
+
tar_directory(directory, archive_path)
|
| 82 |
+
_raw_upload_directory(name, temp_dir)
|
| 83 |
+
|
| 84 |
+
def upload_crashes(self, name, directory):
|
| 85 |
+
"""Uploads the crashes at |directory| to |name|."""
|
| 86 |
+
return _raw_upload_directory(self.CRASHES_PREFIX + name, directory)
|
| 87 |
+
|
| 88 |
+
def upload_corpus(self, name, directory, replace=False):
|
| 89 |
+
"""Uploads the corpus at |directory| to |name|."""
|
| 90 |
+
# Not applicable as the the entire corpus is uploaded under a single
|
| 91 |
+
# artifact name.
|
| 92 |
+
del replace
|
| 93 |
+
return self._upload_directory(self.CORPUS_PREFIX + name, directory)
|
| 94 |
+
|
| 95 |
+
def upload_build(self, name, directory):
|
| 96 |
+
"""Uploads the build at |directory| to |name|."""
|
| 97 |
+
return self._upload_directory(self.BUILD_PREFIX + name, directory)
|
| 98 |
+
|
| 99 |
+
def upload_coverage(self, name, directory):
|
| 100 |
+
"""Uploads the coverage report at |directory| to |name|."""
|
| 101 |
+
return self._upload_directory(self.COVERAGE_PREFIX + name, directory)
|
| 102 |
+
|
| 103 |
+
def download_corpus(self, name, dst_directory): # pylint: disable=unused-argument,no-self-use
|
| 104 |
+
"""Downloads the corpus located at |name| to |dst_directory|."""
|
| 105 |
+
return self._download_artifact(self.CORPUS_PREFIX + name, dst_directory)
|
| 106 |
+
|
| 107 |
+
def _find_artifact(self, name):
|
| 108 |
+
"""Finds an artifact using the GitHub API and returns it."""
|
| 109 |
+
logging.debug('Listing artifacts.')
|
| 110 |
+
artifacts = self._list_artifacts()
|
| 111 |
+
artifact = github_api.find_artifact(name, artifacts)
|
| 112 |
+
logging.debug('Artifact: %s.', artifact)
|
| 113 |
+
return artifact
|
| 114 |
+
|
| 115 |
+
def _download_artifact(self, name, dst_directory):
|
| 116 |
+
"""Downloads artifact with |name| to |dst_directory|. Returns True on
|
| 117 |
+
success."""
|
| 118 |
+
name = self._get_artifact_name(name)
|
| 119 |
+
|
| 120 |
+
with tempfile.TemporaryDirectory() as temp_dir:
|
| 121 |
+
if not self._raw_download_artifact(name, temp_dir):
|
| 122 |
+
logging.warning('Could not download artifact: %s.', name)
|
| 123 |
+
return False
|
| 124 |
+
|
| 125 |
+
artifact_tarfile_path = os.path.join(temp_dir, name + '.tar')
|
| 126 |
+
if not os.path.exists(artifact_tarfile_path):
|
| 127 |
+
logging.error('Artifact zip did not contain a tarfile.')
|
| 128 |
+
return False
|
| 129 |
+
|
| 130 |
+
# TODO(jonathanmetzman): Replace this with archive.unpack from
|
| 131 |
+
# libClusterFuzz so we can avoid path traversal issues.
|
| 132 |
+
with tarfile.TarFile(artifact_tarfile_path) as artifact_tarfile:
|
| 133 |
+
artifact_tarfile.extractall(dst_directory)
|
| 134 |
+
return True
|
| 135 |
+
|
| 136 |
+
def _raw_download_artifact(self, name, dst_directory):
|
| 137 |
+
"""Downloads the artifact with |name| to |dst_directory|. Returns True on
|
| 138 |
+
success. Does not do any untarring or adding prefix to |name|."""
|
| 139 |
+
artifact = self._find_artifact(name)
|
| 140 |
+
if not artifact:
|
| 141 |
+
logging.warning('Could not find artifact: %s.', name)
|
| 142 |
+
return False
|
| 143 |
+
download_url = artifact['archive_download_url']
|
| 144 |
+
return http_utils.download_and_unpack_zip(
|
| 145 |
+
download_url, dst_directory, headers=self.github_api_http_headers)
|
| 146 |
+
|
| 147 |
+
def _list_artifacts(self):
|
| 148 |
+
"""Returns a list of artifacts."""
|
| 149 |
+
return github_api.list_artifacts(self.config.project_repo_owner,
|
| 150 |
+
self.config.project_repo_name,
|
| 151 |
+
self.github_api_http_headers)
|
| 152 |
+
|
| 153 |
+
def download_build(self, name, dst_directory):
|
| 154 |
+
"""Downloads the build with name |name| to |dst_directory|."""
|
| 155 |
+
return self._download_artifact(self.BUILD_PREFIX + name, dst_directory)
|
| 156 |
+
|
| 157 |
+
def download_coverage(self, name, dst_directory):
|
| 158 |
+
"""Downloads the latest project coverage report."""
|
| 159 |
+
return self._download_artifact(self.COVERAGE_PREFIX + name, dst_directory)
|
| 160 |
+
|
| 161 |
+
|
| 162 |
+
def _upload_artifact_with_upload_js(name, artifact_paths, directory):
|
| 163 |
+
"""Uploads the artifacts in |artifact_paths| that are located in |directory|
|
| 164 |
+
to |name|, using the upload.js script."""
|
| 165 |
+
command = [UPLOAD_JS, name, directory] + artifact_paths
|
| 166 |
+
_, _, retcode = utils.execute(command, location=OSS_FUZZ_ROOT_DIR)
|
| 167 |
+
return retcode == 0
|
| 168 |
+
|
| 169 |
+
|
| 170 |
+
def _raw_upload_directory(name, directory):
|
| 171 |
+
"""Uploads the artifacts located in |directory| to |name|. Does not do any
|
| 172 |
+
tarring or adding prefixes to |name|."""
|
| 173 |
+
# Get file paths.
|
| 174 |
+
artifact_paths = []
|
| 175 |
+
for root, _, curr_file_paths in os.walk(directory):
|
| 176 |
+
for file_path in curr_file_paths:
|
| 177 |
+
artifact_paths.append(os.path.join(root, file_path))
|
| 178 |
+
logging.debug('Artifact paths: %s.', artifact_paths)
|
| 179 |
+
return _upload_artifact_with_upload_js(name, artifact_paths, directory)
|
local-test-tika-full-01-vuln_7/fuzz-tooling/infra/cifuzz/filestore/github_actions/github_actions_test.py
ADDED
|
@@ -0,0 +1,283 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2021 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
"""Tests for github_actions."""
|
| 15 |
+
import os
|
| 16 |
+
import shutil
|
| 17 |
+
import sys
|
| 18 |
+
import tarfile
|
| 19 |
+
import tempfile
|
| 20 |
+
import unittest
|
| 21 |
+
from unittest import mock
|
| 22 |
+
|
| 23 |
+
from pyfakefs import fake_filesystem_unittest
|
| 24 |
+
|
| 25 |
+
# pylint: disable=wrong-import-position
|
| 26 |
+
INFRA_DIR = os.path.dirname(
|
| 27 |
+
os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
| 28 |
+
sys.path.append(INFRA_DIR)
|
| 29 |
+
|
| 30 |
+
from filestore import github_actions
|
| 31 |
+
import test_helpers
|
| 32 |
+
|
| 33 |
+
# pylint: disable=protected-access,no-self-use
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
class GithubActionsFilestoreTest(fake_filesystem_unittest.TestCase):
|
| 37 |
+
"""Tests for GithubActionsFilestore."""
|
| 38 |
+
|
| 39 |
+
@mock.patch('platform_config.github._get_event_data', return_value={})
|
| 40 |
+
def setUp(self, _): # pylint: disable=arguments-differ
|
| 41 |
+
test_helpers.patch_environ(self)
|
| 42 |
+
self.token = 'example githubtoken'
|
| 43 |
+
self.owner = 'exampleowner'
|
| 44 |
+
self.repo = 'examplerepo'
|
| 45 |
+
os.environ['GITHUB_REPOSITORY'] = f'{self.owner}/{self.repo}'
|
| 46 |
+
os.environ['GITHUB_EVENT_PATH'] = '/fake'
|
| 47 |
+
os.environ['CFL_PLATFORM'] = 'github'
|
| 48 |
+
os.environ['GITHUB_WORKSPACE'] = '/workspace'
|
| 49 |
+
self.config = test_helpers.create_run_config(token=self.token)
|
| 50 |
+
self.local_dir = '/local-dir'
|
| 51 |
+
self.testcase = os.path.join(self.local_dir, 'testcase')
|
| 52 |
+
|
| 53 |
+
def _get_expected_http_headers(self):
|
| 54 |
+
return {
|
| 55 |
+
'Authorization': f'token {self.token}',
|
| 56 |
+
'Accept': 'application/vnd.github.v3+json',
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
@mock.patch('filestore.github_actions.github_api.list_artifacts')
|
| 60 |
+
def test_list_artifacts(self, mock_list_artifacts):
|
| 61 |
+
"""Tests that _list_artifacts works as intended."""
|
| 62 |
+
filestore = github_actions.GithubActionsFilestore(self.config)
|
| 63 |
+
filestore._list_artifacts()
|
| 64 |
+
mock_list_artifacts.assert_called_with(self.owner, self.repo,
|
| 65 |
+
self._get_expected_http_headers())
|
| 66 |
+
|
| 67 |
+
@mock.patch('logging.warning')
|
| 68 |
+
@mock.patch('filestore.github_actions.GithubActionsFilestore._list_artifacts',
|
| 69 |
+
return_value=None)
|
| 70 |
+
@mock.patch('filestore.github_actions.github_api.find_artifact',
|
| 71 |
+
return_value=None)
|
| 72 |
+
def test_download_build_no_artifact(self, _, __, mock_warning):
|
| 73 |
+
"""Tests that download_build returns None and doesn't exception when
|
| 74 |
+
find_artifact can't find an artifact."""
|
| 75 |
+
filestore = github_actions.GithubActionsFilestore(self.config)
|
| 76 |
+
name = 'name'
|
| 77 |
+
build_dir = 'build-dir'
|
| 78 |
+
self.assertFalse(filestore.download_build(name, build_dir))
|
| 79 |
+
mock_warning.assert_called_with('Could not download artifact: %s.',
|
| 80 |
+
'cifuzz-build-' + name)
|
| 81 |
+
|
| 82 |
+
@mock.patch('logging.warning')
|
| 83 |
+
@mock.patch('filestore.github_actions.GithubActionsFilestore._list_artifacts',
|
| 84 |
+
return_value=None)
|
| 85 |
+
@mock.patch('filestore.github_actions.github_api.find_artifact',
|
| 86 |
+
return_value=None)
|
| 87 |
+
def test_download_corpus_no_artifact(self, _, __, mock_warning):
|
| 88 |
+
"""Tests that download_corpus_build returns None and doesn't exception when
|
| 89 |
+
find_artifact can't find an artifact."""
|
| 90 |
+
filestore = github_actions.GithubActionsFilestore(self.config)
|
| 91 |
+
name = 'name'
|
| 92 |
+
dst_dir = 'local-dir'
|
| 93 |
+
self.assertFalse(filestore.download_corpus(name, dst_dir))
|
| 94 |
+
mock_warning.assert_called_with('Could not download artifact: %s.',
|
| 95 |
+
'cifuzz-corpus-' + name)
|
| 96 |
+
|
| 97 |
+
@mock.patch('filestore.github_actions.tar_directory')
|
| 98 |
+
@mock.patch('filestore.github_actions._upload_artifact_with_upload_js')
|
| 99 |
+
def test_upload_corpus(self, mock_upload_artifact, mock_tar_directory):
|
| 100 |
+
"""Test uploading corpus."""
|
| 101 |
+
self._create_local_dir()
|
| 102 |
+
|
| 103 |
+
def mock_tar_directory_impl(_, archive_path):
|
| 104 |
+
self.fs.create_file(archive_path)
|
| 105 |
+
|
| 106 |
+
mock_tar_directory.side_effect = mock_tar_directory_impl
|
| 107 |
+
|
| 108 |
+
filestore = github_actions.GithubActionsFilestore(self.config)
|
| 109 |
+
filestore.upload_corpus('target', self.local_dir)
|
| 110 |
+
self.assert_upload(mock_upload_artifact, mock_tar_directory,
|
| 111 |
+
'corpus-target')
|
| 112 |
+
|
| 113 |
+
@mock.patch('filestore.github_actions._upload_artifact_with_upload_js')
|
| 114 |
+
def test_upload_crashes(self, mock_upload_artifact):
|
| 115 |
+
"""Test uploading crashes."""
|
| 116 |
+
self._create_local_dir()
|
| 117 |
+
|
| 118 |
+
filestore = github_actions.GithubActionsFilestore(self.config)
|
| 119 |
+
filestore.upload_crashes('current', self.local_dir)
|
| 120 |
+
mock_upload_artifact.assert_has_calls(
|
| 121 |
+
[mock.call('crashes-current', ['/local-dir/testcase'], '/local-dir')])
|
| 122 |
+
|
| 123 |
+
@mock.patch('filestore.github_actions.tar_directory')
|
| 124 |
+
@mock.patch('filestore.github_actions._upload_artifact_with_upload_js')
|
| 125 |
+
def test_upload_build(self, mock_upload_artifact, mock_tar_directory):
|
| 126 |
+
"""Test uploading build."""
|
| 127 |
+
self._create_local_dir()
|
| 128 |
+
|
| 129 |
+
def mock_tar_directory_impl(_, archive_path):
|
| 130 |
+
self.fs.create_file(archive_path)
|
| 131 |
+
|
| 132 |
+
mock_tar_directory.side_effect = mock_tar_directory_impl
|
| 133 |
+
|
| 134 |
+
filestore = github_actions.GithubActionsFilestore(self.config)
|
| 135 |
+
filestore.upload_build('sanitizer', self.local_dir)
|
| 136 |
+
self.assert_upload(mock_upload_artifact, mock_tar_directory,
|
| 137 |
+
'build-sanitizer')
|
| 138 |
+
|
| 139 |
+
@mock.patch('filestore.github_actions.tar_directory')
|
| 140 |
+
@mock.patch('filestore.github_actions._upload_artifact_with_upload_js')
|
| 141 |
+
def test_upload_coverage(self, mock_upload_artifact, mock_tar_directory):
|
| 142 |
+
"""Test uploading coverage."""
|
| 143 |
+
self._create_local_dir()
|
| 144 |
+
|
| 145 |
+
def mock_tar_directory_impl(_, archive_path):
|
| 146 |
+
self.fs.create_file(archive_path)
|
| 147 |
+
|
| 148 |
+
mock_tar_directory.side_effect = mock_tar_directory_impl
|
| 149 |
+
|
| 150 |
+
filestore = github_actions.GithubActionsFilestore(self.config)
|
| 151 |
+
filestore.upload_coverage('latest', self.local_dir)
|
| 152 |
+
self.assert_upload(mock_upload_artifact, mock_tar_directory,
|
| 153 |
+
'coverage-latest')
|
| 154 |
+
|
| 155 |
+
def assert_upload(self, mock_upload_artifact, mock_tar_directory,
|
| 156 |
+
expected_artifact_name):
|
| 157 |
+
"""Tests that upload_directory invokes tar_directory and
|
| 158 |
+
artifact_client.upload_artifact properly."""
|
| 159 |
+
# Don't assert what second argument will be since it's a temporary
|
| 160 |
+
# directory.
|
| 161 |
+
self.assertEqual(mock_tar_directory.call_args_list[0][0][0], self.local_dir)
|
| 162 |
+
|
| 163 |
+
# Don't assert what second and third arguments will be since they are
|
| 164 |
+
# temporary directories.
|
| 165 |
+
expected_artifact_name = 'cifuzz-' + expected_artifact_name
|
| 166 |
+
self.assertEqual(mock_upload_artifact.call_args_list[0][0][0],
|
| 167 |
+
expected_artifact_name)
|
| 168 |
+
|
| 169 |
+
# Assert artifacts list contains one tarfile.
|
| 170 |
+
artifacts_list = mock_upload_artifact.call_args_list[0][0][1]
|
| 171 |
+
self.assertEqual(len(artifacts_list), 1)
|
| 172 |
+
self.assertEqual(os.path.basename(artifacts_list[0]),
|
| 173 |
+
expected_artifact_name + '.tar')
|
| 174 |
+
|
| 175 |
+
def _create_local_dir(self):
|
| 176 |
+
"""Sets up pyfakefs and creates a corpus directory containing
|
| 177 |
+
self.testcase."""
|
| 178 |
+
self.setUpPyfakefs()
|
| 179 |
+
self.fs.create_file(self.testcase, contents='hi')
|
| 180 |
+
|
| 181 |
+
@mock.patch('filestore.github_actions.GithubActionsFilestore._find_artifact')
|
| 182 |
+
@mock.patch('http_utils.download_and_unpack_zip')
|
| 183 |
+
def test_download_artifact(self, mock_download_and_unpack_zip,
|
| 184 |
+
mock_find_artifact):
|
| 185 |
+
"""Tests that _download_artifact works as intended."""
|
| 186 |
+
artifact_download_url = 'http://example.com/download'
|
| 187 |
+
artifact_listing = {
|
| 188 |
+
'expired': False,
|
| 189 |
+
'name': 'corpus',
|
| 190 |
+
'archive_download_url': artifact_download_url
|
| 191 |
+
}
|
| 192 |
+
mock_find_artifact.return_value = artifact_listing
|
| 193 |
+
|
| 194 |
+
self._create_local_dir()
|
| 195 |
+
with tempfile.TemporaryDirectory() as temp_dir:
|
| 196 |
+
# Create a tarball.
|
| 197 |
+
archive_path = os.path.join(temp_dir, 'cifuzz-corpus.tar')
|
| 198 |
+
github_actions.tar_directory(self.local_dir, archive_path)
|
| 199 |
+
|
| 200 |
+
artifact_download_dst_dir = os.path.join(temp_dir, 'dst')
|
| 201 |
+
os.mkdir(artifact_download_dst_dir)
|
| 202 |
+
|
| 203 |
+
def mock_download_and_unpack_zip_impl(url, download_artifact_temp_dir,
|
| 204 |
+
headers):
|
| 205 |
+
self.assertEqual(url, artifact_download_url)
|
| 206 |
+
self.assertEqual(headers, self._get_expected_http_headers())
|
| 207 |
+
shutil.copy(
|
| 208 |
+
archive_path,
|
| 209 |
+
os.path.join(download_artifact_temp_dir,
|
| 210 |
+
os.path.basename(archive_path)))
|
| 211 |
+
return True
|
| 212 |
+
|
| 213 |
+
mock_download_and_unpack_zip.side_effect = (
|
| 214 |
+
mock_download_and_unpack_zip_impl)
|
| 215 |
+
filestore = github_actions.GithubActionsFilestore(self.config)
|
| 216 |
+
self.assertTrue(
|
| 217 |
+
filestore._download_artifact('corpus', artifact_download_dst_dir))
|
| 218 |
+
mock_find_artifact.assert_called_with('cifuzz-corpus')
|
| 219 |
+
self.assertTrue(
|
| 220 |
+
os.path.exists(
|
| 221 |
+
os.path.join(artifact_download_dst_dir,
|
| 222 |
+
os.path.basename(self.testcase))))
|
| 223 |
+
|
| 224 |
+
@mock.patch('filestore.github_actions.github_api.list_artifacts')
|
| 225 |
+
def test_find_artifact(self, mock_list_artifacts):
|
| 226 |
+
"""Tests that _find_artifact works as intended."""
|
| 227 |
+
artifact_listing_1 = {
|
| 228 |
+
'expired': False,
|
| 229 |
+
'name': 'other',
|
| 230 |
+
'archive_download_url': 'http://download1'
|
| 231 |
+
}
|
| 232 |
+
artifact_listing_2 = {
|
| 233 |
+
'expired': False,
|
| 234 |
+
'name': 'artifact',
|
| 235 |
+
'archive_download_url': 'http://download2'
|
| 236 |
+
}
|
| 237 |
+
artifact_listing_3 = {
|
| 238 |
+
'expired': True,
|
| 239 |
+
'name': 'artifact',
|
| 240 |
+
'archive_download_url': 'http://download3'
|
| 241 |
+
}
|
| 242 |
+
artifact_listing_4 = {
|
| 243 |
+
'expired': False,
|
| 244 |
+
'name': 'artifact',
|
| 245 |
+
'archive_download_url': 'http://download4'
|
| 246 |
+
}
|
| 247 |
+
artifacts = [
|
| 248 |
+
artifact_listing_1, artifact_listing_2, artifact_listing_3,
|
| 249 |
+
artifact_listing_4
|
| 250 |
+
]
|
| 251 |
+
mock_list_artifacts.return_value = artifacts
|
| 252 |
+
filestore = github_actions.GithubActionsFilestore(self.config)
|
| 253 |
+
# Test that find_artifact will return the most recent unexpired artifact
|
| 254 |
+
# with the correct name.
|
| 255 |
+
self.assertEqual(filestore._find_artifact('artifact'), artifact_listing_2)
|
| 256 |
+
mock_list_artifacts.assert_called_with(self.owner, self.repo,
|
| 257 |
+
self._get_expected_http_headers())
|
| 258 |
+
|
| 259 |
+
|
| 260 |
+
class TarDirectoryTest(unittest.TestCase):
|
| 261 |
+
"""Tests for tar_directory."""
|
| 262 |
+
|
| 263 |
+
def test_tar_directory(self):
|
| 264 |
+
"""Tests that tar_directory writes the archive to the correct location and
|
| 265 |
+
archives properly."""
|
| 266 |
+
with tempfile.TemporaryDirectory() as temp_dir:
|
| 267 |
+
archive_path = os.path.join(temp_dir, 'myarchive.tar')
|
| 268 |
+
archived_dir = os.path.join(temp_dir, 'toarchive')
|
| 269 |
+
os.mkdir(archived_dir)
|
| 270 |
+
archived_filename = 'file1'
|
| 271 |
+
archived_file_path = os.path.join(archived_dir, archived_filename)
|
| 272 |
+
with open(archived_file_path, 'w') as file_handle:
|
| 273 |
+
file_handle.write('hi')
|
| 274 |
+
github_actions.tar_directory(archived_dir, archive_path)
|
| 275 |
+
self.assertTrue(os.path.exists(archive_path))
|
| 276 |
+
|
| 277 |
+
# Now check it archives correctly.
|
| 278 |
+
unpacked_directory = os.path.join(temp_dir, 'unpacked')
|
| 279 |
+
with tarfile.TarFile(archive_path) as artifact_tarfile:
|
| 280 |
+
artifact_tarfile.extractall(unpacked_directory)
|
| 281 |
+
unpacked_archived_file_path = os.path.join(unpacked_directory,
|
| 282 |
+
archived_filename)
|
| 283 |
+
self.assertTrue(os.path.exists(unpacked_archived_file_path))
|
local-test-tika-full-01-vuln_7/fuzz-tooling/infra/cifuzz/filestore/github_actions/github_api.py
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2021 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
"""Module for dealing with the GitHub API. This is different from
|
| 15 |
+
github_actions_toolkit which only deals with the actions API. We need to use
|
| 16 |
+
both."""
|
| 17 |
+
import logging
|
| 18 |
+
import os
|
| 19 |
+
import sys
|
| 20 |
+
|
| 21 |
+
import requests
|
| 22 |
+
|
| 23 |
+
import filestore
|
| 24 |
+
|
| 25 |
+
# pylint: disable=wrong-import-position,import-error
|
| 26 |
+
|
| 27 |
+
sys.path.append(
|
| 28 |
+
os.path.join(__file__, os.path.pardir, os.path.pardir, os.path.pardir,
|
| 29 |
+
os.path.pardir))
|
| 30 |
+
import retry
|
| 31 |
+
|
| 32 |
+
_MAX_ITEMS_PER_PAGE = 100
|
| 33 |
+
|
| 34 |
+
_GET_ATTEMPTS = 3
|
| 35 |
+
_GET_BACKOFF = 1
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
def get_http_auth_headers(config):
|
| 39 |
+
"""Returns HTTP headers for authentication to the API."""
|
| 40 |
+
authorization = f'token {config.token}'
|
| 41 |
+
return {
|
| 42 |
+
'Authorization': authorization,
|
| 43 |
+
'Accept': 'application/vnd.github.v3+json'
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
def _get_artifacts_list_api_url(repo_owner, repo_name):
|
| 48 |
+
"""Returns the artifacts_api_url for |repo_name| owned by |repo_owner|."""
|
| 49 |
+
github_api_url = os.getenv('GITHUB_API_URL', 'https://api.github.com')
|
| 50 |
+
return (f'{github_api_url}/repos/{repo_owner}/'
|
| 51 |
+
f'{repo_name}/actions/artifacts')
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
@retry.wrap(_GET_ATTEMPTS, _GET_BACKOFF)
|
| 55 |
+
def _do_get_request(*args, **kwargs):
|
| 56 |
+
"""Wrapped version of requests.get that does retries."""
|
| 57 |
+
return requests.get(*args, **kwargs)
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
def _get_items(url, headers):
|
| 61 |
+
"""Generator that gets and yields items from a GitHub API endpoint (specified
|
| 62 |
+
by |URL|) sending |headers| with the get request."""
|
| 63 |
+
# Github API response pages are 1-indexed.
|
| 64 |
+
page_counter = 1
|
| 65 |
+
|
| 66 |
+
# Set to infinity so we run loop at least once.
|
| 67 |
+
total_num_items = float('inf')
|
| 68 |
+
|
| 69 |
+
item_num = 0
|
| 70 |
+
while item_num < total_num_items:
|
| 71 |
+
params = {'per_page': _MAX_ITEMS_PER_PAGE, 'page': str(page_counter)}
|
| 72 |
+
response = _do_get_request(url, params=params, headers=headers)
|
| 73 |
+
response_json = response.json()
|
| 74 |
+
if not response.status_code == 200:
|
| 75 |
+
# Check that request was successful.
|
| 76 |
+
logging.error('Request to %s failed. Code: %d. Response: %s',
|
| 77 |
+
response.request.url, response.status_code, response_json)
|
| 78 |
+
raise filestore.FilestoreError('Github API request failed.')
|
| 79 |
+
|
| 80 |
+
if total_num_items == float('inf'):
|
| 81 |
+
# Set proper total_num_items
|
| 82 |
+
total_num_items = response_json['total_count']
|
| 83 |
+
|
| 84 |
+
# Get the key for the items we are after.
|
| 85 |
+
keys = [key for key in response_json.keys() if key != 'total_count']
|
| 86 |
+
assert len(keys) == 1, keys
|
| 87 |
+
items_key = keys[0]
|
| 88 |
+
|
| 89 |
+
for item in response_json[items_key]:
|
| 90 |
+
yield item
|
| 91 |
+
item_num += 1
|
| 92 |
+
|
| 93 |
+
page_counter += 1
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
def find_artifact(artifact_name, artifacts):
|
| 97 |
+
"""Find the artifact with the name |artifact_name| in |artifacts|."""
|
| 98 |
+
for artifact in artifacts:
|
| 99 |
+
# TODO(metzman): Handle multiple by making sure we download the latest.
|
| 100 |
+
if artifact['name'] == artifact_name and not artifact['expired']:
|
| 101 |
+
return artifact
|
| 102 |
+
return None
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
def list_artifacts(owner, repo, headers):
|
| 106 |
+
"""Returns a generator of all the artifacts for |owner|/|repo|."""
|
| 107 |
+
url = _get_artifacts_list_api_url(owner, repo)
|
| 108 |
+
logging.debug('Getting artifacts from: %s', url)
|
| 109 |
+
return _get_items(url, headers)
|
local-test-tika-full-01-vuln_7/fuzz-tooling/infra/cifuzz/filestore/github_actions/github_api_test.py
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2021 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
"""Tests for github_api."""
|
| 15 |
+
import os
|
| 16 |
+
import sys
|
| 17 |
+
import unittest
|
| 18 |
+
|
| 19 |
+
# pylint: disable=wrong-import-position,import-error
|
| 20 |
+
sys.path.append(
|
| 21 |
+
os.path.abspath(
|
| 22 |
+
os.path.join(os.path.dirname(__file__), os.path.pardir, os.path.pardir,
|
| 23 |
+
os.path.pardir)))
|
| 24 |
+
|
| 25 |
+
from filestore.github_actions import github_api
|
| 26 |
+
import test_helpers
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
class GetHttpAuthHeaders(unittest.TestCase):
|
| 30 |
+
"""Tests for get_http_auth_headers."""
|
| 31 |
+
|
| 32 |
+
def test_get_http_auth_headers(self):
|
| 33 |
+
"""Tests that get_http_auth_headers returns the correct result."""
|
| 34 |
+
token = 'example githubtoken'
|
| 35 |
+
run_config = test_helpers.create_run_config(token=token)
|
| 36 |
+
expected_headers = {
|
| 37 |
+
'Authorization': f'token {token}',
|
| 38 |
+
'Accept': 'application/vnd.github.v3+json',
|
| 39 |
+
}
|
| 40 |
+
self.assertEqual(expected_headers,
|
| 41 |
+
github_api.get_http_auth_headers(run_config))
|
local-test-tika-full-01-vuln_7/fuzz-tooling/infra/cifuzz/filestore/github_actions/upload.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env node
|
| 2 |
+
// Copyright 2021 Google LLC
|
| 3 |
+
//
|
| 4 |
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
// you may not use this file except in compliance with the License.
|
| 6 |
+
// You may obtain a copy of the License at
|
| 7 |
+
//
|
| 8 |
+
// http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
//
|
| 10 |
+
// Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
// See the License for the specific language governing permissions and
|
| 14 |
+
// limitations under the License.
|
| 15 |
+
// Script for uploading an artifact. Returns 0 on success.
|
| 16 |
+
// Usage: upload.js <artifactName> <rootDirectory> <file 1>...<file N>
|
| 17 |
+
|
| 18 |
+
const fs = require('fs');
|
| 19 |
+
const { DefaultArtifactClient } = require('@actions/artifact');
|
| 20 |
+
|
| 21 |
+
const artifactClient = new DefaultArtifactClient();
|
| 22 |
+
const artifactName = process.argv[2];
|
| 23 |
+
const rootDirectory = process.argv[3]
|
| 24 |
+
const files = process.argv.slice(4);
|
| 25 |
+
const options = {
|
| 26 |
+
continueOnError: true
|
| 27 |
+
};
|
| 28 |
+
|
| 29 |
+
async function uploadArtifact() {
|
| 30 |
+
try {
|
| 31 |
+
const uploadResult = await artifactClient.uploadArtifact(artifactName, files, rootDirectory, options);
|
| 32 |
+
console.log(uploadResult);
|
| 33 |
+
if (uploadResult.failedItems.length > 0) {
|
| 34 |
+
return 1;
|
| 35 |
+
}
|
| 36 |
+
return 0;
|
| 37 |
+
} catch (error) {
|
| 38 |
+
console.error('Error uploading artifact:', error);
|
| 39 |
+
return 1;
|
| 40 |
+
}
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
uploadArtifact().then(exitCode => {
|
| 44 |
+
process.exit(exitCode);
|
| 45 |
+
});
|
local-test-tika-full-01-vuln_7/fuzz-tooling/infra/cifuzz/filestore/gitlab/__init__.py
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2022 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
"""GitLab filestore implementation."""
|
| 15 |
+
import logging
|
| 16 |
+
|
| 17 |
+
import json
|
| 18 |
+
import os
|
| 19 |
+
import shutil
|
| 20 |
+
import tempfile
|
| 21 |
+
|
| 22 |
+
import filestore
|
| 23 |
+
import http_utils
|
| 24 |
+
|
| 25 |
+
# pylint: disable=no-self-use,unused-argument
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
class GitlabFilestore(filestore.BaseFilestore):
|
| 29 |
+
"""Implementation of BaseFilestore using GitLab.
|
| 30 |
+
Needs a cache to upload and download builds.
|
| 31 |
+
Needs a git repository for corpus and coverage.
|
| 32 |
+
"""
|
| 33 |
+
|
| 34 |
+
BUILD_PREFIX = 'build-'
|
| 35 |
+
CORPUS_PREFIX = 'corpus-'
|
| 36 |
+
COVERAGE_PREFIX = 'coverage-'
|
| 37 |
+
CRASHES_PREFIX = 'crashes-'
|
| 38 |
+
|
| 39 |
+
def __init__(self, config):
|
| 40 |
+
super().__init__(config)
|
| 41 |
+
self.artifacts_dir = self.config.platform_conf.artifacts_dir
|
| 42 |
+
self.cache_dir = self.config.platform_conf.cache_dir
|
| 43 |
+
if self.config.git_store_repo:
|
| 44 |
+
self.git_filestore = filestore.git.GitFilestore(config, None)
|
| 45 |
+
else:
|
| 46 |
+
self.git_filestore = None
|
| 47 |
+
|
| 48 |
+
def upload_crashes(self, name, directory):
|
| 49 |
+
"""GitLab artifacts implementation of upload_crashes."""
|
| 50 |
+
# Upload crashes as job artifacts.
|
| 51 |
+
if os.listdir(directory):
|
| 52 |
+
dest_dir_artifacts = os.path.join(self.config.project_src_path,
|
| 53 |
+
self.artifacts_dir,
|
| 54 |
+
self.CRASHES_PREFIX + name)
|
| 55 |
+
logging.info('Uploading artifacts to %s.', dest_dir_artifacts)
|
| 56 |
+
shutil.copytree(directory, dest_dir_artifacts)
|
| 57 |
+
|
| 58 |
+
def upload_corpus(self, name, directory, replace=False):
|
| 59 |
+
"""GitLab artifacts implementation of upload_corpus."""
|
| 60 |
+
# Use the git filestore if any.
|
| 61 |
+
if self.git_filestore:
|
| 62 |
+
self.git_filestore.upload_corpus(name, directory, replace)
|
| 63 |
+
return
|
| 64 |
+
# Fall back to cache.
|
| 65 |
+
dest_dir_cache = os.path.join(self.config.project_src_path, self.cache_dir,
|
| 66 |
+
self.CORPUS_PREFIX + name)
|
| 67 |
+
logging.info('Copying from %s to cache %s.', directory, dest_dir_cache)
|
| 68 |
+
# Remove previous corpus from cache if any.
|
| 69 |
+
shutil.rmtree(dest_dir_cache, ignore_errors=True)
|
| 70 |
+
shutil.copytree(directory, dest_dir_cache, dirs_exist_ok=True)
|
| 71 |
+
|
| 72 |
+
def upload_build(self, name, directory):
|
| 73 |
+
"""GitLab artifacts implementation of upload_build."""
|
| 74 |
+
# Puts build into the cache.
|
| 75 |
+
dest_dir_cache = os.path.join(self.config.project_src_path, self.cache_dir,
|
| 76 |
+
self.BUILD_PREFIX + name)
|
| 77 |
+
logging.info('Copying from %s to cache %s.', directory, dest_dir_cache)
|
| 78 |
+
shutil.copytree(directory, dest_dir_cache, dirs_exist_ok=True)
|
| 79 |
+
|
| 80 |
+
def upload_coverage(self, name, directory):
|
| 81 |
+
"""GitLab artifacts implementation of upload_coverage."""
|
| 82 |
+
# Use the git filestore.
|
| 83 |
+
if self.git_filestore:
|
| 84 |
+
self.git_filestore.upload_coverage(name, directory)
|
| 85 |
+
return
|
| 86 |
+
# Fall back to cache.
|
| 87 |
+
dest_dir_cache = os.path.join(self.config.project_src_path, self.cache_dir,
|
| 88 |
+
self.COVERAGE_PREFIX + name)
|
| 89 |
+
logging.info('Copying from %s to cache %s.', directory, dest_dir_cache)
|
| 90 |
+
shutil.copytree(directory, dest_dir_cache, dirs_exist_ok=True)
|
| 91 |
+
# And also updates coverage reports as artifacts
|
| 92 |
+
# as it should not be too big.
|
| 93 |
+
dest_dir_artifacts = os.path.join(self.config.project_src_path,
|
| 94 |
+
self.artifacts_dir,
|
| 95 |
+
self.COVERAGE_PREFIX + name)
|
| 96 |
+
logging.info('Uploading artifacts to %s.', dest_dir_artifacts)
|
| 97 |
+
shutil.copytree(directory, dest_dir_artifacts)
|
| 98 |
+
|
| 99 |
+
def _copy_from_cache(self, src_dir_cache, dst_directory):
|
| 100 |
+
if not os.path.exists(src_dir_cache):
|
| 101 |
+
logging.info('Cache %s does not exist.', src_dir_cache)
|
| 102 |
+
return False
|
| 103 |
+
logging.info('Copying %s from cache to %s.', src_dir_cache, dst_directory)
|
| 104 |
+
shutil.copytree(src_dir_cache, dst_directory, dirs_exist_ok=True)
|
| 105 |
+
return True
|
| 106 |
+
|
| 107 |
+
def download_corpus(self, name, dst_directory):
|
| 108 |
+
"""GitLab artifacts implementation of download_corpus."""
|
| 109 |
+
# Use the git filestore if any.
|
| 110 |
+
if self.git_filestore:
|
| 111 |
+
self.git_filestore.download_corpus(name, dst_directory)
|
| 112 |
+
return
|
| 113 |
+
# Fall back to cache.
|
| 114 |
+
src_dir_cache = os.path.join(self.config.project_src_path, self.cache_dir,
|
| 115 |
+
self.CORPUS_PREFIX + name)
|
| 116 |
+
self._copy_from_cache(src_dir_cache, dst_directory)
|
| 117 |
+
|
| 118 |
+
def download_build(self, name, dst_directory):
|
| 119 |
+
"""GitLab artifacts implementation of download_build."""
|
| 120 |
+
# Gets build from the cache.
|
| 121 |
+
src_dir_cache = os.path.join(self.config.project_src_path, self.cache_dir,
|
| 122 |
+
self.BUILD_PREFIX + name)
|
| 123 |
+
return self._copy_from_cache(src_dir_cache, dst_directory)
|
| 124 |
+
|
| 125 |
+
def download_coverage(self, name, dst_directory):
|
| 126 |
+
"""GitLab artifacts implementation of download_coverage."""
|
| 127 |
+
# Use the git filestore if any.
|
| 128 |
+
if self.git_filestore:
|
| 129 |
+
return self.git_filestore.download_coverage(name, dst_directory)
|
| 130 |
+
# Fall back to cache.
|
| 131 |
+
src_dir_cache = os.path.join(self.config.project_src_path, self.cache_dir,
|
| 132 |
+
self.COVERAGE_PREFIX + name)
|
| 133 |
+
return self._copy_from_cache(src_dir_cache, dst_directory)
|
local-test-tika-full-01-vuln_7/fuzz-tooling/infra/cifuzz/filestore/gsutil/__init__.py
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2021 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
"""Filestore implementation using gsutil."""
|
| 15 |
+
import logging
|
| 16 |
+
import os
|
| 17 |
+
import posixpath
|
| 18 |
+
import subprocess
|
| 19 |
+
import sys
|
| 20 |
+
|
| 21 |
+
# pylint: disable=wrong-import-position,import-error
|
| 22 |
+
sys.path.append(
|
| 23 |
+
os.path.join(os.path.dirname(os.path.abspath(__file__)), os.pardir,
|
| 24 |
+
os.pardir, os.pardir))
|
| 25 |
+
import filestore
|
| 26 |
+
import utils
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def _gsutil_execute(*args, parallel=True):
|
| 30 |
+
"""Executes a gsutil command, passing |*args| to gsutil and returns the
|
| 31 |
+
stdout, stderr and returncode. Exceptions on failure."""
|
| 32 |
+
command = ['gsutil']
|
| 33 |
+
if parallel:
|
| 34 |
+
command.append('-m')
|
| 35 |
+
command += list(args)
|
| 36 |
+
logging.info('Executing gsutil command: %s', command)
|
| 37 |
+
return utils.execute(command, check_result=True)
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
def _rsync(src, dst, recursive=True, delete=False):
|
| 41 |
+
"""Executes gsutil rsync on |src| and |dst|"""
|
| 42 |
+
args = ['rsync']
|
| 43 |
+
if recursive:
|
| 44 |
+
args.append('-r')
|
| 45 |
+
if delete:
|
| 46 |
+
args.append('-d')
|
| 47 |
+
args += [src, dst]
|
| 48 |
+
return _gsutil_execute(*args)
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
class GSUtilFilestore(filestore.BaseFilestore):
|
| 52 |
+
"""Filestore implementation using gsutil."""
|
| 53 |
+
BUILD_DIR = 'build'
|
| 54 |
+
CRASHES_DIR = 'crashes'
|
| 55 |
+
CORPUS_DIR = 'corpus'
|
| 56 |
+
COVERAGE_DIR = 'coverage'
|
| 57 |
+
|
| 58 |
+
def __init__(self, config):
|
| 59 |
+
super().__init__(config)
|
| 60 |
+
self._cloud_bucket = self.config.cloud_bucket
|
| 61 |
+
|
| 62 |
+
def _get_gsutil_url(self, name, prefix_dir):
|
| 63 |
+
"""Returns the gsutil URL for |name| and |prefix_dir|."""
|
| 64 |
+
if not prefix_dir:
|
| 65 |
+
return posixpath.join(self._cloud_bucket, name)
|
| 66 |
+
return posixpath.join(self._cloud_bucket, prefix_dir, name)
|
| 67 |
+
|
| 68 |
+
def _upload_directory(self, name, directory, prefix, delete=False):
|
| 69 |
+
gsutil_url = self._get_gsutil_url(name, prefix)
|
| 70 |
+
return _rsync(directory, gsutil_url, delete=delete)
|
| 71 |
+
|
| 72 |
+
def _download_directory(self, name, dst_directory, prefix):
|
| 73 |
+
gsutil_url = self._get_gsutil_url(name, prefix)
|
| 74 |
+
return _rsync(gsutil_url, dst_directory)
|
| 75 |
+
|
| 76 |
+
def upload_crashes(self, name, directory):
|
| 77 |
+
"""Uploads the crashes at |directory| to |name|."""
|
| 78 |
+
# Name is going to be "current". I don't know if this makes sense outside of
|
| 79 |
+
# GitHub Actions.
|
| 80 |
+
gsutil_url = self._get_gsutil_url(name, self.CRASHES_DIR)
|
| 81 |
+
logging.info('Uploading crashes to %s.', gsutil_url)
|
| 82 |
+
return _rsync(directory, gsutil_url)
|
| 83 |
+
|
| 84 |
+
def upload_corpus(self, name, directory, replace=False):
|
| 85 |
+
"""Uploads the crashes at |directory| to |name|."""
|
| 86 |
+
return self._upload_directory(name,
|
| 87 |
+
directory,
|
| 88 |
+
self.CORPUS_DIR,
|
| 89 |
+
delete=replace)
|
| 90 |
+
|
| 91 |
+
def upload_build(self, name, directory):
|
| 92 |
+
"""Uploads the build located at |directory| to |name|."""
|
| 93 |
+
return self._upload_directory(name, directory, self.BUILD_DIR)
|
| 94 |
+
|
| 95 |
+
def upload_coverage(self, name, directory):
|
| 96 |
+
"""Uploads the coverage report at |directory| to |name|."""
|
| 97 |
+
return self._upload_directory(name, directory, self.COVERAGE_DIR)
|
| 98 |
+
|
| 99 |
+
def download_corpus(self, name, dst_directory):
|
| 100 |
+
"""Downloads the corpus located at |name| to |dst_directory|."""
|
| 101 |
+
return self._download_directory(name, dst_directory, self.CORPUS_DIR)
|
| 102 |
+
|
| 103 |
+
def download_build(self, name, dst_directory):
|
| 104 |
+
"""Downloads the build with |name| to |dst_directory|."""
|
| 105 |
+
return self._download_directory(name, dst_directory, self.BUILD_DIR)
|
| 106 |
+
|
| 107 |
+
def download_coverage(self, name, dst_directory):
|
| 108 |
+
"""Downloads the latest project coverage report."""
|
| 109 |
+
return self._download_directory(name, dst_directory, self.COVERAGE_DIR)
|
local-test-tika-full-01-vuln_7/fuzz-tooling/infra/cifuzz/filestore/no_filestore/__init__.py
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2021 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
"""Empty filestore implementation for platforms that haven't implemented it."""
|
| 15 |
+
import logging
|
| 16 |
+
|
| 17 |
+
import filestore
|
| 18 |
+
|
| 19 |
+
# pylint:disable=no-self-use,unused-argument
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
class NoFilestore(filestore.BaseFilestore):
|
| 23 |
+
"""Empty Filestore implementation."""
|
| 24 |
+
|
| 25 |
+
def upload_crashes(self, name, directory):
|
| 26 |
+
"""Noop implementation of upload_crashes."""
|
| 27 |
+
logging.info('Not uploading crashes because no Filestore.')
|
| 28 |
+
|
| 29 |
+
def upload_corpus(self, name, directory, replace=False):
|
| 30 |
+
"""Noop implementation of upload_corpus."""
|
| 31 |
+
logging.info('Not uploading corpus because no Filestore.')
|
| 32 |
+
|
| 33 |
+
def upload_build(self, name, directory):
|
| 34 |
+
"""Noop implementation of upload_build."""
|
| 35 |
+
logging.info('Not uploading build because no Filestore.')
|
| 36 |
+
|
| 37 |
+
def upload_coverage(self, name, directory):
|
| 38 |
+
"""Noop implementation of upload_coverage."""
|
| 39 |
+
logging.info('Not uploading coverage because no Filestore.')
|
| 40 |
+
|
| 41 |
+
def download_corpus(self, name, dst_directory):
|
| 42 |
+
"""Noop implementation of download_corpus."""
|
| 43 |
+
logging.info('Not downloading corpus because no Filestore.')
|
| 44 |
+
|
| 45 |
+
def download_build(self, name, dst_directory):
|
| 46 |
+
"""Noop implementation of download_build."""
|
| 47 |
+
logging.info('Not downloading build because no Filestore.')
|
| 48 |
+
|
| 49 |
+
def download_coverage(self, name, dst_directory):
|
| 50 |
+
"""Noop implementation of download_coverage."""
|
| 51 |
+
logging.info('Not downloading coverage because no Filestore.')
|
local-test-tika-full-01-vuln_7/fuzz-tooling/infra/cifuzz/platform_config/gitlab.py
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2022 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
"""Module for getting the configuration CIFuzz needs to run on GitLab."""
|
| 15 |
+
import logging
|
| 16 |
+
import os
|
| 17 |
+
|
| 18 |
+
import environment
|
| 19 |
+
import platform_config
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
class PlatformConfig(platform_config.BasePlatformConfig):
|
| 23 |
+
"""CI environment for GitLab."""
|
| 24 |
+
|
| 25 |
+
@property
|
| 26 |
+
def workspace(self):
|
| 27 |
+
"""Returns the workspace."""
|
| 28 |
+
return os.path.join(os.getenv('CI_BUILDS_DIR'), os.getenv('CI_JOB_ID'))
|
| 29 |
+
|
| 30 |
+
@property
|
| 31 |
+
def git_sha(self):
|
| 32 |
+
"""Returns the Git SHA to checkout and fuzz."""
|
| 33 |
+
return os.getenv('CI_COMMIT_SHA')
|
| 34 |
+
|
| 35 |
+
@property
|
| 36 |
+
def project_src_path(self):
|
| 37 |
+
"""Returns the directory with the source of the project"""
|
| 38 |
+
return os.getenv('CI_PROJECT_DIR')
|
| 39 |
+
|
| 40 |
+
@property
|
| 41 |
+
def token(self):
|
| 42 |
+
"""Returns the job token"""
|
| 43 |
+
return os.getenv('CI_JOB_TOKEN')
|
| 44 |
+
|
| 45 |
+
@property
|
| 46 |
+
def project_repo_name(self):
|
| 47 |
+
"""Returns the project's name"""
|
| 48 |
+
return os.getenv('CI_PROJECT_NAME')
|
| 49 |
+
|
| 50 |
+
@property
|
| 51 |
+
def base_commit(self):
|
| 52 |
+
"""Returns the previous commit sha for commit-fuzzing"""
|
| 53 |
+
base_commit = None
|
| 54 |
+
if os.getenv('CI_PIPELINE_SOURCE') == 'push':
|
| 55 |
+
base_commit = os.getenv('CI_COMMIT_BEFORE_SHA')
|
| 56 |
+
logging.debug('base_commit: %s.', base_commit)
|
| 57 |
+
return base_commit
|
| 58 |
+
|
| 59 |
+
@property
|
| 60 |
+
def base_ref(self):
|
| 61 |
+
"""Returns the base commit sha for a merge request"""
|
| 62 |
+
# Could also be CI_MERGE_REQUEST_TARGET_BRANCH_NAME.
|
| 63 |
+
return os.getenv('CI_MERGE_REQUEST_DIFF_BASE_SHA')
|
| 64 |
+
|
| 65 |
+
@property
|
| 66 |
+
def filestore(self):
|
| 67 |
+
"""Returns the filestore used to store persistent data."""
|
| 68 |
+
return os.environ.get('FILESTORE', 'gitlab')
|
| 69 |
+
|
| 70 |
+
@property
|
| 71 |
+
def artifacts_dir(self):
|
| 72 |
+
"""Gitlab: returns the directory to put artifacts"""
|
| 73 |
+
return environment.get('CFL_ARTIFACTS_DIR', 'artifacts')
|
| 74 |
+
|
| 75 |
+
@property
|
| 76 |
+
def cache_dir(self):
|
| 77 |
+
"""Gitlab: returns the directory to use as cache"""
|
| 78 |
+
return environment.get('CFL_CACHE_DIR', 'cache')
|
local-test-tika-full-01-vuln_7/fuzz-tooling/infra/cifuzz/platform_config/standalone.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2022 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
"""Module for getting the configuration CIFuzz needs to run standalone."""
|
| 15 |
+
import os
|
| 16 |
+
|
| 17 |
+
import platform_config
|
| 18 |
+
|
| 19 |
+
# pylint: disable=too-few-public-methods
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
class PlatformConfig(platform_config.BasePlatformConfig):
|
| 23 |
+
"""CI environment for Standalone."""
|
| 24 |
+
|
| 25 |
+
@property
|
| 26 |
+
def filestore(self):
|
| 27 |
+
"""Returns the filestore used to store persistent data."""
|
| 28 |
+
return os.environ.get('FILESTORE', 'filesystem')
|
| 29 |
+
|
| 30 |
+
@property
|
| 31 |
+
def filestore_root_dir(self):
|
| 32 |
+
"""Returns the filestore used to store persistent data."""
|
| 33 |
+
return os.environ['FILESTORE_ROOT_DIR']
|
local-test-tika-full-01-vuln_7/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_7/fuzz-tooling/infra/cifuzz/test_data/external-project/.clusterfuzzlite/build.sh
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash -eu
|
| 2 |
+
# Copyright 2020 Google Inc.
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
################################################################################
|
| 17 |
+
|
| 18 |
+
make clean # Not strictly necessary, since we are building in a fresh dir.
|
| 19 |
+
make -j$(nproc) all # Build the fuzz targets.
|
| 20 |
+
|
| 21 |
+
# Copy the fuzzer executables, zip-ed corpora, option and dictionary files to $OUT
|
| 22 |
+
find . -name '*_fuzzer' -exec cp -v '{}' $OUT ';'
|
| 23 |
+
find . -name '*_fuzzer.dict' -exec cp -v '{}' $OUT ';' # If you have dictionaries.
|
| 24 |
+
find . -name '*_fuzzer.options' -exec cp -v '{}' $OUT ';' # If you have custom options.
|
local-test-tika-full-01-vuln_7/fuzz-tooling/infra/cifuzz/test_data/external-project/Makefile
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2017 Google Inc. All Rights Reserved.
|
| 2 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 3 |
+
|
| 4 |
+
# Simple example of a build file that nicely integrates a fuzz target
|
| 5 |
+
# with the rest of the project.
|
| 6 |
+
#
|
| 7 |
+
# We use 'make' as the build system, but these ideas are applicable
|
| 8 |
+
# to any other build system
|
| 9 |
+
|
| 10 |
+
# By default, use our own standalone_fuzz_target_runner.
|
| 11 |
+
# This runner does no fuzzing, but simply executes the inputs
|
| 12 |
+
# provided via parameters.
|
| 13 |
+
# Run e.g. "make all LIB_FUZZING_ENGINE=/path/to/libFuzzer.a"
|
| 14 |
+
# to link the fuzzer(s) against a real fuzzing engine.
|
| 15 |
+
#
|
| 16 |
+
# OSS-Fuzz will define its own value for LIB_FUZZING_ENGINE.
|
| 17 |
+
LIB_FUZZING_ENGINE ?= standalone_fuzz_target_runner.o
|
| 18 |
+
|
| 19 |
+
# Values for CC, CFLAGS, CXX, CXXFLAGS are provided by OSS-Fuzz.
|
| 20 |
+
# Outside of OSS-Fuzz use the ones you prefer or rely on the default values.
|
| 21 |
+
# Do not use the -fsanitize=* flags by default.
|
| 22 |
+
# OSS-Fuzz will use different -fsanitize=* flags for different builds (asan, ubsan, msan, ...)
|
| 23 |
+
|
| 24 |
+
# You may add extra compiler flags like this:
|
| 25 |
+
CXXFLAGS += -std=c++11
|
| 26 |
+
|
| 27 |
+
all: do_stuff_fuzzer
|
| 28 |
+
|
| 29 |
+
clean:
|
| 30 |
+
rm -fv *.a *.o *_fuzzer crash-* *.zip
|
| 31 |
+
|
| 32 |
+
# Fuzz target, links against $LIB_FUZZING_ENGINE, so that
|
| 33 |
+
# you may choose which fuzzing engine to use.
|
| 34 |
+
do_stuff_fuzzer: do_stuff_fuzzer.cpp my_api.a standalone_fuzz_target_runner.o
|
| 35 |
+
${CXX} ${CXXFLAGS} $< my_api.a ${LIB_FUZZING_ENGINE} -o $@
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
# The library itself.
|
| 39 |
+
my_api.a: my_api.cpp my_api.h
|
| 40 |
+
${CXX} ${CXXFLAGS} $< -c
|
| 41 |
+
ar ruv my_api.a my_api.o
|
| 42 |
+
|
| 43 |
+
# The standalone fuzz target runner.
|
| 44 |
+
standalone_fuzz_target_runner.o: standalone_fuzz_target_runner.cpp
|
local-test-tika-full-01-vuln_7/fuzz-tooling/infra/cifuzz/test_data/external-project/do_stuff_fuzzer.cpp
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
#include "my_api.h"
|
| 15 |
+
|
| 16 |
+
#include <string>
|
| 17 |
+
|
| 18 |
+
// Simple fuzz target for DoStuff().
|
| 19 |
+
// See https://llvm.org/docs/LibFuzzer.html for details.
|
| 20 |
+
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
| 21 |
+
std::string str(reinterpret_cast<const char *>(data), size);
|
| 22 |
+
DoStuff(str); // Disregard the output.
|
| 23 |
+
return 0;
|
| 24 |
+
}
|
local-test-tika-full-01-vuln_7/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_7/fuzz-tooling/infra/cifuzz/test_data/external-project/my_api.cpp
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
// Implementation of "my_api".
|
| 16 |
+
#include "my_api.h"
|
| 17 |
+
|
| 18 |
+
#include <vector>
|
| 19 |
+
|
| 20 |
+
// Do some computations with 'str', return the result.
|
| 21 |
+
// This function contains a bug. Can you spot it?
|
| 22 |
+
size_t DoStuff(const std::string &str) {
|
| 23 |
+
std::vector<int> Vec({0, 1, 2, 3, 4});
|
| 24 |
+
size_t Idx = 0;
|
| 25 |
+
if (str.size() > 5)
|
| 26 |
+
Idx++;
|
| 27 |
+
if (str.find("foo") != std::string::npos)
|
| 28 |
+
Idx++;
|
| 29 |
+
if (str.find("bar") != std::string::npos)
|
| 30 |
+
Idx++;
|
| 31 |
+
if (str.find("ouch") != std::string::npos)
|
| 32 |
+
Idx++;
|
| 33 |
+
if (str.find("omg") != std::string::npos)
|
| 34 |
+
Idx++;
|
| 35 |
+
return Vec[Idx];
|
| 36 |
+
}
|
local-test-tika-full-01-vuln_7/fuzz-tooling/infra/cifuzz/test_data/external-project/my_api.h
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
// A library that does ... stuff.
|
| 16 |
+
// Serves as an example of good fuzz testing and OSS-Fuzz integration.
|
| 17 |
+
#include <string>
|
| 18 |
+
|
| 19 |
+
size_t DoStuff(const std::string &str);
|
local-test-tika-full-01-vuln_7/fuzz-tooling/infra/cifuzz/test_data/external-project/standalone_fuzz_target_runner.cpp
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright 2020 Google LLC
|
| 2 |
+
//
|
| 3 |
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
// you may not use this file except in compliance with the License.
|
| 5 |
+
// You may obtain a copy of the License at
|
| 6 |
+
//
|
| 7 |
+
// http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
//
|
| 9 |
+
// Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
// See the License for the specific language governing permissions and
|
| 13 |
+
// limitations under the License.
|
| 14 |
+
|
| 15 |
+
// Example of a standalone runner for "fuzz targets".
|
| 16 |
+
// It reads all files passed as parameters and feeds their contents
|
| 17 |
+
// one by one into the fuzz target (LLVMFuzzerTestOneInput).
|
| 18 |
+
// This runner does not do any fuzzing, but allows us to run the fuzz target
|
| 19 |
+
// on the test corpus (e.g. "do_stuff_test_data") or on a single file,
|
| 20 |
+
// e.g. the one that comes from a bug report.
|
| 21 |
+
|
| 22 |
+
#include <cassert>
|
| 23 |
+
#include <iostream>
|
| 24 |
+
#include <fstream>
|
| 25 |
+
#include <vector>
|
| 26 |
+
|
| 27 |
+
// Forward declare the "fuzz target" interface.
|
| 28 |
+
// We deliberately keep this inteface simple and header-free.
|
| 29 |
+
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
|
| 30 |
+
|
| 31 |
+
int main(int argc, char **argv) {
|
| 32 |
+
for (int i = 1; i < argc; i++) {
|
| 33 |
+
std::ifstream in(argv[i]);
|
| 34 |
+
in.seekg(0, in.end);
|
| 35 |
+
size_t length = in.tellg();
|
| 36 |
+
in.seekg (0, in.beg);
|
| 37 |
+
std::cout << "Reading " << length << " bytes from " << argv[i] << std::endl;
|
| 38 |
+
// Allocate exactly length bytes so that we reliably catch buffer overflows.
|
| 39 |
+
std::vector<char> bytes(length);
|
| 40 |
+
in.read(bytes.data(), bytes.size());
|
| 41 |
+
assert(in);
|
| 42 |
+
LLVMFuzzerTestOneInput(reinterpret_cast<const uint8_t *>(bytes.data()),
|
| 43 |
+
bytes.size());
|
| 44 |
+
std::cout << "Execution successful" << std::endl;
|
| 45 |
+
}
|
| 46 |
+
return 0;
|
| 47 |
+
}
|
local-test-tika-full-01-vuln_7/fuzz-tooling/infra/cifuzz/test_data/msan_crash_fuzzer_bug_summary.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MemorySanitizer: use-of-uninitialized-value
|
| 2 |
+
#0 0x52675f in LLVMFuzzerTestOneInput /src/cifuzz-example/do_stuff_fuzzer.cpp:13:7
|
| 3 |
+
#1 0x45a431 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:599:15
|
| 4 |
+
#2 0x45ba46 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:792:3
|
| 5 |
+
#3 0x45bed9 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:845:3
|
| 6 |
+
#4 0x44a4bc in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:906:6
|
| 7 |
+
#5 0x474432 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
|
| 8 |
+
#6 0x7eff5562683f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2083f)
|
| 9 |
+
#7 0x41eab8 in _start (out/do_stuff_fuzzer+0x41eab8)
|
| 10 |
+
|
| 11 |
+
DEDUP_TOKEN: LLVMFuzzerTestOneInput--fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long)--fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&)
|
| 12 |
+
Uninitialized value was created by a heap allocation
|
| 13 |
+
#0 0x4d57ad in malloc /src/llvm-project/compiler-rt/lib/msan/msan_interceptors.cpp:901:3
|
| 14 |
+
#1 0x437c07 in operator new(unsigned long) (out/do_stuff_fuzzer+0x437c07)
|
| 15 |
+
#2 0x45ba46 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:792:3
|
| 16 |
+
#3 0x45bed9 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:845:3
|
| 17 |
+
#4 0x44a4bc in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:906:6
|
| 18 |
+
#5 0x474432 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
|
| 19 |
+
#6 0x7eff5562683f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2083f)
|
| 20 |
+
DEDUP_TOKEN: malloc--operator new(unsigned long)--fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&)
|
| 21 |
+
|
| 22 |
+
SUMMARY:
|
local-test-tika-full-01-vuln_7/fuzz-tooling/infra/cifuzz/test_data/msan_crash_fuzzer_output.txt
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Dictionary: 3 entries
|
| 2 |
+
INFO: Running with entropic power schedule (0xFF, 100).
|
| 3 |
+
INFO: Seed: 1337
|
| 4 |
+
INFO: Loaded 1 modules (184 inline 8-bit counters): 184 [0x829300, 0x8293b8),
|
| 5 |
+
INFO: Loaded 1 PC tables (184 PCs): 184 [0x5dc910,0x5dd490),
|
| 6 |
+
INFO: 5 files found in /tmp/do_stuff_fuzzer_corpus
|
| 7 |
+
INFO: -max_len is not provided; libFuzzer will not generate inputs larger than 4096 bytes
|
| 8 |
+
==13==WARNING: MemorySanitizer: use-of-uninitialized-value
|
| 9 |
+
#0 0x52675f in LLVMFuzzerTestOneInput /src/cifuzz-example/do_stuff_fuzzer.cpp:13:7
|
| 10 |
+
#1 0x45a431 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:599:15
|
| 11 |
+
#2 0x45ba46 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:792:3
|
| 12 |
+
#3 0x45bed9 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:845:3
|
| 13 |
+
#4 0x44a4bc in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:906:6
|
| 14 |
+
#5 0x474432 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
|
| 15 |
+
#6 0x7eff5562683f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2083f)
|
| 16 |
+
#7 0x41eab8 in _start (out/do_stuff_fuzzer+0x41eab8)
|
| 17 |
+
|
| 18 |
+
DEDUP_TOKEN: LLVMFuzzerTestOneInput--fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long)--fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&)
|
| 19 |
+
Uninitialized value was created by a heap allocation
|
| 20 |
+
#0 0x4d57ad in malloc /src/llvm-project/compiler-rt/lib/msan/msan_interceptors.cpp:901:3
|
| 21 |
+
#1 0x437c07 in operator new(unsigned long) (out/do_stuff_fuzzer+0x437c07)
|
| 22 |
+
#2 0x45ba46 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:792:3
|
| 23 |
+
#3 0x45bed9 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:845:3
|
| 24 |
+
#4 0x44a4bc in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:906:6
|
| 25 |
+
#5 0x474432 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
|
| 26 |
+
#6 0x7eff5562683f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2083f)
|
| 27 |
+
DEDUP_TOKEN: malloc--operator new(unsigned long)--fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&)
|
| 28 |
+
|
| 29 |
+
SUMMARY: MemorySanitizer: use-of-uninitialized-value /src/cifuzz-example/do_stuff_fuzzer.cpp:13:7 in LLVMFuzzerTestOneInput
|
| 30 |
+
Unique heap origins: 65
|
| 31 |
+
Stack depot allocated bytes: 4424
|
| 32 |
+
Unique origin histories: 29
|
| 33 |
+
History depot allocated bytes: 696
|
| 34 |
+
Exiting
|
| 35 |
+
MS: 0 ; base unit: 0000000000000000000000000000000000000000
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
artifact_prefix='./'; Test unit written to ./crash-da39a3ee5e6b4b0d3255bfef95601890afd80709
|
| 39 |
+
Base64:
|
local-test-tika-full-01-vuln_7/fuzz-tooling/infra/tools/wycheproof/.gitignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
wycheproof.zip
|
local-test-tika-full-01-vuln_7/fuzz-tooling/infra/tools/wycheproof/generate_job.py
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 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 generating an OSS-Fuzz job for a wycheproof project."""
|
| 18 |
+
import sys
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def main():
|
| 22 |
+
"""Usage generate_job.py <project>."""
|
| 23 |
+
project = sys.argv[1]
|
| 24 |
+
print(f'Name: wycheproof_nosanitizer_{project}')
|
| 25 |
+
job_definition = f"""CUSTOM_BINARY = False
|
| 26 |
+
BAD_BUILD_CHECK = False
|
| 27 |
+
APP_NAME = WycheproofTarget.bash
|
| 28 |
+
THREAD_ALIVE_CHECK_INTERVAL = 10
|
| 29 |
+
TEST_TIMEOUT = 3600
|
| 30 |
+
CRASH_RETRIES = 1
|
| 31 |
+
AGGREGATE_COVERAGE = False
|
| 32 |
+
TESTCASE_COVERAGE = False
|
| 33 |
+
FILE_GITHUB_ISSUE = False
|
| 34 |
+
MANAGED = False
|
| 35 |
+
MAX_FUZZ_THREADS = 1
|
| 36 |
+
RELEASE_BUILD_BUCKET_PATH = gs://clusterfuzz-builds-wycheproof/{project}/{project}-none-([0-9]+).zip
|
| 37 |
+
PROJECT_NAME = {project}
|
| 38 |
+
SUMMARY_PREFIX = {project}
|
| 39 |
+
REVISION_VARS_URL = https://commondatastorage.googleapis.com/clusterfuzz-builds-wycheproof/{project}/{project}-none-%s.srcmap.json
|
| 40 |
+
FUZZ_LOGS_BUCKET = {project}-logs.clusterfuzz-external.appspot.com
|
| 41 |
+
CORPUS_BUCKET = {project}-corpus.clusterfuzz-external.appspot.com
|
| 42 |
+
QUARANTINE_BUCKET = {project}-quarantine.clusterfuzz-external.appspot.com
|
| 43 |
+
BACKUP_BUCKET = {project}-backup.clusterfuzz-external.appspot.com
|
| 44 |
+
AUTOMATIC_LABELS = Proj-{project},Engine-wycheproof
|
| 45 |
+
"""
|
| 46 |
+
print(job_definition)
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
if __name__ == '__main__':
|
| 50 |
+
main()
|
local-test-tika-full-01-vuln_7/fuzz-tooling/infra/tools/wycheproof/launcher.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python
|
| 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 running wycheproof."""
|
| 18 |
+
|
| 19 |
+
import logging
|
| 20 |
+
import sys
|
| 21 |
+
import subprocess
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
def main():
|
| 25 |
+
"""Runs wycheproof."""
|
| 26 |
+
if len(sys.argv) < 3:
|
| 27 |
+
logging.error('Usage: %s <test_app> <testcase>.', sys.argv[0])
|
| 28 |
+
return 1
|
| 29 |
+
|
| 30 |
+
return subprocess.run(sys.argv[1:], check=False).returncode
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
if __name__ == '__main__':
|
| 34 |
+
sys.exit(main())
|
local-test-tika-full-01-vuln_7/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
|
local-test-tika-full-01-vuln_7/fuzz-tooling/infra/tools/wycheproof/run.py
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 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 creating "testcases" to run wycheproof on."""
|
| 18 |
+
|
| 19 |
+
import argparse
|
| 20 |
+
import os
|
| 21 |
+
import sys
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
def get_args():
|
| 25 |
+
"""Returns parsed program arguments."""
|
| 26 |
+
parser = argparse.ArgumentParser()
|
| 27 |
+
parser.add_argument(
|
| 28 |
+
'--input_dir',
|
| 29 |
+
help='Ignored.',
|
| 30 |
+
)
|
| 31 |
+
parser.add_argument('--output_dir',
|
| 32 |
+
help='Directory for writing testcases.',
|
| 33 |
+
required=True)
|
| 34 |
+
parser.add_argument('--no_of_files', type=int, help='Ignored.')
|
| 35 |
+
return parser.parse_args()
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
def main():
|
| 39 |
+
"""Generates a dummy testcase for use by a ClusterFuzz blackbox fuzzer."""
|
| 40 |
+
args = get_args()
|
| 41 |
+
if not os.path.exists(args.output_dir):
|
| 42 |
+
os.mkdir(args.output_dir)
|
| 43 |
+
testcase = os.path.join(args.output_dir, 'fuzz-0')
|
| 44 |
+
with open(testcase, 'w') as file_handle:
|
| 45 |
+
file_handle.write(' ')
|
| 46 |
+
return 0
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
if __name__ == '__main__':
|
| 50 |
+
sys.exit(main())
|