diff --git a/.bazelrc b/.bazelrc index 163ffecbf..d07e43ac9 100644 --- a/.bazelrc +++ b/.bazelrc @@ -10,34 +10,53 @@ build --nozip_undeclared_test_outputs # C/C++ # GCC is supported on a best-effort basis. common --repo_env=CC=clang -# Required by abseil-cpp. -build --cxxopt=-std=c++14 +# On Linux, use a hermetic toolchain and sysroot shared between local dev setups and CI. +# Such a toolchain isn't easily available on macOS or Windows. +common:linux --repo_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1 +common:linux --extra_toolchains=@llvm_toolchain//:cc-toolchain-x86_64-linux # Silence protobuf compilation warnings. +build --copt=-Wno-unused-function +build --copt=-Wno-unknown-warning-option build --host_copt=-Wno-unused-function build --host_copt=-Wno-unknown-warning-option -# Requires a relatively modern clang. -build:ci --features=layering_check +# Ensure that cc_* targets declare all their direct dependencies (requires clang). +# TODO: This is currently ignored by the hermetic toolchain used on Linux. +# See: https://github.com/grailbio/bazel-toolchain/issues/203 +build --features=layering_check build:macos --apple_crosstool_top=@local_config_apple_cc//:toolchain build:macos --crosstool_top=@local_config_apple_cc//:toolchain build:macos --host_crosstool_top=@local_config_apple_cc//:toolchain # Java -# Always build for Java 8, even with a newer JDK. This ensures that all -# artifacts we release are compatible with Java 8 runtimes. +# Always build for Java 8, even with a newer JDK. This ensures that all artifacts we release are +# bytecode compatible with Java 8 runtimes. Runtime compatibility (e.g not using APIs that aren't +# available in Java 8) is verified in CI. # Note: We would like to use --release, but can't due to -# https://bugs.openjdk.org/browse/JDK-8214165. -build --javacopt=-target --javacopt=8 +# https://bugs.openjdk.org/browse/JDK-8214165. build --java_language_version=8 -build --tool_java_language_version=8 -# Use a hermetic JDK to compile Java code, which also means that contributors -# don't need to install a JDK to compile Jazzer. -build --java_runtime_version=remotejdk_17 -build --tool_java_runtime_version=remotejdk_17 + +# Targeting Java 8 with JDK 21 is deprecated and results in this warning: +# warning: [options] source value 8 is obsolete and will be removed in a future release +# warning: [options] target value 8 is obsolete and will be removed in a future release +# warning: [options] To suppress warnings about obsolete options, use -Xlint:-options. +# Internally, Bazel always runs javac on a Java 21 runtime, but uses the classpath obtained from the +# runtime configured below. +build --javacopt=-Xlint:-options + +# Tools used during the build do not have compatibility requirements, so we can use the most recent +# language features. +build --tool_java_language_version=21 + +# Compile for a hermetic JDK so that devs don't have to have a particular JDK installed and +# configured locally. +build --java_runtime_version=remotejdk_21 +build --tool_java_runtime_version=remotejdk_21 + # Speed up Java compilation by removing indirect deps from the compile classpath. +# Only has an effect when used together with --disk_cache or --remote_cache. build --experimental_java_classpath=bazel # Android -build --incompatible_enable_android_toolchain_resolution build --android_platforms=//:android_arm64 # Windows @@ -50,10 +69,6 @@ build:windows --features=static_link_msvcrt test:windows --noincompatible_strict_action_env run:windows --noincompatible_strict_action_env -# Toolchain -# Since the toolchain is conditional on OS and architecture, set it on the particular GitHub Action. -common:toolchain --repo_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1 - # Forward debug variables to tests build --test_env=JAZZER_AUTOFUZZ_DEBUG build --test_env=JAZZER_REFLECTION_DEBUG @@ -82,10 +97,6 @@ build:ci --experimental_profile_include_primary_output build:ci --nolegacy_important_outputs common:ci --announce_rc -# Docker images -common:docker --config=toolchain -common:docker --extra_toolchains=@llvm_toolchain//:cc-toolchain-x86_64-linux - # Generic coverage configuration taken from https://github.com/fmeum/rules_jni coverage --combined_report=lcov coverage --experimental_use_llvm_covmap @@ -102,3 +113,10 @@ coverage --test_tag_filters=-no-coverage # https://github.com/bazelbuild/bazel/issues/4867#issuecomment-830402410 common:quiet --ui_event_filters=-info,-stderr common:quiet --noshow_progress + +# Use --config=fail-fast to speed up local iteration on tests by letting bazel test stop right on +# the first failing test. +# Let bazel test stop on the first failing test target. +test:fail-fast --notest_keep_going +# Instruct test runners to fail a test target on the first failing test. +test:fail-fast --test_runner_fail_fast diff --git a/.bazelversion b/.bazelversion index f1f0535f1..150202076 100644 --- a/.bazelversion +++ b/.bazelversion @@ -1 +1 @@ -1f12a4d8f82efa3eac5e1a708833e8ed53e54327 +7.3.0 diff --git a/.github/BUILD.bazel b/.github/BUILD.bazel index 66897c442..4a3a2d889 100644 --- a/.github/BUILD.bazel +++ b/.github/BUILD.bazel @@ -3,6 +3,7 @@ package(default_visibility = ["//visibility:public"]) +# Xcode version on public GitHub Actions macos-12 runners xcode_version( name = "version14_2_0_14C18", aliases = [ @@ -19,8 +20,28 @@ xcode_version( version = "14.2.0.14C18", ) +# Xcode version on public GitHub Actions macos-13 runners +xcode_version( + name = "version15_2_0_15C500b", + aliases = [ + "15.2.0.15C500b", + "15C500b", + "15.2.0", + "15.2", + "15", + ], + default_ios_sdk_version = "17.2", + default_macos_sdk_version = "14.2", + default_tvos_sdk_version = "17.1", + default_watchos_sdk_version = "10.2", + version = "15.2.0.15C500b", +) + xcode_config( name = "host_xcodes", - default = ":version14_2_0_14C18", - versions = [":version14_2_0_14C18"], + default = ":version15_2_0_15C500b", + versions = [ + ":version15_2_0_15C500b", + ":version14_2_0_14C18", + ], ) diff --git a/.github/scripts/echoBuildBuddyConfig.sh b/.github/scripts/echoBuildBuddyConfig.sh index 7953549ba..5f04200b5 100755 --- a/.github/scripts/echoBuildBuddyConfig.sh +++ b/.github/scripts/echoBuildBuddyConfig.sh @@ -1,5 +1,14 @@ #!/usr/bin/env bash +# +# Copyright 2024 Code Intelligence GmbH +# +# By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. +# +# The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt +# located in the root directory of the project. +# + if [ -n "${1}" ]; then echo "BUILD_BUDDY_CONFIG=--config=ci --remote_header=x-buildbuddy-api-key=${1}"; else diff --git a/.github/workflows/check-formatting.yml b/.github/workflows/check-formatting.yml index a1257c68d..c99a5fb83 100644 --- a/.github/workflows/check-formatting.yml +++ b/.github/workflows/check-formatting.yml @@ -2,8 +2,6 @@ name: Check formatting # Controls when the action will run. on: - push: - branches: [ main ] pull_request: branches: [ main ] merge_group: @@ -12,10 +10,10 @@ on: jobs: check_formatting: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Run format.sh and print changes env: diff --git a/.github/workflows/datadog.yaml b/.github/workflows/datadog.yaml index e5f9ff8e5..a9bdc4671 100644 --- a/.github/workflows/datadog.yaml +++ b/.github/workflows/datadog.yaml @@ -6,7 +6,7 @@ on: jobs: send-release-event: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - name: Send Release Event run: | diff --git a/.github/workflows/prerelease.yaml b/.github/workflows/prerelease.yaml index 758707fba..936030334 100644 --- a/.github/workflows/prerelease.yaml +++ b/.github/workflows/prerelease.yaml @@ -12,21 +12,21 @@ jobs: strategy: matrix: include: - - os: ubuntu-20.04 + - os: ubuntu-22.04 name: linux - - os: macos-11 + - os: macos-13 name: macos - os: windows-2019 name: windows steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up JDK - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: distribution: zulu - java-version: 8 + java-version: 21 - name: Append build settings to .bazelrc shell: bash @@ -35,8 +35,6 @@ jobs: echo "build --remote_header=x-buildbuddy-api-key=${{ secrets.BUILDBUDDY_API_KEY }}" >> .bazelrc echo "build --config=ci" >> .bazelrc echo "build --//deploy:jazzer_version=${TAG#v}" >> .bazelrc - echo "build:linux --config=toolchain" >> .bazelrc - echo "build:linux --extra_toolchains=@llvm_toolchain//:cc-toolchain-x86_64-linux" >> .bazelrc - name: Build shell: bash @@ -48,30 +46,31 @@ jobs: cp -L $(bazel cquery --output=files :jazzer_release) jazzer-${{ matrix.name }}.tar.gz - name: Upload jazzer.jar - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: jazzer_tmp + name: jazzer_tmp_${{ matrix.name }} path: jazzer-${{ matrix.name }}.jar if-no-files-found: error - name: Upload release archive - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: jazzer_releases + name: jazzer_releases_${{ matrix.name }} path: jazzer-${{ matrix.name }}.tar.gz if-no-files-found: error merge_jars: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 needs: build_release steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Download individual jars - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: - name: jazzer_tmp + pattern: jazzer_tmp_* + merge-multiple: true path: _tmp/ - name: Merge jars @@ -81,26 +80,24 @@ jobs: $(find "$(pwd)/_tmp/" -name '*.jar' -printf "--sources %h/%f ") - name: Upload merged jar - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: jazzer path: _tmp/jazzer.jar if-no-files-found: error maven_predeploy: - # TODO: Our hermetic toolchain doesn't support ubuntu-latest yet and fails with: - # external/llvm_toolchain_llvm/bin/clang: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 needs: merge_jars environment: name: Deploy steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up JDK - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: distribution: zulu java-version: 8 @@ -112,11 +109,9 @@ jobs: echo "build --remote_header=x-buildbuddy-api-key=${{ secrets.BUILDBUDDY_API_KEY }}" >> .bazelrc echo "build --config=ci" >> .bazelrc echo "build --//deploy:jazzer_version=${TAG#v}" >> .bazelrc - echo "build:linux --config=toolchain" >> .bazelrc - echo "build:linux --extra_toolchains=@llvm_toolchain//:cc-toolchain-x86_64-linux" >> .bazelrc - name: Download merged jar - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: jazzer path: _tmp/ @@ -131,23 +126,24 @@ jobs: create_release: needs: build_release - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 permissions: contents: write # for creating releases steps: - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Download individual tar.gzs - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: - name: jazzer_releases + pattern: jazzer_releases_* + merge-multiple: true path: _releases/ - name: create release - uses: softprops/action-gh-release@c9b46fe7aad9f02afd89b12450b780f52dacfb2d + uses: softprops/action-gh-release@4634c16e79c963813287e889244c50009e7f0981 with: generate_release_notes: true draft: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 64816ac74..450ed95f6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,31 +2,15 @@ name: Release on: workflow_dispatch: - release: - types: [released] jobs: - docker_push: - runs-on: ubuntu-latest - - environment: - name: Deploy - - steps: - - uses: actions/checkout@v3 - - - name: Docker login - run: echo "${{ secrets.DOCKER_TOKEN }}" | docker login --username ${{ secrets.DOCKER_USER }} --password-stdin - - - name: Push docker containers - run: docker/push_all.sh generate_docs: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Build documentation run: | @@ -36,7 +20,7 @@ jobs: cp $(bazel cquery --output=files //deploy:jazzer-junit-docs) ./jazzer-junit-docs.jar - name: Upload jars - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: jazzer_docs_jars path: | @@ -46,7 +30,7 @@ jobs: if-no-files-found: error update_docs: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 needs: generate_docs environment: @@ -54,13 +38,13 @@ jobs: steps: - name: checkout docs - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: 'CodeIntelligenceTesting/jazzer-docs' ssh-key: "${{ secrets.JAZZER_DOCS_SSH_KEY_PRIVATE }}" - name: Download jar - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: jazzer_docs_jars path: . diff --git a/.github/workflows/run-all-tests.yml b/.github/workflows/run-all-tests-main.yml similarity index 55% rename from .github/workflows/run-all-tests.yml rename to .github/workflows/run-all-tests-main.yml index 8c6a93ad6..43e43c672 100644 --- a/.github/workflows/run-all-tests.yml +++ b/.github/workflows/run-all-tests-main.yml @@ -1,22 +1,24 @@ -name: CI +name: CI Main on: push: branches: [ main ] - pull_request: - branches: [ main ] merge_group: workflow_dispatch: +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: test_junit_springboot: name: Spring Boot - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up JDK - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: distribution: zulu java-version: 17 @@ -34,42 +36,31 @@ jobs: name: Build & Test strategy: matrix: - os: [ubuntu-20.04, macos-12, windows-2019] - jdk: [8, 21] + os: [ macos-13, windows-2019 ] + # Test JDK 8 on Windows and mac only on main. + jdk: [8] include: - - jdk: 21 - # Workaround for https://github.com/bazelbuild/bazel/issues/14502 - extra_bazel_args: "--jvmopt=-Djava.security.manager=allow" - - os: ubuntu-20.04 - arch: "linux" - bazel_args: "//launcher/android:jazzer_android //tests/benchmarks" - - os: macos-12 - arch: "macos-x86_64" - bazel_args: "--xcode_version_config=//.github:host_xcodes //launcher/android:jazzer_android" + - os: macos-13 + arch: "macos-arm64" + bazel_args: "--xcode_version_config=//.github:host_xcodes" - os: windows-2019 arch: "windows" steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up JDK - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: distribution: zulu - java-version: ${{ matrix.jdk }} - - # The java binary has the necessary entitlements to allow tests to pass, but that requires - # user interaction (clicking through Gatekeeper warnings) that we can't simulate in CI. - - name: Remove codesign signature on java binary - if: contains(matrix.os, 'mac') - run: codesign --remove-signature "$JAVA_HOME"/bin/java + java-version: 21 - name: Set Build Buddy config run: .github/scripts/echoBuildBuddyConfig.sh ${{ secrets.BUILDBUDDY_API_KEY }} >> $GITHUB_ENV shell: bash - name: Build & Test - run: bazelisk test ${{env.BUILD_BUDDY_CONFIG}} --java_runtime_version=local_jdk_${{ matrix.jdk }} ${{ matrix.bazel_args }} ${{ matrix.extra_bazel_args }} --build_tag_filters="-no-${{ matrix.arch }}-jdk${{ matrix.jdk }},-no-jdk${{ matrix.jdk }}" --test_tag_filters="-no-${{ matrix.arch }}-jdk${{ matrix.jdk }},-no-jdk${{ matrix.jdk }}" //... + run: bazelisk test ${{env.BUILD_BUDDY_CONFIG}} --java_runtime_version=remotejdk_${{ matrix.jdk }} ${{ matrix.bazel_args }} ${{ matrix.extra_bazel_args }} --build_tag_filters="-no-${{ matrix.arch }},-no-${{ matrix.arch }}-jdk${{ matrix.jdk }},-no-jdk${{ matrix.jdk }}" --test_tag_filters="-no-${{ matrix.arch }},-no-${{ matrix.arch }}-jdk${{ matrix.jdk }},-no-jdk${{ matrix.jdk }}" //... - name: Copy Bazel log if: always() @@ -78,7 +69,7 @@ jobs: - name: Upload test logs if: always() - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: testlogs-${{ matrix.arch }}-${{ matrix.jdk }} # https://github.com/actions/upload-artifact/issues/92#issuecomment-711107236 diff --git a/.github/workflows/run-all-tests-pr.yml b/.github/workflows/run-all-tests-pr.yml new file mode 100644 index 000000000..b068c7bbd --- /dev/null +++ b/.github/workflows/run-all-tests-pr.yml @@ -0,0 +1,67 @@ +name: CI PR +on: + pull_request: + branches: [ main ] + merge_group: + + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + + build_and_test: + runs-on: ${{ matrix.os }} + name: Build & Test + strategy: + matrix: + os: [ubuntu-22.04, windows-2019, macos-13] + jdk: [21] + include: + - jdk: 21 + # Workaround for https://github.com/bazelbuild/bazel/issues/14502 + extra_bazel_args: "--jvmopt=-Djava.security.manager=allow" +# - os: ubuntu-22.04 +# arch: "linux" +# bazel_args: "//launcher/android:jazzer_android" + - os: ubuntu-22.04 + # Use JDK 8 only on Ubuntu in PRs. + jdk: 8 + - os: macos-13 + arch: "macos-arm64" + bazel_args: "--xcode_version_config=//.github:host_xcodes" + - os: windows-2019 + arch: "windows" + + steps: + - uses: actions/checkout@v4 + + - name: Set up JDK + uses: actions/setup-java@v4 + with: + distribution: zulu + java-version: 21 + + - name: Set Build Buddy config + run: .github/scripts/echoBuildBuddyConfig.sh ${{ secrets.BUILDBUDDY_API_KEY }} >> $GITHUB_ENV + shell: bash + + - name: Build & Test + run: bazelisk test ${{env.BUILD_BUDDY_CONFIG}} --java_runtime_version=remotejdk_${{ matrix.jdk }} ${{ matrix.bazel_args }} ${{ matrix.extra_bazel_args }} --build_tag_filters="-no-${{ matrix.arch }},-no-${{ matrix.arch }}-jdk${{ matrix.jdk }},-no-jdk${{ matrix.jdk }}" --test_tag_filters="-no-${{ matrix.arch }},-no-${{ matrix.arch }}-jdk${{ matrix.jdk }},-no-jdk${{ matrix.jdk }}" //... + + - name: Copy Bazel log + if: always() + shell: bash + run: cp "$(readlink bazel-out)"/../../../java.log* . + + - name: Upload test logs + if: always() + uses: actions/upload-artifact@v4 + with: + name: testlogs-${{ matrix.arch }}-${{ matrix.jdk }} + # https://github.com/actions/upload-artifact/issues/92#issuecomment-711107236 + path: | + bazel-testlogs*/**/test.log + java.log* diff --git a/.gitignore b/.gitignore index b0ac4affd..27afb26e6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,9 @@ /bazel-* +.idea .ijwb .clwb /coverage +# The lockfile speeds up local builds, but is still quite verbose and potentially +# platform-dependent. Ignore it for now. +# https://github.com/bazelbuild/bazel/issues/20369 +MODULE.bazel.lock diff --git a/BUILD.bazel b/BUILD.bazel index 4210f132a..69df06a33 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1,7 +1,15 @@ load("@buildifier_prebuilt//:rules.bzl", "buildifier", "buildifier_test") +load("@rules_license//rules:license.bzl", "license") load("@rules_pkg//:pkg.bzl", "pkg_tar") load("//bazel:compat.bzl", "SKIP_ON_WINDOWS") +license( + name = "license", + copyright_notice = "Copyright 2024 Code Intelligence GmbH", + license_text = "LICENSE", + visibility = ["//visibility:public"], +) + exports_files(["LICENSE"]) pkg_tar( @@ -59,7 +67,7 @@ buildifier_test( exclude_patterns = BUILDIFIER_EXCLUDE_PATTERNS, no_sandbox = True, target_compatible_with = SKIP_ON_WINDOWS, - workspace = "//:WORKSPACE.bazel", + workspace = "//:WORKSPACE.bzlmod", ) alias( diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 8e1c2f672..000000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,79 +0,0 @@ -# Changelog - -**Note:** Before version 1.0.0, every release may contain breaking changes. - -## Version 0.12.0 - -* **Breaking change**: Autofuzz API methods (`consume` and `autofuzz`) have moved from the - `Jazzer` class to the dedicated `Autofuzz` class -* **Major feature**: Added JUnit 5 integration for fuzzing and regression tests using the - `@FuzzTest` annotation (available as `com.code-intelligence:jazzer-junit`) -* Feature: Added sanitizer for SQL injections -* Feature: Hooks can be selectively disabled by specifying their full class name using the new - `--disabled_hooks` flag -* Fix: Remove memory leaks in native code -* Fix: Don't instrument internal Azul JDK classes -* Fix: Classes with local variable annotations are now instrumented without errors - -This release also includes smaller improvements and bugfixes, as well as a major refactoring and -Java rewrite of native components. - -## Version 0.11.0 - -* Feature: Add sanitizer for context lookups -* Feature: Add sanitizer for OS command injection -* Feature: Add sanitizer for regex injection -* Feature: Add sanitizer for LDAP injections -* Feature: Add sanitizer for arbitrary class loading -* Feature: Guide fuzzer to generate proper map lookups keys -* Feature: Generate standalone Java reproducers for autofuzz -* Feature: Hooks targeting interfaces and abstract classes hook all implementations -* Feature: Enable multiple BEFORE and AFTER hooks for the same target -* Feature: Greatly improve performance of coverage instrumentation -* Feature: Improve performance of interactions between Jazzer and libFuzzer -* Feature: Export JaCoCo coverage dump using `--coverage_dump` flag -* Feature: Honor `JAVA_OPTS` -* API: Add `exploreState` to help the fuzzer maximize state coverage -* API: Provide `additionalClassesToHook` field in `MethodHook` annotation to hook dependent classes -* Fix: Synchronize coverage ID generation -* Fix: Support REPLACE hooks for constructors -* Fix: Do not apply REPLACE hooks in Java 6 class files - -This release also includes smaller improvements and bugfixes. - -## Version 0.10.0 - -* **Breaking change**: Use OS-specific classpath separator to split jvm_args -* Feature: Add support to "autofuzz" targets without the need to manually write fuzz targets -* Feature: Add macOS and Windows support -* Feature: Add option to generate coverage report -* Feature: Support multiple hook annotations per hook method -* Feature: Support hooking internal classes -* Feature: Add sanitizer for insecure deserialization -* Feature: Add sanitizer for arbitrary reflective calls -* Feature: Add sanitizer for expression language injection -* Feature: Provide Jazzer and Jazzer Autofuzz docker images -* Feature: Add a stand-alone replayer to reproduce findings -* API: Add `reportFindingFromHook(Throwable finding)` to report findings from hooks -* API: Add `guideTowardsEquality(String current, String target, int id)` and `guideTowardsContainment(String haystack, String needle, int id)` to guide the fuzzer to generate more useful inputs -* API: Add `consume(FuzzedDataProvider data, Class type)` to create an object instance of the given type from the fuzzer input -* API: Add multiple `autofuzz()` methods to invoke given functions with arguments automatically created from the fuzzer input -* Fixed: Prevent dependency version conflicts in fuzzed application by shading internal dependencies -* Fixed: Make initialized `this` object available to `` AFTER hooks -* Fixed: Allow instrumented classes loaded by custom class loaders to find Jazzer internals - -This release also includes smaller improvements and bugfixes. - -## Version 0.9.1 - -* **Breaking change**: The static `fuzzerTestOneInput` method in a fuzz target now has to return `void` instead of `boolean`. Fuzz targets that previously returned `true` should now throw an exception or use `assert`. -* Fixed: `jazzer` wrapper can find `jazzer_driver` even if not in the working directory -* Fixed: Switch instrumentation no longer causes an out-of-bounds read in the driver -* Feature: `assert` can be used in fuzz targets -* Feature: Coverage is now collision-free and more fine-grained (based on [JaCoCo](https://www.eclemma.org/jacoco/)) -* API: Added `pickValue(Collection c)` and `consumeChar(char min, char max)` to `FuzzedDataProvider` -* API: Added `FuzzerSecurityIssue*` exceptions to allow specifying the severity of findings - -## Version 0.9.0 - -* Initial release diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a8c76d29e..78c2cd546 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -21,11 +21,15 @@ This will speed up incremental builds and tests, especially when switching branc Since a disk cache can be shared across Bazel projects, it is recommended to enable it by creating a file called `.bazelrc` in your home directory with the following contents: ``` -common --disk_cache=$HOME/.cache/bazel-disk +common --disk_cache=/.cache/bazel-disk ``` Bazel currently doesn't remove old entries from the disk cache automatically, so you may want to do this manually from time to time (see https://github.com/bazelbuild/bazel/issues/5139#issuecomment-943534948). +```bash +find ~/.cache/bazel-disk -type f -mtime +15 -delete && find ~/.cache/bazel-disk -type f -size +500M -delete +``` + ### Building Assuming the dependencies are installed, build Jazzer from source and run it as follows: @@ -71,10 +75,40 @@ To run the tests, execute the following command: $ bazel test //... ``` +If you are bisecting a bug or otherwise want test execution to stop right after the first failure, use `--config=fail-fast`. +This is especially useful with long-running or parameterized tests. + #### Debugging +##### Internal debugging + If you need to debug an issue that can only be reproduced by an integration test (`java_fuzz_target_test`), you can start Jazzer in debug mode via `--config=debug`. -The JVM running Jazzer will suspend until a debugger connects on port 5005 (or the port specified via `DEFAULT_JVM_DEBUG_PORT`). +The JVM running Jazzer will suspend until a debugger connects on port `5005` (or the port specified via `DEFAULT_JVM_DEBUG_PORT`). + +##### External debugging + +If you need to debug an issue in an external project or application add the normal JVM debug flags to the `java` command. +A JVM started with these settings will halt on startup until a debugger is connected. + +``` +-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005 +``` + +Connect to the waiting application via your favourite IDE from within the opened Jazzer project. +In IntelliJ, you could do so by adding a new `Remote JVM Debug` run configuration and leave the settings as is. + +![Remote Debug Settings](docs/images/remote-debug.jpeg) + +##### Debug logs + +Jazzer also has a number of environment variables that enable additional debug logging when set to `1`: + +* `JAZZER_AUTOFUZZ_DEBUG`: Print stack traces and generated code while using Autofuzz. +* `JAZZER_MUTATOR_DEBUG`: Print a tree representation of attempts to construct a structured mutator. +* `JAZZER_REFLECTION_DEBUG`: Print stack traces when reflective access from sanitizers fails. +* `RULES_JNI_TRACE`: Let the native launcher emit trace level information while locating a JDK. + + ### Formatting diff --git a/LICENSE b/LICENSE index 7a4a3ea24..55cd6088c 100644 --- a/LICENSE +++ b/LICENSE @@ -1,202 +1,180 @@ +Code Intelligence Jazzer Terms and Conditions +================================== +These Code Intelligence Terms and Conditions ("**Terms**") are a legal +agreement between You and Code Intelligence (GmbH) regarding Your use of Jazzer +software and associated documentation (collectively, the +"**Software**"). By using the Software, You accept these Terms. +**Please read all of these Terms;** in many cases, provisions set +forth later in the Terms limit and qualify provisions set forth +earlier in the Terms. If You do not accept these Terms, do not +download, install, use, or copy the Software. - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. \ No newline at end of file +Definitions +----------- + +In these Terms: + + * "OSI-approved License" means an Open Source Initiative + (OSI)-approved open source software license. + + * "Open Source Codebase" means a codebase that is released under an + OSI-approved License. + + * "You" means an individual or legal entity exercising permissions granted by + this License. + + +Use Rights; Scope of License +---------------------------- + +The Software is licensed on a per user basis. Here's what You may do +with the Software, but subject to License Restrictions provisions +below: + + * Use the Software to perform academic research. + + * Use the Software to demonstrate the Software for mere testing of the + Software itself without production use. + + * Test bug detectors or sanitizers that are released under an OSI-approved + License + +Here's what You may also do with the Software, but only with an Open +Source Codebase and subject to the License Restrictions provisions +below: + + * Perform analysis on the Open Source Codebase but without automated + analysis / fuzzing, CI, or CD. + + * Perform analysis on Open Source Codebases, including automated + analysis / fuzzing, CI, or CD only through the OSS-Fuzz Infrastructure + operated by Google (https://github.com/google/oss-fuzz). + +License Restrictions +-------------------- + +These Terms do not authorize, and the Software may not be used for any +purpose not expressly set forth above, including: + + * To otherwise or in any other context, perform dynamic testing + for or during automated analysis, CI or CD, whether as part of + normal engineering processes or another context. + + * To otherwise or in any other context, use the Software in + connection with any codebase that is not an Open Source Codebase + (e.g., code in a private repo in Github/Gitlab). + +_**Please note:** if Your use of the Software is under a paid customer +license for Code Intelligence or Jazzer, the restrictions with respect to +automated analysis, CI, and CD and use in connection with non-Open +Source Codebases do not apply._ + +At all times, except (and only to the extent) permitted by applicable +law or applicable third-party license, You will not (and have no right +to): + + * work around any technical limitations in the Software that only + allow You to use it in certain ways; + + * reverse engineer, decompile or disassemble the Software if provided in + binary form only; + + * remove, minimize, block, or modify any notices of Code Intelligence + or Contributors in the Software; + + * use the Software in any way that is against the law; or + + * share, publish, distribute, rent, offer for download, or lend the Software, + provide or make available the Software as a hosted solution (whether on a + standalone basis or combined, incorporated or integrated with other software + or services) for others to use, or transfer the Software to any third party. + +Code Intelligence reserves all rights not expressly granted in these Terms. + +Open Source Software +-------------------- + +The Software may include components licensed under open source +software licenses. Any such licenses are included in the "NOTICE"-file that +is included with the Software. + + +Open source software licenses for the Software's source code constitute +separate agreements. To the limited extent that any open source +software license expressly supersedes these Terms, such open source +license governs Your use of the applicable component(s) of the +Software subject to such license. + +Code Intelligence Trademarks +----------------- + +These Terms do not grant any right or license to use any of Code Intelligence's +trademarks or logos, including, without limitation, the names Code Intelligence +and Jazzer and any Software logo designs in the "logos" folder of the +Software. You agree not to display or use any of these trademarks or +logos in any manner without Code Intelligence's prior written permission. +Code Intelligence reserves all rights, title and interest in and to all Code +Intelligence trademarks and logos. + +Additional Services +------------------- + +Auto-Updates: The Software may include dependencies with auto-update service. +If the Software automatically enables such service (or, if it is not +automatically enabled and You choose to use it), Code Intelligence will +automatically update the Software when a new version is available. + +Support +------- + +Because the Software is "as-is," Code Intelligence may not provide support for +it. + +Export Control +-------------- + +You have to comply with all applicable export and import laws and +regulations that apply to the Software. + +Disclaimer; Limitations of Liability +------------------------------------ + +THE SOFTWARE, INCLUDING ANY ADDITIONAL SERVICES, IS PROVIDED ON AN +"AS-IS" BASIS, AND Code Intelligence GIVES NO EXPRESS WARRANTIES, GUARANTEES OR +CONDITIONS. TO THE EXTENT PERMITTED BY APPLICABLE LAW, Code Intelligence +DISCLAIMS THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NON-INFRINGEMENT. YOUR USE OF THE SOFTWARE IS +AT YOUR SOLE RISK. + +TO THE EXTENT PERMITTED BY APPLICABLE LAW, YOU EXPRESSLY UNDERSTAND +AND AGREE THAT (1) YOU CAN RECOVER DIRECT DAMAGES RELATING TO THE +SOFTWARE, INCLUDING ANY ADDITIONAL SERVICES, UP TO U.S. $5.00 FROM +Code Intelligence AND ITS SUPPLIERS, AND (2) Code Intelligence WILL NOT BE +LIABLE FOR ANY INDIRECT, INCIDENTAL, SPECIAL, CONSEQUENTIAL OR EXEMPLARY +DAMAGES, INCLUDING, WITHOUT LIMITATION, ANY DAMAGES FOR LOSS OF PROFITS, +GOODWILL, USE, OR DATA OR OTHER INTANGIBLE LOSSES (EVEN IF Code Intelligence HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES) RELATING TO THE +SOFTWARE, INCLUDING ANY ADDITIONAL SERVICES. + +Miscellaneous +------------- + +_No Waiver._ The failure of Code Intelligence to exercise or enforce any right +or provision of these Terms will not constitute a waiver of such right or +provision. + +_Entire Agreement._ These Terms, together with any open source +software licenses referenced above, constitutes the entire agreement +between You and Code Intelligence regarding Your use of the Software. + +_Governing Law._ You agree that these Terms and Your use of the +Software are governed by the laws of Germany and any +dispute relating to the Software or Your use thereof must be brought +in a court of competent jurisdiction located in Köln / Cologne. + +_Modifications._ These Terms may only be modified by a written +amendment signed by an authorized representative of Code Intelligence, or by the +acceptance of a revised version published by Code Intelligence. + +_Contact Us._ Questions about these Terms or want to purchase a commercial +license? Contact us at https://www.code-intelligence.com/contact. diff --git a/LICENSE-JAZZER.txt b/LICENSE-JAZZER.txt new file mode 120000 index 000000000..7a694c969 --- /dev/null +++ b/LICENSE-JAZZER.txt @@ -0,0 +1 @@ +LICENSE \ No newline at end of file diff --git a/MODULE.bazel b/MODULE.bazel new file mode 100644 index 000000000..2bd6ee89e --- /dev/null +++ b/MODULE.bazel @@ -0,0 +1,419 @@ +module(name = "jazzer") + +################################################################################ +# Bazel module dependencies +# See https://registry.bazel.build for all available modules. +# Kept up-to-date by Renovate +################################################################################ + +bazel_dep(name = "abseil-cpp", version = "20230802.0.bcr.1") +bazel_dep(name = "apple_support", version = "1.11.1") +bazel_dep(name = "bazel_jar_jar", version = "0.1.0") +bazel_dep(name = "bazel_skylib", version = "1.7.1") +bazel_dep(name = "buildifier_prebuilt", version = "6.4.0") +bazel_dep(name = "contrib_rules_jvm", version = "0.24.0") +bazel_dep(name = "googletest", version = "1.14.0.bcr.1") +bazel_dep(name = "platforms", version = "0.0.10") +bazel_dep(name = "protobuf") +bazel_dep(name = "rules_android", version = "0.1.1") +bazel_dep(name = "rules_android_ndk", version = "0.1.2") +bazel_dep(name = "rules_foreign_cc", version = "0.11.1") +bazel_dep(name = "rules_java", version = "7.7.0") +bazel_dep(name = "rules_jni", version = "0.9.1") +bazel_dep(name = "rules_jvm_external", version = "6.2") +bazel_dep(name = "rules_kotlin", version = "1.9.5") +bazel_dep(name = "rules_license", version = "0.0.8") +bazel_dep(name = "rules_pkg", version = "0.9.1") +bazel_dep(name = "toolchains_llvm", version = "0.10.3") + +# TODO: Remove after a release that includes https://github.com/protocolbuffers/protobuf/commit/a7b0421c78412baa48704d727601a17ac0f451d1. +single_version_override( + module_name = "protobuf", + patch_strip = 1, + patches = [ + # https://github.com/protocolbuffers/protobuf/pull/15332 + "//third_party:protobuf-disable-layering_check.patch", + ], + version = "23.1", +) + +################################################################################ +# Maven dependencies +################################################################################ + +# Runtime dependencies of Jazzer that are shaded to prevent classpath pollution. +# Keep these versions up-to-date (automated by Renovate). +SHADED_RUNTIME_MAVEN_ARTIFACTS = [ + # keep sorted + # renovate: keep updated + "com.github.jsqlparser:jsqlparser:4.9", + "com.google.errorprone:error_prone_annotations:2.26.1", + "com.google.errorprone:error_prone_type_annotations:2.26.1", + "io.github.classgraph:classgraph:jar:4.8.170", + "net.bytebuddy:byte-buddy-agent:1.14.13", + "net.jodah:typetools:jar:0.6.3", + "org.ow2.asm:asm:9.7", + "org.ow2.asm:asm-commons:9.7", + "org.ow2.asm:asm-tree:9.7", +] + +# Runtime dependencies of Jazzer that are expected to be provided by the fuzzed project. +# Keep these versions as low as possible for maximum compatibility with user setups. +PROVIDED_RUNTIME_MAVEN_ARTIFACTS = [ + # keep sorted + "org.junit.jupiter:junit-jupiter-api:5.9.0", + "org.junit.jupiter:junit-jupiter-engine:5.9.0", + "org.junit.jupiter:junit-jupiter-params:5.9.0", + "org.junit.platform:junit-platform-commons:1.9.0", + "org.junit.platform:junit-platform-engine:1.9.0", + "org.junit.platform:junit-platform-launcher:1.9.0", + "org.opentest4j:opentest4j:1.2.0", +] + +# Runtime dependencies of Jazzer that should not be included in the generated pom. +# Keep these versions as low as possible for maximum compatibility with user setups. +HIDDEN_RUNTIME_MAVEN_ARTIFACTS = [ + # keep sorted + "jakarta.servlet:jakarta.servlet-api:6.0.0", + "org.springframework:spring-test:6.1.4", + "org.springframework:spring-web:6.1.4", + "org.springframework:spring-webmvc:6.1.4", +] + +# Dependencies used to support Jazzer's own tests. +# Keep these versions in sync with the ones in PROVIDED_RUNTIME_MAVEN_ARTIFACTS, +# as Bazel would use "Minimal Version Selection" and choose a different version +# than the ones defined above. +TEST_MAVEN_ARTIFACTS_FIXED = [ + "org.junit.platform:junit-platform-reporting:1.9.0", + "org.junit.platform:junit-platform-testkit:1.9.0", +] + +# Dependencies used to support Jazzer's own tests. +# Keep these versions up-to-date (automated by Renovate). +TEST_MAVEN_ARTIFACTS = [ + # keep sorted + # renovate: keep updated + "com.google.truth.extensions:truth-java8-extension:1.4.2", + "com.google.truth.extensions:truth-liteproto-extension:1.4.2", + "com.google.truth.extensions:truth-proto-extension:1.4.2", + "com.google.truth:truth:1.4.2", + "junit:junit:4.13.2", + "org.assertj:assertj-core:3.25.3", + "org.jacoco:org.jacoco.core:0.8.12", + "org.mockito:mockito-core:5.11.0", + "org.openjdk.jmh:jmh-core:1.37", + "org.openjdk.jmh:jmh-generator-annprocess:1.37", +] + +# **WARNING**: These Maven dependencies may have known vulnerabilities that Jazzer is supposed to +# find and are only used in tests. DO NOT USE. +# Do not update these deps as doing so may fix the vulnerability that Jazzer is supposed to detect. +VULNERABLE_TEST_MAVEN_ARTIFACTS = [ + # keep sorted + "com.alibaba:fastjson:1.2.75", + "com.beust:klaxon:5.5", + "com.fasterxml.jackson.core:jackson-core:2.12.1", + "com.fasterxml.jackson.core:jackson-databind:2.12.1", + "com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:2.12.1", + "com.google.code.gson:gson:2.8.6", + "com.h2database:h2:2.1.212", + "com.mikesamuel:json-sanitizer:1.2.1", + "com.unboundid:unboundid-ldapsdk:6.0.3", + "javax.el:javax.el-api:3.0.1-b06", + "javax.validation:validation-api:2.0.1.Final", + "javax.xml.bind:jaxb-api:2.3.1", + "org.apache.commons:commons-imaging:1.0-alpha2", + "org.apache.commons:commons-text:1.9", + "org.apache.logging.log4j:log4j-api:2.14.1", + "org.apache.logging.log4j:log4j-core:2.14.1", + "org.apache.xmlgraphics:batik-anim:1.14", + "org.apache.xmlgraphics:batik-awt-util:1.14", + "org.apache.xmlgraphics:batik-bridge:1.14", + "org.apache.xmlgraphics:batik-css:1.14", + "org.apache.xmlgraphics:batik-dom:1.14", + "org.apache.xmlgraphics:batik-gvt:1.14", + "org.apache.xmlgraphics:batik-parser:1.14", + "org.apache.xmlgraphics:batik-script:1.14", + "org.apache.xmlgraphics:batik-svg-dom:1.14", + "org.apache.xmlgraphics:batik-svggen:1.14", + "org.apache.xmlgraphics:batik-transcoder:1.14", + "org.apache.xmlgraphics:batik-util:1.14", + "org.apache.xmlgraphics:batik-xml:1.14", + "org.glassfish:javax.el:3.0.1-b06", + "org.hibernate:hibernate-validator:5.2.4.Final", +] + +maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven") +maven.override( + coordinates = "org.jetbrains.kotlin:kotlin-reflect", + target = "@rules_kotlin//kotlin/compiler:kotlin-reflect", +) +maven.override( + coordinates = "org.jetbrains.kotlin:kotlin-stdlib", + target = "@rules_kotlin//kotlin/compiler:kotlin-stdlib", +) +maven.override( + coordinates = "com.google.protobuf:protobuf-java", + target = "@protobuf//java/core", +) + +[ + maven.artifact( + testonly = True, + artifact = coordinate.split(":")[1], + group = coordinate.split(":")[0], + version = coordinate.split(":")[2], + ) + for coordinate in TEST_MAVEN_ARTIFACTS + TEST_MAVEN_ARTIFACTS_FIXED + VULNERABLE_TEST_MAVEN_ARTIFACTS +] + +[ + maven.artifact( + artifact = coordinate.split(":")[1], + group = coordinate.split(":")[0], + neverlink = True, + version = coordinate.split(":")[2], + ) + for coordinate in HIDDEN_RUNTIME_MAVEN_ARTIFACTS +] + +maven.install( + artifacts = SHADED_RUNTIME_MAVEN_ARTIFACTS + PROVIDED_RUNTIME_MAVEN_ARTIFACTS, + fail_if_repin_required = True, + lock_file = "//:maven_install.json", + repositories = ["https://repo1.maven.org/maven2"], + strict_visibility = True, +) +use_repo(maven, "maven") + +################################################################################ +# Other dependencies that aren't Bazel-aware +################################################################################ + +http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +http_file = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file") + +http_jar = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_jar") + +git_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") + +http_archive( + name = "jazzer_jacoco", + build_file = "//third_party:jacoco_internal.BUILD", + patches = [ + "//third_party:jacoco-make-probe-adapter-subclassable.patch", + "//third_party:jacoco-make-probe-inserter-subclassable.patch", + "//third_party:jacoco-ignore-offline-instrumentation.patch", + ], + sha256 = "5c72dea2d13eef33a4d972d157186fc12d85149bc042186953efe1be50c220ee", + strip_prefix = "jacoco-0.8.10", + url = "https://github.com/jacoco/jacoco/archive/refs/tags/v0.8.10.tar.gz", +) + +http_archive( + name = "jazzer_libfuzzer", + build_file = "//third_party:libFuzzer.BUILD", + sha256 = "200b32c897b1171824462706f577d7f1d6175da602eccfe570d2dceeac11d490", + strip_prefix = "llvm-project-jazzer-2023-04-25/compiler-rt/lib/fuzzer", + url = "https://github.com/CodeIntelligenceTesting/llvm-project-jazzer/archive/refs/tags/2023-04-25.tar.gz", +) + +git_repository( + name = "jazzer_slicer", + build_file = "//third_party:slicer.BUILD", + commit = "0fe35538da107ff48da6e9f9b92b55b014973bf8", + remote = "https://android.googlesource.com/platform/tools/dexter", +) + +http_file( + name = "android_jvmti", + downloaded_file_path = "jvmti.encoded", + sha256 = "95bd6fb4f296ff1c49b893c1d3a665de3c2b1beaa3cc8fc570dea992202daa35", + url = "https://android.googlesource.com/platform/art/+/1cff8449bac0fdab6e84dc9255c3cccd504c1705/openjdkjvmti/include/jvmti.h?format=TEXT", +) + +http_archive( + name = "org_chromium_sysroot_linux_x64", + build_file_content = """ +filegroup( + name = "sysroot", + srcs = glob(["*/**"]), + visibility = ["//visibility:public"], +) +""", + sha256 = "84656a6df544ecef62169cfe3ab6e41bb4346a62d3ba2a045dc5a0a2ecea94a3", + urls = ["https://commondatastorage.googleapis.com/chrome-linux-sysroot/toolchain/2202c161310ffde63729f29d27fe7bb24a0bc540/debian_stretch_amd64_sysroot.tar.xz"], +) + +http_file( + name = "genhtml", + downloaded_file_path = "genhtml", + executable = True, + sha256 = "4120cc9186a0687db218520a2d0dc9bae75d15faf41d87448b6b6c5140c19156", + urls = ["https://raw.githubusercontent.com/linux-test-project/lcov/6da8399c7a7a3370de2c69b16b092e945442ffcd/bin/genhtml"], +) + +http_file( + name = "jacocoagent", + downloaded_file_path = "jacocoagent.jar", + sha256 = "40d25997de4c625769bf5d1283eb855b87c9caef4ca1fa03b8ef0b752ba4b54a", + urls = ["https://repo1.maven.org/maven2/org/jacoco/org.jacoco.agent/0.8.10/org.jacoco.agent-0.8.10-runtime.jar"], +) + +http_file( + name = "jacococli", + downloaded_file_path = "jacococli.jar", + sha256 = "c821fe4f59dc5c1bb29341a259b6c9e49d6425f200f4ac0e373bf46bbfa54cf2", + urls = ["https://repo1.maven.org/maven2/org/jacoco/org.jacoco.cli/0.8.10/org.jacoco.cli-0.8.10-nodeps.jar"], +) + +http_jar( + name = "clojure_jar", + sha256 = "2381b6e9423ab465151455944903d13a56243d6006b9194afc1bf4f8710cb4de", + url = "https://repo1.maven.org/maven2/org/clojure/clojure/1.11.1/clojure-1.11.1.jar", +) + +http_jar( + name = "clojure_spec_alpha_jar", + sha256 = "67ec898eb55c66a957a55279dd85d1376bb994bd87668b2b0de1eb3b97e8aae0", + url = "https://repo1.maven.org/maven2/org/clojure/spec.alpha/0.3.218/spec.alpha-0.3.218.jar", +) + +http_jar( + name = "clojure_core_specs_alpha_jar", + sha256 = "06eea8c070bbe45c158567e443439681bc8c46e9123414f81bfa32ba42d6cbc8", + url = "https://repo1.maven.org/maven2/org/clojure/core.specs.alpha/0.2.62/core.specs.alpha-0.2.62.jar", +) + +http_jar( + name = "google-java-format", + sha256 = "1e69f8b63c39a5124a8efb7bad213eb9ac03944339eb9580ae210b0c60565d9b", + urls = [ + "https://github.com/google/google-java-format/releases/download/v1.21.0/google-java-format-1.21.0-all-deps.jar", + ], +) + +http_file( + name = "clang-format-15-darwin-x64", + downloaded_file_path = "clang-format", + executable = True, + sha256 = "97116f64d97fb2870b4aa29758bba8fb0fe7f3b1ed8a4bc12faa927ecfdec196", + urls = [ + "https://github.com/angular/clang-format/raw/master/bin/darwin_x64/clang-format", + ], +) + +http_file( + name = "clang-format-15-linux-x64", + downloaded_file_path = "clang-format", + executable = True, + sha256 = "050c600256e225eabe9608d28f492fe8673c6e7f5deac59c6da973223c764d6c", + urls = [ + "https://github.com/angular/clang-format/raw/master/bin/linux_x64/clang-format", + ], +) + +http_file( + name = "addlicense-darwin-universal", + downloaded_file_path = "addlicense", + executable = True, + sha256 = "9c08964e15d6ed0568c4e8a5f861bcc2122498419586fbe87e08add56d18762d", + urls = [ + "https://github.com/CodeIntelligenceTesting/addlicense/releases/download/v1.1.1/addlicense-darwin-universal", + ], +) + +http_file( + name = "addlicense-linux-amd64", + downloaded_file_path = "addlicense", + executable = True, + sha256 = "521e680ff085f511d760aa139a0e869238ab4c936e89d258ac3432147d9e8be9", + urls = [ + "https://github.com/CodeIntelligenceTesting/addlicense/releases/download/v1.1.1/addlicense-linux-amd64", + ], +) + +http_archive( + name = "libjpeg_turbo", + build_file = "//third_party:libjpeg_turbo.BUILD", + sha256 = "6a965adb02ad898b2ae48214244618fe342baea79db97157fdc70d8844ac6f09", + strip_prefix = "libjpeg-turbo-2.0.90", + url = "https://github.com/libjpeg-turbo/libjpeg-turbo/archive/refs/tags/2.0.90.tar.gz", +) + +http_archive( + name = "libprotobuf-mutator", + build_file_content = """ +cc_library( + name = "libprotobuf-mutator", + srcs = glob([ + "src/*.cc", + "src/*.h", + "src/libfuzzer/*.cc", + "src/libfuzzer/*.h", + "port/protobuf.h", + ], exclude = [ + "**/*_test.cc", + ]), + hdrs = ["src/libfuzzer/libfuzzer_macro.h"], + deps = ["@protobuf"], + visibility = ["//visibility:public"], +) +""", + sha256 = "21bfdfef25554fa2e30aec2a9f9b58f4a17c1d8c8593763fa94a6dd74b226594", + strip_prefix = "libprotobuf-mutator-3b28530531b154a748fe9884bc9219b4966f0754", + urls = ["https://github.com/google/libprotobuf-mutator/archive/3b28530531b154a748fe9884bc9219b4966f0754.tar.gz"], +) + +################################################################################ +# Toolchain repos and registrations +################################################################################ + +# rules_java doesn't ship remote JDK 8s anymore. +remote_jdk8_repos = use_extension("//third_party:jdk_8.bzl", "remote_jdk8_repos") + +REMOTE_JDK8 = [ + "remote_jdk8_linux", + "remote_jdk8_macos", + "remote_jdk8_macos_aarch64", + "remote_jdk8_windows", +] + +[ + use_repo(remote_jdk8_repos, "{}_toolchain_config_repo".format(jdk)) + for jdk in REMOTE_JDK8 +] + +[ + register_toolchains("@{}_toolchain_config_repo//:all".format(jdk)) + for jdk in REMOTE_JDK8 +] + +register_toolchains("//bazel/toolchains:kotlin_toolchain") + +# Used in CI. +llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm") +llvm.toolchain( + llvm_version = "15.0.6", + sysroot = { + # The extension doesn't handle labels to external repositories correctly: It does not map + # apparent names such as @org_chromium_sysroot_linux_x64 to the correct Bazel-internal + # canonical repository name. As a workaround, specify the canonical name directly. + # TODO: Get rid on this dependency of Bazel implementation details when toolchains_llvm + # offers an attribute of type label rather than string. + # https://github.com/grailbio/bazel-toolchain/issues/234 + # https://github.com/grailbio/bazel-toolchain/pull/235 + "linux-x86_64": "@@_main~_repo_rules~org_chromium_sysroot_linux_x64//:sysroot", + }, +) +use_repo(llvm, "llvm_toolchain") + +# Required by the reference to the Windows toolchain in @local_config_cc from .bazelrc. +cc_configure = use_extension("@bazel_tools//tools/cpp:cc_configure.bzl", "cc_configure_extension") +use_repo(cc_configure, "local_config_cc") + +# Referenced in BUILD files. +java_toolchains = use_extension("@rules_java//java:extensions.bzl", "toolchains") +use_repo(java_toolchains, "local_jdk") diff --git a/README.md b/README.md index 824b9ebc5..51d32825c 100644 --- a/README.md +++ b/README.md @@ -15,9 +15,6 @@ License - - PRs welcome -
@@ -28,21 +25,6 @@ Twitter -> [!IMPORTANT] -> Hello Jazzer/Jazzer.js users! -> -> We stopped maintaining Jazzer/Jazzer.js as open source. -> But we'd be happy to try and understand what you're trying to achieve with it, and help you if we can! -> -> We already added significant new value to our CI Fuzz solution, which includes Jazzer and Jazzer.js. -> Learn more on how to turbocharge your Java Fuzz Testing with [Jazzer Pro](https://www.code-intelligence.com/introducing-jazzer-pro). -> -> Visit [code-intelligence.com](https://code-intelligence.com) for more information, or get in contact with us via [sales@code-intelligence.com](mailto:sales@code-intelligence.com). -> -> Thanks, -> -> The Code Intelligence team - Jazzer is a coverage-guided, in-process fuzzer for the JVM platform developed by [Code Intelligence](https://code-intelligence.com). It is based on [libFuzzer](https://llvm.org/docs/LibFuzzer.html) and brings many of its instrumentation-powered mutation features to the JVM. @@ -51,22 +33,6 @@ Jazzer currently supports the following platforms: * macOS 12+ x86_64 & arm64 * Windows x86_64 -## Quick start - -You can use Docker to try out Jazzer's Autofuzz mode, in which it automatically generates arguments to a given Java function and reports unexpected exceptions and detected security issues: - -``` -docker run -it cifuzz/jazzer-autofuzz \ - com.mikesamuel:json-sanitizer:1.2.0 \ - com.google.json.JsonSanitizer::sanitize \ - --autofuzz_ignore=java.lang.ArrayIndexOutOfBoundsException -``` - -Here, the first two arguments are the Maven coordinates of the Java library and the fully qualified name of the Java function to be fuzzed in "method reference" form. -The optional `--autofuzz_ignore` flag takes a list of uncaught exception classes to ignore. - -After a few seconds, Jazzer should trigger an `AssertionError`, reproducing a bug it found in this library that has since been fixed. - ## Using Jazzer via... ### JUnit 5 @@ -120,17 +86,6 @@ If you see an error saying that `libjvm.so` has not been found, make sure that ` The [`examples`](examples/src/main/java/com/example) directory includes both toy and real-world examples of fuzz tests. -### Docker - -The "distroless" Docker image [cifuzz/jazzer](https://hub.docker.com/r/cifuzz/jazzer) includes a recent Jazzer release together with OpenJDK 17. -Mount a directory containing your compiled fuzz target into the container under `/fuzzing` and use it like a GitHub release binary by running: - -```sh -docker run -v path/containing/the/application:/fuzzing cifuzz/jazzer --cp= --target_class= -``` - -If Jazzer produces a finding, the input that triggered it will be available in the same directory. - ### Bazel Support for Jazzer is available in [rules_fuzzing](https://github.com/bazelbuild/rules_fuzzing), the official Bazel rules for fuzzing. @@ -138,9 +93,12 @@ See [the README](https://github.com/bazelbuild/rules_fuzzing#java-fuzzing) for i ### OSS-Fuzz -[Code Intelligence](https://code-intelligence.com) and Google have teamed up to bring support for Java, Kotlin, and other JVM-based languages to [OSS-Fuzz](https://github.com/google/oss-fuzz), Google's project for large-scale fuzzing of open-souce software. +[Code Intelligence](https://code-intelligence.com) and Google have teamed up to bring support for Java, Kotlin, and other JVM-based languages to [OSS-Fuzz](https://github.com/google/oss-fuzz), Google's project for large-scale fuzzing of open-source software. Read [the OSS-Fuzz guide](https://google.github.io/oss-fuzz/getting-started/new-project-guide/jvm-lang/) to learn how to set up a Java project. +**Note**: projects accepted in OSS-Fuzz can use Jazzer for free and benefit from the OSS-Fuzz infrastructure and +licensing for automated analysis and continuous integration. + ## Building from source Information on building and testing Jazzer for development can be found in [CONTRIBUTING.md](CONTRIBUTING.md) @@ -155,6 +113,17 @@ Information on building and testing Jazzer for development can be found in [CONT A list of security issues and bugs found by Jazzer is maintained [here](docs/findings.md). If you found something interesting and the information is public, please send a PR to add it to the list. +## License +By using Jazzer, you agree to the Code Intelligence [Terms & Conditions](LICENSE). + +Jazzer can only be used for code bases that are released under an OSI-approved open source license, +or to perform academic research. It cannot be used to fuzz projects for or during automated analysis, +continuous integration or continuous delivery, whether as part of normal software engineering processes or otherwise. +For these use cases, get in contact with us via [sales@code-intelligence.com](mailto:sales@code-intelligence.com). + +You can find the latest version released under the Apache 2 license [here](https://github.com/CodeIntelligenceTesting/jazzer/tree/d2cbfdcfc5363593f36cd972b849cc3ab070c90a). + + ## Credit The following developers have contributed to Jazzer before its public release: diff --git a/REPO.bazel b/REPO.bazel new file mode 100644 index 000000000..dba66ecb9 --- /dev/null +++ b/REPO.bazel @@ -0,0 +1,3 @@ +# Applies to all packages in the Jazzer main repository, but not to external repositories. +# Override on a per-package basis via `package(default_applicable_licenses = [...])` if necessary. +repo(default_applicable_licenses = ["//:license"]) diff --git a/WORKSPACE.bazel b/WORKSPACE.bazel index d3771dd11..975acaab3 100644 --- a/WORKSPACE.bazel +++ b/WORKSPACE.bazel @@ -1,324 +1 @@ -workspace(name = "jazzer") - -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file", "http_jar") -load("//:repositories.bzl", "jazzer_dependencies") - -jazzer_dependencies(android = True) - -load("//:init.bzl", "jazzer_init") - -jazzer_init() - -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") - -http_archive( - name = "rules_java", - sha256 = "7b0d9ba216c821ee8697dedc0f9d0a705959ace462a3885fe9ba0347ba950111", - urls = [ - "https://github.com/bazelbuild/rules_java/releases/download/6.5.1/rules_java-6.5.1.tar.gz", - ], -) - -load("@rules_java//java:repositories.bzl", "rules_java_dependencies", "rules_java_toolchains") - -rules_java_dependencies() - -rules_java_toolchains() - -http_archive( - name = "com_google_protobuf", - patches = ["//third_party:protobuf-disable-layering_check.patch"], - sha256 = "616bb3536ac1fff3fb1a141450fa28b875e985712170ea7f1bfe5e5fc41e2cd8", - strip_prefix = "protobuf-24.4", - # Keep in sync with com_google_protobuf_protobuf_java in repositories.bzl. - urls = ["https://github.com/protocolbuffers/protobuf/releases/download/v24.4/protobuf-24.4.tar.gz"], -) - -http_archive( - name = "org_chromium_sysroot_linux_x64", - build_file_content = """ -filegroup( - name = "sysroot", - srcs = glob(["*/**"]), - visibility = ["//visibility:public"], -) -""", - sha256 = "84656a6df544ecef62169cfe3ab6e41bb4346a62d3ba2a045dc5a0a2ecea94a3", - urls = ["https://commondatastorage.googleapis.com/chrome-linux-sysroot/toolchain/2202c161310ffde63729f29d27fe7bb24a0bc540/debian_stretch_amd64_sysroot.tar.xz"], -) - -http_archive( - name = "toolchains_llvm", - canonical_id = "0.10.3", - sha256 = "b7cd301ef7b0ece28d20d3e778697a5e3b81828393150bed04838c0c52963a01", - strip_prefix = "toolchains_llvm-0.10.3", - url = "https://github.com/bazel-contrib/toolchains_llvm/releases/download/0.10.3/toolchains_llvm-0.10.3.tar.gz", -) - -http_archive( - name = "googletest", - sha256 = "81964fe578e9bd7c94dfdb09c8e4d6e6759e19967e397dbea48d1c10e45d0df2", - strip_prefix = "googletest-release-1.12.1", - url = "https://github.com/google/googletest/archive/refs/tags/release-1.12.1.tar.gz", -) - -http_archive( - name = "rules_foreign_cc", - sha256 = "6041f1374ff32ba711564374ad8e007aef77f71561a7ce784123b9b4b88614fc", - strip_prefix = "rules_foreign_cc-0.8.0", - url = "https://github.com/bazelbuild/rules_foreign_cc/archive/refs/tags/0.8.0.tar.gz", -) - -http_archive( - name = "libjpeg_turbo", - build_file = "//third_party:libjpeg_turbo.BUILD", - sha256 = "6a965adb02ad898b2ae48214244618fe342baea79db97157fdc70d8844ac6f09", - strip_prefix = "libjpeg-turbo-2.0.90", - url = "https://github.com/libjpeg-turbo/libjpeg-turbo/archive/refs/tags/2.0.90.tar.gz", -) - -http_archive( - name = "rules_pkg", - sha256 = "8a298e832762eda1830597d64fe7db58178aa84cd5926d76d5b744d6558941c2", - urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/rules_pkg/releases/download/0.7.0/rules_pkg-0.7.0.tar.gz", - "https://github.com/bazelbuild/rules_pkg/releases/download/0.7.0/rules_pkg-0.7.0.tar.gz", - ], -) - -http_archive( - name = "contrib_rules_jvm", - sha256 = "4d62589dc6a55e74bbe33930b826d593367fc777449a410604b2ad7c6c625ef7", - strip_prefix = "rules_jvm-0.19.0", - url = "https://github.com/bazel-contrib/rules_jvm/releases/download/v0.19.0/rules_jvm-v0.19.0.tar.gz", -) - -http_archive( - name = "build_bazel_rules_android", - sha256 = "cd06d15dd8bb59926e4d65f9003bfc20f9da4b2519985c27e190cddc8b7a7806", - strip_prefix = "rules_android-0.1.1", - urls = ["https://github.com/bazelbuild/rules_android/archive/v0.1.1.zip"], -) - -http_archive( - name = "rules_android_ndk", - sha256 = "73eac2cf5f2fd009e8fb197346a2ca39f320b786985658de63a1dff0f12c53d5", - strip_prefix = "rules_android_ndk-72ca32741f27c3de69fdcb7a1aaf3ca59919ad8c", - url = "https://github.com/bazelbuild/rules_android_ndk/archive/72ca32741f27c3de69fdcb7a1aaf3ca59919ad8c.zip", -) - -http_file( - name = "genhtml", - downloaded_file_path = "genhtml", - executable = True, - sha256 = "4120cc9186a0687db218520a2d0dc9bae75d15faf41d87448b6b6c5140c19156", - urls = ["https://raw.githubusercontent.com/linux-test-project/lcov/6da8399c7a7a3370de2c69b16b092e945442ffcd/bin/genhtml"], -) - -http_file( - name = "jacocoagent", - downloaded_file_path = "jacocoagent.jar", - sha256 = "40d25997de4c625769bf5d1283eb855b87c9caef4ca1fa03b8ef0b752ba4b54a", - urls = ["https://repo1.maven.org/maven2/org/jacoco/org.jacoco.agent/0.8.10/org.jacoco.agent-0.8.10-runtime.jar"], -) - -http_file( - name = "jacococli", - downloaded_file_path = "jacococli.jar", - sha256 = "c821fe4f59dc5c1bb29341a259b6c9e49d6425f200f4ac0e373bf46bbfa54cf2", - urls = ["https://repo1.maven.org/maven2/org/jacoco/org.jacoco.cli/0.8.10/org.jacoco.cli-0.8.10-nodeps.jar"], -) - -http_jar( - name = "clojure_jar", - sha256 = "2381b6e9423ab465151455944903d13a56243d6006b9194afc1bf4f8710cb4de", - url = "https://repo1.maven.org/maven2/org/clojure/clojure/1.11.1/clojure-1.11.1.jar", -) - -http_jar( - name = "clojure_spec_alpha_jar", - sha256 = "67ec898eb55c66a957a55279dd85d1376bb994bd87668b2b0de1eb3b97e8aae0", - url = "https://repo1.maven.org/maven2/org/clojure/spec.alpha/0.3.218/spec.alpha-0.3.218.jar", -) - -http_jar( - name = "clojure_core_specs_alpha_jar", - sha256 = "06eea8c070bbe45c158567e443439681bc8c46e9123414f81bfa32ba42d6cbc8", - url = "https://repo1.maven.org/maven2/org/clojure/core.specs.alpha/0.2.62/core.specs.alpha-0.2.62.jar", -) - -load("@contrib_rules_jvm//:repositories.bzl", "contrib_rules_jvm_deps") - -contrib_rules_jvm_deps() - -load("@contrib_rules_jvm//:setup.bzl", "contrib_rules_jvm_setup") - -contrib_rules_jvm_setup() - -load("@toolchains_llvm//toolchain:deps.bzl", "bazel_toolchain_dependencies") - -bazel_toolchain_dependencies() - -load("@toolchains_llvm//toolchain:rules.bzl", "llvm_toolchain") - -llvm_toolchain( - name = "llvm_toolchain", - llvm_version = "15.0.6", - sysroot = { - "linux-x86_64": "@org_chromium_sysroot_linux_x64//:sysroot", - }, -) - -load("@llvm_toolchain//:toolchains.bzl", "llvm_register_toolchains") - -llvm_register_toolchains() - -load("@rules_jvm_external//:repositories.bzl", "rules_jvm_external_deps") - -rules_jvm_external_deps() - -load("@rules_jvm_external//:setup.bzl", "rules_jvm_external_setup") - -rules_jvm_external_setup() - -load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies") - -rules_foreign_cc_dependencies() - -load("@rules_jvm_external//:defs.bzl", "maven_install") -load("//:maven.bzl", "MAVEN_ARTIFACTS", "TEST_MAVEN_ARTIFACTS") - -maven_install( - artifacts = MAVEN_ARTIFACTS + TEST_MAVEN_ARTIFACTS, - fail_if_repin_required = True, - maven_install_json = "//:maven_install.json", - override_targets = { - "org.jetbrains.kotlin:kotlin-reflect": "@com_github_jetbrains_kotlin//:kotlin-reflect", - "org.jetbrains.kotlin:kotlin-stdlib": "@com_github_jetbrains_kotlin//:kotlin-stdlib", - "com.google.errorprone:error_prone_annotations": "@com_google_errorprone_error_prone_annotations//jar", - }, - repositories = [ - "https://repo1.maven.org/maven2", - ], - strict_visibility = True, -) - -load("@maven//:defs.bzl", "pinned_maven_install") - -pinned_maven_install() - -load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies") - -rules_pkg_dependencies() - -load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") - -protobuf_deps() - -load("//third_party/android:android_configure.bzl", "android_configure") - -android_configure(name = "configure_android_rules") - -load("@configure_android_rules//:android_configure.bzl", "android_workspace") - -android_workspace() - -http_archive( - name = "buildifier_prebuilt", - sha256 = "7015c623143084bbdb3d2bb955087deb7cbb8e4806df457f3340d64b6eda876e", - strip_prefix = "buildifier-prebuilt-5b6adef925e98f90305d69de6d7ad70dd512c4ee", - urls = [ - "https://github.com/keith/buildifier-prebuilt/archive/5b6adef925e98f90305d69de6d7ad70dd512c4ee.tar.gz", - ], -) - -load("@buildifier_prebuilt//:deps.bzl", "buildifier_prebuilt_deps") - -buildifier_prebuilt_deps() - -load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") - -bazel_skylib_workspace() - -load("@buildifier_prebuilt//:defs.bzl", "buildifier_prebuilt_register_toolchains") - -buildifier_prebuilt_register_toolchains() - -http_jar( - name = "google-java-format", - sha256 = "33068bbbdce1099982ec1171f5e202898eb35f2919cf486141e439fc6e3a4203", - urls = [ - "https://github.com/google/google-java-format/releases/download/v1.17.0/google-java-format-1.17.0-all-deps.jar", - ], -) - -http_file( - name = "clang-format-15-darwin-x64", - downloaded_file_path = "clang-format", - executable = True, - sha256 = "97116f64d97fb2870b4aa29758bba8fb0fe7f3b1ed8a4bc12faa927ecfdec196", - urls = [ - "https://github.com/angular/clang-format/raw/master/bin/darwin_x64/clang-format", - ], -) - -http_file( - name = "clang-format-15-linux-x64", - downloaded_file_path = "clang-format", - executable = True, - sha256 = "050c600256e225eabe9608d28f492fe8673c6e7f5deac59c6da973223c764d6c", - urls = [ - "https://github.com/angular/clang-format/raw/master/bin/linux_x64/clang-format", - ], -) - -http_file( - name = "addlicense-darwin-universal", - downloaded_file_path = "addlicense", - executable = True, - sha256 = "9c08964e15d6ed0568c4e8a5f861bcc2122498419586fbe87e08add56d18762d", - urls = [ - "https://github.com/CodeIntelligenceTesting/addlicense/releases/download/v1.1.1/addlicense-darwin-universal", - ], -) - -http_file( - name = "addlicense-linux-amd64", - downloaded_file_path = "addlicense", - executable = True, - sha256 = "521e680ff085f511d760aa139a0e869238ab4c936e89d258ac3432147d9e8be9", - urls = [ - "https://github.com/CodeIntelligenceTesting/addlicense/releases/download/v1.1.1/addlicense-linux-amd64", - ], -) - -http_archive( - name = "libprotobuf-mutator", - build_file_content = """ -cc_library( - name = "libprotobuf-mutator", - srcs = glob([ - "src/*.cc", - "src/*.h", - "src/libfuzzer/*.cc", - "src/libfuzzer/*.h", - "port/protobuf.h", - ], exclude = [ - "**/*_test.cc", - ]), - hdrs = ["src/libfuzzer/libfuzzer_macro.h"], - deps = ["@com_google_protobuf//:protobuf"], - visibility = ["//visibility:public"], -) -""", - sha256 = "21bfdfef25554fa2e30aec2a9f9b58f4a17c1d8c8593763fa94a6dd74b226594", - strip_prefix = "libprotobuf-mutator-3b28530531b154a748fe9884bc9219b4966f0754", - urls = ["https://github.com/google/libprotobuf-mutator/archive/3b28530531b154a748fe9884bc9219b4966f0754.tar.gz"], -) - -http_file( - name = "android_jvmti", - downloaded_file_path = "jvmti.encoded", - sha256 = "95bd6fb4f296ff1c49b893c1d3a665de3c2b1beaa3cc8fc570dea992202daa35", - url = "https://android.googlesource.com/platform/art/+/1cff8449bac0fdab6e84dc9255c3cccd504c1705/openjdkjvmti/include/jvmti.h?format=TEXT", -) +# This file only exists for tooling that may not yet support WORKSPACE.bzlmod. diff --git a/WORKSPACE.bzlmod b/WORKSPACE.bzlmod new file mode 100644 index 000000000..a0ab9b8b5 --- /dev/null +++ b/WORKSPACE.bzlmod @@ -0,0 +1 @@ +# Empty to avoid pulling in the non-bzlmod WORKSPACE file diff --git a/bazel/compat.bzl b/bazel/compat.bzl index d834a37eb..1a63be17b 100644 --- a/bazel/compat.bzl +++ b/bazel/compat.bzl @@ -1,16 +1,13 @@ -# Copyright 2021 Code Intelligence GmbH # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Copyright 2024 Code Intelligence GmbH # -# http://www.apache.org/licenses/LICENSE-2.0 +# By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. +# +# The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt +# located in the root directory of the project. +# +# This file also contains code licensed under Apache2 license. # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. SKIP_ON_MACOS = select({ "@platforms//os:macos": ["@platforms//:incompatible"], diff --git a/bazel/coverage/coverage.sh b/bazel/coverage/coverage.sh index 626fdc706..185a7acbe 100755 --- a/bazel/coverage/coverage.sh +++ b/bazel/coverage/coverage.sh @@ -1,17 +1,12 @@ #!/usr/bin/env sh -# Copyright 2022 Code Intelligence GmbH # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Copyright 2024 Code Intelligence GmbH # -# http://www.apache.org/licenses/LICENSE-2.0 +# By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. +# +# The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt +# located in the root directory of the project. # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. # Use just like `bazel test` to generate and open an HTML coverage report. diff --git a/bazel/fuzz_target.bzl b/bazel/fuzz_target.bzl index f748c6d69..db45a8283 100644 --- a/bazel/fuzz_target.bzl +++ b/bazel/fuzz_target.bzl @@ -1,16 +1,11 @@ -# Copyright 2021 Code Intelligence GmbH # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Copyright 2024 Code Intelligence GmbH # -# http://www.apache.org/licenses/LICENSE-2.0 +# By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. +# +# The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt +# located in the root directory of the project. # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. def java_fuzz_target_test( name, @@ -33,8 +28,10 @@ def java_fuzz_target_test( # Superset of the findings the fuzzer is expected to find. Since fuzzing runs are not # deterministic across OSes, pinpointing the exact set of findings is difficult. allowed_findings = [], + expect_number_of_findings = 0, # By default, expect a crash iff allowed_findings isn't empty. expect_crash = None, + expect_non_crash_exit_code = None, # If empty, expect no warnings or errors, if not empty, expect one matching the given regex. expected_warning_or_error = "", **kwargs): @@ -116,7 +113,9 @@ def java_fuzz_target_test( str(verify_crash_input), str(verify_crash_reproducer), str(expect_crash), + str(expect_non_crash_exit_code or -1), str(launcher_variant == "java"), + str(expect_number_of_findings), "'" + expected_warning_or_error + "'", "'" + ",".join(allowed_findings) + "'", ] + fuzzer_args, diff --git a/bazel/jar.bzl b/bazel/jar.bzl index c37b9d49d..15eeaa52b 100644 --- a/bazel/jar.bzl +++ b/bazel/jar.bzl @@ -1,16 +1,11 @@ -# Copyright 2022 Code Intelligence GmbH # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Copyright 2024 Code Intelligence GmbH # -# http://www.apache.org/licenses/LICENSE-2.0 +# By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. +# +# The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt +# located in the root directory of the project. # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. def _strip_jar(ctx): out_jar = ctx.outputs.out diff --git a/bazel/kotlin.bzl b/bazel/kotlin.bzl index 8b2572063..5f4e3960b 100644 --- a/bazel/kotlin.bzl +++ b/bazel/kotlin.bzl @@ -1,19 +1,14 @@ -# Copyright 2021 Code Intelligence GmbH # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Copyright 2024 Code Intelligence GmbH # -# http://www.apache.org/licenses/LICENSE-2.0 +# By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. +# +# The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt +# located in the root directory of the project. # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -load("@io_bazel_rules_kotlin//kotlin:lint.bzl", "ktlint_fix", "ktlint_test") -load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_test") +load("@rules_kotlin//kotlin:lint.bzl", "ktlint_fix", "ktlint_test") +load("@rules_kotlin//kotlin:jvm.bzl", "kt_jvm_test") load("//bazel:compat.bzl", "SKIP_ON_WINDOWS") # A kt_jvm_test wrapped in a java_test for Windows compatibility. diff --git a/bazel/toolchains/BUILD.bazel b/bazel/toolchains/BUILD.bazel index dfce025a8..af65c64a5 100644 --- a/bazel/toolchains/BUILD.bazel +++ b/bazel/toolchains/BUILD.bazel @@ -1,12 +1,6 @@ -load("@bazel_tools//tools/jdk:default_java_toolchain.bzl", "NONPREBUILT_TOOLCHAIN_CONFIGURATION", "default_java_toolchain") -load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "define_kt_toolchain") -load("@io_bazel_rules_kotlin//kotlin:lint.bzl", "ktlint_config") -load("@io_bazel_rules_kotlin//kotlin/internal:opts.bzl", "kt_javac_options", "kt_kotlinc_options") - -default_java_toolchain( - name = "java_non_prebuilt", - configuration = NONPREBUILT_TOOLCHAIN_CONFIGURATION, -) +load("@rules_kotlin//kotlin:kotlin.bzl", "define_kt_toolchain") +load("@rules_kotlin//kotlin:lint.bzl", "ktlint_config") +load("@rules_kotlin//kotlin/internal:opts.bzl", "kt_javac_options", "kt_kotlinc_options") kt_kotlinc_options( name = "kotlinc_options", @@ -18,11 +12,11 @@ kt_javac_options( define_kt_toolchain( name = "kotlin_toolchain", - api_version = "1.5", + api_version = "1.9", javac_options = ":default_javac_options", jvm_target = "1.8", kotlinc_options = ":kotlinc_options", - language_version = "1.5", + language_version = "1.9", ) ktlint_config( diff --git a/bazel/tools/compute_benchmark_stats.sh b/bazel/tools/compute_benchmark_stats.sh index 7cc26a0f2..e1b37fd46 100755 --- a/bazel/tools/compute_benchmark_stats.sh +++ b/bazel/tools/compute_benchmark_stats.sh @@ -1,17 +1,12 @@ #!/usr/bin/env bash -# Copyright 2023 Code Intelligence GmbH # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Copyright 2024 Code Intelligence GmbH # -# http://www.apache.org/licenses/LICENSE-2.0 +# By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. +# +# The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt +# located in the root directory of the project. # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. # Run the benchmark given by $TEST_SUITE_LABEL, then get all "stat::number_of_executed_units: 12345" diff --git a/bazel/tools/java/com/code_intelligence/jazzer/tools/FuzzTargetTestWrapper.java b/bazel/tools/java/com/code_intelligence/jazzer/tools/FuzzTargetTestWrapper.java index 5cdb23a96..86dc8023e 100644 --- a/bazel/tools/java/com/code_intelligence/jazzer/tools/FuzzTargetTestWrapper.java +++ b/bazel/tools/java/com/code_intelligence/jazzer/tools/FuzzTargetTestWrapper.java @@ -1,16 +1,11 @@ -// Copyright 2021 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.code_intelligence.jazzer.tools; import static java.util.Arrays.asList; @@ -70,7 +65,9 @@ public static void main(String[] args) { boolean shouldVerifyCrashInput; boolean shouldVerifyCrashReproducer; boolean expectCrash; + int expectNonCrashExitCode; boolean usesJavaLauncher; + int expectedNumberOfFindings; Optional expectedWarningOrError; Set allowedFindings; List arguments; @@ -84,18 +81,16 @@ public static void main(String[] args) { shouldVerifyCrashInput = Boolean.parseBoolean(args[4]); shouldVerifyCrashReproducer = Boolean.parseBoolean(args[5]); expectCrash = Boolean.parseBoolean(args[6]); - usesJavaLauncher = Boolean.parseBoolean(args[7]); - if (args[8].isEmpty()) { - expectedWarningOrError = Optional.empty(); - } else { - expectedWarningOrError = Optional.of(args[8]); - } + expectNonCrashExitCode = Integer.parseInt(args[7]); + usesJavaLauncher = Boolean.parseBoolean(args[8]); + expectedNumberOfFindings = Integer.parseInt(args[9]); + expectedWarningOrError = args[10].isEmpty() ? Optional.empty() : Optional.of(args[10]); allowedFindings = - Arrays.stream(args[9].split(",")).filter(s -> !s.isEmpty()).collect(toSet()); + Arrays.stream(args[11].split(",")).filter(s -> !s.isEmpty()).collect(toSet()); // Map all files/dirs to real location arguments = Arrays.stream(args) - .skip(10) + .skip(12) .map(arg -> arg.startsWith("-") ? arg : runfiles.rlocation(arg)) .collect(toList()); } catch (IOException | ArrayIndexOutOfBoundsException e) { @@ -104,6 +99,11 @@ public static void main(String[] args) { return; } + if (expectedNumberOfFindings > 1 + && (allowedFindings.contains("timeout") || allowedFindings.contains("native"))) { + throw new IllegalArgumentException("Cannot expect multiple native or timeout findings"); + } + ProcessBuilder processBuilder = new ProcessBuilder(); // Ensure that Jazzer can find its runfiles. processBuilder.environment().putAll(runfiles.getEnvVars()); @@ -131,7 +131,7 @@ public static void main(String[] args) { "-XX:+IgnoreUnrecognizedVMOptions", "-XX:+CriticalJNINatives", "-XX:+EnableDynamicAgentLoading")); - if (System.getenv("JAZZER_DEBUG") != null) { + if (System.getenv("JAZZER_DEBUG") != null && System.getenv("JAZZER_DEBUG").equals("1")) { command.add("--debug"); } } else { @@ -169,13 +169,21 @@ public static void main(String[] args) { process.getErrorStream(), allowedFindings, arguments.contains("--nohooks"), - expectedWarningOrError); + expectedWarningOrError, + expectedNumberOfFindings); } finally { process.getErrorStream().close(); } int exitCode = process.waitFor(); if (!expectCrash) { - if (exitCode != 0) { + if (expectNonCrashExitCode >= 0) { + if (expectNonCrashExitCode != exitCode) { + System.err.printf( + "Expected exit code %d, but Jazzer exited with exit code %d%n", + expectNonCrashExitCode, exitCode); + System.exit(1); + } + } else if (exitCode != 0) { System.err.printf( "Did not expect a crash, but Jazzer exited with exit code %d%n", exitCode); System.exit(1); @@ -230,7 +238,8 @@ private static boolean verifyFuzzerOutput( InputStream fuzzerOutput, Set expectedFindings, boolean noHooks, - Optional expectedWarningOrError) + Optional expectedWarningOrError, + int expectedNumberOfFindings) throws IOException { List lines; try (BufferedReader reader = new BufferedReader(new InputStreamReader(fuzzerOutput))) { @@ -254,7 +263,7 @@ private static boolean verifyFuzzerOutput( } String unexpectedWarningsAndErrors = warningsAndErrors.stream() - .filter(line -> !expectedWarningOrError.get().equals(line)) + .filter(line -> !line.matches(expectedWarningOrError.get() + ".*$")) .collect(Collectors.joining("\n")); if (!unexpectedWarningsAndErrors.isEmpty()) { throw new IllegalStateException( @@ -315,6 +324,12 @@ private static boolean verifyFuzzerOutput( if (findings.isEmpty()) { throw new IllegalStateException("Expected a crash, but did not get a stack trace"); } + if (expectedNumberOfFindings > 0 && (findings.size() != expectedNumberOfFindings)) { + throw new IllegalStateException( + String.format( + "Expected %d findings, but got %d:%n%s", + expectedNumberOfFindings, findings.size(), String.join("\n", findings))); + } for (String finding : findings) { if (!expectedFindings.contains(finding)) { throw new IllegalStateException( diff --git a/bazel/tools/java/com/code_intelligence/jazzer/tools/JarStripper.java b/bazel/tools/java/com/code_intelligence/jazzer/tools/JarStripper.java index 88469d5b4..ec26d331d 100644 --- a/bazel/tools/java/com/code_intelligence/jazzer/tools/JarStripper.java +++ b/bazel/tools/java/com/code_intelligence/jazzer/tools/JarStripper.java @@ -1,16 +1,11 @@ -// Copyright 2022 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.code_intelligence.jazzer.tools; diff --git a/deploy/BUILD.bazel b/deploy/BUILD.bazel index 738ac589a..99b9270fe 100644 --- a/deploy/BUILD.bazel +++ b/deploy/BUILD.bazel @@ -17,6 +17,11 @@ sh_binary( deps = ["@bazel_tools//tools/bash/runfiles"], ) +sh_binary( + name = "deploy_local", + srcs = ["deploy_local.sh"], +) + string_flag( name = "jazzer_version", build_setting_default = "0.0.0-dev", @@ -33,6 +38,7 @@ java_export( ], maven_coordinates = "com.code-intelligence:jazzer-api:$(JAZZER_VERSION)", pom_template = "//deploy:jazzer-api.pom", + tags = ["no-sources"], toolchains = [":jazzer_version"], visibility = ["//visibility:public"], runtime_deps = ["//src/main/java/com/code_intelligence/jazzer/api"], @@ -44,7 +50,10 @@ java_export( pom_template = "jazzer.pom", # Do not generate an implicit javadocs target - the current target is based on the shaded deploy # JAR, for which the docs JAR generated by default would be empty. - tags = ["no-javadocs"], + tags = [ + "no-javadocs", + "no-sources", + ], toolchains = [":jazzer_version"], visibility = ["//visibility:public"], runtime_deps = [ @@ -80,6 +89,12 @@ java_export( ], maven_coordinates = "com.code-intelligence:jazzer-junit:$(JAZZER_VERSION)", pom_template = "jazzer-junit.pom", + tags = [ + "no-sources", + # Generating javadocs breaks the build due to weird dependency issues. + # Deactivate it for now. + "no-javadocs", + ], toolchains = [":jazzer_version"], visibility = ["//visibility:public"], runtime_deps = [ diff --git a/deploy/deploy.sh b/deploy/deploy.sh index 550e4c205..43397f7c5 100755 --- a/deploy/deploy.sh +++ b/deploy/deploy.sh @@ -1,17 +1,12 @@ #!/usr/bin/env bash -# Copyright 2022 Code Intelligence GmbH # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Copyright 2024 Code Intelligence GmbH # -# http://www.apache.org/licenses/LICENSE-2.0 +# By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. +# +# The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt +# located in the root directory of the project. # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. set -eu diff --git a/deploy/deploy_local.sh b/deploy/deploy_local.sh new file mode 100755 index 000000000..11f6a716c --- /dev/null +++ b/deploy/deploy_local.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +# +# Copyright 2024 Code Intelligence GmbH +# +# By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. +# +# The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt +# located in the root directory of the project. +# + +cd "$BUILD_WORKSPACE_DIRECTORY" || fail "BUILD_WORKSPACE_DIRECTORY not found" + +bazel run --define "maven_repo=file://$HOME/.m2/repository" //deploy:jazzer.publish +bazel run --define "maven_repo=file://$HOME/.m2/repository" //deploy:jazzer-junit.publish +bazel run --define "maven_repo=file://$HOME/.m2/repository" //deploy:jazzer-api.publish diff --git a/deploy/jazzer-api.pom b/deploy/jazzer-api.pom index 6ad1cc0c9..423599f2c 100644 --- a/deploy/jazzer-api.pom +++ b/deploy/jazzer-api.pom @@ -1,3 +1,12 @@ + + 4.0.0 {groupId} @@ -13,28 +22,12 @@ Helper functions and annotations for Jazzer fuzz targets https://github.com/CodeIntelligenceTesting/jazzer - - - Apache License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt - repo - - Code Intelligence GmbH https://code-intelligence.com - - - fmeum - Fabian Meumertzheim - meumertzheim@code-intelligence.com - Code Intelligence GmbH - - - https://github.com/CodeIntelligenceTesting/jazzer diff --git a/deploy/jazzer-api_artifact_test.sh b/deploy/jazzer-api_artifact_test.sh index 5a0ec806f..106e0f27c 100755 --- a/deploy/jazzer-api_artifact_test.sh +++ b/deploy/jazzer-api_artifact_test.sh @@ -1,17 +1,12 @@ #!/usr/bin/env sh -# Copyright 2022 Code Intelligence GmbH # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Copyright 2024 Code Intelligence GmbH # -# http://www.apache.org/licenses/LICENSE-2.0 +# By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. +# +# The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt +# located in the root directory of the project. # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. [ -f "$1" ] || exit 1 JAR="$2/bin/jar" diff --git a/deploy/jazzer-junit.pom b/deploy/jazzer-junit.pom index 1fb624e5d..b529f54be 100644 --- a/deploy/jazzer-junit.pom +++ b/deploy/jazzer-junit.pom @@ -1,3 +1,12 @@ + + 4.0.0 {groupId} @@ -13,28 +22,11 @@ JUnit 5 support for Jazzer fuzz tests https://github.com/CodeIntelligenceTesting/jazzer - - - Apache License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt - repo - - - Code Intelligence GmbH https://code-intelligence.com - - - fmeum - Fabian Meumertzheim - meumertzheim@code-intelligence.com - Code Intelligence GmbH - - - https://github.com/CodeIntelligenceTesting/jazzer diff --git a/deploy/jazzer-junit_artifact_test.sh b/deploy/jazzer-junit_artifact_test.sh index 9c45985c9..8dc8d7424 100755 --- a/deploy/jazzer-junit_artifact_test.sh +++ b/deploy/jazzer-junit_artifact_test.sh @@ -1,17 +1,12 @@ #!/usr/bin/env sh -# Copyright 2022 Code Intelligence GmbH # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Copyright 2024 Code Intelligence GmbH # -# http://www.apache.org/licenses/LICENSE-2.0 +# By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. +# +# The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt +# located in the root directory of the project. # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. [ -f "$1" ] || exit 1 JAR="$2/bin/jar" diff --git a/deploy/jazzer.pom b/deploy/jazzer.pom index 114fa0878..31e5382eb 100644 --- a/deploy/jazzer.pom +++ b/deploy/jazzer.pom @@ -1,3 +1,12 @@ + + 4.0.0 {groupId} @@ -13,28 +22,11 @@ Coverage-guided, in-process fuzzing for the JVM https://github.com/CodeIntelligenceTesting/jazzer - - - Apache License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt - repo - - - Code Intelligence GmbH https://code-intelligence.com - - - fmeum - Fabian Meumertzheim - meumertzheim@code-intelligence.com - Code Intelligence GmbH - - - https://github.com/CodeIntelligenceTesting/jazzer diff --git a/deploy/jazzer_artifact_test.sh b/deploy/jazzer_artifact_test.sh index 833fc2292..9aabd337d 100755 --- a/deploy/jazzer_artifact_test.sh +++ b/deploy/jazzer_artifact_test.sh @@ -1,17 +1,12 @@ #!/usr/bin/env sh -# Copyright 2022 Code Intelligence GmbH # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Copyright 2024 Code Intelligence GmbH # -# http://www.apache.org/licenses/LICENSE-2.0 +# By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. +# +# The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt +# located in the root directory of the project. # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. [ -f "$1" ] || exit 1 JAR="$2/bin/jar" diff --git a/deploy/jazzer_version_test.sh b/deploy/jazzer_version_test.sh index 162a87c1f..451b3ede0 100755 --- a/deploy/jazzer_version_test.sh +++ b/deploy/jazzer_version_test.sh @@ -1,17 +1,12 @@ #!/usr/bin/env bash -# Copyright 2023 Code Intelligence GmbH # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Copyright 2024 Code Intelligence GmbH # -# http://www.apache.org/licenses/LICENSE-2.0 +# By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. +# +# The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt +# located in the root directory of the project. # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. # --- begin runfiles.bash initialization v3 --- # Copy-pasted from the Bazel Bash runfiles library v3. diff --git a/docker/build_all.sh b/docker/build_all.sh deleted file mode 100755 index 21c7c8e27..000000000 --- a/docker/build_all.sh +++ /dev/null @@ -1,19 +0,0 @@ -# Copyright 2021 Code Intelligence GmbH -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -e - -this_dir=$(dirname "$(realpath "$0")") -docker build --pull -t cifuzz/jazzer "$@" "$this_dir"/jazzer -docker build -t cifuzz/jazzer-autofuzz "$@" "$this_dir"/jazzer-autofuzz diff --git a/docker/jazzer-autofuzz/Dockerfile b/docker/jazzer-autofuzz/Dockerfile deleted file mode 100644 index 11721e121..000000000 --- a/docker/jazzer-autofuzz/Dockerfile +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright 2021 Code Intelligence GmbH -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -FROM cifuzz/jazzer as jazzer - -FROM ubuntu:20.04 - -ENV DEBIAN_FRONTEND=noninteractive -RUN apt-get update && apt-get install -y curl openjdk-17-jdk-headless - -WORKDIR /app -RUN curl -L 'https://github.com/coursier/coursier/releases/download/v2.0.16/coursier.jar' -o coursier.jar && \ - chmod +x coursier.jar - -COPY entrypoint.sh /app/ -COPY --from=jazzer /app/* /app/ - -WORKDIR /fuzzing -ENTRYPOINT ["/app/entrypoint.sh"] diff --git a/docker/jazzer-autofuzz/entrypoint.sh b/docker/jazzer-autofuzz/entrypoint.sh deleted file mode 100755 index 7df2ec3b2..000000000 --- a/docker/jazzer-autofuzz/entrypoint.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2021 Code Intelligence GmbH -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -e - -CP="$(/app/coursier.jar fetch --classpath "$1")" -/app/jazzer \ - --cp="$CP" \ - --autofuzz="$2" \ - "${@:3}" diff --git a/docker/jazzer/Dockerfile b/docker/jazzer/Dockerfile deleted file mode 100644 index c516dc4c5..000000000 --- a/docker/jazzer/Dockerfile +++ /dev/null @@ -1,42 +0,0 @@ -# Copyright 2021 Code Intelligence GmbH -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -FROM ubuntu:20.04 AS builder - -ENV DEBIAN_FRONTEND=noninteractive -RUN apt-get update && apt-get install -y curl git python3 openjdk-17-jdk-headless - -WORKDIR /root -RUN curl -L https://github.com/bazelbuild/bazelisk/releases/download/v1.15.0/bazelisk-linux-amd64 -o /usr/bin/bazelisk && \ - chmod +x /usr/bin/bazelisk && \ - git clone --depth=1 https://github.com/CodeIntelligenceTesting/jazzer.git && \ - cd jazzer && \ - # The LLVM toolchain requires ld and ld.gold to exist, but does not use them. - touch /usr/bin/ld && \ - touch /usr/bin/ld.gold && \ - bazelisk build --config=docker //launcher:jazzer && \ - mkdir -p /app && \ - cp $(bazelisk cquery --config=docker --output=files //src/main/java/com/code_intelligence/jazzer:jazzer_standalone_deploy.jar) /app/jazzer_standalone.jar && \ - cp $(bazelisk cquery --config=docker --output=files //launcher:jazzer) /app/ - -# :debug includes a busybox shell, which is needed for libFuzzer's use of system() for e.g. the -# -fork and -minimize_crash commands. -FROM gcr.io/distroless/java17:debug - -COPY --from=builder /app/* /app/ -# system() expects the shell at /bin/sh, but the image has it at /busybox/sh. We create a symlink, -# but have to use the long form as a simple RUN also requires /bin/sh. -RUN ["/busybox/sh", "-c", "ln -s /busybox/sh /bin/sh && ln -s /busybox/env /usr/bin/env"] -WORKDIR /fuzzing -ENTRYPOINT [ "/app/jazzer" ] diff --git a/docker/push_all.sh b/docker/push_all.sh deleted file mode 100755 index 59d437189..000000000 --- a/docker/push_all.sh +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright 2021 Code Intelligence GmbH -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -e - -this_dir=$(dirname "$(realpath "$0")") -"$this_dir"/build_all.sh --no-cache - -docker push cifuzz/jazzer -docker push cifuzz/jazzer-autofuzz diff --git a/docs/advanced.md b/docs/advanced.md index 55c3a832c..2c640b9cf 100644 --- a/docs/advanced.md +++ b/docs/advanced.md @@ -1,25 +1,44 @@ ## Advanced options -* [Passing JVM arguments](#passing-jvm-arguments) -* [Coverage instrumentation](#coverage-instrumentation) -* [Trace instrumentation](#trace-instrumentation) -* [Value profile](#value-profile) -* [Custom hooks](#custom-hooks) -* [Suppressing stack traces](#suppressing-stack-traces) -* [Export coverage information](#export-coverage-information) -* [Native libraries](#native-libraries) -* [Fuzzing mutators](#fuzzing-mutators) - - +* [Using Jazzer Standalone](#using-jazzer-standalone) +* [Passing JVM Arguments](#passing-jvm-arguments) +* [Coverage Instrumentation](#coverage-instrumentation) +* [Trace Instrumentation](#trace-instrumentation) +* [Value Profile](#value-profile) +* [Custom Hooks](#custom-hooks) +* [Keep Going](#keep-going) +* [Export Coverage Information](#export-coverage-information) +* [Native Libraries](#native-libraries) -Various command line options are available to control the instrumentation and fuzzer execution. -Since Jazzer is a libFuzzer-compiled binary, all positional and single dash command-line options are parsed by libFuzzer. -Therefore, all Jazzer options are passed via double dash command-line flags, i.e., as `--option=value` (note the `=` instead of a space). +**Note**: These settings apply to the old fuzzing approach using a `fuzzerTestOneInput` method and the native Jazzer binary. They don't work in the new JUnit integration. + +## Using Jazzer Standalone +There are two ways to use Jazzer standalone: by using the `jazzer` binary or by calling the Jazzer main class directly. + +### Using the `jazzer` binary +Jazzer is available as a standalone libFuzzer-compiled binary. To call `jazzer` you need to pass it the project +classpath and target class that contains the Fuzz Test. + +```shell +jazzer --cp= --target_class= +``` + +### Calling the Jazzer main class directly +To call Jazzer directly you need to pass it the project classpath, the path to the `jazzer.jar` and `jazzer-junit.jar` +along with the Jazzer main class `com.code_intelligence.jazzer.Jazzer` and target class that contains the Fuzz Test. + +```shell +java -cp ;; com.code_intelligence.jazzer.Jazzer --target_class= [args...] +``` +Optionally you can add other Jazzer arguments with double dash command-line flags. +Because Jazzer is based on libFuzzer, all available libFuzzer arguments can be added with single dash command-line flags. +Please refer to [libFuzzer](https://llvm.org/docs/LibFuzzer.html) for documentation. + +Various command line options are available to control the instrumentation and fuzzer execution. A full list of command-line flags can be printed with the `--help` flag. -For the available libFuzzer options please refer to [its documentation](https://llvm.org/docs/LibFuzzer.html) for a detailed description. -### Passing JVM arguments +### Passing JVM Arguments When Jazzer is started using the `jazzer` binary, it starts a JVM in which it executes the fuzz target. Arguments for this JVM can be provided via the `JAVA_OPTS` environment variable. @@ -37,13 +56,12 @@ For example, to enable preview features as well as set a maximum heap size, add Arguments specified with `--jvm_args` take precedence over those in `JAVA_OPTS`. -### Coverage instrumentation +## Coverage Instrumentation The Jazzer agent inserts coverage markers into the JVM bytecode during class loading. -libFuzzer uses this information to guide its input mutations towards increased coverage. - It is possible to restrict instrumentation to only a subset of classes with the `--instrumentation_includes` flag. -This is especially useful if coverage inside specific packages is of higher interest, e.g., the user library under test rather than an external parsing library in which the fuzzer is likely to get lost. +This is especially useful if coverage inside specific packages is of higher interest, +e.g., the user library under test rather than an external parsing library in which the fuzzer is likely to get lost. Similarly, there is `--instrumentation_excludes` to exclude specific classes from instrumentation. Both flags take a list of glob patterns for the java class name separated by colon: @@ -51,9 +69,10 @@ Both flags take a list of glob patterns for the java class name separated by col --instrumentation_includes=com.my_com.**:com.other_com.** --instrumentation_excludes=com.my_com.crypto.** ``` -By default, JVM-internal classes and Java as well as Kotlin standard library classes are not instrumented, so these do not need to be excluded manually. +By default, JVM-internal classes and Java as well as Kotlin standard library classes are not instrumented, +so these do not need to be excluded manually. -### Trace instrumentation +### Trace Instrumentation The agent adds additional hooks for tracing compares, integer divisions, switch statements and array indices. These hooks correspond to [clang's data flow hooks](https://clang.llvm.org/docs/SanitizerCoverage.html#tracing-data-flow). @@ -68,7 +87,7 @@ The particular instrumentation types to apply can be specified using the `--trac Multiple instrumentation types can be combined with a colon (Linux, macOS) or a semicolon (Windows). -### Value profile +### Value Profile The run-time flag `-use_value_profile=1` enables [libFuzzer's value profiling mode](https://llvm.org/docs/LibFuzzer.html#value-profile). When running with this flag, the feedback about compares and constants received from Jazzer's trace instrumentation is associated with the particular bytecode location and used to provide additional coverage instrumentation. @@ -88,13 +107,17 @@ To use the compiled method hooks, they have to be available on the classpath pro Hooks have to be loaded from separate JAR files so that Jazzer can [add it to the bootstrap class loader search](https://docs.oracle.com/javase/8/docs/api/java/lang/instrument/Instrumentation.html#appendToBootstrapClassLoaderSearch-java.util.jar.JarFile-). The list of custom hooks can alternatively be specified via the `Jazzer-Hook-Classes` attribute in the fuzz target JAR's manifest. -### Suppressing stack traces +### Keep Going With the flag `--keep_going=N` Jazzer continues fuzzing until `N` unique stack traces have been encountered. +Specifically `--keep-going=0` will keep the fuzzer running until another stop condition (e.g. maximum runtime) is met. -Particular stack traces can also be ignored based on their `DEDUP_TOKEN` by passing a comma-separated list of tokens via `--ignore=,`. +Particular stack traces can also be ignored based on their `DEDUP_TOKEN` by passing a comma-separated list of tokens via +`--ignore=,`. -### Export coverage information +### Export Coverage Information + +**Note**: This feature is deprecated. The standalone JaCoCo agent should be used to generate coverage reports. The internally gathered JaCoCo coverage information can be exported in human-readable and JaCoCo execution data format (`.exec`). These can help identify code areas that have not been covered by the fuzzer and thus may require more comprehensive fuzz targets or a more extensive initial corpus to reach. @@ -118,7 +141,7 @@ java -jar path/to/jacococli.jar report coverage.exec \ --name FuzzCoverageReport ``` -### Native libraries +### Native Libraries Jazzer supports fuzzing of native libraries loaded by the JVM, for example via `System.load()`. For the fuzzer to get coverage feedback, these libraries have to be compiled with `-fsanitize=fuzzer-no-link`. @@ -140,17 +163,3 @@ Furthermore, due to the nature of the JVM's GC, LeakSanitizer reports too many f The fuzz targets `ExampleFuzzerWithASan` and `ExampleFuzzerWithUBSan` in the [`examples`](../examples/src/main/java/com/example) directory contain minimal working examples for fuzzing with native libraries. Also see `TurboJpegFuzzer` for a real-world example. - -### Fuzzing mutators - -LibFuzzer API offers two functions to customize the mutation strategy which is especially useful when fuzzing functions that require structured input. -Jazzer does not define `LLVMFuzzerCustomMutator` nor `LLVMFuzzerCustomCrossOver` and leaves the mutation strategy entirely to libFuzzer. -However, custom mutators can easily be integrated by compiling a mutator library which defines `LLVMFuzzerCustomMutator` (and optionally `LLVMFuzzerCustomCrossOver`) and pre-loading the mutator library: - -```bash -# Using Bazel: -LD_PRELOAD=libcustom_mutator.so bazel run //:jazzer -- -# Using the binary release: -LD_PRELOAD=libcustom_mutator.so ./jazzer -``` - diff --git a/docs/common.md b/docs/common.md index d8ba861db..0a03e8e47 100644 --- a/docs/common.md +++ b/docs/common.md @@ -1,26 +1,26 @@ ## Common options and workflows -* [Recommended JVM options](#recommended-jvm-options) -* [Passing arguments](#passing-arguments) -* [Reproducing a finding](#reproducing-a-finding) -* [Minimizing a crashing input](#minimizing-a-crashing-input) -* [Parallel execution](#parallel-execution) -* [Autofuzz mode](#autofuzz-mode) +* [Recommended JVM Options](#recommended-jvm-options) +* [Passing Arguments](#passing-arguments) +* [Reproducing a Finding](#reproducing-a-finding) +* [Parallel Execution](#parallel-execution) +* [Autofuzz Mode](#autofuzz-mode) - +**Note**: These settings apply to the old fuzzing approach using a `fuzzerTestOneInput` method and the native Jazzer binary. They don't work in the new JUnit integration. -### Recommended JVM options +## Recommended JVM Options -The following JVM settings are recommended for running Jazzer within JUnit. -The `jazzer` launcher binary sets them automatically. +The following JVM settings are recommended for running Jazzer: -* `-XX:-OmitStackTraceInFastThrow` ensures that stack traces are emitted even on hot code paths. - This may hurt performance if your fuzz test frequently throws and catches exceptions, but also helps find flaky bugs. -* `-XX:+UseParallelGC` optimizes garbage collection for high throughput rather than low latency. -* `-XX:+CriticalJNINatives` is supported with JDK 17 and earlier and improves the runtime performance of Jazzer's instrumentation. -* `-XX:+EnableDynamicAgentLoading` silences a warning with JDK 21 and later triggered by the Java agent that Jazzer attaches to instrument the fuzzed code. +* `-XX:-OmitStackTraceInFastThrow`: Ensures that stack traces are emitted even on hot code paths. + This may hurt performance if your Fuzz Test frequently throws and catches exceptions, but also helps find flaky bugs. +* `-XX:+UseParallelGC`: Optimizes garbage collection for high throughput rather than low latency. +* `-XX:+CriticalJNINatives`: Is supported with JDK 17 and earlier and improves the runtime performance of Jazzer's + instrumentation. +* `-XX:+EnableDynamicAgentLoading`: Silences a warning with JDK 21 and later triggered by the Java agent that Jazzer + attaches to instrument the fuzzed code. -### Passing arguments +## Passing Arguments Jazzer provides many configuration settings. An up-to-date list can be found by running Jazzer with the `--help` flag. @@ -45,9 +45,7 @@ When Jazzer manages to find an input that causes an uncaught exception or a fail ### Minimizing a crashing input -Every crash stack trace is accompanied by a `DEDUP_TOKEN` that uniquely identifies the relevant parts of the stack trace. -This value is used by libFuzzer while minimizing a crashing input to ensure that the smaller inputs reproduce the "same" bug. -To minimize a crashing input, execute Jazzer with the following arguments in addition to `--cp` and `--target_class`: +With the following argument you can minimize a crashing input to find the smallest input that reproduces the same "bug": ```bash -minimize_crash=1 diff --git a/docs/images/remote-debug.jpeg b/docs/images/remote-debug.jpeg new file mode 100644 index 000000000..ce2ee7e5a Binary files /dev/null and b/docs/images/remote-debug.jpeg differ diff --git a/docs/junit-integration.md b/docs/junit-integration.md index 1b6c5b6a3..4c8e3420c 100644 --- a/docs/junit-integration.md +++ b/docs/junit-integration.md @@ -1,4 +1,351 @@ -# JUnit Integration Implementation +# JUnit Integration + +Jazzer's JUnit integration is described on the main readme page at [JUnit 5](../README.md#junit-5). This document will +go into more details about more specific aspects of the integration. + +## Mutation Framework + +Classic Jazzer fuzz tests expect a single parameter of type `FuzzedDataProvider` or `byte[]`, which can be used to +create further inputs required by the function under test. This can get quite cumbersome for tests that require multiple +or complex inputs. + +To address this issue, Jazzer adds the ability to expect any number of parameters of primitive and, limited, object +types. The underlying functionality, called "mutation framework", will create and mutate these parameters in a type +specific manner. + +Type information enable the fuzzer to directly generate valid input and not only a low level byte representation, which +could easily break during manual object creation in the fuzz test and result in inefficient retries. + +The mutation framework is designed in an extensible and composable way, so that type specific mutation logic is +encapsulated in dedicated classes, and can easily and automatically be composed into mutators for complex types. +Furthermore, new mutators for currently unsupported or custom types are directly integrated into the mutation framework +and used during generation of mutators for other types. + +The mutation framework integrates with the underlying fuzzing engine and ensures stability of saved findings and corpus +entries, so that changes in the mutation framework itself or the mutation logic of specific mutators don't invalidate +existing findings or corpus entries. + +The mutation framework is located in the `com.code_intelligence.jazzer.mutation` package. + +**Note**: If a fuzz function still expects a single `FuzzedDataProvider` or `byte[]` parameter, the mutation framework +will not be used! + +The example below shows how to use complex data types in a fuzz test. Any supported type can be used as a parameter of a +fuzz test. The mutation framework will automatically create and mutate the parameters accordingly. + +```java +record SimpleTypesRecord(boolean bar, int baz) { +} + +@FuzzTest +public void testSimpleTypeRecord(SimpleTypesRecord record) { + doSomethingWithRecord(record); +} +``` + +### Supported Types + +Type specific mutations are located in the `com.code_intelligence.jazzer.mutation.mutator` package. + +Mutators are free to implement mutations in any way they see fit, e.g. the integral type mutator can perform bit flips, +random walks, pseudo random number picks between specified `min` and `max` values, or fall back to the underlying +fuzzing engine mutation. + +Mutators automatically compose into mutators for complex types, e.g. a list mutator will use the mutator for the list +element type to generate and mutate list elements and so on. If an unsupported type is encountered no mutator can be +created. + +Currently supported types are: + +| Mutator | Type(s) | Notes | +|--------------------------------|--------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| Boolean | `boolean`, `Boolean` | | +| Integral | `byte`, `Byte`, `short`, `Short`, `int`, `Int`, `long`, `Long` | | +| Floating point | `float`, `Float`, `double`, `Double` | | +| String | `java.lang.String` | | +| Enum | `java.lang.Enum` | | +| InputStream | `java.io.InputStream` | | +| Time | `java.time.LocalDate`, `java.time.LocalDateTime`, `java.time.LocalTime`, `java.time.ZonedDateTime` | | +| Array | Arrays holding any other supported type (e.g. `byte[]`, `Integer[]`, `Map[]`, `String[]`, etc.) | | +| List | `java.util.List` | | +| Map | `java.util.Map` | | +| Record | `java.lang.Record` | Arbitrary Java Records, if supported by JVM version | +| Setter-based JavaBean | | Any class adhering to the [JavaBeans Spec](https://www.oracle.com/java/technologies/javase/javabeans-spec.html), see [JavaBeans Support](#javabeans-support) for details | +| Constructor-based JavaBean | | Any class adhering to the [JavaBeans Spec](https://www.oracle.com/java/technologies/javase/javabeans-spec.html), see [JavaBeans Support](#javabeans-support) for details | +| Constructor-based Java Classes | | Any class requiring constructor parameters, but not offering getter methods, see [constructor-based classes](#constructor-based-classes) for details | +| Builder | | See [Builder pattern support](#builder-pattern-support) for details | +| FuzzedDataProvider | `com.code_intelligence.jazzer.api.FuzzedDataProvider` | | +| Protobuf | `com.google.protobuf.Message`, `com.google.protobuf.Message.Builder`, `com.google.protobuf.ByteString` | Classes generated by the Protobuf toolchain | +| Nullable | | Any reference type will occasionally be set to `null` | + +### Annotations + +It is sometimes helpful to provide additional information about the Fuzz Test +parameters, e.g. to specify the range of integers, or the maximum length of a +string. This is done using annotations directly on the parameters. + +**Note**: Annotations are used on best effort basis, meaning that the fuzzer +will try to honor specified constraints, but can not guarantee it. + +All annotations reside in the `com.code_intelligence.jazzer.mutation.annotation` +package. + +| Annotation | Applies To | Notes | +|-------------------|----------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------| +| `@Ascii` | `java.lang.String` | `String` should only contain ASCII characters | +| `@InRange` | `byte`, `Byte`, `short`, `Short`, `int`, `Int`, `long`, `Long` | Specifies `min` and `max` values of generated integrals | +| `@InRangeFloat` | `float`, `Float` | Specifies `min` and `max` values of generated floats | +| `@InRangeDouble` | `double`, `Double` | Specifies `min` and `max` values of generated doubles | +| `@NotNull` | | Specifies that a reference type should not be `null` | +| `@WithLength` | `byte[]` | Specifies the length of the generated byte array | +| `@WithUtf8Length` | `java.lang.String` | Specifies the length of the generated string in UTF-8 bytes, see annotation Javadoc for further information | +| `@WithSize` | `java.util.List`, `java.util.Map` | Specifies the size of the generated collection | +| `@UrlSegment` | `java.lang.String` | `String` should only contain valid URL segment characters | + +The example below shows how Fuzz Test parameters can be annotated to provide +additional information to the mutation framework. + +```java title="Example" showLineNumbers +record SimpleTypesRecord(boolean bar, int baz) {} + +@FuzzTest +public void testSimpleTypeRecord(@NotNull @WithSize(min = 3, max = 100) List records) { + doSomethingWithRecord(record); +} +``` + +#### Annotation constraints + +Often, annotations should be applied to a type and all it's nested component +types. This use-case is supported by the annotation's `constraint` property. It +can be set to `PropertyConstraint.RECURSIVE` so that the annotation is +propagated down to all subcomponent types. +All above-mentioned annotations support this feature. + +For example, if a Fuzz Test expects a `List` of `List` of `Integer` as +parameter, and both the lists and their values must not be `null`, the +annotation `@NotNull(constraint = PropertyConstraint.RECURSIVE)` could be added +on the root type. + +```java title="Example" showLineNumbers +@FuzzTest +public void fuzz(@NotNull(constraint = PropertyConstraint.RECURSIVE) List> list) { + // list is not null and does not contain null entries on any level + assertDeepNotNull(list); +} +``` + +### JavaBeans support + +Jazzer can generate and mutate instances of classes adhering to the +[JavaBeans Spec](https://www.oracle.com/java/technologies/javase/javabeans-spec.html). + +To serialize and deserialize Java objects to and from corpus entries, Jazzer can +use setters, constructors and getters to pass values to a JavaBean and extract +them back out from it. + +#### Setter-based approach + +The setter-based approach requires a class to provide a default constructor with +no arguments. The corresponding methods are looked up by name and must adhere to +the JavaBeans Spec naming convention, meaning `setXX` and `getXX`/`isXX` methods +for property `XX`. A JavaBean can have additional getters corresponding to +computed properties, but it is required that all setters have a corresponding +getter. + +```java title="Example" showLineNumbers +public static class FooBean { + private String foo; + + public String getFoo() { + return foo; + } + + public void setFoo(String foo) { + this.foo = foo; + } +} + +@FuzzTest +public void testFooBean(FooBean fooBean) { + // ... +} +``` + +#### Constructor-based approach + +The constructor-based approach requires a class to provide a constructor with +arguments. If multiple constructors are available, the one with the most +supported parameters will be preferred. + +The lookup of matching getters relies on the Java bean's property names. As a +class can have further properties or internal states, this approach relies on +the constructor parameter names. Since parameter names are not always available +at runtime, they explicitly have to be compiled into the class file with the use +of the JavaBeans `@ConstructorProperties` annotation, to specify property names +explicitly. + +```java title="Example" showLineNumbers +public static class PropertyNamesBean { + private final String bar; + + public PropertyNamesBean(String bar) { + this.bar = bar; + } + + public String getBar() { + return bar; + } +} + +public static class ConstructorPropertiesBean { + private final String foo; + + @ConstructorProperties({"bar"}) + public PropertyNamesBean(String foo) { + this.bar = foo; + } + + public String getBar() { + return foo; + } +} + +public static class FallbackTypeBean { + private final String foo; + + public PropertyNamesBean(String foo) { + this.bar = foo; + } + + public String getSomething() { + return foo; + } +} + +@FuzzTest +public void testBeans(PropertyNamesBean propertyNamesBean, ConstructorPropertiesBean constructorPropertiesBean, FallbackTypeBean fallbackTypeBean) { + // ... +} +``` + +### Constructor-based classes + +Jazzer can generate and mutate instances of classes that build up their internal +state via constructor parameters, and, in contrast to +[JavaBeans](#javabeans-support), don't offer getter methods. + +The following class would fall into this category: + +```java title="Constructor-based class" showLineNumbers +class ImmutableClassTest { + + static class ImmutableClass { + private final int bar; + public ImmutableClass(int foo) { + this.bar = foo * 2; + } + String barAsString() { + return String.valueOf(bar); + } + } + + @FuzzTest + void fuzzImmutableClassFunction(ImmutableClass immutableClass) { + if (immutableClass != null && "42".equals(immutableClass.barAsString())) { + throw new RuntimeException("42!"); + } + } +} +``` + +### Builder pattern support + +The [builder pattern](https://en.wikipedia.org/wiki/Builder_pattern) is a common +[design pattern](https://en.wikipedia.org/wiki/Software_design_pattern) to +simplify the construction of complex objects. + +- A common implementation gathers all required parameters in the `builder` and + passes them to the constructor of the target class. +- Another approach is used for `builder`s supporting a nested type hierarchy in + the target class. In this situation the `builder` itself is passed into the + constructor of the target class. + +**Note**: These pattern are generated by the commonly used +[Lombok](https://projectlombok.org/) `@Builder` and `@SuperBuilder` annotations. + +The examples below use [Lombok](https://projectlombok.org/) to generate +appropriate `builder` classes: + +```java title="@Builder pattern support" showLineNumbers +class SimpleClassFuzzTests { + + @Builder + static class SimpleClass { + String foo; + List bar; + boolean baz; + } + + @FuzzTest + void fuzzSimpleClassFunction(@NotNull SimpleClass simpleClass) { + someFunctionToFuzz(simpleClass); + } +} +``` + +```java title="@SuperBuilder pattern support" showLineNumbers +class SimpleClassFuzzTests { + + @SuperBuilder + static class ParentClass { + String foo; + } + + @SuperBuilder + static class ChildClass extends ParentClass { + List bar; + } + + @FuzzTest + void fuzzChildClassFunction(@NotNull ChildClass childClass) { + someChildFunctionToFuzz(childClass); + } +} +``` + +### FuzzedDataProvider + +The `FuzzedDataProvider` is an alternative approach commonly used in programming +languages like C and C++. It provides an intuitive interface to deconstruct +fuzzer input with type-specific functions, e.g. `consumeString`, +`consumeBoolean` or `consumeInt`. Jazzer's Java implementation follows the +`FuzzedDataProvider` of the [LLVM Project](https://llvm.org/). + +This programmatic approach offers very fine-grained control, but requires much +more effort to build up needed data structures. + +Below is an example of a simple Fuzz Test using the `FuzzedDataProvider`: + +```java title="Example" showLineNumbers +import com.code_intelligence.jazzer.api.FuzzedDataProvider; +import com.code_intelligence.jazzer.junit.FuzzTest; + +class ParserTests { + @Test + void unitTest() { + assertEquals("foobar", SomeScheme.decode(SomeScheme.encode("foobar"))); + } + + @FuzzTest + void fuzzTest(FuzzedDataProvider data) { + String input = data.consumeRemainingAsString(); + assertEquals(input, SomeScheme.decode(SomeScheme.encode(input))); + } +} +``` + +## Implementation Jazzer's JUnit integration starts from the [`FuzzTest`](../src/main/java/com/code_intelligence/jazzer/junit/FuzzTest.java) annotation. As mentioned in the @@ -8,14 +355,14 @@ fuzzing is done. The main entrypoints for the actual integration code are found on `FuzzTest`: `@ArgumentsSource(FuzzTestArgumentsProvider.class)` and `@ExtendsWith(FuzzTestExtensions.class)`. Because these same files and functions are involved in two mostly separate sets of functionality, this will look at the -flow of the different methods involved in integrating with JUnit in fuzzing mode (when `JAZZER_FUZZ` is set to any -non-empty value) and in regression mode (when `JAZZER_FUZZ` is not set) separately. +flow of the different methods involved in integrating with JUnit in fuzzing mode (when `JAZZER_FUZZ` is set to a truthy +value (`true`, `1`, `yes`)) and in regression mode (when `JAZZER_FUZZ` is not set) separately. -# Fuzzing Flow +### Fuzzing Flow JUnit will call the following methods for each test marked with `FuzzTest`. -## `evaluateExecutionCondition` +#### `evaluateExecutionCondition` The first call to this test will determine if the test should be run at all. In fuzzing mode, we only allow one test to be run due to global state in libfuzzer that would mean multiple tests would interfere with each other. Jazzer will @@ -25,18 +372,18 @@ return that test as enabled. If this returns that a test is disabled, JUnit will not run the rest of these methods for this test and instead skip to the next one. -## `provideArguments` +#### `provideArguments` This will configure the fuzzing agent to set up code instrumentation, instantiate a `FuzzTestExecutor` and put it into JUnit's `extensionContext`, then create a stream of a single empty argument set. As the comment mentions, this is so that JUnit will actually execute the test but the argument will not be used. -## `evaluateExecutionCondition` +#### `evaluateExecutionCondition` This will be called for each argument set for the current test. In fuzzing mode, there will only be the single empty argument set which will be enabled. -## `interceptTestTemplateMethod` +#### `interceptTestTemplateMethod` This will call `invocation.skip()` which prevents invoking the test function with the default set of arguments `provideArguments` created. It will instead extract the `FuzzTestExecutor` instance from @@ -46,16 +393,16 @@ fuzzing. Crashes are saved in `resources//Inputs/` and results that are interesting to libfuzzer are saved in `.cifuzz-corpus`. -# Regression Flow +### Regression Flow Similar to fuzzing mode, JUnit will call these methods for each test marked with `FuzzTest`. -## `evaluateExecutionCondition` +#### `evaluateExecutionCondition` This checks if the given test should be run at all. In regression mode, all tests are run so this will always return enabled. -## `provideArguments` +#### `provideArguments` This will configure the fuzzing agent as in fuzzing mode, then gather test cases to run from the following sources: @@ -66,10 +413,11 @@ This will configure the fuzzing agent as in fuzzing mode, then gather test cases Prior to returning, the stream of test cases is put through `adaptInputsForFuzzTest` to turn the raw bytes from the files into the actual types to be given to the tested function. -### Resources Tests +##### Resources Tests The tests from the resources directory are gathered by `walkInputs`. This will look for inputs in two places: -- `resources//Inputs` - files found directly within this directory will be used as inputs for + +- `resources//Inputs` - files found directly within this directory will be used as inputs for any tests within this class. This allows for easy sharing of corpus entries. Jazzer does not automatically put entries here, instead a human will need to decide a finding should be shared and manually move it. - `resources//Inputs/` - files found in this directory and any directory @@ -78,34 +426,34 @@ The tests from the resources directory are gathered by `walkInputs`. This will l JUnit will use the file's name as the name of the test case for its reporting. It also accepts .jar files where it will search with the given directory in the jar. -### Corpus +##### Corpus The corpus kept in `.cifuzz-corpus//` holds any inputs that libfuzzer found worth saving and not necessarily just inputs that caused a crash. Jazzer is able to set the directory but the contents of these directories are managed entirely by libfuzzer. Unlike with the resources test inputs above, this will not look in `.cifuzz-corpus/` for shared test cases. This is a limitation of libfuzzer. -## `evaluateExecutionCondition` +#### `evaluateExecutionCondition` This will run once per argument set returned by `provideArguments` for this test. All argument sets will return as enabled. -## `interceptTestTemplateMethod` +#### `interceptTestTemplateMethod` This will run for each individual test case for each fuzz test and will mostly just allow the test function to proceed with the provided arguments. Prior to the call to the test, it will enable the agent's hooks and then disable them afterward. It will also check for and report any findings from Jazzer to JUnit. -# Diagrams +### Diagrams Below are two sequence diagrams for how JUnit calls `evaluateExecutionConditions` and `provideArguments` in fuzzing and regression mode. These diagrams ignore `interceptTestTemplateMethod` for brevity as its behavior and place in the sequence is more clear. -## Fuzzing +#### Fuzzing ![created on sequencediagram.org, load the svg in the editor to edit](./images/fuzzing-flow.svg) -## Regression +#### Regression ![created on sequencediagram.org, load the svg in the editor to edit](./images/regression-flow.svg) diff --git a/examples/BUILD.bazel b/examples/BUILD.bazel index f7ad00021..9e95def1a 100644 --- a/examples/BUILD.bazel +++ b/examples/BUILD.bazel @@ -1,8 +1,9 @@ -load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library") -load("@fmeum_rules_jni//jni:defs.bzl", "java_jni_library") +load("@rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library") +load("@rules_jni//jni:defs.bzl", "java_jni_library") load("//bazel:compat.bzl", "SKIP_ON_MACOS", "SKIP_ON_WINDOWS") load("//bazel:fuzz_target.bzl", "java_fuzz_target_test") load("//bazel:kotlin.bzl", "ktlint") +load(":labels.bzl", "LIBJPEG_TURBO_LABEL") package(default_testonly = True) @@ -82,7 +83,7 @@ java_fuzz_target_test( ], # The shell launcher generated by Jazzer is killed in CI, even with codesigning disabled on the # Java binary. This is not reproducible locally or with JDK 17. - tags = ["no-macos-x86_64-jdk8"], + tags = ["no-macos-arm64"], target_class = "com.example.ExampleFuzzerWithNative", # Crashes at runtime without an error message. target_compatible_with = SKIP_ON_WINDOWS, @@ -437,9 +438,10 @@ java_fuzz_target_test( ], fuzzer_args = [ "-rss_limit_mb=8196", - "--jvm_args=-Djava.library.path=../libjpeg_turbo", - "--ubsan", + "--jvm_args=-Djava.library.path=../" + LIBJPEG_TURBO_LABEL.workspace_name, + "--asan", ], + launcher_variant = "native", tags = ["manual"], target_class = "com.example.TurboJpegFuzzer", deps = [ diff --git a/examples/check_for_finding.sh b/examples/check_for_finding.sh index afe110c64..106019d3f 100755 --- a/examples/check_for_finding.sh +++ b/examples/check_for_finding.sh @@ -1,17 +1,12 @@ #!/usr/bin/env bash -# Copyright 2021 Code Intelligence GmbH # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Copyright 2024 Code Intelligence GmbH # -# http://www.apache.org/licenses/LICENSE-2.0 +# By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. +# +# The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt +# located in the root directory of the project. # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. # --- begin runfiles.bash initialization v2 --- # Copy-pasted from the Bazel Bash runfiles library v2. diff --git a/examples/junit-spring-web/build-and-run-tests.sh b/examples/junit-spring-web/build-and-run-tests.sh index 2c07863f3..ce166d88b 100755 --- a/examples/junit-spring-web/build-and-run-tests.sh +++ b/examples/junit-spring-web/build-and-run-tests.sh @@ -1,34 +1,24 @@ #!/usr/bin/env bash -# Copyright 2023 Code Intelligence GmbH # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Copyright 2024 Code Intelligence GmbH # -# http://www.apache.org/licenses/LICENSE-2.0 +# By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. +# +# The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt +# located in the root directory of the project. # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. # Development-only. This script builds the example project against the local version of Jazzer, # runs its unit and fuzz tests, and compares the results with expected results. set -e ( cd ../../ && - bazel build //deploy:all + bazel run //deploy:deploy_local ) -# Add locally-built Jazzer to the Maven repository -./mvnw install:install-file -Dfile=../../bazel-bin/deploy/jazzer-junit-project.jar -DpomFile=../../bazel-bin/deploy/jazzer-junit-pom.xml -./mvnw install:install-file -Dfile=../../bazel-bin/deploy/jazzer-project.jar -DpomFile=../../bazel-bin/deploy/jazzer-pom.xml -./mvnw install:install-file -Dfile=../../bazel-bin/deploy/jazzer-api-project.jar -DpomFile=../../bazel-bin/deploy/jazzer-api-pom.xml - ## Regression and unit tests echo "[SPRINGBOOT-JUNIT]: These unit and regression fuzz tests should pass" -./mvnw test -Dtest="JunitSpringWebApplicationTests#unitTestShouldPass+fuzzTestShouldPass" +./mvnw test -Dtest="JunitSpringWebApplicationTests#unitTestShouldPass+fuzzTestShouldPass" 2>&1 | tee /dev/tty | grep -v "==API STATS==" echo "[SPRINGBOOT-JUNIT]: This regression fuzz test should fail." # Temporarily disable exit on error. @@ -48,7 +38,7 @@ fi ## Fuzz tests echo "[SPRINGBOOT-JUNIT]: This fuzz test should pass" -JAZZER_FUZZ=1 ./mvnw test -Dtest="JunitSpringWebApplicationTests#fuzzTestShouldPass" +JAZZER_FUZZ=1 ./mvnw test -Dtest="JunitSpringWebApplicationTests#fuzzTestShouldPass" 2>&1 | tee /dev/tty | grep "==API STATS==" echo "[SPRINGBOOT-JUNIT]: This fuzz test should fail" set +e diff --git a/examples/junit-spring-web/pom.xml b/examples/junit-spring-web/pom.xml index 1643c5aeb..00625cc71 100644 --- a/examples/junit-spring-web/pom.xml +++ b/examples/junit-spring-web/pom.xml @@ -1,19 +1,12 @@ + ~ Copyright 2024 Code Intelligence GmbH + ~ + ~ By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + ~ + ~ The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + ~ located in the root directory of the project. + --> diff --git a/examples/junit-spring-web/src/main/java/com/example/JunitSpringWebApplication.java b/examples/junit-spring-web/src/main/java/com/example/JunitSpringWebApplication.java index 148c4d44a..4986a5a17 100644 --- a/examples/junit-spring-web/src/main/java/com/example/JunitSpringWebApplication.java +++ b/examples/junit-spring-web/src/main/java/com/example/JunitSpringWebApplication.java @@ -1,17 +1,10 @@ /* - * Copyright 2023 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.example; diff --git a/examples/junit-spring-web/src/test/java/com/example/JunitSpringWebApplicationTests.java b/examples/junit-spring-web/src/test/java/com/example/JunitSpringWebApplicationTests.java index 0b00a41d0..a018dff10 100644 --- a/examples/junit-spring-web/src/test/java/com/example/JunitSpringWebApplicationTests.java +++ b/examples/junit-spring-web/src/test/java/com/example/JunitSpringWebApplicationTests.java @@ -1,21 +1,16 @@ /* - * Copyright 2023 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.example; +import static com.code_intelligence.jazzer.junit.SpringFuzzTestHelper.apiTest; +import static com.code_intelligence.jazzer.junit.SpringFuzzTestHelper.statusIsNot5xxServerError; import static org.hamcrest.Matchers.containsString; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; @@ -30,11 +25,14 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrint; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.http.MediaType; import org.springframework.test.web.servlet.MockMvc; @WebMvcTest +@AutoConfigureMockMvc(print = MockMvcPrint.NONE) public class JunitSpringWebApplicationTests { private static final ObjectMapper mapper = new ObjectMapper(); @@ -53,12 +51,12 @@ public void afterEach() { @Test public void unitTestShouldPass() throws Exception { - mockMvc.perform(get("/hello").param("name", "Maven")); + apiTest(mockMvc, "/hello", get("/hello").param("name", "Maven")); } @Test public void unitTestShouldFail() throws Exception { - mockMvc.perform(get("/buggy-hello").param("name", "error")); + apiTest(mockMvc, "/buggy-hello", get("/buggy-hello").param("name", "error")); } @FuzzTest(maxDuration = "10s") @@ -68,7 +66,7 @@ public void fuzzTestShouldPass(FuzzedDataProvider data) throws Exception { } String name = data.consumeRemainingAsString(); - mockMvc.perform(get("/hello").param("name", name)); + apiTest(mockMvc, "/hello", get("/hello").param("name", name)); } @FuzzTest(maxDuration = "10s") @@ -78,8 +76,7 @@ public void fuzzTestShouldFail(FuzzedDataProvider data) throws Exception { } String name = data.consumeRemainingAsString(); - mockMvc - .perform(get("/buggy-hello").param("name", name)) + apiTest(mockMvc, "/buggy-hello", get("/buggy-hello").param("name", name)) .andExpect(content().string(containsString(name))); } @@ -91,11 +88,13 @@ public void fuzzTestWithDtoShouldFail(HelloRequest helloRequest) throws Exceptio Assumptions.assumeTrue( helloRequest != null && helloRequest.name != null && !helloRequest.name.isBlank()); - mockMvc - .perform( + apiTest( + mockMvc, + "/hello", post("/hello") .contentType(MediaType.APPLICATION_JSON) .content(mapper.writeValueAsString(helloRequest))) - .andExpect(content().string(containsString(helloRequest.name))); + .andExpect(content().string(containsString(helloRequest.name))) + .andExpect(statusIsNot5xxServerError()); } } diff --git a/examples/junit/pom.xml b/examples/junit/pom.xml index cd3bae940..d38a4e912 100644 --- a/examples/junit/pom.xml +++ b/examples/junit/pom.xml @@ -1,19 +1,12 @@ + ~ Copyright 2024 Code Intelligence GmbH + ~ + ~ By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + ~ + ~ The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + ~ located in the root directory of the project. + --> 5) { + throw new IllegalStateException("Unexpected input value provided"); + } + } + + @AfterAll + public static void checkInvocations() { + if (invocations != 6) { + throw new IllegalStateException("Invalid number of fuzz target invocations: " + invocations); + } + } +} diff --git a/examples/junit/src/test/java/com/example/DictionaryFuzzTests.java b/examples/junit/src/test/java/com/example/DictionaryFuzzTests.java index 5a6672d30..17acd7de7 100644 --- a/examples/junit/src/test/java/com/example/DictionaryFuzzTests.java +++ b/examples/junit/src/test/java/com/example/DictionaryFuzzTests.java @@ -1,17 +1,10 @@ /* - * Copyright 2023 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.example; diff --git a/examples/junit/src/test/java/com/example/DirectoryInputsFuzzTest.java b/examples/junit/src/test/java/com/example/DirectoryInputsFuzzTest.java index 1d1ce2c4f..f1f15241e 100644 --- a/examples/junit/src/test/java/com/example/DirectoryInputsFuzzTest.java +++ b/examples/junit/src/test/java/com/example/DirectoryInputsFuzzTest.java @@ -1,16 +1,11 @@ -// Copyright 2022 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example; diff --git a/examples/junit/src/test/java/com/example/HermeticInstrumentationFuzzTest.java b/examples/junit/src/test/java/com/example/HermeticInstrumentationFuzzTest.java index 97e038114..8438f00a8 100644 --- a/examples/junit/src/test/java/com/example/HermeticInstrumentationFuzzTest.java +++ b/examples/junit/src/test/java/com/example/HermeticInstrumentationFuzzTest.java @@ -1,17 +1,10 @@ /* - * Copyright 2022 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.example; diff --git a/examples/junit/src/test/java/com/example/InvalidFuzzTests.java b/examples/junit/src/test/java/com/example/InvalidFuzzTests.java index db16108b9..ade76bb4f 100644 --- a/examples/junit/src/test/java/com/example/InvalidFuzzTests.java +++ b/examples/junit/src/test/java/com/example/InvalidFuzzTests.java @@ -1,16 +1,11 @@ -// Copyright 2022 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example; @@ -23,7 +18,7 @@ class InvalidFuzzTests { void invalidParameterCountFuzz() {} @FuzzTest - void parameterResolverFuzz(FuzzedDataProvider data, TestInfo testInfo) { + void invalidParameterResolverFuzz(FuzzedDataProvider data, TestInfo testInfo) { throw new RuntimeException(testInfo.getDisplayName()); } } diff --git a/examples/junit/src/test/java/com/example/JavaBinarySeedFuzzTest.java b/examples/junit/src/test/java/com/example/JavaBinarySeedFuzzTest.java index 70b35352f..2ba65b54a 100644 --- a/examples/junit/src/test/java/com/example/JavaBinarySeedFuzzTest.java +++ b/examples/junit/src/test/java/com/example/JavaBinarySeedFuzzTest.java @@ -1,17 +1,10 @@ /* - * Copyright 2023 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.example; diff --git a/examples/junit/src/test/java/com/example/JavaSeedFuzzTest.java b/examples/junit/src/test/java/com/example/JavaSeedFuzzTest.java index 552dbcadf..b8b7c7b7c 100644 --- a/examples/junit/src/test/java/com/example/JavaSeedFuzzTest.java +++ b/examples/junit/src/test/java/com/example/JavaSeedFuzzTest.java @@ -1,17 +1,10 @@ /* - * Copyright 2023 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.example; diff --git a/examples/junit/src/test/java/com/example/KeepGoingFuzzTest.java b/examples/junit/src/test/java/com/example/KeepGoingFuzzTest.java index ad5d09d2f..bb14e45b5 100644 --- a/examples/junit/src/test/java/com/example/KeepGoingFuzzTest.java +++ b/examples/junit/src/test/java/com/example/KeepGoingFuzzTest.java @@ -1,17 +1,10 @@ /* - * Copyright 2023 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.example; diff --git a/examples/junit/src/test/java/com/example/LifecycleRecordingTestBase.java b/examples/junit/src/test/java/com/example/LifecycleRecordingTestBase.java index 19641b7e8..30f6f1b02 100644 --- a/examples/junit/src/test/java/com/example/LifecycleRecordingTestBase.java +++ b/examples/junit/src/test/java/com/example/LifecycleRecordingTestBase.java @@ -1,23 +1,15 @@ /* - * Copyright 2023 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.example; import static com.google.common.truth.Truth.assertThat; -import static com.google.common.truth.Truth8.assertThat; import static java.util.stream.Collectors.collectingAndThen; import static java.util.stream.Collectors.toList; diff --git a/examples/junit/src/test/java/com/example/MockitoFuzzTest.java b/examples/junit/src/test/java/com/example/MockitoFuzzTest.java index c3c2e973b..729dfc55c 100644 --- a/examples/junit/src/test/java/com/example/MockitoFuzzTest.java +++ b/examples/junit/src/test/java/com/example/MockitoFuzzTest.java @@ -1,17 +1,10 @@ /* - * Copyright 2023 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.example; diff --git a/examples/junit/src/test/java/com/example/MutatorFuzzTest.java b/examples/junit/src/test/java/com/example/MutatorFuzzTest.java index 741dc8d3a..c0ac7f54f 100644 --- a/examples/junit/src/test/java/com/example/MutatorFuzzTest.java +++ b/examples/junit/src/test/java/com/example/MutatorFuzzTest.java @@ -1,17 +1,10 @@ /* - * Copyright 2023 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.example; diff --git a/examples/junit/src/test/java/com/example/PerExecutionLifecycleFuzzTest.java b/examples/junit/src/test/java/com/example/PerExecutionLifecycleFuzzTest.java index 642452a1c..712becd0a 100644 --- a/examples/junit/src/test/java/com/example/PerExecutionLifecycleFuzzTest.java +++ b/examples/junit/src/test/java/com/example/PerExecutionLifecycleFuzzTest.java @@ -1,17 +1,10 @@ /* - * Copyright 2022 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.example; diff --git a/examples/junit/src/test/java/com/example/PerExecutionLifecycleWithFindingFuzzTest.java b/examples/junit/src/test/java/com/example/PerExecutionLifecycleWithFindingFuzzTest.java index b2b3979aa..79ecf5824 100644 --- a/examples/junit/src/test/java/com/example/PerExecutionLifecycleWithFindingFuzzTest.java +++ b/examples/junit/src/test/java/com/example/PerExecutionLifecycleWithFindingFuzzTest.java @@ -1,17 +1,10 @@ /* - * Copyright 2022 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.example; diff --git a/examples/junit/src/test/java/com/example/PerTestLifecycleFuzzTest.java b/examples/junit/src/test/java/com/example/PerTestLifecycleFuzzTest.java index 23ae36b9c..af1bec6c5 100644 --- a/examples/junit/src/test/java/com/example/PerTestLifecycleFuzzTest.java +++ b/examples/junit/src/test/java/com/example/PerTestLifecycleFuzzTest.java @@ -1,17 +1,10 @@ /* - * Copyright 2022 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.example; diff --git a/examples/junit/src/test/java/com/example/TestSuccessfulException.java b/examples/junit/src/test/java/com/example/TestSuccessfulException.java index 1519af284..cc60eb09d 100644 --- a/examples/junit/src/test/java/com/example/TestSuccessfulException.java +++ b/examples/junit/src/test/java/com/example/TestSuccessfulException.java @@ -1,17 +1,10 @@ /* - * Copyright 2023 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.example; diff --git a/examples/junit/src/test/java/com/example/ThrowingFuzzTest.java b/examples/junit/src/test/java/com/example/ThrowingFuzzTest.java index eabfb85d2..f65947f91 100644 --- a/examples/junit/src/test/java/com/example/ThrowingFuzzTest.java +++ b/examples/junit/src/test/java/com/example/ThrowingFuzzTest.java @@ -1,16 +1,11 @@ -// Copyright 2023 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example; diff --git a/examples/junit/src/test/java/com/example/ValidFuzzTests.java b/examples/junit/src/test/java/com/example/ValidFuzzTests.java index 465d3b7e3..12247cca9 100644 --- a/examples/junit/src/test/java/com/example/ValidFuzzTests.java +++ b/examples/junit/src/test/java/com/example/ValidFuzzTests.java @@ -1,16 +1,11 @@ -// Copyright 2022 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example; diff --git a/examples/junit/src/test/java/com/example/ValueProfileFuzzTest.java b/examples/junit/src/test/java/com/example/ValueProfileFuzzTest.java index e69562f35..b4aa9eb83 100644 --- a/examples/junit/src/test/java/com/example/ValueProfileFuzzTest.java +++ b/examples/junit/src/test/java/com/example/ValueProfileFuzzTest.java @@ -1,17 +1,10 @@ /* - * Copyright 2022 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.example; diff --git a/examples/junit/src/test/resources/BUILD.bazel b/examples/junit/src/test/resources/BUILD.bazel index 7189b7ff3..878779d90 100644 --- a/examples/junit/src/test/resources/BUILD.bazel +++ b/examples/junit/src/test/resources/BUILD.bazel @@ -15,3 +15,12 @@ filegroup( srcs = ["com/example/MutatorFuzzTestInputs"], visibility = ["//visibility:public"], ) + +filegroup( + name = "additional_seed_directories", + srcs = [ + "additional/dir1", + "additional/dir2", + ], + visibility = ["//examples/junit/src/test/java/com/example:__pkg__"], +) diff --git a/examples/junit/src/test/resources/additional/dir1/seed4 b/examples/junit/src/test/resources/additional/dir1/seed4 new file mode 100644 index 000000000..eb529631c Binary files /dev/null and b/examples/junit/src/test/resources/additional/dir1/seed4 differ diff --git a/examples/junit/src/test/resources/additional/dir2/seed5 b/examples/junit/src/test/resources/additional/dir2/seed5 new file mode 100644 index 000000000..62f3e6fff Binary files /dev/null and b/examples/junit/src/test/resources/additional/dir2/seed5 differ diff --git a/examples/junit/src/test/resources/com/example/AutofuzzWithCorpusFuzzTestInputs/autofuzzWithCorpus/crashing_input b/examples/junit/src/test/resources/com/example/AutofuzzWithCorpusFuzzTestInputs/autofuzzWithCorpus/crashing_input deleted file mode 100644 index 2c92661f7..000000000 Binary files a/examples/junit/src/test/resources/com/example/AutofuzzWithCorpusFuzzTestInputs/autofuzzWithCorpus/crashing_input and /dev/null differ diff --git a/examples/labels.bzl b/examples/labels.bzl new file mode 100644 index 000000000..b5fdfa9e8 --- /dev/null +++ b/examples/labels.bzl @@ -0,0 +1,10 @@ +# +# Copyright 2024 Code Intelligence GmbH +# +# By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. +# +# The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt +# located in the root directory of the project. +# + +LIBJPEG_TURBO_LABEL = Label("@libjpeg_turbo//:turbojpeg_native") diff --git a/examples/src/main/java/com/example/BatikTranscoderFuzzer.java b/examples/src/main/java/com/example/BatikTranscoderFuzzer.java index 2e96afc96..6421a19fa 100644 --- a/examples/src/main/java/com/example/BatikTranscoderFuzzer.java +++ b/examples/src/main/java/com/example/BatikTranscoderFuzzer.java @@ -1,16 +1,11 @@ -// Copyright 2023 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example; diff --git a/examples/src/main/java/com/example/CommonsTextFuzzer.java b/examples/src/main/java/com/example/CommonsTextFuzzer.java index 40807461e..1de28a414 100644 --- a/examples/src/main/java/com/example/CommonsTextFuzzer.java +++ b/examples/src/main/java/com/example/CommonsTextFuzzer.java @@ -1,16 +1,13 @@ -// Copyright 2023 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + * + * This file also contains code licensed under Apache2 license. + */ package com.example; diff --git a/examples/src/main/java/com/example/ExampleFuzzer.java b/examples/src/main/java/com/example/ExampleFuzzer.java index 6cad59554..537609fc3 100644 --- a/examples/src/main/java/com/example/ExampleFuzzer.java +++ b/examples/src/main/java/com/example/ExampleFuzzer.java @@ -1,16 +1,11 @@ -// Copyright 2021 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example; diff --git a/examples/src/main/java/com/example/ExampleFuzzerHooks.java b/examples/src/main/java/com/example/ExampleFuzzerHooks.java index 15ab932aa..e0f1308a4 100644 --- a/examples/src/main/java/com/example/ExampleFuzzerHooks.java +++ b/examples/src/main/java/com/example/ExampleFuzzerHooks.java @@ -1,16 +1,11 @@ -// Copyright 2021 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example; diff --git a/examples/src/main/java/com/example/ExampleFuzzerWithNative.java b/examples/src/main/java/com/example/ExampleFuzzerWithNative.java index a9fbe29e7..c6bfca9f9 100644 --- a/examples/src/main/java/com/example/ExampleFuzzerWithNative.java +++ b/examples/src/main/java/com/example/ExampleFuzzerWithNative.java @@ -1,16 +1,11 @@ -// Copyright 2021 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example; diff --git a/examples/src/main/java/com/example/ExampleKotlinFuzzer.kt b/examples/src/main/java/com/example/ExampleKotlinFuzzer.kt index eb1aea8fb..6de7833c1 100644 --- a/examples/src/main/java/com/example/ExampleKotlinFuzzer.kt +++ b/examples/src/main/java/com/example/ExampleKotlinFuzzer.kt @@ -1,16 +1,11 @@ -// Copyright 2022 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example diff --git a/examples/src/main/java/com/example/ExampleKotlinValueProfileFuzzer.kt b/examples/src/main/java/com/example/ExampleKotlinValueProfileFuzzer.kt index c86824e8a..917328bb2 100644 --- a/examples/src/main/java/com/example/ExampleKotlinValueProfileFuzzer.kt +++ b/examples/src/main/java/com/example/ExampleKotlinValueProfileFuzzer.kt @@ -1,16 +1,11 @@ -// Copyright 2023 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example diff --git a/examples/src/main/java/com/example/ExampleOutOfMemoryFuzzer.java b/examples/src/main/java/com/example/ExampleOutOfMemoryFuzzer.java index 494bff160..d0fd472f7 100644 --- a/examples/src/main/java/com/example/ExampleOutOfMemoryFuzzer.java +++ b/examples/src/main/java/com/example/ExampleOutOfMemoryFuzzer.java @@ -1,16 +1,11 @@ -// Copyright 2021 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example; diff --git a/examples/src/main/java/com/example/ExamplePathTraversalFuzzer.java b/examples/src/main/java/com/example/ExamplePathTraversalFuzzer.java index da338d676..9de310262 100644 --- a/examples/src/main/java/com/example/ExamplePathTraversalFuzzer.java +++ b/examples/src/main/java/com/example/ExamplePathTraversalFuzzer.java @@ -1,16 +1,11 @@ -// Copyright 2021 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example; diff --git a/examples/src/main/java/com/example/ExamplePathTraversalFuzzerHooks.java b/examples/src/main/java/com/example/ExamplePathTraversalFuzzerHooks.java index 0d43cc5bc..2cd418ce3 100644 --- a/examples/src/main/java/com/example/ExamplePathTraversalFuzzerHooks.java +++ b/examples/src/main/java/com/example/ExamplePathTraversalFuzzerHooks.java @@ -1,16 +1,11 @@ -// Copyright 2021 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example; diff --git a/examples/src/main/java/com/example/ExampleStackOverflowFuzzer.java b/examples/src/main/java/com/example/ExampleStackOverflowFuzzer.java index 47166af43..f4107b313 100644 --- a/examples/src/main/java/com/example/ExampleStackOverflowFuzzer.java +++ b/examples/src/main/java/com/example/ExampleStackOverflowFuzzer.java @@ -1,16 +1,11 @@ -// Copyright 2021 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example; diff --git a/examples/src/main/java/com/example/ExampleValueProfileFuzzer.java b/examples/src/main/java/com/example/ExampleValueProfileFuzzer.java index 2fa18b2e6..94723c781 100644 --- a/examples/src/main/java/com/example/ExampleValueProfileFuzzer.java +++ b/examples/src/main/java/com/example/ExampleValueProfileFuzzer.java @@ -1,16 +1,11 @@ -// Copyright 2021 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example; diff --git a/examples/src/main/java/com/example/FastJsonFuzzer.java b/examples/src/main/java/com/example/FastJsonFuzzer.java index 2e5d47977..091972ee6 100644 --- a/examples/src/main/java/com/example/FastJsonFuzzer.java +++ b/examples/src/main/java/com/example/FastJsonFuzzer.java @@ -1,16 +1,11 @@ -// Copyright 2021 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example; diff --git a/examples/src/main/java/com/example/GifImageParserFuzzer.java b/examples/src/main/java/com/example/GifImageParserFuzzer.java index ab7de9073..974384180 100644 --- a/examples/src/main/java/com/example/GifImageParserFuzzer.java +++ b/examples/src/main/java/com/example/GifImageParserFuzzer.java @@ -1,16 +1,11 @@ -// Copyright 2021 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example; diff --git a/examples/src/main/java/com/example/JacksonCborFuzzer.java b/examples/src/main/java/com/example/JacksonCborFuzzer.java index 902c1d96f..c4671b286 100644 --- a/examples/src/main/java/com/example/JacksonCborFuzzer.java +++ b/examples/src/main/java/com/example/JacksonCborFuzzer.java @@ -1,16 +1,11 @@ -// Copyright 2021 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example; diff --git a/examples/src/main/java/com/example/JpegImageParserFuzzer.java b/examples/src/main/java/com/example/JpegImageParserFuzzer.java index ba3e7c81f..592f0e51e 100644 --- a/examples/src/main/java/com/example/JpegImageParserFuzzer.java +++ b/examples/src/main/java/com/example/JpegImageParserFuzzer.java @@ -1,16 +1,11 @@ -// Copyright 2021 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example; diff --git a/examples/src/main/java/com/example/JsonSanitizerCrashFuzzer.java b/examples/src/main/java/com/example/JsonSanitizerCrashFuzzer.java index 05ac46117..839364086 100644 --- a/examples/src/main/java/com/example/JsonSanitizerCrashFuzzer.java +++ b/examples/src/main/java/com/example/JsonSanitizerCrashFuzzer.java @@ -1,16 +1,11 @@ -// Copyright 2021 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example; diff --git a/examples/src/main/java/com/example/JsonSanitizerDenylistFuzzer.java b/examples/src/main/java/com/example/JsonSanitizerDenylistFuzzer.java index e715b1d9c..955e3c91a 100644 --- a/examples/src/main/java/com/example/JsonSanitizerDenylistFuzzer.java +++ b/examples/src/main/java/com/example/JsonSanitizerDenylistFuzzer.java @@ -1,16 +1,11 @@ -// Copyright 2021 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example; diff --git a/examples/src/main/java/com/example/JsonSanitizerIdempotenceFuzzer.java b/examples/src/main/java/com/example/JsonSanitizerIdempotenceFuzzer.java index 111d3de29..f8e54b487 100644 --- a/examples/src/main/java/com/example/JsonSanitizerIdempotenceFuzzer.java +++ b/examples/src/main/java/com/example/JsonSanitizerIdempotenceFuzzer.java @@ -1,16 +1,11 @@ -// Copyright 2021 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example; diff --git a/examples/src/main/java/com/example/JsonSanitizerValidJsonFuzzer.java b/examples/src/main/java/com/example/JsonSanitizerValidJsonFuzzer.java index 2d270966a..75f2b85c8 100644 --- a/examples/src/main/java/com/example/JsonSanitizerValidJsonFuzzer.java +++ b/examples/src/main/java/com/example/JsonSanitizerValidJsonFuzzer.java @@ -1,16 +1,11 @@ -// Copyright 2021 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example; diff --git a/examples/src/main/java/com/example/KlaxonFuzzer.kt b/examples/src/main/java/com/example/KlaxonFuzzer.kt index 39216eeac..46da577f0 100644 --- a/examples/src/main/java/com/example/KlaxonFuzzer.kt +++ b/examples/src/main/java/com/example/KlaxonFuzzer.kt @@ -1,16 +1,11 @@ -// Copyright 2021 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example diff --git a/examples/src/main/java/com/example/Log4jFuzzer.java b/examples/src/main/java/com/example/Log4jFuzzer.java index eb53b4590..ee4b62b8c 100644 --- a/examples/src/main/java/com/example/Log4jFuzzer.java +++ b/examples/src/main/java/com/example/Log4jFuzzer.java @@ -1,16 +1,11 @@ -// Copyright 2021 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example; diff --git a/examples/src/main/java/com/example/MazeFuzzer.java b/examples/src/main/java/com/example/MazeFuzzer.java index fb225f0c0..e4491bb2d 100644 --- a/examples/src/main/java/com/example/MazeFuzzer.java +++ b/examples/src/main/java/com/example/MazeFuzzer.java @@ -1,16 +1,11 @@ -// Copyright 2022 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example; diff --git a/examples/src/main/java/com/example/TiffImageParserFuzzer.java b/examples/src/main/java/com/example/TiffImageParserFuzzer.java index 5fa1af2d6..77f55aec5 100644 --- a/examples/src/main/java/com/example/TiffImageParserFuzzer.java +++ b/examples/src/main/java/com/example/TiffImageParserFuzzer.java @@ -1,16 +1,11 @@ -// Copyright 2021 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example; diff --git a/examples/src/main/java/com/example/TurboJpegFuzzer.java b/examples/src/main/java/com/example/TurboJpegFuzzer.java index e10af0105..e82a4575c 100644 --- a/examples/src/main/java/com/example/TurboJpegFuzzer.java +++ b/examples/src/main/java/com/example/TurboJpegFuzzer.java @@ -1,16 +1,11 @@ -// Copyright 2021 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example; diff --git a/examples/src/main/native/com/example/BUILD.bazel b/examples/src/main/native/com/example/BUILD.bazel index c72f4842d..2b926f678 100644 --- a/examples/src/main/native/com/example/BUILD.bazel +++ b/examples/src/main/native/com/example/BUILD.bazel @@ -1,4 +1,4 @@ -load("@fmeum_rules_jni//jni:defs.bzl", "cc_jni_library") +load("@rules_jni//jni:defs.bzl", "cc_jni_library") package(default_testonly = True) diff --git a/examples/src/main/native/com/example/com_example_ExampleFuzzerWithNative.cpp b/examples/src/main/native/com/example/com_example_ExampleFuzzerWithNative.cpp index 971ea7400..8df3c7a23 100644 --- a/examples/src/main/native/com/example/com_example_ExampleFuzzerWithNative.cpp +++ b/examples/src/main/native/com/example/com_example_ExampleFuzzerWithNative.cpp @@ -1,16 +1,10 @@ -// Copyright 2021 Code Intelligence GmbH +// Copyright 2024 Code Intelligence GmbH // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// By downloading, you agree to the Code Intelligence Jazzer Terms and +// Conditions. // -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// The Code Intelligence Jazzer Terms and Conditions are provided in +// LICENSE-JAZZER.txt located in the root directory of the project. #include "com_example_ExampleFuzzerWithNative.h" diff --git a/format.sh b/format.sh index 1c8073af0..5b864f8d9 100755 --- a/format.sh +++ b/format.sh @@ -1,17 +1,12 @@ #!/usr/bin/env bash -# Copyright 2023 Code Intelligence GmbH # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Copyright 2024 Code Intelligence GmbH # -# http://www.apache.org/licenses/LICENSE-2.0 +# By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. +# +# The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt +# located in the root directory of the project. # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. set -euo pipefail diff --git a/init.bzl b/init.bzl deleted file mode 100644 index 6b260b190..000000000 --- a/init.bzl +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright 2021 Code Intelligence GmbH -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Dependency initialization utilities.""" - -load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") -load("@com_github_johnynek_bazel_jar_jar//:jar_jar.bzl", "jar_jar_repositories") -load("@io_bazel_rules_kotlin//kotlin:dependencies.bzl", "kt_download_local_dev_dependencies") -load("@io_bazel_rules_kotlin//kotlin:repositories.bzl", "kotlin_repositories") -load("@fmeum_rules_jni//jni:repositories.bzl", "rules_jni_dependencies") -load("@build_bazel_apple_support//lib:repositories.bzl", "apple_support_dependencies") - -def jazzer_init(): - bazel_skylib_workspace() - kt_download_local_dev_dependencies() - kotlin_repositories() - native.register_toolchains("@jazzer//bazel/toolchains:kotlin_toolchain") - jar_jar_repositories() - rules_jni_dependencies() - apple_support_dependencies() diff --git a/launcher/BUILD.bazel b/launcher/BUILD.bazel index 0a80a45f4..b92070dee 100644 --- a/launcher/BUILD.bazel +++ b/launcher/BUILD.bazel @@ -1,14 +1,14 @@ -load("@build_bazel_apple_support//rules:universal_binary.bzl", "universal_binary") +load("@apple_support//rules:universal_binary.bzl", "universal_binary") cc_library( name = "jazzer_main", srcs = ["jazzer_main.cpp"], deps = [ ":jvm_tooling_lib", - "@com_google_absl//absl/strings", + "@abseil-cpp//absl/strings", ] + select({ "@platforms//os:android": [], - "//conditions:default": ["@fmeum_rules_jni//jni:libjvm"], + "//conditions:default": ["@rules_jni//jni:libjvm"], }), ) @@ -24,10 +24,10 @@ cc_library( "//conditions:default": [], }), deps = [ + "@abseil-cpp//absl/strings", + "@abseil-cpp//absl/strings:str_format", "@bazel_tools//tools/cpp/runfiles", - "@com_google_absl//absl/strings", - "@com_google_absl//absl/strings:str_format", - "@fmeum_rules_jni//jni", + "@rules_jni//jni", ], ) @@ -95,7 +95,7 @@ cc_library( srcs = ["test_main.cpp"], linkstatic = True, deps = [ - "@fmeum_rules_jni//jni:libjvm", "@googletest//:gtest", + "@rules_jni//jni:libjvm", ], ) diff --git a/launcher/fuzzed_data_provider_test.cpp b/launcher/fuzzed_data_provider_test.cpp index 9907b75e2..569d17f2d 100644 --- a/launcher/fuzzed_data_provider_test.cpp +++ b/launcher/fuzzed_data_provider_test.cpp @@ -1,16 +1,12 @@ -// Copyright 2021 Code Intelligence GmbH +// Copyright 2024 Code Intelligence GmbH // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// By downloading, you agree to the Code Intelligence Jazzer Terms and +// Conditions. // -// http://www.apache.org/licenses/LICENSE-2.0 +// The Code Intelligence Jazzer Terms and Conditions are provided in +// LICENSE-JAZZER.txt located in the root directory of the project. // -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// This file also contains code licensed under Apache2 license. #include #include diff --git a/launcher/jazzer_main.cpp b/launcher/jazzer_main.cpp index 8e63f5ecf..701f1716b 100644 --- a/launcher/jazzer_main.cpp +++ b/launcher/jazzer_main.cpp @@ -1,16 +1,10 @@ -// Copyright 2021 Code Intelligence GmbH +// Copyright 2024 Code Intelligence GmbH // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// By downloading, you agree to the Code Intelligence Jazzer Terms and +// Conditions. // -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// The Code Intelligence Jazzer Terms and Conditions are provided in +// LICENSE-JAZZER.txt located in the root directory of the project. /* * Jazzer's native main function, which starts a JVM suitably configured for diff --git a/launcher/jvm_tooling.cpp b/launcher/jvm_tooling.cpp index e371fc255..b3e6e2151 100644 --- a/launcher/jvm_tooling.cpp +++ b/launcher/jvm_tooling.cpp @@ -1,16 +1,12 @@ -// Copyright 2021 Code Intelligence GmbH +// Copyright 2024 Code Intelligence GmbH // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// By downloading, you agree to the Code Intelligence Jazzer Terms and +// Conditions. // -// http://www.apache.org/licenses/LICENSE-2.0 +// The Code Intelligence Jazzer Terms and Conditions are provided in +// LICENSE-JAZZER.txt located in the root directory of the project. // -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// This file also contains code licensed under Apache2 license. #include "jvm_tooling.h" diff --git a/launcher/jvm_tooling.h b/launcher/jvm_tooling.h index d7129a130..8e593ee7b 100644 --- a/launcher/jvm_tooling.h +++ b/launcher/jvm_tooling.h @@ -1,18 +1,10 @@ -/* - * Copyright 2021 Code Intelligence GmbH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2024 Code Intelligence GmbH +// +// By downloading, you agree to the Code Intelligence Jazzer Terms and +// Conditions. +// +// The Code Intelligence Jazzer Terms and Conditions are provided in +// LICENSE-JAZZER.txt located in the root directory of the project. #pragma once diff --git a/launcher/jvm_tooling_test.cpp b/launcher/jvm_tooling_test.cpp index 2a70dcb99..2043fa24b 100644 --- a/launcher/jvm_tooling_test.cpp +++ b/launcher/jvm_tooling_test.cpp @@ -1,16 +1,12 @@ -// Copyright 2021 Code Intelligence GmbH +// Copyright 2024 Code Intelligence GmbH // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// By downloading, you agree to the Code Intelligence Jazzer Terms and +// Conditions. // -// http://www.apache.org/licenses/LICENSE-2.0 +// The Code Intelligence Jazzer Terms and Conditions are provided in +// LICENSE-JAZZER.txt located in the root directory of the project. // -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// This file also contains code licensed under Apache2 license. #include "jvm_tooling.h" diff --git a/launcher/test_main.cpp b/launcher/test_main.cpp index cd7c8e816..757b9937e 100644 --- a/launcher/test_main.cpp +++ b/launcher/test_main.cpp @@ -1,16 +1,10 @@ -// Copyright 2021 Code Intelligence GmbH +// Copyright 2024 Code Intelligence GmbH // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// By downloading, you agree to the Code Intelligence Jazzer Terms and +// Conditions. // -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// The Code Intelligence Jazzer Terms and Conditions are provided in +// LICENSE-JAZZER.txt located in the root directory of the project. #include diff --git a/launcher/testdata/test/ModifiedUtf8Encoder.java b/launcher/testdata/test/ModifiedUtf8Encoder.java index 3195a7dd9..6fe4d854f 100644 --- a/launcher/testdata/test/ModifiedUtf8Encoder.java +++ b/launcher/testdata/test/ModifiedUtf8Encoder.java @@ -1,16 +1,11 @@ -// Copyright 2021 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package test; diff --git a/launcher/testdata/test/PropertyPrinter.java b/launcher/testdata/test/PropertyPrinter.java index 97345acd8..69958ca98 100644 --- a/launcher/testdata/test/PropertyPrinter.java +++ b/launcher/testdata/test/PropertyPrinter.java @@ -1,16 +1,11 @@ -// Copyright 2021 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package test; diff --git a/maven.bzl b/maven.bzl deleted file mode 100644 index 2cdab1480..000000000 --- a/maven.bzl +++ /dev/null @@ -1,78 +0,0 @@ -# Copyright 2021 Code Intelligence GmbH -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -load("@rules_jvm_external//:specs.bzl", "maven") - -# keep sorted -MAVEN_ARTIFACTS = [ - "org.junit.jupiter:junit-jupiter-api:5.9.0", - "org.junit.jupiter:junit-jupiter-engine:5.9.0", - "org.junit.jupiter:junit-jupiter-params:5.9.0", - "org.junit.platform:junit-platform-commons:jar:1.9.0", - "org.junit.platform:junit-platform-engine:jar:1.9.0", - "org.junit.platform:junit-platform-launcher:jar:1.9.0", - "org.opentest4j:opentest4j:1.2.0", -] - -# **WARNING**: These Maven dependencies may have known vulnerabilities that Jazzer is supposed to -# find and are only used in tests. DO NOT USE. -TEST_MAVEN_ARTIFACTS = [ - maven.artifact(testonly = True, *coordinate.split(":")) - for coordinate in [ - # keep sorted - "com.alibaba:fastjson:1.2.75", - "com.beust:klaxon:5.5", - "com.fasterxml.jackson.core:jackson-core:2.12.1", - "com.fasterxml.jackson.core:jackson-databind:2.12.1", - "com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:2.12.1", - "com.google.code.gson:gson:2.8.6", - "com.google.truth.extensions:truth-java8-extension:1.1.3", - "com.google.truth.extensions:truth-liteproto-extension:1.1.3", - "com.google.truth.extensions:truth-proto-extension:1.1.3", - "com.google.truth:truth:1.1.3", - "com.h2database:h2:2.1.212", - "com.mikesamuel:json-sanitizer:1.2.1", - "com.unboundid:unboundid-ldapsdk:6.0.3", - "javax.el:javax.el-api:3.0.1-b06", - "javax.validation:validation-api:2.0.1.Final", - "javax.xml.bind:jaxb-api:2.3.1", - "junit:junit:4.12", - "org.apache.commons:commons-imaging:1.0-alpha2", - "org.apache.commons:commons-text:1.9", - "org.apache.logging.log4j:log4j-api:2.14.1", - "org.apache.logging.log4j:log4j-core:2.14.1", - "org.apache.xmlgraphics:batik-anim:1.14", - "org.apache.xmlgraphics:batik-awt-util:1.14", - "org.apache.xmlgraphics:batik-bridge:1.14", - "org.apache.xmlgraphics:batik-css:1.14", - "org.apache.xmlgraphics:batik-dom:1.14", - "org.apache.xmlgraphics:batik-gvt:1.14", - "org.apache.xmlgraphics:batik-parser:1.14", - "org.apache.xmlgraphics:batik-script:1.14", - "org.apache.xmlgraphics:batik-svg-dom:1.14", - "org.apache.xmlgraphics:batik-svggen:1.14", - "org.apache.xmlgraphics:batik-transcoder:1.14", - "org.apache.xmlgraphics:batik-util:1.14", - "org.apache.xmlgraphics:batik-xml:1.14", - "org.assertj:assertj-core:3.23.1", - "org.glassfish:javax.el:3.0.1-b06", - "org.hibernate:hibernate-validator:5.2.4.Final", - "org.jacoco:org.jacoco.core:0.8.8", - "org.junit.platform:junit-platform-reporting:1.8.2", - "org.junit.platform:junit-platform-testkit:1.8.2", - "org.mockito:mockito-core:5.4.0", - "org.openjdk.jmh:jmh-core:1.34", - "org.openjdk.jmh:jmh-generator-annprocess:1.34", - ] -] diff --git a/maven_install.json b/maven_install.json old mode 100644 new mode 100755 index 25f4fd112..be61994e6 --- a/maven_install.json +++ b/maven_install.json @@ -1,9 +1,14 @@ { "__AUTOGENERATED_FILE_DO_NOT_MODIFY_THIS_FILE_MANUALLY": "THERE_IS_NO_DATA_ONLY_ZUUL", - "__INPUT_ARTIFACTS_HASH": 68877449, - "__RESOLVED_ARTIFACTS_HASH": 1123237997, + "__INPUT_ARTIFACTS_HASH": 1598895504, + "__RESOLVED_ARTIFACTS_HASH": 564748184, "conflict_resolution": { - "junit:junit:4.12": "junit:junit:4.13.2" + "com.google.code.gson:gson:2.8.6": "com.google.code.gson:gson:2.8.9", + "com.google.errorprone:error_prone_annotations:2.3.2": "com.google.errorprone:error_prone_annotations:2.26.1", + "com.google.guava:guava:31.1-jre": "com.google.guava:guava:33.0.0-android", + "com.google.j2objc:j2objc-annotations:1.3": "com.google.j2objc:j2objc-annotations:2.8", + "com.google.truth:truth:1.1.2": "com.google.truth:truth:1.4.2", + "org.mockito:mockito-core:4.3.1": "org.mockito:mockito-core:5.11.0" }, "artifacts": { "com.alibaba:fastjson": { @@ -48,11 +53,17 @@ }, "version": "1.1.0" }, + "com.github.jsqlparser:jsqlparser": { + "shasums": { + "jar": "54bd92662fbc084f4fc6d46728d066841cac3a8a2fae4a82925c9caeac19f754" + }, + "version": "4.9" + }, "com.google.auto.value:auto-value-annotations": { "shasums": { - "jar": "37ec09b47d7ed35a99d13927db5c86fc9071f620f943ead5d757144698310852" + "jar": "e1c45e6beadaef9797cb0d9afd5a45621ad061cd8632012f85582853a3887825" }, - "version": "1.8.1" + "version": "1.10.4" }, "com.google.code.findbugs:jsr305": { "shasums": { @@ -62,27 +73,39 @@ }, "com.google.code.gson:gson": { "shasums": { - "jar": "c8fb4839054d280b3033f800d1f5a97de2f028eb8ba2eb458ad287e536f3f25f" + "jar": "d3999291855de495c94c743761b8ab5176cfeabe281a5ab0d8e8d45326fd703e" }, - "version": "2.8.6" + "version": "2.8.9" }, "com.google.errorprone:error_prone_annotations": { "shasums": { - "jar": "cd5257c08a246cf8628817ae71cb822be192ef91f6881ca4a3fcff4f1de1cff3" + "jar": "de25f2d9a2156529bd765f51d8efdfc0dfa7301e04efb9cc75b7f10cf5d0e0fb" + }, + "version": "2.26.1" + }, + "com.google.errorprone:error_prone_type_annotations": { + "shasums": { + "jar": "31907edd46a1f5b7801762b84a2c56d6425ba425acc5d6f8c696d6fac81de9bd" }, - "version": "2.7.1" + "version": "2.26.1" }, "com.google.guava:failureaccess": { "shasums": { - "jar": "a171ee4c734dd2da837e4b16be9df4661afab72a41adaf31eb84dfdaf936ca26" + "jar": "8a8f81cf9b359e3f6dfa691a1e776985c061ef2f223c9b2c80753e1b458e8064" }, - "version": "1.0.1" + "version": "1.0.2" }, "com.google.guava:guava": { "shasums": { - "jar": "355f79352f8c252f2bdaa06c687c4836a38016caccfc4c28d16ae77ecfdffa2f" + "jar": "640535014a304c50221abad19d6b22a096f13119c7c447a655cc1e009a32208d" + }, + "version": "33.0.0-android" + }, + "com.google.guava:guava-testlib": { + "shasums": { + "jar": "aadc71b10d5c3ac474dd16be84cfb18d257e584d1e0a59f8cab64ef4376226ce" }, - "version": "30.1.1-android" + "version": "31.1-jre" }, "com.google.guava:listenablefuture": { "shasums": { @@ -92,39 +115,39 @@ }, "com.google.j2objc:j2objc-annotations": { "shasums": { - "jar": "21af30c92267bd6122c0e0b4d20cccb6641a37eaf956c6540ec471d584e64a7b" + "jar": "f02a95fa1a5e95edb3ed859fd0fb7df709d121a35290eff8b74dce2ab7f4d6ed" }, - "version": "1.3" + "version": "2.8" }, "com.google.protobuf:protobuf-java": { "shasums": { - "jar": "9dcfc5c0b38326660d407375757c685dcd5883d67e06ed770bfc7966c12697dc" + "jar": "e90d8ddb963b20a972a6a59b5093ade2b07cbe546cab3279aaf4383260385f58" }, - "version": "3.17.1" + "version": "3.25.3" }, "com.google.truth.extensions:truth-java8-extension": { "shasums": { - "jar": "2bbd32dd2fa9470d17f1bbda4f52b33b60bce4574052c1d46610a0aa371fc446" + "jar": "b31a61dac6a5147ffab497cb9d7bae283196f12e38dc53b5ec609424e911327b" }, - "version": "1.1.3" + "version": "1.4.2" }, "com.google.truth.extensions:truth-liteproto-extension": { "shasums": { - "jar": "71cce6284554e546d1b5ba48e310ee4b4050676f09fb0eced136d779284ff78d" + "jar": "df6511ca3609c510c266bfdca3d0cedd6eecbcfcb725305eb1c676b5cb4f20a0" }, - "version": "1.1.3" + "version": "1.4.2" }, "com.google.truth.extensions:truth-proto-extension": { "shasums": { - "jar": "821993e4794e7034ae4a7b68105ef83f1913f0de6112f2fe4b5a7130f6a2bf49" + "jar": "85fc5b5c3323d7dfdcaa359c0397cf045a5cf6e625d7d9d9d3ffa5cec7cc30e3" }, - "version": "1.1.3" + "version": "1.4.2" }, "com.google.truth:truth": { "shasums": { - "jar": "fc0b67782289a2aabfddfdf99eff1dcd5edc890d49143fcd489214b107b8f4f3" + "jar": "14c297bc64ca8bc15b6baf67f160627e4562ec91624797e312e907b431113508" }, - "version": "1.1.3" + "version": "1.4.2" }, "com.h2database:h2": { "shasums": { @@ -156,6 +179,30 @@ }, "version": "1.0.4" }, + "io.github.classgraph:classgraph": { + "shasums": { + "jar": "ca0e78c00c074ce99151b5a31ef120cda69e2b4726eb6a0ad7d5081044471951" + }, + "version": "4.8.170" + }, + "io.micrometer:micrometer-commons": { + "shasums": { + "jar": "adfe7d1434c4bb69ed889fb99b7886a6bef27cf19e6d006144cf48d0acd5e6e6" + }, + "version": "1.12.3" + }, + "io.micrometer:micrometer-observation": { + "shasums": { + "jar": "f504c77f776be329f566a48235b591e953c8dad3a79b92b3ea574e19abc9b7fe" + }, + "version": "1.12.3" + }, + "jakarta.servlet:jakarta.servlet-api": { + "shasums": { + "jar": "c034eb1afb158987dbb53a5fea0cadf611c8dae8daadd59c44d9d5ab70129cef" + }, + "version": "6.0.0" + }, "javax.activation:javax.activation-api": { "shasums": { "jar": "43fdef0b5b6ceb31b0424b208b930c74ab58fac2ceeb7b3f6fd3aeb8b5ca4393" @@ -188,15 +235,21 @@ }, "net.bytebuddy:byte-buddy": { "shasums": { - "jar": "e99761a526df0fefbbd3fe14436b0f953000cdfa5151dc63c0b18d37d9c46f1c" + "jar": "970636134d61c183b19f8f58fa631e30d2f2abca344b37848a393cac7863dd70" }, - "version": "1.14.5" + "version": "1.14.12" }, "net.bytebuddy:byte-buddy-agent": { "shasums": { - "jar": "55f19862b870f5d85890ba5386b1b45e9bbc88d5fe1f819abe0c788b4929fa6b" + "jar": "bad2d9413f72cc7106597fdbdfa875b0f88b9781451671b6f69c8b6bb81b4040" + }, + "version": "1.14.13" + }, + "net.jodah:typetools": { + "shasums": { + "jar": "408300867804be05d1083cc0287dd3a21295a9e76090e288013ba5a4182dc96d" }, - "version": "1.14.5" + "version": "0.6.3" }, "net.sf.jopt-simple:jopt-simple": { "shasums": { @@ -218,9 +271,9 @@ }, "org.apache.commons:commons-math3": { "shasums": { - "jar": "6268a9a0ea3e769fc493a21446664c0ef668e48c93d126791f6f3f757978fee2" + "jar": "1e56d7b058d28b65abd256b8458e3885b674c1d588fa43cd7d1cbb9c7ef2b308" }, - "version": "3.2" + "version": "3.6.1" }, "org.apache.commons:commons-text": { "shasums": { @@ -356,21 +409,15 @@ }, "org.assertj:assertj-core": { "shasums": { - "jar": "36af798af9fc20537669e02618bd39f2c797f4813824ef222108cb686fa4c88e" - }, - "version": "3.23.1" - }, - "org.checkerframework:checker-compat-qual": { - "shasums": { - "jar": "11d134b245e9cacc474514d2d66b5b8618f8039a1465cdc55bbc0b34e0008b7a" + "jar": "7fbdffa1996d43cc08e2576e01008b07e57bbad2b4741aa6c3ab73ce8511130e" }, - "version": "2.5.5" + "version": "3.25.3" }, "org.checkerframework:checker-qual": { "shasums": { - "jar": "3ea0dcd73b4d6cb2fb34bd7ed4dad6db327a01ebad7db05eb7894076b3d64491" + "jar": "ccaedd33af0b7894d9f2f3b644f4d19e43928e32902e61ac4d10777830f5aac7" }, - "version": "3.13.0" + "version": "3.42.0" }, "org.glassfish:javax.el": { "shasums": { @@ -392,9 +439,9 @@ }, "org.jacoco:org.jacoco.core": { "shasums": { - "jar": "474c782f809d88924713dfdbf0acb79d330f904be576484803463d0465611643" + "jar": "fca26db37c0c5fbd5dc4985237eb82866df9799d5082af899475a73f91f5b035" }, - "version": "0.8.8" + "version": "0.8.12" }, "org.jboss.logging:jboss-logging": { "shasums": { @@ -464,21 +511,21 @@ }, "org.junit.platform:junit-platform-reporting": { "shasums": { - "jar": "d28048333b378d166f9ad38c2a8e34ac0fa1a29cc016cb279df53c8b54628fc3" + "jar": "e2607d31b971b4dae6dc64cdf440d74354fd0dcf56eb00461ccae7cbf213f810" }, - "version": "1.8.2" + "version": "1.9.0" }, "org.junit.platform:junit-platform-testkit": { "shasums": { - "jar": "94d6fb9b1d4e7bb3d6a967b21f1cf4f7cf84455d602cccf614a186d936929b08" + "jar": "2c48473abe076df4df7b1f2b6f5f37c3434d55a5b6e0e1d245ddfd207251750c" }, - "version": "1.8.2" + "version": "1.9.0" }, "org.mockito:mockito-core": { "shasums": { - "jar": "b1689b06617ea01fd777bfaedbdde512faf083d639a049f79b388d5a4e96d2e5" + "jar": "f076c96b1f49b8d9bc42e46b0969aaf5684c40c8b5b679d400e5d880073a0e00" }, - "version": "5.4.0" + "version": "5.11.0" }, "org.objenesis:objenesis": { "shasums": { @@ -488,15 +535,15 @@ }, "org.openjdk.jmh:jmh-core": { "shasums": { - "jar": "904384762d2ffeca8005aa9b432a7891a0e60c888bfd36f61dfcfa97c3a1d1b3" + "jar": "dc0eaf2bbf0036a70b60798c785d6e03a9daf06b68b8edb0f1ba9eb3421baeb3" }, - "version": "1.34" + "version": "1.37" }, "org.openjdk.jmh:jmh-generator-annprocess": { "shasums": { - "jar": "aa0feeefc0da59427b14c50139cba6deba211750e0033fdc39a5b3b8008b2900" + "jar": "6a5604b5b804e0daca1145df1077609321687734a8b49387e49f10557c186c77" }, - "version": "1.34" + "version": "1.37" }, "org.opentest4j:opentest4j": { "shasums": { @@ -506,27 +553,75 @@ }, "org.ow2.asm:asm": { "shasums": { - "jar": "b9d4fe4d71938df38839f0eca42aaaa64cf8b313d678da036f0cb3ca199b47f5" + "jar": "adf46d5e34940bdf148ecdd26a9ee8eea94496a72034ff7141066b3eea5c4e9d" }, - "version": "9.2" + "version": "9.7" }, - "org.ow2.asm:asm-analysis": { + "org.ow2.asm:asm-commons": { "shasums": { - "jar": "878fbe521731c072d14d2d65b983b1beae6ad06fda0007b6a8bae81f73f433c4" + "jar": "389bc247958e049fc9a0408d398c92c6d370c18035120395d4cba1d9d9304b7a" }, - "version": "9.2" + "version": "9.7" }, - "org.ow2.asm:asm-commons": { + "org.ow2.asm:asm-tree": { "shasums": { - "jar": "be4ce53138a238bb522cd781cf91f3ba5ce2f6ca93ec62d46a162a127225e0a6" + "jar": "62f4b3bc436045c1acb5c3ba2d8ec556ec3369093d7f5d06c747eb04b56d52b1" }, - "version": "9.2" + "version": "9.7" }, - "org.ow2.asm:asm-tree": { + "org.springframework:spring-aop": { + "shasums": { + "jar": "de43e11b649cbc0294dc6d7a5fd82c2b07a55114a5b6558d776c115ad5719a16" + }, + "version": "6.1.4" + }, + "org.springframework:spring-beans": { + "shasums": { + "jar": "6d7c92802e41a5248318433b214b7956d3b905e4e4448b650503722aab0e9d98" + }, + "version": "6.1.4" + }, + "org.springframework:spring-context": { "shasums": { - "jar": "aabf9bd23091a4ebfc109c1f3ee7cf3e4b89f6ba2d3f51c5243f16b3cffae011" + "jar": "89dfb61b5496339630514f323b3030aa2be2319010e414d6a0ebab19cd52d6b3" }, - "version": "9.2" + "version": "6.1.4" + }, + "org.springframework:spring-core": { + "shasums": { + "jar": "da00de5306314c60679054472cc528805c0b246f63fbbbb828fef19fa3b2cf74" + }, + "version": "6.1.4" + }, + "org.springframework:spring-expression": { + "shasums": { + "jar": "b4150506c3bfee0bff73388254e3bec1f0c3d43d0a8b5bbef24277db80d95ef8" + }, + "version": "6.1.4" + }, + "org.springframework:spring-jcl": { + "shasums": { + "jar": "541ce413a1b0a252090cdd0df8e6ed902e912fb31f4a5e60e60223e6da3ded32" + }, + "version": "6.1.4" + }, + "org.springframework:spring-test": { + "shasums": { + "jar": "43ea85da5dc0a4b4c250aa2e12b77bb679bd63c7cd765c80c73c7b52bed47402" + }, + "version": "6.1.4" + }, + "org.springframework:spring-web": { + "shasums": { + "jar": "ca4e93745bd82bf2bc74b97d0323283648ea5fd89b0071f19787c9e08f00b340" + }, + "version": "6.1.4" + }, + "org.springframework:spring-webmvc": { + "shasums": { + "jar": "340c2ccaff0162156920b5526e8d477ebf7718f8f4df111ab7d5156c36de6547" + }, + "version": "6.1.4" }, "xalan:serializer": { "shasums": { @@ -572,7 +667,15 @@ "com.google.guava:failureaccess", "com.google.guava:listenablefuture", "com.google.j2objc:j2objc-annotations", - "org.checkerframework:checker-compat-qual" + "org.checkerframework:checker-qual" + ], + "com.google.guava:guava-testlib": [ + "com.google.code.findbugs:jsr305", + "com.google.errorprone:error_prone_annotations", + "com.google.guava:guava", + "com.google.j2objc:j2objc-annotations", + "junit:junit", + "org.checkerframework:checker-qual" ], "com.google.truth.extensions:truth-java8-extension": [ "com.google.truth:truth", @@ -602,6 +705,9 @@ "org.checkerframework:checker-qual", "org.ow2.asm:asm" ], + "io.micrometer:micrometer-observation": [ + "io.micrometer:micrometer-commons" + ], "javax.xml.bind:jaxb-api": [ "javax.activation:javax.activation-api" ], @@ -795,17 +901,49 @@ "org.openjdk.jmh:jmh-generator-annprocess": [ "org.openjdk.jmh:jmh-core" ], - "org.ow2.asm:asm-analysis": [ - "org.ow2.asm:asm-tree" - ], "org.ow2.asm:asm-commons": [ "org.ow2.asm:asm", - "org.ow2.asm:asm-analysis", "org.ow2.asm:asm-tree" ], "org.ow2.asm:asm-tree": [ "org.ow2.asm:asm" ], + "org.springframework:spring-aop": [ + "org.springframework:spring-beans", + "org.springframework:spring-core" + ], + "org.springframework:spring-beans": [ + "org.springframework:spring-core" + ], + "org.springframework:spring-context": [ + "io.micrometer:micrometer-observation", + "org.springframework:spring-aop", + "org.springframework:spring-beans", + "org.springframework:spring-core", + "org.springframework:spring-expression" + ], + "org.springframework:spring-core": [ + "org.springframework:spring-jcl" + ], + "org.springframework:spring-expression": [ + "org.springframework:spring-core" + ], + "org.springframework:spring-test": [ + "org.springframework:spring-core" + ], + "org.springframework:spring-web": [ + "io.micrometer:micrometer-observation", + "org.springframework:spring-beans", + "org.springframework:spring-core" + ], + "org.springframework:spring-webmvc": [ + "org.springframework:spring-aop", + "org.springframework:spring-beans", + "org.springframework:spring-context", + "org.springframework:spring-core", + "org.springframework:spring-expression", + "org.springframework:spring-web" + ], "xalan:serializer": [ "xml-apis:xml-apis" ], @@ -890,6 +1028,49 @@ "com.fasterxml.classmate.types", "com.fasterxml.classmate.util" ], + "com.github.jsqlparser:jsqlparser": [ + "net.sf.jsqlparser", + "net.sf.jsqlparser.expression", + "net.sf.jsqlparser.expression.operators.arithmetic", + "net.sf.jsqlparser.expression.operators.conditional", + "net.sf.jsqlparser.expression.operators.relational", + "net.sf.jsqlparser.parser", + "net.sf.jsqlparser.parser.feature", + "net.sf.jsqlparser.schema", + "net.sf.jsqlparser.statement", + "net.sf.jsqlparser.statement.alter", + "net.sf.jsqlparser.statement.alter.sequence", + "net.sf.jsqlparser.statement.analyze", + "net.sf.jsqlparser.statement.comment", + "net.sf.jsqlparser.statement.create.function", + "net.sf.jsqlparser.statement.create.index", + "net.sf.jsqlparser.statement.create.procedure", + "net.sf.jsqlparser.statement.create.schema", + "net.sf.jsqlparser.statement.create.sequence", + "net.sf.jsqlparser.statement.create.synonym", + "net.sf.jsqlparser.statement.create.table", + "net.sf.jsqlparser.statement.create.view", + "net.sf.jsqlparser.statement.delete", + "net.sf.jsqlparser.statement.drop", + "net.sf.jsqlparser.statement.execute", + "net.sf.jsqlparser.statement.grant", + "net.sf.jsqlparser.statement.insert", + "net.sf.jsqlparser.statement.merge", + "net.sf.jsqlparser.statement.refresh", + "net.sf.jsqlparser.statement.select", + "net.sf.jsqlparser.statement.show", + "net.sf.jsqlparser.statement.truncate", + "net.sf.jsqlparser.statement.update", + "net.sf.jsqlparser.statement.upsert", + "net.sf.jsqlparser.util", + "net.sf.jsqlparser.util.cnfexpression", + "net.sf.jsqlparser.util.deparser", + "net.sf.jsqlparser.util.validation", + "net.sf.jsqlparser.util.validation.allowedtypes", + "net.sf.jsqlparser.util.validation.feature", + "net.sf.jsqlparser.util.validation.metadata", + "net.sf.jsqlparser.util.validation.validator" + ], "com.google.auto.value:auto-value-annotations": [ "com.google.auto.value", "com.google.auto.value.extension.memoized", @@ -908,6 +1089,7 @@ "com.google.gson.internal.bind", "com.google.gson.internal.bind.util", "com.google.gson.internal.reflect", + "com.google.gson.internal.sql", "com.google.gson.reflect", "com.google.gson.stream" ], @@ -915,6 +1097,9 @@ "com.google.errorprone.annotations", "com.google.errorprone.annotations.concurrent" ], + "com.google.errorprone:error_prone_type_annotations": [ + "com.google.errorprone.annotations" + ], "com.google.guava:failureaccess": [ "com.google.common.util.concurrent.internal" ], @@ -938,6 +1123,15 @@ "com.google.common.xml", "com.google.thirdparty.publicsuffix" ], + "com.google.guava:guava-testlib": [ + "com.google.common.collect.testing", + "com.google.common.collect.testing.features", + "com.google.common.collect.testing.google", + "com.google.common.collect.testing.testers", + "com.google.common.escape.testing", + "com.google.common.testing", + "com.google.common.util.concurrent.testing" + ], "com.google.j2objc:j2objc-annotations": [ "com.google.j2objc.annotations" ], @@ -945,9 +1139,6 @@ "com.google.protobuf", "com.google.protobuf.compiler" ], - "com.google.truth.extensions:truth-java8-extension": [ - "com.google.common.truth" - ], "com.google.truth.extensions:truth-liteproto-extension": [ "com.google.common.truth.extensions.proto" ], @@ -1063,6 +1254,43 @@ "org.apache.commons.logging", "org.apache.commons.logging.impl" ], + "io.github.classgraph:classgraph": [ + "io.github.classgraph", + "nonapi.io.github.classgraph.classloaderhandler", + "nonapi.io.github.classgraph.classpath", + "nonapi.io.github.classgraph.concurrency", + "nonapi.io.github.classgraph.fastzipfilereader", + "nonapi.io.github.classgraph.fileslice", + "nonapi.io.github.classgraph.fileslice.reader", + "nonapi.io.github.classgraph.json", + "nonapi.io.github.classgraph.recycler", + "nonapi.io.github.classgraph.reflection", + "nonapi.io.github.classgraph.scanspec", + "nonapi.io.github.classgraph.types", + "nonapi.io.github.classgraph.utils" + ], + "io.micrometer:micrometer-commons": [ + "io.micrometer.common", + "io.micrometer.common.annotation", + "io.micrometer.common.docs", + "io.micrometer.common.lang", + "io.micrometer.common.util", + "io.micrometer.common.util.internal.logging" + ], + "io.micrometer:micrometer-observation": [ + "io.micrometer.observation", + "io.micrometer.observation.annotation", + "io.micrometer.observation.aop", + "io.micrometer.observation.contextpropagation", + "io.micrometer.observation.docs", + "io.micrometer.observation.transport" + ], + "jakarta.servlet:jakarta.servlet-api": [ + "jakarta.servlet", + "jakarta.servlet.annotation", + "jakarta.servlet.descriptor", + "jakarta.servlet.http" + ], "javax.activation:javax.activation-api": [ "javax.activation" ], @@ -1166,6 +1394,9 @@ "net.bytebuddy.agent", "net.bytebuddy.agent.utility.nullability" ], + "net.jodah:typetools": [ + "net.jodah.typetools" + ], "net.sf.jopt-simple:jopt-simple": [ "joptsimple", "joptsimple.internal", @@ -1251,17 +1482,30 @@ "org.apache.commons.math3.exception.util", "org.apache.commons.math3.filter", "org.apache.commons.math3.fitting", + "org.apache.commons.math3.fitting.leastsquares", "org.apache.commons.math3.fraction", "org.apache.commons.math3.genetics", "org.apache.commons.math3.geometry", + "org.apache.commons.math3.geometry.enclosing", "org.apache.commons.math3.geometry.euclidean.oned", "org.apache.commons.math3.geometry.euclidean.threed", "org.apache.commons.math3.geometry.euclidean.twod", + "org.apache.commons.math3.geometry.euclidean.twod.hull", + "org.apache.commons.math3.geometry.hull", "org.apache.commons.math3.geometry.partitioning", "org.apache.commons.math3.geometry.partitioning.utilities", + "org.apache.commons.math3.geometry.spherical.oned", + "org.apache.commons.math3.geometry.spherical.twod", "org.apache.commons.math3.linear", "org.apache.commons.math3.ml.clustering", + "org.apache.commons.math3.ml.clustering.evaluation", "org.apache.commons.math3.ml.distance", + "org.apache.commons.math3.ml.neuralnet", + "org.apache.commons.math3.ml.neuralnet.oned", + "org.apache.commons.math3.ml.neuralnet.sofm", + "org.apache.commons.math3.ml.neuralnet.sofm.util", + "org.apache.commons.math3.ml.neuralnet.twod", + "org.apache.commons.math3.ml.neuralnet.twod.util", "org.apache.commons.math3.ode", "org.apache.commons.math3.ode.events", "org.apache.commons.math3.ode.nonstiff", @@ -1291,6 +1535,7 @@ "org.apache.commons.math3.stat.descriptive.rank", "org.apache.commons.math3.stat.descriptive.summary", "org.apache.commons.math3.stat.inference", + "org.apache.commons.math3.stat.interval", "org.apache.commons.math3.stat.ranking", "org.apache.commons.math3.stat.regression", "org.apache.commons.math3.transform", @@ -1508,6 +1753,8 @@ "org.assertj.core.api.filter", "org.assertj.core.api.iterable", "org.assertj.core.api.junit.jupiter", + "org.assertj.core.api.recursive", + "org.assertj.core.api.recursive.assertion", "org.assertj.core.api.recursive.comparison", "org.assertj.core.condition", "org.assertj.core.configuration", @@ -1528,9 +1775,6 @@ "org.assertj.core.util.introspection", "org.assertj.core.util.xml" ], - "org.checkerframework:checker-compat-qual": [ - "org.checkerframework.checker.nullness.compatqual" - ], "org.checkerframework:checker-qual": [ "org.checkerframework.checker.builder.qual", "org.checkerframework.checker.calledmethods.qual", @@ -1544,6 +1788,7 @@ "org.checkerframework.checker.initialization.qual", "org.checkerframework.checker.interning.qual", "org.checkerframework.checker.lock.qual", + "org.checkerframework.checker.mustcall.qual", "org.checkerframework.checker.nullness.qual", "org.checkerframework.checker.optional.qual", "org.checkerframework.checker.propkey.qual", @@ -1557,7 +1802,7 @@ "org.checkerframework.common.reflection.qual", "org.checkerframework.common.returnsreceiver.qual", "org.checkerframework.common.subtyping.qual", - "org.checkerframework.common.util.report.qual", + "org.checkerframework.common.util.count.report.qual", "org.checkerframework.common.value.qual", "org.checkerframework.dataflow.qual", "org.checkerframework.framework.qual" @@ -1818,7 +2063,13 @@ ], "org.junit.platform:junit-platform-reporting": [ "org.junit.platform.reporting.legacy", - "org.junit.platform.reporting.legacy.xml" + "org.junit.platform.reporting.legacy.xml", + "org.junit.platform.reporting.open.xml", + "org.junit.platform.reporting.shadow.org.opentest4j.reporting.events.api", + "org.junit.platform.reporting.shadow.org.opentest4j.reporting.events.core", + "org.junit.platform.reporting.shadow.org.opentest4j.reporting.events.java", + "org.junit.platform.reporting.shadow.org.opentest4j.reporting.events.root", + "org.junit.platform.reporting.shadow.org.opentest4j.reporting.schema" ], "org.junit.platform:junit-platform-testkit": [ "org.junit.platform.testkit.engine" @@ -1927,15 +2178,312 @@ "org.objectweb.asm", "org.objectweb.asm.signature" ], - "org.ow2.asm:asm-analysis": [ - "org.objectweb.asm.tree.analysis" - ], "org.ow2.asm:asm-commons": [ "org.objectweb.asm.commons" ], "org.ow2.asm:asm-tree": [ "org.objectweb.asm.tree" ], + "org.springframework:spring-aop": [ + "org.aopalliance.aop", + "org.aopalliance.intercept", + "org.springframework.aop", + "org.springframework.aop.aspectj", + "org.springframework.aop.aspectj.annotation", + "org.springframework.aop.aspectj.autoproxy", + "org.springframework.aop.config", + "org.springframework.aop.framework", + "org.springframework.aop.framework.adapter", + "org.springframework.aop.framework.autoproxy", + "org.springframework.aop.framework.autoproxy.target", + "org.springframework.aop.interceptor", + "org.springframework.aop.scope", + "org.springframework.aop.support", + "org.springframework.aop.support.annotation", + "org.springframework.aop.target", + "org.springframework.aop.target.dynamic" + ], + "org.springframework:spring-beans": [ + "org.springframework.beans", + "org.springframework.beans.factory", + "org.springframework.beans.factory.annotation", + "org.springframework.beans.factory.aot", + "org.springframework.beans.factory.config", + "org.springframework.beans.factory.groovy", + "org.springframework.beans.factory.parsing", + "org.springframework.beans.factory.serviceloader", + "org.springframework.beans.factory.support", + "org.springframework.beans.factory.wiring", + "org.springframework.beans.factory.xml", + "org.springframework.beans.propertyeditors", + "org.springframework.beans.support" + ], + "org.springframework:spring-context": [ + "org.springframework.cache", + "org.springframework.cache.annotation", + "org.springframework.cache.concurrent", + "org.springframework.cache.config", + "org.springframework.cache.interceptor", + "org.springframework.cache.support", + "org.springframework.context", + "org.springframework.context.annotation", + "org.springframework.context.aot", + "org.springframework.context.config", + "org.springframework.context.event", + "org.springframework.context.expression", + "org.springframework.context.i18n", + "org.springframework.context.index", + "org.springframework.context.support", + "org.springframework.context.weaving", + "org.springframework.ejb.config", + "org.springframework.format", + "org.springframework.format.annotation", + "org.springframework.format.datetime", + "org.springframework.format.datetime.standard", + "org.springframework.format.number", + "org.springframework.format.number.money", + "org.springframework.format.support", + "org.springframework.instrument.classloading", + "org.springframework.instrument.classloading.glassfish", + "org.springframework.instrument.classloading.jboss", + "org.springframework.instrument.classloading.tomcat", + "org.springframework.jmx", + "org.springframework.jmx.access", + "org.springframework.jmx.export", + "org.springframework.jmx.export.annotation", + "org.springframework.jmx.export.assembler", + "org.springframework.jmx.export.metadata", + "org.springframework.jmx.export.naming", + "org.springframework.jmx.export.notification", + "org.springframework.jmx.support", + "org.springframework.jndi", + "org.springframework.jndi.support", + "org.springframework.scheduling", + "org.springframework.scheduling.annotation", + "org.springframework.scheduling.concurrent", + "org.springframework.scheduling.config", + "org.springframework.scheduling.support", + "org.springframework.scripting", + "org.springframework.scripting.bsh", + "org.springframework.scripting.config", + "org.springframework.scripting.groovy", + "org.springframework.scripting.support", + "org.springframework.stereotype", + "org.springframework.ui", + "org.springframework.ui.context", + "org.springframework.ui.context.support", + "org.springframework.validation", + "org.springframework.validation.annotation", + "org.springframework.validation.beanvalidation", + "org.springframework.validation.method", + "org.springframework.validation.support" + ], + "org.springframework:spring-core": [ + "org.springframework.aot", + "org.springframework.aot.generate", + "org.springframework.aot.hint", + "org.springframework.aot.hint.annotation", + "org.springframework.aot.hint.predicate", + "org.springframework.aot.hint.support", + "org.springframework.aot.nativex", + "org.springframework.aot.nativex.feature", + "org.springframework.aot.nativex.substitution", + "org.springframework.asm", + "org.springframework.cglib", + "org.springframework.cglib.beans", + "org.springframework.cglib.core", + "org.springframework.cglib.core.internal", + "org.springframework.cglib.proxy", + "org.springframework.cglib.reflect", + "org.springframework.cglib.transform", + "org.springframework.cglib.transform.impl", + "org.springframework.cglib.util", + "org.springframework.core", + "org.springframework.core.annotation", + "org.springframework.core.codec", + "org.springframework.core.convert", + "org.springframework.core.convert.converter", + "org.springframework.core.convert.support", + "org.springframework.core.env", + "org.springframework.core.io", + "org.springframework.core.io.buffer", + "org.springframework.core.io.support", + "org.springframework.core.log", + "org.springframework.core.metrics", + "org.springframework.core.metrics.jfr", + "org.springframework.core.serializer", + "org.springframework.core.serializer.support", + "org.springframework.core.style", + "org.springframework.core.task", + "org.springframework.core.task.support", + "org.springframework.core.type", + "org.springframework.core.type.classreading", + "org.springframework.core.type.filter", + "org.springframework.javapoet", + "org.springframework.lang", + "org.springframework.objenesis", + "org.springframework.objenesis.instantiator", + "org.springframework.objenesis.instantiator.android", + "org.springframework.objenesis.instantiator.annotations", + "org.springframework.objenesis.instantiator.basic", + "org.springframework.objenesis.instantiator.gcj", + "org.springframework.objenesis.instantiator.perc", + "org.springframework.objenesis.instantiator.sun", + "org.springframework.objenesis.instantiator.util", + "org.springframework.objenesis.strategy", + "org.springframework.util", + "org.springframework.util.backoff", + "org.springframework.util.comparator", + "org.springframework.util.concurrent", + "org.springframework.util.function", + "org.springframework.util.unit", + "org.springframework.util.xml" + ], + "org.springframework:spring-expression": [ + "org.springframework.expression", + "org.springframework.expression.common", + "org.springframework.expression.spel", + "org.springframework.expression.spel.ast", + "org.springframework.expression.spel.standard", + "org.springframework.expression.spel.support" + ], + "org.springframework:spring-jcl": [ + "org.apache.commons.logging", + "org.apache.commons.logging.impl" + ], + "org.springframework:spring-test": [ + "org.springframework.mock.env", + "org.springframework.mock.http", + "org.springframework.mock.http.client", + "org.springframework.mock.http.client.reactive", + "org.springframework.mock.http.server.reactive", + "org.springframework.mock.web", + "org.springframework.mock.web.reactive.function.server", + "org.springframework.mock.web.server", + "org.springframework.test.annotation", + "org.springframework.test.context", + "org.springframework.test.context.aot", + "org.springframework.test.context.cache", + "org.springframework.test.context.event", + "org.springframework.test.context.event.annotation", + "org.springframework.test.context.hint", + "org.springframework.test.context.jdbc", + "org.springframework.test.context.junit.jupiter", + "org.springframework.test.context.junit.jupiter.web", + "org.springframework.test.context.junit4", + "org.springframework.test.context.junit4.rules", + "org.springframework.test.context.junit4.statements", + "org.springframework.test.context.observation", + "org.springframework.test.context.support", + "org.springframework.test.context.testng", + "org.springframework.test.context.transaction", + "org.springframework.test.context.util", + "org.springframework.test.context.web", + "org.springframework.test.context.web.socket", + "org.springframework.test.jdbc", + "org.springframework.test.util", + "org.springframework.test.web", + "org.springframework.test.web.client", + "org.springframework.test.web.client.match", + "org.springframework.test.web.client.response", + "org.springframework.test.web.reactive.server", + "org.springframework.test.web.servlet", + "org.springframework.test.web.servlet.client", + "org.springframework.test.web.servlet.htmlunit", + "org.springframework.test.web.servlet.htmlunit.webdriver", + "org.springframework.test.web.servlet.request", + "org.springframework.test.web.servlet.result", + "org.springframework.test.web.servlet.setup" + ], + "org.springframework:spring-web": [ + "org.springframework.http", + "org.springframework.http.client", + "org.springframework.http.client.observation", + "org.springframework.http.client.reactive", + "org.springframework.http.client.support", + "org.springframework.http.codec", + "org.springframework.http.codec.cbor", + "org.springframework.http.codec.json", + "org.springframework.http.codec.multipart", + "org.springframework.http.codec.protobuf", + "org.springframework.http.codec.support", + "org.springframework.http.codec.xml", + "org.springframework.http.converter", + "org.springframework.http.converter.cbor", + "org.springframework.http.converter.feed", + "org.springframework.http.converter.json", + "org.springframework.http.converter.protobuf", + "org.springframework.http.converter.smile", + "org.springframework.http.converter.support", + "org.springframework.http.converter.xml", + "org.springframework.http.server", + "org.springframework.http.server.observation", + "org.springframework.http.server.reactive", + "org.springframework.http.server.reactive.observation", + "org.springframework.http.support", + "org.springframework.web", + "org.springframework.web.accept", + "org.springframework.web.bind", + "org.springframework.web.bind.annotation", + "org.springframework.web.bind.support", + "org.springframework.web.client", + "org.springframework.web.client.support", + "org.springframework.web.context", + "org.springframework.web.context.annotation", + "org.springframework.web.context.request", + "org.springframework.web.context.request.async", + "org.springframework.web.context.support", + "org.springframework.web.cors", + "org.springframework.web.cors.reactive", + "org.springframework.web.filter", + "org.springframework.web.filter.reactive", + "org.springframework.web.jsf", + "org.springframework.web.jsf.el", + "org.springframework.web.method", + "org.springframework.web.method.annotation", + "org.springframework.web.method.support", + "org.springframework.web.multipart", + "org.springframework.web.multipart.support", + "org.springframework.web.server", + "org.springframework.web.server.adapter", + "org.springframework.web.server.handler", + "org.springframework.web.server.i18n", + "org.springframework.web.server.session", + "org.springframework.web.service", + "org.springframework.web.service.annotation", + "org.springframework.web.service.invoker", + "org.springframework.web.util", + "org.springframework.web.util.pattern" + ], + "org.springframework:spring-webmvc": [ + "org.springframework.web.servlet", + "org.springframework.web.servlet.config", + "org.springframework.web.servlet.config.annotation", + "org.springframework.web.servlet.function", + "org.springframework.web.servlet.function.support", + "org.springframework.web.servlet.handler", + "org.springframework.web.servlet.i18n", + "org.springframework.web.servlet.mvc", + "org.springframework.web.servlet.mvc.annotation", + "org.springframework.web.servlet.mvc.condition", + "org.springframework.web.servlet.mvc.method", + "org.springframework.web.servlet.mvc.method.annotation", + "org.springframework.web.servlet.mvc.support", + "org.springframework.web.servlet.resource", + "org.springframework.web.servlet.support", + "org.springframework.web.servlet.tags", + "org.springframework.web.servlet.tags.form", + "org.springframework.web.servlet.theme", + "org.springframework.web.servlet.view", + "org.springframework.web.servlet.view.document", + "org.springframework.web.servlet.view.feed", + "org.springframework.web.servlet.view.freemarker", + "org.springframework.web.servlet.view.groovy", + "org.springframework.web.servlet.view.json", + "org.springframework.web.servlet.view.script", + "org.springframework.web.servlet.view.xml", + "org.springframework.web.servlet.view.xslt" + ], "xalan:serializer": [ "org.apache.xml.serializer", "org.apache.xml.serializer.dom3", @@ -2039,12 +2587,15 @@ "com.fasterxml.jackson.core:jackson-databind", "com.fasterxml.jackson.dataformat:jackson-dataformat-cbor", "com.fasterxml:classmate", + "com.github.jsqlparser:jsqlparser", "com.google.auto.value:auto-value-annotations", "com.google.code.findbugs:jsr305", "com.google.code.gson:gson", "com.google.errorprone:error_prone_annotations", + "com.google.errorprone:error_prone_type_annotations", "com.google.guava:failureaccess", "com.google.guava:guava", + "com.google.guava:guava-testlib", "com.google.guava:listenablefuture", "com.google.j2objc:j2objc-annotations", "com.google.protobuf:protobuf-java", @@ -2057,6 +2608,10 @@ "com.unboundid:unboundid-ldapsdk", "commons-io:commons-io", "commons-logging:commons-logging", + "io.github.classgraph:classgraph", + "io.micrometer:micrometer-commons", + "io.micrometer:micrometer-observation", + "jakarta.servlet:jakarta.servlet-api", "javax.activation:javax.activation-api", "javax.el:javax.el-api", "javax.validation:validation-api", @@ -2064,6 +2619,7 @@ "junit:junit", "net.bytebuddy:byte-buddy", "net.bytebuddy:byte-buddy-agent", + "net.jodah:typetools", "net.sf.jopt-simple:jopt-simple", "org.apache.commons:commons-imaging", "org.apache.commons:commons-lang3", @@ -2091,7 +2647,6 @@ "org.apache.xmlgraphics:xmlgraphics-commons", "org.apiguardian:apiguardian-api", "org.assertj:assertj-core", - "org.checkerframework:checker-compat-qual", "org.checkerframework:checker-qual", "org.glassfish:javax.el", "org.hamcrest:hamcrest-core", @@ -2116,14 +2671,191 @@ "org.openjdk.jmh:jmh-generator-annprocess", "org.opentest4j:opentest4j", "org.ow2.asm:asm", - "org.ow2.asm:asm-analysis", "org.ow2.asm:asm-commons", "org.ow2.asm:asm-tree", + "org.springframework:spring-aop", + "org.springframework:spring-beans", + "org.springframework:spring-context", + "org.springframework:spring-core", + "org.springframework:spring-expression", + "org.springframework:spring-jcl", + "org.springframework:spring-test", + "org.springframework:spring-web", + "org.springframework:spring-webmvc", "xalan:serializer", "xalan:xalan", "xml-apis:xml-apis", "xml-apis:xml-apis-ext" ] }, + "services": { + "com.alibaba:fastjson": { + "javax.ws.rs.ext.MessageBodyReader": [ + "com.alibaba.fastjson.support.jaxrs.FastJsonProvider" + ], + "javax.ws.rs.ext.MessageBodyWriter": [ + "com.alibaba.fastjson.support.jaxrs.FastJsonProvider" + ], + "javax.ws.rs.ext.Providers": [ + "com.alibaba.fastjson.support.jaxrs.FastJsonProvider" + ], + "org.glassfish.jersey.internal.spi.AutoDiscoverable": [ + "com.alibaba.fastjson.support.jaxrs.FastJsonAutoDiscoverable" + ] + }, + "com.fasterxml.jackson.core:jackson-core": { + "com.fasterxml.jackson.core.JsonFactory": [ + "com.fasterxml.jackson.core.JsonFactory" + ] + }, + "com.fasterxml.jackson.core:jackson-databind": { + "com.fasterxml.jackson.core.ObjectCodec": [ + "com.fasterxml.jackson.databind.ObjectMapper" + ] + }, + "com.fasterxml.jackson.dataformat:jackson-dataformat-cbor": { + "com.fasterxml.jackson.core.JsonFactory": [ + "com.fasterxml.jackson.dataformat.cbor.CBORFactory" + ] + }, + "com.h2database:h2": { + "java.sql.Driver": [ + "org.h2.Driver" + ] + }, + "io.micrometer:micrometer-observation": { + "io.micrometer.context.ThreadLocalAccessor": [ + "io.micrometer.observation.contextpropagation.ObservationThreadLocalAccessor" + ] + }, + "org.apache.logging.log4j:log4j-api": { + "org.apache.logging.log4j.util.PropertySource": [ + "org.apache.logging.log4j.util.EnvironmentPropertySource", + "org.apache.logging.log4j.util.SystemPropertiesPropertySource" + ] + }, + "org.apache.logging.log4j:log4j-core": { + "javax.annotation.processing.Processor": [ + "org.apache.logging.log4j.core.config.plugins.processor.PluginProcessor" + ], + "org.apache.logging.log4j.core.util.ContextDataProvider": [ + "org.apache.logging.log4j.core.impl.ThreadContextDataProvider" + ], + "org.apache.logging.log4j.message.ThreadDumpMessage$ThreadInfoFactory": [ + "org.apache.logging.log4j.core.message.ExtendedThreadInfoFactory" + ], + "org.apache.logging.log4j.spi.Provider": [ + "org.apache.logging.log4j.core.impl.Log4jProvider" + ] + }, + "org.apache.xmlgraphics:batik-script": { + "org.apache.batik.script.InterpreterFactory": [ + "org.apache.batik.bridge.RhinoInterpreterFactory" + ] + }, + "org.apache.xmlgraphics:xmlgraphics-commons": { + "javax.xml.transform.URIResolver": [ + "org.apache.xmlgraphics.util.uri.DataURIResolver" + ], + "org.apache.xmlgraphics.image.loader.spi.ImageConverter": [ + "org.apache.xmlgraphics.image.loader.impl.ImageConverterBitmap2G2D", + "org.apache.xmlgraphics.image.loader.impl.ImageConverterBuffered2Rendered", + "org.apache.xmlgraphics.image.loader.impl.ImageConverterG2D2Bitmap", + "org.apache.xmlgraphics.image.loader.impl.ImageConverterRendered2PNG" + ], + "org.apache.xmlgraphics.image.loader.spi.ImageLoaderFactory": [ + "org.apache.xmlgraphics.image.loader.impl.ImageLoaderFactoryEPS", + "org.apache.xmlgraphics.image.loader.impl.ImageLoaderFactoryInternalTIFF", + "org.apache.xmlgraphics.image.loader.impl.ImageLoaderFactoryPNG", + "org.apache.xmlgraphics.image.loader.impl.ImageLoaderFactoryRaw", + "org.apache.xmlgraphics.image.loader.impl.ImageLoaderFactoryRawCCITTFax", + "org.apache.xmlgraphics.image.loader.impl.imageio.ImageLoaderFactoryImageIO" + ], + "org.apache.xmlgraphics.image.loader.spi.ImagePreloader": [ + "org.apache.xmlgraphics.image.loader.impl.PreloaderBMP", + "org.apache.xmlgraphics.image.loader.impl.PreloaderEMF", + "org.apache.xmlgraphics.image.loader.impl.PreloaderEPS", + "org.apache.xmlgraphics.image.loader.impl.PreloaderGIF", + "org.apache.xmlgraphics.image.loader.impl.PreloaderJPEG", + "org.apache.xmlgraphics.image.loader.impl.PreloaderRawPNG", + "org.apache.xmlgraphics.image.loader.impl.PreloaderTIFF", + "org.apache.xmlgraphics.image.loader.impl.imageio.PreloaderImageIO" + ], + "org.apache.xmlgraphics.image.writer.ImageWriter": [ + "org.apache.xmlgraphics.image.writer.imageio.ImageIOJPEGImageWriter", + "org.apache.xmlgraphics.image.writer.imageio.ImageIOPNGImageWriter", + "org.apache.xmlgraphics.image.writer.imageio.ImageIOTIFFImageWriter", + "org.apache.xmlgraphics.image.writer.internal.PNGImageWriter", + "org.apache.xmlgraphics.image.writer.internal.TIFFImageWriter" + ] + }, + "org.hibernate:hibernate-validator": { + "javax.validation.spi.ValidationProvider": [ + "org.hibernate.validator.HibernateValidator" + ] + }, + "org.jetbrains.kotlin:kotlin-reflect": { + "kotlin.reflect.jvm.internal.impl.builtins.BuiltInsLoader": [ + "kotlin.reflect.jvm.internal.impl.serialization.deserialization.builtins.BuiltInsLoaderImpl" + ], + "kotlin.reflect.jvm.internal.impl.resolve.ExternalOverridabilityCondition": [ + "kotlin.reflect.jvm.internal.impl.load.java.ErasedOverridabilityCondition", + "kotlin.reflect.jvm.internal.impl.load.java.FieldOverridabilityCondition", + "kotlin.reflect.jvm.internal.impl.load.java.JavaIncompatibilityRulesOverridabilityCondition" + ] + }, + "org.junit.jupiter:junit-jupiter-engine": { + "org.junit.platform.engine.TestEngine": [ + "org.junit.jupiter.engine.JupiterTestEngine" + ] + }, + "org.junit.platform:junit-platform-launcher": { + "org.junit.platform.launcher.TestExecutionListener": [ + "org.junit.platform.launcher.listeners.UniqueIdTrackingListener" + ] + }, + "org.junit.platform:junit-platform-reporting": { + "org.junit.platform.launcher.TestExecutionListener": [ + "org.junit.platform.reporting.open.xml.OpenTestReportGeneratingListener" + ] + }, + "org.openjdk.jmh:jmh-generator-annprocess": { + "javax.annotation.processing.Processor": [ + "org.openjdk.jmh.generators.BenchmarkProcessor" + ] + }, + "org.springframework:spring-core": { + "reactor.blockhound.integration.BlockHoundIntegration": [ + "org.springframework.core.ReactiveAdapterRegistry$SpringCoreBlockHoundIntegration" + ] + }, + "org.springframework:spring-jcl": { + "org.apache.commons.logging.LogFactory": [ + "org.apache.commons.logging.LogFactoryService" + ] + }, + "org.springframework:spring-web": { + "jakarta.servlet.ServletContainerInitializer": [ + "org.springframework.web.SpringServletContainerInitializer" + ], + "reactor.blockhound.integration.BlockHoundIntegration": [ + "org.springframework.web.server.adapter.WebHttpHandlerBuilder$SpringWebBlockHoundIntegration" + ] + }, + "xalan:xalan": { + "javax.xml.transform.TransformerFactory": [ + "org.apache.xalan.processor.TransformerFactoryImpl" + ], + "javax.xml.xpath.XPathFactory": [ + "org.apache.xpath.jaxp.XPathFactoryImpl" + ], + "org.apache.xalan.extensions.bsf.BSFManager": [ + "org.apache.bsf.BSFManager" + ], + "org.apache.xml.dtm.DTMManager": [ + "org.apache.xml.dtm.ref.DTMManagerDefault" + ] + } + }, "version": "2" } diff --git a/renovate.json5 b/renovate.json5 new file mode 100644 index 000000000..83fba4293 --- /dev/null +++ b/renovate.json5 @@ -0,0 +1,42 @@ +{ + $schema: "https://docs.renovatebot.com/renovate-schema.json", + extends: [ + "config:recommended", + ":dependencyDashboard", + "group:all", + "schedule:weekly" + ], + customManagers: [ + { + description: "Maven dependencies managed by rules_jvm_external", + customType: "regex", + fileMatch: [ + "^MODULE.bazel$" + ], + matchStringsStrategy: "recursive", + matchStrings: [ + // First narrow down the search to those dependencies in a Starlark list annotated with + // a special comment. + "# renovate: keep updated[^\\]]*]", + // Match all lines of the form: + // "com.google.guava:guava:jar:28.2-jre", + "\\n\\s*\"(?[^:]+:[^:]+):(?:jar:)?(?\\d[^\"]*)\"," + ], + datasourceTemplate: "maven" + } + ], + packageRules: [ + { + // Assign regex matches to a separate group since these PRs require manual lockfile updates. + matchManagers: ["regex"], + groupName: "Maven deps", + groupSlug: "maven", + }, + { + // System scoped Maven dependencies are build locally. + matchDepTypes: ["system"], + matchManagers: ["maven"], + enabled: false + } + ] +} diff --git a/repositories.bzl b/repositories.bzl deleted file mode 100644 index cd07d4590..000000000 --- a/repositories.bzl +++ /dev/null @@ -1,193 +0,0 @@ -# Copyright 2021 Code Intelligence GmbH -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Contains the external dependencies required to build Jazzer (but not the examples).""" - -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_jar") -load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") -load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") - -def jazzer_dependencies(android = False): - maybe( - http_archive, - name = "platforms", - sha256 = "3a561c99e7bdbe9173aa653fd579fe849f1d8d67395780ab4770b1f381431d51", - urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.7/platforms-0.0.7.tar.gz", - "https://github.com/bazelbuild/platforms/releases/download/0.0.7/platforms-0.0.7.tar.gz", - ], - ) - - maybe( - http_archive, - name = "bazel_skylib", - sha256 = "ade20530fd2d39abb49d537e77d4d873a823649b6061e0bb0c369b34450909d6", - strip_prefix = "bazel-skylib-8386b9d32bf69dd2d2f92d9ca39582cf6dabeb37", - # TODO: Return to the next release. - urls = [ - "https://github.com/bazelbuild/bazel-skylib/archive/8386b9d32bf69dd2d2f92d9ca39582cf6dabeb37.tar.gz", - ], - ) - - maybe( - http_archive, - name = "io_bazel_rules_kotlin", - sha256 = "a630cda9fdb4f56cf2dc20a4bf873765c41cf00e9379e8d59cd07b24730f4fde", - url = "https://github.com/bazelbuild/rules_kotlin/releases/download/v1.8.1/rules_kotlin_release.tgz", - ) - - maybe( - http_archive, - name = "rules_jvm_external", - sha256 = "5061364ad9c53de3d2072975f6c14768f2982bbf4101442306270554b317772e", - strip_prefix = "rules_jvm_external-f0c92a5aa7a9ea457ec3b89c76c59ff72829d9d7", - url = "https://github.com/bazelbuild/rules_jvm_external/archive/f0c92a5aa7a9ea457ec3b89c76c59ff72829d9d7.tar.gz", - ) - - maybe( - http_archive, - name = "build_bazel_apple_support", - sha256 = "62cb8c6658739d22986bbe4b025fe9f0f42cce91394096dc85d64b120ccde229", - url = "https://github.com/bazelbuild/apple_support/releases/download/1.10.1/apple_support.1.10.1.tar.gz", - ) - - maybe( - http_archive, - name = "com_google_absl", - sha256 = "987ce98f02eefbaf930d6e38ab16aa05737234d7afbab2d5c4ea7adbe50c28ed", - strip_prefix = "abseil-cpp-20230802.1", - url = "https://github.com/abseil/abseil-cpp/archive/refs/tags/20230802.1.tar.gz", - ) - - maybe( - http_archive, - name = "com_github_johnynek_bazel_jar_jar", - sha256 = "7487df7cf64ef85bdd5ffc6a0aff92c46ff7550a663c41b262d53f9dc90cd53d", - strip_prefix = "bazel_jar_jar-4e7bf26da8bc8c955578fd8c8a2c763757d344df", - url = "https://github.com/bazeltools/bazel_jar_jar/archive/4e7bf26da8bc8c955578fd8c8a2c763757d344df.tar.gz", - ) - - maybe( - http_archive, - name = "com_github_jhalterman_typetools", - build_file = Label("//third_party:typetools.BUILD"), - sha256 = "4e11a613aebb3c35deef58d5d942e44802da1a6c6ef7f127419261f00a0a082c", - strip_prefix = "typetools-commit-887153d2a9adf032fac9f145594d0a0248618d48", - url = "https://github.com/CodeIntelligenceTesting/typetools/archive/refs/tags/commit-887153d2a9adf032fac9f145594d0a0248618d48.tar.gz", - ) - - maybe( - http_archive, - build_file = Label("//third_party:classgraph.BUILD"), - name = "com_github_classgraph_classgraph", - sha256 = "83f3c193e90b77487cfc24fb6f73e9624e7478d9be4f94e2b20a29165a1aa906", - strip_prefix = "classgraph-classgraph-4.8.162", - url = "https://github.com/classgraph/classgraph/archive/refs/tags/classgraph-4.8.162.tar.gz", - ) - - maybe( - http_archive, - name = "fmeum_rules_jni", - sha256 = "8ea1e90d5f8ab85a2e267f68e4b7e59d9e27b00de533059ab1d829ece2b8bca0", - url = "https://github.com/fmeum/rules_jni/releases/download/v0.8.0/rules_jni-0.8.0.tar.gz", - ) - - maybe( - http_jar, - name = "net_bytebuddy_byte_buddy_agent", - sha256 = "f7c60fd229df2b0f4e390f50e0582a23ac1d895645df0d487c54dd67a289800b", - url = "https://repo1.maven.org/maven2/net/bytebuddy/byte-buddy-agent/1.14.8/byte-buddy-agent-1.14.8.jar", - ) - - maybe( - http_jar, - name = "org_ow2_asm_asm", - sha256 = "3c6fac2424db3d4a853b669f4e3d1d9c3c552235e19a319673f887083c2303a1", - url = "https://repo1.maven.org/maven2/org/ow2/asm/asm/9.6/asm-9.6.jar", - ) - - maybe( - http_jar, - name = "org_ow2_asm_asm_commons", - sha256 = "7aefd0d5c0901701c69f7513feda765fb6be33af2ce7aa17c5781fc87657c511", - url = "https://repo1.maven.org/maven2/org/ow2/asm/asm-commons/9.6/asm-commons-9.6.jar", - ) - - maybe( - http_jar, - name = "org_ow2_asm_asm_tree", - sha256 = "c43ecf17b539c777e15da7b5b86553b377e2d39a683de6285567d5283888e7ef", - url = "https://repo1.maven.org/maven2/org/ow2/asm/asm-tree/9.6/asm-tree-9.6.jar", - ) - - maybe( - http_jar, - name = "com_github_jsqlparser_jsqlparser", - sha256 = "9d25de1d79a669352f0d535daee906c2e35e8162e6894d82ea3f0aad8545655e", - url = "https://repo1.maven.org/maven2/com/github/jsqlparser/jsqlparser/4.7/jsqlparser-4.7.jar", - ) - - maybe( - http_jar, - name = "com_google_errorprone_error_prone_annotations", - sha256 = "9e6814cb71816988a4fd1b07a993a8f21bb7058d522c162b1de849e19bea54ae", - url = "https://repo1.maven.org/maven2/com/google/errorprone/error_prone_annotations/2.18.0/error_prone_annotations-2.18.0.jar", - ) - - maybe( - http_jar, - name = "com_google_errorprone_error_prone_type_annotations", - sha256 = "d2ab73bc6807277f7463391504313e47bc3465ab1916339c8e82be633a9ab375", - url = "https://repo1.maven.org/maven2/com/google/errorprone/error_prone_type_annotations/2.18.0/error_prone_type_annotations-2.18.0.jar", - ) - - maybe( - http_jar, - name = "com_google_protobuf_protobuf_java", - sha256 = "e5655522be1aa5cc1f2f092aa036b0445157f294928eedf1332ac938c7b69686", - # Keep in sync with com_google_protobuf in WORKSPACE. - url = "https://repo1.maven.org/maven2/com/google/protobuf/protobuf-java/3.24.4/protobuf-java-3.24.4.jar", - ) - - maybe( - http_archive, - name = "jazzer_jacoco", - build_file = Label("//third_party:jacoco_internal.BUILD"), - patches = [ - Label("//third_party:jacoco-make-probe-adapter-subclassable.patch"), - Label("//third_party:jacoco-make-probe-inserter-subclassable.patch"), - Label("//third_party:jacoco-ignore-offline-instrumentation.patch"), - ], - sha256 = "5c72dea2d13eef33a4d972d157186fc12d85149bc042186953efe1be50c220ee", - strip_prefix = "jacoco-0.8.10", - url = "https://github.com/jacoco/jacoco/archive/refs/tags/v0.8.10.tar.gz", - ) - - maybe( - http_archive, - name = "jazzer_libfuzzer", - build_file = Label("//third_party:libFuzzer.BUILD"), - sha256 = "200b32c897b1171824462706f577d7f1d6175da602eccfe570d2dceeac11d490", - strip_prefix = "llvm-project-jazzer-2023-04-25/compiler-rt/lib/fuzzer", - url = "https://github.com/CodeIntelligenceTesting/llvm-project-jazzer/archive/refs/tags/2023-04-25.tar.gz", - ) - - if android: - maybe( - git_repository, - name = "jazzer_slicer", - remote = "https://android.googlesource.com/platform/tools/dexter", - build_file = "//third_party:slicer.BUILD", - commit = "0fe35538da107ff48da6e9f9b92b55b014973bf8", - ) diff --git a/sanitizers/sanitizers.bzl b/sanitizers/sanitizers.bzl index 7a7294364..8fa0780c3 100644 --- a/sanitizers/sanitizers.bzl +++ b/sanitizers/sanitizers.bzl @@ -1,16 +1,13 @@ -# Copyright 2021 Code Intelligence GmbH # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Copyright 2024 Code Intelligence GmbH # -# http://www.apache.org/licenses/LICENSE-2.0 +# By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. +# +# The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt +# located in the root directory of the project. +# +# This file also contains code licensed under Apache2 license. # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. _sanitizer_package_prefix = "com.code_intelligence.jazzer.sanitizers." diff --git a/sanitizers/src/main/java/com/code_intelligence/jazzer/sanitizers/BUILD.bazel b/sanitizers/src/main/java/com/code_intelligence/jazzer/sanitizers/BUILD.bazel index ccd59c53c..2498c8df1 100644 --- a/sanitizers/src/main/java/com/code_intelligence/jazzer/sanitizers/BUILD.bazel +++ b/sanitizers/src/main/java/com/code_intelligence/jazzer/sanitizers/BUILD.bazel @@ -1,5 +1,5 @@ load("@bazel_skylib//rules:write_file.bzl", "write_file") -load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library") +load("@rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library") load("//bazel:kotlin.bzl", "ktlint") load("//sanitizers:sanitizers.bzl", "SANITIZER_CLASSES") @@ -30,7 +30,7 @@ java_library( srcs = ["SqlInjection.java"], deps = [ "//src/main/java/com/code_intelligence/jazzer/api:hooks", - "@com_github_jsqlparser_jsqlparser//jar", + "@maven//:com_github_jsqlparser_jsqlparser", ], ) diff --git a/sanitizers/src/main/java/com/code_intelligence/jazzer/sanitizers/ClojureLangHooks.java b/sanitizers/src/main/java/com/code_intelligence/jazzer/sanitizers/ClojureLangHooks.java index 07c3ea9cc..d5aa3f289 100644 --- a/sanitizers/src/main/java/com/code_intelligence/jazzer/sanitizers/ClojureLangHooks.java +++ b/sanitizers/src/main/java/com/code_intelligence/jazzer/sanitizers/ClojureLangHooks.java @@ -1,16 +1,11 @@ -// Copyright 2021 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.code_intelligence.jazzer.sanitizers; diff --git a/sanitizers/src/main/java/com/code_intelligence/jazzer/sanitizers/Deserialization.kt b/sanitizers/src/main/java/com/code_intelligence/jazzer/sanitizers/Deserialization.kt index 0ecbbf9fe..996a3f10f 100644 --- a/sanitizers/src/main/java/com/code_intelligence/jazzer/sanitizers/Deserialization.kt +++ b/sanitizers/src/main/java/com/code_intelligence/jazzer/sanitizers/Deserialization.kt @@ -1,16 +1,11 @@ -// Copyright 2021 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.code_intelligence.jazzer.sanitizers diff --git a/sanitizers/src/main/java/com/code_intelligence/jazzer/sanitizers/ExpressionLanguageInjection.kt b/sanitizers/src/main/java/com/code_intelligence/jazzer/sanitizers/ExpressionLanguageInjection.kt index a60c088eb..cfe245b6f 100644 --- a/sanitizers/src/main/java/com/code_intelligence/jazzer/sanitizers/ExpressionLanguageInjection.kt +++ b/sanitizers/src/main/java/com/code_intelligence/jazzer/sanitizers/ExpressionLanguageInjection.kt @@ -1,17 +1,12 @@ -// Copyright 2021 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.code_intelligence.jazzer.sanitizers diff --git a/sanitizers/src/main/java/com/code_intelligence/jazzer/sanitizers/LdapInjection.kt b/sanitizers/src/main/java/com/code_intelligence/jazzer/sanitizers/LdapInjection.kt index 76553e1a9..bb2dbaa1d 100644 --- a/sanitizers/src/main/java/com/code_intelligence/jazzer/sanitizers/LdapInjection.kt +++ b/sanitizers/src/main/java/com/code_intelligence/jazzer/sanitizers/LdapInjection.kt @@ -1,16 +1,13 @@ -// Copyright 2021 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + * + * This file also contains code licensed under Apache2 license. + */ package com.code_intelligence.jazzer.sanitizers diff --git a/sanitizers/src/main/java/com/code_intelligence/jazzer/sanitizers/NamingContextLookup.kt b/sanitizers/src/main/java/com/code_intelligence/jazzer/sanitizers/NamingContextLookup.kt index 51cf64533..e058a9895 100644 --- a/sanitizers/src/main/java/com/code_intelligence/jazzer/sanitizers/NamingContextLookup.kt +++ b/sanitizers/src/main/java/com/code_intelligence/jazzer/sanitizers/NamingContextLookup.kt @@ -1,16 +1,11 @@ -// Copyright 2021 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.code_intelligence.jazzer.sanitizers diff --git a/sanitizers/src/main/java/com/code_intelligence/jazzer/sanitizers/OsCommandInjection.kt b/sanitizers/src/main/java/com/code_intelligence/jazzer/sanitizers/OsCommandInjection.kt index 87de35c7c..0398b2360 100644 --- a/sanitizers/src/main/java/com/code_intelligence/jazzer/sanitizers/OsCommandInjection.kt +++ b/sanitizers/src/main/java/com/code_intelligence/jazzer/sanitizers/OsCommandInjection.kt @@ -1,16 +1,11 @@ -// Copyright 2021 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.code_intelligence.jazzer.sanitizers diff --git a/sanitizers/src/main/java/com/code_intelligence/jazzer/sanitizers/ReflectiveCall.kt b/sanitizers/src/main/java/com/code_intelligence/jazzer/sanitizers/ReflectiveCall.kt index 62d581523..ea71535e9 100644 --- a/sanitizers/src/main/java/com/code_intelligence/jazzer/sanitizers/ReflectiveCall.kt +++ b/sanitizers/src/main/java/com/code_intelligence/jazzer/sanitizers/ReflectiveCall.kt @@ -1,16 +1,11 @@ -// Copyright 2021 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.code_intelligence.jazzer.sanitizers diff --git a/sanitizers/src/main/java/com/code_intelligence/jazzer/sanitizers/RegexInjection.kt b/sanitizers/src/main/java/com/code_intelligence/jazzer/sanitizers/RegexInjection.kt index 5770f0c23..67fbdcfd8 100644 --- a/sanitizers/src/main/java/com/code_intelligence/jazzer/sanitizers/RegexInjection.kt +++ b/sanitizers/src/main/java/com/code_intelligence/jazzer/sanitizers/RegexInjection.kt @@ -1,16 +1,11 @@ -// Copyright 2022 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.code_intelligence.jazzer.sanitizers diff --git a/sanitizers/src/main/java/com/code_intelligence/jazzer/sanitizers/RegexRoadblocks.java b/sanitizers/src/main/java/com/code_intelligence/jazzer/sanitizers/RegexRoadblocks.java index 7026684ac..6903e3163 100644 --- a/sanitizers/src/main/java/com/code_intelligence/jazzer/sanitizers/RegexRoadblocks.java +++ b/sanitizers/src/main/java/com/code_intelligence/jazzer/sanitizers/RegexRoadblocks.java @@ -1,16 +1,11 @@ -// Copyright 2022 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.code_intelligence.jazzer.sanitizers; diff --git a/sanitizers/src/main/java/com/code_intelligence/jazzer/sanitizers/ServerSideRequestForgery.java b/sanitizers/src/main/java/com/code_intelligence/jazzer/sanitizers/ServerSideRequestForgery.java index ffcc185d6..6c573a0b3 100644 --- a/sanitizers/src/main/java/com/code_intelligence/jazzer/sanitizers/ServerSideRequestForgery.java +++ b/sanitizers/src/main/java/com/code_intelligence/jazzer/sanitizers/ServerSideRequestForgery.java @@ -1,17 +1,10 @@ /* - * Copyright 2023 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.code_intelligence.jazzer.sanitizers; @@ -28,8 +21,16 @@ public class ServerSideRequestForgery { // Set via reflection by Jazzer's BugDetectors API. + // Allow connections to all hosts and ports until before a fuzz target is executed for the first + // time. This allows the fuzzing setup to connect anywhere without triggering an SSRF-finding + // during initialization. public static final AtomicReference> connectionPermitted = - new AtomicReference<>((host, port) -> false); + new AtomicReference<>((host, port) -> true); + + // Disallow all connections right before the first fuzz target is executed. + static { + Jazzer.onFuzzTargetReady(() -> connectionPermitted.set((host, port) -> false)); + } /** * {@link java.net.Socket} is used in many JDK classes to open network connections. Internally it diff --git a/sanitizers/src/main/java/com/code_intelligence/jazzer/sanitizers/SqlInjection.java b/sanitizers/src/main/java/com/code_intelligence/jazzer/sanitizers/SqlInjection.java index 7f515b727..c5bb6813e 100644 --- a/sanitizers/src/main/java/com/code_intelligence/jazzer/sanitizers/SqlInjection.java +++ b/sanitizers/src/main/java/com/code_intelligence/jazzer/sanitizers/SqlInjection.java @@ -1,16 +1,11 @@ -// Copyright 2022 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.code_intelligence.jazzer.sanitizers; diff --git a/sanitizers/src/main/java/com/code_intelligence/jazzer/sanitizers/Utils.kt b/sanitizers/src/main/java/com/code_intelligence/jazzer/sanitizers/Utils.kt index 219490d8e..8e1d5df9e 100644 --- a/sanitizers/src/main/java/com/code_intelligence/jazzer/sanitizers/Utils.kt +++ b/sanitizers/src/main/java/com/code_intelligence/jazzer/sanitizers/Utils.kt @@ -1,16 +1,11 @@ -// Copyright 2021 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.code_intelligence.jazzer.sanitizers diff --git a/sanitizers/src/main/java/com/code_intelligence/jazzer/sanitizers/utils/ReflectionUtils.java b/sanitizers/src/main/java/com/code_intelligence/jazzer/sanitizers/utils/ReflectionUtils.java index a5527e7e0..2563c4424 100644 --- a/sanitizers/src/main/java/com/code_intelligence/jazzer/sanitizers/utils/ReflectionUtils.java +++ b/sanitizers/src/main/java/com/code_intelligence/jazzer/sanitizers/utils/ReflectionUtils.java @@ -1,16 +1,11 @@ -// Copyright 2022 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.code_intelligence.jazzer.sanitizers.utils; diff --git a/sanitizers/src/test/java/com/example/ClassLoaderLoadClass.java b/sanitizers/src/test/java/com/example/ClassLoaderLoadClass.java index 711e723a0..18f120041 100644 --- a/sanitizers/src/test/java/com/example/ClassLoaderLoadClass.java +++ b/sanitizers/src/test/java/com/example/ClassLoaderLoadClass.java @@ -1,16 +1,11 @@ -// Copyright 2021 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example; diff --git a/sanitizers/src/test/java/com/example/ClojureTests.java b/sanitizers/src/test/java/com/example/ClojureTests.java index 7cfbe1c93..67ffb0366 100644 --- a/sanitizers/src/test/java/com/example/ClojureTests.java +++ b/sanitizers/src/test/java/com/example/ClojureTests.java @@ -1,16 +1,11 @@ -// Copyright 2022 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example; diff --git a/sanitizers/src/test/java/com/example/DisabledHooksTest.java b/sanitizers/src/test/java/com/example/DisabledHooksTest.java index 68903d6a5..3246c8a0b 100644 --- a/sanitizers/src/test/java/com/example/DisabledHooksTest.java +++ b/sanitizers/src/test/java/com/example/DisabledHooksTest.java @@ -1,16 +1,11 @@ -// Copyright 2022 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example; diff --git a/sanitizers/src/test/java/com/example/ExpressionLanguageInjection.java b/sanitizers/src/test/java/com/example/ExpressionLanguageInjection.java index 19d1ecbc6..cd923053b 100644 --- a/sanitizers/src/test/java/com/example/ExpressionLanguageInjection.java +++ b/sanitizers/src/test/java/com/example/ExpressionLanguageInjection.java @@ -1,16 +1,11 @@ -// Copyright 2021 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example; diff --git a/sanitizers/src/test/java/com/example/LdapDnInjection.java b/sanitizers/src/test/java/com/example/LdapDnInjection.java index 2fdf4a0c9..323c58a7f 100644 --- a/sanitizers/src/test/java/com/example/LdapDnInjection.java +++ b/sanitizers/src/test/java/com/example/LdapDnInjection.java @@ -1,16 +1,11 @@ -// Copyright 2021 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example; diff --git a/sanitizers/src/test/java/com/example/LdapSearchInjection.java b/sanitizers/src/test/java/com/example/LdapSearchInjection.java index 4ac84931e..2fae0313f 100644 --- a/sanitizers/src/test/java/com/example/LdapSearchInjection.java +++ b/sanitizers/src/test/java/com/example/LdapSearchInjection.java @@ -1,16 +1,11 @@ -// Copyright 2021 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example; diff --git a/sanitizers/src/test/java/com/example/LibraryLoad.java b/sanitizers/src/test/java/com/example/LibraryLoad.java index 4954deb15..fd00e2e18 100644 --- a/sanitizers/src/test/java/com/example/LibraryLoad.java +++ b/sanitizers/src/test/java/com/example/LibraryLoad.java @@ -1,16 +1,11 @@ -// Copyright 2021 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example; diff --git a/sanitizers/src/test/java/com/example/ObjectInputStreamDeserialization.java b/sanitizers/src/test/java/com/example/ObjectInputStreamDeserialization.java index c62856096..77b0dd0de 100644 --- a/sanitizers/src/test/java/com/example/ObjectInputStreamDeserialization.java +++ b/sanitizers/src/test/java/com/example/ObjectInputStreamDeserialization.java @@ -1,16 +1,11 @@ -// Copyright 2021 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example; diff --git a/sanitizers/src/test/java/com/example/OsCommandInjectionProcessBuilder.java b/sanitizers/src/test/java/com/example/OsCommandInjectionProcessBuilder.java index f5d527825..cf2ae7764 100644 --- a/sanitizers/src/test/java/com/example/OsCommandInjectionProcessBuilder.java +++ b/sanitizers/src/test/java/com/example/OsCommandInjectionProcessBuilder.java @@ -1,16 +1,11 @@ -// Copyright 2021 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example; diff --git a/sanitizers/src/test/java/com/example/OsCommandInjectionRuntimeExec.java b/sanitizers/src/test/java/com/example/OsCommandInjectionRuntimeExec.java index c620a7518..f964e6941 100644 --- a/sanitizers/src/test/java/com/example/OsCommandInjectionRuntimeExec.java +++ b/sanitizers/src/test/java/com/example/OsCommandInjectionRuntimeExec.java @@ -1,16 +1,11 @@ -// Copyright 2021 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example; diff --git a/sanitizers/src/test/java/com/example/ReflectiveCall.java b/sanitizers/src/test/java/com/example/ReflectiveCall.java index d7b3e46cb..cc035fec8 100644 --- a/sanitizers/src/test/java/com/example/ReflectiveCall.java +++ b/sanitizers/src/test/java/com/example/ReflectiveCall.java @@ -1,16 +1,11 @@ -// Copyright 2021 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example; diff --git a/sanitizers/src/test/java/com/example/RegexCanonEqInjection.java b/sanitizers/src/test/java/com/example/RegexCanonEqInjection.java index e2d0b722b..339e4dfad 100644 --- a/sanitizers/src/test/java/com/example/RegexCanonEqInjection.java +++ b/sanitizers/src/test/java/com/example/RegexCanonEqInjection.java @@ -1,16 +1,11 @@ -// Copyright 2022 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example; diff --git a/sanitizers/src/test/java/com/example/RegexInsecureQuoteInjection.java b/sanitizers/src/test/java/com/example/RegexInsecureQuoteInjection.java index a548cfb2c..9838d16fb 100644 --- a/sanitizers/src/test/java/com/example/RegexInsecureQuoteInjection.java +++ b/sanitizers/src/test/java/com/example/RegexInsecureQuoteInjection.java @@ -1,16 +1,11 @@ -// Copyright 2022 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example; diff --git a/sanitizers/src/test/java/com/example/RegexRoadblocks.java b/sanitizers/src/test/java/com/example/RegexRoadblocks.java index 4172c082d..02d39d703 100644 --- a/sanitizers/src/test/java/com/example/RegexRoadblocks.java +++ b/sanitizers/src/test/java/com/example/RegexRoadblocks.java @@ -1,16 +1,11 @@ -// Copyright 2022 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example; diff --git a/sanitizers/src/test/java/com/example/ScriptEngineInjection.java b/sanitizers/src/test/java/com/example/ScriptEngineInjection.java index 5a5236896..247997de3 100644 --- a/sanitizers/src/test/java/com/example/ScriptEngineInjection.java +++ b/sanitizers/src/test/java/com/example/ScriptEngineInjection.java @@ -1,16 +1,13 @@ -// Copyright 2023 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + * + * This file also contains code licensed under Apache2 license. + */ package com.example; diff --git a/sanitizers/src/test/java/com/example/SqlInjection.java b/sanitizers/src/test/java/com/example/SqlInjection.java index 8bd9e0dba..8bfbfbcda 100644 --- a/sanitizers/src/test/java/com/example/SqlInjection.java +++ b/sanitizers/src/test/java/com/example/SqlInjection.java @@ -1,16 +1,11 @@ -// Copyright 2022 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example; diff --git a/sanitizers/src/test/java/com/example/SsrfHttpClient.java b/sanitizers/src/test/java/com/example/SsrfHttpClient.java index 6da561a97..8c471808c 100644 --- a/sanitizers/src/test/java/com/example/SsrfHttpClient.java +++ b/sanitizers/src/test/java/com/example/SsrfHttpClient.java @@ -1,16 +1,11 @@ -// Copyright 2023 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example; diff --git a/sanitizers/src/test/java/com/example/SsrfSocketConnect.java b/sanitizers/src/test/java/com/example/SsrfSocketConnect.java index f1d7a59b0..6a3528873 100644 --- a/sanitizers/src/test/java/com/example/SsrfSocketConnect.java +++ b/sanitizers/src/test/java/com/example/SsrfSocketConnect.java @@ -1,16 +1,11 @@ -// Copyright 2023 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example; diff --git a/sanitizers/src/test/java/com/example/SsrfSocketConnectToHost.java b/sanitizers/src/test/java/com/example/SsrfSocketConnectToHost.java index e3afb2580..d53df515d 100644 --- a/sanitizers/src/test/java/com/example/SsrfSocketConnectToHost.java +++ b/sanitizers/src/test/java/com/example/SsrfSocketConnectToHost.java @@ -1,16 +1,11 @@ -// Copyright 2023 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example; diff --git a/sanitizers/src/test/java/com/example/SsrfUrlConnection.java b/sanitizers/src/test/java/com/example/SsrfUrlConnection.java index 8ea940a16..885711589 100644 --- a/sanitizers/src/test/java/com/example/SsrfUrlConnection.java +++ b/sanitizers/src/test/java/com/example/SsrfUrlConnection.java @@ -1,16 +1,11 @@ -// Copyright 2023 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example; diff --git a/sanitizers/src/test/java/com/example/StackOverflowRegexInjection.java b/sanitizers/src/test/java/com/example/StackOverflowRegexInjection.java index 8abb4faa6..6f66de2b0 100644 --- a/sanitizers/src/test/java/com/example/StackOverflowRegexInjection.java +++ b/sanitizers/src/test/java/com/example/StackOverflowRegexInjection.java @@ -1,16 +1,11 @@ -// Copyright 2022 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example; diff --git a/sanitizers/src/test/java/com/example/el/InsecureEmailValidator.java b/sanitizers/src/test/java/com/example/el/InsecureEmailValidator.java index e10b082ec..945883734 100644 --- a/sanitizers/src/test/java/com/example/el/InsecureEmailValidator.java +++ b/sanitizers/src/test/java/com/example/el/InsecureEmailValidator.java @@ -1,16 +1,11 @@ -// Copyright 2021 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example.el; diff --git a/sanitizers/src/test/java/com/example/el/UserData.java b/sanitizers/src/test/java/com/example/el/UserData.java index b11afe1ca..c94b7ae49 100644 --- a/sanitizers/src/test/java/com/example/el/UserData.java +++ b/sanitizers/src/test/java/com/example/el/UserData.java @@ -1,17 +1,10 @@ /* - * Copyright 2023 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.example.el; diff --git a/sanitizers/src/test/java/com/example/ldap/MockLdapContext.java b/sanitizers/src/test/java/com/example/ldap/MockLdapContext.java index 10cb02f5e..1a7b00492 100644 --- a/sanitizers/src/test/java/com/example/ldap/MockLdapContext.java +++ b/sanitizers/src/test/java/com/example/ldap/MockLdapContext.java @@ -1,16 +1,11 @@ -// Copyright 2021 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example.ldap; diff --git a/selffuzz/BUILD.bazel b/selffuzz/BUILD.bazel index 44ea77ec8..41356293d 100644 --- a/selffuzz/BUILD.bazel +++ b/selffuzz/BUILD.bazel @@ -1,4 +1,4 @@ -load("@com_github_johnynek_bazel_jar_jar//:jar_jar.bzl", "jar_jar") +load("@bazel_jar_jar//:jar_jar.bzl", "jar_jar") jar_jar( name = "jazzer_selffuzz", diff --git a/selffuzz/ci-settings.xml b/selffuzz/ci-settings.xml new file mode 100644 index 000000000..d1c8729ff --- /dev/null +++ b/selffuzz/ci-settings.xml @@ -0,0 +1,18 @@ + + + + + + code-intelligence + ${env.REPOSITORY_USER} + ${env.REPOSITORY_TOKEN} + + + diff --git a/selffuzz/cifuzz.yaml b/selffuzz/cifuzz.yaml index 8d19f1073..12c60ed43 100644 --- a/selffuzz/cifuzz.yaml +++ b/selffuzz/cifuzz.yaml @@ -1,16 +1,11 @@ -# Copyright 2023 Code Intelligence GmbH # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Copyright 2024 Code Intelligence GmbH # -# http://www.apache.org/licenses/LICENSE-2.0 +# By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. +# +# The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt +# located in the root directory of the project. # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. ## Configuration for a CI Fuzz project ## Generated on 2023-06-15 @@ -37,7 +32,7 @@ ## Command-line arguments to pass to libFuzzer. ## See https://llvm.org/docs/LibFuzzer.html#options engine-args: - - --experimental_mutator + - -print_final_stats=1 ## Maximum time to run fuzz tests. The default is to run indefinitely. timeout: 5m @@ -51,15 +46,13 @@ timeout: 5m #print-json: true ## Set to true to disable desktop notifications. -#no-notifications: true +no-notifications: true -## Set URL of the CI App. +## Set URL of CI Sense. #server: https://app.code-intelligence.com -## Set the project name on the CI App. -#project: my-project-1a2b3c4d +## Set the project name on CI Sense. +project: Jazzer-39e8ed3a ## Style for CI Fuzz. #style: plain - -project: Jazzer-39e8ed3a diff --git a/selffuzz/pom.xml b/selffuzz/pom.xml index 39026a16e..9e5b8603d 100644 --- a/selffuzz/pom.xml +++ b/selffuzz/pom.xml @@ -1,19 +1,12 @@ + ~ Copyright 2024 Code Intelligence GmbH + ~ + ~ By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + ~ + ~ The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + ~ located in the root directory of the project. + --> org.junit.jupiter junit-jupiter-engine - 5.9.2 + 5.10.2 test org.junit.jupiter junit-jupiter-api - 5.9.2 + 5.10.2 test org.junit.jupiter junit-jupiter-params - 5.9.2 + 5.10.2 test org.junit.platform junit-platform-commons - 1.9.2 + 1.10.2 test org.junit.platform junit-platform-launcher - 1.9.2 + 1.10.2 test @@ -131,7 +124,7 @@ com.google.truth truth - 1.1.3 + 1.4.0 test special value 1 + 2 + // record field is null due to recursion + )) { + record = mutator.init(prng); + assertThat(record).isEqualTo(new RecursiveTypesRecord(1, null)); + } + + try (MockPseudoRandom prng = + mockPseudoRandom( + 1, + // --> special value 0 for int field in nested record + 1 + // nested record field is null due to recursion + )) { + record = mutator.mutate(record, prng); + assertThat(record).isEqualTo(new RecursiveTypesRecord(1, new RecursiveTypesRecord(0, null))); + assertThat(mutator.detach(record)).isSameInstanceAs(record); + } + } + + record PropagateInnerTypeRecord(List list) {} + + record PropagateTypeRecord(PropagateInnerTypeRecord inner) {} + + @Test + void propagateConstraint() { + SerializingMutator<@NotNull PropagateTypeRecord> mutator = + (SerializingMutator<@NotNull PropagateTypeRecord>) + Mutators.newFactory() + .createOrThrow( + new TypeHolder< + @NotNull(constraint = PropertyConstraint.RECURSIVE) + PropagateTypeRecord>() {}.annotatedType()); + assertThat(mutator.toString()) + .isEqualTo("[[List] -> PropagateInnerTypeRecord] -> PropagateTypeRecord"); + } +} diff --git a/src/test/java/com/code_intelligence/jazzer/mutation/mutator/aggregate/SetterBasedBeanMutatorTest.java b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/aggregate/SetterBasedBeanMutatorTest.java new file mode 100644 index 000000000..8ab3a3166 --- /dev/null +++ b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/aggregate/SetterBasedBeanMutatorTest.java @@ -0,0 +1,219 @@ +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ + +package com.code_intelligence.jazzer.mutation.mutator.aggregate; + +import static com.code_intelligence.jazzer.mutation.support.TestSupport.anyPseudoRandom; +import static com.google.common.truth.Truth.assertThat; + +import com.code_intelligence.jazzer.mutation.annotation.NotNull; +import com.code_intelligence.jazzer.mutation.api.PseudoRandom; +import com.code_intelligence.jazzer.mutation.api.SerializingMutator; +import com.code_intelligence.jazzer.mutation.engine.ChainedMutatorFactory; +import com.code_intelligence.jazzer.mutation.mutator.Mutators; +import com.code_intelligence.jazzer.mutation.support.TypeHolder; +import com.code_intelligence.jazzer.mutation.utils.PropertyConstraint; +import java.util.Objects; +import java.util.stream.Stream; +import org.junit.jupiter.api.Test; + +@SuppressWarnings("unchecked") +class SetterBasedBeanMutatorTest { + + static class EmptyBean {} + + @Test + void testEmptyBean() { + assertThat( + ChainedMutatorFactory.of(Stream.of(new SetterBasedBeanMutatorFactory())) + .tryCreate(new TypeHolder<@NotNull EmptyBean>() {}.annotatedType())) + .isEmpty(); + } + + public static class SimpleTypeBean { + private boolean foo; + private String bar; + private int baz; + + boolean isFoo() { + return foo; + } + + void setFoo(boolean foo) { + this.foo = foo; + } + + public String getBar() { + return bar; + } + + public int getBaz() { + return baz; + } + + // Out-of-order setters are supported. + public void setBaz(int baz) { + this.baz = baz; + } + + // Chainable setters are supported. + public SimpleTypeBean setBar(String bar) { + this.bar = bar; + return this; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + SimpleTypeBean that = (SimpleTypeBean) o; + return foo == that.foo && baz == that.baz && Objects.equals(bar, that.bar); + } + + @Override + public int hashCode() { + return Objects.hash(foo, bar, baz); + } + + @Override + public String toString() { + return "SimpleTypeBean{" + "foo=" + foo + ", bar='" + bar + '\'' + ", baz=" + baz + '}'; + } + } + + @Test + void testSimpleTypeBean() { + SerializingMutator mutator = + (SerializingMutator) + Mutators.newFactory() + .createOrThrow(new TypeHolder<@NotNull SimpleTypeBean>() {}.annotatedType()); + assertThat(mutator.toString()) + .startsWith("[Nullable, Integer, Boolean] -> SimpleTypeBean"); + assertThat(mutator.hasFixedSize()).isFalse(); + + PseudoRandom prng = anyPseudoRandom(); + SimpleTypeBean inited = mutator.init(prng); + SimpleTypeBean mutated = mutator.mutate(inited, prng); + assertThat(mutated).isNotEqualTo(inited); + + SimpleTypeBean detached = mutator.detach(mutated); + assertThat(detached).isEqualTo(mutated); + assertThat(detached).isNotSameInstanceAs(mutated); + } + + static class RecursiveTypeBean { + private final int foo; + private final RecursiveTypeBean bar; + + public RecursiveTypeBean() { + this(0, null); + } + + private RecursiveTypeBean(int foo, RecursiveTypeBean bar) { + this.foo = foo; + this.bar = bar; + } + + public int getFoo() { + return foo; + } + + public RecursiveTypeBean setFoo(int foo) { + return new RecursiveTypeBean(foo, bar); + } + + public RecursiveTypeBean withBar(RecursiveTypeBean bar) { + return new RecursiveTypeBean(foo, bar); + } + + public RecursiveTypeBean getBar() { + return bar; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + RecursiveTypeBean that = (RecursiveTypeBean) o; + return foo == that.foo && Objects.equals(bar, that.bar); + } + + @Override + public int hashCode() { + return Objects.hash(foo, bar); + } + + @Override + public String toString() { + return "RecursiveTypeBean{" + "foo=" + foo + ", bar=" + bar + '}'; + } + } + + @Test + void testRecursiveTypeBean() { + SerializingMutator mutator = + (SerializingMutator) + Mutators.newFactory() + .createOrThrow(new TypeHolder<@NotNull RecursiveTypeBean>() {}.annotatedType()); + assertThat(mutator.toString()) + .startsWith( + "[Integer, Nullable RecursiveTypeBean)>] ->" + + " RecursiveTypeBean"); + assertThat(mutator.hasFixedSize()).isFalse(); + + PseudoRandom prng = anyPseudoRandom(); + RecursiveTypeBean inited = mutator.init(prng); + + RecursiveTypeBean mutated = mutator.mutate(inited, prng); + assertThat(mutated).isNotEqualTo(inited); + } + + public static class BeanWithParent extends SimpleTypeBean { + protected long quz; + + public long getQuz() { + return quz; + } + + public void setQuz(long quz) { + this.quz = quz; + } + } + + @Test + void testBeanWithParent() { + SerializingMutator mutator = + (SerializingMutator) + Mutators.newFactory() + .createOrThrow(new TypeHolder<@NotNull BeanWithParent>() {}.annotatedType()); + assertThat(mutator.toString()) + .startsWith("[Nullable, Integer, Boolean, Long] -> BeanWithParent"); + assertThat(mutator.hasFixedSize()).isFalse(); + + PseudoRandom prng = anyPseudoRandom(); + BeanWithParent inited = mutator.init(prng); + + BeanWithParent mutated = mutator.mutate(inited, prng); + assertThat(mutated).isNotEqualTo(inited); + } + + @Test + void propagateConstraint() { + SerializingMutator<@NotNull RecursiveTypeBean> mutator = + (SerializingMutator<@NotNull RecursiveTypeBean>) + Mutators.newFactory() + .createOrThrow( + new TypeHolder< + @NotNull(constraint = PropertyConstraint.RECURSIVE) + RecursiveTypeBean>() {}.annotatedType()); + assertThat(mutator.toString()) + .isEqualTo( + "[Integer, RecursionBreaking((cycle) -> RecursiveTypeBean)] -> RecursiveTypeBean"); + } +} diff --git a/src/test/java/com/code_intelligence/jazzer/mutation/mutator/aggregate/SuperBuilderMutatorTest.java b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/aggregate/SuperBuilderMutatorTest.java new file mode 100644 index 000000000..79a25e8e8 --- /dev/null +++ b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/aggregate/SuperBuilderMutatorTest.java @@ -0,0 +1,161 @@ +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ + +package com.code_intelligence.jazzer.mutation.mutator.aggregate; + +import static com.code_intelligence.jazzer.mutation.support.TestSupport.anyPseudoRandom; +import static com.google.common.truth.Truth.assertThat; + +import com.code_intelligence.jazzer.mutation.annotation.NotNull; +import com.code_intelligence.jazzer.mutation.api.PseudoRandom; +import com.code_intelligence.jazzer.mutation.api.SerializingMutator; +import com.code_intelligence.jazzer.mutation.mutator.Mutators; +import com.code_intelligence.jazzer.mutation.support.TypeHolder; +import com.code_intelligence.jazzer.mutation.utils.PropertyConstraint; +import org.junit.jupiter.api.Test; + +public class SuperBuilderMutatorTest { + + @SuppressWarnings({"FieldCanBeLocal", "unused"}) + static class Parent { + private String foo; + + protected Parent(ParentBuilder b) { + this.foo = b.foo; + } + + public static ParentBuilder builder() { + return new ParentBuilderImpl(); + } + + public abstract static class ParentBuilder> { + private String foo; + + public ParentBuilder() {} + + public B foo(String foo) { + this.foo = foo; + return this.self(); + } + + protected abstract B self(); + + public abstract C build(); + + public String toString() { + return "Parent.ParentBuilder(foo=" + this.foo + ")"; + } + } + + private static final class ParentBuilderImpl extends ParentBuilder { + private ParentBuilderImpl() {} + + protected ParentBuilderImpl self() { + return this; + } + + public Parent build() { + return new Parent(this); + } + } + } + + @Test + void testMutateSuperBuilderClass() { + SerializingMutator mutator = + (SerializingMutator) + Mutators.newFactory() + .createOrThrow(new TypeHolder<@NotNull Parent>() {}.annotatedType()); + assertThat(mutator.toString()).startsWith("[[Nullable] -> ParentBuilder] -> Parent"); + + assertThat(mutator.hasFixedSize()).isFalse(); + + PseudoRandom prng = anyPseudoRandom(); + Parent inited = mutator.init(prng); + + Parent mutated = mutator.mutate(inited, prng); + assertThat(mutated).isNotEqualTo(inited); + } + + @Test + void cascadePropertyConstraints() { + SerializingMutator mutator = + (SerializingMutator) + Mutators.newFactory() + .createOrThrow( + new TypeHolder< + @NotNull(constraint = PropertyConstraint.RECURSIVE) + Parent>() {}.annotatedType()); + assertThat(mutator.toString()).startsWith("[[String] -> ParentBuilder] -> Parent"); + } + + static class Child extends Parent { + private boolean bar; + + protected Child(ChildBuilder b) { + super(b); + this.bar = b.bar; + } + + public static ChildBuilder builder() { + return new ChildBuilderImpl(); + } + + public abstract static class ChildBuilder> + extends Parent.ParentBuilder { + private boolean bar; + + public ChildBuilder() {} + + public B bar(boolean bar) { + this.bar = bar; + return this.self(); + } + + protected abstract B self(); + + public abstract C build(); + + public String toString() { + String var10000 = super.toString(); + return "Child.ChildBuilder(super=" + var10000 + ", bar=" + this.bar + ")"; + } + } + + private static final class ChildBuilderImpl extends ChildBuilder { + private ChildBuilderImpl() {} + + protected ChildBuilderImpl self() { + return this; + } + + public Child build() { + return new Child(this); + } + } + } + + @Test + void testMutateSuperBuilderClassWithParent() { + SerializingMutator mutator = + (SerializingMutator) + Mutators.newFactory() + .createOrThrow(new TypeHolder<@NotNull Child>() {}.annotatedType()); + assertThat(mutator.toString()) + .startsWith("[[Boolean, Nullable] -> ChildBuilder] -> Child"); + + assertThat(mutator.hasFixedSize()).isFalse(); + + PseudoRandom prng = anyPseudoRandom(); + Child inited = mutator.init(prng); + + Child mutated = mutator.mutate(inited, prng); + assertThat(mutated).isNotEqualTo(inited); + } +} diff --git a/src/test/java/com/code_intelligence/jazzer/mutation/mutator/collection/ArrayMutatorTest.java b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/collection/ArrayMutatorTest.java new file mode 100644 index 000000000..b23c21692 --- /dev/null +++ b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/collection/ArrayMutatorTest.java @@ -0,0 +1,273 @@ +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ + +package com.code_intelligence.jazzer.mutation.mutator.collection; + +import static com.code_intelligence.jazzer.mutation.support.TestSupport.mockPseudoRandom; +import static com.google.common.truth.Truth.assertThat; + +import com.code_intelligence.jazzer.mutation.annotation.NotNull; +import com.code_intelligence.jazzer.mutation.annotation.WithLength; +import com.code_intelligence.jazzer.mutation.api.SerializingMutator; +import com.code_intelligence.jazzer.mutation.engine.ChainedMutatorFactory; +import com.code_intelligence.jazzer.mutation.mutator.lang.LangMutators; +import com.code_intelligence.jazzer.mutation.support.TestSupport.MockPseudoRandom; +import com.code_intelligence.jazzer.mutation.support.TypeHolder; +import com.code_intelligence.jazzer.mutation.utils.PropertyConstraint; +import java.lang.reflect.AnnotatedType; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class ArrayMutatorTest { + + ChainedMutatorFactory factory; + + @BeforeEach + void createFactory() { + factory = + ChainedMutatorFactory.of(LangMutators.newFactories(), CollectionMutators.newFactories()); + } + + private SerializingMutator<@NotNull Integer @NotNull []> defaultArrayMutator() { + AnnotatedType type = new TypeHolder<@NotNull Integer @NotNull []>() {}.annotatedType(); + return (SerializingMutator<@NotNull Integer @NotNull []>) factory.createOrThrow(type); + } + + @Test + void testInit() { + SerializingMutator<@NotNull Integer @NotNull []> mutator = + (SerializingMutator<@NotNull Integer @NotNull []>) + factory.createOrThrow( + new TypeHolder<@NotNull Integer @NotNull []>() {}.annotatedType()); + assertThat(mutator.toString()).isEqualTo("Integer[]"); + + Integer[] arr; + try (MockPseudoRandom prng = + mockPseudoRandom( + // targetSize + 1, + // elementMutator.init + 1)) { + arr = mutator.init(prng); + } + + assertThat(arr).asList().containsExactly(0); + } + + @Test + void testDetach() { + SerializingMutator mutator = + (SerializingMutator) + factory.createOrThrow( + new TypeHolder<@NotNull Integer @NotNull []>() {}.annotatedType()); + assertThat(mutator.toString()).isEqualTo("Integer[]"); + + Integer[] inited; + Integer[] detached; + try (MockPseudoRandom prng = + mockPseudoRandom( + // targetSize + 1, + // elementMutator.init + 1)) { + inited = mutator.init(prng); + detached = mutator.detach(inited); + } + + assertThat(detached).isInstanceOf(Integer[].class); + assertThat(detached).isEqualTo(inited); + assertThat(detached).isNotSameInstanceAs(inited); + } + + @Test + void testInitMaxLength() { + AnnotatedType type = + new TypeHolder< + @NotNull Integer @NotNull @WithLength(min = 2, max = 3) []>() {}.annotatedType(); + + SerializingMutator<@NotNull Integer @NotNull []> mutator = + (SerializingMutator<@NotNull Integer @NotNull []>) factory.createOrThrow(type); + + assertThat(mutator.toString()).isEqualTo("Integer[]"); + Integer[] arr; + try (MockPseudoRandom prng = mockPseudoRandom(2, 4, 42L, 4, 43L)) { + arr = mutator.init(prng); + } + + assertThat(arr).asList().containsExactly(42, 43).inOrder(); + } + + @Test + void testRemoveSingleElement() { + SerializingMutator<@NotNull Integer @NotNull []> mutator = defaultArrayMutator(); + + Integer[] arr = new Integer[] {1, 2, 3, 4, 5, 6, 7, 8, 9}; + try (MockPseudoRandom prng = + mockPseudoRandom( + // action + 0, + // number of elements to remove + 1, + // index to remove + 2)) { + arr = mutator.mutate(arr, prng); + } + assertThat(arr).asList().containsExactly(1, 2, 4, 5, 6, 7, 8, 9).inOrder(); + } + + @Test + void testRemoveChunk() { + SerializingMutator<@NotNull Integer @NotNull []> mutator = defaultArrayMutator(); + + Integer[] arr = new Integer[] {1, 2, 3, 4, 5, 6, 7, 8, 9}; + try (MockPseudoRandom prng = + mockPseudoRandom( + // action + 0, + // chunk size + 2, + // chunk offset + 3)) { + arr = mutator.mutate(arr, prng); + } + assertThat(arr).asList().containsExactly(1, 2, 3, 6, 7, 8, 9).inOrder(); + } + + @Test + void testAddSingleElement() { + SerializingMutator<@NotNull Integer @NotNull []> mutator = defaultArrayMutator(); + + Integer[] arr = new Integer[] {1, 2, 3, 4, 5, 6, 7, 8, 9}; + try (MockPseudoRandom prng = + mockPseudoRandom( + // action + 1, + // add single element, + 1, + // offset, + 9, + // Integral initImpl sentinel value + 4, + // value + 42L)) { + arr = mutator.mutate(arr, prng); + } + assertThat(arr).asList().containsExactly(1, 2, 3, 4, 5, 6, 7, 8, 9, 42).inOrder(); + } + + @Test + void testAddChunk() { + SerializingMutator<@NotNull Integer @NotNull []> mutator = defaultArrayMutator(); + + Integer[] arr = new Integer[] {1, 2, 3, 4, 5, 6, 7, 8, 9}; + + try (MockPseudoRandom prng = + mockPseudoRandom( + // action + 1, + // chunkSize + 2, + // chunkOffset + 3, + // Integral initImpl + 4, + // val + 42L, + // Integral initImpl + 4, + // val + 43L)) { + arr = mutator.mutate(arr, prng); + } + assertThat(arr).asList().containsExactly(1, 2, 3, 42, 43, 4, 5, 6, 7, 8, 9).inOrder(); + } + + @Test + void testChangeSingleElement() { + SerializingMutator<@NotNull Integer @NotNull []> mutator = defaultArrayMutator(); + + Integer[] arr = new Integer[] {1, 2, 3, 4, 5, 6, 7, 8, 9}; + + try (MockPseudoRandom prng = + mockPseudoRandom( + // action + 2, + // index to mutate at + 2, + // mutation choice based on `IntegralMutatorFactory` + // 2 == closedRange + 2, + // value + 55L)) { + arr = mutator.mutate(arr, prng); + } + assertThat(arr).asList().containsExactly(1, 2, 55, 4, 5, 6, 7, 8, 9).inOrder(); + } + + @Test + void testCrossOverEmptyArrays() { + SerializingMutator<@NotNull Integer @NotNull []> mutator = defaultArrayMutator(); + + try (MockPseudoRandom prng = + mockPseudoRandom( + // action CROSSOVER - MUTATE (only one in actions list) + 0, + // size + 1, + // index + 0, + // Integral initImpl + 4, + // val + 42L)) { + Integer[] arr = mutator.crossOver(new Integer[0], new Integer[0], prng); + // chooses mutation? + assertThat(arr).asList().containsExactly(42); + } + } + + @Test + void testCrossOverMix() { + SerializingMutator<@NotNull Integer @NotNull []> mutator = defaultArrayMutator(); + try (MockPseudoRandom prng = + mockPseudoRandom( + // action CROSSOVER: MIX + 7, + // length + 8, + // take from the first array + true, + // 2 elements + 2, + // take from the second array + false, + // 2 elements + 2, + // 1st array + true, + // 3 elements + 3)) { + Integer[] arr = + mutator.crossOver(new Integer[] {0, 1, 2, 3, 4}, new Integer[] {5, 6, 7, 8, 9}, prng); + // chooses mutation? + assertThat(arr).asList().containsExactly(0, 1, 5, 6, 2, 3, 4, 7).inOrder(); + } + } + + @Test + void propagateConstraint() { + SerializingMutator<@NotNull Integer[]> mutator = + (SerializingMutator<@NotNull Integer[]>) + factory.createOrThrow( + new TypeHolder< + Integer @NotNull(constraint = PropertyConstraint.RECURSIVE) + []>() {}.annotatedType()); + assertThat(mutator.toString()).isEqualTo("Integer[]"); + } +} diff --git a/src/test/java/com/code_intelligence/jazzer/mutation/mutator/collection/BUILD.bazel b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/collection/BUILD.bazel index 2e60b9d5d..f4da61b5e 100644 --- a/src/test/java/com/code_intelligence/jazzer/mutation/mutator/collection/BUILD.bazel +++ b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/collection/BUILD.bazel @@ -9,9 +9,11 @@ java_test_suite( deps = [ "//src/main/java/com/code_intelligence/jazzer/mutation/annotation", "//src/main/java/com/code_intelligence/jazzer/mutation/api", + "//src/main/java/com/code_intelligence/jazzer/mutation/engine", "//src/main/java/com/code_intelligence/jazzer/mutation/mutator/collection", "//src/main/java/com/code_intelligence/jazzer/mutation/mutator/lang", "//src/main/java/com/code_intelligence/jazzer/mutation/support", + "//src/main/java/com/code_intelligence/jazzer/mutation/utils", "//src/test/java/com/code_intelligence/jazzer/mutation/support:test_support", ], ) diff --git a/src/test/java/com/code_intelligence/jazzer/mutation/mutator/collection/ChunkMutationsTest.java b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/collection/ChunkMutationsTest.java index e8f638743..12ce7936c 100644 --- a/src/test/java/com/code_intelligence/jazzer/mutation/mutator/collection/ChunkMutationsTest.java +++ b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/collection/ChunkMutationsTest.java @@ -1,17 +1,10 @@ /* - * Copyright 2023 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.code_intelligence.jazzer.mutation.mutator.collection; diff --git a/src/test/java/com/code_intelligence/jazzer/mutation/mutator/collection/ListMutatorTest.java b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/collection/ListMutatorTest.java index 728962e6e..48515d85a 100644 --- a/src/test/java/com/code_intelligence/jazzer/mutation/mutator/collection/ListMutatorTest.java +++ b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/collection/ListMutatorTest.java @@ -1,17 +1,10 @@ /* - * Copyright 2023 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.code_intelligence.jazzer.mutation.mutator.collection; @@ -22,26 +15,32 @@ import com.code_intelligence.jazzer.mutation.annotation.NotNull; import com.code_intelligence.jazzer.mutation.annotation.WithSize; -import com.code_intelligence.jazzer.mutation.api.ChainedMutatorFactory; -import com.code_intelligence.jazzer.mutation.api.MutatorFactory; import com.code_intelligence.jazzer.mutation.api.SerializingMutator; +import com.code_intelligence.jazzer.mutation.engine.ChainedMutatorFactory; import com.code_intelligence.jazzer.mutation.mutator.lang.LangMutators; import com.code_intelligence.jazzer.mutation.support.TestSupport.MockPseudoRandom; import com.code_intelligence.jazzer.mutation.support.TypeHolder; +import com.code_intelligence.jazzer.mutation.utils.PropertyConstraint; import java.lang.reflect.AnnotatedType; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @SuppressWarnings("unchecked") public class ListMutatorTest { - public static final MutatorFactory FACTORY = - new ChainedMutatorFactory(LangMutators.newFactory(), CollectionMutators.newFactory()); + ChainedMutatorFactory factory; + + @BeforeEach + void createFactory() { + factory = + ChainedMutatorFactory.of(LangMutators.newFactories(), CollectionMutators.newFactories()); + } - private static SerializingMutator<@NotNull List<@NotNull Integer>> defaultListMutator() { + private SerializingMutator<@NotNull List<@NotNull Integer>> defaultListMutator() { AnnotatedType type = new TypeHolder<@NotNull List<@NotNull Integer>>() {}.annotatedType(); - return (SerializingMutator<@NotNull List<@NotNull Integer>>) FACTORY.createOrThrow(type); + return (SerializingMutator<@NotNull List<@NotNull Integer>>) factory.createOrThrow(type); } @Test @@ -68,7 +67,7 @@ void testInitMaxSize() { @NotNull @WithSize(min = 2, max = 3) List<@NotNull Integer>>() {}.annotatedType(); SerializingMutator<@NotNull List<@NotNull Integer>> mutator = - (SerializingMutator<@NotNull List<@NotNull Integer>>) FACTORY.createOrThrow(type); + (SerializingMutator<@NotNull List<@NotNull Integer>>) factory.createOrThrow(type); assertThat(mutator.toString()).isEqualTo("List"); List list; @@ -191,6 +190,8 @@ void testChangeChunk() { mockPseudoRandom( // action 2, + // Mutate a chunk instead of a single element. + 8, // number of elements to mutate 2, // first index to mutate at @@ -309,4 +310,15 @@ void testCrossOverCrossOverChunk() { } assertThat(list).containsExactly(0, 1, 7, 8, 9, 5, 6, 7, 8, 9).inOrder(); } + + @Test + void propagateConstraint() { + SerializingMutator<@NotNull List>> mutator = + (SerializingMutator<@NotNull List>>) + factory.createOrThrow( + new TypeHolder< + @NotNull(constraint = PropertyConstraint.RECURSIVE) List< + List>>() {}.annotatedType()); + assertThat(mutator.toString()).isEqualTo("List>"); + } } diff --git a/src/test/java/com/code_intelligence/jazzer/mutation/mutator/collection/MapMutatorTest.java b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/collection/MapMutatorTest.java index 2f5cf4e50..80bc9d421 100644 --- a/src/test/java/com/code_intelligence/jazzer/mutation/mutator/collection/MapMutatorTest.java +++ b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/collection/MapMutatorTest.java @@ -1,17 +1,10 @@ /* - * Copyright 2023 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.code_intelligence.jazzer.mutation.mutator.collection; @@ -24,26 +17,32 @@ import com.code_intelligence.jazzer.mutation.annotation.NotNull; import com.code_intelligence.jazzer.mutation.annotation.WithSize; -import com.code_intelligence.jazzer.mutation.api.ChainedMutatorFactory; -import com.code_intelligence.jazzer.mutation.api.MutatorFactory; import com.code_intelligence.jazzer.mutation.api.SerializingMutator; +import com.code_intelligence.jazzer.mutation.engine.ChainedMutatorFactory; import com.code_intelligence.jazzer.mutation.mutator.lang.LangMutators; import com.code_intelligence.jazzer.mutation.support.TestSupport.MockPseudoRandom; import com.code_intelligence.jazzer.mutation.support.TypeHolder; +import com.code_intelligence.jazzer.mutation.utils.PropertyConstraint; import java.lang.reflect.AnnotatedType; import java.util.List; import java.util.Map; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @SuppressWarnings("unchecked") class MapMutatorTest { - public static final MutatorFactory FACTORY = - new ChainedMutatorFactory(LangMutators.newFactory(), CollectionMutators.newFactory()); + ChainedMutatorFactory factory; + + @BeforeEach + void createFactory() { + factory = + ChainedMutatorFactory.of(LangMutators.newFactories(), CollectionMutators.newFactories()); + } - private static SerializingMutator> defaultTestMapMutator() { + private SerializingMutator> defaultTestMapMutator() { AnnotatedType type = new TypeHolder<@NotNull Map<@NotNull Integer, @NotNull Integer>>() {}.annotatedType(); - return (SerializingMutator>) FACTORY.createOrThrow(type); + return (SerializingMutator>) factory.createOrThrow(type); } @Test @@ -52,8 +51,8 @@ void mapInitInsert() { new TypeHolder< @NotNull @WithSize(max = 3) Map<@NotNull String, @NotNull String>>() {}.annotatedType(); SerializingMutator> mutator = - (SerializingMutator>) FACTORY.createOrThrow(type); - assertThat(mutator.toString()).isEqualTo("Map"); + (SerializingMutator>) factory.createOrThrow(type); + assertThat(mutator.toString()).isEqualTo("Map"); // Initialize new map Map map; @@ -103,11 +102,8 @@ void mapInitInsert() { @Test void mapDelete() { - AnnotatedType type = - new TypeHolder<@NotNull Map<@NotNull Integer, @NotNull Integer>>() {}.annotatedType(); - SerializingMutator> mutator = - (SerializingMutator>) FACTORY.createOrThrow(type); - assertThat(mutator.toString()).isEqualTo("Map"); + SerializingMutator> mutator = defaultTestMapMutator(); + assertThat(mutator.toString()).isEqualTo("Map"); Map map = asMap(1, 10, 2, 20, 3, 30, 4, 40, 5, 50, 6, 60); @@ -126,11 +122,8 @@ void mapDelete() { @Test void mapMutateValues() { - AnnotatedType type = - new TypeHolder<@NotNull Map<@NotNull Integer, @NotNull Integer>>() {}.annotatedType(); - SerializingMutator> mutator = - (SerializingMutator>) FACTORY.createOrThrow(type); - assertThat(mutator.toString()).isEqualTo("Map"); + SerializingMutator> mutator = defaultTestMapMutator(); + assertThat(mutator.toString()).isEqualTo("Map"); Map map = asMap(1, 10, 2, 20, 3, 30, 4, 40, 5, 50, 6, 60); @@ -159,11 +152,8 @@ void mapMutateValues() { @Test void mapMutateKeys() { - AnnotatedType type = - new TypeHolder<@NotNull Map<@NotNull Integer, @NotNull Integer>>() {}.annotatedType(); - SerializingMutator> mutator = - (SerializingMutator>) FACTORY.createOrThrow(type); - assertThat(mutator.toString()).isEqualTo("Map"); + SerializingMutator> mutator = defaultTestMapMutator(); + assertThat(mutator.toString()).isEqualTo("Map"); Map map = asMap(1, 10, 2, 20, 3, 30, 4, 40, 5, 50, 6, 60); @@ -195,8 +185,8 @@ void mapMutateKeysFallbackToValues() { AnnotatedType type = new TypeHolder<@NotNull Map<@NotNull Boolean, @NotNull Boolean>>() {}.annotatedType(); SerializingMutator> mutator = - (SerializingMutator>) FACTORY.createOrThrow(type); - assertThat(mutator.toString()).isEqualTo("Map"); + (SerializingMutator>) factory.createOrThrow(type); + assertThat(mutator.toString()).isEqualTo("Map"); // No new keys can be generated for this map. Map map = asMap(false, false, true, false); @@ -305,7 +295,7 @@ void testCrossOverCrossOverChunkKeys() { @NotNull Map<@NotNull List<@NotNull Integer>, @NotNull Integer>>() {}.annotatedType(); SerializingMutator<@NotNull Map<@NotNull List<@NotNull Integer>, @NotNull Integer>> mutator = (SerializingMutator<@NotNull Map<@NotNull List<@NotNull Integer>, @NotNull Integer>>) - FACTORY.createOrThrow(type); + factory.createOrThrow(type); Map, Integer> map = asMap( @@ -391,7 +381,7 @@ void testCrossOverCrossOverChunkValues() { @NotNull Map<@NotNull Integer, @NotNull List<@NotNull Integer>>>() {}.annotatedType(); SerializingMutator<@NotNull Map<@NotNull Integer, @NotNull List<@NotNull Integer>>> mutator = (SerializingMutator<@NotNull Map<@NotNull Integer, @NotNull List<@NotNull Integer>>>) - FACTORY.createOrThrow(type); + factory.createOrThrow(type); Map> map = asMap( @@ -468,4 +458,15 @@ void testCrossOverCrossOverChunkValues() { .inOrder(); } } + + @Test + void propagateConstraint() { + SerializingMutator<@NotNull Map>> mutator = + (SerializingMutator<@NotNull Map>>) + factory.createOrThrow( + new TypeHolder< + @NotNull(constraint = PropertyConstraint.RECURSIVE) Map< + String, List>>() {}.annotatedType()); + assertThat(mutator.toString()).isEqualTo("Map>"); + } } diff --git a/src/test/java/com/code_intelligence/jazzer/mutation/mutator/lang/BUILD.bazel b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/lang/BUILD.bazel index 274960b22..476bd595c 100644 --- a/src/test/java/com/code_intelligence/jazzer/mutation/mutator/lang/BUILD.bazel +++ b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/lang/BUILD.bazel @@ -9,10 +9,11 @@ java_test_suite( deps = [ "//src/main/java/com/code_intelligence/jazzer/mutation/annotation", "//src/main/java/com/code_intelligence/jazzer/mutation/api", + "//src/main/java/com/code_intelligence/jazzer/mutation/engine", "//src/main/java/com/code_intelligence/jazzer/mutation/mutator/lang", "//src/main/java/com/code_intelligence/jazzer/mutation/mutator/libfuzzer:libfuzzermutate", "//src/main/java/com/code_intelligence/jazzer/mutation/support", "//src/test/java/com/code_intelligence/jazzer/mutation/support:test_support", - "@com_google_protobuf//java/core", + "@protobuf//java/core", ], ) diff --git a/src/test/java/com/code_intelligence/jazzer/mutation/mutator/lang/BooleanMutatorTest.java b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/lang/BooleanMutatorTest.java index 2fa18fbc8..6cb6a6ad1 100644 --- a/src/test/java/com/code_intelligence/jazzer/mutation/mutator/lang/BooleanMutatorTest.java +++ b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/lang/BooleanMutatorTest.java @@ -1,17 +1,10 @@ /* - * Copyright 2023 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.code_intelligence.jazzer.mutation.mutator.lang; @@ -21,15 +14,30 @@ import com.code_intelligence.jazzer.mutation.annotation.NotNull; import com.code_intelligence.jazzer.mutation.api.SerializingMutator; +import com.code_intelligence.jazzer.mutation.engine.ChainedMutatorFactory; import com.code_intelligence.jazzer.mutation.support.TestSupport.MockPseudoRandom; +import com.code_intelligence.jazzer.mutation.support.TestSupport.ParameterHolder; import com.code_intelligence.jazzer.mutation.support.TypeHolder; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @SuppressWarnings("unchecked") class BooleanMutatorTest { + ChainedMutatorFactory factory; + + @BeforeEach + void createFactory() { + factory = ChainedMutatorFactory.of(LangMutators.newFactories()); + } + @Test void testPrimitive() { - SerializingMutator mutator = LangMutators.newFactory().createOrThrow(boolean.class); + SerializingMutator mutator = + (SerializingMutator) + factory.createOrThrow( + new ParameterHolder() { + void singleParam(boolean parameter) {} + }.annotatedType()); assertThat(mutator.toString()).isEqualTo("Boolean"); boolean bool; @@ -48,8 +56,7 @@ void testPrimitive() { void testBoxed() { SerializingMutator mutator = (SerializingMutator) - LangMutators.newFactory() - .createOrThrow(new TypeHolder<@NotNull Boolean>() {}.annotatedType()); + factory.createOrThrow(new TypeHolder<@NotNull Boolean>() {}.annotatedType()); assertThat(mutator.toString()).isEqualTo("Boolean"); Boolean bool; @@ -66,7 +73,12 @@ void testBoxed() { @Test void testCrossOver() { - SerializingMutator mutator = LangMutators.newFactory().createOrThrow(boolean.class); + SerializingMutator mutator = + (SerializingMutator) + factory.createOrThrow( + new ParameterHolder() { + void singleParam(boolean parameter) {} + }.annotatedType()); try (MockPseudoRandom prng = mockPseudoRandom(true, false)) { assertThat(mutator.crossOver(true, false, prng)).isTrue(); assertThat(mutator.crossOver(true, false, prng)).isFalse(); diff --git a/src/test/java/com/code_intelligence/jazzer/mutation/mutator/lang/ByteArrayMutatorTest.java b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/lang/ByteArrayMutatorTest.java index f91ea500b..793bfe749 100644 --- a/src/test/java/com/code_intelligence/jazzer/mutation/mutator/lang/ByteArrayMutatorTest.java +++ b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/lang/ByteArrayMutatorTest.java @@ -1,17 +1,10 @@ /* - * Copyright 2023 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.code_intelligence.jazzer.mutation.mutator.lang; @@ -22,14 +15,23 @@ import com.code_intelligence.jazzer.mutation.annotation.NotNull; import com.code_intelligence.jazzer.mutation.annotation.WithLength; import com.code_intelligence.jazzer.mutation.api.SerializingMutator; +import com.code_intelligence.jazzer.mutation.engine.ChainedMutatorFactory; import com.code_intelligence.jazzer.mutation.mutator.libfuzzer.LibFuzzerMutate; import com.code_intelligence.jazzer.mutation.support.TestSupport.MockPseudoRandom; import com.code_intelligence.jazzer.mutation.support.TypeHolder; import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -@SuppressWarnings({"unchecked", "ResultOfMethodCallIgnored"}) +@SuppressWarnings({"unchecked"}) public class ByteArrayMutatorTest { + ChainedMutatorFactory factory; + + @BeforeEach + void createFactory() { + factory = ChainedMutatorFactory.of(LangMutators.newFactories()); + } + /** * Some tests may set {@link LibFuzzerMutate#MOCK_SIZE_KEY} which can interfere with other tests * unless cleared. @@ -43,7 +45,7 @@ void cleanMockSize() { void testBasicFunction() { SerializingMutator mutator = (SerializingMutator) - LangMutators.newFactory().createOrThrow(new TypeHolder() {}.annotatedType()); + factory.createOrThrow(new TypeHolder() {}.annotatedType()); assertThat(mutator.toString()).isEqualTo("Nullable"); byte[] arr; @@ -63,9 +65,8 @@ void testBasicFunction() { void testMaxLength() { SerializingMutator mutator = (SerializingMutator) - LangMutators.newFactory() - .createOrThrow( - new TypeHolder() {}.annotatedType()); + factory.createOrThrow( + new TypeHolder() {}.annotatedType()); assertThat(mutator.toString()).isEqualTo("byte[]"); byte[] arr; @@ -90,9 +91,8 @@ void testMaxLength() { void testMaxLengthInitClamp() { SerializingMutator mutator = (SerializingMutator) - LangMutators.newFactory() - .createOrThrow( - new TypeHolder() {}.annotatedType()); + factory.createOrThrow( + new TypeHolder() {}.annotatedType()); assertThat(mutator.toString()).isEqualTo("byte[]"); try (MockPseudoRandom prng = mockPseudoRandom(10)) { @@ -111,9 +111,8 @@ void testMaxLengthInitClamp() { void testMinLengthInitClamp() { SerializingMutator mutator = (SerializingMutator) - LangMutators.newFactory() - .createOrThrow( - new TypeHolder() {}.annotatedType()); + factory.createOrThrow( + new TypeHolder() {}.annotatedType()); assertThat(mutator.toString()).isEqualTo("byte[]"); try (MockPseudoRandom prng = mockPseudoRandom(3)) { @@ -132,9 +131,8 @@ void testMinLengthInitClamp() { void testMinLength() { SerializingMutator mutator = (SerializingMutator) - LangMutators.newFactory() - .createOrThrow( - new TypeHolder() {}.annotatedType()); + factory.createOrThrow( + new TypeHolder() {}.annotatedType()); assertThat(mutator.toString()).isEqualTo("byte[]"); byte[] arr; @@ -156,8 +154,7 @@ void testMinLength() { void testCrossOver() { SerializingMutator mutator = (SerializingMutator) - LangMutators.newFactory() - .createOrThrow(new TypeHolder() {}.annotatedType()); + factory.createOrThrow(new TypeHolder() {}.annotatedType()); assertThat(mutator.toString()).isEqualTo("byte[]"); byte[] value = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; diff --git a/src/test/java/com/code_intelligence/jazzer/mutation/mutator/lang/EnumMutatorTest.java b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/lang/EnumMutatorTest.java index 030371cf0..e856aa2cb 100644 --- a/src/test/java/com/code_intelligence/jazzer/mutation/mutator/lang/EnumMutatorTest.java +++ b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/lang/EnumMutatorTest.java @@ -1,17 +1,10 @@ /* - * Copyright 2023 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.code_intelligence.jazzer.mutation.mutator.lang; @@ -22,6 +15,7 @@ import com.code_intelligence.jazzer.mutation.annotation.NotNull; import com.code_intelligence.jazzer.mutation.api.SerializingMutator; +import com.code_intelligence.jazzer.mutation.engine.ChainedMutatorFactory; import com.code_intelligence.jazzer.mutation.support.TestSupport.MockPseudoRandom; import com.code_intelligence.jazzer.mutation.support.TypeHolder; import java.io.ByteArrayInputStream; @@ -29,9 +23,17 @@ import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; class EnumMutatorTest { + ChainedMutatorFactory factory; + + @BeforeEach + void createFactory() { + factory = ChainedMutatorFactory.of(LangMutators.newFactories()); + } + enum TestEnumOne { A } @@ -46,8 +48,7 @@ enum TestEnum { void testBoxed() { SerializingMutator mutator = (SerializingMutator) - LangMutators.newFactory() - .createOrThrow(new TypeHolder<@NotNull TestEnum>() {}.annotatedType()); + factory.createOrThrow(new TypeHolder<@NotNull TestEnum>() {}.annotatedType()); assertThat(mutator.toString()).isEqualTo("Enum"); TestEnum cl; try (MockPseudoRandom prng = mockPseudoRandom(0)) { @@ -81,8 +82,7 @@ void testEnumWithOneElementShouldThrow() { assertThrows( IllegalArgumentException.class, () -> { - LangMutators.newFactory() - .createOrThrow(new TypeHolder<@NotNull TestEnumOne>() {}.annotatedType()); + factory.createOrThrow(new TypeHolder<@NotNull TestEnumOne>() {}.annotatedType()); }, "When trying to build mutators for Enum with one value, an Exception should be thrown."); } @@ -91,8 +91,7 @@ void testEnumWithOneElementShouldThrow() { void testEnumBasedOnInvalidInput() throws IOException { SerializingMutator mutator = (SerializingMutator) - LangMutators.newFactory() - .createOrThrow(new TypeHolder<@NotNull TestEnum>() {}.annotatedType()); + factory.createOrThrow(new TypeHolder<@NotNull TestEnum>() {}.annotatedType()); ByteArrayOutputStream bo = new ByteArrayOutputStream(); DataOutputStream os = new DataOutputStream(bo); // Valid values diff --git a/src/test/java/com/code_intelligence/jazzer/mutation/mutator/lang/FloatingPointMutatorTest.java b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/lang/FloatingPointMutatorTest.java index 643ab7b1c..be7231da6 100644 --- a/src/test/java/com/code_intelligence/jazzer/mutation/mutator/lang/FloatingPointMutatorTest.java +++ b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/lang/FloatingPointMutatorTest.java @@ -1,17 +1,10 @@ /* - * Copyright 2023 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.code_intelligence.jazzer.mutation.mutator.lang; @@ -27,6 +20,7 @@ import com.code_intelligence.jazzer.mutation.annotation.FloatInRange; import com.code_intelligence.jazzer.mutation.annotation.NotNull; import com.code_intelligence.jazzer.mutation.api.SerializingMutator; +import com.code_intelligence.jazzer.mutation.engine.ChainedMutatorFactory; import com.code_intelligence.jazzer.mutation.support.TestSupport; import com.code_intelligence.jazzer.mutation.support.TypeHolder; import java.util.function.Supplier; @@ -37,6 +31,10 @@ import org.junit.jupiter.params.provider.MethodSource; class FloatingPointMutatorTest { + static ChainedMutatorFactory createFactory() { + return ChainedMutatorFactory.of(LangMutators.newFactories()); + } + static final Float UNUSED_FLOAT = 0.0f; static final Double UNUSED_DOUBLE = 0.0; @@ -187,6 +185,20 @@ void testFloatForceInRange(float value, float minValue, float maxValue, boolean } } + @Test + void testFloatForceInRangeMinMax() { + boolean allowNaN = true; + assertThat(FloatMutator.forceInRange(1.0f, 0.0f, 1.0f, allowNaN)).isEqualTo(1.0f); + assertThat(FloatMutator.forceInRange(0.0f, 0.0f, 1.0f, allowNaN)).isEqualTo(0.0f); + assertThat(DoubleMutator.forceInRange(Double.MAX_VALUE, 10.0, Double.MAX_VALUE, allowNaN)) + .isEqualTo(Double.MAX_VALUE); + assertThat(DoubleMutator.forceInRange(0.0, 0.0, Double.MAX_VALUE, allowNaN)).isEqualTo(0.0); + assertThat( + DoubleMutator.forceInRange( + -Double.MAX_VALUE, -Double.MAX_VALUE, Double.MAX_VALUE, allowNaN)) + .isEqualTo(-Double.MAX_VALUE); + } + @ParameterizedTest @MethodSource("doubleForceInRangeCases") void testDoubleForceInRange(double value, double minValue, double maxValue, boolean allowNaN) { @@ -226,8 +238,7 @@ public Integer get() { static Stream floatInitCasesFullRange() { SerializingMutator mutator = (SerializingMutator) - LangMutators.newFactory() - .createOrThrow(new TypeHolder<@NotNull Float>() {}.annotatedType()); + createFactory().createOrThrow(new TypeHolder<@NotNull Float>() {}.annotatedType()); Supplier ctr = makeCounter(); return Stream.of( arguments(mutator, Stream.of(true, ctr.get()), Float.NEGATIVE_INFINITY, true), @@ -245,7 +256,7 @@ static Stream floatInitCasesFullRange() { static Stream floatInitCasesMinusOneToOne() { SerializingMutator mutator = (SerializingMutator) - LangMutators.newFactory() + createFactory() .createOrThrow( new TypeHolder< @NotNull @FloatInRange(min = -1.0f, max = 1.0f) @@ -265,7 +276,7 @@ static Stream floatInitCasesMinusOneToOne() { static Stream floatInitCasesMinusMinToMin() { SerializingMutator mutator = (SerializingMutator) - LangMutators.newFactory() + createFactory() .createOrThrow( new TypeHolder< @NotNull @FloatInRange(min = -Float.MIN_VALUE, max = Float.MIN_VALUE) @@ -283,7 +294,7 @@ static Stream floatInitCasesMinusMinToMin() { static Stream floatInitCasesMaxToInf() { SerializingMutator mutator = (SerializingMutator) - LangMutators.newFactory() + createFactory() .createOrThrow( new TypeHolder< @NotNull @FloatInRange(min = Float.MAX_VALUE, max = Float.POSITIVE_INFINITY) @@ -299,7 +310,7 @@ static Stream floatInitCasesMaxToInf() { static Stream floatInitCasesMinusInfToMinusMax() { SerializingMutator mutator = (SerializingMutator) - LangMutators.newFactory() + createFactory() .createOrThrow( new TypeHolder< @NotNull @@ -316,7 +327,7 @@ static Stream floatInitCasesMinusInfToMinusMax() { static Stream floatInitCasesFullRangeWithoutNaN() { SerializingMutator mutator = (SerializingMutator) - LangMutators.newFactory() + createFactory() .createOrThrow( new TypeHolder< @NotNull @@ -374,7 +385,7 @@ void testFloatInitCases( static Stream floatMutateSanityChecksFullRangeCases() { SerializingMutator mutator = (SerializingMutator) - LangMutators.newFactory() + createFactory() .createOrThrow( new TypeHolder< @NotNull @@ -418,7 +429,7 @@ static Stream floatMutateSanityChecksFullRangeCases() { static Stream floatMutateLimitedRangeCases() { SerializingMutator mutator = (SerializingMutator) - LangMutators.newFactory() + createFactory() .createOrThrow( new TypeHolder< @NotNull @FloatInRange(min = -1f, max = 1f, allowNaN = false) @@ -443,7 +454,7 @@ static Stream floatMutateLimitedRangeCases() { static Stream floatMutateLimitedRangeCasesWithNaN() { SerializingMutator mutator = (SerializingMutator) - LangMutators.newFactory() + createFactory() .createOrThrow( new TypeHolder< @NotNull @FloatInRange(min = -1f, max = 1f, allowNaN = true) @@ -508,8 +519,7 @@ void testFloatMutateCases( void testFloatCrossOverMean() { SerializingMutator mutator = (SerializingMutator) - LangMutators.newFactory() - .createOrThrow(new TypeHolder<@NotNull Float>() {}.annotatedType()); + createFactory().createOrThrow(new TypeHolder<@NotNull Float>() {}.annotatedType()); try (TestSupport.MockPseudoRandom prng = mockPseudoRandom(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)) { assertThat(mutator.crossOver(0f, 0f, prng)).isWithin(0).of(0f); @@ -548,8 +558,7 @@ void testFloatCrossOverMean() { void testFloatCrossOverExponent() { SerializingMutator mutator = (SerializingMutator) - LangMutators.newFactory() - .createOrThrow(new TypeHolder<@NotNull Float>() {}.annotatedType()); + createFactory().createOrThrow(new TypeHolder<@NotNull Float>() {}.annotatedType()); try (TestSupport.MockPseudoRandom prng = mockPseudoRandom(1, 1, 1)) { assertThat(mutator.crossOver(2.0f, -1.5f, prng)).isWithin(1e-10f).of(1.0f); assertThat(mutator.crossOver(2.0f, Float.POSITIVE_INFINITY, prng)).isPositiveInfinity(); @@ -561,8 +570,7 @@ void testFloatCrossOverExponent() { void testFloatCrossOverMantissa() { SerializingMutator mutator = (SerializingMutator) - LangMutators.newFactory() - .createOrThrow(new TypeHolder<@NotNull Float>() {}.annotatedType()); + createFactory().createOrThrow(new TypeHolder<@NotNull Float>() {}.annotatedType()); try (TestSupport.MockPseudoRandom prng = mockPseudoRandom(2, 2, 2)) { assertThat(mutator.crossOver(4.0f, 3.5f, prng)).isWithin(1e-10f).of(7.0f); assertThat(mutator.crossOver(Float.POSITIVE_INFINITY, 3.0f, prng)).isNaN(); @@ -573,8 +581,7 @@ void testFloatCrossOverMantissa() { static Stream doubleInitCasesFullRange() { SerializingMutator mutator = (SerializingMutator) - LangMutators.newFactory() - .createOrThrow(new TypeHolder<@NotNull Double>() {}.annotatedType()); + createFactory().createOrThrow(new TypeHolder<@NotNull Double>() {}.annotatedType()); Supplier ctr = makeCounter(); return Stream.of( arguments(mutator, Stream.of(true, ctr.get()), Double.NEGATIVE_INFINITY, true), @@ -592,7 +599,7 @@ static Stream doubleInitCasesFullRange() { static Stream doubleInitCasesMinusOneToOne() { SerializingMutator mutator = (SerializingMutator) - LangMutators.newFactory() + createFactory() .createOrThrow( new TypeHolder< @NotNull @DoubleInRange(min = -1.0, max = 1.0) @@ -612,7 +619,7 @@ static Stream doubleInitCasesMinusOneToOne() { static Stream doubleInitCasesMinusMinToMin() { SerializingMutator mutator = (SerializingMutator) - LangMutators.newFactory() + createFactory() .createOrThrow( new TypeHolder< @NotNull @DoubleInRange(min = -Double.MIN_VALUE, max = Double.MIN_VALUE) @@ -630,7 +637,7 @@ static Stream doubleInitCasesMinusMinToMin() { static Stream doubleInitCasesMaxToInf() { SerializingMutator mutator = (SerializingMutator) - LangMutators.newFactory() + createFactory() .createOrThrow( new TypeHolder< @NotNull @@ -647,7 +654,7 @@ static Stream doubleInitCasesMaxToInf() { static Stream doubleInitCasesMinusInfToMinusMax() { SerializingMutator mutator = (SerializingMutator) - LangMutators.newFactory() + createFactory() .createOrThrow( new TypeHolder< @NotNull @@ -664,7 +671,7 @@ static Stream doubleInitCasesMinusInfToMinusMax() { static Stream doubleInitCasesFullRangeWithoutNaN() { SerializingMutator mutator = (SerializingMutator) - LangMutators.newFactory() + createFactory() .createOrThrow( new TypeHolder< @NotNull @@ -722,7 +729,7 @@ void testDoubleInitCases( static Stream doubleMutateSanityChecksFullRangeCases() { SerializingMutator mutator = (SerializingMutator) - LangMutators.newFactory() + createFactory() .createOrThrow( new TypeHolder< @NotNull @@ -765,7 +772,7 @@ static Stream doubleMutateSanityChecksFullRangeCases() { static Stream doubleMutateLimitedRangeCases() { SerializingMutator mutator = (SerializingMutator) - LangMutators.newFactory() + createFactory() .createOrThrow( new TypeHolder< @NotNull @DoubleInRange(min = -1, max = 1, allowNaN = false) @@ -792,7 +799,7 @@ static Stream doubleMutateLimitedRangeCases() { static Stream doubleMutateLimitedRangeCasesWithNaN() { SerializingMutator mutator = (SerializingMutator) - LangMutators.newFactory() + createFactory() .createOrThrow( new TypeHolder< @NotNull @DoubleInRange(min = -1, max = 1, allowNaN = true) @@ -857,8 +864,7 @@ void testDoubleMutateCases( void testDoubleCrossOverMean() { SerializingMutator mutator = (SerializingMutator) - LangMutators.newFactory() - .createOrThrow(new TypeHolder<@NotNull Double>() {}.annotatedType()); + createFactory().createOrThrow(new TypeHolder<@NotNull Double>() {}.annotatedType()); try (TestSupport.MockPseudoRandom prng = mockPseudoRandom(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)) { assertThat(mutator.crossOver(0.0, 0.0, prng)).isWithin(0).of(0f); @@ -898,8 +904,7 @@ void testDoubleCrossOverMean() { void testDoubleCrossOverExponent() { SerializingMutator mutator = (SerializingMutator) - LangMutators.newFactory() - .createOrThrow(new TypeHolder<@NotNull Double>() {}.annotatedType()); + createFactory().createOrThrow(new TypeHolder<@NotNull Double>() {}.annotatedType()); try (TestSupport.MockPseudoRandom prng = mockPseudoRandom(1, 1, 1)) { assertThat(mutator.crossOver(2.0, -1.5, prng)).isWithin(1e-10f).of(1.0f); assertThat(mutator.crossOver(2.0, Double.POSITIVE_INFINITY, prng)).isPositiveInfinity(); @@ -911,8 +916,7 @@ void testDoubleCrossOverExponent() { void testDoubleCrossOverMantissa() { SerializingMutator mutator = (SerializingMutator) - LangMutators.newFactory() - .createOrThrow(new TypeHolder<@NotNull Double>() {}.annotatedType()); + createFactory().createOrThrow(new TypeHolder<@NotNull Double>() {}.annotatedType()); try (TestSupport.MockPseudoRandom prng = mockPseudoRandom(2, 2, 2)) { assertThat(mutator.crossOver(4.0, 3.5, prng)).isWithin(1e-10f).of(7.0f); assertThat(mutator.crossOver(Double.POSITIVE_INFINITY, 3.0, prng)).isNaN(); diff --git a/src/test/java/com/code_intelligence/jazzer/mutation/mutator/lang/InputStreamMutatorTest.java b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/lang/InputStreamMutatorTest.java new file mode 100644 index 000000000..b909cc362 --- /dev/null +++ b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/lang/InputStreamMutatorTest.java @@ -0,0 +1,76 @@ +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ + +package com.code_intelligence.jazzer.mutation.mutator.lang; + +import static com.code_intelligence.jazzer.mutation.support.TestSupport.anyPseudoRandom; +import static com.google.common.truth.Truth.assertThat; + +import com.code_intelligence.jazzer.mutation.annotation.NotNull; +import com.code_intelligence.jazzer.mutation.api.PseudoRandom; +import com.code_intelligence.jazzer.mutation.api.SerializingMutator; +import com.code_intelligence.jazzer.mutation.engine.ChainedMutatorFactory; +import com.code_intelligence.jazzer.mutation.mutator.libfuzzer.LibFuzzerMutate; +import com.code_intelligence.jazzer.mutation.support.TypeHolder; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +class InputStreamMutatorTest { + ChainedMutatorFactory factory; + + @BeforeEach + void createFactory() { + factory = ChainedMutatorFactory.of(LangMutators.newFactories()); + } + + @AfterEach + void cleanMockSize() { + System.clearProperty(LibFuzzerMutate.MOCK_SIZE_KEY); + } + + @Test + void testInputStreamMutator() throws IOException { + SerializingMutator mutator = + (SerializingMutator) + factory.createOrThrow(new TypeHolder<@NotNull InputStream>() {}.annotatedType()); + assertThat(mutator.toString()).isEqualTo("InputStream"); + + PseudoRandom prng = anyPseudoRandom(); + + InputStream inited = mutator.init(prng); + assertThat(inited).isNotNull(); + + InputStream mutated = mutator.mutate(inited, prng); + assertThat(mutated).isNotEqualTo(inited); + + InputStream detached = mutator.detach(mutated); + assertThat(detached).isNotEqualTo(mutated); + + byte[] initedData = readAll(inited); + byte[] mutatedData = readAll(mutated); + byte[] detachedData = readAll(detached); + assertThat(initedData).isNotEqualTo(mutatedData); + assertThat(mutatedData).isEqualTo(detachedData); + } + + private static byte[] readAll(InputStream inited) throws IOException { + ByteArrayOutputStream buffer = new ByteArrayOutputStream(); + int nRead; + byte[] data = new byte[4]; + while ((nRead = inited.read(data, 0, data.length)) != -1) { + buffer.write(data, 0, nRead); + } + buffer.flush(); + return buffer.toByteArray(); + } +} diff --git a/src/test/java/com/code_intelligence/jazzer/mutation/mutator/lang/IntegralMutatorTest.java b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/lang/IntegralMutatorTest.java index d70872381..a45f1703c 100644 --- a/src/test/java/com/code_intelligence/jazzer/mutation/mutator/lang/IntegralMutatorTest.java +++ b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/lang/IntegralMutatorTest.java @@ -1,17 +1,10 @@ /* - * Copyright 2023 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.code_intelligence.jazzer.mutation.mutator.lang; @@ -23,9 +16,11 @@ import com.code_intelligence.jazzer.mutation.annotation.NotNull; import com.code_intelligence.jazzer.mutation.api.SerializingMutator; +import com.code_intelligence.jazzer.mutation.engine.ChainedMutatorFactory; import com.code_intelligence.jazzer.mutation.support.TestSupport.MockPseudoRandom; import com.code_intelligence.jazzer.mutation.support.TypeHolder; import java.util.stream.Stream; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; @@ -33,6 +28,13 @@ @SuppressWarnings("unchecked") class IntegralMutatorTest { + ChainedMutatorFactory factory; + + @BeforeEach + void createFactory() { + factory = ChainedMutatorFactory.of(LangMutators.newFactories()); + } + static Stream forceInRangeCases() { return Stream.of( arguments(0, 0, 1), @@ -65,12 +67,27 @@ void testForceInRange(long value, long minValue, long maxValue) { } } + static Stream forceInRangeMinMaxCases() { + return Stream.of( + arguments(Long.MAX_VALUE, 0, Long.MAX_VALUE, Long.MAX_VALUE), + arguments(Long.MAX_VALUE, Long.MIN_VALUE, Long.MAX_VALUE, Long.MAX_VALUE), + arguments(Long.MIN_VALUE, Long.MIN_VALUE, Long.MAX_VALUE, Long.MIN_VALUE), + arguments(0, Long.MIN_VALUE, Long.MAX_VALUE, 0), + arguments(0, 0, 0, 0), + arguments(1, 0, 1, 1)); + } + + @ParameterizedTest + @MethodSource("forceInRangeMinMaxCases") + void testForceInRangeMinMax(long value, long minValue, long maxValue, long expected) { + assertThat(forceInRange(value, minValue, maxValue)).isEqualTo(expected); + } + @Test void testCrossOver() { SerializingMutator mutator = (SerializingMutator) - LangMutators.newFactory() - .createOrThrow(new TypeHolder<@NotNull Long>() {}.annotatedType()); + factory.createOrThrow(new TypeHolder<@NotNull Long>() {}.annotatedType()); // cross over mean values try (MockPseudoRandom prng = mockPseudoRandom(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)) { assertThat(mutator.crossOver(0L, 0L, prng)).isEqualTo(0); diff --git a/src/test/java/com/code_intelligence/jazzer/mutation/mutator/lang/NullableMutatorTest.java b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/lang/NullableMutatorTest.java index bc9a65b2d..8aedbb1ec 100644 --- a/src/test/java/com/code_intelligence/jazzer/mutation/mutator/lang/NullableMutatorTest.java +++ b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/lang/NullableMutatorTest.java @@ -1,39 +1,43 @@ /* - * Copyright 2023 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.code_intelligence.jazzer.mutation.mutator.lang; +import static com.code_intelligence.jazzer.mutation.support.TestSupport.createOrThrow; import static com.code_intelligence.jazzer.mutation.support.TestSupport.mockPseudoRandom; import static com.google.common.truth.Truth.assertThat; import com.code_intelligence.jazzer.mutation.annotation.NotNull; -import com.code_intelligence.jazzer.mutation.api.ChainedMutatorFactory; import com.code_intelligence.jazzer.mutation.api.SerializingMutator; +import com.code_intelligence.jazzer.mutation.engine.ChainedMutatorFactory; import com.code_intelligence.jazzer.mutation.support.TestSupport.MockPseudoRandom; +import com.code_intelligence.jazzer.mutation.support.TestSupport.ParameterHolder; import com.code_intelligence.jazzer.mutation.support.TypeHolder; import java.lang.reflect.AnnotatedType; +import java.util.stream.Stream; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @SuppressWarnings("unchecked") class NullableMutatorTest { + ChainedMutatorFactory factory; + + @BeforeEach + void createFactory() { + factory = + ChainedMutatorFactory.of( + Stream.of(new NullableMutatorFactory(), new BooleanMutatorFactory())); + } + @Test void testNullable() { - SerializingMutator mutator = - new ChainedMutatorFactory(new NullableMutatorFactory(), new BooleanMutatorFactory()) - .createOrThrow(Boolean.class); + SerializingMutator mutator = createOrThrow(factory, new TypeHolder() {}); assertThat(mutator.toString()).isEqualTo("Nullable"); Boolean bool; @@ -60,8 +64,6 @@ void testNullable() { @Test void testNotNull() { - ChainedMutatorFactory factory = - new ChainedMutatorFactory(new NullableMutatorFactory(), new BooleanMutatorFactory()); AnnotatedType notNullBoolean = new TypeHolder<@NotNull Boolean>() {}.annotatedType(); SerializingMutator mutator = (SerializingMutator) factory.createOrThrow(notNullBoolean); @@ -70,17 +72,18 @@ void testNotNull() { @Test void testPrimitive() { - ChainedMutatorFactory factory = - new ChainedMutatorFactory(new NullableMutatorFactory(), new BooleanMutatorFactory()); - SerializingMutator mutator = factory.createOrThrow(boolean.class); + SerializingMutator mutator = + (SerializingMutator) + factory.createOrThrow( + new ParameterHolder() { + void singleParam(boolean parameter) {} + }.annotatedType()); assertThat(mutator.toString()).isEqualTo("Boolean"); } @Test void testCrossOver() { - SerializingMutator mutator = - new ChainedMutatorFactory(new NullableMutatorFactory(), new BooleanMutatorFactory()) - .createOrThrow(Boolean.class); + SerializingMutator mutator = createOrThrow(factory, new TypeHolder() {}); try (MockPseudoRandom prng = mockPseudoRandom(true)) { Boolean valueCrossedOver = mutator.crossOver(Boolean.TRUE, Boolean.TRUE, prng); assertThat(valueCrossedOver).isNotNull(); diff --git a/src/test/java/com/code_intelligence/jazzer/mutation/mutator/lang/PCharGenerator.java b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/lang/PCharGenerator.java new file mode 100644 index 000000000..1a7a97ef9 --- /dev/null +++ b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/lang/PCharGenerator.java @@ -0,0 +1,35 @@ +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ + +package com.code_intelligence.jazzer.mutation.mutator.lang; + +import java.nio.charset.StandardCharsets; +import java.util.Arrays; + +public class PCharGenerator { + public static void main(String[] args) { + byte[] VALID_PCHAR = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~:@!$&'()*+,;=" + .getBytes(StandardCharsets.UTF_8); + Arrays.sort(VALID_PCHAR); + byte[] lut = new byte[256]; + int idx = 0; + for (int i = 0; i < 256; i++) { + if (Arrays.binarySearch(VALID_PCHAR, (byte) i) >= 0) { + lut[i] = (byte) i; + } else { + lut[i] = VALID_PCHAR[idx]; + idx = (idx + 1) % VALID_PCHAR.length; + } + } + for (byte b : lut) { + System.out.print((char) b); + } + } +} diff --git a/src/test/java/com/code_intelligence/jazzer/mutation/mutator/lang/PrimitiveArrayMutatorTest.java b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/lang/PrimitiveArrayMutatorTest.java new file mode 100644 index 000000000..beab764aa --- /dev/null +++ b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/lang/PrimitiveArrayMutatorTest.java @@ -0,0 +1,632 @@ +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ +package com.code_intelligence.jazzer.mutation.mutator.lang; + +import static com.code_intelligence.jazzer.mutation.mutator.lang.PrimitiveArrayMutatorFactory.PrimitiveArrayMutator.getBooleanPrimitiveArray; +import static com.code_intelligence.jazzer.mutation.mutator.lang.PrimitiveArrayMutatorFactory.PrimitiveArrayMutator.getBytePrimitiveArray; +import static com.code_intelligence.jazzer.mutation.mutator.lang.PrimitiveArrayMutatorFactory.PrimitiveArrayMutator.getCharPrimitiveArray; +import static com.code_intelligence.jazzer.mutation.mutator.lang.PrimitiveArrayMutatorFactory.PrimitiveArrayMutator.getDoublePrimitiveArray; +import static com.code_intelligence.jazzer.mutation.mutator.lang.PrimitiveArrayMutatorFactory.PrimitiveArrayMutator.getFloatPrimitiveArray; +import static com.code_intelligence.jazzer.mutation.mutator.lang.PrimitiveArrayMutatorFactory.PrimitiveArrayMutator.getIntegerPrimitiveArray; +import static com.code_intelligence.jazzer.mutation.mutator.lang.PrimitiveArrayMutatorFactory.PrimitiveArrayMutator.getLongPrimitiveArray; +import static com.code_intelligence.jazzer.mutation.mutator.lang.PrimitiveArrayMutatorFactory.PrimitiveArrayMutator.getShortPrimitiveArray; +import static com.code_intelligence.jazzer.mutation.mutator.lang.PrimitiveArrayMutatorFactory.PrimitiveArrayMutator.makePrimitiveArrayToBytesConverter; +import static com.google.common.truth.Truth.assertThat; +import static org.junit.jupiter.params.provider.Arguments.arguments; + +import com.code_intelligence.jazzer.mutation.support.TypeHolder; +import java.lang.reflect.AnnotatedArrayType; +import java.lang.reflect.AnnotatedType; +import java.util.function.Function; +import java.util.stream.Stream; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +@SuppressWarnings({"unchecked"}) +public class PrimitiveArrayMutatorTest { + + static AnnotatedType annotatedType_int = + ((AnnotatedArrayType) (new TypeHolder() {}.annotatedType())) + .getAnnotatedGenericComponentType(); + static AnnotatedType annotatedType_long = + ((AnnotatedArrayType) (new TypeHolder() {}.annotatedType())) + .getAnnotatedGenericComponentType(); + static AnnotatedType annotatedType_short = + ((AnnotatedArrayType) (new TypeHolder() {}.annotatedType())) + .getAnnotatedGenericComponentType(); + static AnnotatedType annotatedType_byte = + ((AnnotatedArrayType) (new TypeHolder() {}.annotatedType())) + .getAnnotatedGenericComponentType(); + static AnnotatedType annotatedType_char = + ((AnnotatedArrayType) (new TypeHolder() {}.annotatedType())) + .getAnnotatedGenericComponentType(); + static AnnotatedType annotatedType_boolean = + ((AnnotatedArrayType) (new TypeHolder() {}.annotatedType())) + .getAnnotatedGenericComponentType(); + static AnnotatedType annotatedType_float = + ((AnnotatedArrayType) (new TypeHolder() {}.annotatedType())) + .getAnnotatedGenericComponentType(); + static AnnotatedType annotatedType_double = + ((AnnotatedArrayType) (new TypeHolder() {}.annotatedType())) + .getAnnotatedGenericComponentType(); + static Function intsToBytes = + (Function) makePrimitiveArrayToBytesConverter(annotatedType_int); + static Function bytesToInts = + getIntegerPrimitiveArray(Integer.MIN_VALUE, Integer.MAX_VALUE); + + static Function bytesToLibfuzzerBytes = + (Function) makePrimitiveArrayToBytesConverter(annotatedType_byte); + static Function libfuzzerBytesToBytes = + getBytePrimitiveArray(Byte.MIN_VALUE, Byte.MAX_VALUE); + + static Function longsToBytes = + (Function) makePrimitiveArrayToBytesConverter(annotatedType_long); + static Function bytesToLongs = + getLongPrimitiveArray(Long.MIN_VALUE, Long.MAX_VALUE); + + static Function shortsToBytes = + (Function) makePrimitiveArrayToBytesConverter(annotatedType_short); + static Function bytesToShorts = + getShortPrimitiveArray(Short.MIN_VALUE, Short.MAX_VALUE); + + static Function charsToBytes = + (Function) makePrimitiveArrayToBytesConverter(annotatedType_char); + static Function bytesToChars = + getCharPrimitiveArray(Character.MIN_VALUE, Character.MAX_VALUE); + + static Function booleansToBytes = + (Function) makePrimitiveArrayToBytesConverter(annotatedType_boolean); + static Function bytesToBooleans = getBooleanPrimitiveArray(0, 1); + + static Function floatsToBytes = + (Function) makePrimitiveArrayToBytesConverter(annotatedType_float); + static Function bytesToFloats = + getFloatPrimitiveArray(Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY, true); + + static Function doublesToBytes = + (Function) makePrimitiveArrayToBytesConverter(annotatedType_double); + static Function bytesToDoubles = + getDoublePrimitiveArray(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, true); + + static Stream int2ByteTestCases() { + return Stream.of( + arguments(new int[] {0x010203}, new byte[] {0x00, 0x01, 0x02, 0x03}), + arguments(new int[] {1}, new byte[] {0x00, 0x00, 0x00, 0x1}), + arguments(new int[] {0x01000000}, new byte[] {0x01, 0x00, 0x00, 0x0}), + arguments( + new int[] {1, 2, 3, 4}, new byte[] {0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 4})); + } + + @ParameterizedTest + @MethodSource("int2ByteTestCases") + void testArrayConversion_ints2bytes(int[] ints, byte[] bytes) { + assertThat(intsToBytes.apply(ints)).isEqualTo(bytes); + } + + static Stream bytes2intsTestCases() { + return Stream.of( + arguments(new byte[] {0x01}, new int[] {0x00000001}, Integer.MIN_VALUE, Integer.MAX_VALUE), + arguments( + new byte[] {0x01, 0x00}, new int[] {0x00000100}, Integer.MIN_VALUE, Integer.MAX_VALUE), + arguments( + new byte[] {0x01, 0x00, 0x00}, + new int[] {0x00010000}, + Integer.MIN_VALUE, + Integer.MAX_VALUE), + arguments( + new byte[] {0x01, 0x00, 0x00, 0x00}, + new int[] {0x01000000}, + Integer.MIN_VALUE, + Integer.MAX_VALUE), + arguments( + new byte[] {(byte) 0xff}, new int[] {0x000000ff}, Integer.MIN_VALUE, Integer.MAX_VALUE), + arguments( + new byte[] {(byte) 0xff, (byte) 0x0f}, + new int[] {0x0000ff0f}, + Integer.MIN_VALUE, + Integer.MAX_VALUE), + arguments( + new byte[] {(byte) 0xff}, new int[] {0x000000ff}, Integer.MIN_VALUE, Integer.MAX_VALUE), + arguments( + new byte[] {(byte) 0xff, (byte) 0xff}, + new int[] {0x0000ffff}, + Integer.MIN_VALUE, + Integer.MAX_VALUE), + arguments( + new byte[] {(byte) 0xff, 0x00, (byte) 0xff, (byte) 0xff}, + new int[] {0xff00ffff}, + Integer.MIN_VALUE, + Integer.MAX_VALUE)); + } + + // same for longs + static Stream bytes2longsTestCases() { + return Stream.of( + arguments(new byte[] {0x01}, new long[] {0x00000001}, Long.MIN_VALUE, Long.MAX_VALUE), + arguments(new byte[] {0x01, 0x00}, new long[] {0x00000100}, Long.MIN_VALUE, Long.MAX_VALUE), + arguments( + new byte[] {0x01, 0x00, 0x00}, new long[] {0x00010000}, Long.MIN_VALUE, Long.MAX_VALUE), + arguments( + new byte[] {0x01, 0x00, 0x00, 0x00}, + new long[] {0x01000000}, + Long.MIN_VALUE, + Long.MAX_VALUE), + arguments( + new byte[] {0x01, 0x00, 0x00, 0x00, 0x00}, + new long[] {0x0100000000L}, + Long.MIN_VALUE, + Long.MAX_VALUE), + arguments( + new byte[] {0x01, 0x00, 0x00, 0x00, 0x00, 0x00}, + new long[] {0x010000000000L}, + Long.MIN_VALUE, + Long.MAX_VALUE), + arguments( + new byte[] {0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + new long[] {0x01000000000000L}, + Long.MIN_VALUE, + Long.MAX_VALUE), + arguments( + new byte[] {0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + new long[] {0x0100000000000000L}, + Long.MIN_VALUE, + Long.MAX_VALUE), + arguments( + new byte[] {(byte) 0xff}, new long[] {0x000000ff}, Long.MIN_VALUE, Long.MAX_VALUE), + arguments( + new byte[] {(byte) 0xff, (byte) 0x0f}, + new long[] {0x0000ff0f}, + Long.MIN_VALUE, + Long.MAX_VALUE), + arguments( + new byte[] {(byte) 0xff}, new long[] {0x000000ff}, Long.MIN_VALUE, Long.MAX_VALUE), + arguments( + new byte[] {(byte) 0xff, (byte) 0xff}, + new long[] {0x0000ffff}, + Long.MIN_VALUE, + Long.MAX_VALUE), + arguments( + new byte[] {(byte) 0xff, 0x00, (byte) 0xff, (byte) 0xff}, + new long[] {0xff00ffffL}, + Long.MIN_VALUE, + Long.MAX_VALUE), + arguments( + new byte[] {(byte) 0xff, 0x00, (byte) 0xff, (byte) 0xff, (byte) 0xff}, + new long[] {0xff00ffffffL}, + Long.MIN_VALUE, + Long.MAX_VALUE), + arguments( + new byte[] {(byte) 0xff, 0x00, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff}, + new long[] {0xff00ffffffffL}, + Long.MIN_VALUE, + Long.MAX_VALUE), + arguments( + new byte[] { + (byte) 0xff, 0x00, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff + }, + new long[] {0xff00ffffffffffL}, + Long.MIN_VALUE, + Long.MAX_VALUE), + arguments( + new byte[] { + (byte) 0xff, + 0x00, + (byte) 0xff, + (byte) 0xff, + (byte) 0xff, + (byte) 0xff, + (byte) 0xff, + (byte) 0xff + }, + new long[] {0xff00ffffffffffffL}, + Long.MIN_VALUE, + Long.MAX_VALUE)); + } + + @ParameterizedTest + @MethodSource("bytes2longsTestCases") + void testArrayConversion_bytes2longs(byte[] input, long[] expected, long min, long max) { + Function fn = getLongPrimitiveArray(min, max); + assertThat(fn.apply(input)).isEqualTo(expected); + } + + @ParameterizedTest + @MethodSource("bytes2intsTestCases") + void testArrayConversion_bytes2ints(byte[] input, int[] expected, int min, int max) { + Function toInts = getIntegerPrimitiveArray(min, max); + assertThat(toInts.apply(input)).isEqualTo(expected); + } + + static Stream bytes2shortsTestCases() { + return Stream.of( + arguments(new byte[] {0x01}, new short[] {0x0001}, Short.MIN_VALUE, Short.MAX_VALUE), + arguments(new byte[] {0x01, 0x00}, new short[] {0x0100}, Short.MIN_VALUE, Short.MAX_VALUE), + arguments(new byte[] {(byte) 0xff}, new short[] {0x00ff}, Short.MIN_VALUE, Short.MAX_VALUE), + arguments( + new byte[] {(byte) 0xff, (byte) 0xff}, + new short[] {(short) 0xffff}, + Short.MIN_VALUE, + Short.MAX_VALUE), + arguments( + new byte[] {(byte) 0xff, 0x00}, + new short[] {(short) 0xff00}, + Short.MIN_VALUE, + Short.MAX_VALUE)); + } + + @ParameterizedTest + @MethodSource("bytes2shortsTestCases") + void testArrayConversion_bytes2shorts(byte[] input, short[] expected, short min, short max) { + Function fn = getShortPrimitiveArray(min, max); + assertThat(fn.apply(input)).isEqualTo(expected); + } + + static Stream bytes2charsTestCases() { + return Stream.of( + arguments(new byte[] {0x41}, new char[] {0x41}, Character.MIN_VALUE, Character.MAX_VALUE), + arguments( + new byte[] {0x41, 0x41}, new char[] {0x4141}, Character.MIN_VALUE, Character.MAX_VALUE), + arguments( + new byte[] {0x01, 0x00}, + new char[] {(char) 0x0100}, + Character.MIN_VALUE, + Character.MAX_VALUE), + arguments( + new byte[] {(byte) 0xff}, + new char[] {(char) 0x00ff}, + Character.MIN_VALUE, + Character.MAX_VALUE), + arguments( + new byte[] {(byte) 0xff, (byte) 0xff}, + new char[] {(char) 0xffff}, + Character.MIN_VALUE, + Character.MAX_VALUE), + arguments( + new byte[] {(byte) 0xff, 0x00}, + new char[] {(char) 0xff00}, + Character.MIN_VALUE, + Character.MAX_VALUE)); + } + + @ParameterizedTest + @MethodSource("bytes2charsTestCases") + void testArrayConversion_bytes2chars(byte[] input, char[] expected, long min, long max) { + Function fn = getCharPrimitiveArray(min, max); + assertThat(fn.apply(input)).isEqualTo(expected); + } + + // same with booleans + static Stream bytes2booleansTestCases() { + return Stream.of( + arguments(new byte[] {0x01}, new boolean[] {true}), + arguments( + new byte[] {0, 1, 2, 3, 4, 5, 6}, + new boolean[] {false, true, false, true, false, true, false}), + arguments(new byte[] {0x00}, new boolean[] {false}), + arguments(new byte[] {(byte) 0xff}, new boolean[] {true}), + arguments(new byte[] {(byte) 0x00}, new boolean[] {false}), + arguments(new byte[] {(byte) 0x01, (byte) 0x00}, new boolean[] {true, false}), + arguments(new byte[] {(byte) 0x01, (byte) 0x01}, new boolean[] {true, true}), + arguments(new byte[] {(byte) 0x00, (byte) 0x00}, new boolean[] {false, false}), + arguments(new byte[] {(byte) 0xff, (byte) 0xff}, new boolean[] {true, true}), + arguments(new byte[] {(byte) 0xff, (byte) 0x00}, new boolean[] {true, false}), + arguments(new byte[] {(byte) 0x00, (byte) 0xff}, new boolean[] {false, true}), + arguments(new byte[] {(byte) 0x00, (byte) 0x01}, new boolean[] {false, true}), + arguments( + new byte[] {(byte) 0x01, (byte) 0x00, (byte) 0x01}, new boolean[] {true, false, true}), + arguments( + new byte[] {(byte) 0x01, (byte) 0x01, (byte) 0x01}, new boolean[] {true, true, true}), + arguments( + new byte[] {(byte) 0x00, (byte) 0x00, (byte) 0x00}, + new boolean[] {false, false, false}), + arguments( + new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff}, new boolean[] {true, true, true}), + arguments( + new byte[] {(byte) 0xff, (byte) 0x00, (byte) 0xff}, new boolean[] {true, false, true})); + } + + @ParameterizedTest + @MethodSource("bytes2booleansTestCases") + void testArrayConversion_bytes2booleans(byte[] input, boolean[] expected) { + Function fn = getBooleanPrimitiveArray(0, 1); + assertThat(fn.apply(input)).isEqualTo(expected); + } + + // same with bytes + static Stream bytes2bytesTestCases() { + return Stream.of( + arguments(new byte[] {1}, new byte[] {0x01}, Byte.MIN_VALUE, Byte.MAX_VALUE), + arguments(new byte[] {1, 2, 3}, new byte[] {1, 2, 3}, Byte.MIN_VALUE, Byte.MAX_VALUE), + arguments( + new byte[] {(byte) 0xff}, new byte[] {(byte) 0xff}, Byte.MIN_VALUE, Byte.MAX_VALUE), + // reduced domain + arguments(new byte[] {1, 2, 3}, new byte[] {1, 2, -2}, -2, 2), + arguments( + new byte[] {10, 11, 0, -10, -11, -5, 1}, + new byte[] {10, -10, 0, -10, -9, -5, 1}, + -10, + 10)); + } + + @ParameterizedTest + @MethodSource("bytes2bytesTestCases") + void testArrayConversion_bytes2bytes(byte[] input, byte[] expected, long min, long max) { + Function fn = getBytePrimitiveArray(min, max); + assertThat(fn.apply(input)).isEqualTo(expected); + } + + // same with floats + static Stream bytes2floatsTestCases() { + return Stream.of( + arguments( + new byte[] {(byte) 0xff}, + new float[] {Float.intBitsToFloat(0xff)}, + -Float.MAX_VALUE, + Float.MAX_VALUE, + true), + arguments( + new byte[] {(byte) 0xff, (byte) 0xff}, + new float[] {Float.intBitsToFloat(0xffff)}, + -Float.MAX_VALUE, + Float.MAX_VALUE, + true), + arguments( + new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff}, + new float[] {Float.intBitsToFloat(0xffffff)}, + -Float.MAX_VALUE, + Float.MAX_VALUE, + true), + arguments( + new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff}, + new float[] {Float.intBitsToFloat(0xffffffff)}, + -Float.MAX_VALUE, + Float.MAX_VALUE, + true), + arguments( + new byte[] {0, 0, 0, 0, 1}, + new float[] {0f, Float.intBitsToFloat(1)}, + -Float.MAX_VALUE, + Float.MAX_VALUE, + true), + arguments( + new byte[] {0, 0, 0, 0, 1, 1}, + new float[] {0f, Float.intBitsToFloat(0x0101)}, + -Float.MAX_VALUE, + Float.MAX_VALUE, + true), + arguments( + new byte[] {0, 0, 0, 0, 1, 1, 1}, + new float[] {0f, Float.intBitsToFloat(0x010101)}, + -Float.MAX_VALUE, + Float.MAX_VALUE, + true), + arguments( + new byte[] {0, 0, 0, 0, 1, 1, 1, 1}, + new float[] {0f, Float.intBitsToFloat(0x01010101)}, + -Float.MAX_VALUE, + Float.MAX_VALUE, + true)); + } + + @ParameterizedTest + @MethodSource("bytes2floatsTestCases") + void testArrayConversion_bytes2floats( + byte[] input, float[] expected, float min, float max, boolean allowNan) { + Function fn = getFloatPrimitiveArray(min, max, allowNan); + assertThat(fn.apply(input)).isEqualTo(expected); + } + + // same with doubles + static Stream bytes2doublesTestCases() { + return Stream.of( + arguments( + new byte[] {(byte) 0xff}, + new double[] {Double.longBitsToDouble(0xff)}, + -Double.MAX_VALUE, + Double.MAX_VALUE, + true), + arguments( + new byte[] {(byte) 0xff, (byte) 0xff}, + new double[] {Double.longBitsToDouble(0xffff)}, + -Double.MAX_VALUE, + Double.MAX_VALUE, + true), + arguments( + new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff}, + new double[] {Double.longBitsToDouble(0xffffff)}, + -Double.MAX_VALUE, + Double.MAX_VALUE, + true), + arguments( + new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff}, + new double[] {Double.longBitsToDouble(0xffffffffL)}, + -Double.MAX_VALUE, + Double.MAX_VALUE, + true), + arguments( + new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff}, + new double[] {Double.longBitsToDouble(0xffffffffffL)}, + -Double.MAX_VALUE, + Double.MAX_VALUE, + true), + arguments( + new byte[] { + (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff + }, + new double[] {Double.longBitsToDouble(0xffffffffffffL)}, + -Double.MAX_VALUE, + Double.MAX_VALUE, + true), + arguments( + new byte[] { + (byte) 0xff, + (byte) 0xff, + (byte) 0xff, + (byte) 0xff, + (byte) 0xff, + (byte) 0xff, + (byte) 0xff + }, + new double[] {Double.longBitsToDouble(0xffffffffffffffL)}, + -Double.MAX_VALUE, + Double.MAX_VALUE, + true), + arguments( + new byte[] {0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1}, + new double[] {0.0, Double.longBitsToDouble(0x010101)}, + -Double.MAX_VALUE, + Double.MAX_VALUE, + true)); + } + + @ParameterizedTest + @MethodSource("bytes2doublesTestCases") + void testArrayConversion_bytes2doubles( + byte[] input, double[] expected, double min, double max, boolean allowNan) { + Function fn = getDoublePrimitiveArray(min, max, allowNan); + assertThat(fn.apply(input)).isEqualTo(expected); + } + + static Stream intsRoundTripTestCases() { + return Stream.of( + arguments(new int[] {1, 2, 3, 0, 1, 2, 3, 41037219}), + arguments(new int[] {0, 0, 0, 0, 0, 0, 0, 0}), + arguments(new int[] {0, 0, 0, 0, 0, 0, 0, 1}), + arguments(new int[] {0, 0, 0, 0, 0, 0, 0, 2}), + arguments(new int[] {0, 0, 0, 0, 0, 0, 0, 1 << 31}), + arguments(new int[] {1 << 31, 0, 0, 0, 0, 0, 0, 1 >> 31})); + } + + @ParameterizedTest + @MethodSource("intsRoundTripTestCases") + void testRoundTrip_ints(int[] numbers) { + assertThat(bytesToInts.apply(intsToBytes.apply(numbers))).isEqualTo(numbers); + } + + static Stream longsRoundTripTestCases() { + return Stream.of( + arguments(new long[] {1, 2, 3, 0, 1, 2, 3, 41037219}), + arguments(new long[] {0, 0, 0, 0, 0, 0, 0, 0}), + arguments(new long[] {0, 0, 0, 0, 0, 0, 0, 1}), + arguments(new long[] {0, 0, 0, 0, 0, 0, 0, 2}), + arguments(new long[] {0, 0, 0, 0, 0, 0, 0, 1L << 63}), + arguments(new long[] {1L << 63, 0, 0, 0, 0, 0, 0, 1})); + } + + @ParameterizedTest + @MethodSource("longsRoundTripTestCases") + void testRoundTrip_longs(long[] numbers) { + assertThat(bytesToLongs.apply(longsToBytes.apply(numbers))).isEqualTo(numbers); + } + + static Stream shortsRoundTripTestCases() { + return Stream.of( + arguments(new short[] {1, 2, 3, 0, 1, 2, 3, 12313}), + arguments(new short[] {0, 0, 0, 0, 0, 0, 0, 0}), + arguments(new short[] {0, 0, 0, 0, 0, 0, 0, 1}), + arguments(new short[] {0, 0, 0, 0, 0, 0, 0, 2}), + arguments(new short[] {0, 0, 0, 0, 0, 0, 0, 32767}), + arguments(new short[] {32767, 0, 0, 0, 0, 0, 0, 1})); + } + + @ParameterizedTest + @MethodSource("shortsRoundTripTestCases") + void testRoundTrip_shorts(short[] numbers) { + assertThat(bytesToShorts.apply(shortsToBytes.apply(numbers))).isEqualTo(numbers); + } + + static Stream charsRoundTripTestCases() { + return Stream.of( + arguments(new char[] {1, 2, 3, 0, 1, 2, 3, 12313}), + arguments(new char[] {0, 0, 0, 0, 0, 0, 0, 0}), + arguments(new char[] {0, 0, 0, 0, 0, 0, 0, 1}), + arguments(new char[] {0, 0, 0, 0, 0, 0, 0, 2}), + arguments(new char[] {0, 0, 0, 0, 0, 0, 0, 32767}), + arguments(new char[] {32767, 0, 0, 0, 0, 0, 0, 1})); + } + + @ParameterizedTest + @MethodSource("charsRoundTripTestCases") + void testRoundTrip_chars(char[] numbers) { + assertThat(bytesToChars.apply(charsToBytes.apply(numbers))).isEqualTo(numbers); + } + + static Stream booleansRoundTripTestCases() { + return Stream.of( + arguments(new boolean[] {true}), + arguments(new boolean[] {false}), + arguments(new boolean[] {true, false}), + arguments(new boolean[] {false, true}), + arguments(new boolean[] {true, true}), + arguments(new boolean[] {false, false}), + arguments(new boolean[] {true, true, false})); + } + + @ParameterizedTest + @MethodSource("booleansRoundTripTestCases") + void testRoundTrip_booleans(boolean[] numbers) { + assertThat(bytesToBooleans.apply(booleansToBytes.apply(numbers))).isEqualTo(numbers); + } + + static Stream floatsRoundTripTestCases() { + return Stream.of( + arguments(new float[] {1.0f, 2.0f, 3.0f, 0.0f, 1.0f, 2.0f, 3.0f, 12313.0f}), + arguments( + new float[] { + Float.MIN_VALUE, + Float.MAX_VALUE, + 0.0f, + -0.0f, + Float.POSITIVE_INFINITY, + Float.NEGATIVE_INFINITY, + Float.NaN + })); + } + + @ParameterizedTest + @MethodSource("floatsRoundTripTestCases") + void testRoundTrip_floats(float[] numbers) { + assertThat(bytesToFloats.apply(floatsToBytes.apply(numbers))).isEqualTo(numbers); + } + + static Stream doublesRoundTripTestCases() { + return Stream.of( + arguments(new double[] {1, 2, 3, 4, 5}), + arguments( + new double[] { + Double.MIN_VALUE, + Double.MAX_VALUE, + 0.0, + -0.0, + Double.POSITIVE_INFINITY, + Double.NEGATIVE_INFINITY, + Double.NaN + })); + } + + @ParameterizedTest + @MethodSource("doublesRoundTripTestCases") + void testRoundTrip_doubles(double[] numbers) { + assertThat(bytesToDoubles.apply(doublesToBytes.apply(numbers))).isEqualTo(numbers); + } + + static Stream bytesRoundTripTestCases() { + return Stream.of( + arguments(new byte[] {1, 2, 3, 4, 5}), + arguments(new byte[] {Byte.MIN_VALUE, Byte.MAX_VALUE, 0, -0, 1, -1, 127, -128})); + } + + @ParameterizedTest + @MethodSource("bytesRoundTripTestCases") + void testRoundTrip_bytes(byte[] numbers) { + assertThat(libfuzzerBytesToBytes.apply(bytesToLibfuzzerBytes.apply(numbers))) + .isEqualTo(numbers); + } +} diff --git a/src/test/java/com/code_intelligence/jazzer/mutation/mutator/lang/StringMutatorTest.java b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/lang/StringMutatorTest.java index 982e1ad04..25433b689 100644 --- a/src/test/java/com/code_intelligence/jazzer/mutation/mutator/lang/StringMutatorTest.java +++ b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/lang/StringMutatorTest.java @@ -1,29 +1,27 @@ /* - * Copyright 2023 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.code_intelligence.jazzer.mutation.mutator.lang; import static com.code_intelligence.jazzer.mutation.mutator.lang.StringMutatorFactory.fixUpAscii; +import static com.code_intelligence.jazzer.mutation.mutator.lang.StringMutatorFactory.fixUpPchar; import static com.code_intelligence.jazzer.mutation.mutator.lang.StringMutatorFactory.fixUpUtf8; +import static com.code_intelligence.jazzer.mutation.support.TestSupport.anyPseudoRandom; import static com.code_intelligence.jazzer.mutation.support.TestSupport.mockPseudoRandom; import static com.google.common.truth.Truth.assertThat; import com.code_intelligence.jazzer.mutation.annotation.NotNull; +import com.code_intelligence.jazzer.mutation.annotation.UrlSegment; import com.code_intelligence.jazzer.mutation.annotation.WithUtf8Length; +import com.code_intelligence.jazzer.mutation.api.PseudoRandom; import com.code_intelligence.jazzer.mutation.api.SerializingMutator; +import com.code_intelligence.jazzer.mutation.engine.ChainedMutatorFactory; import com.code_intelligence.jazzer.mutation.mutator.libfuzzer.LibFuzzerMutate; import com.code_intelligence.jazzer.mutation.support.RandomSupport; import com.code_intelligence.jazzer.mutation.support.TestSupport.MockPseudoRandom; @@ -35,6 +33,13 @@ import org.junit.jupiter.api.*; class StringMutatorTest { + ChainedMutatorFactory factory; + + @BeforeEach + void createFactory() { + factory = ChainedMutatorFactory.of(LangMutators.newFactories()); + } + /** * Some tests may set {@link LibFuzzerMutate#MOCK_SIZE_KEY} which can interfere with other tests * unless cleared. @@ -108,13 +113,46 @@ void testFixUtf8_validInputNotChanged(RepetitionInfo info) { } } + @RepeatedTest(10) + void testFixPchar_randomInputFixed(RepetitionInfo info) { + SplittableRandom random = + new SplittableRandom( + (long) "testFixPchar_randomInputFixed".hashCode() * info.getCurrentRepetition()); + + for (int length = 0; length < 1000; length++) { + byte[] randomBytes = generateRandomBytes(random, length); + byte[] copy = Arrays.copyOf(randomBytes, randomBytes.length); + fixUpPchar(copy); + if (isValidPathVariable(randomBytes)) { + assertThat(copy).isEqualTo(randomBytes); + } else { + assertThat(isValidAscii(copy)).isTrue(); + } + } + } + + @Test + void testUrlSegmentInit() { + SerializingMutator mutator = + (SerializingMutator) + factory.createOrThrow( + new TypeHolder< + @NotNull @UrlSegment @WithUtf8Length(min = 10) String>() {}.annotatedType()); + assertThat(mutator.toString()).isEqualTo("String"); + PseudoRandom prng = anyPseudoRandom(); + for (int i = 0; i < 1000; i++) { + String urlSegment = mutator.init(prng); + assertThat(urlSegment.length()).isAtLeast(10); + assertThat(isValidPathVariable(urlSegment.getBytes(StandardCharsets.UTF_8))).isTrue(); + } + } + @Test void testMinLengthInit() { SerializingMutator mutator = (SerializingMutator) - LangMutators.newFactory() - .createOrThrow( - new TypeHolder<@NotNull @WithUtf8Length(min = 10) String>() {}.annotatedType()); + factory.createOrThrow( + new TypeHolder<@NotNull @WithUtf8Length(min = 10) String>() {}.annotatedType()); assertThat(mutator.toString()).isEqualTo("String"); try (MockPseudoRandom prng = mockPseudoRandom(5)) { @@ -131,9 +169,8 @@ void testMinLengthInit() { void testMaxLengthInit() { SerializingMutator mutator = (SerializingMutator) - LangMutators.newFactory() - .createOrThrow( - new TypeHolder<@NotNull @WithUtf8Length(max = 50) String>() {}.annotatedType()); + factory.createOrThrow( + new TypeHolder<@NotNull @WithUtf8Length(max = 50) String>() {}.annotatedType()); assertThat(mutator.toString()).isEqualTo("String"); try (MockPseudoRandom prng = mockPseudoRandom(60)) { @@ -150,9 +187,8 @@ void testMaxLengthInit() { void testMinLengthMutate() { SerializingMutator mutator = (SerializingMutator) - LangMutators.newFactory() - .createOrThrow( - new TypeHolder<@NotNull @WithUtf8Length(min = 10) String>() {}.annotatedType()); + factory.createOrThrow( + new TypeHolder<@NotNull @WithUtf8Length(min = 10) String>() {}.annotatedType()); assertThat(mutator.toString()).isEqualTo("String"); String s; @@ -172,9 +208,8 @@ void testMinLengthMutate() { void testMaxLengthMutate() { SerializingMutator mutator = (SerializingMutator) - LangMutators.newFactory() - .createOrThrow( - new TypeHolder<@NotNull @WithUtf8Length(max = 15) String>() {}.annotatedType()); + factory.createOrThrow( + new TypeHolder<@NotNull @WithUtf8Length(max = 15) String>() {}.annotatedType()); assertThat(mutator.toString()).isEqualTo("String"); String s; @@ -197,9 +232,8 @@ void testMaxLengthMutate() { void testMultibyteCharacters() { SerializingMutator mutator = (SerializingMutator) - LangMutators.newFactory() - .createOrThrow( - new TypeHolder<@NotNull @WithUtf8Length(min = 10) String>() {}.annotatedType()); + factory.createOrThrow( + new TypeHolder<@NotNull @WithUtf8Length(min = 10) String>() {}.annotatedType()); assertThat(mutator.toString()).isEqualTo("String"); String s; @@ -224,6 +258,27 @@ private static boolean isValidAscii(byte[] data) { return true; } + private static final byte[] VALID_PCHAR = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~:@!$&'()*+,;=".getBytes(); + + private static boolean isValidPathVariable(byte[] data) { + for (byte b : data) { + if (!isValidPathChar(b)) { + return false; + } + } + return true; + } + + private static boolean isValidPathChar(byte b) { + for (byte valid : VALID_PCHAR) { + if (b == valid) { + return true; + } + } + return false; + } + private static byte[] generateRandomBytes(SplittableRandom random, int length) { byte[] bytes = new byte[length]; RandomSupport.nextBytes(random, bytes); diff --git a/src/test/java/com/code_intelligence/jazzer/mutation/mutator/proto/BUILD.bazel b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/proto/BUILD.bazel index bf8b551d9..5c8545753 100644 --- a/src/test/java/com/code_intelligence/jazzer/mutation/mutator/proto/BUILD.bazel +++ b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/proto/BUILD.bazel @@ -4,7 +4,7 @@ proto_library( name = "proto3_proto", srcs = ["proto3.proto"], deps = [ - "@com_google_protobuf//:any_proto", + "@protobuf//:any_proto", ], ) @@ -50,11 +50,13 @@ java_test_suite( "//src/main/java/com/code_intelligence/jazzer/mutation/annotation", "//src/main/java/com/code_intelligence/jazzer/mutation/annotation/proto", "//src/main/java/com/code_intelligence/jazzer/mutation/api", + "//src/main/java/com/code_intelligence/jazzer/mutation/engine", "//src/main/java/com/code_intelligence/jazzer/mutation/mutator/collection", "//src/main/java/com/code_intelligence/jazzer/mutation/mutator/lang", "//src/main/java/com/code_intelligence/jazzer/mutation/mutator/proto", "//src/main/java/com/code_intelligence/jazzer/mutation/support", + "//src/main/java/com/code_intelligence/jazzer/mutation/utils", "//src/test/java/com/code_intelligence/jazzer/mutation/support:test_support", - "@com_google_protobuf//java/core", + "@protobuf//java/core", ], ) diff --git a/src/test/java/com/code_intelligence/jazzer/mutation/mutator/proto/BuilderAdaptersTest.java b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/proto/BuilderAdaptersTest.java index 7722a6ad7..589107632 100644 --- a/src/test/java/com/code_intelligence/jazzer/mutation/mutator/proto/BuilderAdaptersTest.java +++ b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/proto/BuilderAdaptersTest.java @@ -1,17 +1,10 @@ /* - * Copyright 2023 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.code_intelligence.jazzer.mutation.mutator.proto; diff --git a/src/test/java/com/code_intelligence/jazzer/mutation/mutator/proto/BuilderMutatorProto2Test.java b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/proto/BuilderMutatorProto2Test.java index b41744907..7b0fb8700 100644 --- a/src/test/java/com/code_intelligence/jazzer/mutation/mutator/proto/BuilderMutatorProto2Test.java +++ b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/proto/BuilderMutatorProto2Test.java @@ -1,17 +1,10 @@ /* - * Copyright 2023 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.code_intelligence.jazzer.mutation.mutator.proto; @@ -21,35 +14,39 @@ import static com.google.common.truth.extensions.proto.ProtoTruth.assertThat; import com.code_intelligence.jazzer.mutation.annotation.NotNull; -import com.code_intelligence.jazzer.mutation.api.ChainedMutatorFactory; import com.code_intelligence.jazzer.mutation.api.InPlaceMutator; -import com.code_intelligence.jazzer.mutation.api.MutatorFactory; +import com.code_intelligence.jazzer.mutation.api.SerializingMutator; +import com.code_intelligence.jazzer.mutation.engine.ChainedMutatorFactory; import com.code_intelligence.jazzer.mutation.mutator.collection.CollectionMutators; import com.code_intelligence.jazzer.mutation.mutator.lang.LangMutators; import com.code_intelligence.jazzer.mutation.support.TestSupport.MockPseudoRandom; import com.code_intelligence.jazzer.mutation.support.TypeHolder; -import com.code_intelligence.jazzer.protobuf.Proto2.MessageField2; -import com.code_intelligence.jazzer.protobuf.Proto2.OneOfField2; -import com.code_intelligence.jazzer.protobuf.Proto2.PrimitiveField2; -import com.code_intelligence.jazzer.protobuf.Proto2.RecursiveMessageField2; -import com.code_intelligence.jazzer.protobuf.Proto2.RepeatedMessageField2; -import com.code_intelligence.jazzer.protobuf.Proto2.RepeatedOptionalMessageField2; -import com.code_intelligence.jazzer.protobuf.Proto2.RepeatedPrimitiveField2; -import com.code_intelligence.jazzer.protobuf.Proto2.RequiredPrimitiveField2; +import com.code_intelligence.jazzer.mutation.utils.PropertyConstraint; +import com.code_intelligence.jazzer.protobuf.Proto2.*; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +@SuppressWarnings("unchecked") class BuilderMutatorProto2Test { - private static final MutatorFactory FACTORY = - new ChainedMutatorFactory( - LangMutators.newFactory(), CollectionMutators.newFactory(), ProtoMutators.newFactory()); + ChainedMutatorFactory factory; + + @BeforeEach + void createFactory() { + factory = + ChainedMutatorFactory.of( + LangMutators.newFactories(), + CollectionMutators.newFactories(), + ProtoMutators.newFactories()); + } @Test void testPrimitiveField() { InPlaceMutator mutator = (InPlaceMutator) - FACTORY.createInPlaceOrThrow( + factory.createInPlaceOrThrow( new TypeHolder() {}.annotatedType()); assertThat(mutator.toString()).isEqualTo("{Builder.Nullable}"); + assertThat(mutator.hasFixedSize()).isTrue(); PrimitiveField2.Builder builder = PrimitiveField2.newBuilder(); @@ -100,9 +97,10 @@ void testPrimitiveField() { void testRequiredPrimitiveField() { InPlaceMutator mutator = (InPlaceMutator) - FACTORY.createInPlaceOrThrow( + factory.createInPlaceOrThrow( new TypeHolder() {}.annotatedType()); assertThat(mutator.toString()).isEqualTo("{Builder.Boolean}"); + assertThat(mutator.hasFixedSize()).isTrue(); RequiredPrimitiveField2.Builder builder = RequiredPrimitiveField2.newBuilder(); @@ -121,9 +119,10 @@ void testRequiredPrimitiveField() { void testRepeatedPrimitiveField() { InPlaceMutator mutator = (InPlaceMutator) - FACTORY.createInPlaceOrThrow( + factory.createInPlaceOrThrow( new TypeHolder() {}.annotatedType()); assertThat(mutator.toString()).isEqualTo("{Builder via List}"); + assertThat(mutator.hasFixedSize()).isFalse(); RepeatedPrimitiveField2.Builder builder = RepeatedPrimitiveField2.newBuilder(); @@ -172,9 +171,10 @@ void testRepeatedPrimitiveField() { void testMessageField() { InPlaceMutator mutator = (InPlaceMutator) - FACTORY.createInPlaceOrThrow( + factory.createInPlaceOrThrow( new TypeHolder() {}.annotatedType()); assertThat(mutator.toString()).isEqualTo("{Builder.Nullable<{Builder.Boolean} -> Message>}"); + assertThat(mutator.hasFixedSize()).isTrue(); MessageField2.Builder builder = MessageField2.newBuilder(); @@ -220,11 +220,12 @@ void testMessageField() { void testRepeatedOptionalMessageField() { InPlaceMutator mutator = (InPlaceMutator) - FACTORY.createInPlaceOrThrow( + factory.createInPlaceOrThrow( new TypeHolder< RepeatedOptionalMessageField2.@NotNull Builder>() {}.annotatedType()); assertThat(mutator.toString()) .isEqualTo("{Builder via List<{Builder.Nullable} -> Message>}"); + assertThat(mutator.hasFixedSize()).isFalse(); RepeatedOptionalMessageField2.Builder builder = RepeatedOptionalMessageField2.newBuilder(); @@ -261,9 +262,10 @@ void testRepeatedOptionalMessageField() { void testRepeatedRequiredMessageField() { InPlaceMutator mutator = (InPlaceMutator) - FACTORY.createInPlaceOrThrow( + factory.createInPlaceOrThrow( new TypeHolder() {}.annotatedType()); assertThat(mutator.toString()).isEqualTo("{Builder via List<{Builder.Boolean} -> Message>}"); + assertThat(mutator.hasFixedSize()).isFalse(); RepeatedMessageField2.Builder builder = RepeatedMessageField2.newBuilder(); @@ -324,10 +326,11 @@ void testRepeatedRequiredMessageField() { void testRecursiveMessageField() { InPlaceMutator mutator = (InPlaceMutator) - FACTORY.createInPlaceOrThrow( + factory.createInPlaceOrThrow( new TypeHolder() {}.annotatedType()); assertThat(mutator.toString()) .isEqualTo("{Builder.Boolean, WithoutInit(Builder.Nullable<(cycle) -> Message>)}"); + assertThat(mutator.hasFixedSize()).isFalse(); RecursiveMessageField2.Builder builder = RecursiveMessageField2.newBuilder(); try (MockPseudoRandom prng = @@ -390,12 +393,13 @@ void testRecursiveMessageField() { void testOneOfField2() { InPlaceMutator mutator = (InPlaceMutator) - FACTORY.createInPlaceOrThrow( + factory.createInPlaceOrThrow( new TypeHolder() {}.annotatedType()); assertThat(mutator.toString()) .isEqualTo( "{Builder.Boolean, Builder.Nullable, Builder.Nullable |" + " Builder.Nullable<{Builder.Boolean} -> Message>}"); + assertThat(mutator.hasFixedSize()).isTrue(); OneOfField2.Builder builder = OneOfField2.newBuilder(); try (MockPseudoRandom prng = @@ -485,4 +489,15 @@ void testOneOfField2() { assertThat(builder.build()).isEqualTo(OneOfField2.newBuilder().setOtherField(true).build()); assertThat(builder.build().hasMessageField()).isFalse(); } + + @Test + void propagateConstraint() { + SerializingMutator mutator = + (SerializingMutator) + factory.createOrThrow( + new TypeHolder< + @NotNull(constraint = PropertyConstraint.RECURSIVE) + TestProtobuf>() {}.annotatedType()); + assertThat(mutator.toString()).doesNotContain("Nullable"); + } } diff --git a/src/test/java/com/code_intelligence/jazzer/mutation/mutator/proto/BuilderMutatorProto3Test.java b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/proto/BuilderMutatorProto3Test.java index 67f940bea..84daa67a3 100644 --- a/src/test/java/com/code_intelligence/jazzer/mutation/mutator/proto/BuilderMutatorProto3Test.java +++ b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/proto/BuilderMutatorProto3Test.java @@ -1,17 +1,10 @@ /* - * Copyright 2023 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.code_intelligence.jazzer.mutation.mutator.proto; @@ -22,9 +15,8 @@ import com.code_intelligence.jazzer.mutation.annotation.NotNull; import com.code_intelligence.jazzer.mutation.annotation.proto.AnySource; -import com.code_intelligence.jazzer.mutation.api.ChainedMutatorFactory; import com.code_intelligence.jazzer.mutation.api.InPlaceMutator; -import com.code_intelligence.jazzer.mutation.api.MutatorFactory; +import com.code_intelligence.jazzer.mutation.engine.ChainedMutatorFactory; import com.code_intelligence.jazzer.mutation.mutator.collection.CollectionMutators; import com.code_intelligence.jazzer.mutation.mutator.lang.LangMutators; import com.code_intelligence.jazzer.mutation.support.TestSupport.MockPseudoRandom; @@ -49,20 +41,29 @@ import com.code_intelligence.jazzer.protobuf.Proto3.TestEnumOutside3; import com.google.protobuf.InvalidProtocolBufferException; import java.util.Arrays; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; class BuilderMutatorProto3Test { - private static final MutatorFactory FACTORY = - new ChainedMutatorFactory( - LangMutators.newFactory(), CollectionMutators.newFactory(), ProtoMutators.newFactory()); + ChainedMutatorFactory factory; + + @BeforeEach + void createFactory() { + factory = + ChainedMutatorFactory.of( + LangMutators.newFactories(), + CollectionMutators.newFactories(), + ProtoMutators.newFactories()); + } @Test void testPrimitiveField() { InPlaceMutator mutator = (InPlaceMutator) - FACTORY.createInPlaceOrThrow( + factory.createInPlaceOrThrow( new TypeHolder() {}.annotatedType()); assertThat(mutator.toString()).isEqualTo("{Builder.Boolean}"); + assertThat(mutator.hasFixedSize()).isTrue(); PrimitiveField3.Builder builder = PrimitiveField3.newBuilder(); @@ -81,9 +82,10 @@ void testPrimitiveField() { void testEnumField() { InPlaceMutator mutator = (InPlaceMutator) - FACTORY.createInPlaceOrThrow( + factory.createInPlaceOrThrow( new TypeHolder() {}.annotatedType()); assertThat(mutator.toString()).isEqualTo("{Builder.Enum}"); + assertThat(mutator.hasFixedSize()).isTrue(); EnumField3.Builder builder = EnumField3.newBuilder(); try (MockPseudoRandom prng = mockPseudoRandom(0)) { mutator.initInPlace(builder, prng); @@ -99,9 +101,10 @@ void testEnumField() { void testEnumFieldOutside() { InPlaceMutator mutator = (InPlaceMutator) - FACTORY.createInPlaceOrThrow( + factory.createInPlaceOrThrow( new TypeHolder() {}.annotatedType()); assertThat(mutator.toString()).isEqualTo("{Builder.Enum}"); + assertThat(mutator.hasFixedSize()).isTrue(); EnumFieldOutside3.Builder builder = EnumFieldOutside3.newBuilder(); try (MockPseudoRandom prng = mockPseudoRandom(0)) { mutator.initInPlace(builder, prng); @@ -117,9 +120,10 @@ void testEnumFieldOutside() { void testEnumFieldWithOneValue() { InPlaceMutator mutator = (InPlaceMutator) - FACTORY.createInPlaceOrThrow( + factory.createInPlaceOrThrow( new TypeHolder() {}.annotatedType()); assertThat(mutator.toString()).isEqualTo("{Builder.FixedValue(ONE)}"); + assertThat(mutator.hasFixedSize()).isTrue(); EnumFieldOne3.Builder builder = EnumFieldOne3.newBuilder(); try (MockPseudoRandom prng = mockPseudoRandom()) { mutator.initInPlace(builder, prng); @@ -135,9 +139,10 @@ void testEnumFieldWithOneValue() { void testRepeatedEnumField() { InPlaceMutator mutator = (InPlaceMutator) - FACTORY.createInPlaceOrThrow( + factory.createInPlaceOrThrow( new TypeHolder() {}.annotatedType()); assertThat(mutator.toString()).isEqualTo("{Builder via List>}"); + assertThat(mutator.hasFixedSize()).isFalse(); EnumFieldRepeated3.Builder builder = EnumFieldRepeated3.newBuilder(); try (MockPseudoRandom prng = mockPseudoRandom( @@ -170,9 +175,10 @@ void testRepeatedEnumField() { void testOptionalPrimitiveField() { InPlaceMutator mutator = (InPlaceMutator) - FACTORY.createInPlaceOrThrow( + factory.createInPlaceOrThrow( new TypeHolder() {}.annotatedType()); assertThat(mutator.toString()).isEqualTo("{Builder.Nullable}"); + assertThat(mutator.hasFixedSize()).isTrue(); OptionalPrimitiveField3.Builder builder = OptionalPrimitiveField3.newBuilder(); @@ -223,9 +229,10 @@ void testOptionalPrimitiveField() { void testRepeatedPrimitiveField() { InPlaceMutator mutator = (InPlaceMutator) - FACTORY.createInPlaceOrThrow( + factory.createInPlaceOrThrow( new TypeHolder() {}.annotatedType()); assertThat(mutator.toString()).isEqualTo("{Builder via List}"); + assertThat(mutator.hasFixedSize()).isFalse(); RepeatedPrimitiveField3.Builder builder = RepeatedPrimitiveField3.newBuilder(); @@ -274,9 +281,10 @@ void testRepeatedPrimitiveField() { void testMessageField() { InPlaceMutator mutator = (InPlaceMutator) - FACTORY.createInPlaceOrThrow( + factory.createInPlaceOrThrow( new TypeHolder() {}.annotatedType()); assertThat(mutator.toString()).isEqualTo("{Builder.Nullable<{Builder.Boolean} -> Message>}"); + assertThat(mutator.hasFixedSize()).isTrue(); MessageField3.Builder builder = MessageField3.newBuilder(); @@ -321,9 +329,10 @@ void testMessageField() { void testRepeatedMessageField() { InPlaceMutator mutator = (InPlaceMutator) - FACTORY.createInPlaceOrThrow( + factory.createInPlaceOrThrow( new TypeHolder() {}.annotatedType()); assertThat(mutator.toString()).isEqualTo("{Builder via List<{Builder.Boolean} -> Message>}"); + assertThat(mutator.hasFixedSize()).isFalse(); RepeatedMessageField3.Builder builder = RepeatedMessageField3.newBuilder(); @@ -384,10 +393,11 @@ void testRepeatedMessageField() { void testRecursiveMessageField() { InPlaceMutator mutator = (InPlaceMutator) - FACTORY.createInPlaceOrThrow( + factory.createInPlaceOrThrow( new TypeHolder() {}.annotatedType()); assertThat(mutator.toString()) .isEqualTo("{Builder.Boolean, WithoutInit(Builder.Nullable<(cycle) -> Message>)}"); + assertThat(mutator.hasFixedSize()).isFalse(); RecursiveMessageField3.Builder builder = RecursiveMessageField3.newBuilder(); try (MockPseudoRandom prng = @@ -450,12 +460,13 @@ void testRecursiveMessageField() { void testOneOfField3() { InPlaceMutator mutator = (InPlaceMutator) - FACTORY.createInPlaceOrThrow( + factory.createInPlaceOrThrow( new TypeHolder() {}.annotatedType()); assertThat(mutator.toString()) .isEqualTo( "{Builder.Boolean, Builder.Boolean, Builder.Nullable |" + " Builder.Nullable<{Builder.Boolean} -> Message>}"); + assertThat(mutator.hasFixedSize()).isTrue(); OneOfField3.Builder builder = OneOfField3.newBuilder(); try (MockPseudoRandom prng = @@ -563,9 +574,10 @@ void testOneOfField3() { void testEmptyMessage3() { InPlaceMutator mutator = (InPlaceMutator) - FACTORY.createInPlaceOrThrow( + factory.createInPlaceOrThrow( new TypeHolder() {}.annotatedType()); assertThat(mutator.toString()).isEqualTo("{}"); + assertThat(mutator.hasFixedSize()).isTrue(); EmptyMessage3.Builder builder = EmptyMessage3.newBuilder(); try (MockPseudoRandom prng = mockPseudoRandom()) { @@ -583,7 +595,7 @@ void testEmptyMessage3() { void testAnyField3() throws InvalidProtocolBufferException { InPlaceMutator mutator = (InPlaceMutator) - FACTORY.createInPlaceOrThrow( + factory.createInPlaceOrThrow( new TypeHolder< @NotNull @AnySource({PrimitiveField3.class, MessageField3.class}) Builder>() {}.annotatedType()); @@ -591,6 +603,7 @@ void testAnyField3() throws InvalidProtocolBufferException { .isEqualTo( "{Builder.Nullable Message |" + " Builder.{Builder.Nullable<(cycle) -> Message>} -> Message -> Message>}"); + assertThat(mutator.hasFixedSize()).isTrue(); AnyField3.Builder builder = AnyField3.newBuilder(); try (MockPseudoRandom prng = @@ -648,7 +661,7 @@ void testAnyField3() throws InvalidProtocolBufferException { void testAnyField3WithoutAnySourceDoesNotCrash() throws InvalidProtocolBufferException { InPlaceMutator mutator = (InPlaceMutator) - FACTORY.createInPlaceOrThrow(new TypeHolder<@NotNull Builder>() {}.annotatedType()); + factory.createInPlaceOrThrow(new TypeHolder<@NotNull Builder>() {}.annotatedType()); assertThat(mutator.toString()) .isEqualTo("{Builder.Nullable<{Builder.String, Builder.byte[] -> ByteString} -> Message>}"); } diff --git a/src/test/java/com/code_intelligence/jazzer/mutation/mutator/proto/MessageMutatorTest.java b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/proto/MessageMutatorTest.java index a8111cb4e..dd304257f 100644 --- a/src/test/java/com/code_intelligence/jazzer/mutation/mutator/proto/MessageMutatorTest.java +++ b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/proto/MessageMutatorTest.java @@ -1,28 +1,21 @@ /* - * Copyright 2023 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.code_intelligence.jazzer.mutation.mutator.proto; +import static com.code_intelligence.jazzer.mutation.support.TestSupport.createOrThrow; import static com.code_intelligence.jazzer.mutation.support.TestSupport.mockPseudoRandom; import static com.google.common.truth.Truth.assertThat; import com.code_intelligence.jazzer.mutation.annotation.NotNull; -import com.code_intelligence.jazzer.mutation.api.ChainedMutatorFactory; -import com.code_intelligence.jazzer.mutation.api.MutatorFactory; import com.code_intelligence.jazzer.mutation.api.SerializingMutator; +import com.code_intelligence.jazzer.mutation.engine.ChainedMutatorFactory; import com.code_intelligence.jazzer.mutation.mutator.collection.CollectionMutators; import com.code_intelligence.jazzer.mutation.mutator.lang.LangMutators; import com.code_intelligence.jazzer.mutation.support.TestSupport.MockPseudoRandom; @@ -35,16 +28,25 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; class MessageMutatorTest { - private static final MutatorFactory FACTORY = - new ChainedMutatorFactory( - LangMutators.newFactory(), CollectionMutators.newFactory(), ProtoMutators.newFactory()); + ChainedMutatorFactory factory; + + @BeforeEach + void createFactory() { + factory = + ChainedMutatorFactory.of( + LangMutators.newFactories(), + CollectionMutators.newFactories(), + ProtoMutators.newFactories()); + } @Test void testSimpleMessage() { - SerializingMutator mutator = FACTORY.createOrThrow(PrimitiveField3.class); + SerializingMutator mutator = + createOrThrow(factory, new TypeHolder() {}); PrimitiveField3 msg; @@ -81,7 +83,7 @@ void testIncompleteMessageWithRequiredFields() throws IOException { SerializingMutator mutator = (SerializingMutator) - FACTORY.createOrThrow(new TypeHolder<@NotNull ExtendedMessage2>() {}.annotatedType()); + factory.createOrThrow(new TypeHolder<@NotNull ExtendedMessage2>() {}.annotatedType()); ExtendedMessage2 extendedMessage = mutator.readExclusive(new ByteArrayInputStream(bytes)); assertThat(extendedMessage) .isEqualTo( diff --git a/src/test/java/com/code_intelligence/jazzer/mutation/mutator/proto/proto2.proto b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/proto/proto2.proto index ea7c99995..73c488d71 100644 --- a/src/test/java/com/code_intelligence/jazzer/mutation/mutator/proto/proto2.proto +++ b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/proto/proto2.proto @@ -1,16 +1,11 @@ -// Copyright 2023 Code Intelligence GmbH // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// Copyright 2024 Code Intelligence GmbH // -// http://www.apache.org/licenses/LICENSE-2.0 +// By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. +// +// The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt +// located in the root directory of the project. // -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. syntax = "proto2"; diff --git a/src/test/java/com/code_intelligence/jazzer/mutation/mutator/proto/proto3.proto b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/proto/proto3.proto index 7bd6ffeb6..b0b4872bb 100644 --- a/src/test/java/com/code_intelligence/jazzer/mutation/mutator/proto/proto3.proto +++ b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/proto/proto3.proto @@ -1,16 +1,11 @@ -// Copyright 2023 Code Intelligence GmbH // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// Copyright 2024 Code Intelligence GmbH // -// http://www.apache.org/licenses/LICENSE-2.0 +// By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. +// +// The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt +// located in the root directory of the project. // -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. syntax = "proto3"; diff --git a/src/test/java/com/code_intelligence/jazzer/mutation/mutator/time/BUILD.bazel b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/time/BUILD.bazel new file mode 100644 index 000000000..a84d482a7 --- /dev/null +++ b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/time/BUILD.bazel @@ -0,0 +1,20 @@ +load("@contrib_rules_jvm//java:defs.bzl", "java_test_suite") + +java_test_suite( + name = "TimeTests", + size = "small", + srcs = glob(["*.java"]), + env = {"JAZZER_MOCK_LIBFUZZER_MUTATOR": "true"}, + runner = "junit5", + deps = [ + "//src/main/java/com/code_intelligence/jazzer/mutation/annotation", + "//src/main/java/com/code_intelligence/jazzer/mutation/api", + "//src/main/java/com/code_intelligence/jazzer/mutation/engine", + "//src/main/java/com/code_intelligence/jazzer/mutation/mutator/lang", + "//src/main/java/com/code_intelligence/jazzer/mutation/mutator/libfuzzer:libfuzzermutate", + "//src/main/java/com/code_intelligence/jazzer/mutation/mutator/time", + "//src/main/java/com/code_intelligence/jazzer/mutation/support", + "//src/test/java/com/code_intelligence/jazzer/mutation/support:test_support", + "@protobuf//java/core", + ], +) diff --git a/src/test/java/com/code_intelligence/jazzer/mutation/mutator/time/LocalDateMutatorTest.java b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/time/LocalDateMutatorTest.java new file mode 100644 index 000000000..ff9778560 --- /dev/null +++ b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/time/LocalDateMutatorTest.java @@ -0,0 +1,56 @@ +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ + +package com.code_intelligence.jazzer.mutation.mutator.time; + +import static com.code_intelligence.jazzer.mutation.support.TestSupport.anyPseudoRandom; +import static com.google.common.truth.Truth.assertThat; + +import com.code_intelligence.jazzer.mutation.annotation.NotNull; +import com.code_intelligence.jazzer.mutation.api.PseudoRandom; +import com.code_intelligence.jazzer.mutation.api.SerializingMutator; +import com.code_intelligence.jazzer.mutation.engine.ChainedMutatorFactory; +import com.code_intelligence.jazzer.mutation.mutator.lang.LangMutators; +import com.code_intelligence.jazzer.mutation.mutator.libfuzzer.LibFuzzerMutate; +import com.code_intelligence.jazzer.mutation.support.TypeHolder; +import java.time.LocalDate; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +@SuppressWarnings("unchecked") +class LocalDateMutatorTest { + ChainedMutatorFactory factory; + + @BeforeEach + void createFactory() { + factory = ChainedMutatorFactory.of(LangMutators.newFactories(), TimeMutators.newFactories()); + } + + @AfterEach + void cleanMockSize() { + System.clearProperty(LibFuzzerMutate.MOCK_SIZE_KEY); + } + + @Test + void testLocalDateMutator() { + SerializingMutator mutator = + (SerializingMutator) + factory.createOrThrow(new TypeHolder<@NotNull LocalDate>() {}.annotatedType()); + assertThat(mutator.toString()).isEqualTo("LocalDate"); + + PseudoRandom prng = anyPseudoRandom(); + + LocalDate inited = mutator.init(prng); + assertThat(inited).isNotNull(); + + LocalDate mutated = mutator.mutate(inited, prng); + assertThat(mutated).isNotEqualTo(inited); + } +} diff --git a/src/test/java/com/code_intelligence/jazzer/mutation/mutator/time/LocalDateTimeMutatorTest.java b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/time/LocalDateTimeMutatorTest.java new file mode 100644 index 000000000..44f7e8aa5 --- /dev/null +++ b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/time/LocalDateTimeMutatorTest.java @@ -0,0 +1,56 @@ +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ + +package com.code_intelligence.jazzer.mutation.mutator.time; + +import static com.code_intelligence.jazzer.mutation.support.TestSupport.anyPseudoRandom; +import static com.google.common.truth.Truth.assertThat; + +import com.code_intelligence.jazzer.mutation.annotation.NotNull; +import com.code_intelligence.jazzer.mutation.api.PseudoRandom; +import com.code_intelligence.jazzer.mutation.api.SerializingMutator; +import com.code_intelligence.jazzer.mutation.engine.ChainedMutatorFactory; +import com.code_intelligence.jazzer.mutation.mutator.lang.LangMutators; +import com.code_intelligence.jazzer.mutation.mutator.libfuzzer.LibFuzzerMutate; +import com.code_intelligence.jazzer.mutation.support.TypeHolder; +import java.time.LocalDateTime; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +@SuppressWarnings("unchecked") +class LocalDateTimeMutatorTest { + ChainedMutatorFactory factory; + + @BeforeEach + void createFactory() { + factory = ChainedMutatorFactory.of(LangMutators.newFactories(), TimeMutators.newFactories()); + } + + @AfterEach + void cleanMockSize() { + System.clearProperty(LibFuzzerMutate.MOCK_SIZE_KEY); + } + + @Test + void testLocalDateTimeMutator() { + SerializingMutator mutator = + (SerializingMutator) + factory.createOrThrow(new TypeHolder<@NotNull LocalDateTime>() {}.annotatedType()); + assertThat(mutator.toString()).isEqualTo("LocalDateTime"); + + PseudoRandom prng = anyPseudoRandom(); + + LocalDateTime inited = mutator.init(prng); + assertThat(inited).isNotNull(); + + LocalDateTime mutated = mutator.mutate(inited, prng); + assertThat(mutated).isNotEqualTo(inited); + } +} diff --git a/src/test/java/com/code_intelligence/jazzer/mutation/mutator/time/LocalTimeMutatorTest.java b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/time/LocalTimeMutatorTest.java new file mode 100644 index 000000000..937c46ccc --- /dev/null +++ b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/time/LocalTimeMutatorTest.java @@ -0,0 +1,56 @@ +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ + +package com.code_intelligence.jazzer.mutation.mutator.time; + +import static com.code_intelligence.jazzer.mutation.support.TestSupport.anyPseudoRandom; +import static com.google.common.truth.Truth.assertThat; + +import com.code_intelligence.jazzer.mutation.annotation.NotNull; +import com.code_intelligence.jazzer.mutation.api.PseudoRandom; +import com.code_intelligence.jazzer.mutation.api.SerializingMutator; +import com.code_intelligence.jazzer.mutation.engine.ChainedMutatorFactory; +import com.code_intelligence.jazzer.mutation.mutator.lang.LangMutators; +import com.code_intelligence.jazzer.mutation.mutator.libfuzzer.LibFuzzerMutate; +import com.code_intelligence.jazzer.mutation.support.TypeHolder; +import java.time.LocalTime; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +@SuppressWarnings("unchecked") +class LocalTimeMutatorTest { + ChainedMutatorFactory factory; + + @BeforeEach + void createFactory() { + factory = ChainedMutatorFactory.of(LangMutators.newFactories(), TimeMutators.newFactories()); + } + + @AfterEach + void cleanMockSize() { + System.clearProperty(LibFuzzerMutate.MOCK_SIZE_KEY); + } + + @Test + void testLocalTimeMutator() { + SerializingMutator mutator = + (SerializingMutator) + factory.createOrThrow(new TypeHolder<@NotNull LocalTime>() {}.annotatedType()); + assertThat(mutator.toString()).isEqualTo("LocalTime"); + + PseudoRandom prng = anyPseudoRandom(); + + LocalTime inited = mutator.init(prng); + assertThat(inited).isNotNull(); + + LocalTime mutated = mutator.mutate(inited, prng); + assertThat(mutated).isNotEqualTo(inited); + } +} diff --git a/src/test/java/com/code_intelligence/jazzer/mutation/mutator/time/ZonedDateTimeMutatorTest.java b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/time/ZonedDateTimeMutatorTest.java new file mode 100644 index 000000000..0732adfdb --- /dev/null +++ b/src/test/java/com/code_intelligence/jazzer/mutation/mutator/time/ZonedDateTimeMutatorTest.java @@ -0,0 +1,56 @@ +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ + +package com.code_intelligence.jazzer.mutation.mutator.time; + +import static com.code_intelligence.jazzer.mutation.support.TestSupport.anyPseudoRandom; +import static com.google.common.truth.Truth.assertThat; + +import com.code_intelligence.jazzer.mutation.annotation.NotNull; +import com.code_intelligence.jazzer.mutation.api.PseudoRandom; +import com.code_intelligence.jazzer.mutation.api.SerializingMutator; +import com.code_intelligence.jazzer.mutation.engine.ChainedMutatorFactory; +import com.code_intelligence.jazzer.mutation.mutator.lang.LangMutators; +import com.code_intelligence.jazzer.mutation.mutator.libfuzzer.LibFuzzerMutate; +import com.code_intelligence.jazzer.mutation.support.TypeHolder; +import java.time.ZonedDateTime; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +@SuppressWarnings("unchecked") +class ZonedDateTimeMutatorTest { + ChainedMutatorFactory factory; + + @BeforeEach + void createFactory() { + factory = ChainedMutatorFactory.of(LangMutators.newFactories(), TimeMutators.newFactories()); + } + + @AfterEach + void cleanMockSize() { + System.clearProperty(LibFuzzerMutate.MOCK_SIZE_KEY); + } + + @Test + void testZonedDateTimeMutator() { + SerializingMutator mutator = + (SerializingMutator) + factory.createOrThrow(new TypeHolder<@NotNull ZonedDateTime>() {}.annotatedType()); + assertThat(mutator.toString()).isEqualTo("ZonedDateTime"); + + PseudoRandom prng = anyPseudoRandom(); + + ZonedDateTime inited = mutator.init(prng); + assertThat(inited).isNotNull(); + + ZonedDateTime mutated = mutator.mutate(inited, prng); + assertThat(mutated).isNotEqualTo(inited); + } +} diff --git a/src/test/java/com/code_intelligence/jazzer/mutation/support/AnnotationSupportTest.java b/src/test/java/com/code_intelligence/jazzer/mutation/support/AnnotationSupportTest.java new file mode 100644 index 000000000..9bae82e4f --- /dev/null +++ b/src/test/java/com/code_intelligence/jazzer/mutation/support/AnnotationSupportTest.java @@ -0,0 +1,94 @@ +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ + +package com.code_intelligence.jazzer.mutation.support; + +import static com.code_intelligence.jazzer.mutation.support.AnnotationSupport.validateAnnotationUsage; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.params.provider.Arguments.arguments; + +import com.code_intelligence.jazzer.mutation.annotation.Ascii; +import com.code_intelligence.jazzer.mutation.annotation.DoubleInRange; +import com.code_intelligence.jazzer.mutation.annotation.FloatInRange; +import com.code_intelligence.jazzer.mutation.annotation.InRange; +import com.code_intelligence.jazzer.mutation.annotation.NotNull; +import com.code_intelligence.jazzer.mutation.annotation.UrlSegment; +import com.code_intelligence.jazzer.mutation.annotation.WithLength; +import com.code_intelligence.jazzer.mutation.annotation.WithSize; +import com.code_intelligence.jazzer.mutation.annotation.WithUtf8Length; +import com.code_intelligence.jazzer.mutation.utils.PropertyConstraint; +import java.lang.reflect.AnnotatedType; +import java.util.List; +import java.util.stream.Stream; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +public class AnnotationSupportTest { + + static Stream validateAnnotationUsageCases_ok() { + return Stream.of( + arguments(new TypeHolder<@WithSize(min = 10) List>() {}.annotatedType()), + arguments(new TypeHolder<@NotNull @WithSize(min = 10) List>() {}.annotatedType()), + arguments(new TypeHolder() {}.annotatedType()), + arguments(new TypeHolder<@WithUtf8Length(min = 10) String>() {}.annotatedType()), + arguments(new TypeHolder<@UrlSegment String>() {}.annotatedType()), + arguments( + new TypeHolder< + @Ascii(constraint = PropertyConstraint.RECURSIVE) List< + String>>() {}.annotatedType())); + } + + @ParameterizedTest + @MethodSource("validateAnnotationUsageCases_ok") + void testValidateAnnotationUsage_ok(AnnotatedType type) { + validateAnnotationUsage(type); + } + + static Stream validateAnnotationUsageCases_throw() { + return Stream.of( + // sizes/lengths + arguments(new TypeHolder<@WithSize(min = -1) List>() {}.annotatedType()), + arguments(new TypeHolder<@WithSize(min = 10, max = 9) List>() {}.annotatedType()), + arguments(new TypeHolder() {}.annotatedType()), + arguments(new TypeHolder() {}.annotatedType()), + arguments(new TypeHolder<@WithUtf8Length(min = -1) String>() {}.annotatedType()), + arguments(new TypeHolder<@WithUtf8Length(min = 11, max = 0) String>() {}.annotatedType()), + // ranges + arguments(new TypeHolder<@InRange(min = -1, max = -2) Integer>() {}.annotatedType()), + arguments(new TypeHolder<@FloatInRange(min = -1f, max = -2f) Float>() {}.annotatedType()), + arguments( + new TypeHolder<@DoubleInRange(min = -1.0, max = -2.0) Double>() {}.annotatedType()), + // deep + arguments( + new TypeHolder< + @NotNull @WithSize(min = 0, max = 10) List< + List>>> + []>() {}.annotatedType()), + // violations of @AppliesTo + arguments(new TypeHolder<@WithSize(min = 10) String>() {}.annotatedType()), + arguments(new TypeHolder<@WithLength(min = 10) List>() {}.annotatedType()), + arguments(new TypeHolder<@InRange(min = 10) List>() {}.annotatedType()), + arguments(new TypeHolder() {}.annotatedType()), + arguments(new TypeHolder<@UrlSegment Integer>() {}.annotatedType()), + arguments(new TypeHolder<@UrlSegment List>() {}.annotatedType()), + // deep + arguments( + new TypeHolder< + @NotNull @WithSize(min = 0, max = 10) List< + List>>> + []>() {}.annotatedType())); + } + + @ParameterizedTest + @MethodSource("validateAnnotationUsageCases_throw") + void testValidateAnnotationUsage_throw(AnnotatedType type) { + assertThrows(IllegalArgumentException.class, () -> validateAnnotationUsage(type)); + } +} diff --git a/src/test/java/com/code_intelligence/jazzer/mutation/support/BUILD.bazel b/src/test/java/com/code_intelligence/jazzer/mutation/support/BUILD.bazel index bcde8ba9f..a87f8a391 100644 --- a/src/test/java/com/code_intelligence/jazzer/mutation/support/BUILD.bazel +++ b/src/test/java/com/code_intelligence/jazzer/mutation/support/BUILD.bazel @@ -17,7 +17,7 @@ java_library( "//src/main/java/com/code_intelligence/jazzer/mutation/api", "//src/main/java/com/code_intelligence/jazzer/mutation/engine", "//src/main/java/com/code_intelligence/jazzer/mutation/support", - "@com_google_errorprone_error_prone_annotations//jar", + "@maven//:com_google_errorprone_error_prone_annotations", "@maven//:com_google_truth_truth", ], ) @@ -31,5 +31,6 @@ java_test_suite( ":test_support", "//src/main/java/com/code_intelligence/jazzer/mutation/annotation", "//src/main/java/com/code_intelligence/jazzer/mutation/support", + "//src/main/java/com/code_intelligence/jazzer/mutation/utils", ], ) diff --git a/src/test/java/com/code_intelligence/jazzer/mutation/support/ExceptionSupportTest.java b/src/test/java/com/code_intelligence/jazzer/mutation/support/ExceptionSupportTest.java index 2a77cc68f..a02029dd2 100644 --- a/src/test/java/com/code_intelligence/jazzer/mutation/support/ExceptionSupportTest.java +++ b/src/test/java/com/code_intelligence/jazzer/mutation/support/ExceptionSupportTest.java @@ -1,17 +1,10 @@ /* - * Copyright 2023 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.code_intelligence.jazzer.mutation.support; diff --git a/src/test/java/com/code_intelligence/jazzer/mutation/support/HolderTest.java b/src/test/java/com/code_intelligence/jazzer/mutation/support/HolderTest.java index 50f087a73..e48dc9415 100644 --- a/src/test/java/com/code_intelligence/jazzer/mutation/support/HolderTest.java +++ b/src/test/java/com/code_intelligence/jazzer/mutation/support/HolderTest.java @@ -1,23 +1,17 @@ /* - * Copyright 2023 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.code_intelligence.jazzer.mutation.support; import static com.google.common.truth.Truth.assertThat; +import com.code_intelligence.jazzer.mutation.support.TestSupport.ParameterHolder; import java.lang.annotation.Annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; @@ -63,7 +57,7 @@ void testTypeHolder_annotatedType() { void testParameterHolder_rawType() { Type type = new ParameterHolder() { - void foo(List parameter) {} + void singleParam(List parameter) {} }.type(); assertThat(type).isInstanceOf(ParameterizedType.class); @@ -76,7 +70,7 @@ void foo(List parameter) {} void testParameterHolder_annotatedType() { AnnotatedType type = new ParameterHolder() { - void foo(@ParameterAnnotation @Foo List<@Bar String> parameter) {} + void singleParam(@ParameterAnnotation @Foo List<@Bar String> parameter) {} }.annotatedType(); assertThat(type).isInstanceOf(AnnotatedParameterizedType.class); @@ -97,7 +91,7 @@ void foo(@ParameterAnnotation @Foo List<@Bar String> parameter) {} void testParameterHolder_parameterAnnotations() { Annotation[] annotations = new ParameterHolder() { - void foo(@ParameterAnnotation @Foo List<@Bar String> parameter) {} + void singleParam(@ParameterAnnotation @Foo List<@Bar String> parameter) {} }.parameterAnnotations(); assertThat(annotations).hasLength(1); assertThat(annotations[0]).isInstanceOf(ParameterAnnotation.class); diff --git a/src/test/java/com/code_intelligence/jazzer/mutation/support/InputStreamSupportTest.java b/src/test/java/com/code_intelligence/jazzer/mutation/support/InputStreamSupportTest.java index 13087fbb1..f063d406b 100644 --- a/src/test/java/com/code_intelligence/jazzer/mutation/support/InputStreamSupportTest.java +++ b/src/test/java/com/code_intelligence/jazzer/mutation/support/InputStreamSupportTest.java @@ -1,17 +1,10 @@ /* - * Copyright 2023 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.code_intelligence.jazzer.mutation.support; diff --git a/src/test/java/com/code_intelligence/jazzer/mutation/support/PropertyConstraintSupportTest.java b/src/test/java/com/code_intelligence/jazzer/mutation/support/PropertyConstraintSupportTest.java new file mode 100644 index 000000000..16c012477 --- /dev/null +++ b/src/test/java/com/code_intelligence/jazzer/mutation/support/PropertyConstraintSupportTest.java @@ -0,0 +1,82 @@ +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ + +package com.code_intelligence.jazzer.mutation.support; + +import static com.code_intelligence.jazzer.mutation.support.PropertyConstraintSupport.propagatePropertyConstraints; +import static com.code_intelligence.jazzer.mutation.support.TypeSupport.parameterTypeIfParameterized; +import static com.google.common.truth.Truth.assertThat; + +import com.code_intelligence.jazzer.mutation.annotation.Ascii; +import com.code_intelligence.jazzer.mutation.annotation.NotNull; +import com.code_intelligence.jazzer.mutation.utils.PropertyConstraint; +import java.lang.reflect.AnnotatedType; +import java.util.List; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.EnabledForJreRange; +import org.junit.jupiter.api.condition.JRE; + +@SuppressWarnings("OptionalGetWithoutIsPresent") +public class PropertyConstraintSupportTest { + @Test + @EnabledForJreRange(min = JRE.JAVA_12) + void doNotPropagateDeclarationConstraint() { + AnnotatedType sourceType = new TypeHolder<@NotNull List<@Ascii String>>() {}.annotatedType(); + AnnotatedType targetType = parameterTypeIfParameterized(sourceType, List.class).get(); + + AnnotatedType propagatedType = propagatePropertyConstraints(sourceType, targetType); + + AnnotatedType expectedType = new TypeHolder<@Ascii String>() {}.annotatedType(); + assertThat(propagatedType).isEqualTo(expectedType); + } + + @Test + void propagateRecursiveConstraint() { + AnnotatedType sourceType = + new TypeHolder< + @NotNull(constraint = PropertyConstraint.RECURSIVE) List>() {}.annotatedType(); + AnnotatedType targetType = parameterTypeIfParameterized(sourceType, List.class).get(); + + AnnotatedType propagatedType = propagatePropertyConstraints(sourceType, targetType); + + AnnotatedType expectedType = + new TypeHolder< + @NotNull(constraint = PropertyConstraint.RECURSIVE) String>() {}.annotatedType(); + assertThat(propagatedType).isEqualTo(expectedType); + } + + @Test + void propagateRecursiveConstraintAndKeepExistingAnnotation() { + AnnotatedType sourceType = + new TypeHolder< + @NotNull(constraint = PropertyConstraint.RECURSIVE) List< + @Ascii String>>() {}.annotatedType(); + AnnotatedType targetType = parameterTypeIfParameterized(sourceType, List.class).get(); + + AnnotatedType propagatedType = propagatePropertyConstraints(sourceType, targetType); + + AnnotatedType expectedType = + new TypeHolder< + @Ascii @NotNull(constraint = PropertyConstraint.RECURSIVE) String>() {}.annotatedType(); + assertThat(propagatedType).isEqualTo(expectedType); + } + + @Test + void preferInnerConstraintToPropagatedOne() { + AnnotatedType sourceType = + new TypeHolder< + @NotNull(constraint = PropertyConstraint.RECURSIVE) List< + @NotNull String>>() {}.annotatedType(); + AnnotatedType targetType = parameterTypeIfParameterized(sourceType, List.class).get(); + + AnnotatedType propagatedType = propagatePropertyConstraints(sourceType, targetType); + + assertThat(propagatedType).isEqualTo(targetType); + } +} diff --git a/src/test/java/com/code_intelligence/jazzer/mutation/support/TestSupport.java b/src/test/java/com/code_intelligence/jazzer/mutation/support/TestSupport.java index 1d33b93a2..07a43c3da 100644 --- a/src/test/java/com/code_intelligence/jazzer/mutation/support/TestSupport.java +++ b/src/test/java/com/code_intelligence/jazzer/mutation/support/TestSupport.java @@ -1,27 +1,23 @@ /* - * Copyright 2023 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.code_intelligence.jazzer.mutation.support; +import static com.code_intelligence.jazzer.mutation.support.Preconditions.require; import static com.code_intelligence.jazzer.mutation.support.Preconditions.requireNonNullElements; import static com.google.common.truth.Truth.assertThat; import static java.util.Arrays.stream; import static java.util.stream.Collectors.toCollection; +import static java.util.stream.Collectors.toList; import com.code_intelligence.jazzer.mutation.api.Debuggable; +import com.code_intelligence.jazzer.mutation.api.ExtendedMutatorFactory; import com.code_intelligence.jazzer.mutation.api.InPlaceMutator; import com.code_intelligence.jazzer.mutation.api.PseudoRandom; import com.code_intelligence.jazzer.mutation.api.SerializingMutator; @@ -31,8 +27,13 @@ import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.OutputStream; +import java.lang.annotation.Annotation; +import java.lang.reflect.AnnotatedType; +import java.lang.reflect.Method; +import java.lang.reflect.Type; import java.util.ArrayDeque; import java.util.ArrayList; +import java.util.Arrays; import java.util.LinkedHashMap; import java.util.List; import java.util.Queue; @@ -250,6 +251,10 @@ private MockPseudoRandom(Object... objects) { this.elements = stream(objects).collect(toCollection(ArrayDeque::new)); } + public String toString() { + return "PRNG: " + Arrays.toString(elements.toArray()); + } + @Override public boolean choice() { assertThat(elements).isNotEmpty(); @@ -282,18 +287,12 @@ public T pickIn(List list) { @Override public int indexIn(T[] array) { - assertThat(array).isNotEmpty(); - - assertThat(elements).isNotEmpty(); - return (int) elements.poll(); + return indexIn(array.length); } @Override public int indexIn(List list) { - assertThat(list).isNotEmpty(); - - assertThat(elements).isNotEmpty(); - return (int) elements.poll(); + return indexIn(list.size()); } @Override @@ -301,7 +300,10 @@ public int indexIn(int range) { assertThat(range).isAtLeast(1); assertThat(elements).isNotEmpty(); - return (int) elements.poll(); + int result = (int) elements.poll(); + assertThat(result).isAtLeast(0); + assertThat(result).isLessThan(range); + return result; } @Override @@ -423,4 +425,49 @@ public static LinkedHashMap asMap(Object... objs) { public static ArrayList asMutableList(T... objs) { return stream(objs).collect(toCollection(ArrayList::new)); } + + /** + * A factory for {@link AnnotatedType} instances capturing method parameters. + * + *

Due to type erasure, this class can only be used by creating an anonymous subclass with a + * method called {@code singleParam} that takes exactly the desired parameter. + * + *

Example: {@code new ParameterHolder {void singleParam(@NotNull List param)} + * .annotatedType} + */ + public abstract static class ParameterHolder { + protected ParameterHolder() {} + + public AnnotatedType annotatedType() { + return getMethod().getAnnotatedParameterTypes()[0]; + } + + public Type type() { + return annotatedType().getType(); + } + + public Annotation[] parameterAnnotations() { + return getMethod().getParameterAnnotations()[0]; + } + + private Method getMethod() { + List methods = + stream(this.getClass().getDeclaredMethods()) + .filter(method -> method.getName().equals("singleParam")) + .collect(toList()); + require( + methods.size() == 1, + this.getClass().getName() + " must define exactly one function named 'singleParam'"); + Method foo = methods.get(0); + require( + foo.getParameterCount() == 1, + this.getClass().getName() + "#singleParam must define exactly one parameter"); + return foo; + } + } + + public static SerializingMutator createOrThrow( + ExtendedMutatorFactory factory, TypeHolder typeHolder) { + return (SerializingMutator) factory.createOrThrow(typeHolder.annotatedType()); + } } diff --git a/src/test/java/com/code_intelligence/jazzer/mutation/support/TypeSupportTest.java b/src/test/java/com/code_intelligence/jazzer/mutation/support/TypeSupportTest.java index 4f17ed4d5..8f7da5afb 100644 --- a/src/test/java/com/code_intelligence/jazzer/mutation/support/TypeSupportTest.java +++ b/src/test/java/com/code_intelligence/jazzer/mutation/support/TypeSupportTest.java @@ -1,32 +1,34 @@ /* - * Copyright 2023 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.code_intelligence.jazzer.mutation.support; -import static com.code_intelligence.jazzer.mutation.support.TypeSupport.asAnnotatedType; +import static com.code_intelligence.jazzer.mutation.support.TypeSupport.annotatedTypeEquals; import static com.code_intelligence.jazzer.mutation.support.TypeSupport.asSubclassOrEmpty; import static com.code_intelligence.jazzer.mutation.support.TypeSupport.containedInDirectedCycle; +import static com.code_intelligence.jazzer.mutation.support.TypeSupport.forwardAnnotations; import static com.code_intelligence.jazzer.mutation.support.TypeSupport.visitAnnotatedType; +import static com.code_intelligence.jazzer.mutation.support.TypeSupport.withExtraAnnotations; import static com.code_intelligence.jazzer.mutation.support.TypeSupport.withTypeArguments; import static com.google.common.truth.Truth.assertThat; -import static com.google.common.truth.Truth8.assertThat; import static java.util.Arrays.stream; import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.params.provider.Arguments.arguments; +import com.code_intelligence.jazzer.mutation.annotation.DoubleInRange; +import com.code_intelligence.jazzer.mutation.annotation.FloatInRange; +import com.code_intelligence.jazzer.mutation.annotation.InRange; import com.code_intelligence.jazzer.mutation.annotation.NotNull; +import com.code_intelligence.jazzer.mutation.annotation.WithLength; +import com.code_intelligence.jazzer.mutation.annotation.WithSize; +import com.code_intelligence.jazzer.mutation.annotation.WithUtf8Length; +import java.lang.annotation.Annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -37,11 +39,16 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.Objects; +import java.util.function.BiPredicate; import java.util.function.Function; import java.util.stream.Stream; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.EnabledForJreRange; import org.junit.jupiter.api.condition.JRE; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; class TypeSupportTest { @Test @@ -212,17 +219,19 @@ void testFillTypeVariables_failures() { IllegalArgumentException.class, () -> withTypeArguments( - new TypeHolder>() {}.annotatedType(), asAnnotatedType(String.class))); + new TypeHolder>() {}.annotatedType(), + new TypeHolder() {}.annotatedType())); } @Test void testAsSubclassOrEmpty() { - assertThat(asSubclassOrEmpty(asAnnotatedType(String.class), String.class)) + assertThat(asSubclassOrEmpty(new TypeHolder() {}.annotatedType(), String.class)) .hasValue(String.class); - assertThat(asSubclassOrEmpty(asAnnotatedType(String.class), CharSequence.class)) + assertThat(asSubclassOrEmpty(new TypeHolder() {}.annotatedType(), CharSequence.class)) .hasValue(String.class); - assertThat(asSubclassOrEmpty(asAnnotatedType(CharSequence.class), String.class)).isEmpty(); assertThat(asSubclassOrEmpty(new TypeHolder>() {}.annotatedType(), List.class)) + .hasValue(List.class); + assertThat(asSubclassOrEmpty(new TypeHolder() {}.annotatedType(), String.class)) .isEmpty(); } @@ -295,4 +304,206 @@ void testContainedInDirectedCycle() { assertThat(containedInDirectedCycle(4, successors)).isTrue(); assertThat(containedInDirectedCycle(5, successors)).isFalse(); } + + void doTestWithExtraAnnotationsWithCustomEquality( + BiPredicate equality) { + Annotation NOT_NULL = + new TypeHolder<@NotNull String>() {}.annotatedType().getAnnotation(NotNull.class); + Annotation WITH_SIZE = + new TypeHolder<@WithSize(min = 42) String>() {}.annotatedType() + .getAnnotation(WithSize.class); + assertThat( + equality.test( + withExtraAnnotations(new TypeHolder() {}.annotatedType(), NOT_NULL), + new TypeHolder<@NotNull Boolean>() {}.annotatedType())) + .isTrue(); + assertThat( + equality.test( + withExtraAnnotations(new TypeHolder() {}.annotatedType()), + new TypeHolder<@NotNull Boolean>() {}.annotatedType())) + .isFalse(); + assertThat( + equality.test( + withExtraAnnotations( + new TypeHolder<@NotNull Map>() {}.annotatedType(), + WITH_SIZE), + new TypeHolder< + @NotNull @WithSize(min = 42) Map< + String, @NotNull String>>() {}.annotatedType())) + .isTrue(); + assertThat( + equality.test( + withExtraAnnotations( + new TypeHolder>() {}.annotatedType(), + NOT_NULL, + WITH_SIZE), + new TypeHolder< + @NotNull @WithSize(min = 42) Map< + String, @NotNull String>>() {}.annotatedType())) + .isTrue(); + assertThat( + equality.test( + withExtraAnnotations( + new TypeHolder<@NotNull Map>() {}.annotatedType(), + WITH_SIZE), + new TypeHolder< + @WithSize(min = 42) @NotNull Map< + String, @NotNull String>>() {}.annotatedType())) + .isFalse(); + assertThat( + equality.test( + withExtraAnnotations( + new TypeHolder>() {}.annotatedType(), NOT_NULL), + new TypeHolder<@NotNull Map>() {}.annotatedType())) + .isFalse(); + assertThat( + equality.test( + withExtraAnnotations( + new TypeHolder<@NotNull Byte[]>() {}.annotatedType(), NOT_NULL), + new TypeHolder<@NotNull Byte @NotNull []>() {}.annotatedType())) + .isTrue(); + assertThat( + equality.test( + withExtraAnnotations( + new TypeHolder<@NotNull Byte[]>() {}.annotatedType(), NOT_NULL), + new TypeHolder<@NotNull Byte @NotNull []>() {}.annotatedType())) + .isTrue(); + } + + @Test + void testWithExtraAnnotationsWithBackportedEquality() { + doTestWithExtraAnnotationsWithCustomEquality(TypeSupport::annotatedTypeEquals); + } + + @Test + void testWithExtraAnnotationsWithBackportedEquality_flipped() { + doTestWithExtraAnnotationsWithCustomEquality((a, b) -> annotatedTypeEquals(b, a)); + } + + // The tests below verify that the equals implementation of the AnnotatedType implementations + // shipped with Java 12+ are compatible with our annotatedTypeEquals. While we do not use equals + // in our code, this is additional assurance that our custom implementation is correct and also + // allows us to migrate to the standard equals in the (far) future. + + // Java <= 11 does not implement AnnotatedType#equals. + // https://github.com/openjdk/jdk/commit/ab0128ca51de59aaaa674654ca8d4e16b3b79965 + @Test + @EnabledForJreRange(min = JRE.JAVA_12) + void testWithExtraAnnotationsWithEquals() { + doTestWithExtraAnnotationsWithCustomEquality(Objects::equals); + } + + // Java <= 11 does not implement AnnotatedType#equals. + // https://github.com/openjdk/jdk/commit/ab0128ca51de59aaaa674654ca8d4e16b3b79965 + @Test + @EnabledForJreRange(min = JRE.JAVA_12) + void testWithExtraAnnotationsWithEquals_flipped() { + doTestWithExtraAnnotationsWithCustomEquality((a, b) -> Objects.equals(b, a)); + } + + // isEqualTo is not invariant to the order of annotations--sometimes the annotations should be + // arranged in a specific order. + static Stream forwardAnnotationCases() { + return Stream.of( + arguments( + new TypeHolder< + @NotNull List<@WithLength(min = 10, max = 20) String>>() {}.annotatedType(), + new TypeHolder() {}.annotatedType(), + new TypeHolder() {}.annotatedType()), + arguments( + new TypeHolder<@NotNull @WithSize(min = 0, max = 1) List>() {}.annotatedType(), + new TypeHolder<@WithSize(min = 200, max = 300) List>() {}.annotatedType(), + new TypeHolder< + @WithSize(min = 200, max = 300) @NotNull List>() {}.annotatedType()), + arguments( + new TypeHolder() {}.annotatedType(), + new TypeHolder() {}.annotatedType(), + new TypeHolder< + byte @NotNull @WithLength(min = 100, max = 200) []>() {}.annotatedType()), + arguments( + new TypeHolder<@DoubleInRange(min = 10.0, max = 20.0) Integer>() {}.annotatedType(), + new TypeHolder<@NotNull Double>() {}.annotatedType(), + new TypeHolder< + @NotNull @DoubleInRange(min = 10.0, max = 20.0) Double>() {}.annotatedType()), + arguments( + new TypeHolder<@FloatInRange(min = 10.0f, max = 20.0f) Integer>() {}.annotatedType(), + new TypeHolder<@NotNull Float>() {}.annotatedType(), + new TypeHolder< + @NotNull @FloatInRange(min = 10.0f, max = 20.0f) Float>() {}.annotatedType()), + arguments( + new TypeHolder<@NotNull @WithUtf8Length(min = 10) String>() {}.annotatedType(), + new TypeHolder() {}.annotatedType(), + new TypeHolder<@NotNull @WithUtf8Length(min = 10) String>() {}.annotatedType()), + arguments( + new TypeHolder<@NotNull @InRange(min = 10) Integer>() {}.annotatedType(), + new TypeHolder<@InRange(min = 20) Integer>() {}.annotatedType(), + new TypeHolder<@InRange(min = 20) @NotNull Integer>() {}.annotatedType())); + } + + @ParameterizedTest + @EnabledForJreRange(min = JRE.JAVA_12) + @MethodSource("forwardAnnotationCases") + void testForwardAnnotations(AnnotatedType type1, AnnotatedType type2, AnnotatedType expected) { + assertThat(forwardAnnotations(type1, type2)).isEqualTo(expected); + } + + static Stream forwardAnnotationExceptionCases() { + return Stream.of( + arguments( + new TypeHolder<@WithLength(min = 10) List>() {}.annotatedType(), + new TypeHolder<@NotNull Double>() {}.annotatedType()), + arguments( + new TypeHolder<@NotNull @WithSize(min = 10) List>() {}.annotatedType(), + new TypeHolder() {}.annotatedType()), + arguments( + new TypeHolder() {}.annotatedType(), + new TypeHolder>() {}.annotatedType()), + arguments( + new TypeHolder<@WithUtf8Length(min = 10) String>() {}.annotatedType(), + new TypeHolder>() {}.annotatedType())); + } + + @ParameterizedTest + @EnabledForJreRange(min = JRE.JAVA_12) + @MethodSource("forwardAnnotationExceptionCases") + void testForwardAnnotations_violateAppliesTo(AnnotatedType type1, AnnotatedType type2) { + assertThrows(IllegalArgumentException.class, () -> forwardAnnotations(type1, type2)); + } + + // Some annotations would be invalid if used in Jazzer, however in these tests {@code src} is not + // validated, only {@code target} is. + static Stream forwardAnnotationCases_withExcludes() { + return Stream.of( + arguments( + new TypeHolder< + @NotNull List<@WithLength(min = 10, max = 20) String>>() {}.annotatedType(), + new TypeHolder() {}.annotatedType(), + // exclude @NotNull + new TypeHolder<@NotNull String>() {}.annotatedType().getAnnotations(), + new TypeHolder() {}.annotatedType()), + arguments( + new TypeHolder< + @NotNull @WithSize(min = 10, max = 100) @WithLength(min = 1, max = 2) + @WithUtf8Length(min = 1, max = 2) @InRange(min = 10, max = 20) + @FloatInRange(min = 1f, max = 2f) @DoubleInRange(min = 1.0, max = 2.0) + Integer>() {}.annotatedType(), + new TypeHolder() {}.annotatedType(), + // exclude @WithSize, @WithLength, @WithUtf8Length, @InRange, @FloatInRange, + // @DoubleInRange + new TypeHolder< + @FloatInRange @WithSize @WithUtf8Length @InRange @DoubleInRange + String>() {}.annotatedType().getAnnotations(), + // @WithLength was already present, so it should stay unchanged. @NotNull should be + // added. + new TypeHolder< + String @WithLength(min = 200, max = 201) @NotNull []>() {}.annotatedType())); + } + + @ParameterizedTest + @EnabledForJreRange(min = JRE.JAVA_12) + @MethodSource("forwardAnnotationCases_withExcludes") + void testForwardAnnotations_withExcludes( + AnnotatedType src, AnnotatedType target, Annotation[] excludes, AnnotatedType expected) { + assertThat(forwardAnnotations(src, target, excludes)).isEqualTo(expected); + } } diff --git a/src/test/java/com/code_intelligence/jazzer/mutation/support/WeakIdentityHashMapTest.java b/src/test/java/com/code_intelligence/jazzer/mutation/support/WeakIdentityHashMapTest.java index 5406ef889..783946b90 100644 --- a/src/test/java/com/code_intelligence/jazzer/mutation/support/WeakIdentityHashMapTest.java +++ b/src/test/java/com/code_intelligence/jazzer/mutation/support/WeakIdentityHashMapTest.java @@ -1,17 +1,10 @@ /* - * Copyright 2023 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.code_intelligence.jazzer.mutation.support; diff --git a/src/test/java/com/code_intelligence/jazzer/runtime/TraceCmpHooksTest.java b/src/test/java/com/code_intelligence/jazzer/runtime/TraceCmpHooksTest.java index ed63453d7..24e465bb1 100644 --- a/src/test/java/com/code_intelligence/jazzer/runtime/TraceCmpHooksTest.java +++ b/src/test/java/com/code_intelligence/jazzer/runtime/TraceCmpHooksTest.java @@ -1,17 +1,10 @@ /* - * Copyright 2022 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.code_intelligence.jazzer.runtime; diff --git a/src/test/java/com/code_intelligence/jazzer/utils/BUILD.bazel b/src/test/java/com/code_intelligence/jazzer/utils/BUILD.bazel new file mode 100644 index 000000000..e78fcef17 --- /dev/null +++ b/src/test/java/com/code_intelligence/jazzer/utils/BUILD.bazel @@ -0,0 +1,10 @@ +load("//bazel:compat.bzl", "SKIP_ON_WINDOWS") + +java_library( + name = "test_utils", + srcs = ["CapturedOutput.java"], + visibility = ["//visibility:public"], + deps = [ + "//src/main/java/com/code_intelligence/jazzer/utils:log", + ], +) diff --git a/src/test/java/com/code_intelligence/jazzer/utils/CapturedOutput.java b/src/test/java/com/code_intelligence/jazzer/utils/CapturedOutput.java new file mode 100644 index 000000000..647bf97c4 --- /dev/null +++ b/src/test/java/com/code_intelligence/jazzer/utils/CapturedOutput.java @@ -0,0 +1,41 @@ +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ + +package com.code_intelligence.jazzer.utils; + +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; + +public final class CapturedOutput { + + public static Output withCapturedOutput(SideEffect sideeffect) { + ByteArrayOutputStream outs = new ByteArrayOutputStream(); + ByteArrayOutputStream errs = new ByteArrayOutputStream(); + Log.fixOutErr(new PrintStream(outs), new PrintStream(errs)); + sideeffect.call(); + return new Output(outs.toString(), errs.toString()); + } + + public static class Output { + public final String out; + public final String err; + + Output(String out, String err) { + this.out = out; + this.err = err; + } + } + + @FunctionalInterface + public interface SideEffect { + void call(); + } + + private CapturedOutput() {} +} diff --git a/tests/BUILD.bazel b/tests/BUILD.bazel index 007566721..5aeccbb13 100644 --- a/tests/BUILD.bazel +++ b/tests/BUILD.bazel @@ -1,5 +1,5 @@ -load("@fmeum_rules_jni//jni:defs.bzl", "java_jni_library") -load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library") +load("@rules_jni//jni:defs.bzl", "java_jni_library") +load("@rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library") load("//bazel:compat.bzl", "LINUX_ONLY", "SKIP_ON_MACOS", "SKIP_ON_WINDOWS") load("//bazel:fuzz_target.bzl", "java_fuzz_target_test") load("//bazel:kotlin.bzl", "ktlint") @@ -333,6 +333,64 @@ java_fuzz_target_test( deps = ["@maven//:org_junit_jupiter_junit_jupiter_api"], ) +java_fuzz_target_test( + name = "JUnitSsrfFindingFuzzer", + timeout = "short", + srcs = ["src/test/java/com/example/JUnitSsrfFindingFuzzer.java"], + allowed_findings = [ + "com.code_intelligence.jazzer.api.FuzzerSecurityIssueMedium", + ], + fuzzer_args = [ + "-runs=1", + ], + target_class = "com.example.JUnitSsrfFindingFuzzer", + verify_crash_reproducer = False, + runtime_deps = [ + "@maven//:org_junit_jupiter_junit_jupiter_engine", + ], + deps = [ + "//deploy:jazzer-junit", + "@maven//:org_junit_jupiter_junit_jupiter_api", + "@maven//:org_junit_jupiter_junit_jupiter_params", + ], +) + +java_fuzz_target_test( + name = "JUnitSsrfAllowListFuzzer", + timeout = "short", + srcs = ["src/test/java/com/example/JUnitSsrfAllowListFuzzer.java"], + fuzzer_args = [ + "-runs=1", + ], + target_class = "com.example.JUnitSsrfAllowListFuzzer", + runtime_deps = [ + "@maven//:org_junit_jupiter_junit_jupiter_engine", + ], + deps = [ + "//deploy:jazzer-junit", + "@maven//:org_junit_jupiter_junit_jupiter_api", + "@maven//:org_junit_jupiter_junit_jupiter_params", + ], +) + +java_fuzz_target_test( + name = "JUnitSsrfAllowConnectionsBeforeFuzzingFuzzer", + timeout = "short", + srcs = ["src/test/java/com/example/JUnitSsrfAllowConnectionsBeforeFuzzingFuzzer.java"], + fuzzer_args = [ + "-runs=1", + ], + target_class = "com.example.JUnitSsrfAllowConnectionsBeforeFuzzingFuzzer", + runtime_deps = [ + "@maven//:org_junit_jupiter_junit_jupiter_engine", + ], + deps = [ + "//deploy:jazzer-junit", + "@maven//:org_junit_jupiter_junit_jupiter_api", + "@maven//:org_junit_jupiter_junit_jupiter_params", + ], +) + java_library( name = "autofuzz_ignore_target", srcs = ["src/test/java/com/example/AutofuzzIgnoreTarget.java"], @@ -344,7 +402,7 @@ java_fuzz_target_test( fuzzer_args = [ "--autofuzz=com.example.AutofuzzIgnoreTarget::doStuff", "--autofuzz_ignore=java.lang.NullPointerException", - "--ignore=bdde2af8735993f3,0123456789ABCDEF", + "--ignore=5e595e58d76956b7,0123456789ABCDEF", ], runtime_deps = [ ":autofuzz_ignore_target", @@ -415,6 +473,42 @@ java_fuzz_target_test( verify_crash_reproducer = False, ) +java_fuzz_target_test( + name = "TimeoutFuzzingModeTest", + srcs = ["src/test/java/com/example/TimeoutTest.java"], + allowed_findings = ["timeout"], + target_class = "com.example.TimeoutTest", + verify_crash_reproducer = False, + runtime_deps = [ + "@maven//:org_junit_jupiter_junit_jupiter_engine", + ], + deps = [ + "//deploy:jazzer-junit", + "@maven//:org_junit_jupiter_junit_jupiter_api", + "@maven//:org_junit_jupiter_junit_jupiter_params", + ], +) + +java_fuzz_target_test( + name = "TimeoutRegressionModeTest", + srcs = ["src/test/java/com/example/TimeoutTest.java"], + env = { + "JAZZER_FUZZ": "0", + }, + expect_crash = False, + expect_non_crash_exit_code = 1, + expected_warning_or_error = "ERROR: java.util.concurrent.TimeoutException", + target_class = "com.example.TimeoutTest", + runtime_deps = [ + "@maven//:org_junit_jupiter_junit_jupiter_engine", + ], + deps = [ + "//deploy:jazzer-junit", + "@maven//:org_junit_jupiter_junit_jupiter_api", + "@maven//:org_junit_jupiter_junit_jupiter_params", + ], +) + java_library( name = "autofuzz_crashing_setter_target", srcs = ["src/test/java/com/example/AutofuzzCrashingSetterTarget.java"], @@ -500,11 +594,10 @@ java_fuzz_target_test( # TODO: Move to //examples eventually. java_fuzz_target_test( - name = "ExperimentalMutatorFuzzer", - srcs = ["src/test/java/com/example/ExperimentalMutatorFuzzer.java"], + name = "MutatorFuzzer", + srcs = ["src/test/java/com/example/MutatorFuzzer.java"], allowed_findings = ["com.code_intelligence.jazzer.api.FuzzerSecurityIssueMedium"], fuzzer_args = [ - "--experimental_mutator", "--instrumentation_includes=com.example.**", "--custom_hook_includes=com.example.**", # TODO: Investigate whether we can automatically exclude protos. @@ -513,7 +606,7 @@ java_fuzz_target_test( # Limit runs to catch regressions in mutator efficiency and speed up test runs. "-runs=40000", ], - target_class = "com.example.ExperimentalMutatorFuzzer", + target_class = "com.example.MutatorFuzzer", verify_crash_reproducer = False, deps = [ "//src/main/java/com/code_intelligence/jazzer/mutation/annotation", @@ -522,17 +615,18 @@ java_fuzz_target_test( ) java_fuzz_target_test( - name = "ExperimentalMutatorComplexProtoFuzzer", - srcs = ["src/test/java/com/example/ExperimentalMutatorComplexProtoFuzzer.java"], + name = "MutatorComplexProtoFuzzer", + srcs = ["src/test/java/com/example/MutatorComplexProtoFuzzer.java"], allowed_findings = ["com.code_intelligence.jazzer.api.FuzzerSecurityIssueMedium"], fuzzer_args = [ - "--experimental_mutator", "--instrumentation_includes=com.example.**", "--custom_hook_includes=com.example.**", # Limit runs to catch regressions in mutator efficiency and speed up test runs. - "-runs=1500000", + # Especially on Windows this test needs way more iterations than on other platforms. + "-runs=3000000", + "-seed=123", ], - target_class = "com.example.ExperimentalMutatorComplexProtoFuzzer", + target_class = "com.example.MutatorComplexProtoFuzzer", verify_crash_reproducer = False, deps = [ "//src/main/java/com/code_intelligence/jazzer/mutation/annotation", @@ -555,11 +649,10 @@ cc_binary( ) java_fuzz_target_test( - name = "ExperimentalMutatorDynamicProtoFuzzer", - srcs = ["src/test/java/com/example/ExperimentalMutatorDynamicProtoFuzzer.java"], + name = "MutatorDynamicProtoFuzzer", + srcs = ["src/test/java/com/example/MutatorDynamicProtoFuzzer.java"], allowed_findings = ["com.code_intelligence.jazzer.api.FuzzerSecurityIssueMedium"], fuzzer_args = [ - "--experimental_mutator", "--instrumentation_includes=com.example.**", "--custom_hook_includes=com.example.**", ] + select({ @@ -569,12 +662,12 @@ java_fuzz_target_test( # significantly worse than Linux. "//conditions:default": ["-runs=1200000"], }), - target_class = "com.example.ExperimentalMutatorDynamicProtoFuzzer", + target_class = "com.example.MutatorDynamicProtoFuzzer", verify_crash_reproducer = False, deps = [ "//src/main/java/com/code_intelligence/jazzer/mutation/annotation", "//src/main/java/com/code_intelligence/jazzer/mutation/annotation/proto", - "@com_google_protobuf//java/core", + "@protobuf//java/core", ], ) @@ -583,7 +676,6 @@ java_fuzz_target_test( srcs = ["src/test/java/com/example/MapFuzzer.java"], allowed_findings = ["com.code_intelligence.jazzer.api.FuzzerSecurityIssueMedium"], fuzzer_args = [ - "--experimental_mutator", "-use_value_profile=1", ], target_class = "com.example.MapFuzzer", @@ -628,4 +720,419 @@ java_fuzz_target_test( ], ) +java_fuzz_target_test( + name = "StringCompareFuzzer", + srcs = ["src/test/java/com/example/StringCompareFuzzer.java"], + allowed_findings = ["com.code_intelligence.jazzer.api.FuzzerSecurityIssueLow"], + fuzzer_args = [ + "-use_value_profile=1", + ], + target_class = "com.example.StringCompareFuzzer", +) + +kt_jvm_library( + name = "kotlin_string_compare_fuzzer", + srcs = ["src/test/java/com/example/KotlinStringCompareFuzzer.kt"], +) + +java_fuzz_target_test( + name = "KotlinStringCompareFuzzer", + allowed_findings = ["java.io.IOException"], + fuzzer_args = [ + "-use_value_profile=1", + ], + target_class = "com.example.KotlinStringCompareFuzzer", + runtime_deps = [":kotlin_string_compare_fuzzer"], +) + +java_fuzz_target_test( + name = "ObjectEqualsStringFuzzer", + timeout = "short", + srcs = ["src/test/java/com/example/ObjectEqualsStringFuzzer.java"], + allowed_findings = [ + "com.code_intelligence.jazzer.api.FuzzerSecurityIssueLow", + ], + target_class = "com.example.ObjectEqualsStringFuzzer", + verify_crash_reproducer = False, + runtime_deps = [ + "@maven//:org_junit_jupiter_junit_jupiter_engine", + ], + deps = [ + "//deploy:jazzer-junit", + "@maven//:org_junit_jupiter_junit_jupiter_api", + "@maven//:org_junit_jupiter_junit_jupiter_params", + ], +) + +java_fuzz_target_test( + name = "ObjectEqualsIntegerFuzzer", + timeout = "short", + srcs = ["src/test/java/com/example/ObjectEqualsIntegerFuzzer.java"], + allowed_findings = [ + "com.code_intelligence.jazzer.api.FuzzerSecurityIssueLow", + ], + target_class = "com.example.ObjectEqualsIntegerFuzzer", + verify_crash_reproducer = False, + runtime_deps = [ + "@maven//:org_junit_jupiter_junit_jupiter_engine", + ], + deps = [ + "//deploy:jazzer-junit", + "@maven//:org_junit_jupiter_junit_jupiter_api", + "@maven//:org_junit_jupiter_junit_jupiter_params", + ], +) + +java_fuzz_target_test( + name = "LocalDateTimeFuzzer", + timeout = "short", + srcs = ["src/test/java/com/example/LocalDateTimeFuzzer.java"], + allowed_findings = [ + "com.code_intelligence.jazzer.api.FuzzerSecurityIssueLow", + ], + target_class = "com.example.LocalDateTimeFuzzer", + verify_crash_reproducer = False, + runtime_deps = [ + "@maven//:org_junit_jupiter_junit_jupiter_engine", + ], + deps = [ + "//deploy:jazzer-junit", + "@maven//:org_junit_jupiter_junit_jupiter_api", + "@maven//:org_junit_jupiter_junit_jupiter_params", + ], +) + +java_fuzz_target_test( + name = "RegressionModeTest", + timeout = "short", + srcs = ["src/test/java/com/example/RegressionModeTest.java"], + env = { + "JAZZER_FUZZ": "0", + }, + target_class = "com.example.RegressionModeTest", + runtime_deps = [ + "@maven//:org_junit_jupiter_junit_jupiter_engine", + ], + deps = [ + "//deploy:jazzer-junit", + "@maven//:org_junit_jupiter_junit_jupiter_api", + "@maven//:org_junit_jupiter_junit_jupiter_params", + ], +) + +java_fuzz_target_test( + name = "SwitchOnIntegersFuzzer", + timeout = "short", + srcs = [ + "src/test/java/com/example/SwitchCoverageHelper.java", + "src/test/java/com/example/SwitchOnIntegersFuzzer.java", + ], + allowed_findings = [ + "com.code_intelligence.jazzer.api.FuzzerSecurityIssueLow", + ], + fuzzer_args = [ + "-print_final_stats=1", + ] + select({ + # Windows needs significantly more executions in this test. + # Maybe on Windows, the call to __sanitizer_cov_trace_switch does something different? + "@platforms//os:windows": ["-runs=10000000"], + "//conditions:default": ["-runs=300000"], + }), + target_class = "com.example.SwitchOnIntegersFuzzer", + verify_crash_reproducer = False, + runtime_deps = [ + "@maven//:org_junit_jupiter_junit_jupiter_engine", + ], + deps = [ + "//deploy:jazzer-junit", + "//deploy:jazzer-project", + "@maven//:org_junit_jupiter_junit_jupiter_api", + "@maven//:org_junit_jupiter_junit_jupiter_params", + ], +) + +java_fuzz_target_test( + name = "SwitchOnStringsFuzzer", + timeout = "short", + srcs = [ + "src/test/java/com/example/SwitchCoverageHelper.java", + "src/test/java/com/example/SwitchOnStringsFuzzer.java", + ], + allowed_findings = [ + "com.code_intelligence.jazzer.api.FuzzerSecurityIssueLow", + ], + fuzzer_args = [ + "-print_final_stats=1", + "-runs=300000", + ], + target_class = "com.example.SwitchOnStringsFuzzer", + verify_crash_reproducer = False, + runtime_deps = [ + "@maven//:org_junit_jupiter_junit_jupiter_engine", + ], + deps = [ + "//deploy:jazzer-junit", + "//deploy:jazzer-project", + "@maven//:org_junit_jupiter_junit_jupiter_api", + "@maven//:org_junit_jupiter_junit_jupiter_params", + ], +) + +java_fuzz_target_test( + name = "SwitchStatementOnStringsFuzzer", + timeout = "short", + srcs = [ + "src/test/java/com/example/SwitchCoverageHelper.java", + "src/test/java/com/example/SwitchStatementOnStringsFuzzer.java", + ], + allowed_findings = [ + "com.code_intelligence.jazzer.api.FuzzerSecurityIssueLow", + ], + fuzzer_args = [ + "-print_final_stats=1", + "-runs=350000", + ], + javacopts = [ + "--release", + "17", + ], + tags = [ + "no-jdk8", + ], + target_class = "com.example.SwitchStatementOnStringsFuzzer", + verify_crash_reproducer = False, + runtime_deps = [ + "@maven//:org_junit_jupiter_junit_jupiter_engine", + ], + deps = [ + "//deploy:jazzer-junit", + "//deploy:jazzer-project", + "@maven//:org_junit_jupiter_junit_jupiter_api", + "@maven//:org_junit_jupiter_junit_jupiter_params", + ], +) + +java_fuzz_target_test( + name = "SwitchStatementOnIntegersFuzzer", + timeout = "short", + srcs = [ + "src/test/java/com/example/SwitchCoverageHelper.java", + "src/test/java/com/example/SwitchStatementOnIntegersFuzzer.java", + ], + allowed_findings = [ + "com.code_intelligence.jazzer.api.FuzzerSecurityIssueLow", + ], + fuzzer_args = [ + "-print_final_stats=1", + ] + select({ + # Windows needs significantly more executions in this test. + # Maybe on Windows, the call to __sanitizer_cov_trace_switch does something different? + "@platforms//os:windows": ["-runs=10000000"], + "//conditions:default": ["-runs=1000000"], + }), + javacopts = [ + "--release", + "17", + ], + tags = [ + "no-jdk8", + ], + target_class = "com.example.SwitchStatementOnIntegersFuzzer", + verify_crash_reproducer = False, + runtime_deps = [ + "@maven//:org_junit_jupiter_junit_jupiter_engine", + ], + deps = [ + "//deploy:jazzer-junit", + "//deploy:jazzer-project", + "@maven//:org_junit_jupiter_junit_jupiter_api", + "@maven//:org_junit_jupiter_junit_jupiter_params", + ], +) + +java_fuzz_target_test( + name = "SwitchMultipleCaseLabelsOfStrings", + timeout = "short", + srcs = [ + "src/test/java/com/example/SwitchCoverageHelper.java", + "src/test/java/com/example/SwitchMultipleCaseLabelsOfStrings.java", + ], + allowed_findings = [ + "com.code_intelligence.jazzer.api.FuzzerSecurityIssueLow", + ], + fuzzer_args = [ + "-print_final_stats=1", + "-runs=1000000", + ], + javacopts = [ + "--release", + "17", + ], + tags = [ + "no-jdk8", + ], + target_class = "com.example.SwitchMultipleCaseLabelsOfStrings", + verify_crash_reproducer = False, + runtime_deps = [ + "@maven//:org_junit_jupiter_junit_jupiter_engine", + ], + deps = [ + "//deploy:jazzer-junit", + "//deploy:jazzer-project", + "@maven//:org_junit_jupiter_junit_jupiter_api", + "@maven//:org_junit_jupiter_junit_jupiter_params", + ], +) + +java_fuzz_target_test( + name = "SwitchPatternMatchingWithGuardOverTypes", + timeout = "short", + srcs = [ + "src/test/java/com/example/SwitchCoverageHelper.java", + "src/test/java/com/example/SwitchPatternMatchingWithGuardOverTypes.java", + ], + allowed_findings = [ + "com.code_intelligence.jazzer.api.FuzzerSecurityIssueLow", + ], + fuzzer_args = [ + "-print_final_stats=1", + "-runs=1000000", + ], + javacopts = [ + "--release", + "21", + ], + tags = [ + "no-jdk8", + ], + target_class = "com.example.SwitchPatternMatchingWithGuardOverTypes", + verify_crash_reproducer = False, + runtime_deps = [ + "@maven//:org_junit_jupiter_junit_jupiter_engine", + ], + deps = [ + "//deploy:jazzer-junit", + "//deploy:jazzer-project", + "@maven//:org_junit_jupiter_junit_jupiter_api", + "@maven//:org_junit_jupiter_junit_jupiter_params", + ], +) + +java_fuzz_target_test( + name = "InvalidMutatorParameterTest", + timeout = "short", + srcs = ["src/test/java/com/example/InvalidMutatorTest.java"], + expect_crash = False, + expect_non_crash_exit_code = 1, + expected_warning_or_error = "(ERROR: Unsupported fuzz test parameter type java.lang.System in com.example.InvalidMutatorTest.invalidParameter.*)|(ERROR: Could not find suitable mutator for type: java.lang.System)", + target_class = "com.example.InvalidMutatorTest", + target_method = "invalidParameter", + runtime_deps = [ + "@maven//:org_junit_jupiter_junit_jupiter_engine", + ], + deps = [ + "//deploy:jazzer-junit", + "//src/main/java/com/code_intelligence/jazzer/mutation/annotation", + "@maven//:org_junit_jupiter_junit_jupiter_api", + "@maven//:org_junit_jupiter_junit_jupiter_params", + ], +) + +java_fuzz_target_test( + name = "InvalidMutatorAnnotationTest", + timeout = "short", + srcs = ["src/test/java/com/example/InvalidMutatorTest.java"], + expect_crash = False, + expect_non_crash_exit_code = 1, + expected_warning_or_error = "ERROR: @UrlSegment does not apply to java.lang.Integer, only applies to java.lang.String", + target_class = "com.example.InvalidMutatorTest", + target_method = "invalidAnnotation", + runtime_deps = [ + "@maven//:org_junit_jupiter_junit_jupiter_engine", + ], + deps = [ + "//deploy:jazzer-junit", + "//src/main/java/com/code_intelligence/jazzer/mutation/annotation", + "@maven//:org_junit_jupiter_junit_jupiter_api", + "@maven//:org_junit_jupiter_junit_jupiter_params", + ], +) + +java_fuzz_target_test( + name = "InitializationErrorTest", + timeout = "short", + srcs = ["src/test/java/com/example/InitializationErrorTest.java"], + expect_crash = False, + expect_non_crash_exit_code = 1, + expected_warning_or_error = "ERROR: java.lang.ExceptionInInitializerError", + target_class = "com.example.InitializationErrorTest", + runtime_deps = [ + "@maven//:org_junit_jupiter_junit_jupiter_engine", + ], + deps = [ + "//deploy:jazzer-junit", + "@maven//:org_junit_jupiter_junit_jupiter_api", + "@maven//:org_junit_jupiter_junit_jupiter_params", + ], +) + +java_fuzz_target_test( + name = "JUnitInvalidJavaSeedTest", + timeout = "short", + srcs = ["src/test/java/com/example/JUnitInvalidJavaSeedTest.java"], + expect_crash = False, + expected_warning_or_error = "WARN: JUnit arguments of type\\(s\\) .* can not be serialized as fuzzing inputs. Skipped.", + target_class = "com.example.JUnitInvalidJavaSeedTest", + runtime_deps = [ + "@maven//:org_junit_jupiter_junit_jupiter_engine", + ], + deps = [ + "//deploy:jazzer-junit", + "@maven//:org_junit_jupiter_junit_jupiter_api", + "@maven//:org_junit_jupiter_junit_jupiter_params", + ], +) + +filegroup( + name = "fuzz_test_lister_classes", + srcs = ["src/test/data/fuzz_test_lister_test"], +) + +sh_test( + name = "fuzz_test_lister_test", + size = "enormous", + srcs = ["src/test/shell/fuzz_test_lister_test.sh"], + args = [ + "$(rlocationpath //deploy:jazzer)", + "$(rlocationpath //deploy:jazzer-junit)", + "$(rlocationpath :fuzz_test_lister_classes)", + "$(rlocationpath @maven//:org_junit_jupiter_junit_jupiter_api)", + "$(rlocationpath @maven//:org_junit_jupiter_junit_jupiter_engine)", + "$(rlocationpath @maven//:org_junit_jupiter_junit_jupiter_params)", + "$(rlocationpath @maven//:org_junit_platform_junit_platform_commons)", + "$(rlocationpath @maven//:org_junit_platform_junit_platform_engine)", + "$(rlocationpath @maven//:org_junit_platform_junit_platform_launcher)", + ], + data = [ + ":fuzz_test_lister_classes", + ":src/test/data/fuzz_test_lister_test", + "//deploy:jazzer", + "//deploy:jazzer-junit", + "@bazel_tools//tools/jdk:current_host_java_runtime", + "@maven//:org_junit_jupiter_junit_jupiter_api", + "@maven//:org_junit_jupiter_junit_jupiter_engine", + "@maven//:org_junit_jupiter_junit_jupiter_params", + "@maven//:org_junit_platform_junit_platform_commons", + "@maven//:org_junit_platform_junit_platform_engine", + "@maven//:org_junit_platform_junit_platform_launcher", + ], + env = { + "JAVA_EXECPATH": "$(JAVA)", + "JAZZER_DEBUG": "1", + }, + target_compatible_with = SKIP_ON_WINDOWS, + toolchains = ["@bazel_tools//tools/jdk:current_host_java_runtime"], + deps = ["@bazel_tools//tools/bash/runfiles"], +) + ktlint() diff --git a/tests/benchmarks/BUILD.bazel b/tests/benchmarks/BUILD.bazel index d7b47d840..70868f9ab 100644 --- a/tests/benchmarks/BUILD.bazel +++ b/tests/benchmarks/BUILD.bazel @@ -29,10 +29,26 @@ fuzzer_benchmark( ], allowed_findings = ["com.example.StructuredMutatorMazeFuzzer$$TreasureFoundException"], fuzzer_args = [ - "--experimental_mutator", "-use_value_profile=1", ], - max_runs = 35000, + max_runs = 37000, + num_seeds = 15, + target_class = "com.example.StructuredMutatorMazeFuzzer", + deps = [ + "//src/main/java/com/code_intelligence/jazzer/mutation/annotation", + ], +) + +fuzzer_benchmark( + name = "ListOfIntegersFuzzerBenchmark", + srcs = [ + "src/test/java/com/example/ListOfIntegersFuzzer.java", + ], + allowed_findings = ["com.example.StructuredMutatorMazeFuzzer$$TreasureFoundException"], + fuzzer_args = [ + "-use_value_profile=1", + ], + max_runs = 4000000, num_seeds = 15, target_class = "com.example.StructuredMutatorMazeFuzzer", deps = [ diff --git a/tests/benchmarks/src/test/java/com/example/ListOfIntegersFuzzer.java b/tests/benchmarks/src/test/java/com/example/ListOfIntegersFuzzer.java new file mode 100644 index 000000000..b43a7b656 --- /dev/null +++ b/tests/benchmarks/src/test/java/com/example/ListOfIntegersFuzzer.java @@ -0,0 +1,37 @@ +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ + +package com.example; + +import com.code_intelligence.jazzer.mutation.annotation.NotNull; +import com.code_intelligence.jazzer.mutation.annotation.WithSize; +import java.util.List; + +public final class ListOfIntegersFuzzer { + public static void fuzzerTestOneInput( + @NotNull @WithSize(min = 10, max = 10) List<@NotNull Integer> data) { + if (data.size() != 10) return; + + if (data.get(0) == 10) { + if (data.get(1) == 200000) { + if (data.get(2) == 300000) { + if (data.get(3) == 102031) { + if (data.get(4) == 918736) { + if (data.get(5) == 12301) { + throw new TreasureFoundException(); + } + } + } + } + } + } + } + + private static class TreasureFoundException extends RuntimeException {} +} diff --git a/tests/benchmarks/src/test/java/com/example/StructuredMutatorMazeFuzzer.java b/tests/benchmarks/src/test/java/com/example/StructuredMutatorMazeFuzzer.java index 09ac4fd9c..75269667c 100644 --- a/tests/benchmarks/src/test/java/com/example/StructuredMutatorMazeFuzzer.java +++ b/tests/benchmarks/src/test/java/com/example/StructuredMutatorMazeFuzzer.java @@ -1,16 +1,11 @@ -// Copyright 2022 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example; diff --git a/tests/benchmarks/src/test/java/com/example/UnstructuredPackedMazeFuzzer.java b/tests/benchmarks/src/test/java/com/example/UnstructuredPackedMazeFuzzer.java index 3446bd6aa..b293db9cf 100644 --- a/tests/benchmarks/src/test/java/com/example/UnstructuredPackedMazeFuzzer.java +++ b/tests/benchmarks/src/test/java/com/example/UnstructuredPackedMazeFuzzer.java @@ -1,16 +1,11 @@ -// Copyright 2022 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example; diff --git a/tests/src/test/cc/complex_proto_fuzzer.cc b/tests/src/test/cc/complex_proto_fuzzer.cc index b9eea8bb7..134e28e44 100644 --- a/tests/src/test/cc/complex_proto_fuzzer.cc +++ b/tests/src/test/cc/complex_proto_fuzzer.cc @@ -1,16 +1,9 @@ -// Copyright 2023 Code Intelligence GmbH +// Copyright 2024 Code Intelligence GmbH // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. // -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt +// located in the root directory of the project. #include "src/libfuzzer/libfuzzer_macro.h" #include "src/test/java/com/code_intelligence/jazzer/mutation/mutator/proto/proto2.pb.h" diff --git a/tests/src/test/data/fuzz_test_lister_test/org/example/FuzzTests.class b/tests/src/test/data/fuzz_test_lister_test/org/example/FuzzTests.class new file mode 100644 index 000000000..bfcf94ba9 Binary files /dev/null and b/tests/src/test/data/fuzz_test_lister_test/org/example/FuzzTests.class differ diff --git a/tests/src/test/java/com/example/AutofuzzAssertionErrorTarget.java b/tests/src/test/java/com/example/AutofuzzAssertionErrorTarget.java index d692371f7..bcfdbf221 100644 --- a/tests/src/test/java/com/example/AutofuzzAssertionErrorTarget.java +++ b/tests/src/test/java/com/example/AutofuzzAssertionErrorTarget.java @@ -1,17 +1,10 @@ /* - * Copyright 2023 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.example; diff --git a/tests/src/test/java/com/example/AutofuzzCrashingSetterTarget.java b/tests/src/test/java/com/example/AutofuzzCrashingSetterTarget.java index 1af0c7bf6..c4cd0b14d 100644 --- a/tests/src/test/java/com/example/AutofuzzCrashingSetterTarget.java +++ b/tests/src/test/java/com/example/AutofuzzCrashingSetterTarget.java @@ -1,17 +1,10 @@ /* - * Copyright 2023 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.example; diff --git a/tests/src/test/java/com/example/AutofuzzIgnoreTarget.java b/tests/src/test/java/com/example/AutofuzzIgnoreTarget.java index d71ca4d9c..667e85780 100644 --- a/tests/src/test/java/com/example/AutofuzzIgnoreTarget.java +++ b/tests/src/test/java/com/example/AutofuzzIgnoreTarget.java @@ -1,16 +1,11 @@ -// Copyright 2022 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example; diff --git a/tests/src/test/java/com/example/AutofuzzInnerClassTarget.java b/tests/src/test/java/com/example/AutofuzzInnerClassTarget.java index 16240eff3..e4f763b4d 100644 --- a/tests/src/test/java/com/example/AutofuzzInnerClassTarget.java +++ b/tests/src/test/java/com/example/AutofuzzInnerClassTarget.java @@ -1,17 +1,10 @@ /* - * Copyright 2022 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.example; diff --git a/tests/src/test/java/com/example/BytesMemoryLeakFuzzer.java b/tests/src/test/java/com/example/BytesMemoryLeakFuzzer.java index 954063166..dc4304192 100644 --- a/tests/src/test/java/com/example/BytesMemoryLeakFuzzer.java +++ b/tests/src/test/java/com/example/BytesMemoryLeakFuzzer.java @@ -1,17 +1,10 @@ /* - * Copyright 2022 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.example; diff --git a/tests/src/test/java/com/example/CoverageFuzzer.java b/tests/src/test/java/com/example/CoverageFuzzer.java index c35e710bf..de7f19adf 100644 --- a/tests/src/test/java/com/example/CoverageFuzzer.java +++ b/tests/src/test/java/com/example/CoverageFuzzer.java @@ -1,17 +1,12 @@ /* - * Copyright 2022 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * This file also contains code licensed under Apache2 license. */ package com.example; diff --git a/tests/src/test/java/com/example/CrashResistantCoverageTarget.java b/tests/src/test/java/com/example/CrashResistantCoverageTarget.java index c88d45091..d644e2040 100644 --- a/tests/src/test/java/com/example/CrashResistantCoverageTarget.java +++ b/tests/src/test/java/com/example/CrashResistantCoverageTarget.java @@ -1,16 +1,11 @@ -// Copyright 2022 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example; diff --git a/tests/src/test/java/com/example/DisabledHooksFuzzer.java b/tests/src/test/java/com/example/DisabledHooksFuzzer.java index 34c1e4913..00e89673f 100644 --- a/tests/src/test/java/com/example/DisabledHooksFuzzer.java +++ b/tests/src/test/java/com/example/DisabledHooksFuzzer.java @@ -1,17 +1,10 @@ /* - * Copyright 2022 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.example; diff --git a/tests/src/test/java/com/example/ExperimentalMutatorComplexProtoFuzzer.java b/tests/src/test/java/com/example/ExperimentalMutatorComplexProtoFuzzer.java deleted file mode 100644 index 749e0dfd7..000000000 --- a/tests/src/test/java/com/example/ExperimentalMutatorComplexProtoFuzzer.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2023 Code Intelligence GmbH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.example; - -import com.code_intelligence.jazzer.api.FuzzerSecurityIssueMedium; -import com.code_intelligence.jazzer.mutation.annotation.NotNull; -import com.code_intelligence.jazzer.protobuf.Proto2.TestProtobuf; - -public class ExperimentalMutatorComplexProtoFuzzer { - public static void fuzzerTestOneInput(@NotNull TestProtobuf proto) { - if (proto.getI32() == 1234 && proto.getStr().equals("abcd")) { - throw new FuzzerSecurityIssueMedium("Secret proto is found!"); - } - } -} diff --git a/tests/src/test/java/com/example/ExperimentalMutatorFuzzer.java b/tests/src/test/java/com/example/ExperimentalMutatorFuzzer.java deleted file mode 100644 index 9645e8178..000000000 --- a/tests/src/test/java/com/example/ExperimentalMutatorFuzzer.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2023 Code Intelligence GmbH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.example; - -import com.code_intelligence.jazzer.api.FuzzerSecurityIssueMedium; -import com.code_intelligence.jazzer.mutation.annotation.InRange; -import com.code_intelligence.jazzer.mutation.annotation.NotNull; - -public class ExperimentalMutatorFuzzer { - public static void fuzzerTestOneInput( - @InRange(max = -42) short num, @NotNull SimpleProto.MyProto proto) { - if (num > -42) { - throw new IllegalArgumentException(); - } - - if (proto.getNumber() == 12345678) { - if (proto.getMessage().getText().contains("Hello, proto!")) { - throw new FuzzerSecurityIssueMedium("Dangerous proto"); - } - } - } -} diff --git a/tests/src/test/java/com/example/ForkModeFuzzer.java b/tests/src/test/java/com/example/ForkModeFuzzer.java index b75d3359a..9e923e941 100644 --- a/tests/src/test/java/com/example/ForkModeFuzzer.java +++ b/tests/src/test/java/com/example/ForkModeFuzzer.java @@ -1,16 +1,11 @@ -// Copyright 2022 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example; diff --git a/tests/src/test/java/com/example/HookDependenciesFuzzer.java b/tests/src/test/java/com/example/HookDependenciesFuzzer.java index 251f6e82b..bea4ba75e 100644 --- a/tests/src/test/java/com/example/HookDependenciesFuzzer.java +++ b/tests/src/test/java/com/example/HookDependenciesFuzzer.java @@ -1,16 +1,11 @@ -// Copyright 2022 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example; diff --git a/tests/src/test/java/com/example/HookDependenciesFuzzerHooks.java b/tests/src/test/java/com/example/HookDependenciesFuzzerHooks.java index b9d81fb86..8c48d68fb 100644 --- a/tests/src/test/java/com/example/HookDependenciesFuzzerHooks.java +++ b/tests/src/test/java/com/example/HookDependenciesFuzzerHooks.java @@ -1,16 +1,11 @@ -// Copyright 2022 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example; diff --git a/tests/src/test/java/com/example/InitializationErrorTest.java b/tests/src/test/java/com/example/InitializationErrorTest.java new file mode 100644 index 000000000..bf300e8a0 --- /dev/null +++ b/tests/src/test/java/com/example/InitializationErrorTest.java @@ -0,0 +1,28 @@ +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ + +package com.example; + +import com.code_intelligence.jazzer.junit.FuzzTest; + +public class InitializationErrorTest { + + static { + sneakyThrow(); + } + + private static void sneakyThrow() { + throw new IllegalArgumentException("Sneaky throw in static initializer"); + } + + @FuzzTest + public void fuzz(String ignored) { + throw new IllegalStateException("This method should not be executed"); + } +} diff --git a/tests/src/test/java/com/example/InvalidMutatorTest.java b/tests/src/test/java/com/example/InvalidMutatorTest.java new file mode 100644 index 000000000..b3c154e3c --- /dev/null +++ b/tests/src/test/java/com/example/InvalidMutatorTest.java @@ -0,0 +1,26 @@ +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ + +package com.example; + +import com.code_intelligence.jazzer.junit.FuzzTest; +import com.code_intelligence.jazzer.mutation.annotation.UrlSegment; + +public class InvalidMutatorTest { + + @FuzzTest + public void invalidParameter(System ignored) { + throw new IllegalStateException("This method should not be executed"); + } + + @FuzzTest + public void invalidAnnotation(@UrlSegment Integer ignored) { + throw new IllegalStateException("This method should not be executed"); + } +} diff --git a/tests/src/test/java/com/example/JUnitAgentConfigurationFuzzTest.java b/tests/src/test/java/com/example/JUnitAgentConfigurationFuzzTest.java index 1f2ffaaf9..faf2edc99 100644 --- a/tests/src/test/java/com/example/JUnitAgentConfigurationFuzzTest.java +++ b/tests/src/test/java/com/example/JUnitAgentConfigurationFuzzTest.java @@ -1,17 +1,10 @@ /* - * Copyright 2023 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.example; diff --git a/tests/src/test/java/com/example/JUnitAssertFuzzer.java b/tests/src/test/java/com/example/JUnitAssertFuzzer.java index d26442812..31dc44596 100644 --- a/tests/src/test/java/com/example/JUnitAssertFuzzer.java +++ b/tests/src/test/java/com/example/JUnitAssertFuzzer.java @@ -1,17 +1,10 @@ /* - * Copyright 2022 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.example; diff --git a/tests/src/test/java/com/example/JUnitInvalidJavaSeedTest.java b/tests/src/test/java/com/example/JUnitInvalidJavaSeedTest.java new file mode 100644 index 000000000..082a54ce7 --- /dev/null +++ b/tests/src/test/java/com/example/JUnitInvalidJavaSeedTest.java @@ -0,0 +1,36 @@ +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ + +package com.example; + +import static org.junit.jupiter.params.provider.Arguments.arguments; + +import com.code_intelligence.jazzer.junit.FuzzTest; +import java.util.stream.Stream; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +class JUnitInvalidJavaSeedTest { + + static class ConstructorBased { + final int b; + + ConstructorBased(int a) { + this.b = a * a; + } + } + + public static Stream seeds() { + return Stream.of(arguments(new ConstructorBased(42))); + } + + @MethodSource("seeds") + @FuzzTest(maxExecutions = 10) + void fuzzTest(ConstructorBased ignored) {} +} diff --git a/tests/src/test/java/com/example/JUnitReproducerTest.java b/tests/src/test/java/com/example/JUnitReproducerTest.java index 419f1c4be..97a33c9e1 100644 --- a/tests/src/test/java/com/example/JUnitReproducerTest.java +++ b/tests/src/test/java/com/example/JUnitReproducerTest.java @@ -1,17 +1,10 @@ /* - * Copyright 2023 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.example; diff --git a/tests/src/test/java/com/example/JUnitSsrfAllowConnectionsBeforeFuzzingFuzzer.java b/tests/src/test/java/com/example/JUnitSsrfAllowConnectionsBeforeFuzzingFuzzer.java new file mode 100644 index 000000000..996ff0ae7 --- /dev/null +++ b/tests/src/test/java/com/example/JUnitSsrfAllowConnectionsBeforeFuzzingFuzzer.java @@ -0,0 +1,30 @@ +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ + +package com.example; + +import com.code_intelligence.jazzer.api.FuzzedDataProvider; +import com.code_intelligence.jazzer.junit.FuzzTest; +import java.io.IOException; +import java.net.Socket; +import org.junit.jupiter.api.BeforeAll; + +public class JUnitSsrfAllowConnectionsBeforeFuzzingFuzzer { + // Before the fuzzer is started, we allow network connections. + @BeforeAll + static void connect() { + try (Socket s = new Socket("localhost", 62351)) { + s.getInetAddress(); + } catch (IOException ignored) { + } + } + + @FuzzTest + void fuzzTest(FuzzedDataProvider data) throws Exception {} +} diff --git a/tests/src/test/java/com/example/JUnitSsrfAllowListFuzzer.java b/tests/src/test/java/com/example/JUnitSsrfAllowListFuzzer.java new file mode 100644 index 000000000..3f8b0eb75 --- /dev/null +++ b/tests/src/test/java/com/example/JUnitSsrfAllowListFuzzer.java @@ -0,0 +1,29 @@ +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ + +package com.example; + +import com.code_intelligence.jazzer.api.BugDetectors; +import com.code_intelligence.jazzer.api.FuzzedDataProvider; +import com.code_intelligence.jazzer.junit.FuzzTest; +import java.net.ConnectException; +import java.net.Socket; + +public class JUnitSsrfAllowListFuzzer { + + @FuzzTest + void fuzzTest(FuzzedDataProvider data) throws Exception { + BugDetectors.allowNetworkConnections( + (host, port) -> host.equals("localhost") && port.equals(62351)); + try (Socket s = new Socket("localhost", 62351)) { + s.getInetAddress(); + } catch (ConnectException ignored) { + } + } +} diff --git a/tests/src/test/java/com/example/JUnitSsrfFindingFuzzer.java b/tests/src/test/java/com/example/JUnitSsrfFindingFuzzer.java new file mode 100644 index 000000000..c0c0a3d02 --- /dev/null +++ b/tests/src/test/java/com/example/JUnitSsrfFindingFuzzer.java @@ -0,0 +1,25 @@ +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ + +package com.example; + +import com.code_intelligence.jazzer.api.FuzzedDataProvider; +import com.code_intelligence.jazzer.junit.FuzzTest; +import java.net.ConnectException; +import java.net.Socket; + +public class JUnitSsrfFindingFuzzer { + @FuzzTest + void fuzzTest(FuzzedDataProvider data) throws Exception { + try (Socket s = new Socket("localhost", 62351)) { + s.getInetAddress(); + } catch (ConnectException ignored) { + } + } +} diff --git a/tests/src/test/java/com/example/JUnitTimeoutTest.java b/tests/src/test/java/com/example/JUnitTimeoutTest.java index 6dff5067c..afa213009 100644 --- a/tests/src/test/java/com/example/JUnitTimeoutTest.java +++ b/tests/src/test/java/com/example/JUnitTimeoutTest.java @@ -1,17 +1,10 @@ /* - * Copyright 2023 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.example; diff --git a/tests/src/test/java/com/example/JazzerApiFuzzer.java b/tests/src/test/java/com/example/JazzerApiFuzzer.java index 2428d21fc..8dda092b5 100644 --- a/tests/src/test/java/com/example/JazzerApiFuzzer.java +++ b/tests/src/test/java/com/example/JazzerApiFuzzer.java @@ -1,17 +1,10 @@ /* - * Copyright 2022 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.example; diff --git a/tests/src/test/java/com/example/KotlinStringCompareFuzzer.kt b/tests/src/test/java/com/example/KotlinStringCompareFuzzer.kt new file mode 100644 index 000000000..4a092c0a6 --- /dev/null +++ b/tests/src/test/java/com/example/KotlinStringCompareFuzzer.kt @@ -0,0 +1,27 @@ +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ + +package com.example + +import java.io.IOException +import kotlin.io.encoding.Base64 +import kotlin.io.encoding.ExperimentalEncodingApi + +object KotlinStringCompareFuzzer { + @JvmStatic + @OptIn(ExperimentalEncodingApi::class) + fun fuzzerTestOneInput(data: ByteArray) { + val text = Base64.encode(data) + if (text.startsWith("aGVsbG8K") && // hello + text.endsWith("d29ybGQK") // world + ) { + throw IOException("Found the secret message!") + } + } +} diff --git a/tests/src/test/java/com/example/KotlinVararg.kt b/tests/src/test/java/com/example/KotlinVararg.kt index 81974eba7..e179d49cc 100644 --- a/tests/src/test/java/com/example/KotlinVararg.kt +++ b/tests/src/test/java/com/example/KotlinVararg.kt @@ -1,17 +1,10 @@ /* - * Copyright 2022 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.example diff --git a/tests/src/test/java/com/example/KotlinVarargFuzzer.java b/tests/src/test/java/com/example/KotlinVarargFuzzer.java index 3324e2e89..6238c1cf2 100644 --- a/tests/src/test/java/com/example/KotlinVarargFuzzer.java +++ b/tests/src/test/java/com/example/KotlinVarargFuzzer.java @@ -1,17 +1,10 @@ /* - * Copyright 2022 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.example; diff --git a/tests/src/test/java/com/example/LocalDateTimeFuzzer.java b/tests/src/test/java/com/example/LocalDateTimeFuzzer.java new file mode 100644 index 000000000..877aa5954 --- /dev/null +++ b/tests/src/test/java/com/example/LocalDateTimeFuzzer.java @@ -0,0 +1,27 @@ +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ + +package com.example; + +import com.code_intelligence.jazzer.api.FuzzerSecurityIssueLow; +import com.code_intelligence.jazzer.junit.FuzzTest; +import java.time.LocalDateTime; + +public class LocalDateTimeFuzzer { + @FuzzTest + void localDateTimeFuzzTest(LocalDateTime localDateTime) { + if (localDateTime == null) { + return; + } + LocalDateTime targetDate = LocalDateTime.of(2024, 5, 30, 23, 59); + if (targetDate.getDayOfYear() == localDateTime.getDayOfYear()) { + throw new FuzzerSecurityIssueLow("LocalDateTime mutator works!"); + } + } +} diff --git a/tests/src/test/java/com/example/LongStringFuzzer.java b/tests/src/test/java/com/example/LongStringFuzzer.java index f168be81e..c9347deac 100644 --- a/tests/src/test/java/com/example/LongStringFuzzer.java +++ b/tests/src/test/java/com/example/LongStringFuzzer.java @@ -1,16 +1,11 @@ -// Copyright 2021 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example; diff --git a/tests/src/test/java/com/example/MapFuzzer.java b/tests/src/test/java/com/example/MapFuzzer.java index ba61aefc8..0fbb421c7 100644 --- a/tests/src/test/java/com/example/MapFuzzer.java +++ b/tests/src/test/java/com/example/MapFuzzer.java @@ -1,17 +1,10 @@ /* - * Copyright 2023 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.example; diff --git a/tests/src/test/java/com/example/MemoryLeakFuzzer.java b/tests/src/test/java/com/example/MemoryLeakFuzzer.java index 9f38a1e20..eda6c6034 100644 --- a/tests/src/test/java/com/example/MemoryLeakFuzzer.java +++ b/tests/src/test/java/com/example/MemoryLeakFuzzer.java @@ -1,17 +1,10 @@ /* - * Copyright 2022 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.example; diff --git a/tests/src/test/java/com/example/MutatorComplexProtoFuzzer.java b/tests/src/test/java/com/example/MutatorComplexProtoFuzzer.java new file mode 100644 index 000000000..6b4c67ff3 --- /dev/null +++ b/tests/src/test/java/com/example/MutatorComplexProtoFuzzer.java @@ -0,0 +1,22 @@ +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ + +package com.example; + +import com.code_intelligence.jazzer.api.FuzzerSecurityIssueMedium; +import com.code_intelligence.jazzer.mutation.annotation.NotNull; +import com.code_intelligence.jazzer.protobuf.Proto2.TestProtobuf; + +public class MutatorComplexProtoFuzzer { + public static void fuzzerTestOneInput(@NotNull TestProtobuf proto) { + if (proto.getI32() == 1234 && proto.getStr().equals("abcd")) { + throw new FuzzerSecurityIssueMedium("Secret proto is found!"); + } + } +} diff --git a/tests/src/test/java/com/example/ExperimentalMutatorDynamicProtoFuzzer.java b/tests/src/test/java/com/example/MutatorDynamicProtoFuzzer.java similarity index 73% rename from tests/src/test/java/com/example/ExperimentalMutatorDynamicProtoFuzzer.java rename to tests/src/test/java/com/example/MutatorDynamicProtoFuzzer.java index 9da6e5623..12866f27c 100644 --- a/tests/src/test/java/com/example/ExperimentalMutatorDynamicProtoFuzzer.java +++ b/tests/src/test/java/com/example/MutatorDynamicProtoFuzzer.java @@ -1,17 +1,10 @@ /* - * Copyright 2023 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.example; @@ -29,11 +22,9 @@ import com.google.protobuf.DynamicMessage; import com.google.protobuf.Message; -public class ExperimentalMutatorDynamicProtoFuzzer { +public class MutatorDynamicProtoFuzzer { public static void fuzzerTestOneInput( - @NotNull - @WithDefaultInstance( - "com.example.ExperimentalMutatorDynamicProtoFuzzer#getDefaultInstance") + @NotNull @WithDefaultInstance("com.example.MutatorDynamicProtoFuzzer#getDefaultInstance") Message proto) { FieldDescriptor I32 = proto.getDescriptorForType().findFieldByName("i32"); FieldDescriptor STR = proto.getDescriptorForType().findFieldByName("str"); diff --git a/tests/src/test/java/com/example/MutatorFuzzer.java b/tests/src/test/java/com/example/MutatorFuzzer.java new file mode 100644 index 000000000..f9ff6fd7e --- /dev/null +++ b/tests/src/test/java/com/example/MutatorFuzzer.java @@ -0,0 +1,29 @@ +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ + +package com.example; + +import com.code_intelligence.jazzer.api.FuzzerSecurityIssueMedium; +import com.code_intelligence.jazzer.mutation.annotation.InRange; +import com.code_intelligence.jazzer.mutation.annotation.NotNull; + +public class MutatorFuzzer { + public static void fuzzerTestOneInput( + @InRange(max = -42) short num, @NotNull SimpleProto.MyProto proto) { + if (num > -42) { + throw new IllegalArgumentException(); + } + + if (proto.getNumber() == 12345678) { + if (proto.getMessage().getText().contains("Hello, proto!")) { + throw new FuzzerSecurityIssueMedium("Dangerous proto"); + } + } + } +} diff --git a/tests/src/test/java/com/example/NativeValueProfileFuzzer.java b/tests/src/test/java/com/example/NativeValueProfileFuzzer.java index b942fc1b7..24c65d8c8 100644 --- a/tests/src/test/java/com/example/NativeValueProfileFuzzer.java +++ b/tests/src/test/java/com/example/NativeValueProfileFuzzer.java @@ -1,17 +1,10 @@ /* - * Copyright 2022 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.example; diff --git a/tests/src/test/java/com/example/NoCoverageFuzzer.java b/tests/src/test/java/com/example/NoCoverageFuzzer.java index a1f8b4ea9..0fbfbc5ec 100644 --- a/tests/src/test/java/com/example/NoCoverageFuzzer.java +++ b/tests/src/test/java/com/example/NoCoverageFuzzer.java @@ -1,16 +1,11 @@ -// Copyright 2022 Code Intelligence GmbH -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ package com.example; diff --git a/tests/src/test/java/com/example/NoSeedFuzzer.java b/tests/src/test/java/com/example/NoSeedFuzzer.java index bf1c11038..3a0f51e79 100644 --- a/tests/src/test/java/com/example/NoSeedFuzzer.java +++ b/tests/src/test/java/com/example/NoSeedFuzzer.java @@ -1,17 +1,10 @@ /* - * Copyright 2022 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.example; diff --git a/tests/src/test/java/com/example/ObjectEqualsIntegerFuzzer.java b/tests/src/test/java/com/example/ObjectEqualsIntegerFuzzer.java new file mode 100644 index 000000000..836383d45 --- /dev/null +++ b/tests/src/test/java/com/example/ObjectEqualsIntegerFuzzer.java @@ -0,0 +1,25 @@ +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ + +package com.example; + +import com.code_intelligence.jazzer.api.FuzzedDataProvider; +import com.code_intelligence.jazzer.api.FuzzerSecurityIssueLow; +import com.code_intelligence.jazzer.junit.FuzzTest; +import java.util.Objects; + +public class ObjectEqualsIntegerFuzzer { + @FuzzTest + void objectEqualsInteger(FuzzedDataProvider fdp) { + int integer = fdp.consumeInt(); + if (Objects.equals(integer, 4711)) { + throw new FuzzerSecurityIssueLow("ObjectsEqualsFuzzer works!"); + } + } +} diff --git a/tests/src/test/java/com/example/ObjectEqualsStringFuzzer.java b/tests/src/test/java/com/example/ObjectEqualsStringFuzzer.java new file mode 100644 index 000000000..fc2b57f9c --- /dev/null +++ b/tests/src/test/java/com/example/ObjectEqualsStringFuzzer.java @@ -0,0 +1,24 @@ +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ + +package com.example; + +import com.code_intelligence.jazzer.api.FuzzerSecurityIssueLow; +import com.code_intelligence.jazzer.junit.FuzzTest; +import java.util.Objects; + +public class ObjectEqualsStringFuzzer { + @FuzzTest + void objectEqualsString(byte[] input) { + String stringInput = new String(input); + if (Objects.equals(stringInput, "ObjectsEqualsFuzzer")) { + throw new FuzzerSecurityIssueLow("ObjectsEqualsFuzzer works!"); + } + } +} diff --git a/tests/src/test/java/com/example/OfflineInstrumentedFuzzer.java b/tests/src/test/java/com/example/OfflineInstrumentedFuzzer.java index eb7da4802..05a514b96 100644 --- a/tests/src/test/java/com/example/OfflineInstrumentedFuzzer.java +++ b/tests/src/test/java/com/example/OfflineInstrumentedFuzzer.java @@ -1,17 +1,10 @@ /* - * Copyright 2023 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.example; diff --git a/tests/src/test/java/com/example/OfflineInstrumentedTarget.java b/tests/src/test/java/com/example/OfflineInstrumentedTarget.java index 523472700..a4ce848fd 100644 --- a/tests/src/test/java/com/example/OfflineInstrumentedTarget.java +++ b/tests/src/test/java/com/example/OfflineInstrumentedTarget.java @@ -1,17 +1,10 @@ /* - * Copyright 2023 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.example; diff --git a/tests/src/test/java/com/example/PrimitiveTypeCompareHookFuzzer.java b/tests/src/test/java/com/example/PrimitiveTypeCompareHookFuzzer.java index be009d175..4b3e4971a 100644 --- a/tests/src/test/java/com/example/PrimitiveTypeCompareHookFuzzer.java +++ b/tests/src/test/java/com/example/PrimitiveTypeCompareHookFuzzer.java @@ -1,17 +1,10 @@ /* - * Copyright 2023 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.example; diff --git a/tests/src/test/java/com/example/RegressionModeTest.java b/tests/src/test/java/com/example/RegressionModeTest.java new file mode 100644 index 000000000..9ff2a2946 --- /dev/null +++ b/tests/src/test/java/com/example/RegressionModeTest.java @@ -0,0 +1,25 @@ +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ + +package com.example; + +import com.code_intelligence.jazzer.api.FuzzerSecurityIssueLow; +import com.code_intelligence.jazzer.junit.FuzzTest; + +public class RegressionModeTest { + + private static int count = 0; + + @FuzzTest + void fuzzTest(String ignored) { + if (count++ > 0) { + throw new FuzzerSecurityIssueLow("Should not be reached in regression mode"); + } + } +} diff --git a/tests/src/test/java/com/example/SeedFuzzer.java b/tests/src/test/java/com/example/SeedFuzzer.java index 4d1e4e8b6..5a519dadb 100644 --- a/tests/src/test/java/com/example/SeedFuzzer.java +++ b/tests/src/test/java/com/example/SeedFuzzer.java @@ -1,17 +1,10 @@ /* - * Copyright 2022 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.example; diff --git a/tests/src/test/java/com/example/SilencedFuzzer.java b/tests/src/test/java/com/example/SilencedFuzzer.java index 16d8ff135..bd6afb95d 100644 --- a/tests/src/test/java/com/example/SilencedFuzzer.java +++ b/tests/src/test/java/com/example/SilencedFuzzer.java @@ -1,17 +1,10 @@ /* - * Copyright 2023 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.example; diff --git a/tests/src/test/java/com/example/StringCompareFuzzer.java b/tests/src/test/java/com/example/StringCompareFuzzer.java new file mode 100644 index 000000000..96c312ccf --- /dev/null +++ b/tests/src/test/java/com/example/StringCompareFuzzer.java @@ -0,0 +1,24 @@ +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ + +package com.example; + +import com.code_intelligence.jazzer.api.FuzzerSecurityIssueLow; +import java.util.Base64; + +public class StringCompareFuzzer { + public static void fuzzerTestOneInput(byte[] data) { + String text = Base64.getEncoder().encodeToString(data); + if (text.startsWith("aGVsbG8K") // hello + && text.endsWith("d29ybGQK") // world + ) { + throw new FuzzerSecurityIssueLow("Found the secret message!"); + } + } +} diff --git a/tests/src/test/java/com/example/SwitchCoverageHelper.java b/tests/src/test/java/com/example/SwitchCoverageHelper.java new file mode 100644 index 000000000..ed782a533 --- /dev/null +++ b/tests/src/test/java/com/example/SwitchCoverageHelper.java @@ -0,0 +1,36 @@ +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ + +package com.example; + +public class SwitchCoverageHelper { + int covered = 0; + final int cases; + static boolean[] casesVisited; + + public SwitchCoverageHelper(int cases) { + this.cases = cases; + casesVisited = new boolean[cases]; + } + + public void coverCase(int caze) { + if (caze < 0 || caze >= cases) { + throw new IllegalArgumentException("Invalid case"); + } + if (casesVisited[caze]) { + return; + } + casesVisited[caze] = true; + covered++; + } + + public boolean allBranchesCovered() { + return covered == cases; + } +} diff --git a/tests/src/test/java/com/example/SwitchMultipleCaseLabelsOfStrings.java b/tests/src/test/java/com/example/SwitchMultipleCaseLabelsOfStrings.java new file mode 100644 index 000000000..61d6d942e --- /dev/null +++ b/tests/src/test/java/com/example/SwitchMultipleCaseLabelsOfStrings.java @@ -0,0 +1,45 @@ +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ + +package com.example; + +import com.code_intelligence.jazzer.api.FuzzerSecurityIssueLow; +import com.code_intelligence.jazzer.junit.FuzzTest; +import com.code_intelligence.jazzer.mutation.annotation.NotNull; + +public class SwitchMultipleCaseLabelsOfStrings { + static SwitchCoverageHelper cov = new SwitchCoverageHelper(4); + + @FuzzTest + public void test(@NotNull String data) { + if (cov.allBranchesCovered()) { + throw new FuzzerSecurityIssueLow("All cases visited"); + } + String ignored = + switch (data) { + case "Test1", "Blidfsfba", "BUIbda1ibeb", "nfbuidsf91" -> { + cov.coverCase(0); + yield "Hello 0"; + } + case "Olqofdsn", "ndsufi298fnbds", "fndsjaf" -> { + cov.coverCase(1); + yield "Hello 1"; + } + case "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" -> { + cov.coverCase(2); + yield "Hello 2"; + } + case "Unknown", "Unknown2", "Unknown3" -> { + cov.coverCase(3); + yield "Hello 3"; + } + default -> "Hello default"; + }; + } +} diff --git a/tests/src/test/java/com/example/SwitchOnIntegersFuzzer.java b/tests/src/test/java/com/example/SwitchOnIntegersFuzzer.java new file mode 100644 index 000000000..760995001 --- /dev/null +++ b/tests/src/test/java/com/example/SwitchOnIntegersFuzzer.java @@ -0,0 +1,44 @@ +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ + +package com.example; + +import com.code_intelligence.jazzer.api.FuzzerSecurityIssueLow; +import com.code_intelligence.jazzer.junit.FuzzTest; + +public class SwitchOnIntegersFuzzer { + static SwitchCoverageHelper cov = new SwitchCoverageHelper(5); + + @FuzzTest + public void test(int data) { + if (cov.allBranchesCovered()) { + throw new FuzzerSecurityIssueLow("All cases visited"); + } + + switch (data) { + case 1029391: + cov.coverCase(0); + break; + case 10101010: + cov.coverCase(1); + break; + case 20202020: + cov.coverCase(2); + break; + case 303003033: + cov.coverCase(3); + break; + case 409102931: + cov.coverCase(4); + break; + default: + break; + } + } +} diff --git a/tests/src/test/java/com/example/SwitchOnStringsFuzzer.java b/tests/src/test/java/com/example/SwitchOnStringsFuzzer.java new file mode 100644 index 000000000..4d7cd435e --- /dev/null +++ b/tests/src/test/java/com/example/SwitchOnStringsFuzzer.java @@ -0,0 +1,39 @@ +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ + +package com.example; + +import com.code_intelligence.jazzer.api.FuzzerSecurityIssueLow; +import com.code_intelligence.jazzer.junit.FuzzTest; +import com.code_intelligence.jazzer.mutation.annotation.NotNull; + +public class SwitchOnStringsFuzzer { + static SwitchCoverageHelper cov = new SwitchCoverageHelper(4); + + @FuzzTest + public void test(@NotNull String data) { + if (cov.allBranchesCovered()) { + throw new FuzzerSecurityIssueLow("All cases visited"); + } + switch (data) { + case "The Road goes ever on and on": + cov.coverCase(0); + break; + case "Out from the door where it began.": + cov.coverCase(1); + break; + case "Now far ahead the Road has gone,": + cov.coverCase(2); + break; + case "Let others follow it who can!": + cov.coverCase(3); + break; + } + } +} diff --git a/tests/src/test/java/com/example/SwitchPatternMatchingWithGuardOverTypes.java b/tests/src/test/java/com/example/SwitchPatternMatchingWithGuardOverTypes.java new file mode 100644 index 000000000..9d2bca3e5 --- /dev/null +++ b/tests/src/test/java/com/example/SwitchPatternMatchingWithGuardOverTypes.java @@ -0,0 +1,91 @@ +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ + +package com.example; + +import com.code_intelligence.jazzer.api.FuzzerSecurityIssueLow; +import com.code_intelligence.jazzer.junit.FuzzTest; +import com.code_intelligence.jazzer.mutation.annotation.NotNull; +import java.util.Objects; + +public class SwitchPatternMatchingWithGuardOverTypes { + public static class Employee { + public String name; + public int age; + + public Employee(String name, int age) { + this.name = name; + this.age = age; + } + + public void setAge(int age) { + this.age = age; + } + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public int getAge() { + return age; + } + } + + public enum Type { + INTEGER_T, + STRING_T, + EMPLOYEE_T, + NULL_T + } + + static SwitchCoverageHelper cov = new SwitchCoverageHelper(4); + + @FuzzTest + public void test( + @NotNull Integer anInt, + @NotNull String aString, + @NotNull Employee anEmployee, + @NotNull Type type) { + if (cov.allBranchesCovered()) { + throw new FuzzerSecurityIssueLow("All cases visited"); + } + Object inp = + switch (type) { + case INTEGER_T -> anInt; + case STRING_T -> aString; + case EMPLOYEE_T -> anEmployee; + case NULL_T -> null; + }; + + int ignored = + switch (inp) { + case Integer i -> { + cov.coverCase(0); + yield 0; + } + case String s -> { + cov.coverCase(1); + yield 1; + } + case Employee e when Objects.equals(e.name, "Robot 001") -> { + cov.coverCase(2); + yield 2; + } + case null -> { + cov.coverCase(3); + yield 3; + } + default -> -10; + }; + } +} diff --git a/tests/src/test/java/com/example/SwitchStatementOnIntegersFuzzer.java b/tests/src/test/java/com/example/SwitchStatementOnIntegersFuzzer.java new file mode 100644 index 000000000..2421ea2ff --- /dev/null +++ b/tests/src/test/java/com/example/SwitchStatementOnIntegersFuzzer.java @@ -0,0 +1,49 @@ +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ + +package com.example; + +import com.code_intelligence.jazzer.api.FuzzerSecurityIssueLow; +import com.code_intelligence.jazzer.junit.FuzzTest; + +public class SwitchStatementOnIntegersFuzzer { + private static SwitchCoverageHelper cov = new SwitchCoverageHelper(5); + + @FuzzTest + public void test(int data) { + if (cov.allBranchesCovered()) { + throw new FuzzerSecurityIssueLow("All cases visited"); + } + + int ignored = + switch (data) { + case 19391 -> { + cov.coverCase(0); + yield 0; + } + case 1101010 -> { + cov.coverCase(1); + yield 1; + } + case 23202020 -> { + cov.coverCase(2); + yield 2; + } + case 333003033 -> { + cov.coverCase(3); + yield 3; + } + case 429102931 -> { + cov.coverCase(4); + yield 4; + } + default -> -10; + }; + } +} diff --git a/tests/src/test/java/com/example/SwitchStatementOnStringsFuzzer.java b/tests/src/test/java/com/example/SwitchStatementOnStringsFuzzer.java new file mode 100644 index 000000000..20fabb4d5 --- /dev/null +++ b/tests/src/test/java/com/example/SwitchStatementOnStringsFuzzer.java @@ -0,0 +1,45 @@ +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ + +package com.example; + +import com.code_intelligence.jazzer.api.FuzzerSecurityIssueLow; +import com.code_intelligence.jazzer.junit.FuzzTest; +import com.code_intelligence.jazzer.mutation.annotation.NotNull; + +public class SwitchStatementOnStringsFuzzer { + static SwitchCoverageHelper cov = new SwitchCoverageHelper(4); + + @FuzzTest + public void test(@NotNull String data) { + if (cov.allBranchesCovered()) { + throw new FuzzerSecurityIssueLow("All cases visited"); + } + int ignored = + switch (data) { + case "The Road goes ever on and on" -> { + cov.coverCase(0); + yield 0; + } + case "Out from the door where it began." -> { + cov.coverCase(1); + yield 1; + } + case "Now far ahead the Road has gone," -> { + cov.coverCase(2); + yield 2; + } + case "Let others follow it who can!" -> { + cov.coverCase(3); + yield 3; + } + default -> -100; + }; + } +} diff --git a/tests/src/test/java/com/example/TestMethodInManifestFuzzer.java b/tests/src/test/java/com/example/TestMethodInManifestFuzzer.java index 48b0a7e75..56bbd1b95 100644 --- a/tests/src/test/java/com/example/TestMethodInManifestFuzzer.java +++ b/tests/src/test/java/com/example/TestMethodInManifestFuzzer.java @@ -1,17 +1,10 @@ /* - * Copyright 2023 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.example; diff --git a/tests/src/test/java/com/example/TimeoutFuzzer.java b/tests/src/test/java/com/example/TimeoutFuzzer.java index 13bf8c0ab..5675edc7d 100644 --- a/tests/src/test/java/com/example/TimeoutFuzzer.java +++ b/tests/src/test/java/com/example/TimeoutFuzzer.java @@ -1,17 +1,10 @@ /* - * Copyright 2022 Code Intelligence GmbH + * Copyright 2024 Code Intelligence GmbH * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. */ package com.example; diff --git a/tests/src/test/java/com/example/TimeoutTest.java b/tests/src/test/java/com/example/TimeoutTest.java new file mode 100644 index 000000000..897e2170f --- /dev/null +++ b/tests/src/test/java/com/example/TimeoutTest.java @@ -0,0 +1,40 @@ +/* + * Copyright 2024 Code Intelligence GmbH + * + * By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. + * + * The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt + * located in the root directory of the project. + */ + +package com.example; + +import com.code_intelligence.jazzer.junit.FuzzTest; +import java.util.concurrent.TimeUnit; +import org.junit.jupiter.api.Timeout; + +public class TimeoutTest { + + @FuzzTest + @Timeout(5) + @SuppressWarnings("InfiniteLoopStatement") + public void timeout(String ignored) throws InterruptedException { + while (true) { + // JUnit supports different thread modes in the timeout context, see + // https://junit.org/junit5/docs/current/user-guide/#writing-tests-declarative-timeouts-thread-mode + // + // As a result it can not detect infinite busy loops in the default thread mode. + // For this it would be necessary to switch the thread mode from SAME_THREAD to + // SEPARATE_THREAD, so that the second thread could detect timeout in the first one executing + // the actual test. It is possible to detect timeouts in "not busy" infinite loops, though. + // These release their possession of a thread via JVM concurrency functions, e.g. sleep, wait, + // etc. + // + // This differs from fuzzing mode, in which JUnit timeout handling is deactivated and timeouts + // are solely handled by libFuzzer. libFuzzer registers reoccurring alarm handlers to detect + // timeouts in the fuzzer process. This approach is comparable to the SEPARATE_THREAD mode in + // JUnit. + TimeUnit.SECONDS.sleep(1); + } + } +} diff --git a/tests/src/test/native/com/example/BUILD.bazel b/tests/src/test/native/com/example/BUILD.bazel index 80657364b..76c688020 100644 --- a/tests/src/test/native/com/example/BUILD.bazel +++ b/tests/src/test/native/com/example/BUILD.bazel @@ -1,4 +1,4 @@ -load("@fmeum_rules_jni//jni:defs.bzl", "cc_jni_library") +load("@rules_jni//jni:defs.bzl", "cc_jni_library") load("//bazel:compat.bzl", "SKIP_ON_WINDOWS") cc_jni_library( diff --git a/tests/src/test/native/com/example/native_value_profile_fuzzer.cpp b/tests/src/test/native/com/example/native_value_profile_fuzzer.cpp index 2edcc269e..1b182277b 100644 --- a/tests/src/test/native/com/example/native_value_profile_fuzzer.cpp +++ b/tests/src/test/native/com/example/native_value_profile_fuzzer.cpp @@ -1,16 +1,10 @@ -// Copyright 2022 Code Intelligence GmbH +// Copyright 2024 Code Intelligence GmbH // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// By downloading, you agree to the Code Intelligence Jazzer Terms and +// Conditions. // -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// The Code Intelligence Jazzer Terms and Conditions are provided in +// LICENSE-JAZZER.txt located in the root directory of the project. #include #include diff --git a/tests/src/test/proto/simple_proto.proto b/tests/src/test/proto/simple_proto.proto index b8c10e370..cbbfc354b 100644 --- a/tests/src/test/proto/simple_proto.proto +++ b/tests/src/test/proto/simple_proto.proto @@ -1,16 +1,11 @@ -// Copyright 2023 Code Intelligence GmbH // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// Copyright 2024 Code Intelligence GmbH // -// http://www.apache.org/licenses/LICENSE-2.0 +// By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. +// +// The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt +// located in the root directory of the project. // -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. syntax = "proto3"; diff --git a/tests/src/test/shell/crash_resistant_coverage_test.sh b/tests/src/test/shell/crash_resistant_coverage_test.sh index f7fe281c2..aed46c7fa 100755 --- a/tests/src/test/shell/crash_resistant_coverage_test.sh +++ b/tests/src/test/shell/crash_resistant_coverage_test.sh @@ -1,17 +1,14 @@ #!/bin/bash -# Copyright 2022 Code Intelligence GmbH # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Copyright 2024 Code Intelligence GmbH # -# http://www.apache.org/licenses/LICENSE-2.0 +# By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. +# +# The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt +# located in the root directory of the project. +# +# This file also contains code licensed under Apache2 license. # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. # This test verifies that Jazzer's --nohook mode can be used to measure code coverage using the # JaCoCo agent. @@ -70,6 +67,7 @@ grep -o -P ' tag - (?:[^<]|<[^\/]).* matches everything but between the two. # Similarly, verify that isn't covered as the default constructor is never invoked. -grep -q -P '\Q\E(?:[^<]|<[^\/])*\Q\E' "$xml_report" && fail " has been covered" -grep -q -P '\Q\E(?:[^<]|<[^\/])*\Q\E' "$xml_report" || fail "fuzzerTestOneInput hasn't been covered" -grep -q -P '\Q\E(?:[^<]|<[^\/])*\Q\E' "$xml_report" || fail "someFunction hasn't been covered" +cat "$xml_report" +grep -q -P '\Q\E(?:[^<]|<[^\/])*\Q\E' "$xml_report" || fail " has been covered" +grep -q -P '\Q\E(?:[^<]|<[^\/])*\Q\E' "$xml_report" || fail "fuzzerTestOneInput hasn't been covered" +grep -q -P '\Q\E(?:[^<]|<[^\/])*\Q\E' "$xml_report" || fail "someFunction hasn't been covered" diff --git a/tests/src/test/shell/fuzz_test_lister_test.sh b/tests/src/test/shell/fuzz_test_lister_test.sh new file mode 100755 index 000000000..70663256c --- /dev/null +++ b/tests/src/test/shell/fuzz_test_lister_test.sh @@ -0,0 +1,55 @@ +#!/bin/bash +# +# Copyright 2024 Code Intelligence GmbH +# +# By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. +# +# The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt +# located in the root directory of the project. +# + +set -euf -o pipefail + +# --- begin runfiles.bash initialization v2 --- +# Copy-pasted from the Bazel Bash runfiles library v2. +set -uo pipefail; f=bazel_tools/tools/bash/runfiles/runfiles.bash +source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ + source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \ + source "$0.runfiles/$f" 2>/dev/null || \ + source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ + source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ + { echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e +# --- end runfiles.bash initialization v2 --- + +function fail() { + echo "FAILED: $1" + exit 1 +} + +java_rlocationpath=$(echo "$JAVA_EXECPATH" | cut -d/ -f2-) +java=$(rlocation "$java_rlocationpath") +jazzer=$(rlocation "$1") +jazzer_junit=$(rlocation "$2") +classes=$(rlocation "$3") +junit_api=$(rlocation "$4") +junit_engine=$(rlocation "$5") +junit_params=$(rlocation "$6") +junit_platform_commons=$(rlocation "$7") +junit_platform_engine=$(rlocation "$8") +junit_platform_launcher=$(rlocation "$9") + +# Copy classes directory as JUnit does not handle symlinks properly. +cp -rL "$classes" "$TEST_TMPDIR" +classes_dir="$TEST_TMPDIR/fuzz_test_lister_test" + +stderr="$TEST_TMPDIR/stderr" +$java \ + -cp $jazzer:$jazzer_junit:$classes_dir:$junit_api:$junit_params:$junit_engine:$junit_platform_commons:$junit_platform_engine:$junit_platform_launcher \ + com.code_intelligence.jazzer.Jazzer \ + --list_fuzz_tests= \ + --target_class=should.be.ignored \ + 2>&1 \ + | tee "$stderr" || fail "Jazzer did not exit with exit code 0" + +[[ $(grep -c "org.example.FuzzTests::fuzz1" "$stderr") == 1 ]] || fail "Could not find \"fuzz1\"" +[[ $(grep -c "org.example.FuzzTests::fuzz2" "$stderr") == 1 ]] || fail "Could not find \"fuzz2\"" diff --git a/tests/src/test/shell/jazzer_from_path_test.sh b/tests/src/test/shell/jazzer_from_path_test.sh index 357fde680..2d6966136 100755 --- a/tests/src/test/shell/jazzer_from_path_test.sh +++ b/tests/src/test/shell/jazzer_from_path_test.sh @@ -1,17 +1,12 @@ #!/bin/bash -# Copyright 2022 Code Intelligence GmbH # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Copyright 2024 Code Intelligence GmbH # -# http://www.apache.org/licenses/LICENSE-2.0 +# By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. +# +# The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt +# located in the root directory of the project. # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. # Verify that the Jazzer launcher finds the jar when executed from PATH. diff --git a/tests/src/test/shell/junit_agent_configuration_test.sh b/tests/src/test/shell/junit_agent_configuration_test.sh index dd029825f..55e947a44 100755 --- a/tests/src/test/shell/junit_agent_configuration_test.sh +++ b/tests/src/test/shell/junit_agent_configuration_test.sh @@ -1,17 +1,12 @@ #!/bin/bash -# Copyright 2022 Code Intelligence GmbH # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Copyright 2024 Code Intelligence GmbH # -# http://www.apache.org/licenses/LICENSE-2.0 +# By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. +# +# The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt +# located in the root directory of the project. # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. # Verify that instrumentation filter defaults set by @FuzzTest work. diff --git a/third_party/android/android_configure.bzl b/third_party/android/android_configure.bzl index 331189046..f777ebce1 100644 --- a/third_party/android/android_configure.bzl +++ b/third_party/android/android_configure.bzl @@ -1,8 +1,5 @@ """Repository rule for Android SKD and NDK autoconfigure""" -load("@build_bazel_rules_android//android:rules.bzl", "android_sdk_repository") -load("@rules_android_ndk//:rules.bzl", "android_ndk_repository") - _ANDROID_SDK_HOME = "ANDROID_HOME" _ANDROID_NDK_HOME = "ANDROID_NDK_HOME" @@ -41,7 +38,7 @@ def _android_autoconf_impl(repository_ctx): repository_ctx.file("BUILD.bazel", "") repository_ctx.file("android_configure.bzl", """ -load("@build_bazel_rules_android//android:rules.bzl", "android_sdk_repository") +load("@rules_android//android:rules.bzl", "android_sdk_repository") load("@rules_android_ndk//:rules.bzl", "android_ndk_repository") def android_workspace(): diff --git a/third_party/classgraph.BUILD b/third_party/classgraph.BUILD deleted file mode 100644 index ab51f11c7..000000000 --- a/third_party/classgraph.BUILD +++ /dev/null @@ -1,8 +0,0 @@ -java_library( - name = "classgraph", - srcs = glob([ - "src/main/java/io/github/classgraph/**/*.java", - "src/main/java/nonapi/io/github/classgraph/**/*.java", - ]), - visibility = ["//visibility:public"], -) diff --git a/third_party/jacoco_internal.BUILD b/third_party/jacoco_internal.BUILD index 72669be4c..db020cd0a 100644 --- a/third_party/jacoco_internal.BUILD +++ b/third_party/jacoco_internal.BUILD @@ -1,13 +1,13 @@ -load("@com_github_johnynek_bazel_jar_jar//:jar_jar.bzl", "jar_jar") +load("@bazel_jar_jar//:jar_jar.bzl", "jar_jar") java_import( name = "jacoco_internal", jars = ["jacoco_internal_shaded.jar"], visibility = ["//visibility:public"], deps = [ - "@org_ow2_asm_asm//jar", - "@org_ow2_asm_asm_commons//jar", - "@org_ow2_asm_asm_tree//jar", + "@maven//:org_ow2_asm_asm", + "@maven//:org_ow2_asm_asm_commons", + "@maven//:org_ow2_asm_asm_tree", ], ) @@ -30,8 +30,8 @@ java_library( "org.jacoco.core/src/org/jacoco/core/**/*.properties", ]), deps = [ - "@org_ow2_asm_asm//jar", - "@org_ow2_asm_asm_commons//jar", - "@org_ow2_asm_asm_tree//jar", + "@maven//:org_ow2_asm_asm", + "@maven//:org_ow2_asm_asm_commons", + "@maven//:org_ow2_asm_asm_tree", ], ) diff --git a/third_party/jdk_8.bzl b/third_party/jdk_8.bzl new file mode 100644 index 000000000..88f8ec0d5 --- /dev/null +++ b/third_party/jdk_8.bzl @@ -0,0 +1,66 @@ +# +# Copyright 2024 Code Intelligence GmbH +# +# By downloading, you agree to the Code Intelligence Jazzer Terms and Conditions. +# +# The Code Intelligence Jazzer Terms and Conditions are provided in LICENSE-JAZZER.txt +# located in the root directory of the project. +# + +load("@rules_java//toolchains:remote_java_repository.bzl", "remote_java_repository") + +def _remote_jdk8_repos(_): + remote_java_repository( + name = "remote_jdk8_linux", + target_compatible_with = [ + "@platforms//os:linux", + "@platforms//cpu:x86_64", + ], + sha256 = "39dc809ef8e88eff49d2eaeb48580729888486d56d846559b719da9c545e2884", + strip_prefix = "zulu8.74.0.17-ca-jdk8.0.392-linux_x64", + urls = [ + "https://cdn.azul.com/zulu/bin/zulu8.74.0.17-ca-jdk8.0.392-linux_x64.tar.gz", + ], + version = "8", + ) + remote_java_repository( + name = "remote_jdk8_macos_aarch64", + target_compatible_with = [ + "@platforms//os:macos", + "@platforms//cpu:aarch64", + ], + sha256 = "51b5187e3d50fd469a67c4a9e2e816cb14e6247a51a24d8a96b88d2bdc512714", + strip_prefix = "zulu8.74.0.17-ca-jdk8.0.392-macosx_aarch64", + urls = [ + "https://cdn.azul.com/zulu/bin/zulu8.74.0.17-ca-jdk8.0.392-macosx_aarch64.tar.gz", + ], + version = "8", + ) + remote_java_repository( + name = "remote_jdk8_macos", + target_compatible_with = [ + "@platforms//os:macos", + "@platforms//cpu:x86_64", + ], + sha256 = "ab29ecd51033c8804cd0711c225266c3b757518c90040cb279e329bf1eb9b387", + strip_prefix = "zulu8.74.0.17-ca-jdk8.0.392-macosx_x64", + urls = [ + "https://cdn.azul.com/zulu/bin/zulu8.74.0.17-ca-jdk8.0.392-macosx_x64.tar.gz", + ], + version = "8", + ) + remote_java_repository( + name = "remote_jdk8_windows", + target_compatible_with = [ + "@platforms//os:windows", + "@platforms//cpu:x86_64", + ], + sha256 = "3ba91c758ca93c527983ed3f409ee504c6fc33e0a697672db9c959abba10e38d", + strip_prefix = "zulu8.74.0.17-ca-jdk8.0.392-win_x64", + urls = [ + "https://cdn.azul.com/zulu/bin/zulu8.74.0.17-ca-jdk8.0.392-win_x64.zip", + ], + version = "8", + ) + +remote_jdk8_repos = module_extension(_remote_jdk8_repos) diff --git a/third_party/libjpeg_turbo.BUILD b/third_party/libjpeg_turbo.BUILD index e140bc079..a44a04eea 100644 --- a/third_party/libjpeg_turbo.BUILD +++ b/third_party/libjpeg_turbo.BUILD @@ -39,7 +39,7 @@ cmake( ], deps = [ ":libawt", - "@fmeum_rules_jni//jni", + "@rules_jni//jni", ], ) diff --git a/third_party/protobuf-disable-layering_check.patch b/third_party/protobuf-disable-layering_check.patch index 76c7ca8e9..c16b44a34 100644 --- a/third_party/protobuf-disable-layering_check.patch +++ b/third_party/protobuf-disable-layering_check.patch @@ -1,129 +1,29 @@ -commit 0cb6965869ab94858d9b843ab5d94f7deaea5dc8 -Author: Fabian Meumertzheim -Date: Mon Jun 12 16:12:02 2023 +0200 +From f4444a81218ede5eb58306bd57eaefb5d9ffd9e2 Mon Sep 17 00:00:00 2001 +From: Fabian Meumertzheim +Date: Mon, 8 Jan 2024 13:30:32 +0100 +Subject: [PATCH] Disable unsupported `layering_check` Bazel feature - Disable layering_check - - protobuf misses a sizeable number of dependency declarations, which - means that `layering_check` has to be disabled for it. - - Generated with: - ``` - buildozer 'add features -layering_check' //src/...:__pkg__ - ``` - - Contains only the changes to `package` directives. +This allows downstream projects to use `layering_check` without having +to patch Protobuf to disable the feature for the repository. +--- + REPO.bazel | 11 +++++++++++ + 1 file changed, 11 insertions(+) + create mode 100644 REPO.bazel -diff --git src/BUILD.bazel src/BUILD.bazel -index 0de1a4eb1..b7e405147 100644 ---- src/BUILD.bazel -+++ src/BUILD.bazel -@@ -7,6 +7,8 @@ load("@rules_pkg//:mappings.bzl", "pkg_filegroup", "pkg_files", "strip_prefix") - load("@upb//cmake:build_defs.bzl", "staleness_test") - load("//conformance:defs.bzl", "conformance_test") - -+package(features = ["-layering_check"]) -+ - pkg_files( - name = "dist_files", - srcs = glob(["**"]), -diff --git src/google/protobuf/BUILD.bazel src/google/protobuf/BUILD.bazel -index 77ed2309f..8c38fb872 100644 ---- src/google/protobuf/BUILD.bazel -+++ src/google/protobuf/BUILD.bazel -@@ -13,6 +13,7 @@ package( - "//:__pkg__", # "public" targets are alias rules in //. - "//json:__subpackages__", - ], -+ features = ["-layering_check"], - ) - - proto_library( -diff --git src/google/protobuf/compiler/BUILD.bazel src/google/protobuf/compiler/BUILD.bazel -index 9b4c243d1..e258c7298 100644 ---- src/google/protobuf/compiler/BUILD.bazel -+++ src/google/protobuf/compiler/BUILD.bazel -@@ -14,6 +14,8 @@ load("//build_defs:arch_tests.bzl", "aarch64_test", "x86_64_test") - load("//build_defs:cpp_opts.bzl", "COPTS") - load("test_plugin_injection.bzl", "inject_plugin_paths") - -+package(features = ["-layering_check"]) -+ - proto_library( - name = "plugin_proto", - srcs = ["plugin.proto"], -diff --git src/google/protobuf/io/BUILD.bazel src/google/protobuf/io/BUILD.bazel -index 8f39625c2..fc2f8e002 100644 ---- src/google/protobuf/io/BUILD.bazel -+++ src/google/protobuf/io/BUILD.bazel -@@ -6,6 +6,7 @@ load("//build_defs:cpp_opts.bzl", "COPTS") - - package( - default_visibility = ["//visibility:public"], -+ features = ["-layering_check"], - ) - - cc_library( -diff --git src/google/protobuf/json/BUILD.bazel src/google/protobuf/json/BUILD.bazel -index d6019f939..83caca985 100644 ---- src/google/protobuf/json/BUILD.bazel -+++ src/google/protobuf/json/BUILD.bazel -@@ -1,10 +1,13 @@ - load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") - load("//build_defs:cpp_opts.bzl", "COPTS") - --package(default_visibility = [ -- "//pkg:__pkg__", -- "//src/google/protobuf/json:__pkg__", --]) -+package( -+ default_visibility = [ -+ "//pkg:__pkg__", -+ "//src/google/protobuf/json:__pkg__", +diff --git a/REPO.bazel b/REPO.bazel +new file mode 100644 +index 00000000000..a537ac745fa +--- /dev/null ++++ b/REPO.bazel +@@ -0,0 +1,11 @@ ++# This file is read by Bazel 7 and newer, both if Protobuf is the main ++# repository and if it is an external repository. ++repo( ++ features = [ ++ # Protobuf cc_* targets do not specify all dependencies from which they ++ # include headers. This causes builds of downstream projects with ++ # --feature=layering_check to fail, which can be avoided by disabling ++ # the feature for the entire repository. ++ "-layering_check", + ], -+ features = ["-layering_check"], -+) - - licenses(["notice"]) - -diff --git src/google/protobuf/stubs/BUILD.bazel src/google/protobuf/stubs/BUILD.bazel -index c8fc3e9d0..9521f5103 100644 ---- src/google/protobuf/stubs/BUILD.bazel -+++ src/google/protobuf/stubs/BUILD.bazel -@@ -7,6 +7,7 @@ load("//build_defs:cpp_opts.bzl", "COPTS", "LINK_OPTS") - - package( - default_visibility = ["//:__subpackages__"], -+ features = ["-layering_check"], - ) - - cc_library( -diff --git src/google/protobuf/testing/BUILD.bazel src/google/protobuf/testing/BUILD.bazel -index 572c1f9f4..d10435cce 100644 ---- src/google/protobuf/testing/BUILD.bazel -+++ src/google/protobuf/testing/BUILD.bazel -@@ -5,7 +5,10 @@ load("@rules_cc//cc:defs.bzl", "cc_library") - load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix") - load("//build_defs:cpp_opts.bzl", "COPTS", "LINK_OPTS") - --package(default_visibility = ["//:__subpackages__"]) -+package( -+ default_visibility = ["//:__subpackages__"], -+ features = ["-layering_check"], +) - - cc_library( - name = "testing", -diff --git src/google/protobuf/util/BUILD.bazel src/google/protobuf/util/BUILD.bazel -index 3afe464cf..03a3045b3 100644 ---- src/google/protobuf/util/BUILD.bazel -+++ src/google/protobuf/util/BUILD.bazel -@@ -7,6 +7,8 @@ load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix") - load("@rules_proto//proto:defs.bzl", "proto_library") - load("//build_defs:cpp_opts.bzl", "COPTS") - -+package(features = ["-layering_check"]) -+ - cc_library( - name = "delimited_message_util", - srcs = ["delimited_message_util.cc"], diff --git a/third_party/typetools.BUILD b/third_party/typetools.BUILD deleted file mode 100644 index f94fb0dc8..000000000 --- a/third_party/typetools.BUILD +++ /dev/null @@ -1,7 +0,0 @@ -java_library( - name = "typetools", - srcs = glob([ - "src/main/java/net/jodah/typetools/*.java", - ]), - visibility = ["//visibility:public"], -)