Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder-javascript/Dockerfile +20 -0
- local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder-jvm/Dockerfile +68 -0
- local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder-rust/Dockerfile +37 -0
- local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/Dockerfile +213 -0
- local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/bazel.bazelrc +20 -0
- local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/bisect_clang.py +227 -0
- local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/compile +420 -0
- local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/compile_centipede +32 -0
- local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/compile_honggfuzz +33 -0
- local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/jcc/build_jcc.bash +25 -0
- local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/jcc/go.mod +3 -0
- local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/jcc/jcc.go +88 -0
- local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/jcc/jcc2.go +401 -0
- local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/jcc/jcc_test.go +186 -0
- local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/jcc/testdata/.gitignore +2 -0
- local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/jcc/testdata/cfile.c +18 -0
- local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/jcc/testdata/cpp.cc +18 -0
- local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/jcc/testdata/path/to/header.h +15 -0
- local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/sanitizers/pysecsan/.gitignore +4 -0
- local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/sanitizers/pysecsan/LICENSE +13 -0
- local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/sanitizers/pysecsan/README.md +3 -0
- local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/sanitizers/pysecsan/pyproject.toml +22 -0
- local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/sanitizers/pysecsan/pysecsan/__init__.py +20 -0
- local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/sanitizers/pysecsan/pysecsan/command_injection.py +106 -0
- local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/sanitizers/pysecsan/pysecsan/redos.py +84 -0
- local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/sanitizers/pysecsan/pysecsan/sanlib.py +227 -0
- local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/sanitizers/pysecsan/pysecsan/yaml_deserialization.py +42 -0
- local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/sanitizers/pysecsan/setup.py +21 -0
- local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/sanitizers/pysecsan/tests/README.md +1 -0
- local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/sanitizers/pysecsan/tests/os_command_injection.py +52 -0
- local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/sanitizers/pysecsan/tests/poe/ansible-runner-cve-2021-4041/build.sh +25 -0
- local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/sanitizers/pysecsan/tests/poe/ansible-runner-cve-2021-4041/fuzz_ansible_runner.py +64 -0
- local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/sanitizers/pysecsan/tests/poe/libvcs-cve-2022-21187/build.sh +21 -0
- local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/sanitizers/pysecsan/tests/poe/libvcs-cve-2022-21187/fuzz_libvcs.py +45 -0
- local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/sanitizers/pysecsan/tests/poe/python-ldap-GHSL-2021-117/build.sh +25 -0
- local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/sanitizers/pysecsan/tests/poe/python-ldap-GHSL-2021-117/fuzz_ldap.py +42 -0
- local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/sanitizers/pysecsan/tests/poe/pytorch-lightning-1.5.10/build.sh +22 -0
- local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/sanitizers/pysecsan/tests/poe/pytorch-lightning-1.5.10/fuzz_pytorch_lightning.dict +1 -0
- local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/sanitizers/pysecsan/tests/poe/pytorch-lightning-1.5.10/fuzz_pytorch_lightning.py +67 -0
- local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/sanitizers/pysecsan/tests/subprocess_popen_injection.py +51 -0
- local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/sanitizers/pysecsan/tests/yaml_deserialization_general.py +47 -0
- local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/sanitizers/pysecsan/tests/yaml_deserialization_simple.py +54 -0
- local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/test_data/culprit-commit.txt +30 -0
- local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-clang/Dockerfile +79 -0
- local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-clang/checkout_build_install_llvm.sh +246 -0
- local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-runner/gocoverage/convertcorpus/go.mod +10 -0
- local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-runner/gocoverage/convertcorpus/go.sum +24 -0
- local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-runner/gocoverage/convertcorpus/main.go +54 -0
- local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-runner/gocoverage/go.mod +8 -0
- local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-runner/gocoverage/go.sum +30 -0
local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder-javascript/Dockerfile
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2022 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
#
|
| 15 |
+
################################################################################
|
| 16 |
+
|
| 17 |
+
ARG IMG_TAG=latest
|
| 18 |
+
FROM ghcr.io/aixcc-finals/base-builder:${IMG_TAG}
|
| 19 |
+
|
| 20 |
+
RUN install_javascript.sh
|
local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder-jvm/Dockerfile
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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} AS base
|
| 19 |
+
|
| 20 |
+
ENV JAVA_HOME /usr/lib/jvm/java-17-openjdk-amd64
|
| 21 |
+
ENV JAVA_15_HOME /usr/lib/jvm/java-15-openjdk-amd64
|
| 22 |
+
ENV JVM_LD_LIBRARY_PATH $JAVA_HOME/lib/server
|
| 23 |
+
ENV PATH $PATH:$JAVA_HOME/bin
|
| 24 |
+
ENV JAZZER_API_PATH "/usr/local/lib/jazzer_api_deploy.jar"
|
| 25 |
+
ENV JAZZER_JUNIT_PATH "/usr/local/bin/jazzer_junit.jar"
|
| 26 |
+
|
| 27 |
+
RUN install_java.sh
|
| 28 |
+
|
| 29 |
+
RUN chmod 777 /usr/local/bin && chmod 777 /usr/local/lib
|
| 30 |
+
|
| 31 |
+
FROM base AS builder
|
| 32 |
+
RUN useradd -m jazzer_user
|
| 33 |
+
|
| 34 |
+
USER jazzer_user
|
| 35 |
+
|
| 36 |
+
WORKDIR $SRC
|
| 37 |
+
|
| 38 |
+
RUN git clone https://github.com/aixcc-finals/jazzer-aixcc jazzer && \
|
| 39 |
+
cd jazzer && \
|
| 40 |
+
git checkout 43791565a765b854b537d878c9cab757ff1f2140
|
| 41 |
+
|
| 42 |
+
WORKDIR $SRC/jazzer
|
| 43 |
+
|
| 44 |
+
RUN echo "build --java_runtime_version=local_jdk_17" >> .bazelrc \
|
| 45 |
+
&& echo "build --cxxopt=-stdlib=libc++" >> .bazelrc \
|
| 46 |
+
&& echo "build --linkopt=-lc++" >> .bazelrc
|
| 47 |
+
|
| 48 |
+
RUN bazel build \
|
| 49 |
+
//src/main/java/com/code_intelligence/jazzer:jazzer_standalone_deploy.jar \
|
| 50 |
+
//deploy:jazzer-api \
|
| 51 |
+
//deploy:jazzer-junit \
|
| 52 |
+
//launcher:jazzer
|
| 53 |
+
|
| 54 |
+
RUN cp $(bazel cquery --output=files //src/main/java/com/code_intelligence/jazzer:jazzer_standalone_deploy.jar) /usr/local/bin/jazzer_agent_deploy.jar && \
|
| 55 |
+
cp $(bazel cquery --output=files //launcher:jazzer) /usr/local/bin/jazzer_driver && \
|
| 56 |
+
cp $(bazel cquery --output=files //deploy:jazzer-api) $JAZZER_API_PATH && \
|
| 57 |
+
cp $(bazel cquery --output=files //deploy:jazzer-junit) $JAZZER_JUNIT_PATH
|
| 58 |
+
|
| 59 |
+
FROM base AS final
|
| 60 |
+
|
| 61 |
+
COPY --from=builder /usr/local/bin/jazzer_agent_deploy.jar /usr/local/bin/jazzer_agent_deploy.jar
|
| 62 |
+
COPY --from=builder /usr/local/bin/jazzer_driver /usr/local/bin/jazzer_driver
|
| 63 |
+
COPY --from=builder $JAZZER_API_PATH $JAZZER_API_PATH
|
| 64 |
+
COPY --from=builder $JAZZER_JUNIT_PATH $JAZZER_JUNIT_PATH
|
| 65 |
+
|
| 66 |
+
RUN chmod 755 /usr/local/bin && chmod 755 /usr/local/lib
|
| 67 |
+
|
| 68 |
+
WORKDIR $SRC
|
local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder-rust/Dockerfile
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
ENV CARGO_HOME=/rust
|
| 21 |
+
ENV RUSTUP_HOME=/rust/rustup
|
| 22 |
+
ENV PATH=$PATH:/rust/bin
|
| 23 |
+
# Set up custom environment variable for source code copy for coverage reports
|
| 24 |
+
ENV OSSFUZZ_RUSTPATH /rust
|
| 25 |
+
|
| 26 |
+
# Force rustup to ignore `rust-toolchain` and `rust-toolchain.toml` files by
|
| 27 |
+
# manually specifying what toolchain to use. Note that this environment variable
|
| 28 |
+
# is additionally used by `install_rust.sh` as the toolchain to install.
|
| 29 |
+
# cf https://rust-lang.github.io/rustup/overrides.html
|
| 30 |
+
ENV RUSTUP_TOOLCHAIN nightly-2024-07-12
|
| 31 |
+
|
| 32 |
+
# Configure the linker used by default for x86_64 linux to be `clang` instead of
|
| 33 |
+
# rustc's default of `cc` which is able to find custom-built libraries like
|
| 34 |
+
# `libc++` by default more easily.
|
| 35 |
+
ENV CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER clang
|
| 36 |
+
|
| 37 |
+
RUN install_rust.sh
|
local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/Dockerfile
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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-clang:${IMG_TAG}
|
| 19 |
+
|
| 20 |
+
COPY install_deps.sh /
|
| 21 |
+
RUN /install_deps.sh && rm /install_deps.sh
|
| 22 |
+
|
| 23 |
+
# Build and install latest Python 3.10.
|
| 24 |
+
ENV PYTHON_VERSION 3.10.14
|
| 25 |
+
RUN PYTHON_DEPS="\
|
| 26 |
+
zlib1g-dev \
|
| 27 |
+
libncurses5-dev \
|
| 28 |
+
libgdbm-dev \
|
| 29 |
+
libnss3-dev \
|
| 30 |
+
libssl-dev \
|
| 31 |
+
libsqlite3-dev \
|
| 32 |
+
libreadline-dev \
|
| 33 |
+
libffi-dev \
|
| 34 |
+
libbz2-dev \
|
| 35 |
+
liblzma-dev" && \
|
| 36 |
+
unset CFLAGS CXXFLAGS && \
|
| 37 |
+
apt-get install -y $PYTHON_DEPS && \
|
| 38 |
+
cd /tmp && \
|
| 39 |
+
curl -O https://www.python.org/ftp/python/$PYTHON_VERSION/Python-$PYTHON_VERSION.tar.xz && \
|
| 40 |
+
tar -xvf Python-$PYTHON_VERSION.tar.xz && \
|
| 41 |
+
cd Python-$PYTHON_VERSION && \
|
| 42 |
+
./configure --enable-optimizations --enable-shared && \
|
| 43 |
+
make -j$(nproc) install && \
|
| 44 |
+
ldconfig && \
|
| 45 |
+
ln -s /usr/local/bin/python3 /usr/local/bin/python && \
|
| 46 |
+
cd .. && \
|
| 47 |
+
rm -r /tmp/Python-$PYTHON_VERSION.tar.xz /tmp/Python-$PYTHON_VERSION && \
|
| 48 |
+
rm -rf /usr/local/lib/python${PYTHON_VERSION%.*}/test && \
|
| 49 |
+
python3 -m ensurepip && \
|
| 50 |
+
python3 -m pip install --upgrade pip && \
|
| 51 |
+
apt-get remove -y $PYTHON_DEPS # https://github.com/google/oss-fuzz/issues/3888
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
ENV CCACHE_VERSION 4.10.2
|
| 55 |
+
RUN cd /tmp && curl -OL https://github.com/ccache/ccache/releases/download/v$CCACHE_VERSION/ccache-$CCACHE_VERSION.tar.xz && \
|
| 56 |
+
tar -xvf ccache-$CCACHE_VERSION.tar.xz && cd ccache-$CCACHE_VERSION && \
|
| 57 |
+
mkdir build && cd build && \
|
| 58 |
+
export LDFLAGS='-lpthread' && \
|
| 59 |
+
cmake -D CMAKE_BUILD_TYPE=Release .. && \
|
| 60 |
+
make -j && make install && \
|
| 61 |
+
rm -rf /tmp/ccache-$CCACHE_VERSION /tmp/ccache-$CCACHE_VERSION.tar.xz
|
| 62 |
+
|
| 63 |
+
# Install six for Bazel rules.
|
| 64 |
+
RUN unset CFLAGS CXXFLAGS && pip3 install -v --no-cache-dir \
|
| 65 |
+
six==1.15.0 && rm -rf /tmp/*
|
| 66 |
+
|
| 67 |
+
# Install Bazel through Bazelisk, which automatically fetches the latest Bazel version.
|
| 68 |
+
ENV BAZELISK_VERSION 1.9.0
|
| 69 |
+
RUN curl -L https://github.com/bazelbuild/bazelisk/releases/download/v$BAZELISK_VERSION/bazelisk-linux-amd64 -o /usr/local/bin/bazel && \
|
| 70 |
+
chmod +x /usr/local/bin/bazel
|
| 71 |
+
|
| 72 |
+
# Default build flags for various sanitizers.
|
| 73 |
+
ENV SANITIZER_FLAGS_address "-fsanitize=address -fsanitize-address-use-after-scope"
|
| 74 |
+
ENV SANITIZER_FLAGS_hwaddress "-fsanitize=hwaddress -fuse-ld=lld -Wno-unused-command-line-argument"
|
| 75 |
+
|
| 76 |
+
# Set of '-fsanitize' flags matches '-fno-sanitize-recover' + 'unsigned-integer-overflow'.
|
| 77 |
+
ENV SANITIZER_FLAGS_undefined "-fsanitize=array-bounds,bool,builtin,enum,function,integer-divide-by-zero,null,object-size,return,returns-nonnull-attribute,shift,signed-integer-overflow,unsigned-integer-overflow,unreachable,vla-bound,vptr -fno-sanitize-recover=array-bounds,bool,builtin,enum,function,integer-divide-by-zero,null,object-size,return,returns-nonnull-attribute,shift,signed-integer-overflow,unreachable,vla-bound,vptr"
|
| 78 |
+
|
| 79 |
+
# Don't include "function" since it is unsupported on aarch64.
|
| 80 |
+
ENV SANITIZER_FLAGS_undefined_aarch64 "-fsanitize=array-bounds,bool,builtin,enum,integer-divide-by-zero,null,object-size,return,returns-nonnull-attribute,shift,signed-integer-overflow,unsigned-integer-overflow,unreachable,vla-bound,vptr -fno-sanitize-recover=array-bounds,bool,builtin,enum,integer-divide-by-zero,null,object-size,return,returns-nonnull-attribute,shift,signed-integer-overflow,unreachable,vla-bound,vptr"
|
| 81 |
+
|
| 82 |
+
ENV SANITIZER_FLAGS_memory "-fsanitize=memory -fsanitize-memory-track-origins"
|
| 83 |
+
|
| 84 |
+
ENV SANITIZER_FLAGS_thread "-fsanitize=thread"
|
| 85 |
+
|
| 86 |
+
ENV SANITIZER_FLAGS_introspector "-O0 -flto -fno-inline-functions -fuse-ld=gold -Wno-unused-command-line-argument"
|
| 87 |
+
|
| 88 |
+
# Do not use any sanitizers in the coverage build.
|
| 89 |
+
ENV SANITIZER_FLAGS_coverage ""
|
| 90 |
+
|
| 91 |
+
# We use unsigned-integer-overflow as an additional coverage signal and have to
|
| 92 |
+
# suppress error messages. See https://github.com/google/oss-fuzz/issues/910.
|
| 93 |
+
ENV UBSAN_OPTIONS="silence_unsigned_overflow=1"
|
| 94 |
+
|
| 95 |
+
# To suppress warnings from binaries running during compilation.
|
| 96 |
+
ENV DFSAN_OPTIONS='warn_unimplemented=0'
|
| 97 |
+
|
| 98 |
+
# Default build flags for coverage feedback.
|
| 99 |
+
ENV COVERAGE_FLAGS="-fsanitize=fuzzer-no-link"
|
| 100 |
+
|
| 101 |
+
# Use '-Wno-unused-command-line-argument' to suppress "warning: -ldl: 'linker' input unused"
|
| 102 |
+
# messages which are treated as errors by some projects.
|
| 103 |
+
ENV COVERAGE_FLAGS_coverage "-fprofile-instr-generate -fcoverage-mapping -pthread -Wl,--no-as-needed -Wl,-ldl -Wl,-lm -Wno-unused-command-line-argument"
|
| 104 |
+
|
| 105 |
+
# Default sanitizer, fuzzing engine and architecture to use.
|
| 106 |
+
ENV SANITIZER="address"
|
| 107 |
+
ENV FUZZING_ENGINE="libfuzzer"
|
| 108 |
+
ENV ARCHITECTURE="x86_64"
|
| 109 |
+
|
| 110 |
+
# DEPRECATED - NEW CODE SHOULD NOT USE THIS. OLD CODE SHOULD STOP. Please use
|
| 111 |
+
# LIB_FUZZING_ENGINE instead.
|
| 112 |
+
# Path to fuzzing engine library to support some old users of
|
| 113 |
+
# LIB_FUZZING_ENGINE.
|
| 114 |
+
ENV LIB_FUZZING_ENGINE_DEPRECATED="/usr/lib/libFuzzingEngine.a"
|
| 115 |
+
|
| 116 |
+
# Argument passed to compiler to link against fuzzing engine.
|
| 117 |
+
# Defaults to the path, but is "-fsanitize=fuzzer" in libFuzzer builds.
|
| 118 |
+
ENV LIB_FUZZING_ENGINE="/usr/lib/libFuzzingEngine.a"
|
| 119 |
+
|
| 120 |
+
# TODO: remove after tpm2 catchup.
|
| 121 |
+
ENV FUZZER_LDFLAGS ""
|
| 122 |
+
|
| 123 |
+
WORKDIR $SRC
|
| 124 |
+
|
| 125 |
+
RUN git clone https://github.com/AFLplusplus/AFLplusplus.git aflplusplus && \
|
| 126 |
+
cd aflplusplus && \
|
| 127 |
+
git checkout daaefcddc063b356018c29027494a00bcfc3e240 && \
|
| 128 |
+
wget --no-check-certificate -O oss.sh https://raw.githubusercontent.com/vanhauser-thc/binary_blobs/master/oss.sh && \
|
| 129 |
+
rm -rf .git && \
|
| 130 |
+
chmod 755 oss.sh
|
| 131 |
+
|
| 132 |
+
# Do precompiles before copying other scripts for better cache efficiency.
|
| 133 |
+
COPY precompile_afl /usr/local/bin/
|
| 134 |
+
RUN precompile_afl
|
| 135 |
+
|
| 136 |
+
RUN cd $SRC && \
|
| 137 |
+
curl -L -O https://github.com/google/honggfuzz/archive/oss-fuzz.tar.gz && \
|
| 138 |
+
mkdir honggfuzz && \
|
| 139 |
+
cd honggfuzz && \
|
| 140 |
+
tar -xz --strip-components=1 -f $SRC/oss-fuzz.tar.gz && \
|
| 141 |
+
rm -rf examples $SRC/oss-fuzz.tar.gz
|
| 142 |
+
|
| 143 |
+
|
| 144 |
+
COPY precompile_honggfuzz /usr/local/bin/
|
| 145 |
+
RUN precompile_honggfuzz
|
| 146 |
+
|
| 147 |
+
RUN cd $SRC && \
|
| 148 |
+
git clone https://github.com/google/fuzztest && \
|
| 149 |
+
cd fuzztest && \
|
| 150 |
+
git checkout a37d133f714395cabc20dd930969a889495c9f53 && \
|
| 151 |
+
rm -rf .git
|
| 152 |
+
|
| 153 |
+
ENV CENTIPEDE_BIN_DIR=$SRC/fuzztest/bazel-bin
|
| 154 |
+
COPY precompile_centipede /usr/local/bin/
|
| 155 |
+
RUN precompile_centipede
|
| 156 |
+
|
| 157 |
+
COPY sanitizers /usr/local/lib/sanitizers
|
| 158 |
+
|
| 159 |
+
COPY bazel_build_fuzz_tests \
|
| 160 |
+
cargo \
|
| 161 |
+
compile \
|
| 162 |
+
compile_afl \
|
| 163 |
+
compile_centipede \
|
| 164 |
+
compile_honggfuzz \
|
| 165 |
+
compile_fuzztests.sh \
|
| 166 |
+
compile_go_fuzzer \
|
| 167 |
+
compile_javascript_fuzzer \
|
| 168 |
+
compile_libfuzzer \
|
| 169 |
+
compile_native_go_fuzzer \
|
| 170 |
+
compile_python_fuzzer \
|
| 171 |
+
debug_afl \
|
| 172 |
+
# Go, JavaScript, Java, Python, Rust, and Swift installation scripts.
|
| 173 |
+
install_go.sh \
|
| 174 |
+
install_javascript.sh \
|
| 175 |
+
install_java.sh \
|
| 176 |
+
install_python.sh \
|
| 177 |
+
install_ruby.sh \
|
| 178 |
+
install_rust.sh \
|
| 179 |
+
install_swift.sh \
|
| 180 |
+
python_coverage_helper.py \
|
| 181 |
+
bash_parser.py \
|
| 182 |
+
srcmap \
|
| 183 |
+
write_labels.py \
|
| 184 |
+
/usr/local/bin/
|
| 185 |
+
|
| 186 |
+
# TODO: Build this as part of a multi-stage build.
|
| 187 |
+
ADD https://commondatastorage.googleapis.com/clusterfuzz-builds/jcc/clang-jcc /usr/local/bin/
|
| 188 |
+
ADD https://commondatastorage.googleapis.com/clusterfuzz-builds/jcc/clang++-jcc /usr/local/bin
|
| 189 |
+
ADD https://commondatastorage.googleapis.com/clusterfuzz-builds/jcc/clang-jcc2 /usr/local/bin/
|
| 190 |
+
ADD https://commondatastorage.googleapis.com/clusterfuzz-builds/jcc/clang++-jcc2 /usr/local/bin
|
| 191 |
+
RUN chmod +x /usr/local/bin/clang-jcc /usr/local/bin/clang++-jcc /usr/local/bin/clang-jcc2 /usr/local/bin/clang++-jcc2
|
| 192 |
+
|
| 193 |
+
COPY llvmsymbol.diff $SRC
|
| 194 |
+
COPY detect_repo.py /opt/cifuzz/
|
| 195 |
+
COPY bazel.bazelrc /root/.bazelrc
|
| 196 |
+
|
| 197 |
+
# Set up ccache binary and cache directory.
|
| 198 |
+
# /ccache/bin will contain the compiler wrappers, and /ccache/cache will
|
| 199 |
+
# contain the actual cache, which can be saved.
|
| 200 |
+
# To use this, set PATH=/ccache/bin:$PATH.
|
| 201 |
+
RUN mkdir -p /ccache/bin && mkdir -p /ccache/cache && \
|
| 202 |
+
ln -s /usr/local/bin/ccache /ccache/bin/clang && \
|
| 203 |
+
ln -s /usr/local/bin/ccache /ccache/bin/clang++ && \
|
| 204 |
+
ln -s /usr/local/bin/ccache /ccache/bin/clang-jcc && \
|
| 205 |
+
ln -s /usr/local/bin/ccache /ccache/bin/clang++-jcc
|
| 206 |
+
ENV CCACHE_DIR /ccache/cache
|
| 207 |
+
|
| 208 |
+
# Don't check that the compiler is the same, so we can switch between jcc and
|
| 209 |
+
# clang under the hood and re-use the same build cache.
|
| 210 |
+
ENV CCACHE_COMPILERCHECK none
|
| 211 |
+
ENV CCACHE_COMPILERTYPE clang
|
| 212 |
+
|
| 213 |
+
CMD ["compile"]
|
local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/bazel.bazelrc
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2022 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
#
|
| 15 |
+
################################################################################
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
# Pass variables from environment.
|
| 19 |
+
build --action_env=FUZZ_INTROSPECTOR
|
| 20 |
+
build --action_env=FUZZINTRO_OUTDIR
|
local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/bisect_clang.py
ADDED
|
@@ -0,0 +1,227 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
# Copyright 2019 Google Inc.
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
################################################################################
|
| 17 |
+
"""Use git bisect to find the Clang/LLVM commit causing a regression."""
|
| 18 |
+
|
| 19 |
+
import logging
|
| 20 |
+
import os
|
| 21 |
+
import re
|
| 22 |
+
import shutil
|
| 23 |
+
import subprocess
|
| 24 |
+
import sys
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def execute(command, *args, expect_zero=True, **kwargs):
|
| 28 |
+
"""Execute |command| and return the returncode, stdout and stderr."""
|
| 29 |
+
kwargs['stdout'] = subprocess.PIPE
|
| 30 |
+
kwargs['stderr'] = subprocess.PIPE
|
| 31 |
+
logging.debug('Running command: "%s"', str(command))
|
| 32 |
+
process = subprocess.Popen(command, *args, **kwargs)
|
| 33 |
+
stdout, stderr = process.communicate()
|
| 34 |
+
stdout = stdout.decode('utf-8')
|
| 35 |
+
stderr = stderr.decode('utf-8')
|
| 36 |
+
retcode = process.returncode
|
| 37 |
+
logging.info('Command: "%s" returned: %d.\nStdout: %s.\nStderr: %s',
|
| 38 |
+
str(command), retcode, stdout, stderr)
|
| 39 |
+
if expect_zero and retcode != 0:
|
| 40 |
+
raise subprocess.CalledProcessError(retcode, command)
|
| 41 |
+
return retcode, stdout, stderr
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
def search_bisect_output(output):
|
| 45 |
+
"""Search |output| for a message indicating the culprit commit has been
|
| 46 |
+
found."""
|
| 47 |
+
# TODO(metzman): Is it necessary to look for "good"?
|
| 48 |
+
culprit_regex = re.compile('([a-z0-9]{40}) is the first (good|bad) commit')
|
| 49 |
+
match = re.match(culprit_regex, output)
|
| 50 |
+
return match.group(1) if match is not None else None
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
class GitRepo:
|
| 54 |
+
"""Class for executing commmands on a git repo."""
|
| 55 |
+
|
| 56 |
+
def __init__(self, repo_dir):
|
| 57 |
+
self.repo_dir = repo_dir
|
| 58 |
+
|
| 59 |
+
def do_command(self, git_subcommand):
|
| 60 |
+
"""Execute a |git_subcommand| (a list of strings)."""
|
| 61 |
+
command = ['git', '-C', self.repo_dir] + git_subcommand
|
| 62 |
+
return execute(command)
|
| 63 |
+
|
| 64 |
+
def test_commit(self, test_command):
|
| 65 |
+
"""Build LLVM at the currently checkedout commit, then run |test_command|.
|
| 66 |
+
If returncode is 0 run 'git bisect good' otherwise return 'git bisect bad'.
|
| 67 |
+
Return None if bisect didn't finish yet. Return the culprit commit if it
|
| 68 |
+
does."""
|
| 69 |
+
build_clang(self.repo_dir)
|
| 70 |
+
retcode, _, _ = execute(test_command, shell=True, expect_zero=False)
|
| 71 |
+
if retcode == 0:
|
| 72 |
+
retcode, stdout, _ = self.do_bisect_command('good')
|
| 73 |
+
else:
|
| 74 |
+
retcode, stdout, _ = self.do_bisect_command('bad')
|
| 75 |
+
return search_bisect_output(stdout)
|
| 76 |
+
|
| 77 |
+
def bisect(self, good_commit, bad_commit, test_command):
|
| 78 |
+
"""Do git bisect assuming |good_commit| is good, |bad_commit| is bad and
|
| 79 |
+
|test_command| is an oracle. Return the culprit commit."""
|
| 80 |
+
self.bisect_start(good_commit, bad_commit, test_command)
|
| 81 |
+
result = self.test_commit(test_command)
|
| 82 |
+
while result is None:
|
| 83 |
+
result = self.test_commit(test_command)
|
| 84 |
+
return result
|
| 85 |
+
|
| 86 |
+
def bisect_start(self, good_commit, bad_commit, test_command):
|
| 87 |
+
"""Start doing git bisect."""
|
| 88 |
+
self.do_bisect_command('start')
|
| 89 |
+
# Do bad commit first since it is more likely to be recent.
|
| 90 |
+
self.test_start_commit(bad_commit, 'bad', test_command)
|
| 91 |
+
self.test_start_commit(good_commit, 'good', test_command)
|
| 92 |
+
|
| 93 |
+
def do_bisect_command(self, subcommand):
|
| 94 |
+
"""Execute a git bisect |subcommand| (string) and return the result."""
|
| 95 |
+
return self.do_command(['bisect', subcommand])
|
| 96 |
+
|
| 97 |
+
def test_start_commit(self, commit, label, test_command):
|
| 98 |
+
"""Use |test_command| to test the first good or bad |commit| (depending on
|
| 99 |
+
|label|)."""
|
| 100 |
+
assert label in ('good', 'bad'), label
|
| 101 |
+
self.do_command(['checkout', commit])
|
| 102 |
+
build_clang(self.repo_dir)
|
| 103 |
+
retcode, _, _ = execute(test_command, shell=True, expect_zero=False)
|
| 104 |
+
if label == 'good' and retcode != 0:
|
| 105 |
+
raise BisectError('Test command "%s" returns %d on first good commit %s' %
|
| 106 |
+
(test_command, retcode, commit))
|
| 107 |
+
if label == 'bad' and retcode == 0:
|
| 108 |
+
raise BisectError('Test command "%s" returns %d on first bad commit %s' %
|
| 109 |
+
(test_command, retcode, commit))
|
| 110 |
+
|
| 111 |
+
self.do_bisect_command(label)
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
class BisectError(Exception):
|
| 115 |
+
"""Error that was encountered during bisection."""
|
| 116 |
+
|
| 117 |
+
|
| 118 |
+
def get_clang_build_env():
|
| 119 |
+
"""Get an environment for building Clang."""
|
| 120 |
+
env = os.environ.copy()
|
| 121 |
+
for variable in ['CXXFLAGS', 'CFLAGS']:
|
| 122 |
+
if variable in env:
|
| 123 |
+
del env[variable]
|
| 124 |
+
return env
|
| 125 |
+
|
| 126 |
+
|
| 127 |
+
def install_clang_build_deps():
|
| 128 |
+
"""Instal dependencies necessary to build clang."""
|
| 129 |
+
execute([
|
| 130 |
+
'apt-get', 'install', '-y', 'build-essential', 'make', 'cmake',
|
| 131 |
+
'ninja-build', 'git', 'subversion', 'g++-multilib'
|
| 132 |
+
])
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
def clone_with_retries(repo, local_path, num_retries=10):
|
| 136 |
+
"""Clone |repo| to |local_path| if it doesn't exist already. Try up to
|
| 137 |
+
|num_retries| times. Return False if unable to checkout."""
|
| 138 |
+
if os.path.isdir(local_path):
|
| 139 |
+
return
|
| 140 |
+
for _ in range(num_retries):
|
| 141 |
+
if os.path.isdir(local_path):
|
| 142 |
+
shutil.rmtree(local_path)
|
| 143 |
+
retcode, _, _ = execute(['git', 'clone', repo, local_path],
|
| 144 |
+
expect_zero=False)
|
| 145 |
+
if retcode == 0:
|
| 146 |
+
return
|
| 147 |
+
raise Exception('Could not checkout %s.' % repo)
|
| 148 |
+
|
| 149 |
+
|
| 150 |
+
def get_clang_target_arch():
|
| 151 |
+
"""Get target architecture we want clang to target when we build it."""
|
| 152 |
+
_, arch, _ = execute(['uname', '-m'])
|
| 153 |
+
if 'x86_64' in arch:
|
| 154 |
+
return 'X86'
|
| 155 |
+
if 'aarch64' in arch:
|
| 156 |
+
return 'AArch64'
|
| 157 |
+
raise Exception('Unsupported target: %s.' % arch)
|
| 158 |
+
|
| 159 |
+
|
| 160 |
+
def prepare_build(llvm_project_path):
|
| 161 |
+
"""Prepare to build clang."""
|
| 162 |
+
llvm_build_dir = os.path.join(os.getenv('WORK'), 'llvm-build')
|
| 163 |
+
if not os.path.exists(llvm_build_dir):
|
| 164 |
+
os.mkdir(llvm_build_dir)
|
| 165 |
+
execute([
|
| 166 |
+
'cmake', '-G', 'Ninja', '-DLIBCXX_ENABLE_SHARED=OFF',
|
| 167 |
+
'-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON', '-DLIBCXXABI_ENABLE_SHARED=OFF',
|
| 168 |
+
'-DCMAKE_BUILD_TYPE=Release',
|
| 169 |
+
'-DLLVM_ENABLE_PROJECTS=libcxx;libcxxabi;compiler-rt;clang',
|
| 170 |
+
'-DLLVM_TARGETS_TO_BUILD=' + get_clang_target_arch(),
|
| 171 |
+
os.path.join(llvm_project_path, 'llvm')
|
| 172 |
+
],
|
| 173 |
+
env=get_clang_build_env(),
|
| 174 |
+
cwd=llvm_build_dir)
|
| 175 |
+
return llvm_build_dir
|
| 176 |
+
|
| 177 |
+
|
| 178 |
+
def build_clang(llvm_project_path):
|
| 179 |
+
"""Checkout, build and install Clang."""
|
| 180 |
+
# TODO(metzman): Merge Python checkout and build code with
|
| 181 |
+
# checkout_build_install_llvm.sh.
|
| 182 |
+
# TODO(metzman): Look into speeding this process using ccache.
|
| 183 |
+
# TODO(metzman): Make this program capable of handling MSAN and i386 Clang
|
| 184 |
+
# regressions.
|
| 185 |
+
llvm_build_dir = prepare_build(llvm_project_path)
|
| 186 |
+
execute(['ninja', '-C', llvm_build_dir, 'install'], env=get_clang_build_env())
|
| 187 |
+
|
| 188 |
+
|
| 189 |
+
def find_culprit_commit(test_command, good_commit, bad_commit):
|
| 190 |
+
"""Returns the culprit LLVM commit that introduced a bug revealed by running
|
| 191 |
+
|test_command|. Uses git bisect and treats |good_commit| as the first latest
|
| 192 |
+
known good commit and |bad_commit| as the first known bad commit."""
|
| 193 |
+
llvm_project_path = os.path.join(os.getenv('SRC'), 'llvm-project')
|
| 194 |
+
clone_with_retries('https://github.com/llvm/llvm-project.git',
|
| 195 |
+
llvm_project_path)
|
| 196 |
+
git_repo = GitRepo(llvm_project_path)
|
| 197 |
+
result = git_repo.bisect(good_commit, bad_commit, test_command)
|
| 198 |
+
print('Culprit commit', result)
|
| 199 |
+
return result
|
| 200 |
+
|
| 201 |
+
|
| 202 |
+
def main():
|
| 203 |
+
# pylint: disable=line-too-long
|
| 204 |
+
"""Finds the culprit LLVM commit that introduced a clang regression.
|
| 205 |
+
Can be tested using this command in a libsodium shell:
|
| 206 |
+
python3 bisect_clang.py "cd /src/libsodium; make clean; cd -; compile && /out/secret_key_auth_fuzzer -runs=100" \
|
| 207 |
+
f7e52fbdb5a7af8ea0808e98458b497125a5eca1 \
|
| 208 |
+
8288453f6aac05080b751b680455349e09d49825
|
| 209 |
+
"""
|
| 210 |
+
# pylint: enable=line-too-long
|
| 211 |
+
# TODO(metzman): Check CFLAGS for things like -fsanitize=fuzzer-no-link.
|
| 212 |
+
# TODO(metzman): Allow test_command to be optional and for just build.sh to be
|
| 213 |
+
# used instead.
|
| 214 |
+
test_command = sys.argv[1]
|
| 215 |
+
# TODO(metzman): Add in more automation so that the script can automatically
|
| 216 |
+
# determine the commits used in last Clang roll.
|
| 217 |
+
good_commit = sys.argv[2]
|
| 218 |
+
bad_commit = sys.argv[3]
|
| 219 |
+
# TODO(metzman): Make verbosity configurable.
|
| 220 |
+
logging.getLogger().setLevel(logging.DEBUG)
|
| 221 |
+
install_clang_build_deps()
|
| 222 |
+
find_culprit_commit(test_command, good_commit, bad_commit)
|
| 223 |
+
return 0
|
| 224 |
+
|
| 225 |
+
|
| 226 |
+
if __name__ == '__main__':
|
| 227 |
+
sys.exit(main())
|
local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/compile
ADDED
|
@@ -0,0 +1,420 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash -eu
|
| 2 |
+
# Copyright 2016 Google Inc.
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
################################################################################
|
| 17 |
+
|
| 18 |
+
echo "---------------------------------------------------------------"
|
| 19 |
+
|
| 20 |
+
sysctl -w vm.mmap_rnd_bits=28
|
| 21 |
+
|
| 22 |
+
OSS_FUZZ_ON_DEMAND="${OSS_FUZZ_ON_DEMAND:-0}"
|
| 23 |
+
|
| 24 |
+
# Used for Rust introspector builds
|
| 25 |
+
RUST_SANITIZER=$SANITIZER
|
| 26 |
+
|
| 27 |
+
if [ "$FUZZING_LANGUAGE" = "jvm" ]; then
|
| 28 |
+
if [ "$FUZZING_ENGINE" != "libfuzzer" ] && [ "$FUZZING_ENGINE" != "wycheproof" ]; then
|
| 29 |
+
echo "ERROR: JVM projects can be fuzzed with libFuzzer or tested with wycheproof engines only."
|
| 30 |
+
exit 1
|
| 31 |
+
fi
|
| 32 |
+
if [ "$SANITIZER" != "address" ] && [ "$SANITIZER" != "coverage" ] && [ "$SANITIZER" != "undefined" ] && [ "$SANITIZER" != "none" ] && [ "$SANITIZER" != "introspector" ]; then
|
| 33 |
+
echo "ERROR: JVM projects can be fuzzed with AddressSanitizer or UndefinedBehaviorSanitizer or Introspector only."
|
| 34 |
+
exit 1
|
| 35 |
+
fi
|
| 36 |
+
if [ "$ARCHITECTURE" != "x86_64" ]; then
|
| 37 |
+
echo "ERROR: JVM projects can be fuzzed on x86_64 architecture only."
|
| 38 |
+
exit 1
|
| 39 |
+
fi
|
| 40 |
+
fi
|
| 41 |
+
|
| 42 |
+
if [ "$FUZZING_LANGUAGE" = "rust" ]; then
|
| 43 |
+
if [ "$SANITIZER" = "introspector" ]; then
|
| 44 |
+
# introspector sanitizer flag will cause cargo build to fail. Rremove it
|
| 45 |
+
# temporarily, RUST_SANITIZER will hold the original sanitizer.
|
| 46 |
+
export SANITIZER=address
|
| 47 |
+
fi
|
| 48 |
+
fi
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
if [ "$FUZZING_LANGUAGE" = "javascript" ]; then
|
| 52 |
+
if [ "$FUZZING_ENGINE" != "libfuzzer" ]; then
|
| 53 |
+
echo "ERROR: JavaScript projects can be fuzzed with libFuzzer engine only."
|
| 54 |
+
exit 1
|
| 55 |
+
fi
|
| 56 |
+
if [ "$SANITIZER" != "coverage" ] && [ "$SANITIZER" != "none" ]; then
|
| 57 |
+
echo "ERROR: JavaScript projects cannot be fuzzed with sanitizers."
|
| 58 |
+
exit 1
|
| 59 |
+
fi
|
| 60 |
+
if [ "$ARCHITECTURE" != "x86_64" ]; then
|
| 61 |
+
echo "ERROR: JavaScript projects can be fuzzed on x86_64 architecture only."
|
| 62 |
+
exit 1
|
| 63 |
+
fi
|
| 64 |
+
fi
|
| 65 |
+
|
| 66 |
+
if [ "$FUZZING_LANGUAGE" = "python" ]; then
|
| 67 |
+
if [ "$FUZZING_ENGINE" != "libfuzzer" ]; then
|
| 68 |
+
echo "ERROR: Python projects can be fuzzed with libFuzzer engine only."
|
| 69 |
+
exit 1
|
| 70 |
+
fi
|
| 71 |
+
if [ "$SANITIZER" != "address" ] && [ "$SANITIZER" != "undefined" ] && [ "$SANITIZER" != "coverage" ] && [ "$SANITIZER" != "introspector" ]; then
|
| 72 |
+
echo "ERROR: Python projects can be fuzzed with AddressSanitizer or UndefinedBehaviorSanitizer or Coverage or Fuzz Introspector only."
|
| 73 |
+
exit 1
|
| 74 |
+
fi
|
| 75 |
+
if [ "$ARCHITECTURE" != "x86_64" ]; then
|
| 76 |
+
echo "ERROR: Python projects can be fuzzed on x86_64 architecture only."
|
| 77 |
+
exit 1
|
| 78 |
+
fi
|
| 79 |
+
fi
|
| 80 |
+
|
| 81 |
+
if [ -z "${SANITIZER_FLAGS-}" ]; then
|
| 82 |
+
FLAGS_VAR="SANITIZER_FLAGS_${SANITIZER}"
|
| 83 |
+
export SANITIZER_FLAGS=${!FLAGS_VAR-}
|
| 84 |
+
fi
|
| 85 |
+
|
| 86 |
+
if [[ $ARCHITECTURE == "i386" ]]; then
|
| 87 |
+
export CFLAGS="-m32 $CFLAGS"
|
| 88 |
+
cp -R /usr/i386/lib/* /usr/local/lib
|
| 89 |
+
cp -R /usr/i386/include/* /usr/local/include
|
| 90 |
+
fi
|
| 91 |
+
|
| 92 |
+
# Don't use a fuzzing engine with Jazzer which has libFuzzer built-in or with
|
| 93 |
+
# FuzzBench which will provide the fuzzing engine.
|
| 94 |
+
if [[ $FUZZING_ENGINE != "none" ]] && [[ $FUZZING_LANGUAGE != "jvm" ]] && [[ "${OSS_FUZZ_ON_DEMAND}" == "0" ]] ; then
|
| 95 |
+
# compile script might override environment, use . to call it.
|
| 96 |
+
. compile_${FUZZING_ENGINE}
|
| 97 |
+
fi
|
| 98 |
+
|
| 99 |
+
if [[ $SANITIZER_FLAGS = *sanitize=memory* ]]
|
| 100 |
+
then
|
| 101 |
+
# Take all libraries from lib/msan
|
| 102 |
+
# export CXXFLAGS_EXTRA="-L/usr/msan/lib $CXXFLAGS_EXTRA"
|
| 103 |
+
cp -R /usr/msan/lib/* /usr/local/lib/x86_64-unknown-linux-gnu/
|
| 104 |
+
cp -R /usr/msan/include/* /usr/local/include
|
| 105 |
+
|
| 106 |
+
echo 'Building without MSan instrumented libraries.'
|
| 107 |
+
fi
|
| 108 |
+
|
| 109 |
+
# Coverage flag overrides.
|
| 110 |
+
COVERAGE_FLAGS_VAR="COVERAGE_FLAGS_${SANITIZER}"
|
| 111 |
+
if [[ -n ${!COVERAGE_FLAGS_VAR+x} ]]
|
| 112 |
+
then
|
| 113 |
+
export COVERAGE_FLAGS="${!COVERAGE_FLAGS_VAR}"
|
| 114 |
+
fi
|
| 115 |
+
|
| 116 |
+
# Only need the default coverage instrumentation for libFuzzer or honggfuzz.
|
| 117 |
+
# Other engines bring their own.
|
| 118 |
+
if [ $FUZZING_ENGINE = "none" ] || [ $FUZZING_ENGINE = "afl" ] || [ $FUZZING_ENGINE = "centipede" ] || [ "${OSS_FUZZ_ON_DEMAND}" != "0" ]; then
|
| 119 |
+
export COVERAGE_FLAGS=
|
| 120 |
+
fi
|
| 121 |
+
|
| 122 |
+
# Rust does not support sanitizers and coverage flags via CFLAGS/CXXFLAGS, so
|
| 123 |
+
# use RUSTFLAGS.
|
| 124 |
+
# FIXME: Support code coverage once support is in.
|
| 125 |
+
# See https://github.com/rust-lang/rust/issues/34701.
|
| 126 |
+
if [ "$RUST_SANITIZER" == "introspector" ]; then
|
| 127 |
+
export RUSTFLAGS="-Cdebuginfo=2 -Cforce-frame-pointers"
|
| 128 |
+
elif [ "$SANITIZER" != "undefined" ] && [ "$SANITIZER" != "coverage" ] && [ "$SANITIZER" != "none" ] && [ "$ARCHITECTURE" != 'i386' ]; then
|
| 129 |
+
export RUSTFLAGS="--cfg fuzzing -Zsanitizer=${SANITIZER} -Cdebuginfo=1 -Cforce-frame-pointers"
|
| 130 |
+
else
|
| 131 |
+
export RUSTFLAGS="--cfg fuzzing -Cdebuginfo=1 -Cforce-frame-pointers"
|
| 132 |
+
fi
|
| 133 |
+
if [ "$SANITIZER" = "coverage" ]
|
| 134 |
+
then
|
| 135 |
+
# link to C++ from comment in f5098035eb1a14aa966c8651d88ea3d64323823d
|
| 136 |
+
export RUSTFLAGS="$RUSTFLAGS -Cinstrument-coverage -C link-arg=-lc++"
|
| 137 |
+
fi
|
| 138 |
+
|
| 139 |
+
# Add Rust libfuzzer flags.
|
| 140 |
+
# See https://github.com/rust-fuzz/libfuzzer/blob/master/build.rs#L12.
|
| 141 |
+
export CUSTOM_LIBFUZZER_PATH="$LIB_FUZZING_ENGINE_DEPRECATED"
|
| 142 |
+
export CUSTOM_LIBFUZZER_STD_CXX=c++
|
| 143 |
+
|
| 144 |
+
export CFLAGS="$CFLAGS $SANITIZER_FLAGS $COVERAGE_FLAGS"
|
| 145 |
+
export CXXFLAGS="$CFLAGS $CXXFLAGS_EXTRA"
|
| 146 |
+
|
| 147 |
+
if [ "$SANITIZER" = "undefined" ]; then
|
| 148 |
+
# Disable "function" sanitizer for C code for now, because many projects,
|
| 149 |
+
# possibly via legacy C code are affected.
|
| 150 |
+
# The projects should be fixed and this workaround be removed in the future.
|
| 151 |
+
# TODO(#11778):
|
| 152 |
+
# https://github.com/google/oss-fuzz/issues/11778
|
| 153 |
+
export CFLAGS="$CFLAGS -fno-sanitize=function"
|
| 154 |
+
fi
|
| 155 |
+
|
| 156 |
+
if [ "$FUZZING_LANGUAGE" = "go" ]; then
|
| 157 |
+
# required by Go 1.20
|
| 158 |
+
export CXX="${CXX} -lresolv"
|
| 159 |
+
fi
|
| 160 |
+
|
| 161 |
+
if [ "$FUZZING_LANGUAGE" = "python" ]; then
|
| 162 |
+
sanitizer_with_fuzzer_lib_dir=`python3 -c "import atheris; import os; print(atheris.path())"`
|
| 163 |
+
sanitizer_with_fuzzer_output_lib=$OUT/sanitizer_with_fuzzer.so
|
| 164 |
+
if [ "$SANITIZER" = "address" ]; then
|
| 165 |
+
cp $sanitizer_with_fuzzer_lib_dir/asan_with_fuzzer.so $sanitizer_with_fuzzer_output_lib
|
| 166 |
+
elif [ "$SANITIZER" = "undefined" ]; then
|
| 167 |
+
cp $sanitizer_with_fuzzer_lib_dir/ubsan_with_fuzzer.so $sanitizer_with_fuzzer_output_lib
|
| 168 |
+
fi
|
| 169 |
+
|
| 170 |
+
# Disable leak checking as it is unsupported.
|
| 171 |
+
export CFLAGS="$CFLAGS -fno-sanitize=function,leak,vptr,"
|
| 172 |
+
export CXXFLAGS="$CXXFLAGS -fno-sanitize=function,leak,vptr"
|
| 173 |
+
fi
|
| 174 |
+
|
| 175 |
+
# Copy latest llvm-symbolizer in $OUT for stack symbolization.
|
| 176 |
+
cp $(which llvm-symbolizer) $OUT/
|
| 177 |
+
|
| 178 |
+
# Copy Jazzer to $OUT if needed.
|
| 179 |
+
if [ "$FUZZING_LANGUAGE" = "jvm" ]; then
|
| 180 |
+
cp $(which jazzer_agent_deploy.jar) $(which jazzer_driver) $(which jazzer_junit.jar) $OUT/
|
| 181 |
+
jazzer_driver_with_sanitizer=$OUT/jazzer_driver_with_sanitizer
|
| 182 |
+
if [ "$SANITIZER" = "address" ]; then
|
| 183 |
+
cat > $jazzer_driver_with_sanitizer << 'EOF'
|
| 184 |
+
#!/bin/bash
|
| 185 |
+
this_dir=$(dirname "$0")
|
| 186 |
+
"$this_dir/jazzer_driver" --asan "$@"
|
| 187 |
+
EOF
|
| 188 |
+
elif [ "$SANITIZER" = "undefined" ]; then
|
| 189 |
+
cat > $jazzer_driver_with_sanitizer << 'EOF'
|
| 190 |
+
#!/bin/bash
|
| 191 |
+
this_dir=$(dirname "$0")
|
| 192 |
+
"$this_dir/jazzer_driver" --ubsan "$@"
|
| 193 |
+
EOF
|
| 194 |
+
elif [ "$SANITIZER" = "coverage" ] || [ "$SANITIZER" = "introspector" ]; then
|
| 195 |
+
# Coverage & introspector builds require no instrumentation.
|
| 196 |
+
cp $(which jazzer_driver) $jazzer_driver_with_sanitizer
|
| 197 |
+
fi
|
| 198 |
+
chmod +x $jazzer_driver_with_sanitizer
|
| 199 |
+
|
| 200 |
+
# Disable leak checking since the JVM triggers too many false positives.
|
| 201 |
+
export CFLAGS="$CFLAGS -fno-sanitize=leak"
|
| 202 |
+
export CXXFLAGS="$CXXFLAGS -fno-sanitize=leak"
|
| 203 |
+
fi
|
| 204 |
+
|
| 205 |
+
if [ "$SANITIZER" = "introspector" ] || [ "$RUST_SANITIZER" = "introspector" ]; then
|
| 206 |
+
export AR=llvm-ar
|
| 207 |
+
export NM=llvm-nm
|
| 208 |
+
export RANLIB=llvm-ranlib
|
| 209 |
+
|
| 210 |
+
export CFLAGS="$CFLAGS -g"
|
| 211 |
+
export CXXFLAGS="$CXXFLAGS -g"
|
| 212 |
+
export FI_BRANCH_PROFILE=1
|
| 213 |
+
export FUZZ_INTROSPECTOR=1
|
| 214 |
+
export FUZZ_INTROSPECTOR_AUTO_FUZZ=1
|
| 215 |
+
|
| 216 |
+
# Move ar and ranlib
|
| 217 |
+
mv /usr/bin/ar /usr/bin/old-ar
|
| 218 |
+
mv /usr/bin/nm /usr/bin/old-nm
|
| 219 |
+
mv /usr/bin/ranlib /usr/bin/old-ranlib
|
| 220 |
+
|
| 221 |
+
ln -sf /usr/local/bin/llvm-ar /usr/bin/ar
|
| 222 |
+
ln -sf /usr/local/bin/llvm-nm /usr/bin/nm
|
| 223 |
+
ln -sf /usr/local/bin/llvm-ranlib /usr/bin/ranlib
|
| 224 |
+
|
| 225 |
+
apt-get install -y libjpeg-dev zlib1g-dev libyaml-dev
|
| 226 |
+
python3 -m pip install --upgrade pip setuptools
|
| 227 |
+
python3 -m pip install cxxfilt pyyaml beautifulsoup4 lxml soupsieve rust-demangler
|
| 228 |
+
python3 -m pip install --prefer-binary matplotlib
|
| 229 |
+
|
| 230 |
+
# Install Fuzz-Introspector
|
| 231 |
+
pushd /fuzz-introspector/src
|
| 232 |
+
python3 -m pip install -e .
|
| 233 |
+
popd
|
| 234 |
+
|
| 235 |
+
if [ "$FUZZING_LANGUAGE" = "python" ]; then
|
| 236 |
+
python3 /fuzz-introspector/src/main.py light --language=python
|
| 237 |
+
cp -rf $SRC/inspector/ /tmp/inspector-saved
|
| 238 |
+
elif [ "$FUZZING_LANGUAGE" = "jvm" ]; then
|
| 239 |
+
python3 /fuzz-introspector/src/main.py light --language=jvm
|
| 240 |
+
cp -rf $SRC/inspector/ /tmp/inspector-saved
|
| 241 |
+
elif [ "$FUZZING_LANGUAGE" = "rust" ]; then
|
| 242 |
+
python3 /fuzz-introspector/src/main.py light --language=rust
|
| 243 |
+
cp -rf $SRC/inspector/ /tmp/inspector-saved
|
| 244 |
+
else
|
| 245 |
+
python3 /fuzz-introspector/src/main.py light
|
| 246 |
+
|
| 247 |
+
# Make a copy of the light. This is needed because we run two versions of
|
| 248 |
+
# introspector: one based on pure statis analysis and one based on
|
| 249 |
+
# regular LTO.
|
| 250 |
+
cp -rf $SRC/inspector/ /tmp/inspector-saved
|
| 251 |
+
|
| 252 |
+
|
| 253 |
+
# Move coverage report.
|
| 254 |
+
if [ -d "$OUT/textcov_reports" ]
|
| 255 |
+
then
|
| 256 |
+
find $OUT/textcov_reports/ -name "*.covreport" -exec cp {} $SRC/inspector/ \;
|
| 257 |
+
find $OUT/textcov_reports/ -name "*.json" -exec cp {} $SRC/inspector/ \;
|
| 258 |
+
fi
|
| 259 |
+
|
| 260 |
+
# Make fuzz-introspector HTML report using light approach.
|
| 261 |
+
REPORT_ARGS="--name=$PROJECT_NAME"
|
| 262 |
+
|
| 263 |
+
# Only pass coverage_url when COVERAGE_URL is set (in cloud builds)
|
| 264 |
+
if [[ ! -z "${COVERAGE_URL+x}" ]]; then
|
| 265 |
+
REPORT_ARGS="$REPORT_ARGS --coverage-url=${COVERAGE_URL}"
|
| 266 |
+
fi
|
| 267 |
+
|
| 268 |
+
# Run pure static analysis fuzz introspector
|
| 269 |
+
fuzz-introspector full --target-dir=$SRC \
|
| 270 |
+
--language=${FUZZING_LANGUAGE} \
|
| 271 |
+
--out-dir=$SRC/inspector \
|
| 272 |
+
${REPORT_ARGS}
|
| 273 |
+
fi
|
| 274 |
+
|
| 275 |
+
rsync -avu --delete "$SRC/inspector/" "$OUT/inspector"
|
| 276 |
+
fi
|
| 277 |
+
|
| 278 |
+
echo "---------------------------------------------------------------"
|
| 279 |
+
echo "CC=$CC"
|
| 280 |
+
echo "CXX=$CXX"
|
| 281 |
+
echo "CFLAGS=$CFLAGS"
|
| 282 |
+
echo "CXXFLAGS=$CXXFLAGS"
|
| 283 |
+
echo "RUSTFLAGS=$RUSTFLAGS"
|
| 284 |
+
echo "---------------------------------------------------------------"
|
| 285 |
+
|
| 286 |
+
if [ "${OSS_FUZZ_ON_DEMAND}" != "0" ]; then
|
| 287 |
+
fuzzbench_build
|
| 288 |
+
cp $(which llvm-symbolizer) $OUT/
|
| 289 |
+
exit 0
|
| 290 |
+
fi
|
| 291 |
+
|
| 292 |
+
|
| 293 |
+
if [[ ! -z "${CAPTURE_REPLAY_SCRIPT-}" ]]; then
|
| 294 |
+
# Capture a replaying build script which can be used for replaying the build
|
| 295 |
+
# after a vanilla build. This script is meant to be used in a cached
|
| 296 |
+
# container.
|
| 297 |
+
python3 -m pip install bashlex
|
| 298 |
+
python3 /usr/local/bin/bash_parser.py $SRC/build.sh
|
| 299 |
+
fi
|
| 300 |
+
|
| 301 |
+
# Prepare the build command to run the project's build script.
|
| 302 |
+
if [[ ! -z "${REPLAY_ENABLED-}" ]]; then
|
| 303 |
+
# If this is a replay, then use replay_build.sh. This is expected to be
|
| 304 |
+
# running in a cached container where a build has already happened prior.
|
| 305 |
+
BUILD_CMD="bash -eux $SRC/replay_build.sh"
|
| 306 |
+
else
|
| 307 |
+
BUILD_CMD="bash -eux $SRC/build.sh"
|
| 308 |
+
fi
|
| 309 |
+
|
| 310 |
+
# Set +u temporarily to continue even if GOPATH and OSSFUZZ_RUSTPATH are undefined.
|
| 311 |
+
set +u
|
| 312 |
+
# We need to preserve source code files for generating a code coverage report.
|
| 313 |
+
# We need exact files that were compiled, so copy both $SRC and $WORK dirs.
|
| 314 |
+
COPY_SOURCES_CMD="cp -rL --parents $SRC $WORK /usr/include /usr/local/include $GOPATH $OSSFUZZ_RUSTPATH /rustc $OUT"
|
| 315 |
+
set -u
|
| 316 |
+
|
| 317 |
+
if [ "$FUZZING_LANGUAGE" = "rust" ]; then
|
| 318 |
+
# Copy rust std lib to its path with a hash.
|
| 319 |
+
export rustch=`rustc --version --verbose | grep commit-hash | cut -d' ' -f2`
|
| 320 |
+
mkdir -p /rustc/$rustch/
|
| 321 |
+
export rustdef=`rustup toolchain list | grep default | cut -d' ' -f1`
|
| 322 |
+
cp -r /rust/rustup/toolchains/$rustdef/lib/rustlib/src/rust/library/ /rustc/$rustch/
|
| 323 |
+
fi
|
| 324 |
+
|
| 325 |
+
if [ "${BUILD_UID-0}" -ne "0" ]; then
|
| 326 |
+
adduser -u $BUILD_UID --disabled-password --gecos '' builder
|
| 327 |
+
chown -R builder $SRC $OUT $WORK
|
| 328 |
+
su -c "$BUILD_CMD" builder
|
| 329 |
+
if [ "$SANITIZER" = "coverage" ]; then
|
| 330 |
+
# Some directories have broken symlinks (e.g. honggfuzz), ignore the errors.
|
| 331 |
+
su -c "$COPY_SOURCES_CMD" builder 2>/dev/null || true
|
| 332 |
+
fi
|
| 333 |
+
else
|
| 334 |
+
$BUILD_CMD
|
| 335 |
+
if [ "$SANITIZER" = "coverage" ]; then
|
| 336 |
+
# Some directories have broken symlinks (e.g. honggfuzz), ignore the errors.
|
| 337 |
+
$COPY_SOURCES_CMD 2>/dev/null || true
|
| 338 |
+
fi
|
| 339 |
+
fi
|
| 340 |
+
|
| 341 |
+
if [ "$SANITIZER" = "introspector" ] || [ "$RUST_SANITIZER" = "introspector" ]; then
|
| 342 |
+
unset CXXFLAGS
|
| 343 |
+
unset CFLAGS
|
| 344 |
+
export G_ANALYTICS_TAG="G-8WTFM1Y62J"
|
| 345 |
+
|
| 346 |
+
# If we get to here, it means the e.g. LTO had no problems and succeeded.
|
| 347 |
+
# TO this end, we wlil restore the original light analysis and used the
|
| 348 |
+
# LTO processing itself.
|
| 349 |
+
rm -rf $SRC/inspector
|
| 350 |
+
cp -rf /tmp/inspector-saved $SRC/inspector
|
| 351 |
+
|
| 352 |
+
cd /fuzz-introspector/src
|
| 353 |
+
python3 -m pip install -e .
|
| 354 |
+
cd /src/
|
| 355 |
+
|
| 356 |
+
if [ "$FUZZING_LANGUAGE" = "rust" ]; then
|
| 357 |
+
# Restore the sanitizer flag for rust
|
| 358 |
+
export SANITIZER="introspector"
|
| 359 |
+
fi
|
| 360 |
+
|
| 361 |
+
mkdir -p $SRC/inspector
|
| 362 |
+
find $SRC/ -name "fuzzerLogFile-*.data" -exec cp {} $SRC/inspector/ \;
|
| 363 |
+
find $SRC/ -name "fuzzerLogFile-*.data.yaml" -exec cp {} $SRC/inspector/ \;
|
| 364 |
+
find $SRC/ -name "fuzzerLogFile-*.data.debug_*" -exec cp {} $SRC/inspector/ \;
|
| 365 |
+
find $SRC/ -name "allFunctionsWithMain-*.yaml" -exec cp {} $SRC/inspector/ \;
|
| 366 |
+
|
| 367 |
+
# Move coverage report.
|
| 368 |
+
if [ -d "$OUT/textcov_reports" ]
|
| 369 |
+
then
|
| 370 |
+
find $OUT/textcov_reports/ -name "*.covreport" -exec cp {} $SRC/inspector/ \;
|
| 371 |
+
find $OUT/textcov_reports/ -name "*.json" -exec cp {} $SRC/inspector/ \;
|
| 372 |
+
fi
|
| 373 |
+
|
| 374 |
+
cd $SRC/inspector
|
| 375 |
+
|
| 376 |
+
# Make fuzz-introspector HTML report.
|
| 377 |
+
REPORT_ARGS="--name=$PROJECT_NAME"
|
| 378 |
+
# Only pass coverage_url when COVERAGE_URL is set (in cloud builds)
|
| 379 |
+
if [[ ! -z "${COVERAGE_URL+x}" ]]; then
|
| 380 |
+
REPORT_ARGS="$REPORT_ARGS --coverage-url=${COVERAGE_URL}"
|
| 381 |
+
fi
|
| 382 |
+
|
| 383 |
+
# Do different things depending on languages
|
| 384 |
+
if [ "$FUZZING_LANGUAGE" = "python" ]; then
|
| 385 |
+
echo "GOING python route"
|
| 386 |
+
set -x
|
| 387 |
+
REPORT_ARGS="$REPORT_ARGS --target-dir=$SRC/inspector"
|
| 388 |
+
REPORT_ARGS="$REPORT_ARGS --language=python"
|
| 389 |
+
fuzz-introspector report $REPORT_ARGS
|
| 390 |
+
rsync -avu --delete "$SRC/inspector/" "$OUT/inspector"
|
| 391 |
+
elif [ "$FUZZING_LANGUAGE" = "jvm" ]; then
|
| 392 |
+
echo "GOING jvm route"
|
| 393 |
+
set -x
|
| 394 |
+
find $OUT/ -name "jacoco.xml" -exec cp {} $SRC/inspector/ \;
|
| 395 |
+
REPORT_ARGS="$REPORT_ARGS --target-dir=$SRC --out-dir=$SRC/inspector"
|
| 396 |
+
REPORT_ARGS="$REPORT_ARGS --language=jvm"
|
| 397 |
+
fuzz-introspector full $REPORT_ARGS
|
| 398 |
+
rsync -avu --delete "$SRC/inspector/" "$OUT/inspector"
|
| 399 |
+
elif [ "$FUZZING_LANGUAGE" = "rust" ]; then
|
| 400 |
+
echo "GOING rust route"
|
| 401 |
+
REPORT_ARGS="$REPORT_ARGS --target-dir=$SRC --out-dir=$SRC/inspector"
|
| 402 |
+
REPORT_ARGS="$REPORT_ARGS --language=rust"
|
| 403 |
+
fuzz-introspector full $REPORT_ARGS
|
| 404 |
+
rsync -avu --delete "$SRC/inspector/" "$OUT/inspector"
|
| 405 |
+
else
|
| 406 |
+
# C/C++
|
| 407 |
+
mkdir -p $SRC/inspector
|
| 408 |
+
# Correlate fuzzer binaries to fuzz-introspector's raw data
|
| 409 |
+
fuzz-introspector correlate --binaries-dir=$OUT/
|
| 410 |
+
|
| 411 |
+
# Generate fuzz-introspector HTML report, this generates
|
| 412 |
+
# the file exe_to_fuzz_introspector_logs.yaml
|
| 413 |
+
REPORT_ARGS="$REPORT_ARGS --target-dir=$SRC/inspector"
|
| 414 |
+
# Use the just-generated correlation file
|
| 415 |
+
REPORT_ARGS="$REPORT_ARGS --correlation-file=exe_to_fuzz_introspector_logs.yaml"
|
| 416 |
+
fuzz-introspector report $REPORT_ARGS
|
| 417 |
+
|
| 418 |
+
rsync -avu --delete "$SRC/inspector/" "$OUT/inspector"
|
| 419 |
+
fi
|
| 420 |
+
fi
|
local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/compile_centipede
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash -eu
|
| 2 |
+
# Copyright 2022 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
################################################################################
|
| 17 |
+
|
| 18 |
+
echo "Skipping compilation; using precompiled centipede"
|
| 19 |
+
|
| 20 |
+
if [[ "$SANITIZER" == 'none' ]]; then
|
| 21 |
+
cp "$CENTIPEDE_BIN_DIR/centipede" "$OUT"
|
| 22 |
+
fi
|
| 23 |
+
|
| 24 |
+
cp "$CENTIPEDE_BIN_DIR/libcentipede_runner.pic.a" "$LIB_FUZZING_ENGINE"
|
| 25 |
+
|
| 26 |
+
export CENTIPEDE_FLAGS=`cat "$SRC/fuzztest/centipede/clang-flags.txt" | tr '\n' ' '`
|
| 27 |
+
export LIBRARIES_FLAGS="-Wno-unused-command-line-argument -Wl,-ldl -Wl,-lrt -Wl,-lpthread -Wl,$SRC/fuzztest/centipede/weak.o"
|
| 28 |
+
|
| 29 |
+
export CFLAGS="$CFLAGS $CENTIPEDE_FLAGS $LIBRARIES_FLAGS"
|
| 30 |
+
export CXXFLAGS="$CXXFLAGS $CENTIPEDE_FLAGS $LIBRARIES_FLAGS"
|
| 31 |
+
|
| 32 |
+
echo 'done.'
|
local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/compile_honggfuzz
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash -eu
|
| 2 |
+
# Copyright 2016 Google Inc.
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
################################################################################
|
| 17 |
+
|
| 18 |
+
echo "Skipping compilation; using precompiled honggfuzz"
|
| 19 |
+
|
| 20 |
+
cp $SRC/honggfuzz/honggfuzz.a $LIB_FUZZING_ENGINE
|
| 21 |
+
cp $SRC/honggfuzz/honggfuzz $OUT/
|
| 22 |
+
|
| 23 |
+
# Set flags necessary for netdriver compilation.
|
| 24 |
+
export LIB_HFND="-Wl,-u,LIBHFNETDRIVER_module_netdriver -Wl,--start-group $SRC/honggfuzz/libhfnetdriver/libhfnetdriver.a $SRC/honggfuzz/libhfcommon/libhfcommon.a -Wl,--end-group"
|
| 25 |
+
|
| 26 |
+
export HFND_CXXFLAGS='-DHFND_FUZZING_ENTRY_FUNCTION_CXX(x,y)=extern const char* LIBHFNETDRIVER_module_netdriver;const char** LIBHFNETDRIVER_tmp1 = &LIBHFNETDRIVER_module_netdriver;extern "C" int HonggfuzzNetDriver_main(x,y);int HonggfuzzNetDriver_main(x,y)'
|
| 27 |
+
export HFND_CFLAGS='-DHFND_FUZZING_ENTRY_FUNCTION(x,y)=extern const char* LIBHFNETDRIVER_module_netdriver;const char** LIBHFNETDRIVER_tmp1 = &LIBHFNETDRIVER_module_netdriver;int HonggfuzzNetDriver_main(x,y);int HonggfuzzNetDriver_main(x,y)'
|
| 28 |
+
|
| 29 |
+
# Custom coverage flags, roughly in sync with:
|
| 30 |
+
# https://github.com/google/honggfuzz/blob/oss-fuzz/hfuzz_cc/hfuzz-cc.c
|
| 31 |
+
export COVERAGE_FLAGS="-fsanitize-coverage=trace-pc-guard,indirect-calls,trace-cmp"
|
| 32 |
+
|
| 33 |
+
echo " done."
|
local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/jcc/build_jcc.bash
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash -eu
|
| 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 |
+
|
| 19 |
+
go build jcc.go
|
| 20 |
+
go build jcc2.go
|
| 21 |
+
gsutil cp jcc gs://clusterfuzz-builds/jcc/clang++-jcc
|
| 22 |
+
gsutil cp jcc gs://clusterfuzz-builds/jcc/clang-jcc
|
| 23 |
+
|
| 24 |
+
gsutil cp jcc2 gs://clusterfuzz-builds/jcc/clang++-jcc2
|
| 25 |
+
gsutil cp jcc2 gs://clusterfuzz-builds/jcc/clang-jcc2
|
local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/jcc/go.mod
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
module github.com/google/jcc
|
| 2 |
+
|
| 3 |
+
go 1.21
|
local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/jcc/jcc.go
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright 2023 Google LLC
|
| 2 |
+
//
|
| 3 |
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
// you may not use this file except in compliance with the License.
|
| 5 |
+
// You may obtain a copy of the License at
|
| 6 |
+
//
|
| 7 |
+
// http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
//
|
| 9 |
+
// Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
// See the License for the specific language governing permissions and
|
| 13 |
+
// limitations under the License.
|
| 14 |
+
|
| 15 |
+
package main
|
| 16 |
+
|
| 17 |
+
import (
|
| 18 |
+
"bytes"
|
| 19 |
+
"fmt"
|
| 20 |
+
"log"
|
| 21 |
+
"os"
|
| 22 |
+
"os/exec"
|
| 23 |
+
"path/filepath"
|
| 24 |
+
)
|
| 25 |
+
|
| 26 |
+
func ExecBuildCommand(bin string, args []string) (int, string, string) {
|
| 27 |
+
// Executes the original command.
|
| 28 |
+
cmd := exec.Command(bin, args...)
|
| 29 |
+
var outb, errb bytes.Buffer
|
| 30 |
+
cmd.Stdout = &outb
|
| 31 |
+
cmd.Stderr = &errb
|
| 32 |
+
cmd.Stdin = os.Stdin
|
| 33 |
+
cmd.Run()
|
| 34 |
+
return cmd.ProcessState.ExitCode(), outb.String(), errb.String()
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
func Compile(bin string, args []string) (int, string, string) {
|
| 38 |
+
// Run the actual command.
|
| 39 |
+
return ExecBuildCommand(bin, args)
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
func AppendStringToFile(filepath, new_content string) error {
|
| 43 |
+
// Appends |new_content| to the content of |filepath|.
|
| 44 |
+
file, err := os.OpenFile(filepath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
|
| 45 |
+
if err != nil {
|
| 46 |
+
return err
|
| 47 |
+
}
|
| 48 |
+
defer file.Close()
|
| 49 |
+
|
| 50 |
+
_, err = file.WriteString(new_content)
|
| 51 |
+
return err
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
func WriteStdErrOut(args []string, outstr string, errstr string) {
|
| 55 |
+
// Prints |outstr| to stdout, prints |errstr| to stderr, and saves |errstr| to err.log.
|
| 56 |
+
fmt.Print(outstr)
|
| 57 |
+
fmt.Fprint(os.Stderr, errstr)
|
| 58 |
+
// Record what compile args produced the error and the error itself in log file.
|
| 59 |
+
AppendStringToFile("/tmp/err.log", fmt.Sprintf("%s\n", args)+errstr)
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
func main() {
|
| 63 |
+
f, err := os.OpenFile("/tmp/jcc.log", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
|
| 64 |
+
|
| 65 |
+
if err != nil {
|
| 66 |
+
log.Println(err)
|
| 67 |
+
}
|
| 68 |
+
defer f.Close()
|
| 69 |
+
if _, err := f.WriteString(fmt.Sprintf("%s\n", os.Args)); err != nil {
|
| 70 |
+
log.Println(err)
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
args := os.Args[1:]
|
| 74 |
+
basename := filepath.Base(os.Args[0])
|
| 75 |
+
isCPP := basename == "clang++-jcc"
|
| 76 |
+
newArgs := args
|
| 77 |
+
|
| 78 |
+
var bin string
|
| 79 |
+
if isCPP {
|
| 80 |
+
bin = "clang++"
|
| 81 |
+
} else {
|
| 82 |
+
bin = "clang"
|
| 83 |
+
}
|
| 84 |
+
fullCmdArgs := append([]string{bin}, newArgs...)
|
| 85 |
+
retcode, out, errstr := Compile(bin, newArgs)
|
| 86 |
+
WriteStdErrOut(fullCmdArgs, out, errstr)
|
| 87 |
+
os.Exit(retcode)
|
| 88 |
+
}
|
local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/jcc/jcc2.go
ADDED
|
@@ -0,0 +1,401 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright 2024 Google LLC
|
| 2 |
+
//
|
| 3 |
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
// you may not use this file except in compliance with the License.
|
| 5 |
+
// You may obtain a copy of the License at
|
| 6 |
+
//
|
| 7 |
+
// http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
//
|
| 9 |
+
// Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
// See the License for the specific language governing permissions and
|
| 13 |
+
// limitations under the License.
|
| 14 |
+
|
| 15 |
+
package main
|
| 16 |
+
|
| 17 |
+
import (
|
| 18 |
+
"bytes"
|
| 19 |
+
"encoding/json"
|
| 20 |
+
"errors"
|
| 21 |
+
"fmt"
|
| 22 |
+
"io/fs"
|
| 23 |
+
"io/ioutil"
|
| 24 |
+
"log"
|
| 25 |
+
"os"
|
| 26 |
+
"os/exec"
|
| 27 |
+
"path/filepath"
|
| 28 |
+
"regexp"
|
| 29 |
+
"strings"
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
+
var MaxMissingHeaderFiles = 10
|
| 33 |
+
var CppifyHeadersMagicString = "\n/* JCCCppifyHeadersMagicString */\n"
|
| 34 |
+
|
| 35 |
+
func CopyFile(src string, dst string) {
|
| 36 |
+
contents, err := ioutil.ReadFile(src)
|
| 37 |
+
if err != nil {
|
| 38 |
+
panic(err)
|
| 39 |
+
}
|
| 40 |
+
err = ioutil.WriteFile(dst, contents, 0644)
|
| 41 |
+
if err != nil {
|
| 42 |
+
panic(err)
|
| 43 |
+
}
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
func TryFixCCompilation(cmdline []string) ([]string, int, string, string) {
|
| 47 |
+
var newFile string = ""
|
| 48 |
+
for i, arg := range cmdline {
|
| 49 |
+
if !strings.HasSuffix(arg, ".c") {
|
| 50 |
+
continue
|
| 51 |
+
}
|
| 52 |
+
if _, err := os.Stat(arg); errors.Is(err, os.ErrNotExist) {
|
| 53 |
+
continue
|
| 54 |
+
}
|
| 55 |
+
newFile = strings.TrimSuffix(arg, ".c")
|
| 56 |
+
newFile += ".cpp"
|
| 57 |
+
CopyFile(arg, newFile)
|
| 58 |
+
CppifyHeaderIncludesFromFile(newFile)
|
| 59 |
+
cmdline[i] = newFile
|
| 60 |
+
break
|
| 61 |
+
}
|
| 62 |
+
if newFile == "" {
|
| 63 |
+
return []string{}, 1, "", ""
|
| 64 |
+
}
|
| 65 |
+
cppBin := "clang++"
|
| 66 |
+
newCmdline := []string{"-stdlib=libc++"}
|
| 67 |
+
newCmdline = append(cmdline, newCmdline...)
|
| 68 |
+
newFullArgs := append([]string{cppBin}, newCmdline...)
|
| 69 |
+
|
| 70 |
+
retcode, out, err := Compile(cppBin, newCmdline)
|
| 71 |
+
if retcode == 0 {
|
| 72 |
+
return newFullArgs, retcode, out, err
|
| 73 |
+
}
|
| 74 |
+
correctedCmdline, corrected, _ := CorrectMissingHeaders(cppBin, newCmdline)
|
| 75 |
+
if corrected {
|
| 76 |
+
return append([]string{cppBin}, correctedCmdline...), 0, "", ""
|
| 77 |
+
}
|
| 78 |
+
return newFullArgs, retcode, out, err
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
func ExtractMissingHeader(compilerOutput string) (string, bool) {
|
| 82 |
+
r := regexp.MustCompile(`fatal error: ['|<](?P<header>[a-zA-z0-9\/\.]+)['|>] file not found`)
|
| 83 |
+
matches := r.FindStringSubmatch(compilerOutput)
|
| 84 |
+
if len(matches) == 0 {
|
| 85 |
+
return "", false
|
| 86 |
+
}
|
| 87 |
+
return matches[1], true
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
func ReplaceMissingHeaderInFile(srcFilename, curHeader, replacementHeader string) error {
|
| 91 |
+
srcFile, err := os.Open(srcFilename)
|
| 92 |
+
if err != nil {
|
| 93 |
+
return err
|
| 94 |
+
}
|
| 95 |
+
srcBytes, err := ioutil.ReadAll(srcFile)
|
| 96 |
+
if err != nil {
|
| 97 |
+
return err
|
| 98 |
+
}
|
| 99 |
+
src := string(srcBytes)
|
| 100 |
+
newSrc := ReplaceMissingHeader(src, curHeader, replacementHeader)
|
| 101 |
+
b := []byte(newSrc)
|
| 102 |
+
err = ioutil.WriteFile(srcFilename, b, 0644)
|
| 103 |
+
if err != nil {
|
| 104 |
+
return err
|
| 105 |
+
}
|
| 106 |
+
return nil
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
func ReplaceMissingHeader(src, curHeader, replacementHeader string) string {
|
| 110 |
+
re := regexp.MustCompile(`#include ["|<]` + curHeader + `["|>]\n`)
|
| 111 |
+
replacement := "#include \"" + replacementHeader + "\"\n"
|
| 112 |
+
return re.ReplaceAllString(src, replacement)
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
func GetHeaderCorrectedFilename(compilerErr string) (string, string, bool) {
|
| 116 |
+
re := regexp.MustCompile(`(?P<buggy>[a-z\/\-\_0-9A-z\.]+):.* fatal error: .* file not found`)
|
| 117 |
+
matches := re.FindStringSubmatch(compilerErr)
|
| 118 |
+
if len(matches) < 2 {
|
| 119 |
+
return "", "", false
|
| 120 |
+
}
|
| 121 |
+
oldFilename := matches[1]
|
| 122 |
+
base := filepath.Base(oldFilename)
|
| 123 |
+
root := filepath.Dir(oldFilename)
|
| 124 |
+
newFilename := root + "/jcc-corrected-" + base
|
| 125 |
+
return oldFilename, newFilename, true
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
func GetHeaderCorrectedCmd(cmd []string, compilerErr string) ([]string, string, error) {
|
| 129 |
+
oldFilename, newFilename, success := GetHeaderCorrectedFilename(compilerErr)
|
| 130 |
+
if !success {
|
| 131 |
+
return cmd, "", errors.New("Couldn't find buggy file")
|
| 132 |
+
}
|
| 133 |
+
// Make new cmd.
|
| 134 |
+
newCmd := make([]string, len(cmd))
|
| 135 |
+
for i, part := range cmd {
|
| 136 |
+
newCmd[i] = part
|
| 137 |
+
}
|
| 138 |
+
found := false
|
| 139 |
+
for i, filename := range newCmd {
|
| 140 |
+
if filename == oldFilename {
|
| 141 |
+
newCmd[i] = newFilename
|
| 142 |
+
found = true
|
| 143 |
+
break
|
| 144 |
+
}
|
| 145 |
+
}
|
| 146 |
+
CopyFile(oldFilename, newFilename)
|
| 147 |
+
if found {
|
| 148 |
+
return newCmd, newFilename, nil
|
| 149 |
+
}
|
| 150 |
+
return cmd, "", errors.New("Couldn't find file")
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
func CorrectMissingHeaders(bin string, cmd []string) ([]string, bool, error) {
|
| 154 |
+
|
| 155 |
+
_, _, stderr := Compile(bin, cmd)
|
| 156 |
+
cmd, correctedFilename, err := GetHeaderCorrectedCmd(cmd, stderr)
|
| 157 |
+
if err != nil {
|
| 158 |
+
return cmd, false, err
|
| 159 |
+
}
|
| 160 |
+
for i := 0; i < MaxMissingHeaderFiles; i++ {
|
| 161 |
+
fixed, hasBrokenHeaders := TryCompileAndFixHeadersOnce(bin, cmd, correctedFilename)
|
| 162 |
+
if fixed {
|
| 163 |
+
return cmd, true, nil
|
| 164 |
+
}
|
| 165 |
+
if !hasBrokenHeaders {
|
| 166 |
+
return cmd, false, nil
|
| 167 |
+
}
|
| 168 |
+
}
|
| 169 |
+
return cmd, false, nil
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
func ExecBuildCommand(bin string, args []string) (int, string, string) {
|
| 173 |
+
// Executes the original command.
|
| 174 |
+
cmd := exec.Command(bin, args...)
|
| 175 |
+
var outb, errb bytes.Buffer
|
| 176 |
+
cmd.Stdout = &outb
|
| 177 |
+
cmd.Stderr = &errb
|
| 178 |
+
cmd.Stdin = os.Stdin
|
| 179 |
+
cmd.Run()
|
| 180 |
+
return cmd.ProcessState.ExitCode(), outb.String(), errb.String()
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
func Compile(bin string, args []string) (int, string, string) {
|
| 184 |
+
// Run the actual command.
|
| 185 |
+
return ExecBuildCommand(bin, args)
|
| 186 |
+
}
|
| 187 |
+
|
| 188 |
+
func TryCompileAndFixHeadersOnce(bin string, cmd []string, filename string) (fixed, hasBrokenHeaders bool) {
|
| 189 |
+
retcode, _, err := Compile(bin, cmd)
|
| 190 |
+
if retcode == 0 {
|
| 191 |
+
fixed = true
|
| 192 |
+
hasBrokenHeaders = false
|
| 193 |
+
return
|
| 194 |
+
}
|
| 195 |
+
missingHeader, isMissing := ExtractMissingHeader(err)
|
| 196 |
+
if !isMissing {
|
| 197 |
+
fixed = false
|
| 198 |
+
hasBrokenHeaders = false
|
| 199 |
+
return
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
newHeaderPath, found := FindMissingHeader(missingHeader)
|
| 203 |
+
if !found {
|
| 204 |
+
fixed = false
|
| 205 |
+
hasBrokenHeaders = true
|
| 206 |
+
return false, true
|
| 207 |
+
}
|
| 208 |
+
ReplaceMissingHeaderInFile(filename, missingHeader, newHeaderPath)
|
| 209 |
+
return false, true
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
+
func FindMissingHeader(missingHeader string) (string, bool) {
|
| 213 |
+
envVar := "JCC_MISSING_HEADER_SEARCH_PATH"
|
| 214 |
+
var searchPath string
|
| 215 |
+
searchPath, exists := os.LookupEnv(envVar)
|
| 216 |
+
if !exists {
|
| 217 |
+
searchPath = "/src"
|
| 218 |
+
}
|
| 219 |
+
searchPath, _ = filepath.Abs(searchPath)
|
| 220 |
+
var headerLocation string
|
| 221 |
+
missingHeader = "/" + missingHeader
|
| 222 |
+
find := func(path string, d fs.DirEntry, err error) error {
|
| 223 |
+
if err != nil {
|
| 224 |
+
return err
|
| 225 |
+
}
|
| 226 |
+
if d.IsDir() {
|
| 227 |
+
return nil
|
| 228 |
+
}
|
| 229 |
+
if strings.HasSuffix(path, missingHeader) {
|
| 230 |
+
headerLocation = path
|
| 231 |
+
return nil
|
| 232 |
+
}
|
| 233 |
+
return nil
|
| 234 |
+
}
|
| 235 |
+
filepath.WalkDir(searchPath, find)
|
| 236 |
+
if headerLocation == "" {
|
| 237 |
+
return "", false
|
| 238 |
+
}
|
| 239 |
+
return headerLocation, true
|
| 240 |
+
}
|
| 241 |
+
|
| 242 |
+
func CppifyHeaderIncludesFromFile(srcFile string) error {
|
| 243 |
+
contentsBytes, err := ioutil.ReadFile(srcFile)
|
| 244 |
+
if err != nil {
|
| 245 |
+
return err
|
| 246 |
+
}
|
| 247 |
+
contents := string(contentsBytes[:])
|
| 248 |
+
contents, err = CppifyHeaderIncludes(contents)
|
| 249 |
+
if err != nil {
|
| 250 |
+
return err
|
| 251 |
+
}
|
| 252 |
+
b := []byte(contents)
|
| 253 |
+
err = ioutil.WriteFile(srcFile, b, 0644)
|
| 254 |
+
return err
|
| 255 |
+
}
|
| 256 |
+
|
| 257 |
+
func CppifyHeaderIncludes(contents string) (string, error) {
|
| 258 |
+
shouldCppify, exists := os.LookupEnv("JCC_CPPIFY_PROJECT_HEADERS")
|
| 259 |
+
if !exists || strings.Compare(shouldCppify, "0") == 0 {
|
| 260 |
+
return contents, nil
|
| 261 |
+
}
|
| 262 |
+
if strings.Contains(contents, CppifyHeadersMagicString) {
|
| 263 |
+
return contents, nil
|
| 264 |
+
}
|
| 265 |
+
re := regexp.MustCompile(`\#include \"(?P<header>.+)\"\n`)
|
| 266 |
+
matches := re.FindAllStringSubmatch(contents, -1)
|
| 267 |
+
if len(matches) == 0 {
|
| 268 |
+
return "", nil // !!!
|
| 269 |
+
}
|
| 270 |
+
for i, match := range matches {
|
| 271 |
+
if i == 0 {
|
| 272 |
+
// So we don't cppify twice.
|
| 273 |
+
contents += CppifyHeadersMagicString
|
| 274 |
+
}
|
| 275 |
+
oldStr := match[0]
|
| 276 |
+
replacement := "extern \"C\" {\n#include \"" + match[1] + "\"\n}\n"
|
| 277 |
+
contents = strings.Replace(contents, oldStr, replacement, 1)
|
| 278 |
+
if strings.Compare(contents, "") == 0 {
|
| 279 |
+
panic("Failed to replace")
|
| 280 |
+
}
|
| 281 |
+
}
|
| 282 |
+
return contents, nil
|
| 283 |
+
}
|
| 284 |
+
|
| 285 |
+
func AppendStringToFile(filepath, new_content string) error {
|
| 286 |
+
// Appends |new_content| to the content of |filepath|.
|
| 287 |
+
file, err := os.OpenFile(filepath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
|
| 288 |
+
if err != nil {
|
| 289 |
+
return err
|
| 290 |
+
}
|
| 291 |
+
defer file.Close()
|
| 292 |
+
|
| 293 |
+
_, err = file.WriteString(new_content)
|
| 294 |
+
return err
|
| 295 |
+
}
|
| 296 |
+
|
| 297 |
+
func WriteStdErrOut(args []string, outstr string, errstr string) {
|
| 298 |
+
// Prints |outstr| to stdout, prints |errstr| to stderr, and saves |errstr| to err.log.
|
| 299 |
+
fmt.Print(outstr)
|
| 300 |
+
fmt.Fprint(os.Stderr, errstr)
|
| 301 |
+
// Record what compile args produced the error and the error itself in log file.
|
| 302 |
+
AppendStringToFile("/workspace/err.log", fmt.Sprintf("%s\n", args)+errstr)
|
| 303 |
+
}
|
| 304 |
+
|
| 305 |
+
func main() {
|
| 306 |
+
f, err := os.OpenFile("/tmp/jcc.log", os.O_CREATE|os.O_WRONLY, 0644)
|
| 307 |
+
if err != nil {
|
| 308 |
+
log.Println(err)
|
| 309 |
+
}
|
| 310 |
+
defer f.Close()
|
| 311 |
+
if _, err := f.WriteString(fmt.Sprintf("%s\n", os.Args)); err != nil {
|
| 312 |
+
log.Println(err)
|
| 313 |
+
}
|
| 314 |
+
|
| 315 |
+
args := os.Args[1:]
|
| 316 |
+
if args[0] == "unfreeze" {
|
| 317 |
+
fmt.Println("unfreeze")
|
| 318 |
+
unfreeze()
|
| 319 |
+
}
|
| 320 |
+
basename := filepath.Base(os.Args[0])
|
| 321 |
+
isCPP := basename == "clang++-jcc"
|
| 322 |
+
newArgs := append(args, "-w")
|
| 323 |
+
|
| 324 |
+
var bin string
|
| 325 |
+
if isCPP {
|
| 326 |
+
bin = "clang++"
|
| 327 |
+
newArgs = append(args, "-stdlib=libc++")
|
| 328 |
+
} else {
|
| 329 |
+
bin = "clang"
|
| 330 |
+
}
|
| 331 |
+
fullCmdArgs := append([]string{bin}, newArgs...)
|
| 332 |
+
if IsCompilingTarget(fullCmdArgs) {
|
| 333 |
+
WriteTargetArgsAndCommitImage(fullCmdArgs)
|
| 334 |
+
os.Exit(0)
|
| 335 |
+
}
|
| 336 |
+
retcode, out, errstr := Compile(bin, newArgs)
|
| 337 |
+
WriteStdErrOut(fullCmdArgs, out, errstr)
|
| 338 |
+
os.Exit(retcode)
|
| 339 |
+
}
|
| 340 |
+
|
| 341 |
+
type BuildCommand struct {
|
| 342 |
+
CWD string `json:"CWD"`
|
| 343 |
+
CMD []string `json:"CMD"`
|
| 344 |
+
}
|
| 345 |
+
|
| 346 |
+
func WriteTargetArgsAndCommitImage(cmdline []string) {
|
| 347 |
+
log.Println("WRITE COMMAND")
|
| 348 |
+
f, _ := os.OpenFile("/out/statefile.json", os.O_CREATE|os.O_WRONLY, 0644)
|
| 349 |
+
wd, _ := os.Getwd()
|
| 350 |
+
buildcmd := BuildCommand{
|
| 351 |
+
CWD: wd,
|
| 352 |
+
CMD: cmdline,
|
| 353 |
+
}
|
| 354 |
+
jsonData, _ := json.Marshal(buildcmd)
|
| 355 |
+
f.Write(jsonData)
|
| 356 |
+
f.Close()
|
| 357 |
+
hostname, _ := os.Hostname()
|
| 358 |
+
dockerArgs := []string{"commit", hostname, "frozen"}
|
| 359 |
+
cmd := exec.Command("docker", dockerArgs...)
|
| 360 |
+
var outb, errb bytes.Buffer
|
| 361 |
+
cmd.Stdout = &outb
|
| 362 |
+
cmd.Stderr = &errb
|
| 363 |
+
cmd.Stdin = os.Stdin
|
| 364 |
+
cmd.Run()
|
| 365 |
+
fmt.Println(outb.String(), errb.String())
|
| 366 |
+
fmt.Println("COMMIT IMAGE")
|
| 367 |
+
}
|
| 368 |
+
|
| 369 |
+
func IsCompilingTarget(cmdline []string) bool {
|
| 370 |
+
for _, arg := range cmdline {
|
| 371 |
+
// This can fail if people do crazy things they aren't supposed
|
| 372 |
+
// to such as using some other means to link in libFuzzer.
|
| 373 |
+
if arg == "-fsanitize=fuzzer" {
|
| 374 |
+
return true
|
| 375 |
+
}
|
| 376 |
+
if arg == "-lFuzzingEngine" {
|
| 377 |
+
return true
|
| 378 |
+
}
|
| 379 |
+
}
|
| 380 |
+
return false
|
| 381 |
+
}
|
| 382 |
+
|
| 383 |
+
func parseCommand(command string) (string, []string) {
|
| 384 |
+
args := strings.Fields(command)
|
| 385 |
+
commandBin := args[0]
|
| 386 |
+
commandArgs := args[1:]
|
| 387 |
+
return commandBin, commandArgs
|
| 388 |
+
}
|
| 389 |
+
|
| 390 |
+
func unfreeze() {
|
| 391 |
+
content, err := ioutil.ReadFile("/out/statefile.json")
|
| 392 |
+
if err != nil {
|
| 393 |
+
log.Fatal(err)
|
| 394 |
+
}
|
| 395 |
+
var command BuildCommand
|
| 396 |
+
json.Unmarshal(content, &command)
|
| 397 |
+
bin, args := parseCommand(strings.Join(command.CMD, " "))
|
| 398 |
+
os.Chdir(command.CWD)
|
| 399 |
+
ExecBuildCommand(bin, args)
|
| 400 |
+
os.Exit(0)
|
| 401 |
+
}
|
local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/jcc/jcc_test.go
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package main
|
| 2 |
+
|
| 3 |
+
import (
|
| 4 |
+
"fmt"
|
| 5 |
+
"os"
|
| 6 |
+
"strings"
|
| 7 |
+
"testing"
|
| 8 |
+
)
|
| 9 |
+
|
| 10 |
+
func TestExtractMissingHeader(t *testing.T) {
|
| 11 |
+
missingHeaderMessage := `path/to/file.cpp:8:10: fatal error: 'missingheader.h' file not found
|
| 12 |
+
|
| 13 |
+
#include "missingheader.h"
|
| 14 |
+
|
| 15 |
+
^~~~~~~~~~~~
|
| 16 |
+
|
| 17 |
+
1 error generated.
|
| 18 |
+
`
|
| 19 |
+
|
| 20 |
+
res, _ := ExtractMissingHeader(missingHeaderMessage)
|
| 21 |
+
expected := "missingheader.h"
|
| 22 |
+
if strings.Compare(res, expected) != 0 {
|
| 23 |
+
t.Errorf("Got: %s. Expected: %s.", res, expected)
|
| 24 |
+
}
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
func TestGetHeaderCorrectedFilename(t *testing.T) {
|
| 28 |
+
missingHeaderMessage := `path/to/file.cpp:8:10: fatal error: 'missingheader.h' file not found
|
| 29 |
+
|
| 30 |
+
#include "missingheader.h"
|
| 31 |
+
|
| 32 |
+
^~~~~~~~~~~~
|
| 33 |
+
|
| 34 |
+
1 error generated.
|
| 35 |
+
`
|
| 36 |
+
_, correctedFilename, _ := GetHeaderCorrectedFilename(missingHeaderMessage)
|
| 37 |
+
expected := "path/to/jcc-corrected-file.cpp"
|
| 38 |
+
if strings.Compare(correctedFilename, expected) != 0 {
|
| 39 |
+
t.Errorf("Got: %s. Expected: %s.", correctedFilename, expected)
|
| 40 |
+
}
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
func TestFindMissingHeader(t *testing.T) {
|
| 44 |
+
pwd, _ := os.Getwd()
|
| 45 |
+
t.Setenv("JCC_MISSING_HEADER_SEARCH_PATH", pwd)
|
| 46 |
+
|
| 47 |
+
location, _ := FindMissingHeader("header.h")
|
| 48 |
+
expected := pwd + "/testdata/path/to/header.h"
|
| 49 |
+
if strings.Compare(location, expected) != 0 {
|
| 50 |
+
t.Errorf("Got: %s. Expected: %s.", location, expected)
|
| 51 |
+
}
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
func TestCorrectMissingHeaders(t *testing.T) {
|
| 55 |
+
pwd, _ := os.Getwd()
|
| 56 |
+
t.Setenv("JCC_MISSING_HEADER_SEARCH_PATH", pwd)
|
| 57 |
+
cfile := pwd + "/testdata/cfile.c"
|
| 58 |
+
cmd := [4]string{"-fsanitize=address", cfile, "-o", "/tmp/blah"}
|
| 59 |
+
res, err := CorrectMissingHeaders("clang", cmd[:])
|
| 60 |
+
if !res {
|
| 61 |
+
fmt.Println(err)
|
| 62 |
+
t.Errorf("Expected successful compilation")
|
| 63 |
+
}
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
func TestGetHeaderCorrectedCmd(t *testing.T) {
|
| 67 |
+
compilerErr := `testdata/cpp.cc:8:10: fatal error: 'missingheader.h' file not found
|
| 68 |
+
|
| 69 |
+
#include "missingheader.h"
|
| 70 |
+
|
| 71 |
+
^~~~~~~~~~~~
|
| 72 |
+
|
| 73 |
+
1 error generated.
|
| 74 |
+
`
|
| 75 |
+
|
| 76 |
+
cmd := [3]string{"-fsanitize=address", "file.cpp", "path/to/cpp.cc"}
|
| 77 |
+
expectedFixedCmd := [3]string{"-fanitize=address", "file.cpp", "path/to/jcc-corrected-cpp.cc"}
|
| 78 |
+
fixedCmd, _, _ := GetHeaderCorrectedCmd(cmd[:], compilerErr)
|
| 79 |
+
if strings.Compare(fixedCmd[1], expectedFixedCmd[1]) != 0 {
|
| 80 |
+
t.Errorf("Expected %s, got: %s", expectedFixedCmd, fixedCmd)
|
| 81 |
+
}
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
func TestCppifyHeaderIncludes(t *testing.T) {
|
| 85 |
+
t.Setenv("JCC_CPPIFY_PROJECT_HEADERS", "1")
|
| 86 |
+
src := `// Copyright blah
|
| 87 |
+
#include <stddef.h>
|
| 88 |
+
|
| 89 |
+
#include "fuzz.h"
|
| 90 |
+
#include "x/y.h"
|
| 91 |
+
extern "C" LLVMFuzzerTestOneInput(uint8_t* data, size_t sz) {
|
| 92 |
+
return 0;
|
| 93 |
+
}`
|
| 94 |
+
newFile, _ := CppifyHeaderIncludes(src)
|
| 95 |
+
expected := `// Copyright blah
|
| 96 |
+
#include <stddef.h>
|
| 97 |
+
|
| 98 |
+
extern "C" {
|
| 99 |
+
#include "fuzz.h"
|
| 100 |
+
}
|
| 101 |
+
extern "C" {
|
| 102 |
+
#include "x/y.h"
|
| 103 |
+
}
|
| 104 |
+
extern "C" LLVMFuzzerTestOneInput(uint8_t* data, size_t sz) {
|
| 105 |
+
return 0;
|
| 106 |
+
}
|
| 107 |
+
/* JCCCppifyHeadersMagicString */
|
| 108 |
+
`
|
| 109 |
+
if strings.Compare(newFile, expected) != 0 {
|
| 110 |
+
t.Errorf("Expected: %s, got: %s", expected, newFile)
|
| 111 |
+
}
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
func TestCppifyHeaderIncludesShouldnt(t *testing.T) {
|
| 115 |
+
src := `// Copyright blah
|
| 116 |
+
#include <stddef.h>
|
| 117 |
+
|
| 118 |
+
#include "fuzz.h"
|
| 119 |
+
#include "x/y.h"
|
| 120 |
+
extern "C" LLVMFuzzerTestOneInput(uint8_t* data, size_t sz) {
|
| 121 |
+
return 0;
|
| 122 |
+
}`
|
| 123 |
+
newFile, _ := CppifyHeaderIncludes(src)
|
| 124 |
+
if strings.Compare(newFile, src) != 0 {
|
| 125 |
+
t.Errorf("Expected: %s. Got: %s", src, newFile)
|
| 126 |
+
}
|
| 127 |
+
}
|
| 128 |
+
|
| 129 |
+
func TestCppifyHeaderIncludesAlready(t *testing.T) {
|
| 130 |
+
src := `// Copyright blah
|
| 131 |
+
#include <stddef.h>
|
| 132 |
+
|
| 133 |
+
#include "fuzz.h"
|
| 134 |
+
#include "x/y.h"
|
| 135 |
+
extern "C" LLVMFuzzerTestOneInput(uint8_t* data, size_t sz) {
|
| 136 |
+
return 0;
|
| 137 |
+
}
|
| 138 |
+
/* JCCCppifyHeadersMagicString */
|
| 139 |
+
`
|
| 140 |
+
newFile, _ := CppifyHeaderIncludes(src)
|
| 141 |
+
if strings.Compare(newFile, src) != 0 {
|
| 142 |
+
t.Errorf("Expected %s, got: %s", src, newFile)
|
| 143 |
+
}
|
| 144 |
+
}
|
| 145 |
+
|
| 146 |
+
func TestExtractMissingHeaderNonHeaderFailure(t *testing.T) {
|
| 147 |
+
missingHeaderMessage := `clang: error: no such file or directory: 'x'
|
| 148 |
+
clang: error: no input files`
|
| 149 |
+
|
| 150 |
+
header, res := ExtractMissingHeader(missingHeaderMessage)
|
| 151 |
+
if res {
|
| 152 |
+
t.Errorf("Expected no match, got: %s", header)
|
| 153 |
+
}
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
func TestReplaceMissingHeader(t *testing.T) {
|
| 157 |
+
cfile := `// Copyright 2035 Robots
|
| 158 |
+
#include <stddef.h>
|
| 159 |
+
|
| 160 |
+
#include <cstdint>
|
| 161 |
+
|
| 162 |
+
// Some libraries like OpenSSL will use brackets for their own headers.
|
| 163 |
+
#include <missingheader.h>
|
| 164 |
+
|
| 165 |
+
int LLVMFuzzerTestOneInput(uint8_t* data, size_t size) {
|
| 166 |
+
return 0;
|
| 167 |
+
}
|
| 168 |
+
`
|
| 169 |
+
|
| 170 |
+
res := ReplaceMissingHeader(cfile, "missingheader.h", "path/to/includes/missingheader.h")
|
| 171 |
+
expected := `// Copyright 2035 Robots
|
| 172 |
+
#include <stddef.h>
|
| 173 |
+
|
| 174 |
+
#include <cstdint>
|
| 175 |
+
|
| 176 |
+
// Some libraries like OpenSSL will use brackets for their own headers.
|
| 177 |
+
#include "path/to/includes/missingheader.h"
|
| 178 |
+
|
| 179 |
+
int LLVMFuzzerTestOneInput(uint8_t* data, size_t size) {
|
| 180 |
+
return 0;
|
| 181 |
+
}
|
| 182 |
+
`
|
| 183 |
+
if strings.Compare(res, expected) != 0 {
|
| 184 |
+
t.Errorf("Got: %s. Expected: %s.", res, expected)
|
| 185 |
+
}
|
| 186 |
+
}
|
local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/jcc/testdata/.gitignore
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
jcc-corrected-cfile.c
|
| 2 |
+
jcc-corrected-cfile.cpp
|
local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/jcc/testdata/cfile.c
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright 2023 Google LLC
|
| 2 |
+
//
|
| 3 |
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
// you may not use this file except in compliance with the License.
|
| 5 |
+
// You may obtain a copy of the License at
|
| 6 |
+
//
|
| 7 |
+
// http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
//
|
| 9 |
+
// Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
// See the License for the specific language governing permissions and
|
| 13 |
+
// limitations under the License.
|
| 14 |
+
|
| 15 |
+
#include "header.h"
|
| 16 |
+
int main() {
|
| 17 |
+
return 0;
|
| 18 |
+
}
|
local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/jcc/testdata/cpp.cc
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright 2023 Google LLC
|
| 2 |
+
//
|
| 3 |
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
// you may not use this file except in compliance with the License.
|
| 5 |
+
// You may obtain a copy of the License at
|
| 6 |
+
//
|
| 7 |
+
// http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
//
|
| 9 |
+
// Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
// See the License for the specific language governing permissions and
|
| 13 |
+
// limitations under the License.
|
| 14 |
+
|
| 15 |
+
#include "header.h"
|
| 16 |
+
int main() {
|
| 17 |
+
return 0;
|
| 18 |
+
}
|
local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/jcc/testdata/path/to/header.h
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright 2023 Google LLC
|
| 2 |
+
//
|
| 3 |
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
// you may not use this file except in compliance with the License.
|
| 5 |
+
// You may obtain a copy of the License at
|
| 6 |
+
//
|
| 7 |
+
// http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
//
|
| 9 |
+
// Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
// See the License for the specific language governing permissions and
|
| 13 |
+
// limitations under the License.
|
| 14 |
+
|
| 15 |
+
int xhg(void);
|
local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/sanitizers/pysecsan/.gitignore
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
dist
|
| 2 |
+
pysecsan.egg-info*
|
| 3 |
+
build
|
| 4 |
+
.venv
|
local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/sanitizers/pysecsan/LICENSE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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.
|
local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/sanitizers/pysecsan/README.md
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# pysecsan
|
| 2 |
+
|
| 3 |
+
Security sanitizers for vulnerability detection during runtime.
|
local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/sanitizers/pysecsan/pyproject.toml
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[build-system]
|
| 2 |
+
requires = ["setuptools>=61.0"]
|
| 3 |
+
build-backend = "setuptools.build_meta"
|
| 4 |
+
|
| 5 |
+
[project]
|
| 6 |
+
name = "pysecsan"
|
| 7 |
+
version = "0.1.0"
|
| 8 |
+
authors = [
|
| 9 |
+
{ name="David Korczynski", email="david@adalogics.com" },
|
| 10 |
+
]
|
| 11 |
+
description = "Sanitizers to detect security vulnerabilities at runtime."
|
| 12 |
+
readme = "README.md"
|
| 13 |
+
requires-python = ">=3.7"
|
| 14 |
+
classifiers = [
|
| 15 |
+
"Programming Language :: Python :: 3",
|
| 16 |
+
"License :: OSI Approved :: Apache Software License",
|
| 17 |
+
"Operating System :: OS Independent",
|
| 18 |
+
]
|
| 19 |
+
|
| 20 |
+
[project.urls]
|
| 21 |
+
"Homepage" = "https://github.com/google/oss-fuzz/tree/master/infra/sanitizers/pysecsan"
|
| 22 |
+
"Bug Tracker" = "https://github.com/google/oss-fuzz/issues"
|
local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/sanitizers/pysecsan/pysecsan/__init__.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
"""Glue for pysecsan library."""
|
| 15 |
+
|
| 16 |
+
# Import sanlib and expose only needs functionality by way of __all__
|
| 17 |
+
from .sanlib import *
|
| 18 |
+
|
| 19 |
+
# pylint: disable=undefined-all-variable
|
| 20 |
+
__all__ = ['add_hooks']
|
local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/sanitizers/pysecsan/pysecsan/command_injection.py
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2022 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
#
|
| 15 |
+
################################################################################
|
| 16 |
+
"""Sanitizers for capturing code injections."""
|
| 17 |
+
|
| 18 |
+
from typing import Optional
|
| 19 |
+
from pysecsan import sanlib
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
def get_all_substr_prefixes(main_str, sub_str):
|
| 23 |
+
"""Yields all strings prefixed with sub_str in main_str."""
|
| 24 |
+
idx = 0
|
| 25 |
+
while True:
|
| 26 |
+
idx = main_str.find(sub_str, idx)
|
| 27 |
+
if idx == -1:
|
| 28 |
+
return
|
| 29 |
+
yield main_str[0:idx]
|
| 30 |
+
# Increase idx the length of the substring from the current position
|
| 31 |
+
# where an occurence of the substring was found.
|
| 32 |
+
idx += len(sub_str)
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
# pylint: disable=unsubscriptable-object
|
| 36 |
+
def check_code_injection_match(elem, check_unquoted=False) -> Optional[str]:
|
| 37 |
+
"""identify if elem is an injection match."""
|
| 38 |
+
# Check exact match
|
| 39 |
+
if elem == 'exec-sanitizer':
|
| 40 |
+
return 'Explicit command injection found.'
|
| 41 |
+
|
| 42 |
+
# Check potential for injecting into a string
|
| 43 |
+
if 'FROMFUZZ' in elem:
|
| 44 |
+
if check_unquoted:
|
| 45 |
+
# return true if any index is unquoted
|
| 46 |
+
for sub_str in get_all_substr_prefixes(elem, 'FROMFUZZ'):
|
| 47 |
+
if sub_str.count('\"') % 2 == 0:
|
| 48 |
+
return 'Fuzzer controlled content in data. Code injection potential.'
|
| 49 |
+
|
| 50 |
+
# Return None if all fuzzer taints were quoted
|
| 51 |
+
return None
|
| 52 |
+
return 'Fuzzer-controlled data in command string. Injection potential.'
|
| 53 |
+
return None
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
# pylint: disable=invalid-name
|
| 57 |
+
def hook_pre_exec_subprocess_Popen(cmd, **kwargs):
|
| 58 |
+
"""Hook for subprocess.Popen."""
|
| 59 |
+
|
| 60 |
+
arg_shell = 'shell' in kwargs and kwargs['shell']
|
| 61 |
+
|
| 62 |
+
# Command injections depend on whether the first argument is a list of
|
| 63 |
+
# strings or a string. Handle this now.
|
| 64 |
+
# Example: tests/poe/ansible-runner-cve-2021-4041
|
| 65 |
+
if isinstance(cmd, str):
|
| 66 |
+
res = check_code_injection_match(cmd, check_unquoted=True)
|
| 67 |
+
if res is not None:
|
| 68 |
+
# if shell arg is true and string is tainted and unquoted that's a
|
| 69 |
+
# definite code injection.
|
| 70 |
+
if arg_shell is True:
|
| 71 |
+
sanlib.abort_with_issue('Code injection in Popen', 'Command injection')
|
| 72 |
+
|
| 73 |
+
# It's a maybe: will not report this to avoid false positives.
|
| 74 |
+
# TODO: add more precise detection here.
|
| 75 |
+
|
| 76 |
+
# Check for hg command injection
|
| 77 |
+
# Example: tests/poe/libvcs-cve-2022-21187
|
| 78 |
+
if cmd[0] == 'hg':
|
| 79 |
+
# Check if the arguments are controlled by the fuzzer, and this given
|
| 80 |
+
# arg is not preceded by --
|
| 81 |
+
found_dashes = False
|
| 82 |
+
for idx in range(1, len(cmd)):
|
| 83 |
+
if cmd[0] == '--':
|
| 84 |
+
found_dashes = True
|
| 85 |
+
if not found_dashes and check_code_injection_match(cmd[idx]):
|
| 86 |
+
sanlib.abort_with_issue(
|
| 87 |
+
'command injection likely by way of mercurial. The following'
|
| 88 |
+
f'command {str(cmd)} is executed, and if you substitute {cmd[idx]} '
|
| 89 |
+
'with \"--config=alias.init=!touch HELLO_PY\" then you will '
|
| 90 |
+
'create HELLO_PY', 'Command injection')
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
def hook_pre_exec_os_system(cmd):
|
| 94 |
+
"""Hook for os.system."""
|
| 95 |
+
res = check_code_injection_match(cmd)
|
| 96 |
+
if res is not None:
|
| 97 |
+
sanlib.abort_with_issue(f'code injection by way of os.system\n{res}',
|
| 98 |
+
'Command injection')
|
| 99 |
+
|
| 100 |
+
|
| 101 |
+
def hook_pre_exec_eval(cmd, *args, **kwargs):
|
| 102 |
+
"""Hook for eval. Experimental atm."""
|
| 103 |
+
res = check_code_injection_match(cmd, check_unquoted=True)
|
| 104 |
+
if res is not None:
|
| 105 |
+
sanlib.abort_with_issue(f'Potential code injection by way of eval\n{res}',
|
| 106 |
+
'Command injection')
|
local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/sanitizers/pysecsan/pysecsan/redos.py
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2022 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
#
|
| 15 |
+
################################################################################
|
| 16 |
+
"""Sanitizer for regular expression dos."""
|
| 17 |
+
|
| 18 |
+
# pylint: disable=protected-access
|
| 19 |
+
|
| 20 |
+
import time
|
| 21 |
+
import os
|
| 22 |
+
from pysecsan import sanlib
|
| 23 |
+
|
| 24 |
+
START_RE_TIME = None
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
# Hooks for regular expressions.
|
| 28 |
+
# Main problem is to identify ReDOS attemps. This is a non-trivial task
|
| 29 |
+
# - https://arxiv.org/pdf/1701.04045.pdf
|
| 30 |
+
# - https://dl.acm.org/doi/pdf/10.1145/3236024.3236027
|
| 31 |
+
# and the current approach we use is simply check for extensive computing time.
|
| 32 |
+
# In essence, this is more of a refinement of traditional timeout checker from
|
| 33 |
+
# the fuzzer, which, effectively will detect these types of attacks by way of
|
| 34 |
+
# timeouts.
|
| 35 |
+
#
|
| 36 |
+
# Perhaps the smartest would be to use something like e.g.
|
| 37 |
+
# https://github.com/doyensec/regexploit to scan the regex patterns.
|
| 38 |
+
# Other heuristics without going too technical on identifying super-linear
|
| 39 |
+
# regexes:
|
| 40 |
+
# - check
|
| 41 |
+
# - if 'taint' exists in re.compile(xx)
|
| 42 |
+
# - check
|
| 43 |
+
# - for backtracking possbility in PATTERN within re.comile(PATTERN)
|
| 44 |
+
# - and
|
| 45 |
+
# - 'taint' in findall(XX) calls.
|
| 46 |
+
# pylint: disable=global-statement
|
| 47 |
+
def hook_post_exec_re_pattern_findall(self, re_str):
|
| 48 |
+
"""Hook post exeution re.compile().findall()."""
|
| 49 |
+
_ = self # Satisfy lint
|
| 50 |
+
global START_RE_TIME
|
| 51 |
+
try:
|
| 52 |
+
endtime = time.time() - START_RE_TIME
|
| 53 |
+
if endtime > 4:
|
| 54 |
+
sanlib.abort_with_issue(f'Potential ReDOS attack.\n {re_str}', 'ReDOS')
|
| 55 |
+
except NameError:
|
| 56 |
+
sanlib.sanitizer_log(
|
| 57 |
+
'starttime is not set, which it should have. Error in PySecSan',
|
| 58 |
+
sanlib.LOG_INFO)
|
| 59 |
+
os._exit(1)
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
def hook_pre_exec_re_pattern_findall(self, string):
|
| 63 |
+
"""Hook pre execution of re.pattern().findall()."""
|
| 64 |
+
_ = (self, string) # Satisfy lint
|
| 65 |
+
global START_RE_TIME
|
| 66 |
+
START_RE_TIME = time.time()
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
def hook_post_exec_re_compile(retval, pattern, flags=None):
|
| 70 |
+
"""Hook for re.compile post execution to hook returned objects functions."""
|
| 71 |
+
_ = (pattern, flags) # Satisfy lint
|
| 72 |
+
sanlib.sanitizer_log('Inside of post compile hook', sanlib.LOG_DEBUG)
|
| 73 |
+
wrapper_object = sanlib.create_object_wrapper(
|
| 74 |
+
findall=(hook_pre_exec_re_pattern_findall,
|
| 75 |
+
hook_post_exec_re_pattern_findall))
|
| 76 |
+
hooked_object = wrapper_object(retval)
|
| 77 |
+
return hooked_object
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
def hook_pre_exec_re_compile(pattern, flags=None):
|
| 81 |
+
"""Check if tainted input exists in pattern. If so, likely chance of making
|
| 82 |
+
ReDOS possible."""
|
| 83 |
+
_ = (pattern, flags) # Satisfy lint
|
| 84 |
+
sanlib.sanitizer_log('Inside re compile hook', sanlib.LOG_DEBUG)
|
local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/sanitizers/pysecsan/pysecsan/sanlib.py
ADDED
|
@@ -0,0 +1,227 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2022 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
#
|
| 15 |
+
################################################################################
|
| 16 |
+
"""Core routines for pysecsan library."""
|
| 17 |
+
|
| 18 |
+
# pylint: disable=protected-access
|
| 19 |
+
|
| 20 |
+
import re
|
| 21 |
+
import os
|
| 22 |
+
import functools
|
| 23 |
+
import subprocess
|
| 24 |
+
import traceback
|
| 25 |
+
import importlib.util
|
| 26 |
+
|
| 27 |
+
from typing import Any, Callable, Optional
|
| 28 |
+
from pysecsan import command_injection, redos, yaml_deserialization
|
| 29 |
+
|
| 30 |
+
LOG_DEBUG = 0
|
| 31 |
+
LOG_INFO = 1
|
| 32 |
+
PYSECSAN_LOG_LVL = LOG_INFO
|
| 33 |
+
|
| 34 |
+
# Message that will be printed to stdout when an issue is found.
|
| 35 |
+
PYSECSAN_BUG_LABEL = r'===BUG DETECTED: PySecSan:'
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
# pylint: disable=global-statement
|
| 39 |
+
def sanitizer_log(msg, log_level, force=False, log_prefix=True):
|
| 40 |
+
"""Helper printing function."""
|
| 41 |
+
global PYSECSAN_LOG_LVL
|
| 42 |
+
if log_level >= PYSECSAN_LOG_LVL or force:
|
| 43 |
+
if log_prefix:
|
| 44 |
+
print(f'[PYSECSAN] {msg}')
|
| 45 |
+
else:
|
| 46 |
+
print(f'{msg}')
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
def sanitizer_log_always(msg, log_prefix=True):
|
| 50 |
+
"""Wrapper for sanitizer logging. Will always log"""
|
| 51 |
+
sanitizer_log(msg, 0, force=True, log_prefix=log_prefix)
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
def is_module_present(mod_name):
|
| 55 |
+
"""Identify if module is importable."""
|
| 56 |
+
# pylint: disable=deprecated-method
|
| 57 |
+
return importlib.util.find_spec(mod_name) is not None
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
def _log_bug(bug_title):
|
| 61 |
+
sanitizer_log_always('%s %s ===' % (PYSECSAN_BUG_LABEL, bug_title),
|
| 62 |
+
log_prefix=False)
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
def abort_with_issue(msg, bug_title):
|
| 66 |
+
"""Print message, display stacktrace and force process exit.
|
| 67 |
+
|
| 68 |
+
Use this function for signalling an issue is found and use the messages
|
| 69 |
+
logged from this function to determine if a fuzzer found a bug.
|
| 70 |
+
"""
|
| 71 |
+
# Show breaker string using an ASAN approach (uses 65 =)
|
| 72 |
+
sanitizer_log_always("=" * 65, log_prefix=False)
|
| 73 |
+
|
| 74 |
+
# Log issue message
|
| 75 |
+
_log_bug(bug_title)
|
| 76 |
+
sanitizer_log_always(msg)
|
| 77 |
+
|
| 78 |
+
# Log stacktrace
|
| 79 |
+
sanitizer_log_always("Stacktrace:")
|
| 80 |
+
traceback.print_stack()
|
| 81 |
+
|
| 82 |
+
# Force exit
|
| 83 |
+
# Use os._exit here to force exit. sys.exit will exit
|
| 84 |
+
# by throwing a SystemExit exception which the interpreter
|
| 85 |
+
# handles by exiting. However, code may catch this exception,
|
| 86 |
+
# and thus to avoid this we exit the process without exceptions.
|
| 87 |
+
# pylint: disable=protected-access
|
| 88 |
+
sanitizer_log_always("Exiting")
|
| 89 |
+
os._exit(1)
|
| 90 |
+
|
| 91 |
+
|
| 92 |
+
def is_exact_taint(stream) -> bool:
|
| 93 |
+
"""Checks if stream is an exact match for taint from fuzzer."""
|
| 94 |
+
# The fuzzer has to get 8 characters right. This may be a bit much,
|
| 95 |
+
# however, when found it shows a high level of control over the data.
|
| 96 |
+
if stream == 'FROMFUZZ':
|
| 97 |
+
return True
|
| 98 |
+
|
| 99 |
+
return False
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
def create_object_wrapper(**methods):
|
| 103 |
+
"""Hooks functions in an object.
|
| 104 |
+
|
| 105 |
+
This is needed for hooking built-in types and object attributes.
|
| 106 |
+
|
| 107 |
+
Example use case is if we want to find ReDOS vulnerabilities, that
|
| 108 |
+
have a pattern of
|
| 109 |
+
|
| 110 |
+
```
|
| 111 |
+
import re
|
| 112 |
+
r = re.compile(REGEX)
|
| 113 |
+
for _ in r.findall(...)
|
| 114 |
+
```
|
| 115 |
+
|
| 116 |
+
In the above case r.findall is a reference to
|
| 117 |
+
re.Pattern.findall, which is a built-in type that is non-writeable.
|
| 118 |
+
|
| 119 |
+
In order to hook such calls we need to wrap the object, and also hook the
|
| 120 |
+
re.compile function to return the wrapped/hooked object.
|
| 121 |
+
"""
|
| 122 |
+
|
| 123 |
+
class Wrapper():
|
| 124 |
+
"""Wrap an object by hiding attributes."""
|
| 125 |
+
|
| 126 |
+
def __init__(self, instance):
|
| 127 |
+
object.__setattr__(self, 'instance', instance)
|
| 128 |
+
|
| 129 |
+
def __setattr__(self, name, value):
|
| 130 |
+
object.__setattr__(object.__getattribute__(self, 'instance'), name, value)
|
| 131 |
+
|
| 132 |
+
def __getattribute__(self, name):
|
| 133 |
+
instance = object.__getattribute__(self, 'instance')
|
| 134 |
+
|
| 135 |
+
def _hook_func(self, pre_hook, post_hook, orig, *args, **kargs):
|
| 136 |
+
if pre_hook is not None:
|
| 137 |
+
pre_hook(self, *args, **kargs)
|
| 138 |
+
# No need to pass instance here because when we extracted
|
| 139 |
+
# the function we used instance.__getattribute__(name) which
|
| 140 |
+
# seems to include it. I think.
|
| 141 |
+
orig_retval = orig(*args, **kargs)
|
| 142 |
+
|
| 143 |
+
if post_hook is not None:
|
| 144 |
+
post_hook(self, *args, **kargs)
|
| 145 |
+
return orig_retval
|
| 146 |
+
|
| 147 |
+
# If this is a wrapped method, return a bound method
|
| 148 |
+
if name in methods:
|
| 149 |
+
pre_hook = methods[name][0]
|
| 150 |
+
post_hook = methods[name][1]
|
| 151 |
+
orig = instance.__getattribute__(name)
|
| 152 |
+
return (lambda *args, **kargs: _hook_func(self, pre_hook, post_hook,
|
| 153 |
+
orig, *args, **kargs))
|
| 154 |
+
|
| 155 |
+
# Otherwise, just return attribute of instance
|
| 156 |
+
return instance.__getattribute__(name)
|
| 157 |
+
|
| 158 |
+
return Wrapper
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
# pylint: disable=unsubscriptable-object
|
| 162 |
+
def add_hook(function: Callable[[Any], Any],
|
| 163 |
+
pre_exec_hook: Optional[Callable[[Any], Any]] = None,
|
| 164 |
+
post_exec_hook: Optional[Callable[[Any], Any]] = None):
|
| 165 |
+
"""Hook a function.
|
| 166 |
+
|
| 167 |
+
Hooks can be placed pre and post function call. At least one hook is
|
| 168 |
+
needed.
|
| 169 |
+
|
| 170 |
+
This hooking is intended on non-object hooks. In order to hook functions
|
| 171 |
+
in objects the `create_object_wrapper` function is used in combination
|
| 172 |
+
with function hooking initialisation functions post execution.
|
| 173 |
+
"""
|
| 174 |
+
if pre_exec_hook is None and post_exec_hook is None:
|
| 175 |
+
raise Exception('Some hooks must be included')
|
| 176 |
+
|
| 177 |
+
@functools.wraps(function)
|
| 178 |
+
def run(*args, **kwargs):
|
| 179 |
+
sanitizer_log(f'Hook start {str(function)}', LOG_DEBUG)
|
| 180 |
+
|
| 181 |
+
# Call hook
|
| 182 |
+
if pre_exec_hook is not None:
|
| 183 |
+
pre_exec_hook(*args, **kwargs)
|
| 184 |
+
|
| 185 |
+
# Call the original function in the even the hook did not indicate
|
| 186 |
+
# failure.
|
| 187 |
+
ret = function(*args, **kwargs)
|
| 188 |
+
|
| 189 |
+
# Post execution hook. Overwrite return value if anything is returned
|
| 190 |
+
# by post hook.
|
| 191 |
+
if post_exec_hook is not None:
|
| 192 |
+
tmp_ret = post_exec_hook(ret, *args, **kwargs)
|
| 193 |
+
if tmp_ret is not None:
|
| 194 |
+
sanitizer_log('Overwriting return value', LOG_DEBUG)
|
| 195 |
+
ret = tmp_ret
|
| 196 |
+
sanitizer_log(f'Hook end {str(function)}', LOG_DEBUG)
|
| 197 |
+
return ret
|
| 198 |
+
|
| 199 |
+
return run
|
| 200 |
+
|
| 201 |
+
|
| 202 |
+
def add_hooks():
|
| 203 |
+
"""Sets up hooks."""
|
| 204 |
+
sanitizer_log('Starting', LOG_INFO)
|
| 205 |
+
os.system = add_hook(os.system,
|
| 206 |
+
pre_exec_hook=command_injection.hook_pre_exec_os_system)
|
| 207 |
+
subprocess.Popen = add_hook(
|
| 208 |
+
subprocess.Popen,
|
| 209 |
+
pre_exec_hook=command_injection.hook_pre_exec_subprocess_Popen)
|
| 210 |
+
|
| 211 |
+
__builtins__['eval'] = add_hook(
|
| 212 |
+
__builtins__['eval'], pre_exec_hook=command_injection.hook_pre_exec_eval)
|
| 213 |
+
|
| 214 |
+
re.compile = add_hook(re.compile,
|
| 215 |
+
pre_exec_hook=redos.hook_pre_exec_re_compile,
|
| 216 |
+
post_exec_hook=redos.hook_post_exec_re_compile)
|
| 217 |
+
|
| 218 |
+
# Hack to determine if yaml is elligible, because pkg_resources does
|
| 219 |
+
# not seem to work from pyinstaller.
|
| 220 |
+
# pylint: disable=import-outside-toplevel
|
| 221 |
+
if is_module_present('yaml'):
|
| 222 |
+
import yaml
|
| 223 |
+
sanitizer_log('Hooking pyyaml.load', LOG_DEBUG)
|
| 224 |
+
yaml.load = add_hook(
|
| 225 |
+
yaml.load,
|
| 226 |
+
pre_exec_hook=yaml_deserialization.hook_pre_exec_pyyaml_load,
|
| 227 |
+
)
|
local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/sanitizers/pysecsan/pysecsan/yaml_deserialization.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2022 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
#
|
| 15 |
+
################################################################################
|
| 16 |
+
"""Catches vulnerable yaml desrializations that can potentially lead to
|
| 17 |
+
arbitrary code execution."""
|
| 18 |
+
from pysecsan import sanlib
|
| 19 |
+
|
| 20 |
+
try:
|
| 21 |
+
import yaml
|
| 22 |
+
# pylint: disable=broad-except
|
| 23 |
+
except Exception:
|
| 24 |
+
pass
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def hook_pre_exec_pyyaml_load(stream, loader):
|
| 28 |
+
"""Hook for pyyaml.load_yaml.
|
| 29 |
+
|
| 30 |
+
Exits if the loader is unsafe or vanilla loader and the stream passed
|
| 31 |
+
to the loader is controlled by the fuzz data
|
| 32 |
+
"""
|
| 33 |
+
# Ensure loader is the unsafe loader or vanilla loader
|
| 34 |
+
if loader not in (yaml.loader.Loader, yaml.loader.UnsafeLoader):
|
| 35 |
+
return
|
| 36 |
+
|
| 37 |
+
# Check for exact taint in stream
|
| 38 |
+
if sanlib.is_exact_taint(stream):
|
| 39 |
+
msg = (
|
| 40 |
+
'Yaml deserialization issue.\n'
|
| 41 |
+
'Unsafe deserialization can be used to execute arbitrary commands.\n')
|
| 42 |
+
sanlib.abort_with_issue(msg, 'Yaml deserialisation')
|
local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/sanitizers/pysecsan/setup.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
"""Config for installing python as package."""
|
| 15 |
+
from setuptools import setup, find_packages
|
| 16 |
+
|
| 17 |
+
setup(name='pysecsan',
|
| 18 |
+
version='0.1',
|
| 19 |
+
author='David Korczynski',
|
| 20 |
+
author_email='david@adalogics.com',
|
| 21 |
+
packages=find_packages(exclude='tests'))
|
local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/sanitizers/pysecsan/tests/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
# Tests including Proof of Exploits
|
local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/sanitizers/pysecsan/tests/os_command_injection.py
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/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 |
+
"""Fuzzer targetting command injection of os.system."""
|
| 16 |
+
|
| 17 |
+
import os
|
| 18 |
+
import sys
|
| 19 |
+
import atheris
|
| 20 |
+
import pysecsan
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
def list_files_perhaps(param, magicval):
|
| 24 |
+
"""Pass fuzzer data into os.system."""
|
| 25 |
+
if 'B' not in param:
|
| 26 |
+
return
|
| 27 |
+
if magicval == 1338:
|
| 28 |
+
os.system('exec-san')
|
| 29 |
+
elif magicval == 1339:
|
| 30 |
+
os.system('ls -la FROMFUZZ')
|
| 31 |
+
else:
|
| 32 |
+
os.system('ls -la ./')
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
def test_one_input(data):
|
| 36 |
+
"""Fuzzer entrypoint."""
|
| 37 |
+
fdp = atheris.FuzzedDataProvider(data)
|
| 38 |
+
list_files_perhaps(fdp.ConsumeUnicodeNoSurrogates(24),
|
| 39 |
+
fdp.ConsumeIntInRange(500, 1500))
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
def main():
|
| 43 |
+
"""Set up and start fuzzing."""
|
| 44 |
+
pysecsan.add_hooks()
|
| 45 |
+
|
| 46 |
+
atheris.instrument_all()
|
| 47 |
+
atheris.Setup(sys.argv, test_one_input, enable_python_coverage=True)
|
| 48 |
+
atheris.Fuzz()
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
if __name__ == '__main__':
|
| 52 |
+
main()
|
local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/sanitizers/pysecsan/tests/poe/ansible-runner-cve-2021-4041/build.sh
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash -eu
|
| 2 |
+
# Copyright 2022 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
################################################################################
|
| 17 |
+
|
| 18 |
+
python3 -m pip install pysecsan
|
| 19 |
+
|
| 20 |
+
git clone https://github.com/ansible/ansible-runner/
|
| 21 |
+
cd ansible-runner
|
| 22 |
+
git checkout cdc0961df51fa1e10b44371944aafe5ae140b98c
|
| 23 |
+
python3 -m pip install .
|
| 24 |
+
cd ..
|
| 25 |
+
python3 fuzz_ansible_runner.py
|
local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/sanitizers/pysecsan/tests/poe/ansible-runner-cve-2021-4041/fuzz_ansible_runner.py
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/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 |
+
"""Targets: https://github.com/advisories/GHSA-6j58-grhv-2769."""
|
| 16 |
+
|
| 17 |
+
import sys
|
| 18 |
+
import atheris
|
| 19 |
+
import pexpect
|
| 20 |
+
import pysecsan
|
| 21 |
+
import ansible_runner
|
| 22 |
+
from ansible_runner.config.runner import RunnerConfig
|
| 23 |
+
|
| 24 |
+
pysecsan.add_hooks()
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def test_one_input(data):
|
| 28 |
+
"""Fuzzer entrypoint."""
|
| 29 |
+
fdp = atheris.FuzzedDataProvider(data)
|
| 30 |
+
|
| 31 |
+
conf = RunnerConfig('/tmp/')
|
| 32 |
+
conf.suppress_ansible_output = True
|
| 33 |
+
conf.expect_passwords = {pexpect.TIMEOUT: None, pexpect.EOF: None}
|
| 34 |
+
conf.cwd = str('/tmp/')
|
| 35 |
+
conf.env = {}
|
| 36 |
+
conf.job_timeout = 10
|
| 37 |
+
conf.idle_timeout = 0
|
| 38 |
+
conf.pexpect_timeout = 2.
|
| 39 |
+
conf.pexpect_use_poll = True
|
| 40 |
+
conf.command = 'from_fuzzer'
|
| 41 |
+
|
| 42 |
+
runner = ansible_runner.Runner(conf)
|
| 43 |
+
runner.resource_profiling = True
|
| 44 |
+
# rc.resource_profiling_base_cgroup = "; exec-san"
|
| 45 |
+
assistance = True
|
| 46 |
+
if assistance and fdp.ConsumeIntInRange(1, 100) > 80:
|
| 47 |
+
conf.resource_profiling_base_cgroup = 'FROMFUZZ'
|
| 48 |
+
else:
|
| 49 |
+
conf.resource_profiling_base_cgroup = fdp.ConsumeUnicodeNoSurrogates(24)
|
| 50 |
+
try:
|
| 51 |
+
runner.run()
|
| 52 |
+
except (RuntimeError, ValueError, TypeError) as _:
|
| 53 |
+
pass
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
def main():
|
| 57 |
+
"""Set up and start fuzzing."""
|
| 58 |
+
atheris.instrument_all()
|
| 59 |
+
atheris.Setup(sys.argv, test_one_input, enable_python_coverage=True)
|
| 60 |
+
atheris.Fuzz()
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
if __name__ == '__main__':
|
| 64 |
+
main()
|
local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/sanitizers/pysecsan/tests/poe/libvcs-cve-2022-21187/build.sh
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash -eu
|
| 2 |
+
# Copyright 2022 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
################################################################################
|
| 17 |
+
|
| 18 |
+
python3 -m pip install pysecsan
|
| 19 |
+
|
| 20 |
+
python3 -m pip install libvcs==0.11.0
|
| 21 |
+
python3 ./fuzz_libvcs.py
|
local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/sanitizers/pysecsan/tests/poe/libvcs-cve-2022-21187/fuzz_libvcs.py
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/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 |
+
"""Targets https://github.com/advisories/GHSA-mv2w-4jqc-6fg4."""
|
| 16 |
+
|
| 17 |
+
import sys
|
| 18 |
+
import atheris
|
| 19 |
+
import pysecsan
|
| 20 |
+
from libvcs.shortcuts import create_repo
|
| 21 |
+
|
| 22 |
+
pysecsan.add_hooks()
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def test_one_input(data):
|
| 26 |
+
"""Target code injection in libvcs."""
|
| 27 |
+
fdp = atheris.FuzzedDataProvider(data)
|
| 28 |
+
mercurial_repo = create_repo(url=fdp.ConsumeUnicodeNoSurrogates(128),
|
| 29 |
+
vcs='hg',
|
| 30 |
+
repo_dir='./')
|
| 31 |
+
try:
|
| 32 |
+
mercurial_repo.update_repo()
|
| 33 |
+
except (ValueError, FileNotFoundError) as exception:
|
| 34 |
+
_ = exception # Satisfy lint
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
def main():
|
| 38 |
+
"""Set up and start fuzzing."""
|
| 39 |
+
atheris.instrument_all()
|
| 40 |
+
atheris.Setup(sys.argv, test_one_input, enable_python_coverage=True)
|
| 41 |
+
atheris.Fuzz()
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
if __name__ == '__main__':
|
| 45 |
+
main()
|
local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/sanitizers/pysecsan/tests/poe/python-ldap-GHSL-2021-117/build.sh
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash -eu
|
| 2 |
+
# Copyright 2022 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
################################################################################
|
| 17 |
+
|
| 18 |
+
python3 -m pip install pysecsan
|
| 19 |
+
|
| 20 |
+
git clone https://github.com/python-ldap/python-ldap
|
| 21 |
+
cd python-ldap
|
| 22 |
+
git checkout 404c36b702c5b3a7e60729745c8bda16098b1472
|
| 23 |
+
python3 -m pip install .
|
| 24 |
+
cd ../
|
| 25 |
+
python3 ./fuzz_ldap.py
|
local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/sanitizers/pysecsan/tests/poe/python-ldap-GHSL-2021-117/fuzz_ldap.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/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 |
+
"""Targets: https://github.com/python-ldap/python-ldap/security/advisories/GHSA-r8wq-qrxc-hmcm""" # pylint: disable=line-too-long
|
| 16 |
+
|
| 17 |
+
import sys
|
| 18 |
+
import atheris
|
| 19 |
+
import pysecsan
|
| 20 |
+
import ldap.schema
|
| 21 |
+
|
| 22 |
+
pysecsan.add_hooks()
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def test_one_input(data):
|
| 26 |
+
"""Fuzzer targetting regex dos in ldap."""
|
| 27 |
+
fdp = atheris.FuzzedDataProvider(data)
|
| 28 |
+
try:
|
| 29 |
+
ldap.schema.split_tokens(fdp.ConsumeUnicodeNoSurrogates(1024))
|
| 30 |
+
except ValueError:
|
| 31 |
+
pass
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
def main():
|
| 35 |
+
"""Set up and start fuzzing."""
|
| 36 |
+
atheris.instrument_all()
|
| 37 |
+
atheris.Setup(sys.argv, test_one_input, enable_python_coverage=True)
|
| 38 |
+
atheris.Fuzz()
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
if __name__ == '__main__':
|
| 42 |
+
main()
|
local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/sanitizers/pysecsan/tests/poe/pytorch-lightning-1.5.10/build.sh
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash -eu
|
| 2 |
+
# Copyright 2022 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
################################################################################
|
| 17 |
+
|
| 18 |
+
git clone --depth 1 --branch 1.5.10 https://github.com/PyTorchLightning/pytorch-lightning.git
|
| 19 |
+
cd pytorch-lightning
|
| 20 |
+
python3 -m pip install .
|
| 21 |
+
cd ../
|
| 22 |
+
python3 ./fuzz_pytorch_lightning.py
|
local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/sanitizers/pysecsan/tests/poe/pytorch-lightning-1.5.10/fuzz_pytorch_lightning.dict
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
"os.system('exec-sanitizer')"
|
local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/sanitizers/pysecsan/tests/poe/pytorch-lightning-1.5.10/fuzz_pytorch_lightning.py
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/local/bin/python3
|
| 2 |
+
#
|
| 3 |
+
# Copyright 2022 Google LLC
|
| 4 |
+
#
|
| 5 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 6 |
+
# you may not use this file except in compliance with the License.
|
| 7 |
+
# You may obtain a copy of the License at
|
| 8 |
+
#
|
| 9 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 10 |
+
#
|
| 11 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 12 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 13 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 14 |
+
# See the License for the specific language governing permissions and
|
| 15 |
+
# limitations under the License.
|
| 16 |
+
#
|
| 17 |
+
################################################################################
|
| 18 |
+
"""Exploit pytorch lightning with fuzzer's input as a random env variable.
|
| 19 |
+
This PoC is extended from a report in GitHub Advisory Database:
|
| 20 |
+
https://github.com/advisories/GHSA-r5qj-cvf9-p85h
|
| 21 |
+
The original report documents an exploit using a specific environment variable,
|
| 22 |
+
we show a way to achieve the same exploit with an arbitrary env variable.
|
| 23 |
+
"""
|
| 24 |
+
|
| 25 |
+
import os
|
| 26 |
+
import sys
|
| 27 |
+
import atheris
|
| 28 |
+
import pysecsan
|
| 29 |
+
|
| 30 |
+
pysecsan.add_hooks()
|
| 31 |
+
|
| 32 |
+
with atheris.instrument_imports():
|
| 33 |
+
from pytorch_lightning import Trainer
|
| 34 |
+
from pytorch_lightning.utilities.argparse import parse_env_variables
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
def prepare_fuzzing_input(data):
|
| 38 |
+
"""Prepare the data needed by the exploit with input data from fuzzers."""
|
| 39 |
+
data = data.replace(b'\0', b'')
|
| 40 |
+
env_name = 'AN_ARBITRARY_ENV_NAME'
|
| 41 |
+
return data, env_name
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
def exploit_target(env_value, env_name):
|
| 45 |
+
"""This target is based on a snippet from the official documentation of
|
| 46 |
+
`parse_env_variables`:
|
| 47 |
+
https://pytorch-lightning.readthedocs.io/en/stable/api/pytorch_lightning.utilities.argparse.html # pylint: disable=line-too-long
|
| 48 |
+
It might not be the most realistic example,
|
| 49 |
+
but serves as a PoC to show that SystemSan works for Python."""
|
| 50 |
+
os.environb[env_name.encode()] = env_value
|
| 51 |
+
parse_env_variables(Trainer, template=env_name)
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
def TestOneInput(data): # pylint: disable=invalid-name
|
| 55 |
+
"""Exploit the target only with input data from fuzzers."""
|
| 56 |
+
env_value, env_name = prepare_fuzzing_input(data)
|
| 57 |
+
exploit_target(env_value, env_name)
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
def main():
|
| 61 |
+
"""Fuzz target with atheris."""
|
| 62 |
+
atheris.Setup(sys.argv, TestOneInput)
|
| 63 |
+
atheris.Fuzz()
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
if __name__ == '__main__':
|
| 67 |
+
main()
|
local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/sanitizers/pysecsan/tests/subprocess_popen_injection.py
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/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 |
+
"""Fuzzer displaying insecure use of subprocess.Popen."""
|
| 16 |
+
|
| 17 |
+
import sys
|
| 18 |
+
import subprocess
|
| 19 |
+
import atheris
|
| 20 |
+
import pysecsan
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
def list_files_perhaps(param):
|
| 24 |
+
"""Insecure call to Popen."""
|
| 25 |
+
try:
|
| 26 |
+
subprocess.Popen(' '.join(['ls', '-la', param]), shell=True)
|
| 27 |
+
except ValueError:
|
| 28 |
+
pass
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def test_one_input(data):
|
| 32 |
+
"""Fuzzer entrypoint."""
|
| 33 |
+
fdp = atheris.FuzzedDataProvider(data)
|
| 34 |
+
|
| 35 |
+
if fdp.ConsumeIntInRange(1, 10) == 5:
|
| 36 |
+
list_files_perhaps('FROMFUZZ')
|
| 37 |
+
else:
|
| 38 |
+
list_files_perhaps('.')
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
def main():
|
| 42 |
+
"""Set up and start fuzzing."""
|
| 43 |
+
pysecsan.add_hooks()
|
| 44 |
+
|
| 45 |
+
atheris.instrument_all()
|
| 46 |
+
atheris.Setup(sys.argv, test_one_input, enable_python_coverage=True)
|
| 47 |
+
atheris.Fuzz()
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
if __name__ == '__main__':
|
| 51 |
+
main()
|
local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/sanitizers/pysecsan/tests/yaml_deserialization_general.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/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 |
+
"""Fuzzer for insecure yaml deserialization."""
|
| 16 |
+
|
| 17 |
+
import sys
|
| 18 |
+
import yaml
|
| 19 |
+
import atheris
|
| 20 |
+
import pysecsan
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
def serialize_with_tainted_data(param):
|
| 24 |
+
"""Hit insecure yaml function."""
|
| 25 |
+
try:
|
| 26 |
+
yaml.load(param, yaml.Loader)
|
| 27 |
+
except yaml.YAMLError:
|
| 28 |
+
pass
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def test_one_input(data):
|
| 32 |
+
"""Fuzzer routine."""
|
| 33 |
+
fdp = atheris.FuzzedDataProvider(data)
|
| 34 |
+
serialize_with_tainted_data(fdp.ConsumeUnicodeNoSurrogates(32))
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
def main():
|
| 38 |
+
"""Set up and start fuzzing."""
|
| 39 |
+
pysecsan.add_hooks()
|
| 40 |
+
|
| 41 |
+
atheris.instrument_all()
|
| 42 |
+
atheris.Setup(sys.argv, test_one_input, enable_python_coverage=True)
|
| 43 |
+
atheris.Fuzz()
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
if __name__ == '__main__':
|
| 47 |
+
main()
|
local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/sanitizers/pysecsan/tests/yaml_deserialization_simple.py
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/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 |
+
"""Fuzzer triggering insecure yaml serialization."""
|
| 16 |
+
|
| 17 |
+
import sys
|
| 18 |
+
import yaml
|
| 19 |
+
import atheris
|
| 20 |
+
import pysecsan
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
def serialize_with_tainted_data(param, magicval):
|
| 24 |
+
"""Pass data to insecure yaml functions."""
|
| 25 |
+
if magicval == 1337:
|
| 26 |
+
try:
|
| 27 |
+
yaml.load(param, yaml.Loader)
|
| 28 |
+
except yaml.YAMLError:
|
| 29 |
+
pass
|
| 30 |
+
elif magicval == 1338:
|
| 31 |
+
try:
|
| 32 |
+
yaml.load('FROMFUZZ', yaml.Loader)
|
| 33 |
+
except yaml.YAMLError:
|
| 34 |
+
pass
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
def test_one_input(data):
|
| 38 |
+
"""Fuzzer entrypoint."""
|
| 39 |
+
fdp = atheris.FuzzedDataProvider(data)
|
| 40 |
+
serialize_with_tainted_data(fdp.ConsumeUnicodeNoSurrogates(32),
|
| 41 |
+
fdp.ConsumeIntInRange(500, 1500))
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
def main():
|
| 45 |
+
"""Set up and start fuzzing."""
|
| 46 |
+
pysecsan.add_hooks()
|
| 47 |
+
|
| 48 |
+
atheris.instrument_all()
|
| 49 |
+
atheris.Setup(sys.argv, test_one_input, enable_python_coverage=True)
|
| 50 |
+
atheris.Fuzz()
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
if __name__ == '__main__':
|
| 54 |
+
main()
|
local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-builder/test_data/culprit-commit.txt
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
ac9ee01fcbfac745aaedca0393a8e1c8a33acd8d is the first bad commit
|
| 2 |
+
commit ac9ee01fcbfac745aaedca0393a8e1c8a33acd8d
|
| 3 |
+
Author: John Doe <johndoe@example.com>
|
| 4 |
+
Date: Tue Aug 6 08:41:53 2019 +0000
|
| 5 |
+
|
| 6 |
+
[compiler-rt] Implement getrandom interception
|
| 7 |
+
|
| 8 |
+
Summary:
|
| 9 |
+
Straightforward implementation of `getrandom` syscall and libc
|
| 10 |
+
hooks.
|
| 11 |
+
|
| 12 |
+
Test Plan: Local MSAN failures caused by uninstrumented `getrandom`
|
| 13 |
+
calls stop failing.
|
| 14 |
+
|
| 15 |
+
Patch by John Doe 3.
|
| 16 |
+
|
| 17 |
+
Reviewers: jonhdoe2, johndoe
|
| 18 |
+
|
| 19 |
+
Reviewed By: johndoe
|
| 20 |
+
|
| 21 |
+
Subscribers: johndoe4, johndoe5, #sanitizers, llvm-commits
|
| 22 |
+
|
| 23 |
+
Tags: #sanitizers, #llvm
|
| 24 |
+
|
| 25 |
+
Differential Revision: https://reviews.llvm.org/D65551
|
| 26 |
+
|
| 27 |
+
llvm-svn: 367999
|
| 28 |
+
|
| 29 |
+
:040000 040000 8db10511ca83cc7b0265c7703684cd386350151b 62508fdc5e8919bbb2a0bd185cc109868192cdb0 M compiler-rt
|
| 30 |
+
bisect run success
|
local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-clang/Dockerfile
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2016 Google Inc.
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
#
|
| 15 |
+
################################################################################
|
| 16 |
+
|
| 17 |
+
# Docker image with clang installed.
|
| 18 |
+
|
| 19 |
+
ARG IMG_TAG=latest
|
| 20 |
+
FROM ghcr.io/aixcc-finals/base-image:${IMG_TAG}
|
| 21 |
+
|
| 22 |
+
ARG arch=x86_64
|
| 23 |
+
|
| 24 |
+
ENV FUZZINTRO_OUTDIR=$SRC
|
| 25 |
+
|
| 26 |
+
# Install newer cmake.
|
| 27 |
+
# Many projects, as well as recent clang versions, need a newer cmake.
|
| 28 |
+
ENV CMAKE_VERSION 3.29.2
|
| 29 |
+
RUN apt-get update && apt-get install -y wget sudo && \
|
| 30 |
+
wget -q https://github.com/Kitware/CMake/releases/download/v$CMAKE_VERSION/cmake-$CMAKE_VERSION-Linux-$arch.sh && \
|
| 31 |
+
chmod +x cmake-$CMAKE_VERSION-Linux-$arch.sh && \
|
| 32 |
+
./cmake-$CMAKE_VERSION-Linux-$arch.sh --skip-license --prefix="/usr/local" && \
|
| 33 |
+
rm cmake-$CMAKE_VERSION-Linux-$arch.sh && \
|
| 34 |
+
SUDO_FORCE_REMOVE=yes apt-get autoremove --purge -y wget sudo && \
|
| 35 |
+
rm -rf /usr/local/doc/cmake /usr/local/bin/cmake-gui
|
| 36 |
+
|
| 37 |
+
RUN apt-get update && apt-get install -y git && \
|
| 38 |
+
git clone https://github.com/ossf/fuzz-introspector.git fuzz-introspector && \
|
| 39 |
+
cd fuzz-introspector && \
|
| 40 |
+
git checkout f9bcb8824a18d60d57e2430c5b43f525d811cae8 && \
|
| 41 |
+
git submodule init && \
|
| 42 |
+
git submodule update && \
|
| 43 |
+
apt-get autoremove --purge -y git && \
|
| 44 |
+
rm -rf .git
|
| 45 |
+
|
| 46 |
+
COPY checkout_build_install_llvm.sh /root/
|
| 47 |
+
# Keep all steps in the same script to decrease the number of intermediate
|
| 48 |
+
# layes in docker file.
|
| 49 |
+
RUN /root/checkout_build_install_llvm.sh
|
| 50 |
+
RUN rm /root/checkout_build_install_llvm.sh
|
| 51 |
+
|
| 52 |
+
# Setup the environment.
|
| 53 |
+
ENV CC "clang"
|
| 54 |
+
ENV CXX "clang++"
|
| 55 |
+
ENV CCC "clang++"
|
| 56 |
+
|
| 57 |
+
# FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION is described at
|
| 58 |
+
# https://llvm.org/docs/LibFuzzer.html#fuzzer-friendly-build-mode
|
| 59 |
+
|
| 60 |
+
# The implicit-function-declaration and implicit-int errors are downgraded to a
|
| 61 |
+
# warning, to allow compiling legacy code.
|
| 62 |
+
# See https://releases.llvm.org/16.0.0/tools/clang/docs/ReleaseNotes.html#potentially-breaking-changes
|
| 63 |
+
# Same for deprecated-declarations, int-conversion,
|
| 64 |
+
# incompatible-function-pointer-types, enum-constexpr-conversion,
|
| 65 |
+
# vla-cxx-extension
|
| 66 |
+
|
| 67 |
+
ENV CFLAGS -O1 \
|
| 68 |
+
-fno-omit-frame-pointer \
|
| 69 |
+
-gline-tables-only \
|
| 70 |
+
-Wno-error=enum-constexpr-conversion \
|
| 71 |
+
-Wno-error=incompatible-function-pointer-types \
|
| 72 |
+
-Wno-error=int-conversion \
|
| 73 |
+
-Wno-error=deprecated-declarations \
|
| 74 |
+
-Wno-error=implicit-function-declaration \
|
| 75 |
+
-Wno-error=implicit-int \
|
| 76 |
+
-Wno-error=vla-cxx-extension \
|
| 77 |
+
-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
| 78 |
+
ENV CXXFLAGS_EXTRA "-stdlib=libc++"
|
| 79 |
+
ENV CXXFLAGS "$CFLAGS $CXXFLAGS_EXTRA"
|
local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-clang/checkout_build_install_llvm.sh
ADDED
|
@@ -0,0 +1,246 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
NPROC=$(nproc)
|
| 19 |
+
|
| 20 |
+
TARGET_TO_BUILD=
|
| 21 |
+
case $(uname -m) in
|
| 22 |
+
x86_64)
|
| 23 |
+
TARGET_TO_BUILD=X86
|
| 24 |
+
ARCHITECTURE_DEPS="g++-multilib"
|
| 25 |
+
# Use chromium's clang revision.
|
| 26 |
+
export CC=$WORK/llvm-stage1/bin/clang
|
| 27 |
+
export CXX=$WORK/llvm-stage1/bin/clang++
|
| 28 |
+
;;
|
| 29 |
+
aarch64)
|
| 30 |
+
TARGET_TO_BUILD=AArch64
|
| 31 |
+
# g++ multilib is not needed on AArch64 because we don't care about i386.
|
| 32 |
+
# We need to install clang and lld using apt because the binary downloaded
|
| 33 |
+
# from Chrome's developer tools doesn't support AArch64.
|
| 34 |
+
# TODO(metzman): Make x86_64 use the distro's clang for consistency once
|
| 35 |
+
# we support AArch64 fully.
|
| 36 |
+
ARCHITECTURE_DEPS="clang lld g++"
|
| 37 |
+
export CC=clang
|
| 38 |
+
export CXX=clang++
|
| 39 |
+
;;
|
| 40 |
+
*)
|
| 41 |
+
echo "Error: unsupported target $(uname -m)"
|
| 42 |
+
exit 1
|
| 43 |
+
;;
|
| 44 |
+
esac
|
| 45 |
+
|
| 46 |
+
INTROSPECTOR_DEP_PACKAGES="texinfo bison flex"
|
| 47 |
+
# zlib1g-dev is needed for llvm-profdata to handle coverage data from rust compiler
|
| 48 |
+
LLVM_DEP_PACKAGES="build-essential make ninja-build git python3 python3-distutils binutils-dev zlib1g-dev $ARCHITECTURE_DEPS $INTROSPECTOR_DEP_PACKAGES"
|
| 49 |
+
|
| 50 |
+
apt-get update && apt-get install -y $LLVM_DEP_PACKAGES --no-install-recommends
|
| 51 |
+
|
| 52 |
+
# For manual bumping.
|
| 53 |
+
# On each bump a full trial run for everything (fuzzing engines, sanitizers,
|
| 54 |
+
# languages, projects, ...) is needed.
|
| 55 |
+
# Check CMAKE_VERSION infra/base-images/base-clang/Dockerfile was released
|
| 56 |
+
# recently enough to fully support this clang version.
|
| 57 |
+
OUR_LLVM_REVISION=llvmorg-18.1.8
|
| 58 |
+
|
| 59 |
+
mkdir $SRC/chromium_tools
|
| 60 |
+
cd $SRC/chromium_tools
|
| 61 |
+
git clone https://chromium.googlesource.com/chromium/src/tools/clang
|
| 62 |
+
cd clang
|
| 63 |
+
# Pin clang script due to https://github.com/google/oss-fuzz/issues/7617
|
| 64 |
+
git checkout 9eb79319239629c1b23cf7a59e5ebb2bab319a34
|
| 65 |
+
|
| 66 |
+
LLVM_SRC=$SRC/llvm-project
|
| 67 |
+
# Checkout
|
| 68 |
+
CHECKOUT_RETRIES=10
|
| 69 |
+
function clone_with_retries {
|
| 70 |
+
REPOSITORY=$1
|
| 71 |
+
LOCAL_PATH=$2
|
| 72 |
+
CHECKOUT_RETURN_CODE=1
|
| 73 |
+
|
| 74 |
+
# Disable exit on error since we might encounter some failures while retrying.
|
| 75 |
+
set +e
|
| 76 |
+
for i in $(seq 1 $CHECKOUT_RETRIES); do
|
| 77 |
+
rm -rf $LOCAL_PATH
|
| 78 |
+
git clone $REPOSITORY $LOCAL_PATH
|
| 79 |
+
CHECKOUT_RETURN_CODE=$?
|
| 80 |
+
if [ $CHECKOUT_RETURN_CODE -eq 0 ]; then
|
| 81 |
+
break
|
| 82 |
+
fi
|
| 83 |
+
done
|
| 84 |
+
|
| 85 |
+
# Re-enable exit on error. If checkout failed, script will exit.
|
| 86 |
+
set -e
|
| 87 |
+
return $CHECKOUT_RETURN_CODE
|
| 88 |
+
}
|
| 89 |
+
clone_with_retries https://github.com/llvm/llvm-project.git $LLVM_SRC
|
| 90 |
+
|
| 91 |
+
git -C $LLVM_SRC checkout $OUR_LLVM_REVISION
|
| 92 |
+
echo "Using LLVM revision: $OUR_LLVM_REVISION"
|
| 93 |
+
|
| 94 |
+
# For fuzz introspector.
|
| 95 |
+
echo "Applying introspector changes"
|
| 96 |
+
OLD_WORKING_DIR=$PWD
|
| 97 |
+
cd $LLVM_SRC
|
| 98 |
+
cp -rf /fuzz-introspector/frontends/llvm/include/llvm/Transforms/FuzzIntrospector/ ./llvm/include/llvm/Transforms/FuzzIntrospector
|
| 99 |
+
cp -rf /fuzz-introspector/frontends/llvm/lib/Transforms/FuzzIntrospector ./llvm/lib/Transforms/FuzzIntrospector
|
| 100 |
+
|
| 101 |
+
# LLVM currently does not support dynamically loading LTO passes. Thus, we
|
| 102 |
+
# hardcode it into Clang instead. Ref: https://reviews.llvm.org/D77704
|
| 103 |
+
/fuzz-introspector/frontends/llvm/patch-llvm.sh
|
| 104 |
+
cd $OLD_WORKING_DIR
|
| 105 |
+
|
| 106 |
+
mkdir -p $WORK/llvm-stage2 $WORK/llvm-stage1
|
| 107 |
+
python3 $SRC/chromium_tools/clang/scripts/update.py --output-dir $WORK/llvm-stage1
|
| 108 |
+
|
| 109 |
+
cd $WORK/llvm-stage2
|
| 110 |
+
cmake -G "Ninja" \
|
| 111 |
+
-DLIBCXX_ENABLE_SHARED=OFF \
|
| 112 |
+
-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON \
|
| 113 |
+
-DLIBCXXABI_ENABLE_SHARED=OFF \
|
| 114 |
+
-DCMAKE_BUILD_TYPE=Release \
|
| 115 |
+
-DLLVM_ENABLE_RUNTIMES="compiler-rt;libcxx;libcxxabi" \
|
| 116 |
+
-DLLVM_TARGETS_TO_BUILD="$TARGET_TO_BUILD" \
|
| 117 |
+
-DLLVM_ENABLE_PROJECTS="clang;lld" \
|
| 118 |
+
-DLLVM_BINUTILS_INCDIR="/usr/include/" \
|
| 119 |
+
-DLIBCXXABI_USE_LLVM_UNWINDER=OFF \
|
| 120 |
+
$LLVM_SRC/llvm
|
| 121 |
+
|
| 122 |
+
ninja -j $NPROC
|
| 123 |
+
ninja install
|
| 124 |
+
rm -rf $WORK/llvm-stage1 $WORK/llvm-stage2
|
| 125 |
+
|
| 126 |
+
# libFuzzer sources.
|
| 127 |
+
cp -r $LLVM_SRC/compiler-rt/lib/fuzzer $SRC/libfuzzer
|
| 128 |
+
|
| 129 |
+
# Use the clang we just built from now on.
|
| 130 |
+
export CC=clang
|
| 131 |
+
export CXX=clang++
|
| 132 |
+
|
| 133 |
+
function free_disk_space {
|
| 134 |
+
rm -rf $LLVM_SRC $SRC/chromium_tools
|
| 135 |
+
apt-get autoremove --purge -y $LLVM_DEP_PACKAGES
|
| 136 |
+
# Delete unneeded parts of LLVM to reduce image size.
|
| 137 |
+
# See https://github.com/google/oss-fuzz/issues/5170
|
| 138 |
+
LLVM_TOOLS_TMPDIR=/tmp/llvm-tools
|
| 139 |
+
mkdir $LLVM_TOOLS_TMPDIR
|
| 140 |
+
# Move binaries with llvm- prefix that we want into LLVM_TOOLS_TMPDIR.
|
| 141 |
+
mv \
|
| 142 |
+
/usr/local/bin/llvm-ar \
|
| 143 |
+
/usr/local/bin/llvm-as \
|
| 144 |
+
/usr/local/bin/llvm-config \
|
| 145 |
+
/usr/local/bin/llvm-cov \
|
| 146 |
+
/usr/local/bin/llvm-objcopy \
|
| 147 |
+
/usr/local/bin/llvm-nm \
|
| 148 |
+
/usr/local/bin/llvm-profdata \
|
| 149 |
+
/usr/local/bin/llvm-ranlib \
|
| 150 |
+
/usr/local/bin/llvm-symbolizer \
|
| 151 |
+
/usr/local/bin/llvm-undname \
|
| 152 |
+
$LLVM_TOOLS_TMPDIR
|
| 153 |
+
|
| 154 |
+
# Delete remaining llvm- binaries.
|
| 155 |
+
rm -rf /usr/local/bin/llvm-*
|
| 156 |
+
|
| 157 |
+
# Restore the llvm- binaries we want to keep.
|
| 158 |
+
mv $LLVM_TOOLS_TMPDIR/* /usr/local/bin/
|
| 159 |
+
rm -rf $LLVM_TOOLS_TMPDIR
|
| 160 |
+
|
| 161 |
+
# Remove binaries from LLVM build that we don't need.
|
| 162 |
+
rm -f \
|
| 163 |
+
/usr/local/bin/bugpoint \
|
| 164 |
+
/usr/local/bin/llc \
|
| 165 |
+
/usr/local/bin/lli \
|
| 166 |
+
/usr/local/bin/clang-check \
|
| 167 |
+
/usr/local/bin/clang-refactor \
|
| 168 |
+
/usr/local/bin/clang-offload-wrapper \
|
| 169 |
+
/usr/local/bin/clang-offload-bundler \
|
| 170 |
+
/usr/local/bin/clang-repl \
|
| 171 |
+
/usr/local/bin/clang-check \
|
| 172 |
+
/usr/local/bin/clang-refactor \
|
| 173 |
+
/usr/local/bin/c-index-test \
|
| 174 |
+
/usr/local/bin/clang-rename \
|
| 175 |
+
/usr/local/bin/clang-scan-deps \
|
| 176 |
+
/usr/local/bin/clang-extdef-mapping \
|
| 177 |
+
/usr/local/bin/diagtool \
|
| 178 |
+
/usr/local/bin/sanstats \
|
| 179 |
+
/usr/local/bin/dsymutil \
|
| 180 |
+
/usr/local/bin/verify-uselistorder \
|
| 181 |
+
/usr/local/bin/clang-format
|
| 182 |
+
|
| 183 |
+
# Remove unneeded clang libs, CMake files from LLVM build, lld libs, and the
|
| 184 |
+
# libraries.
|
| 185 |
+
# Note: we need fuzzer_no_main libraries for atheris. Don't delete.
|
| 186 |
+
rm -rf \
|
| 187 |
+
/usr/local/lib/libclang* \
|
| 188 |
+
/usr/local/lib/liblld* \
|
| 189 |
+
/usr/local/lib/cmake/
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
if [ "$TARGET_TO_BUILD" == "AArch64" ]
|
| 193 |
+
then
|
| 194 |
+
free_disk_space
|
| 195 |
+
# Exit now on AArch64. We don't need to rebuild libc++ because on AArch64 we
|
| 196 |
+
# do not support MSAN nor do we care about i386.
|
| 197 |
+
exit 0
|
| 198 |
+
fi
|
| 199 |
+
|
| 200 |
+
function cmake_libcxx {
|
| 201 |
+
extra_args="$@"
|
| 202 |
+
cmake -G "Ninja" \
|
| 203 |
+
-DLIBCXX_ENABLE_SHARED=OFF \
|
| 204 |
+
-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON \
|
| 205 |
+
-DLIBCXXABI_ENABLE_SHARED=OFF \
|
| 206 |
+
-DLIBCXXABI_USE_LLVM_UNWINDER=OFF \
|
| 207 |
+
-DCMAKE_BUILD_TYPE=Release \
|
| 208 |
+
-DLLVM_ENABLE_PIC=ON \
|
| 209 |
+
-DLLVM_TARGETS_TO_BUILD="$TARGET_TO_BUILD" \
|
| 210 |
+
-DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi" \
|
| 211 |
+
-DLLVM_BINUTILS_INCDIR="/usr/include/" \
|
| 212 |
+
$extra_args \
|
| 213 |
+
-S $LLVM_SRC/runtimes
|
| 214 |
+
}
|
| 215 |
+
|
| 216 |
+
# 32-bit libraries.
|
| 217 |
+
mkdir -p $WORK/i386
|
| 218 |
+
cd $WORK/i386
|
| 219 |
+
cmake_libcxx \
|
| 220 |
+
-DCMAKE_INSTALL_PREFIX=/usr/i386/ \
|
| 221 |
+
-DCMAKE_C_FLAGS="-m32" \
|
| 222 |
+
-DCMAKE_CXX_FLAGS="-m32"
|
| 223 |
+
|
| 224 |
+
ninja -j $NPROC cxx
|
| 225 |
+
ninja install-cxx
|
| 226 |
+
rm -rf $WORK/i386
|
| 227 |
+
|
| 228 |
+
# MemorySanitizer instrumented libraries.
|
| 229 |
+
mkdir -p $WORK/msan
|
| 230 |
+
cd $WORK/msan
|
| 231 |
+
|
| 232 |
+
# https://github.com/google/oss-fuzz/issues/1099
|
| 233 |
+
cat <<EOF > $WORK/msan/ignorelist.txt
|
| 234 |
+
fun:__gxx_personality_*
|
| 235 |
+
EOF
|
| 236 |
+
|
| 237 |
+
cmake_libcxx \
|
| 238 |
+
-DLLVM_USE_SANITIZER=Memory \
|
| 239 |
+
-DCMAKE_INSTALL_PREFIX=/usr/msan/ \
|
| 240 |
+
-DCMAKE_CXX_FLAGS="-fsanitize-ignorelist=$WORK/msan/ignorelist.txt"
|
| 241 |
+
|
| 242 |
+
ninja -j $NPROC cxx
|
| 243 |
+
ninja install-cxx
|
| 244 |
+
rm -rf $WORK/msan
|
| 245 |
+
|
| 246 |
+
free_disk_space
|
local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-runner/gocoverage/convertcorpus/go.mod
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
module oss-fuzz.com/gocoverage/convertcorpus
|
| 2 |
+
|
| 3 |
+
go 1.19
|
| 4 |
+
|
| 5 |
+
require github.com/AdamKorcz/go-118-fuzz-build v0.0.0-20221110144148-3ffc89b74f84
|
| 6 |
+
|
| 7 |
+
require (
|
| 8 |
+
github.com/AdaLogics/go-fuzz-headers v0.0.0-20220824214621-3c06a36a6952 // indirect
|
| 9 |
+
github.com/cyphar/filepath-securejoin v0.2.3 // indirect
|
| 10 |
+
)
|
local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-runner/gocoverage/convertcorpus/go.sum
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
github.com/AdaLogics/go-fuzz-headers v0.0.0-20220824214621-3c06a36a6952 h1:cs1LC1MGKD1O4neR89Rc24t0u15Vs5ASfUQ2tLr/KbY=
|
| 2 |
+
github.com/AdaLogics/go-fuzz-headers v0.0.0-20220824214621-3c06a36a6952/go.mod h1:i9fr2JpcEcY/IHEvzCM3qXUZYOQHgR89dt4es1CgMhc=
|
| 3 |
+
github.com/AdamKorcz/go-118-fuzz-build v0.0.0-20221110144148-3ffc89b74f84 h1:a0NR83n+t4XyUh32ifxu6XsmeLMKyOx5Lxub9IeBM7k=
|
| 4 |
+
github.com/AdamKorcz/go-118-fuzz-build v0.0.0-20221110144148-3ffc89b74f84/go.mod h1:pXIs8t4wo19ehhsffZsAZxSQ+oPUF41iiDrUaIDWKFU=
|
| 5 |
+
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
| 6 |
+
github.com/cyphar/filepath-securejoin v0.2.3 h1:YX6ebbZCZP7VkM3scTTokDgBL2TY741X51MTk3ycuNI=
|
| 7 |
+
github.com/cyphar/filepath-securejoin v0.2.3/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4=
|
| 8 |
+
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
| 9 |
+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
| 10 |
+
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
| 11 |
+
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
| 12 |
+
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
| 13 |
+
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
| 14 |
+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
| 15 |
+
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
|
| 16 |
+
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
| 17 |
+
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
| 18 |
+
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
| 19 |
+
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
| 20 |
+
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
| 21 |
+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
| 22 |
+
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
| 23 |
+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
| 24 |
+
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-runner/gocoverage/convertcorpus/main.go
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package main
|
| 2 |
+
|
| 3 |
+
import (
|
| 4 |
+
"fmt"
|
| 5 |
+
"log"
|
| 6 |
+
"os"
|
| 7 |
+
"path/filepath"
|
| 8 |
+
|
| 9 |
+
"github.com/AdamKorcz/go-118-fuzz-build/coverage"
|
| 10 |
+
)
|
| 11 |
+
|
| 12 |
+
// reads all corpus files in a directory and converts
|
| 13 |
+
// them from libFuzzer format to native Go format.
|
| 14 |
+
func main() {
|
| 15 |
+
if len(os.Args) != 3 {
|
| 16 |
+
fmt.Println(os.Args)
|
| 17 |
+
log.Fatalf("need exactly two argument")
|
| 18 |
+
}
|
| 19 |
+
FUZZERNAME := os.Args[1]
|
| 20 |
+
CORPUS_PATH := os.Args[2]
|
| 21 |
+
|
| 22 |
+
filepath.Walk(CORPUS_PATH, func(path string, info os.FileInfo, err error) error {
|
| 23 |
+
if err != nil {
|
| 24 |
+
return nil
|
| 25 |
+
}
|
| 26 |
+
if !info.Mode().IsRegular() {
|
| 27 |
+
return nil
|
| 28 |
+
}
|
| 29 |
+
libFuzzerSeed, err := os.ReadFile(path)
|
| 30 |
+
if err != nil {
|
| 31 |
+
panic(err)
|
| 32 |
+
}
|
| 33 |
+
out := os.Getenv("OUT")
|
| 34 |
+
fuzzerContents, err := os.ReadFile(filepath.Join(out, "rawfuzzers", FUZZERNAME))
|
| 35 |
+
if err != nil {
|
| 36 |
+
panic(err)
|
| 37 |
+
}
|
| 38 |
+
goSeed := coverage.ConvertLibfuzzerSeedToGoSeed(fuzzerContents, libFuzzerSeed, FUZZERNAME)
|
| 39 |
+
err = os.Remove(path)
|
| 40 |
+
if err != nil {
|
| 41 |
+
panic(err)
|
| 42 |
+
}
|
| 43 |
+
f, err := os.Create(path)
|
| 44 |
+
if err != nil {
|
| 45 |
+
panic(err)
|
| 46 |
+
}
|
| 47 |
+
defer f.Close()
|
| 48 |
+
_, err = f.Write([]byte(goSeed))
|
| 49 |
+
if err != nil {
|
| 50 |
+
panic(err)
|
| 51 |
+
}
|
| 52 |
+
return nil
|
| 53 |
+
})
|
| 54 |
+
}
|
local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-runner/gocoverage/go.mod
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
module oss-fuzz.com/gocoverage
|
| 2 |
+
|
| 3 |
+
go 1.14
|
| 4 |
+
|
| 5 |
+
require (
|
| 6 |
+
github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5
|
| 7 |
+
golang.org/x/tools v0.1.0
|
| 8 |
+
)
|
local-test-tika-full-01-vuln_6/fuzz-tooling/infra/base-images/base-runner/gocoverage/go.sum
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
| 2 |
+
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
|
| 3 |
+
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
|
| 4 |
+
github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5 h1:zIaiqGYDQwa4HVx5wGRTXbx38Pqxjemn4BP98wpzpXo=
|
| 5 |
+
github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
| 6 |
+
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
| 7 |
+
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
| 8 |
+
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
| 9 |
+
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
| 10 |
+
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
| 11 |
+
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
| 12 |
+
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
| 13 |
+
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
| 14 |
+
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
| 15 |
+
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
| 16 |
+
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
| 17 |
+
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
| 18 |
+
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
| 19 |
+
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
| 20 |
+
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
| 21 |
+
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
| 22 |
+
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
| 23 |
+
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
| 24 |
+
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
| 25 |
+
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
| 26 |
+
golang.org/x/tools v0.1.0 h1:po9/4sTYwZU9lPhi1tOrb4hCv3qrhiQ77LZfGa2OjwY=
|
| 27 |
+
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
|
| 28 |
+
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
| 29 |
+
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
| 30 |
+
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|