Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/affected_fuzz_targets_test.py +113 -0
- local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/base_runner_utils.py +33 -0
- local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/build_fuzzers.py +217 -0
- local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/cifuzz-base/Dockerfile +44 -0
- local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/cifuzz_combined_entrypoint.py +40 -0
- local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/cifuzz_end_to_end_test.py +48 -0
- local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/cloudbuild.yaml +52 -0
- local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/clusterfuzz_deployment_test.py +268 -0
- local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/config_utils.py +283 -0
- local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/config_utils_test.py +200 -0
- local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/docker_test.py +119 -0
- local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/example_cifuzz.yml +33 -0
- local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/external-actions/run_fuzzers/action.yml +97 -0
- local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/filestore/git/git_test.py +122 -0
- local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/filestore/github_actions/github_actions_test.py +283 -0
- local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/filestore/github_actions/github_api.py +109 -0
- local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/filestore/github_actions/github_api_test.py +41 -0
- local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/filestore/no_filestore/__init__.py +51 -0
- local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/filestore_utils_test.py +50 -0
- local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/fuzz_target_test.py +298 -0
- local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/generate_coverage_report.py +48 -0
- local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/generate_coverage_report_test.py +71 -0
- local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/get_coverage.py +208 -0
- local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/get_coverage_test.py +253 -0
- local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/http_utils.py +118 -0
- local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/platform_config/__init__.py +124 -0
- local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/platform_config/gcb.py +40 -0
- local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/platform_config/github.py +146 -0
- local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/platform_config/github_test.py +87 -0
- local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/platform_config/gitlab.py +78 -0
- local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/platform_config/platform_config_test.py +82 -0
- local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/platform_config/prow.py +64 -0
- local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/platform_config/standalone.py +33 -0
- local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/run_fuzzers.py +321 -0
- local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/test_data/TimeoutFuzzer.cpp +36 -0
- local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/test_data/example_crash_fuzzer_bug_summary.txt +68 -0
- local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/test_data/example_crash_fuzzer_output.txt +202 -0
- local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/test_data/msan_crash_fuzzer_bug_summary.txt +22 -0
- local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/test_data/msan_crash_fuzzer_output.txt +39 -0
- local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/test_data/sarif_utils_msan_stack.txt +62 -0
- local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/test_data/sarif_utils_only_llvmfuzzer_stack.txt +302 -0
- local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/test_data/sarif_utils_systemd_stack.txt +302 -0
- local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/experimental/SystemSan/Makefile +41 -0
- local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/experimental/SystemSan/PoEs/node-shell-quote-v1.7.3/Dockerfile +35 -0
- local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/experimental/SystemSan/PoEs/node-shell-quote-v1.7.3/Makefile +12 -0
- local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/experimental/SystemSan/PoEs/node-shell-quote-v1.7.3/build.sh +22 -0
- local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/experimental/SystemSan/PoEs/node-shell-quote-v1.7.3/target.js +35 -0
- local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/experimental/SystemSan/PoEs/pytorch-lightning-1.5.10/Dockerfile +32 -0
- local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/experimental/SystemSan/PoEs/pytorch-lightning-1.5.10/Makefile +12 -0
- local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/experimental/SystemSan/PoEs/pytorch-lightning-1.5.10/build.sh +25 -0
local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/affected_fuzz_targets_test.py
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2021 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
"""Tests for affected_fuzz_targets.py"""
|
| 15 |
+
import os
|
| 16 |
+
import shutil
|
| 17 |
+
import tempfile
|
| 18 |
+
import unittest
|
| 19 |
+
from unittest import mock
|
| 20 |
+
|
| 21 |
+
import parameterized
|
| 22 |
+
|
| 23 |
+
import affected_fuzz_targets
|
| 24 |
+
import clusterfuzz_deployment
|
| 25 |
+
import get_coverage
|
| 26 |
+
import test_helpers
|
| 27 |
+
import workspace_utils
|
| 28 |
+
|
| 29 |
+
# pylint: disable=protected-access
|
| 30 |
+
|
| 31 |
+
# NOTE: This integration test relies on
|
| 32 |
+
# https://github.com/google/oss-fuzz/tree/master/projects/example project.
|
| 33 |
+
EXAMPLE_PROJECT = 'example'
|
| 34 |
+
|
| 35 |
+
EXAMPLE_FILE_CHANGED = 'test.txt'
|
| 36 |
+
|
| 37 |
+
TEST_DATA_OUT_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)),
|
| 38 |
+
'test_data', 'build-out')
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
class RemoveUnaffectedFuzzTargetsTest(unittest.TestCase):
|
| 42 |
+
"""Tests remove_unaffected_fuzzers."""
|
| 43 |
+
|
| 44 |
+
TEST_FUZZER_1 = os.path.join(TEST_DATA_OUT_PATH, 'example_crash_fuzzer')
|
| 45 |
+
TEST_FUZZER_2 = os.path.join(TEST_DATA_OUT_PATH, 'example_nocrash_fuzzer')
|
| 46 |
+
|
| 47 |
+
# yapf: disable
|
| 48 |
+
@parameterized.parameterized.expand([
|
| 49 |
+
# Tests specific affected fuzzers are kept.
|
| 50 |
+
([[EXAMPLE_FILE_CHANGED], None], 2,),
|
| 51 |
+
|
| 52 |
+
# Tests specific affected fuzzer is kept.
|
| 53 |
+
([[EXAMPLE_FILE_CHANGED], ['not/a/real/file']], 1),
|
| 54 |
+
|
| 55 |
+
# Tests all fuzzers are kept if none are deemed affected.
|
| 56 |
+
([None, None], 2),
|
| 57 |
+
|
| 58 |
+
# Tests that multiple fuzzers are kept if multiple fuzzers are affected.
|
| 59 |
+
([[EXAMPLE_FILE_CHANGED], [EXAMPLE_FILE_CHANGED]], 2),
|
| 60 |
+
])
|
| 61 |
+
# yapf: enable
|
| 62 |
+
def test_remove_unaffected_fuzz_targets(self, side_effect, expected_dir_len):
|
| 63 |
+
"""Tests that remove_unaffected_fuzzers has the intended effect."""
|
| 64 |
+
config = test_helpers.create_run_config(
|
| 65 |
+
cfl_platform='github',
|
| 66 |
+
oss_fuzz_project_name=EXAMPLE_PROJECT,
|
| 67 |
+
workspace='/workspace')
|
| 68 |
+
workspace = workspace_utils.Workspace(config)
|
| 69 |
+
deployment = clusterfuzz_deployment.get_clusterfuzz_deployment(
|
| 70 |
+
config, workspace)
|
| 71 |
+
# We can't use fakefs in this test because this test executes
|
| 72 |
+
# utils.is_fuzz_target_local. This function relies on the executable bit
|
| 73 |
+
# being set, which doesn't work properly in fakefs.
|
| 74 |
+
with tempfile.TemporaryDirectory() as tmp_dir, mock.patch(
|
| 75 |
+
'get_coverage.OSSFuzzCoverage.get_files_covered_by_target'
|
| 76 |
+
) as mock_get_files:
|
| 77 |
+
with mock.patch('get_coverage._get_oss_fuzz_fuzzer_stats_dir_url',
|
| 78 |
+
return_value=1):
|
| 79 |
+
mock_get_files.side_effect = side_effect
|
| 80 |
+
shutil.copy(self.TEST_FUZZER_1, tmp_dir)
|
| 81 |
+
shutil.copy(self.TEST_FUZZER_2, tmp_dir)
|
| 82 |
+
|
| 83 |
+
affected_fuzz_targets.remove_unaffected_fuzz_targets(
|
| 84 |
+
deployment, tmp_dir, [EXAMPLE_FILE_CHANGED], '')
|
| 85 |
+
self.assertEqual(expected_dir_len, len(os.listdir(tmp_dir)))
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
class IsFuzzTargetAffectedTest(unittest.TestCase):
|
| 89 |
+
"""Tests for is_fuzz_target_affected."""
|
| 90 |
+
|
| 91 |
+
def setUp(self):
|
| 92 |
+
self.fuzz_target_path = '/fuzz_target'
|
| 93 |
+
|
| 94 |
+
def test_relative_paths(self):
|
| 95 |
+
"""Tests that is_fuzz_target_affected works as intended when the covered
|
| 96 |
+
files are relative paths."""
|
| 97 |
+
with mock.patch.object(
|
| 98 |
+
get_coverage.FilesystemCoverage,
|
| 99 |
+
'get_files_covered_by_target',
|
| 100 |
+
) as get_files_covered_by_target:
|
| 101 |
+
get_files_covered_by_target.return_value = [
|
| 102 |
+
'/work/build/../../src/systemd/src/basic/alloc-util.c'
|
| 103 |
+
]
|
| 104 |
+
coverage = get_coverage.FilesystemCoverage('/', '/')
|
| 105 |
+
|
| 106 |
+
self.assertTrue(
|
| 107 |
+
affected_fuzz_targets.is_fuzz_target_affected(
|
| 108 |
+
coverage, self.fuzz_target_path,
|
| 109 |
+
['/src/systemd/src/basic/alloc-util.c']))
|
| 110 |
+
|
| 111 |
+
|
| 112 |
+
if __name__ == '__main__':
|
| 113 |
+
unittest.main()
|
local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/base_runner_utils.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2021 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
"""Utilities for scripts from ghcr.io/aixcc-finals/base-runner."""
|
| 15 |
+
|
| 16 |
+
import os
|
| 17 |
+
|
| 18 |
+
import config_utils
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def get_env(config, workspace):
|
| 22 |
+
"""Returns a dictionary containing the current environment with additional env
|
| 23 |
+
vars set to values needed to run a fuzzer."""
|
| 24 |
+
env = os.environ.copy()
|
| 25 |
+
env['SANITIZER'] = config.sanitizer
|
| 26 |
+
env['FUZZING_LANGUAGE'] = config.language
|
| 27 |
+
env['OUT'] = workspace.out
|
| 28 |
+
env['CIFUZZ'] = 'True'
|
| 29 |
+
env['FUZZING_ENGINE'] = config_utils.DEFAULT_ENGINE
|
| 30 |
+
env['ARCHITECTURE'] = config.architecture
|
| 31 |
+
# Do this so we don't fail in tests.
|
| 32 |
+
env['FUZZER_ARGS'] = '-rss_limit_mb=2560 -timeout=25'
|
| 33 |
+
return env
|
local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/build_fuzzers.py
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2020 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
"""Module used by CI tools in order to interact with fuzzers. This module helps
|
| 15 |
+
CI tools to build fuzzers."""
|
| 16 |
+
|
| 17 |
+
import logging
|
| 18 |
+
import os
|
| 19 |
+
import sys
|
| 20 |
+
|
| 21 |
+
import affected_fuzz_targets
|
| 22 |
+
import base_runner_utils
|
| 23 |
+
import clusterfuzz_deployment
|
| 24 |
+
import continuous_integration
|
| 25 |
+
import docker
|
| 26 |
+
import logs
|
| 27 |
+
import workspace_utils
|
| 28 |
+
|
| 29 |
+
# pylint: disable=wrong-import-position,import-error
|
| 30 |
+
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
| 31 |
+
import helper
|
| 32 |
+
import utils
|
| 33 |
+
|
| 34 |
+
logs.init()
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
def check_project_src_path(project_src_path):
|
| 38 |
+
"""Returns True if |project_src_path| exists."""
|
| 39 |
+
if not os.path.exists(project_src_path):
|
| 40 |
+
logging.error(
|
| 41 |
+
'PROJECT_SRC_PATH: %s does not exist. '
|
| 42 |
+
'Are you mounting it correctly?', project_src_path)
|
| 43 |
+
return False
|
| 44 |
+
return True
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
# pylint: disable=too-many-arguments
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
class Builder: # pylint: disable=too-many-instance-attributes
|
| 51 |
+
"""Class for fuzzer builders."""
|
| 52 |
+
|
| 53 |
+
def __init__(self, config, ci_system):
|
| 54 |
+
self.config = config
|
| 55 |
+
self.ci_system = ci_system
|
| 56 |
+
self.workspace = workspace_utils.Workspace(config)
|
| 57 |
+
self.workspace.initialize_dir(self.workspace.out)
|
| 58 |
+
self.workspace.initialize_dir(self.workspace.work)
|
| 59 |
+
self.clusterfuzz_deployment = (
|
| 60 |
+
clusterfuzz_deployment.get_clusterfuzz_deployment(
|
| 61 |
+
self.config, self.workspace))
|
| 62 |
+
self.image_repo_path = None
|
| 63 |
+
self.host_repo_path = None
|
| 64 |
+
self.repo_manager = None
|
| 65 |
+
|
| 66 |
+
def build_image_and_checkout_src(self):
|
| 67 |
+
"""Builds the project builder image and checkout source code for the patch
|
| 68 |
+
we want to fuzz (if necessary). Returns True on success."""
|
| 69 |
+
result = self.ci_system.prepare_for_fuzzer_build()
|
| 70 |
+
if not result.success:
|
| 71 |
+
return False
|
| 72 |
+
self.image_repo_path = result.image_repo_path
|
| 73 |
+
self.repo_manager = result.repo_manager
|
| 74 |
+
if self.config.output_sarif:
|
| 75 |
+
self.workspace.make_repo_for_sarif(self.repo_manager)
|
| 76 |
+
logging.info('repo_dir: %s.', self.repo_manager.repo_dir)
|
| 77 |
+
self.host_repo_path = self.repo_manager.repo_dir
|
| 78 |
+
return True
|
| 79 |
+
|
| 80 |
+
def build_fuzzers(self):
|
| 81 |
+
"""Moves the source code we want to fuzz into the project builder and builds
|
| 82 |
+
the fuzzers from that source code. Returns True on success."""
|
| 83 |
+
docker_args, docker_container = docker.get_base_docker_run_args(
|
| 84 |
+
self.workspace, self.config.sanitizer, self.config.language,
|
| 85 |
+
self.config.architecture, self.config.docker_in_docker)
|
| 86 |
+
if not docker_container:
|
| 87 |
+
docker_args.extend(
|
| 88 |
+
_get_docker_build_fuzzers_args_not_container(self.host_repo_path))
|
| 89 |
+
|
| 90 |
+
build_command = self.ci_system.get_build_command(self.host_repo_path,
|
| 91 |
+
self.image_repo_path)
|
| 92 |
+
|
| 93 |
+
# Set extra environment variables so that they are visible to the build.
|
| 94 |
+
for key in self.config.extra_environment_variables:
|
| 95 |
+
# Don't specify their value in case they get echoed.
|
| 96 |
+
docker_args.extend(['-e', key])
|
| 97 |
+
|
| 98 |
+
docker_args.extend([
|
| 99 |
+
docker.get_project_image_name(self.config.oss_fuzz_project_name),
|
| 100 |
+
'/bin/bash',
|
| 101 |
+
'-c',
|
| 102 |
+
build_command,
|
| 103 |
+
])
|
| 104 |
+
logging.info('Building with %s sanitizer.', self.config.sanitizer)
|
| 105 |
+
|
| 106 |
+
# TODO(metzman): Stop using helper.docker_run so we can get rid of
|
| 107 |
+
# docker.get_base_docker_run_args and merge its contents into
|
| 108 |
+
# docker.get_base_docker_run_command.
|
| 109 |
+
if not helper.docker_run(docker_args):
|
| 110 |
+
logging.error('Building fuzzers failed.')
|
| 111 |
+
return False
|
| 112 |
+
|
| 113 |
+
return True
|
| 114 |
+
|
| 115 |
+
def upload_build(self):
|
| 116 |
+
"""Upload build."""
|
| 117 |
+
if self.config.upload_build:
|
| 118 |
+
self.clusterfuzz_deployment.upload_build(
|
| 119 |
+
self.repo_manager.get_current_commit())
|
| 120 |
+
|
| 121 |
+
return True
|
| 122 |
+
|
| 123 |
+
def check_fuzzer_build(self):
|
| 124 |
+
"""Checks the fuzzer build. Returns True on success or if config specifies
|
| 125 |
+
to skip check."""
|
| 126 |
+
if not self.config.bad_build_check:
|
| 127 |
+
return True
|
| 128 |
+
|
| 129 |
+
return check_fuzzer_build(self.config)
|
| 130 |
+
|
| 131 |
+
def build(self):
|
| 132 |
+
"""Builds the image, checkouts the source (if needed), builds the fuzzers
|
| 133 |
+
and then removes the unaffectted fuzzers. Returns True on success."""
|
| 134 |
+
methods = [
|
| 135 |
+
self.build_image_and_checkout_src,
|
| 136 |
+
self.build_fuzzers,
|
| 137 |
+
self.remove_unaffected_fuzz_targets,
|
| 138 |
+
self.upload_build,
|
| 139 |
+
self.check_fuzzer_build,
|
| 140 |
+
]
|
| 141 |
+
for method in methods:
|
| 142 |
+
if not method():
|
| 143 |
+
return False
|
| 144 |
+
return True
|
| 145 |
+
|
| 146 |
+
def remove_unaffected_fuzz_targets(self):
|
| 147 |
+
"""Removes the fuzzers unaffected by the patch."""
|
| 148 |
+
if self.config.keep_unaffected_fuzz_targets:
|
| 149 |
+
logging.info('Not removing unaffected fuzz targets.')
|
| 150 |
+
return True
|
| 151 |
+
|
| 152 |
+
logging.info('Removing unaffected fuzz targets.')
|
| 153 |
+
changed_files = self.ci_system.get_changed_code_under_test(
|
| 154 |
+
self.repo_manager)
|
| 155 |
+
affected_fuzz_targets.remove_unaffected_fuzz_targets(
|
| 156 |
+
self.clusterfuzz_deployment, self.workspace.out, changed_files,
|
| 157 |
+
self.image_repo_path)
|
| 158 |
+
return True
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
def build_fuzzers(config):
|
| 162 |
+
"""Builds all of the fuzzers for a specific OSS-Fuzz project.
|
| 163 |
+
|
| 164 |
+
Args:
|
| 165 |
+
config: The configuration object for building fuzzers.
|
| 166 |
+
|
| 167 |
+
Returns:
|
| 168 |
+
True if build succeeded.
|
| 169 |
+
"""
|
| 170 |
+
# Do some quick validation.
|
| 171 |
+
if config.project_src_path and not check_project_src_path(
|
| 172 |
+
config.project_src_path):
|
| 173 |
+
return False
|
| 174 |
+
|
| 175 |
+
# Get the builder and then build the fuzzers.
|
| 176 |
+
ci_system = continuous_integration.get_ci(config)
|
| 177 |
+
logging.info('ci_system: %s.', ci_system)
|
| 178 |
+
builder = Builder(config, ci_system)
|
| 179 |
+
return builder.build()
|
| 180 |
+
|
| 181 |
+
|
| 182 |
+
def check_fuzzer_build(config):
|
| 183 |
+
"""Checks the integrity of the built fuzzers.
|
| 184 |
+
|
| 185 |
+
Args:
|
| 186 |
+
config: The config object.
|
| 187 |
+
|
| 188 |
+
Returns:
|
| 189 |
+
True if fuzzers pass OSS-Fuzz's build check.
|
| 190 |
+
"""
|
| 191 |
+
workspace = workspace_utils.Workspace(config)
|
| 192 |
+
if not os.path.exists(workspace.out):
|
| 193 |
+
logging.error('Invalid out directory: %s.', workspace.out)
|
| 194 |
+
return False
|
| 195 |
+
if not os.listdir(workspace.out):
|
| 196 |
+
logging.error('No fuzzers found in out directory: %s.', workspace.out)
|
| 197 |
+
return False
|
| 198 |
+
|
| 199 |
+
env = base_runner_utils.get_env(config, workspace)
|
| 200 |
+
if config.allowed_broken_targets_percentage is not None:
|
| 201 |
+
env['ALLOWED_BROKEN_TARGETS_PERCENTAGE'] = (
|
| 202 |
+
config.allowed_broken_targets_percentage)
|
| 203 |
+
|
| 204 |
+
stdout, stderr, retcode = utils.execute('test_all.py', env=env)
|
| 205 |
+
print(f'Build check: stdout: {stdout}\nstderr: {stderr}')
|
| 206 |
+
if retcode == 0:
|
| 207 |
+
logging.info('Build check passed.')
|
| 208 |
+
return True
|
| 209 |
+
logging.error('Build check failed.')
|
| 210 |
+
return False
|
| 211 |
+
|
| 212 |
+
|
| 213 |
+
def _get_docker_build_fuzzers_args_not_container(host_repo_path):
|
| 214 |
+
"""Returns arguments to the docker build arguments that are needed to use
|
| 215 |
+
|host_repo_path| when the host of the OSS-Fuzz builder container is not
|
| 216 |
+
another container."""
|
| 217 |
+
return ['-v', f'{host_repo_path}:{host_repo_path}']
|
local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/cifuzz-base/Dockerfile
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2020 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
#
|
| 15 |
+
################################################################################
|
| 16 |
+
|
| 17 |
+
FROM ghcr.io/aixcc-finals/base-runner
|
| 18 |
+
|
| 19 |
+
RUN apt-get update && \
|
| 20 |
+
apt-get install -y systemd && \
|
| 21 |
+
wget https://download.docker.com/linux/ubuntu/dists/focal/pool/stable/amd64/docker-ce-cli_20.10.8~3-0~ubuntu-focal_amd64.deb -O /tmp/docker-ce.deb && \
|
| 22 |
+
dpkg -i /tmp/docker-ce.deb && \
|
| 23 |
+
rm /tmp/docker-ce.deb
|
| 24 |
+
|
| 25 |
+
ENV PATH=/opt/gcloud/google-cloud-sdk/bin/:$PATH
|
| 26 |
+
ENV OSS_FUZZ_ROOT=/opt/oss-fuzz
|
| 27 |
+
|
| 28 |
+
# Do this step before copying to make rebuilding faster when developing.
|
| 29 |
+
COPY ./infra/cifuzz/requirements.txt /tmp/requirements.txt
|
| 30 |
+
RUN python3 -m pip install -r /tmp/requirements.txt && rm /tmp/requirements.txt
|
| 31 |
+
|
| 32 |
+
ADD . ${OSS_FUZZ_ROOT}
|
| 33 |
+
# Don't use the default npm location since jazzer.js can break us.
|
| 34 |
+
# This means javascript needed by cifuzz/clusterfuzzlite must be executed in
|
| 35 |
+
# OSS_FUZZ_ROOT.
|
| 36 |
+
RUN cd ${OSS_FUZZ_ROOT} && npm install ${OSS_FUZZ_ROOT}/infra/cifuzz
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
ENV PYTHONUNBUFFERED=1
|
| 40 |
+
|
| 41 |
+
# Python file to execute when the docker container starts up.
|
| 42 |
+
# We can't use the env var $OSS_FUZZ_ROOT here. Since it's a constant env var,
|
| 43 |
+
# just expand to '/opt/oss-fuzz'.
|
| 44 |
+
ENTRYPOINT ["python3", "/opt/oss-fuzz/infra/cifuzz/cifuzz_combined_entrypoint.py"]
|
local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/cifuzz_combined_entrypoint.py
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2021 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
"""Builds fuzzers and runs fuzzers. Entrypoint used for external users"""
|
| 15 |
+
import logging
|
| 16 |
+
import sys
|
| 17 |
+
|
| 18 |
+
import build_fuzzers_entrypoint
|
| 19 |
+
import run_fuzzers_entrypoint
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
def main():
|
| 23 |
+
"""Builds and runs fuzzers for CI tools.
|
| 24 |
+
|
| 25 |
+
NOTE: Any crash report will be in the filepath: $WORKSPACE/out/testcase
|
| 26 |
+
This can be used with GitHub's upload-artifact action to surface the logs.
|
| 27 |
+
|
| 28 |
+
Required environment variables:
|
| 29 |
+
Returns:
|
| 30 |
+
0 on success or 1 on failure.
|
| 31 |
+
"""
|
| 32 |
+
logging.debug("Using cifuzz_combined_entrypoint.")
|
| 33 |
+
result = build_fuzzers_entrypoint.build_fuzzers_entrypoint()
|
| 34 |
+
if result != 0:
|
| 35 |
+
return result
|
| 36 |
+
return run_fuzzers_entrypoint.run_fuzzers_entrypoint()
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
if __name__ == '__main__':
|
| 40 |
+
sys.exit(main())
|
local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/cifuzz_end_to_end_test.py
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2021 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
"""End-to-End tests for CIFuzz."""
|
| 15 |
+
import os
|
| 16 |
+
import unittest
|
| 17 |
+
|
| 18 |
+
import run_cifuzz
|
| 19 |
+
import test_helpers
|
| 20 |
+
|
| 21 |
+
CIFUZZ_DIR = os.path.dirname(os.path.abspath(__file__))
|
| 22 |
+
EXTERNAL_PROJECT_PATH = os.path.join(CIFUZZ_DIR, 'test_data',
|
| 23 |
+
'external-project')
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
# This test will fail if not run as root because the fuzzer build process
|
| 27 |
+
# creates binaries that only root can write to.
|
| 28 |
+
# Use a seperate env var to keep this seperate from integration tests which
|
| 29 |
+
# don't have this annoying property.
|
| 30 |
+
@unittest.skipIf(not os.getenv('END_TO_END_TESTS'),
|
| 31 |
+
'END_TO_END_TESTS=1 not set')
|
| 32 |
+
class EndToEndTest(unittest.TestCase):
|
| 33 |
+
"""End-to-End tests for CIFuzz."""
|
| 34 |
+
|
| 35 |
+
def setUp(self):
|
| 36 |
+
test_helpers.patch_environ(self, runner=True)
|
| 37 |
+
|
| 38 |
+
def test_simple(self):
|
| 39 |
+
"""Simple end-to-end test using run_cifuzz.main()."""
|
| 40 |
+
os.environ['REPOSITORY'] = 'external-project'
|
| 41 |
+
os.environ['PROJECT_SRC_PATH'] = EXTERNAL_PROJECT_PATH
|
| 42 |
+
os.environ['FILESTORE'] = 'no_filestore'
|
| 43 |
+
os.environ['NO_CLUSTERFUZZ_DEPLOYMENT'] = 'True'
|
| 44 |
+
|
| 45 |
+
with test_helpers.docker_temp_dir() as temp_dir:
|
| 46 |
+
os.environ['WORKSPACE'] = temp_dir
|
| 47 |
+
# TODO(metzman): Verify the crash, affected fuzzers, and other things.
|
| 48 |
+
self.assertEqual(run_cifuzz.main(), 1)
|
local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/cloudbuild.yaml
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# TODO(metzman): Get rid of cifuzz-build-fuzzers and cifuzz-run-fuzzers.
|
| 2 |
+
steps:
|
| 3 |
+
- name: 'gcr.io/cloud-builders/docker'
|
| 4 |
+
args:
|
| 5 |
+
- build
|
| 6 |
+
- '-t'
|
| 7 |
+
- ghcr.io/aixcc-finals/cifuzz-base
|
| 8 |
+
- '-t'
|
| 9 |
+
- ghcr.io/aixcc-finals/cifuzz-base:v1
|
| 10 |
+
- '-f'
|
| 11 |
+
- infra/cifuzz/cifuzz-base/Dockerfile
|
| 12 |
+
- .
|
| 13 |
+
- name: 'gcr.io/cloud-builders/docker'
|
| 14 |
+
args:
|
| 15 |
+
- build
|
| 16 |
+
- '-t'
|
| 17 |
+
- ghcr.io/aixcc-finals/cifuzz-build-fuzzers
|
| 18 |
+
- '-t'
|
| 19 |
+
- ghcr.io/aixcc-finals/cifuzz-build-fuzzers:v1
|
| 20 |
+
- '-t'
|
| 21 |
+
- ghcr.io/aixcc-finals/clusterfuzzlite-build-fuzzers
|
| 22 |
+
- '-t'
|
| 23 |
+
- ghcr.io/aixcc-finals/clusterfuzzlite-build-fuzzers:v1
|
| 24 |
+
- '-f'
|
| 25 |
+
- infra/build_fuzzers.Dockerfile
|
| 26 |
+
- infra
|
| 27 |
+
- name: 'gcr.io/cloud-builders/docker'
|
| 28 |
+
args:
|
| 29 |
+
- build
|
| 30 |
+
- '-t'
|
| 31 |
+
- ghcr.io/aixcc-finals/cifuzz-run-fuzzers
|
| 32 |
+
- '-t'
|
| 33 |
+
- ghcr.io/aixcc-finals/cifuzz-run-fuzzers:v1
|
| 34 |
+
- '-t'
|
| 35 |
+
- ghcr.io/aixcc-finals/clusterfuzzlite-run-fuzzers
|
| 36 |
+
- '-t'
|
| 37 |
+
- ghcr.io/aixcc-finals/clusterfuzzlite-run-fuzzers:v1
|
| 38 |
+
- '-f'
|
| 39 |
+
- infra/run_fuzzers.Dockerfile
|
| 40 |
+
- infra
|
| 41 |
+
images:
|
| 42 |
+
- ghcr.io/aixcc-finals/cifuzz-base
|
| 43 |
+
- ghcr.io/aixcc-finals/cifuzz-base:v1
|
| 44 |
+
- ghcr.io/aixcc-finals/cifuzz-run-fuzzers
|
| 45 |
+
- ghcr.io/aixcc-finals/cifuzz-run-fuzzers:v1
|
| 46 |
+
- ghcr.io/aixcc-finals/cifuzz-build-fuzzers
|
| 47 |
+
- ghcr.io/aixcc-finals/cifuzz-build-fuzzers:v1
|
| 48 |
+
- ghcr.io/aixcc-finals/clusterfuzzlite-build-fuzzers
|
| 49 |
+
- ghcr.io/aixcc-finals/clusterfuzzlite-build-fuzzers:v1
|
| 50 |
+
- ghcr.io/aixcc-finals/clusterfuzzlite-run-fuzzers
|
| 51 |
+
- ghcr.io/aixcc-finals/clusterfuzzlite-run-fuzzers:v1
|
| 52 |
+
timeout: 1800s
|
local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/clusterfuzz_deployment_test.py
ADDED
|
@@ -0,0 +1,268 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2021 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
"""Tests for clusterfuzz_deployment.py"""
|
| 15 |
+
|
| 16 |
+
import os
|
| 17 |
+
import unittest
|
| 18 |
+
from unittest import mock
|
| 19 |
+
|
| 20 |
+
import parameterized
|
| 21 |
+
from pyfakefs import fake_filesystem_unittest
|
| 22 |
+
|
| 23 |
+
import clusterfuzz_deployment
|
| 24 |
+
import config_utils
|
| 25 |
+
import test_helpers
|
| 26 |
+
import workspace_utils
|
| 27 |
+
|
| 28 |
+
# NOTE: This integration test relies on
|
| 29 |
+
# https://github.com/google/oss-fuzz/tree/master/projects/example project.
|
| 30 |
+
EXAMPLE_PROJECT = 'example'
|
| 31 |
+
|
| 32 |
+
# An example fuzzer that triggers an error.
|
| 33 |
+
EXAMPLE_FUZZER = 'example_crash_fuzzer'
|
| 34 |
+
|
| 35 |
+
WORKSPACE = '/workspace'
|
| 36 |
+
EXPECTED_LATEST_BUILD_PATH = os.path.join(WORKSPACE, 'cifuzz-prev-build')
|
| 37 |
+
|
| 38 |
+
# pylint: disable=unused-argument
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
def _create_config(**kwargs):
|
| 42 |
+
"""Creates a config object and then sets every attribute that is a key in
|
| 43 |
+
|kwargs| to the corresponding value. Asserts that each key in |kwargs| is an
|
| 44 |
+
attribute of Config."""
|
| 45 |
+
defaults = {
|
| 46 |
+
'cfl_platform': 'github',
|
| 47 |
+
'oss_fuzz_project_name': EXAMPLE_PROJECT,
|
| 48 |
+
'workspace': WORKSPACE,
|
| 49 |
+
}
|
| 50 |
+
for default_key, default_value in defaults.items():
|
| 51 |
+
if default_key not in kwargs:
|
| 52 |
+
kwargs[default_key] = default_value
|
| 53 |
+
|
| 54 |
+
return test_helpers.create_run_config(**kwargs)
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
def _create_deployment(**kwargs):
|
| 58 |
+
config = _create_config(**kwargs)
|
| 59 |
+
workspace = workspace_utils.Workspace(config)
|
| 60 |
+
return clusterfuzz_deployment.get_clusterfuzz_deployment(config, workspace)
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
class OSSFuzzTest(fake_filesystem_unittest.TestCase):
|
| 64 |
+
"""Tests OSSFuzz."""
|
| 65 |
+
|
| 66 |
+
def setUp(self):
|
| 67 |
+
self.setUpPyfakefs()
|
| 68 |
+
self.deployment = _create_deployment()
|
| 69 |
+
self.corpus_dir = os.path.join(self.deployment.workspace.corpora,
|
| 70 |
+
EXAMPLE_FUZZER)
|
| 71 |
+
|
| 72 |
+
@mock.patch('http_utils.download_and_unpack_zip', return_value=True)
|
| 73 |
+
def test_download_corpus(self, mock_download_and_unpack_zip):
|
| 74 |
+
"""Tests that we can download a corpus for a valid project."""
|
| 75 |
+
self.deployment.download_corpus(EXAMPLE_FUZZER, self.corpus_dir)
|
| 76 |
+
expected_url = ('https://storage.googleapis.com/example-backup.'
|
| 77 |
+
'clusterfuzz-external.appspot.com/corpus/libFuzzer/'
|
| 78 |
+
'example_crash_fuzzer/public.zip')
|
| 79 |
+
call_args, _ = mock_download_and_unpack_zip.call_args
|
| 80 |
+
self.assertEqual(call_args, (expected_url, self.corpus_dir))
|
| 81 |
+
self.assertTrue(os.path.exists(self.corpus_dir))
|
| 82 |
+
|
| 83 |
+
@mock.patch('http_utils.download_and_unpack_zip', return_value=False)
|
| 84 |
+
def test_download_corpus_fail(self, _):
|
| 85 |
+
"""Tests that when downloading fails, an empty corpus directory is still
|
| 86 |
+
returned."""
|
| 87 |
+
self.deployment.download_corpus(EXAMPLE_FUZZER, self.corpus_dir)
|
| 88 |
+
self.assertEqual(os.listdir(self.corpus_dir), [])
|
| 89 |
+
|
| 90 |
+
def test_get_latest_build_name(self):
|
| 91 |
+
"""Tests that the latest build name can be retrieved from GCS."""
|
| 92 |
+
latest_build_name = self.deployment.get_latest_build_name()
|
| 93 |
+
self.assertTrue(latest_build_name.endswith('.zip'))
|
| 94 |
+
self.assertTrue('address' in latest_build_name)
|
| 95 |
+
|
| 96 |
+
@parameterized.parameterized.expand([
|
| 97 |
+
('upload_build', ('commit',),
|
| 98 |
+
'Not uploading latest build because on OSS-Fuzz.'),
|
| 99 |
+
('upload_corpus', ('target', 'corpus-dir'),
|
| 100 |
+
'Not uploading corpus because on OSS-Fuzz.'),
|
| 101 |
+
('upload_crashes', tuple(), 'Not uploading crashes because on OSS-Fuzz.'),
|
| 102 |
+
])
|
| 103 |
+
def test_noop_methods(self, method, method_args, expected_message):
|
| 104 |
+
"""Tests that certain methods are noops for OSS-Fuzz."""
|
| 105 |
+
with mock.patch('logging.info') as mock_info:
|
| 106 |
+
method = getattr(self.deployment, method)
|
| 107 |
+
self.assertIsNone(method(*method_args))
|
| 108 |
+
mock_info.assert_called_with(expected_message)
|
| 109 |
+
|
| 110 |
+
@mock.patch('http_utils.download_and_unpack_zip', return_value=True)
|
| 111 |
+
def test_download_latest_build(self, mock_download_and_unpack_zip):
|
| 112 |
+
"""Tests that downloading the latest build works as intended under normal
|
| 113 |
+
circumstances."""
|
| 114 |
+
self.assertEqual(self.deployment.download_latest_build(),
|
| 115 |
+
EXPECTED_LATEST_BUILD_PATH)
|
| 116 |
+
expected_url = ('https://storage.googleapis.com/clusterfuzz-builds/example/'
|
| 117 |
+
'example-address-202008030600.zip')
|
| 118 |
+
mock_download_and_unpack_zip.assert_called_with(expected_url,
|
| 119 |
+
EXPECTED_LATEST_BUILD_PATH)
|
| 120 |
+
|
| 121 |
+
@mock.patch('http_utils.download_and_unpack_zip', return_value=False)
|
| 122 |
+
def test_download_latest_build_fail(self, _):
|
| 123 |
+
"""Tests that download_latest_build returns None when it fails to download a
|
| 124 |
+
build."""
|
| 125 |
+
self.assertIsNone(self.deployment.download_latest_build())
|
| 126 |
+
|
| 127 |
+
|
| 128 |
+
class ClusterFuzzLiteTest(fake_filesystem_unittest.TestCase):
|
| 129 |
+
"""Tests for ClusterFuzzLite."""
|
| 130 |
+
|
| 131 |
+
def setUp(self):
|
| 132 |
+
self.setUpPyfakefs()
|
| 133 |
+
self.deployment = _create_deployment(mode='batch',
|
| 134 |
+
oss_fuzz_project_name='',
|
| 135 |
+
cloud_bucket='gs://bucket')
|
| 136 |
+
self.corpus_dir = os.path.join(self.deployment.workspace.corpora,
|
| 137 |
+
EXAMPLE_FUZZER)
|
| 138 |
+
|
| 139 |
+
@mock.patch('filestore.github_actions.GithubActionsFilestore.download_corpus',
|
| 140 |
+
return_value=True)
|
| 141 |
+
def test_download_corpus(self, mock_download_corpus):
|
| 142 |
+
"""Tests that download_corpus works for a valid project."""
|
| 143 |
+
self.deployment.download_corpus(EXAMPLE_FUZZER, self.corpus_dir)
|
| 144 |
+
mock_download_corpus.assert_called_with('example_crash_fuzzer',
|
| 145 |
+
self.corpus_dir)
|
| 146 |
+
self.assertTrue(os.path.exists(self.corpus_dir))
|
| 147 |
+
|
| 148 |
+
@mock.patch('filestore.github_actions.GithubActionsFilestore.download_corpus',
|
| 149 |
+
side_effect=Exception)
|
| 150 |
+
def test_download_corpus_fail(self, _):
|
| 151 |
+
"""Tests that when downloading fails, an empty corpus directory is still
|
| 152 |
+
returned."""
|
| 153 |
+
self.deployment.download_corpus(EXAMPLE_FUZZER, self.corpus_dir)
|
| 154 |
+
self.assertEqual(os.listdir(self.corpus_dir), [])
|
| 155 |
+
|
| 156 |
+
@mock.patch('filestore.github_actions.GithubActionsFilestore.download_build',
|
| 157 |
+
side_effect=[False, True])
|
| 158 |
+
@mock.patch('repo_manager.RepoManager.get_commit_list',
|
| 159 |
+
return_value=['commit1', 'commit2'])
|
| 160 |
+
@mock.patch('continuous_integration.GithubCiMixin.repo_dir',
|
| 161 |
+
return_value='/path/to/repo')
|
| 162 |
+
def test_download_latest_build(self, mock_repo_dir, mock_get_commit_list,
|
| 163 |
+
mock_download_build):
|
| 164 |
+
"""Tests that downloading the latest build works as intended under normal
|
| 165 |
+
circumstances."""
|
| 166 |
+
self.assertEqual(self.deployment.download_latest_build(),
|
| 167 |
+
EXPECTED_LATEST_BUILD_PATH)
|
| 168 |
+
expected_artifact_name = 'address-commit2'
|
| 169 |
+
mock_download_build.assert_called_with(expected_artifact_name,
|
| 170 |
+
EXPECTED_LATEST_BUILD_PATH)
|
| 171 |
+
|
| 172 |
+
@mock.patch('filestore.github_actions.GithubActionsFilestore.download_build',
|
| 173 |
+
side_effect=Exception)
|
| 174 |
+
@mock.patch('repo_manager.RepoManager.get_commit_list',
|
| 175 |
+
return_value=['commit1', 'commit2'])
|
| 176 |
+
@mock.patch('continuous_integration.GithubCiMixin.repo_dir',
|
| 177 |
+
return_value='/path/to/repo')
|
| 178 |
+
def test_download_latest_build_fail(self, mock_repo_dir, mock_get_commit_list,
|
| 179 |
+
_):
|
| 180 |
+
"""Tests that download_latest_build returns None when it fails to download a
|
| 181 |
+
build."""
|
| 182 |
+
self.assertIsNone(self.deployment.download_latest_build())
|
| 183 |
+
|
| 184 |
+
@mock.patch('filestore.github_actions.GithubActionsFilestore.upload_build')
|
| 185 |
+
def test_upload_build(self, mock_upload_build):
|
| 186 |
+
"""Tests that upload_build works as intended."""
|
| 187 |
+
self.deployment.upload_build('commit')
|
| 188 |
+
mock_upload_build.assert_called_with('address-commit',
|
| 189 |
+
'/workspace/build-out')
|
| 190 |
+
|
| 191 |
+
|
| 192 |
+
class NoClusterFuzzDeploymentTest(fake_filesystem_unittest.TestCase):
|
| 193 |
+
"""Tests for NoClusterFuzzDeployment."""
|
| 194 |
+
|
| 195 |
+
def setUp(self):
|
| 196 |
+
self.setUpPyfakefs()
|
| 197 |
+
config = test_helpers.create_run_config(workspace=WORKSPACE,
|
| 198 |
+
cfl_platform='other',
|
| 199 |
+
filestore='no_filestore',
|
| 200 |
+
no_clusterfuzz_deployment=True)
|
| 201 |
+
workspace = workspace_utils.Workspace(config)
|
| 202 |
+
self.deployment = clusterfuzz_deployment.get_clusterfuzz_deployment(
|
| 203 |
+
config, workspace)
|
| 204 |
+
|
| 205 |
+
self.corpus_dir = os.path.join(workspace.corpora, EXAMPLE_FUZZER)
|
| 206 |
+
|
| 207 |
+
@mock.patch('logging.info')
|
| 208 |
+
def test_download_corpus(self, mock_info):
|
| 209 |
+
"""Tests that download corpus returns the path to the empty corpus
|
| 210 |
+
directory."""
|
| 211 |
+
self.deployment.download_corpus(EXAMPLE_FUZZER, self.corpus_dir)
|
| 212 |
+
mock_info.assert_called_with(
|
| 213 |
+
'Not downloading corpus because no ClusterFuzz deployment.')
|
| 214 |
+
self.assertTrue(os.path.exists(self.corpus_dir))
|
| 215 |
+
|
| 216 |
+
@parameterized.parameterized.expand([
|
| 217 |
+
('upload_build', ('commit',),
|
| 218 |
+
'Not uploading latest build because no ClusterFuzz deployment.'),
|
| 219 |
+
('upload_corpus', ('target', 'corpus-dir'),
|
| 220 |
+
'Not uploading corpus because no ClusterFuzz deployment.'),
|
| 221 |
+
('upload_crashes', tuple(),
|
| 222 |
+
'Not uploading crashes because no ClusterFuzz deployment.'),
|
| 223 |
+
('download_latest_build', tuple(),
|
| 224 |
+
'Not downloading latest build because no ClusterFuzz deployment.')
|
| 225 |
+
])
|
| 226 |
+
def test_noop_methods(self, method, method_args, expected_message):
|
| 227 |
+
"""Tests that certain methods are noops for NoClusterFuzzDeployment."""
|
| 228 |
+
with mock.patch('logging.info') as mock_info:
|
| 229 |
+
method = getattr(self.deployment, method)
|
| 230 |
+
self.assertIsNone(method(*method_args))
|
| 231 |
+
mock_info.assert_called_with(expected_message)
|
| 232 |
+
|
| 233 |
+
|
| 234 |
+
class GetClusterFuzzDeploymentTest(unittest.TestCase):
|
| 235 |
+
"""Tests for get_clusterfuzz_deployment."""
|
| 236 |
+
|
| 237 |
+
def setUp(self):
|
| 238 |
+
test_helpers.patch_environ(self)
|
| 239 |
+
os.environ['GITHUB_REPOSITORY'] = 'owner/myproject'
|
| 240 |
+
|
| 241 |
+
@parameterized.parameterized.expand([
|
| 242 |
+
(config_utils.BaseConfig.Platform.INTERNAL_GENERIC_CI,
|
| 243 |
+
clusterfuzz_deployment.OSSFuzz),
|
| 244 |
+
(config_utils.BaseConfig.Platform.INTERNAL_GITHUB,
|
| 245 |
+
clusterfuzz_deployment.OSSFuzz),
|
| 246 |
+
(config_utils.BaseConfig.Platform.EXTERNAL_GENERIC_CI,
|
| 247 |
+
clusterfuzz_deployment.ClusterFuzzLite),
|
| 248 |
+
(config_utils.BaseConfig.Platform.EXTERNAL_GITHUB,
|
| 249 |
+
clusterfuzz_deployment.ClusterFuzzLite),
|
| 250 |
+
])
|
| 251 |
+
def test_get_clusterfuzz_deployment(self, platform, expected_deployment_cls):
|
| 252 |
+
"""Tests that get_clusterfuzz_deployment returns the correct value."""
|
| 253 |
+
with mock.patch('config_utils.BaseConfig.platform',
|
| 254 |
+
return_value=platform,
|
| 255 |
+
new_callable=mock.PropertyMock):
|
| 256 |
+
with mock.patch('filestore_utils.get_filestore', return_value=None):
|
| 257 |
+
with mock.patch('platform_config.github._get_event_data',
|
| 258 |
+
return_value={}):
|
| 259 |
+
config = _create_config()
|
| 260 |
+
workspace = workspace_utils.Workspace(config)
|
| 261 |
+
|
| 262 |
+
self.assertIsInstance(
|
| 263 |
+
clusterfuzz_deployment.get_clusterfuzz_deployment(
|
| 264 |
+
config, workspace), expected_deployment_cls)
|
| 265 |
+
|
| 266 |
+
|
| 267 |
+
if __name__ == '__main__':
|
| 268 |
+
unittest.main()
|
local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/config_utils.py
ADDED
|
@@ -0,0 +1,283 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2021 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
"""Module for getting the configuration CIFuzz needs to run."""
|
| 15 |
+
|
| 16 |
+
import enum
|
| 17 |
+
import importlib
|
| 18 |
+
import logging
|
| 19 |
+
import os
|
| 20 |
+
import sys
|
| 21 |
+
|
| 22 |
+
import environment
|
| 23 |
+
|
| 24 |
+
# pylint: disable=wrong-import-position,import-error
|
| 25 |
+
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
| 26 |
+
|
| 27 |
+
import platform_config
|
| 28 |
+
import constants
|
| 29 |
+
|
| 30 |
+
SANITIZERS = ['address', 'memory', 'undefined', 'coverage']
|
| 31 |
+
|
| 32 |
+
# TODO(metzman): Set these on config objects so there's one source of truth.
|
| 33 |
+
DEFAULT_ENGINE = 'libfuzzer'
|
| 34 |
+
|
| 35 |
+
# This module deals a lot with env variables. Many of these will be set by users
|
| 36 |
+
# and others beyond CIFuzz's control. Thus, you should be careful about using
|
| 37 |
+
# the environment.py helpers for getting env vars, since it can cause values
|
| 38 |
+
# that should be interpreted as strings to be returned as other types (bools or
|
| 39 |
+
# ints for example). The environment.py helpers should not be used for values
|
| 40 |
+
# that are supposed to be strings.
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
def _get_sanitizer():
|
| 44 |
+
return os.getenv('SANITIZER', constants.DEFAULT_SANITIZER).lower()
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
def _get_architecture():
|
| 48 |
+
return os.getenv('ARCHITECTURE', constants.DEFAULT_ARCHITECTURE).lower()
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
def _is_dry_run():
|
| 52 |
+
"""Returns True if configured to do a dry run."""
|
| 53 |
+
return environment.get_bool('DRY_RUN', False)
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
def _get_language():
|
| 57 |
+
"""Returns the project language."""
|
| 58 |
+
# Get language from environment. We took this approach because the convenience
|
| 59 |
+
# given to OSS-Fuzz users by not making them specify the language again (and
|
| 60 |
+
# getting it from the project.yaml) is outweighed by the complexity in
|
| 61 |
+
# implementing this. A lot of the complexity comes from our unittests not
|
| 62 |
+
# setting a proper projet at this point.
|
| 63 |
+
return os.getenv('LANGUAGE', constants.DEFAULT_LANGUAGE)
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
def _get_extra_environment_variables():
|
| 67 |
+
"""Gets extra environment variables specified by the user with
|
| 68 |
+
CFL_EXTRA_$NAME=$VALUE."""
|
| 69 |
+
return [key for key in os.environ if key.startswith('CFL_EXTRA_')]
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
# pylint: disable=too-many-instance-attributes
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
class ConfigError(Exception):
|
| 76 |
+
"""Error for invalid configuration."""
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
class BaseConfig:
|
| 80 |
+
"""Object containing constant configuration for CIFuzz."""
|
| 81 |
+
|
| 82 |
+
class Platform(enum.Enum):
|
| 83 |
+
"""Enum representing the different platforms CIFuzz runs on."""
|
| 84 |
+
EXTERNAL_GITHUB = 0 # Non-OSS-Fuzz on GitHub actions.
|
| 85 |
+
INTERNAL_GITHUB = 1 # OSS-Fuzz on GitHub actions.
|
| 86 |
+
INTERNAL_GENERIC_CI = 2 # OSS-Fuzz on any CI.
|
| 87 |
+
EXTERNAL_GENERIC_CI = 3 # Non-OSS-Fuzz on any CI.
|
| 88 |
+
|
| 89 |
+
@property
|
| 90 |
+
def is_github(self):
|
| 91 |
+
"""Returns True if running on GitHub."""
|
| 92 |
+
return self.cfl_platform == 'github'
|
| 93 |
+
|
| 94 |
+
def __init__(self):
|
| 95 |
+
# Need to set these before calling self.platform.
|
| 96 |
+
self.oss_fuzz_project_name = os.getenv('OSS_FUZZ_PROJECT_NAME')
|
| 97 |
+
self.cfl_platform = os.getenv('CFL_PLATFORM')
|
| 98 |
+
logging.debug('Is github: %s.', self.is_github)
|
| 99 |
+
|
| 100 |
+
self.platform_conf = _get_platform_config(self.cfl_platform)
|
| 101 |
+
self.base_commit = self.platform_conf.base_commit
|
| 102 |
+
self.base_ref = self.platform_conf.base_ref
|
| 103 |
+
self.pr_ref = self.platform_conf.pr_ref
|
| 104 |
+
self.workspace = self.platform_conf.workspace
|
| 105 |
+
self.project_src_path = self.platform_conf.project_src_path
|
| 106 |
+
self.actor = self.platform_conf.actor
|
| 107 |
+
self.token = self.platform_conf.token
|
| 108 |
+
self.project_repo_owner = self.platform_conf.project_repo_owner
|
| 109 |
+
self.project_repo_name = self.platform_conf.project_repo_name
|
| 110 |
+
self.filestore = self.platform_conf.filestore
|
| 111 |
+
|
| 112 |
+
# This determines if builds are done using docker in docker
|
| 113 |
+
# rather than the normal method which is sibling containers.
|
| 114 |
+
self.docker_in_docker = self.platform_conf.docker_in_docker
|
| 115 |
+
|
| 116 |
+
self.dry_run = _is_dry_run() # Check if failures should not be reported.
|
| 117 |
+
self.sanitizer = _get_sanitizer()
|
| 118 |
+
self.architecture = _get_architecture()
|
| 119 |
+
self.language = _get_language()
|
| 120 |
+
self.low_disk_space = environment.get_bool('LOW_DISK_SPACE', False)
|
| 121 |
+
|
| 122 |
+
self.git_store_repo = os.environ.get('GIT_STORE_REPO')
|
| 123 |
+
self.git_store_branch = os.environ.get('GIT_STORE_BRANCH')
|
| 124 |
+
self.git_store_branch_coverage = os.environ.get('GIT_STORE_BRANCH_COVERAGE',
|
| 125 |
+
self.git_store_branch)
|
| 126 |
+
self.cloud_bucket = os.environ.get('CLOUD_BUCKET')
|
| 127 |
+
self.no_clusterfuzz_deployment = environment.get_bool(
|
| 128 |
+
'NO_CLUSTERFUZZ_DEPLOYMENT', False)
|
| 129 |
+
self.build_integration_path = (
|
| 130 |
+
constants.DEFAULT_EXTERNAL_BUILD_INTEGRATION_PATH)
|
| 131 |
+
|
| 132 |
+
self.parallel_fuzzing = environment.get_bool('PARALLEL_FUZZING', False)
|
| 133 |
+
self.extra_environment_variables = _get_extra_environment_variables()
|
| 134 |
+
self.output_sarif = environment.get_bool('OUTPUT_SARIF', False)
|
| 135 |
+
|
| 136 |
+
# TODO(metzman): Fix tests to create valid configurations and get rid of
|
| 137 |
+
# CIFUZZ_TEST here and in presubmit.py.
|
| 138 |
+
if not os.getenv('CIFUZZ_TEST') and not self.validate():
|
| 139 |
+
raise ConfigError('Invalid Configuration.')
|
| 140 |
+
|
| 141 |
+
def validate(self):
|
| 142 |
+
"""Returns False if the configuration is invalid."""
|
| 143 |
+
# Do validation here so that unittests don't need to make a fully-valid
|
| 144 |
+
# config.
|
| 145 |
+
# pylint: disable=too-many-return-statements
|
| 146 |
+
if not self.workspace:
|
| 147 |
+
logging.error('Must set WORKSPACE.')
|
| 148 |
+
return False
|
| 149 |
+
|
| 150 |
+
if self.sanitizer not in SANITIZERS:
|
| 151 |
+
logging.error('Invalid SANITIZER: %s. Must be one of: %s.',
|
| 152 |
+
self.sanitizer, SANITIZERS)
|
| 153 |
+
return False
|
| 154 |
+
|
| 155 |
+
if self.architecture not in constants.ARCHITECTURES:
|
| 156 |
+
logging.error('Invalid ARCHITECTURE: %s. Must be one of: %s.',
|
| 157 |
+
self.architecture, constants.ARCHITECTURES)
|
| 158 |
+
return False
|
| 159 |
+
|
| 160 |
+
if self.architecture == 'i386' and self.sanitizer != 'address':
|
| 161 |
+
logging.error(
|
| 162 |
+
'ARCHITECTURE=i386 can be used with SANITIZER=address only.')
|
| 163 |
+
return False
|
| 164 |
+
|
| 165 |
+
if self.language not in constants.LANGUAGES:
|
| 166 |
+
logging.error('Invalid LANGUAGE: %s. Must be one of: %s.', self.language,
|
| 167 |
+
constants.LANGUAGES)
|
| 168 |
+
return False
|
| 169 |
+
|
| 170 |
+
if not self.project_repo_name:
|
| 171 |
+
logging.error('Must set REPOSITORY.')
|
| 172 |
+
return False
|
| 173 |
+
|
| 174 |
+
return True
|
| 175 |
+
|
| 176 |
+
@property
|
| 177 |
+
def is_internal(self):
|
| 178 |
+
"""Returns True if this is an OSS-Fuzz project."""
|
| 179 |
+
return bool(self.oss_fuzz_project_name)
|
| 180 |
+
|
| 181 |
+
@property
|
| 182 |
+
def platform(self):
|
| 183 |
+
"""Returns the platform CIFuzz is runnning on."""
|
| 184 |
+
if not self.is_internal:
|
| 185 |
+
if not self.is_github:
|
| 186 |
+
return self.Platform.EXTERNAL_GENERIC_CI
|
| 187 |
+
return self.Platform.EXTERNAL_GITHUB
|
| 188 |
+
|
| 189 |
+
if self.is_github:
|
| 190 |
+
return self.Platform.INTERNAL_GITHUB
|
| 191 |
+
return self.Platform.INTERNAL_GENERIC_CI
|
| 192 |
+
|
| 193 |
+
@property
|
| 194 |
+
def is_coverage(self):
|
| 195 |
+
"""Returns True if this CIFuzz run (building fuzzers and running them) for
|
| 196 |
+
generating a coverage report."""
|
| 197 |
+
return self.sanitizer == 'coverage'
|
| 198 |
+
|
| 199 |
+
|
| 200 |
+
def _get_platform_config(cfl_platform):
|
| 201 |
+
"""Returns the CI environment object for |cfl_platform|."""
|
| 202 |
+
module_name = f'platform_config.{cfl_platform}'
|
| 203 |
+
try:
|
| 204 |
+
cls = importlib.import_module(module_name).PlatformConfig
|
| 205 |
+
except ImportError:
|
| 206 |
+
cls = platform_config.BasePlatformConfig
|
| 207 |
+
return cls()
|
| 208 |
+
|
| 209 |
+
|
| 210 |
+
class RunFuzzersConfig(BaseConfig):
|
| 211 |
+
"""Class containing constant configuration for running fuzzers in CIFuzz."""
|
| 212 |
+
|
| 213 |
+
MODES = ['batch', 'code-change', 'coverage', 'prune']
|
| 214 |
+
|
| 215 |
+
def __init__(self):
|
| 216 |
+
super().__init__()
|
| 217 |
+
# TODO(metzman): Pick a better default for pruning.
|
| 218 |
+
self.fuzz_seconds = int(os.environ.get('FUZZ_SECONDS', 600))
|
| 219 |
+
self.mode = os.environ.get('MODE', 'code-change').lower()
|
| 220 |
+
if self.is_coverage:
|
| 221 |
+
self.mode = 'coverage'
|
| 222 |
+
|
| 223 |
+
self.report_unreproducible_crashes = environment.get_bool(
|
| 224 |
+
'REPORT_UNREPRODUCIBLE_CRASHES', False)
|
| 225 |
+
|
| 226 |
+
self.minimize_crashes = environment.get_bool('MINIMIZE_CRASHES', False)
|
| 227 |
+
if self.mode == 'batch':
|
| 228 |
+
logging.warning(
|
| 229 |
+
'Minimizing crashes reduces fuzzing time in batch fuzzing.')
|
| 230 |
+
self.report_timeouts = environment.get_bool('REPORT_TIMEOUTS', False)
|
| 231 |
+
self.report_ooms = environment.get_bool('REPORT_OOMS', True)
|
| 232 |
+
self.upload_all_crashes = environment.get_bool('UPLOAD_ALL_CRASHES', False)
|
| 233 |
+
|
| 234 |
+
# TODO(metzman): Fix tests to create valid configurations and get rid of
|
| 235 |
+
# CIFUZZ_TEST here and in presubmit.py.
|
| 236 |
+
if not os.getenv('CIFUZZ_TEST') and not self._run_config_validate():
|
| 237 |
+
raise ConfigError('Invalid Run Configuration.')
|
| 238 |
+
|
| 239 |
+
def _run_config_validate(self):
|
| 240 |
+
"""Do extra validation on RunFuzzersConfig.__init__(). Do not name this
|
| 241 |
+
validate or else it will be called when using the parent's __init__ and will
|
| 242 |
+
fail. Returns True if valid."""
|
| 243 |
+
if self.mode not in self.MODES:
|
| 244 |
+
logging.error('Invalid MODE: %s. Must be one of %s.', self.mode,
|
| 245 |
+
self.MODES)
|
| 246 |
+
return False
|
| 247 |
+
|
| 248 |
+
return True
|
| 249 |
+
|
| 250 |
+
|
| 251 |
+
class BuildFuzzersConfig(BaseConfig):
|
| 252 |
+
"""Class containing constant configuration for building fuzzers in CIFuzz."""
|
| 253 |
+
|
| 254 |
+
def __init__(self):
|
| 255 |
+
"""Get the configuration from CIFuzz from the environment. These variables
|
| 256 |
+
are set by GitHub or the user."""
|
| 257 |
+
super().__init__()
|
| 258 |
+
self.git_sha = self.platform_conf.git_sha
|
| 259 |
+
self.git_url = self.platform_conf.git_url
|
| 260 |
+
|
| 261 |
+
self.allowed_broken_targets_percentage = os.getenv(
|
| 262 |
+
'ALLOWED_BROKEN_TARGETS_PERCENTAGE')
|
| 263 |
+
self.bad_build_check = environment.get_bool('BAD_BUILD_CHECK', True)
|
| 264 |
+
|
| 265 |
+
self.keep_unaffected_fuzz_targets = environment.get_bool(
|
| 266 |
+
'KEEP_UNAFFECTED_FUZZ_TARGETS')
|
| 267 |
+
|
| 268 |
+
self.upload_build = environment.get_bool('UPLOAD_BUILD', False)
|
| 269 |
+
if not self.keep_unaffected_fuzz_targets:
|
| 270 |
+
has_base_for_diff = (self.base_ref or self.base_commit)
|
| 271 |
+
if not has_base_for_diff:
|
| 272 |
+
logging.info(
|
| 273 |
+
'Keeping all fuzzers because there is nothing to diff against.')
|
| 274 |
+
self.keep_unaffected_fuzz_targets = True
|
| 275 |
+
elif self.upload_build:
|
| 276 |
+
logging.info('Keeping all fuzzers because we are uploading build.')
|
| 277 |
+
self.keep_unaffected_fuzz_targets = True
|
| 278 |
+
elif self.sanitizer == 'coverage':
|
| 279 |
+
logging.info('Keeping all fuzzers because we are doing coverage.')
|
| 280 |
+
self.keep_unaffected_fuzz_targets = True
|
| 281 |
+
|
| 282 |
+
if self.sanitizer == 'coverage':
|
| 283 |
+
self.bad_build_check = False
|
local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/config_utils_test.py
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2021 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
"""Tests for config_utils."""
|
| 15 |
+
import os
|
| 16 |
+
import unittest
|
| 17 |
+
from unittest import mock
|
| 18 |
+
|
| 19 |
+
import config_utils
|
| 20 |
+
import constants
|
| 21 |
+
import test_helpers
|
| 22 |
+
|
| 23 |
+
# pylint: disable=no-self-use,protected-access
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
class BaseConfigTest(unittest.TestCase):
|
| 27 |
+
"""Tests for BaseConfig."""
|
| 28 |
+
|
| 29 |
+
def setUp(self):
|
| 30 |
+
test_helpers.patch_environ(self)
|
| 31 |
+
|
| 32 |
+
def _create_config(self):
|
| 33 |
+
return config_utils.BuildFuzzersConfig()
|
| 34 |
+
|
| 35 |
+
def test_language_default(self):
|
| 36 |
+
"""Tests that the correct default language is set."""
|
| 37 |
+
config = self._create_config()
|
| 38 |
+
self.assertEqual(config.language, 'c++')
|
| 39 |
+
|
| 40 |
+
def test_language(self):
|
| 41 |
+
"""Tests that the correct language is set."""
|
| 42 |
+
language = 'python'
|
| 43 |
+
os.environ['LANGUAGE'] = language
|
| 44 |
+
config = self._create_config()
|
| 45 |
+
self.assertEqual(config.language, language)
|
| 46 |
+
|
| 47 |
+
def test_is_coverage(self):
|
| 48 |
+
"""Tests that is_coverage is set correctly."""
|
| 49 |
+
# Test it is set when it is supposed to be.
|
| 50 |
+
os.environ['SANITIZER'] = 'coverage'
|
| 51 |
+
config = self._create_config()
|
| 52 |
+
self.assertTrue(config.is_coverage)
|
| 53 |
+
|
| 54 |
+
# Test it is not set when it is not supposed to be.
|
| 55 |
+
os.environ['SANITIZER'] = 'address'
|
| 56 |
+
config = self._create_config()
|
| 57 |
+
self.assertFalse(config.is_coverage)
|
| 58 |
+
|
| 59 |
+
@mock.patch('logging.error')
|
| 60 |
+
def test_validate_no_workspace(self, mock_error):
|
| 61 |
+
"""Tests that validate returns False if GITHUB_WORKSPACE isn't set."""
|
| 62 |
+
os.environ['OSS_FUZZ_PROJECT_NAME'] = 'example'
|
| 63 |
+
config = self._create_config()
|
| 64 |
+
self.assertFalse(config.validate())
|
| 65 |
+
mock_error.assert_called_with('Must set WORKSPACE.')
|
| 66 |
+
|
| 67 |
+
@mock.patch('logging.error')
|
| 68 |
+
def test_validate_invalid_language(self, mock_error):
|
| 69 |
+
"""Tests that validate returns False if GITHUB_WORKSPACE isn't set."""
|
| 70 |
+
os.environ['OSS_FUZZ_PROJECT_NAME'] = 'example'
|
| 71 |
+
os.environ['WORKSPACE'] = '/workspace'
|
| 72 |
+
os.environ['LANGUAGE'] = 'invalid-language'
|
| 73 |
+
config = self._create_config()
|
| 74 |
+
self.assertFalse(config.validate())
|
| 75 |
+
mock_error.assert_called_with('Invalid LANGUAGE: %s. Must be one of: %s.',
|
| 76 |
+
os.environ['LANGUAGE'], constants.LANGUAGES)
|
| 77 |
+
|
| 78 |
+
@mock.patch('logging.error')
|
| 79 |
+
def test_validate_invalid_sanitizer(self, mock_error):
|
| 80 |
+
"""Tests that validate returns False if GITHUB_WORKSPACE isn't set."""
|
| 81 |
+
os.environ['OSS_FUZZ_PROJECT_NAME'] = 'example'
|
| 82 |
+
os.environ['WORKSPACE'] = '/workspace'
|
| 83 |
+
os.environ['SANITIZER'] = 'invalid-sanitizer'
|
| 84 |
+
config = self._create_config()
|
| 85 |
+
self.assertFalse(config.validate())
|
| 86 |
+
mock_error.assert_called_with('Invalid SANITIZER: %s. Must be one of: %s.',
|
| 87 |
+
os.environ['SANITIZER'],
|
| 88 |
+
config_utils.SANITIZERS)
|
| 89 |
+
|
| 90 |
+
def test_validate(self):
|
| 91 |
+
"""Tests that validate returns True if config is valid."""
|
| 92 |
+
os.environ['OSS_FUZZ_PROJECT_NAME'] = 'example'
|
| 93 |
+
os.environ['WORKSPACE'] = '/workspace'
|
| 94 |
+
os.environ['REPOSITORY'] = 'repo'
|
| 95 |
+
config = self._create_config()
|
| 96 |
+
self.assertTrue(config.validate())
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
class BuildFuzzersConfigTest(unittest.TestCase):
|
| 100 |
+
"""Tests for BuildFuzzersConfig."""
|
| 101 |
+
|
| 102 |
+
def setUp(self):
|
| 103 |
+
test_helpers.patch_environ(self)
|
| 104 |
+
|
| 105 |
+
def _create_config(self):
|
| 106 |
+
return config_utils.BuildFuzzersConfig()
|
| 107 |
+
|
| 108 |
+
@mock.patch('platform_config.github._get_event_data', return_value={})
|
| 109 |
+
def test_github_base_ref(self, _):
|
| 110 |
+
"""Tests that base_ref is set properly."""
|
| 111 |
+
expected_base_ref = 'expected_base_ref'
|
| 112 |
+
os.environ['GITHUB_BASE_REF'] = expected_base_ref
|
| 113 |
+
os.environ['CFL_PLATFORM'] = 'github'
|
| 114 |
+
os.environ['GITHUB_REPOSITORY'] = 'owner/repo'
|
| 115 |
+
config = self._create_config()
|
| 116 |
+
self.assertEqual(config.base_ref, expected_base_ref)
|
| 117 |
+
|
| 118 |
+
def test_base_ref(self):
|
| 119 |
+
"""Tests that base_ref is set properly."""
|
| 120 |
+
expected_base_ref = 'expected_base_ref'
|
| 121 |
+
os.environ['GIT_BASE_REF'] = expected_base_ref
|
| 122 |
+
config = self._create_config()
|
| 123 |
+
self.assertEqual(config.base_ref, expected_base_ref)
|
| 124 |
+
|
| 125 |
+
def test_keep_unaffected_defaults_to_true(self):
|
| 126 |
+
"""Tests that keep_unaffected_fuzz_targets defaults to true."""
|
| 127 |
+
config = self._create_config()
|
| 128 |
+
self.assertTrue(config.keep_unaffected_fuzz_targets)
|
| 129 |
+
|
| 130 |
+
def test_keep_unaffected_defaults_to_false_when_pr(self):
|
| 131 |
+
"""Tests that keep_unaffected_fuzz_targets defaults to false when from a
|
| 132 |
+
pr."""
|
| 133 |
+
os.environ['GIT_BASE_REF'] = 'base-ref'
|
| 134 |
+
config = self._create_config()
|
| 135 |
+
self.assertFalse(config.keep_unaffected_fuzz_targets)
|
| 136 |
+
|
| 137 |
+
|
| 138 |
+
class RunFuzzersConfigTest(unittest.TestCase):
|
| 139 |
+
"""Tests for RunFuzzersConfig."""
|
| 140 |
+
|
| 141 |
+
def setUp(self):
|
| 142 |
+
test_helpers.patch_environ(self)
|
| 143 |
+
|
| 144 |
+
def _create_config(self):
|
| 145 |
+
return config_utils.RunFuzzersConfig()
|
| 146 |
+
|
| 147 |
+
def test_coverage(self):
|
| 148 |
+
"""Tests that mode is overriden properly based on is_coverage."""
|
| 149 |
+
# Test that it is overriden when it is supposed to be.
|
| 150 |
+
os.environ['SANITIZER'] = 'coverage'
|
| 151 |
+
os.environ['MODE'] = 'code-change'
|
| 152 |
+
config = self._create_config()
|
| 153 |
+
self.assertEqual(config.mode, 'coverage')
|
| 154 |
+
|
| 155 |
+
# Test that it isn't overriden when it isn't supposed to be.
|
| 156 |
+
os.environ['SANITIZER'] = 'address'
|
| 157 |
+
mode = 'code-change'
|
| 158 |
+
os.environ['MODE'] = mode
|
| 159 |
+
config = self._create_config()
|
| 160 |
+
self.assertEqual(config.mode, mode)
|
| 161 |
+
|
| 162 |
+
def test_run_config_validate(self):
|
| 163 |
+
"""Tests that _run_config_validate returns True when the config is valid."""
|
| 164 |
+
self.assertTrue(self._create_config()._run_config_validate())
|
| 165 |
+
|
| 166 |
+
@mock.patch('logging.error')
|
| 167 |
+
def test_run_config_invalid_mode(self, mock_error):
|
| 168 |
+
"""Tests that _run_config_validate returns False when mode is invalid."""
|
| 169 |
+
fake_mode = 'fake-mode'
|
| 170 |
+
os.environ['MODE'] = fake_mode
|
| 171 |
+
self.assertFalse(self._create_config()._run_config_validate())
|
| 172 |
+
mock_error.assert_called_with('Invalid MODE: %s. Must be one of %s.',
|
| 173 |
+
fake_mode,
|
| 174 |
+
config_utils.RunFuzzersConfig.MODES)
|
| 175 |
+
|
| 176 |
+
|
| 177 |
+
class GetSanitizerTest(unittest.TestCase):
|
| 178 |
+
"""Tests for _get_sanitizer."""
|
| 179 |
+
|
| 180 |
+
def setUp(self):
|
| 181 |
+
test_helpers.patch_environ(self)
|
| 182 |
+
self.sanitizer = 'memory'
|
| 183 |
+
|
| 184 |
+
def test_default_value(self):
|
| 185 |
+
"""Tests that the default value returned by _get_sanitizer is correct."""
|
| 186 |
+
self.assertEqual(config_utils._get_sanitizer(), 'address')
|
| 187 |
+
|
| 188 |
+
def test_normal_case(self):
|
| 189 |
+
"""Tests that _get_sanitizer returns the correct value in normal cases."""
|
| 190 |
+
os.environ['SANITIZER'] = self.sanitizer
|
| 191 |
+
self.assertEqual(config_utils._get_sanitizer(), self.sanitizer)
|
| 192 |
+
|
| 193 |
+
def test_capitalization(self):
|
| 194 |
+
"""Tests that that _get_sanitizer handles capitalization properly."""
|
| 195 |
+
os.environ['SANITIZER'] = self.sanitizer.upper()
|
| 196 |
+
self.assertEqual(config_utils._get_sanitizer(), self.sanitizer)
|
| 197 |
+
|
| 198 |
+
|
| 199 |
+
if __name__ == '__main__':
|
| 200 |
+
unittest.main()
|
local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/docker_test.py
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2021 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
"""Tests the functionality of the docker module."""
|
| 15 |
+
import unittest
|
| 16 |
+
from unittest import mock
|
| 17 |
+
|
| 18 |
+
import docker
|
| 19 |
+
import test_helpers
|
| 20 |
+
import workspace_utils
|
| 21 |
+
|
| 22 |
+
CONTAINER_NAME = 'example-container'
|
| 23 |
+
config = test_helpers.create_run_config(oss_fuzz_project_name='project',
|
| 24 |
+
workspace='/workspace')
|
| 25 |
+
config.workspace = '/workspace'
|
| 26 |
+
WORKSPACE = workspace_utils.Workspace(config)
|
| 27 |
+
SANITIZER = 'example-sanitizer'
|
| 28 |
+
LANGUAGE = 'example-language'
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
class GetProjectImageTest(unittest.TestCase):
|
| 32 |
+
"""Tests for get_project_image."""
|
| 33 |
+
|
| 34 |
+
def test_get_project_image(self):
|
| 35 |
+
"""Tests that get_project_image_name works as intended."""
|
| 36 |
+
project = 'my-project'
|
| 37 |
+
self.assertEqual(docker.get_project_image_name(project),
|
| 38 |
+
'gcr.io/oss-fuzz/my-project')
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
class GetDeleteImagesTest(unittest.TestCase):
|
| 42 |
+
"""Tests for delete_images."""
|
| 43 |
+
|
| 44 |
+
@mock.patch('utils.execute')
|
| 45 |
+
def test_delete_images(self, mock_execute): # pylint: disable=no-self-use
|
| 46 |
+
"""Tests that get_project_image_name works as intended."""
|
| 47 |
+
images = ['image']
|
| 48 |
+
docker.delete_images(images)
|
| 49 |
+
expected_calls = [
|
| 50 |
+
mock.call(['docker', 'rmi', '-f'] + images),
|
| 51 |
+
mock.call(['docker', 'builder', 'prune', '-f'])
|
| 52 |
+
]
|
| 53 |
+
|
| 54 |
+
mock_execute.assert_has_calls(expected_calls)
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
class GetBaseDockerRunArgsTest(unittest.TestCase):
|
| 58 |
+
"""Tests get_base_docker_run_args."""
|
| 59 |
+
|
| 60 |
+
@mock.patch('utils.get_container_name', return_value=CONTAINER_NAME)
|
| 61 |
+
def test_get_base_docker_run_args_container(self, _):
|
| 62 |
+
"""Tests that get_base_docker_run_args works as intended when inside a
|
| 63 |
+
container."""
|
| 64 |
+
docker_args, docker_container = docker.get_base_docker_run_args(
|
| 65 |
+
WORKSPACE, SANITIZER, LANGUAGE)
|
| 66 |
+
self.assertEqual(docker_container, CONTAINER_NAME)
|
| 67 |
+
expected_docker_args = []
|
| 68 |
+
expected_docker_args = [
|
| 69 |
+
'-e',
|
| 70 |
+
'FUZZING_ENGINE=libfuzzer',
|
| 71 |
+
'-e',
|
| 72 |
+
'CIFUZZ=True',
|
| 73 |
+
'-e',
|
| 74 |
+
f'SANITIZER={SANITIZER}',
|
| 75 |
+
'-e',
|
| 76 |
+
'ARCHITECTURE=x86_64',
|
| 77 |
+
'-e',
|
| 78 |
+
f'FUZZING_LANGUAGE={LANGUAGE}',
|
| 79 |
+
'-e',
|
| 80 |
+
f'OUT={WORKSPACE.out}',
|
| 81 |
+
'--volumes-from',
|
| 82 |
+
CONTAINER_NAME,
|
| 83 |
+
]
|
| 84 |
+
self.assertEqual(docker_args, expected_docker_args)
|
| 85 |
+
|
| 86 |
+
@mock.patch('utils.get_container_name', return_value=None)
|
| 87 |
+
def test_get_base_docker_run_args_no_container(self, _):
|
| 88 |
+
"""Tests that get_base_docker_run_args works as intended when not inside a
|
| 89 |
+
container."""
|
| 90 |
+
docker_args, docker_container = docker.get_base_docker_run_args(
|
| 91 |
+
WORKSPACE, SANITIZER, LANGUAGE)
|
| 92 |
+
self.assertEqual(docker_container, None)
|
| 93 |
+
expected_docker_args = [
|
| 94 |
+
'-e', 'FUZZING_ENGINE=libfuzzer', '-e', 'CIFUZZ=True', '-e',
|
| 95 |
+
f'SANITIZER={SANITIZER}', '-e', 'ARCHITECTURE=x86_64', '-e',
|
| 96 |
+
f'FUZZING_LANGUAGE={LANGUAGE}', '-e', f'OUT={WORKSPACE.out}', '-v',
|
| 97 |
+
f'{WORKSPACE.workspace}:{WORKSPACE.workspace}'
|
| 98 |
+
]
|
| 99 |
+
self.assertEqual(docker_args, expected_docker_args)
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
class GetBaseDockerRunCommandTest(unittest.TestCase):
|
| 103 |
+
"""Tests get_base_docker_run_args."""
|
| 104 |
+
|
| 105 |
+
@mock.patch('utils.get_container_name', return_value=None)
|
| 106 |
+
def test_get_base_docker_run_command_no_container(self, _):
|
| 107 |
+
"""Tests that get_base_docker_run_args works as intended when not inside a
|
| 108 |
+
container."""
|
| 109 |
+
docker_args, docker_container = docker.get_base_docker_run_command(
|
| 110 |
+
WORKSPACE, SANITIZER, LANGUAGE)
|
| 111 |
+
self.assertEqual(docker_container, None)
|
| 112 |
+
expected_docker_command = [
|
| 113 |
+
'docker', 'run', '--rm', '--privileged', '-e',
|
| 114 |
+
'FUZZING_ENGINE=libfuzzer', '-e', 'CIFUZZ=True', '-e',
|
| 115 |
+
f'SANITIZER={SANITIZER}', '-e', 'ARCHITECTURE=x86_64', '-e',
|
| 116 |
+
f'FUZZING_LANGUAGE={LANGUAGE}', '-e', f'OUT={WORKSPACE.out}', '-v',
|
| 117 |
+
f'{WORKSPACE.workspace}:{WORKSPACE.workspace}'
|
| 118 |
+
]
|
| 119 |
+
self.assertEqual(docker_args, expected_docker_command)
|
local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/example_cifuzz.yml
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: CIFuzz
|
| 2 |
+
on: [pull_request]
|
| 3 |
+
permissions: {}
|
| 4 |
+
jobs:
|
| 5 |
+
Fuzzing:
|
| 6 |
+
runs-on: ubuntu-latest
|
| 7 |
+
permissions:
|
| 8 |
+
security-events: write
|
| 9 |
+
steps:
|
| 10 |
+
- name: Build Fuzzers
|
| 11 |
+
id: build
|
| 12 |
+
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
|
| 13 |
+
with:
|
| 14 |
+
oss-fuzz-project-name: 'example'
|
| 15 |
+
- name: Run Fuzzers
|
| 16 |
+
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
|
| 17 |
+
with:
|
| 18 |
+
oss-fuzz-project-name: 'example'
|
| 19 |
+
fuzz-seconds: 600
|
| 20 |
+
output-sarif: true
|
| 21 |
+
- name: Upload Crash
|
| 22 |
+
uses: actions/upload-artifact@v3
|
| 23 |
+
if: failure() && steps.build.outcome == 'success'
|
| 24 |
+
with:
|
| 25 |
+
name: artifacts
|
| 26 |
+
path: ./out/artifacts
|
| 27 |
+
- name: Upload Sarif
|
| 28 |
+
if: always() && steps.build.outcome == 'success'
|
| 29 |
+
uses: github/codeql-action/upload-sarif@v2
|
| 30 |
+
with:
|
| 31 |
+
# Path to SARIF file relative to the root of the repository
|
| 32 |
+
sarif_file: cifuzz-sarif/results.sarif
|
| 33 |
+
checkout_path: cifuzz-sarif
|
local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/external-actions/run_fuzzers/action.yml
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# action.yml
|
| 2 |
+
name: 'run-fuzzers'
|
| 3 |
+
description: 'Runs fuzz target binaries for a specified length of time.'
|
| 4 |
+
inputs:
|
| 5 |
+
language:
|
| 6 |
+
description: 'Programming language project is written in.'
|
| 7 |
+
required: false
|
| 8 |
+
default: 'c++'
|
| 9 |
+
fuzz-seconds:
|
| 10 |
+
description: 'The total time allotted for fuzzing in seconds.'
|
| 11 |
+
required: true
|
| 12 |
+
default: 600
|
| 13 |
+
dry-run:
|
| 14 |
+
description: 'If set, run the action without actually reporting a failure.'
|
| 15 |
+
default: false
|
| 16 |
+
sanitizer:
|
| 17 |
+
description: 'The sanitizer to run the fuzzers with.'
|
| 18 |
+
default: 'address'
|
| 19 |
+
mode:
|
| 20 |
+
description: |
|
| 21 |
+
The mode to run the fuzzers with ("code-change", "batch", "coverage", or "prune").
|
| 22 |
+
"code-change" is for fuzzing a pull request or commit.
|
| 23 |
+
"batch" is for non-interactive fuzzing of an entire project.
|
| 24 |
+
"coverage" is for coverage generation.
|
| 25 |
+
"prune" is for corpus pruning.
|
| 26 |
+
required: false
|
| 27 |
+
default: 'code-change'
|
| 28 |
+
github-token:
|
| 29 |
+
description: |
|
| 30 |
+
Token for GitHub API. WARNING: THIS SHOULD NOT BE USED IN PRODUCTION YET
|
| 31 |
+
You should use "secrets.GITHUB_TOKEN" in your workflow file, do not
|
| 32 |
+
hardcode the token.
|
| 33 |
+
TODO(https://github.com/google/oss-fuzz/pull/5841#discussion_r639393361):
|
| 34 |
+
Document locking this down.
|
| 35 |
+
required: true
|
| 36 |
+
storage-repo:
|
| 37 |
+
description: |
|
| 38 |
+
The git repo to use for storing certain artifacts from fuzzing.
|
| 39 |
+
required: false
|
| 40 |
+
storage-repo-branch:
|
| 41 |
+
description: |
|
| 42 |
+
The branch of the git repo to use for storing certain artifacts from
|
| 43 |
+
fuzzing.
|
| 44 |
+
default: main
|
| 45 |
+
required: false
|
| 46 |
+
storage-repo-branch-coverage:
|
| 47 |
+
description: |
|
| 48 |
+
The branch of the git repo to use for storing coverage reports.
|
| 49 |
+
default: gh-pages
|
| 50 |
+
required: false
|
| 51 |
+
report-unreproducible-crashes:
|
| 52 |
+
description: 'If True, then unreproducible crashes will be reported.'
|
| 53 |
+
required: false
|
| 54 |
+
default: false
|
| 55 |
+
minimize-crashes:
|
| 56 |
+
description: 'If True, reportable crashes will be minimized.'
|
| 57 |
+
required: false
|
| 58 |
+
default: False
|
| 59 |
+
parallel-fuzzing:
|
| 60 |
+
description: "Whether to use all available cores for fuzzing."
|
| 61 |
+
required: false
|
| 62 |
+
default: false
|
| 63 |
+
output-sarif:
|
| 64 |
+
description: "Whether to output fuzzing results to SARIF."
|
| 65 |
+
required: false
|
| 66 |
+
default: false
|
| 67 |
+
report-timeouts:
|
| 68 |
+
description: "Whether to report fails due to timeout."
|
| 69 |
+
required: false
|
| 70 |
+
default: true
|
| 71 |
+
report-ooms:
|
| 72 |
+
description: "Whether to report fails due to OOM."
|
| 73 |
+
required: false
|
| 74 |
+
default: true
|
| 75 |
+
runs:
|
| 76 |
+
using: 'docker'
|
| 77 |
+
image: '../../../run_fuzzers.Dockerfile'
|
| 78 |
+
env:
|
| 79 |
+
OSS_FUZZ_PROJECT_NAME: ${{ inputs.oss-fuzz-project-name }}
|
| 80 |
+
LANGUAGE: ${{ inputs.language }}
|
| 81 |
+
FUZZ_SECONDS: ${{ inputs.fuzz-seconds }}
|
| 82 |
+
DRY_RUN: ${{ inputs.dry-run}}
|
| 83 |
+
SANITIZER: ${{ inputs.sanitizer }}
|
| 84 |
+
MODE: ${{ inputs.mode }}
|
| 85 |
+
GITHUB_TOKEN: ${{ inputs.github-token }}
|
| 86 |
+
LOW_DISK_SPACE: 'True'
|
| 87 |
+
GIT_STORE_REPO: ${{ inputs.storage-repo }}
|
| 88 |
+
GIT_STORE_BRANCH: ${{ inputs.storage-repo-branch }}
|
| 89 |
+
GIT_STORE_BRANCH_COVERAGE: ${{ inputs.storage-repo-branch-coverage }}
|
| 90 |
+
REPORT_UNREPRODUCIBLE_CRASHES: ${{ inputs.report-unreproducible-crashes }}
|
| 91 |
+
MINIMIZE_CRASHES: ${{ inputs.minimize-crashes }}
|
| 92 |
+
CIFUZZ_DEBUG: 'True'
|
| 93 |
+
CFL_PLATFORM: 'github'
|
| 94 |
+
PARALLEL_FUZZING: ${{ inputs.parallel-fuzzing }}
|
| 95 |
+
OUTPUT_SARIF: ${{ inputs.output-sarif }}
|
| 96 |
+
REPORT_TIMEOUTS: ${{ inputs.report-timeouts }}
|
| 97 |
+
REPORT_OOMS: ${{ inputs.report-ooms}}
|
local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/filestore/git/git_test.py
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2021 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
"""Tests for git."""
|
| 15 |
+
import filecmp
|
| 16 |
+
import os
|
| 17 |
+
import tempfile
|
| 18 |
+
import subprocess
|
| 19 |
+
import sys
|
| 20 |
+
import unittest
|
| 21 |
+
from unittest import mock
|
| 22 |
+
|
| 23 |
+
# pylint: disable=wrong-import-position
|
| 24 |
+
INFRA_DIR = os.path.dirname(
|
| 25 |
+
os.path.dirname(os.path.dirname(os.path.dirname(
|
| 26 |
+
os.path.abspath(__file__)))))
|
| 27 |
+
sys.path.append(INFRA_DIR)
|
| 28 |
+
|
| 29 |
+
from filestore import git
|
| 30 |
+
import test_helpers
|
| 31 |
+
|
| 32 |
+
# pylint: disable=protected-access,no-self-use
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
class GitFilestoreTest(unittest.TestCase):
|
| 36 |
+
"""Tests for GitFilestore."""
|
| 37 |
+
|
| 38 |
+
def setUp(self):
|
| 39 |
+
self.git_dir = tempfile.TemporaryDirectory()
|
| 40 |
+
self.addCleanup(self.git_dir.cleanup)
|
| 41 |
+
|
| 42 |
+
self.local_dir = tempfile.TemporaryDirectory()
|
| 43 |
+
self.addCleanup(self.local_dir.cleanup)
|
| 44 |
+
|
| 45 |
+
self.download_dir = tempfile.TemporaryDirectory()
|
| 46 |
+
self.addCleanup(self.download_dir.cleanup)
|
| 47 |
+
|
| 48 |
+
with open(os.path.join(self.local_dir.name, 'a'), 'w') as handle:
|
| 49 |
+
handle.write('')
|
| 50 |
+
|
| 51 |
+
os.makedirs(os.path.join(self.local_dir.name, 'b'))
|
| 52 |
+
|
| 53 |
+
with open(os.path.join(self.local_dir.name, 'b', 'c'), 'w') as handle:
|
| 54 |
+
handle.write('')
|
| 55 |
+
|
| 56 |
+
self.git_repo = git.git_runner(self.git_dir.name)
|
| 57 |
+
self.git_repo('init', '--bare')
|
| 58 |
+
|
| 59 |
+
self.config = test_helpers.create_run_config(
|
| 60 |
+
git_store_repo='file://' + self.git_dir.name,
|
| 61 |
+
git_store_branch='main',
|
| 62 |
+
git_store_branch_coverage='cov-branch')
|
| 63 |
+
|
| 64 |
+
self.mock_ci_filestore = mock.MagicMock()
|
| 65 |
+
self.git_store = git.GitFilestore(self.config, self.mock_ci_filestore)
|
| 66 |
+
|
| 67 |
+
def assert_dirs_same(self, first, second):
|
| 68 |
+
"""Asserts two dirs are the same."""
|
| 69 |
+
dcmp = filecmp.dircmp(first, second)
|
| 70 |
+
if dcmp.diff_files or dcmp.left_only or dcmp.right_only:
|
| 71 |
+
return False
|
| 72 |
+
|
| 73 |
+
return all(
|
| 74 |
+
self.assert_dirs_same(os.path.join(first, subdir),
|
| 75 |
+
os.path.join(second, subdir))
|
| 76 |
+
for subdir in dcmp.common_dirs)
|
| 77 |
+
|
| 78 |
+
def get_repo_filelist(self, branch):
|
| 79 |
+
"""Get files in repo."""
|
| 80 |
+
return subprocess.check_output([
|
| 81 |
+
'git', '-C', self.git_dir.name, 'ls-tree', '-r', '--name-only', branch
|
| 82 |
+
]).decode().splitlines()
|
| 83 |
+
|
| 84 |
+
def test_upload_download_corpus(self):
|
| 85 |
+
"""Tests uploading and downloading corpus."""
|
| 86 |
+
self.git_store.upload_corpus('target', self.local_dir.name)
|
| 87 |
+
self.git_store.download_corpus('target', self.download_dir.name)
|
| 88 |
+
self.assert_dirs_same(self.local_dir.name, self.download_dir.name)
|
| 89 |
+
|
| 90 |
+
self.assertCountEqual([
|
| 91 |
+
'corpus/target/a',
|
| 92 |
+
'corpus/target/b/c',
|
| 93 |
+
], self.get_repo_filelist('main'))
|
| 94 |
+
|
| 95 |
+
def test_upload_download_coverage(self):
|
| 96 |
+
"""Tests uploading and downloading corpus."""
|
| 97 |
+
self.git_store.upload_coverage('latest', self.local_dir.name)
|
| 98 |
+
self.git_store.download_coverage('latest', self.download_dir.name)
|
| 99 |
+
self.assert_dirs_same(self.local_dir.name, self.download_dir.name)
|
| 100 |
+
|
| 101 |
+
self.assertCountEqual([
|
| 102 |
+
'coverage/latest/a',
|
| 103 |
+
'coverage/latest/b/c',
|
| 104 |
+
], self.get_repo_filelist('cov-branch'))
|
| 105 |
+
|
| 106 |
+
def test_upload_crashes(self):
|
| 107 |
+
"""Tests uploading crashes."""
|
| 108 |
+
self.git_store.upload_crashes('current', self.local_dir.name)
|
| 109 |
+
self.mock_ci_filestore.upload_crashes.assert_called_with(
|
| 110 |
+
'current', self.local_dir.name)
|
| 111 |
+
|
| 112 |
+
def test_upload_build(self):
|
| 113 |
+
"""Tests uploading build."""
|
| 114 |
+
self.git_store.upload_build('sanitizer', self.local_dir.name)
|
| 115 |
+
self.mock_ci_filestore.upload_build.assert_called_with(
|
| 116 |
+
'sanitizer', self.local_dir.name)
|
| 117 |
+
|
| 118 |
+
def test_download_build(self):
|
| 119 |
+
"""Tests downloading build."""
|
| 120 |
+
self.git_store.download_build('sanitizer', self.download_dir.name)
|
| 121 |
+
self.mock_ci_filestore.download_build.assert_called_with(
|
| 122 |
+
'sanitizer', self.download_dir.name)
|
local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/filestore/github_actions/github_actions_test.py
ADDED
|
@@ -0,0 +1,283 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2021 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
"""Tests for github_actions."""
|
| 15 |
+
import os
|
| 16 |
+
import shutil
|
| 17 |
+
import sys
|
| 18 |
+
import tarfile
|
| 19 |
+
import tempfile
|
| 20 |
+
import unittest
|
| 21 |
+
from unittest import mock
|
| 22 |
+
|
| 23 |
+
from pyfakefs import fake_filesystem_unittest
|
| 24 |
+
|
| 25 |
+
# pylint: disable=wrong-import-position
|
| 26 |
+
INFRA_DIR = os.path.dirname(
|
| 27 |
+
os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
| 28 |
+
sys.path.append(INFRA_DIR)
|
| 29 |
+
|
| 30 |
+
from filestore import github_actions
|
| 31 |
+
import test_helpers
|
| 32 |
+
|
| 33 |
+
# pylint: disable=protected-access,no-self-use
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
class GithubActionsFilestoreTest(fake_filesystem_unittest.TestCase):
|
| 37 |
+
"""Tests for GithubActionsFilestore."""
|
| 38 |
+
|
| 39 |
+
@mock.patch('platform_config.github._get_event_data', return_value={})
|
| 40 |
+
def setUp(self, _): # pylint: disable=arguments-differ
|
| 41 |
+
test_helpers.patch_environ(self)
|
| 42 |
+
self.token = 'example githubtoken'
|
| 43 |
+
self.owner = 'exampleowner'
|
| 44 |
+
self.repo = 'examplerepo'
|
| 45 |
+
os.environ['GITHUB_REPOSITORY'] = f'{self.owner}/{self.repo}'
|
| 46 |
+
os.environ['GITHUB_EVENT_PATH'] = '/fake'
|
| 47 |
+
os.environ['CFL_PLATFORM'] = 'github'
|
| 48 |
+
os.environ['GITHUB_WORKSPACE'] = '/workspace'
|
| 49 |
+
self.config = test_helpers.create_run_config(token=self.token)
|
| 50 |
+
self.local_dir = '/local-dir'
|
| 51 |
+
self.testcase = os.path.join(self.local_dir, 'testcase')
|
| 52 |
+
|
| 53 |
+
def _get_expected_http_headers(self):
|
| 54 |
+
return {
|
| 55 |
+
'Authorization': f'token {self.token}',
|
| 56 |
+
'Accept': 'application/vnd.github.v3+json',
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
@mock.patch('filestore.github_actions.github_api.list_artifacts')
|
| 60 |
+
def test_list_artifacts(self, mock_list_artifacts):
|
| 61 |
+
"""Tests that _list_artifacts works as intended."""
|
| 62 |
+
filestore = github_actions.GithubActionsFilestore(self.config)
|
| 63 |
+
filestore._list_artifacts()
|
| 64 |
+
mock_list_artifacts.assert_called_with(self.owner, self.repo,
|
| 65 |
+
self._get_expected_http_headers())
|
| 66 |
+
|
| 67 |
+
@mock.patch('logging.warning')
|
| 68 |
+
@mock.patch('filestore.github_actions.GithubActionsFilestore._list_artifacts',
|
| 69 |
+
return_value=None)
|
| 70 |
+
@mock.patch('filestore.github_actions.github_api.find_artifact',
|
| 71 |
+
return_value=None)
|
| 72 |
+
def test_download_build_no_artifact(self, _, __, mock_warning):
|
| 73 |
+
"""Tests that download_build returns None and doesn't exception when
|
| 74 |
+
find_artifact can't find an artifact."""
|
| 75 |
+
filestore = github_actions.GithubActionsFilestore(self.config)
|
| 76 |
+
name = 'name'
|
| 77 |
+
build_dir = 'build-dir'
|
| 78 |
+
self.assertFalse(filestore.download_build(name, build_dir))
|
| 79 |
+
mock_warning.assert_called_with('Could not download artifact: %s.',
|
| 80 |
+
'cifuzz-build-' + name)
|
| 81 |
+
|
| 82 |
+
@mock.patch('logging.warning')
|
| 83 |
+
@mock.patch('filestore.github_actions.GithubActionsFilestore._list_artifacts',
|
| 84 |
+
return_value=None)
|
| 85 |
+
@mock.patch('filestore.github_actions.github_api.find_artifact',
|
| 86 |
+
return_value=None)
|
| 87 |
+
def test_download_corpus_no_artifact(self, _, __, mock_warning):
|
| 88 |
+
"""Tests that download_corpus_build returns None and doesn't exception when
|
| 89 |
+
find_artifact can't find an artifact."""
|
| 90 |
+
filestore = github_actions.GithubActionsFilestore(self.config)
|
| 91 |
+
name = 'name'
|
| 92 |
+
dst_dir = 'local-dir'
|
| 93 |
+
self.assertFalse(filestore.download_corpus(name, dst_dir))
|
| 94 |
+
mock_warning.assert_called_with('Could not download artifact: %s.',
|
| 95 |
+
'cifuzz-corpus-' + name)
|
| 96 |
+
|
| 97 |
+
@mock.patch('filestore.github_actions.tar_directory')
|
| 98 |
+
@mock.patch('filestore.github_actions._upload_artifact_with_upload_js')
|
| 99 |
+
def test_upload_corpus(self, mock_upload_artifact, mock_tar_directory):
|
| 100 |
+
"""Test uploading corpus."""
|
| 101 |
+
self._create_local_dir()
|
| 102 |
+
|
| 103 |
+
def mock_tar_directory_impl(_, archive_path):
|
| 104 |
+
self.fs.create_file(archive_path)
|
| 105 |
+
|
| 106 |
+
mock_tar_directory.side_effect = mock_tar_directory_impl
|
| 107 |
+
|
| 108 |
+
filestore = github_actions.GithubActionsFilestore(self.config)
|
| 109 |
+
filestore.upload_corpus('target', self.local_dir)
|
| 110 |
+
self.assert_upload(mock_upload_artifact, mock_tar_directory,
|
| 111 |
+
'corpus-target')
|
| 112 |
+
|
| 113 |
+
@mock.patch('filestore.github_actions._upload_artifact_with_upload_js')
|
| 114 |
+
def test_upload_crashes(self, mock_upload_artifact):
|
| 115 |
+
"""Test uploading crashes."""
|
| 116 |
+
self._create_local_dir()
|
| 117 |
+
|
| 118 |
+
filestore = github_actions.GithubActionsFilestore(self.config)
|
| 119 |
+
filestore.upload_crashes('current', self.local_dir)
|
| 120 |
+
mock_upload_artifact.assert_has_calls(
|
| 121 |
+
[mock.call('crashes-current', ['/local-dir/testcase'], '/local-dir')])
|
| 122 |
+
|
| 123 |
+
@mock.patch('filestore.github_actions.tar_directory')
|
| 124 |
+
@mock.patch('filestore.github_actions._upload_artifact_with_upload_js')
|
| 125 |
+
def test_upload_build(self, mock_upload_artifact, mock_tar_directory):
|
| 126 |
+
"""Test uploading build."""
|
| 127 |
+
self._create_local_dir()
|
| 128 |
+
|
| 129 |
+
def mock_tar_directory_impl(_, archive_path):
|
| 130 |
+
self.fs.create_file(archive_path)
|
| 131 |
+
|
| 132 |
+
mock_tar_directory.side_effect = mock_tar_directory_impl
|
| 133 |
+
|
| 134 |
+
filestore = github_actions.GithubActionsFilestore(self.config)
|
| 135 |
+
filestore.upload_build('sanitizer', self.local_dir)
|
| 136 |
+
self.assert_upload(mock_upload_artifact, mock_tar_directory,
|
| 137 |
+
'build-sanitizer')
|
| 138 |
+
|
| 139 |
+
@mock.patch('filestore.github_actions.tar_directory')
|
| 140 |
+
@mock.patch('filestore.github_actions._upload_artifact_with_upload_js')
|
| 141 |
+
def test_upload_coverage(self, mock_upload_artifact, mock_tar_directory):
|
| 142 |
+
"""Test uploading coverage."""
|
| 143 |
+
self._create_local_dir()
|
| 144 |
+
|
| 145 |
+
def mock_tar_directory_impl(_, archive_path):
|
| 146 |
+
self.fs.create_file(archive_path)
|
| 147 |
+
|
| 148 |
+
mock_tar_directory.side_effect = mock_tar_directory_impl
|
| 149 |
+
|
| 150 |
+
filestore = github_actions.GithubActionsFilestore(self.config)
|
| 151 |
+
filestore.upload_coverage('latest', self.local_dir)
|
| 152 |
+
self.assert_upload(mock_upload_artifact, mock_tar_directory,
|
| 153 |
+
'coverage-latest')
|
| 154 |
+
|
| 155 |
+
def assert_upload(self, mock_upload_artifact, mock_tar_directory,
|
| 156 |
+
expected_artifact_name):
|
| 157 |
+
"""Tests that upload_directory invokes tar_directory and
|
| 158 |
+
artifact_client.upload_artifact properly."""
|
| 159 |
+
# Don't assert what second argument will be since it's a temporary
|
| 160 |
+
# directory.
|
| 161 |
+
self.assertEqual(mock_tar_directory.call_args_list[0][0][0], self.local_dir)
|
| 162 |
+
|
| 163 |
+
# Don't assert what second and third arguments will be since they are
|
| 164 |
+
# temporary directories.
|
| 165 |
+
expected_artifact_name = 'cifuzz-' + expected_artifact_name
|
| 166 |
+
self.assertEqual(mock_upload_artifact.call_args_list[0][0][0],
|
| 167 |
+
expected_artifact_name)
|
| 168 |
+
|
| 169 |
+
# Assert artifacts list contains one tarfile.
|
| 170 |
+
artifacts_list = mock_upload_artifact.call_args_list[0][0][1]
|
| 171 |
+
self.assertEqual(len(artifacts_list), 1)
|
| 172 |
+
self.assertEqual(os.path.basename(artifacts_list[0]),
|
| 173 |
+
expected_artifact_name + '.tar')
|
| 174 |
+
|
| 175 |
+
def _create_local_dir(self):
|
| 176 |
+
"""Sets up pyfakefs and creates a corpus directory containing
|
| 177 |
+
self.testcase."""
|
| 178 |
+
self.setUpPyfakefs()
|
| 179 |
+
self.fs.create_file(self.testcase, contents='hi')
|
| 180 |
+
|
| 181 |
+
@mock.patch('filestore.github_actions.GithubActionsFilestore._find_artifact')
|
| 182 |
+
@mock.patch('http_utils.download_and_unpack_zip')
|
| 183 |
+
def test_download_artifact(self, mock_download_and_unpack_zip,
|
| 184 |
+
mock_find_artifact):
|
| 185 |
+
"""Tests that _download_artifact works as intended."""
|
| 186 |
+
artifact_download_url = 'http://example.com/download'
|
| 187 |
+
artifact_listing = {
|
| 188 |
+
'expired': False,
|
| 189 |
+
'name': 'corpus',
|
| 190 |
+
'archive_download_url': artifact_download_url
|
| 191 |
+
}
|
| 192 |
+
mock_find_artifact.return_value = artifact_listing
|
| 193 |
+
|
| 194 |
+
self._create_local_dir()
|
| 195 |
+
with tempfile.TemporaryDirectory() as temp_dir:
|
| 196 |
+
# Create a tarball.
|
| 197 |
+
archive_path = os.path.join(temp_dir, 'cifuzz-corpus.tar')
|
| 198 |
+
github_actions.tar_directory(self.local_dir, archive_path)
|
| 199 |
+
|
| 200 |
+
artifact_download_dst_dir = os.path.join(temp_dir, 'dst')
|
| 201 |
+
os.mkdir(artifact_download_dst_dir)
|
| 202 |
+
|
| 203 |
+
def mock_download_and_unpack_zip_impl(url, download_artifact_temp_dir,
|
| 204 |
+
headers):
|
| 205 |
+
self.assertEqual(url, artifact_download_url)
|
| 206 |
+
self.assertEqual(headers, self._get_expected_http_headers())
|
| 207 |
+
shutil.copy(
|
| 208 |
+
archive_path,
|
| 209 |
+
os.path.join(download_artifact_temp_dir,
|
| 210 |
+
os.path.basename(archive_path)))
|
| 211 |
+
return True
|
| 212 |
+
|
| 213 |
+
mock_download_and_unpack_zip.side_effect = (
|
| 214 |
+
mock_download_and_unpack_zip_impl)
|
| 215 |
+
filestore = github_actions.GithubActionsFilestore(self.config)
|
| 216 |
+
self.assertTrue(
|
| 217 |
+
filestore._download_artifact('corpus', artifact_download_dst_dir))
|
| 218 |
+
mock_find_artifact.assert_called_with('cifuzz-corpus')
|
| 219 |
+
self.assertTrue(
|
| 220 |
+
os.path.exists(
|
| 221 |
+
os.path.join(artifact_download_dst_dir,
|
| 222 |
+
os.path.basename(self.testcase))))
|
| 223 |
+
|
| 224 |
+
@mock.patch('filestore.github_actions.github_api.list_artifacts')
|
| 225 |
+
def test_find_artifact(self, mock_list_artifacts):
|
| 226 |
+
"""Tests that _find_artifact works as intended."""
|
| 227 |
+
artifact_listing_1 = {
|
| 228 |
+
'expired': False,
|
| 229 |
+
'name': 'other',
|
| 230 |
+
'archive_download_url': 'http://download1'
|
| 231 |
+
}
|
| 232 |
+
artifact_listing_2 = {
|
| 233 |
+
'expired': False,
|
| 234 |
+
'name': 'artifact',
|
| 235 |
+
'archive_download_url': 'http://download2'
|
| 236 |
+
}
|
| 237 |
+
artifact_listing_3 = {
|
| 238 |
+
'expired': True,
|
| 239 |
+
'name': 'artifact',
|
| 240 |
+
'archive_download_url': 'http://download3'
|
| 241 |
+
}
|
| 242 |
+
artifact_listing_4 = {
|
| 243 |
+
'expired': False,
|
| 244 |
+
'name': 'artifact',
|
| 245 |
+
'archive_download_url': 'http://download4'
|
| 246 |
+
}
|
| 247 |
+
artifacts = [
|
| 248 |
+
artifact_listing_1, artifact_listing_2, artifact_listing_3,
|
| 249 |
+
artifact_listing_4
|
| 250 |
+
]
|
| 251 |
+
mock_list_artifacts.return_value = artifacts
|
| 252 |
+
filestore = github_actions.GithubActionsFilestore(self.config)
|
| 253 |
+
# Test that find_artifact will return the most recent unexpired artifact
|
| 254 |
+
# with the correct name.
|
| 255 |
+
self.assertEqual(filestore._find_artifact('artifact'), artifact_listing_2)
|
| 256 |
+
mock_list_artifacts.assert_called_with(self.owner, self.repo,
|
| 257 |
+
self._get_expected_http_headers())
|
| 258 |
+
|
| 259 |
+
|
| 260 |
+
class TarDirectoryTest(unittest.TestCase):
|
| 261 |
+
"""Tests for tar_directory."""
|
| 262 |
+
|
| 263 |
+
def test_tar_directory(self):
|
| 264 |
+
"""Tests that tar_directory writes the archive to the correct location and
|
| 265 |
+
archives properly."""
|
| 266 |
+
with tempfile.TemporaryDirectory() as temp_dir:
|
| 267 |
+
archive_path = os.path.join(temp_dir, 'myarchive.tar')
|
| 268 |
+
archived_dir = os.path.join(temp_dir, 'toarchive')
|
| 269 |
+
os.mkdir(archived_dir)
|
| 270 |
+
archived_filename = 'file1'
|
| 271 |
+
archived_file_path = os.path.join(archived_dir, archived_filename)
|
| 272 |
+
with open(archived_file_path, 'w') as file_handle:
|
| 273 |
+
file_handle.write('hi')
|
| 274 |
+
github_actions.tar_directory(archived_dir, archive_path)
|
| 275 |
+
self.assertTrue(os.path.exists(archive_path))
|
| 276 |
+
|
| 277 |
+
# Now check it archives correctly.
|
| 278 |
+
unpacked_directory = os.path.join(temp_dir, 'unpacked')
|
| 279 |
+
with tarfile.TarFile(archive_path) as artifact_tarfile:
|
| 280 |
+
artifact_tarfile.extractall(unpacked_directory)
|
| 281 |
+
unpacked_archived_file_path = os.path.join(unpacked_directory,
|
| 282 |
+
archived_filename)
|
| 283 |
+
self.assertTrue(os.path.exists(unpacked_archived_file_path))
|
local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/filestore/github_actions/github_api.py
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2021 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
"""Module for dealing with the GitHub API. This is different from
|
| 15 |
+
github_actions_toolkit which only deals with the actions API. We need to use
|
| 16 |
+
both."""
|
| 17 |
+
import logging
|
| 18 |
+
import os
|
| 19 |
+
import sys
|
| 20 |
+
|
| 21 |
+
import requests
|
| 22 |
+
|
| 23 |
+
import filestore
|
| 24 |
+
|
| 25 |
+
# pylint: disable=wrong-import-position,import-error
|
| 26 |
+
|
| 27 |
+
sys.path.append(
|
| 28 |
+
os.path.join(__file__, os.path.pardir, os.path.pardir, os.path.pardir,
|
| 29 |
+
os.path.pardir))
|
| 30 |
+
import retry
|
| 31 |
+
|
| 32 |
+
_MAX_ITEMS_PER_PAGE = 100
|
| 33 |
+
|
| 34 |
+
_GET_ATTEMPTS = 3
|
| 35 |
+
_GET_BACKOFF = 1
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
def get_http_auth_headers(config):
|
| 39 |
+
"""Returns HTTP headers for authentication to the API."""
|
| 40 |
+
authorization = f'token {config.token}'
|
| 41 |
+
return {
|
| 42 |
+
'Authorization': authorization,
|
| 43 |
+
'Accept': 'application/vnd.github.v3+json'
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
def _get_artifacts_list_api_url(repo_owner, repo_name):
|
| 48 |
+
"""Returns the artifacts_api_url for |repo_name| owned by |repo_owner|."""
|
| 49 |
+
github_api_url = os.getenv('GITHUB_API_URL', 'https://api.github.com')
|
| 50 |
+
return (f'{github_api_url}/repos/{repo_owner}/'
|
| 51 |
+
f'{repo_name}/actions/artifacts')
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
@retry.wrap(_GET_ATTEMPTS, _GET_BACKOFF)
|
| 55 |
+
def _do_get_request(*args, **kwargs):
|
| 56 |
+
"""Wrapped version of requests.get that does retries."""
|
| 57 |
+
return requests.get(*args, **kwargs)
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
def _get_items(url, headers):
|
| 61 |
+
"""Generator that gets and yields items from a GitHub API endpoint (specified
|
| 62 |
+
by |URL|) sending |headers| with the get request."""
|
| 63 |
+
# Github API response pages are 1-indexed.
|
| 64 |
+
page_counter = 1
|
| 65 |
+
|
| 66 |
+
# Set to infinity so we run loop at least once.
|
| 67 |
+
total_num_items = float('inf')
|
| 68 |
+
|
| 69 |
+
item_num = 0
|
| 70 |
+
while item_num < total_num_items:
|
| 71 |
+
params = {'per_page': _MAX_ITEMS_PER_PAGE, 'page': str(page_counter)}
|
| 72 |
+
response = _do_get_request(url, params=params, headers=headers)
|
| 73 |
+
response_json = response.json()
|
| 74 |
+
if not response.status_code == 200:
|
| 75 |
+
# Check that request was successful.
|
| 76 |
+
logging.error('Request to %s failed. Code: %d. Response: %s',
|
| 77 |
+
response.request.url, response.status_code, response_json)
|
| 78 |
+
raise filestore.FilestoreError('Github API request failed.')
|
| 79 |
+
|
| 80 |
+
if total_num_items == float('inf'):
|
| 81 |
+
# Set proper total_num_items
|
| 82 |
+
total_num_items = response_json['total_count']
|
| 83 |
+
|
| 84 |
+
# Get the key for the items we are after.
|
| 85 |
+
keys = [key for key in response_json.keys() if key != 'total_count']
|
| 86 |
+
assert len(keys) == 1, keys
|
| 87 |
+
items_key = keys[0]
|
| 88 |
+
|
| 89 |
+
for item in response_json[items_key]:
|
| 90 |
+
yield item
|
| 91 |
+
item_num += 1
|
| 92 |
+
|
| 93 |
+
page_counter += 1
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
def find_artifact(artifact_name, artifacts):
|
| 97 |
+
"""Find the artifact with the name |artifact_name| in |artifacts|."""
|
| 98 |
+
for artifact in artifacts:
|
| 99 |
+
# TODO(metzman): Handle multiple by making sure we download the latest.
|
| 100 |
+
if artifact['name'] == artifact_name and not artifact['expired']:
|
| 101 |
+
return artifact
|
| 102 |
+
return None
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
def list_artifacts(owner, repo, headers):
|
| 106 |
+
"""Returns a generator of all the artifacts for |owner|/|repo|."""
|
| 107 |
+
url = _get_artifacts_list_api_url(owner, repo)
|
| 108 |
+
logging.debug('Getting artifacts from: %s', url)
|
| 109 |
+
return _get_items(url, headers)
|
local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/filestore/github_actions/github_api_test.py
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2021 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
"""Tests for github_api."""
|
| 15 |
+
import os
|
| 16 |
+
import sys
|
| 17 |
+
import unittest
|
| 18 |
+
|
| 19 |
+
# pylint: disable=wrong-import-position,import-error
|
| 20 |
+
sys.path.append(
|
| 21 |
+
os.path.abspath(
|
| 22 |
+
os.path.join(os.path.dirname(__file__), os.path.pardir, os.path.pardir,
|
| 23 |
+
os.path.pardir)))
|
| 24 |
+
|
| 25 |
+
from filestore.github_actions import github_api
|
| 26 |
+
import test_helpers
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
class GetHttpAuthHeaders(unittest.TestCase):
|
| 30 |
+
"""Tests for get_http_auth_headers."""
|
| 31 |
+
|
| 32 |
+
def test_get_http_auth_headers(self):
|
| 33 |
+
"""Tests that get_http_auth_headers returns the correct result."""
|
| 34 |
+
token = 'example githubtoken'
|
| 35 |
+
run_config = test_helpers.create_run_config(token=token)
|
| 36 |
+
expected_headers = {
|
| 37 |
+
'Authorization': f'token {token}',
|
| 38 |
+
'Accept': 'application/vnd.github.v3+json',
|
| 39 |
+
}
|
| 40 |
+
self.assertEqual(expected_headers,
|
| 41 |
+
github_api.get_http_auth_headers(run_config))
|
local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/filestore/no_filestore/__init__.py
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2021 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
"""Empty filestore implementation for platforms that haven't implemented it."""
|
| 15 |
+
import logging
|
| 16 |
+
|
| 17 |
+
import filestore
|
| 18 |
+
|
| 19 |
+
# pylint:disable=no-self-use,unused-argument
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
class NoFilestore(filestore.BaseFilestore):
|
| 23 |
+
"""Empty Filestore implementation."""
|
| 24 |
+
|
| 25 |
+
def upload_crashes(self, name, directory):
|
| 26 |
+
"""Noop implementation of upload_crashes."""
|
| 27 |
+
logging.info('Not uploading crashes because no Filestore.')
|
| 28 |
+
|
| 29 |
+
def upload_corpus(self, name, directory, replace=False):
|
| 30 |
+
"""Noop implementation of upload_corpus."""
|
| 31 |
+
logging.info('Not uploading corpus because no Filestore.')
|
| 32 |
+
|
| 33 |
+
def upload_build(self, name, directory):
|
| 34 |
+
"""Noop implementation of upload_build."""
|
| 35 |
+
logging.info('Not uploading build because no Filestore.')
|
| 36 |
+
|
| 37 |
+
def upload_coverage(self, name, directory):
|
| 38 |
+
"""Noop implementation of upload_coverage."""
|
| 39 |
+
logging.info('Not uploading coverage because no Filestore.')
|
| 40 |
+
|
| 41 |
+
def download_corpus(self, name, dst_directory):
|
| 42 |
+
"""Noop implementation of download_corpus."""
|
| 43 |
+
logging.info('Not downloading corpus because no Filestore.')
|
| 44 |
+
|
| 45 |
+
def download_build(self, name, dst_directory):
|
| 46 |
+
"""Noop implementation of download_build."""
|
| 47 |
+
logging.info('Not downloading build because no Filestore.')
|
| 48 |
+
|
| 49 |
+
def download_coverage(self, name, dst_directory):
|
| 50 |
+
"""Noop implementation of download_coverage."""
|
| 51 |
+
logging.info('Not downloading coverage because no Filestore.')
|
local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/filestore_utils_test.py
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2021 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
"""Tests for filestore_utils."""
|
| 15 |
+
import unittest
|
| 16 |
+
from unittest import mock
|
| 17 |
+
|
| 18 |
+
import parameterized
|
| 19 |
+
|
| 20 |
+
import platform_config
|
| 21 |
+
import filestore
|
| 22 |
+
from filestore import github_actions
|
| 23 |
+
import filestore_utils
|
| 24 |
+
import test_helpers
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
class GetFilestoreTest(unittest.TestCase):
|
| 28 |
+
"""Tests for get_filestore."""
|
| 29 |
+
|
| 30 |
+
@parameterized.parameterized.expand([
|
| 31 |
+
({
|
| 32 |
+
'cfl_platform': 'github',
|
| 33 |
+
}, github_actions.GithubActionsFilestore),
|
| 34 |
+
])
|
| 35 |
+
def test_get_filestore(self, config_kwargs, filestore_cls):
|
| 36 |
+
"""Tests that get_filestore returns the right filestore given a certain
|
| 37 |
+
platform."""
|
| 38 |
+
run_config = test_helpers.create_run_config(**config_kwargs)
|
| 39 |
+
filestore_impl = filestore_utils.get_filestore(run_config)
|
| 40 |
+
self.assertIsInstance(filestore_impl, filestore_cls)
|
| 41 |
+
|
| 42 |
+
@mock.patch('config_utils.BaseConfig.platform', return_value='other')
|
| 43 |
+
@mock.patch('config_utils._get_platform_config',
|
| 44 |
+
return_value=platform_config.BasePlatformConfig())
|
| 45 |
+
def test_get_filestore_unsupported_platform(self, _, __):
|
| 46 |
+
"""Tests that get_filestore exceptions given a platform it doesn't
|
| 47 |
+
support."""
|
| 48 |
+
run_config = test_helpers.create_run_config()
|
| 49 |
+
with self.assertRaises(filestore.FilestoreError):
|
| 50 |
+
filestore_utils.get_filestore(run_config)
|
local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/fuzz_target_test.py
ADDED
|
@@ -0,0 +1,298 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2020 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
"""Tests the functionality of the fuzz_target module."""
|
| 15 |
+
|
| 16 |
+
import os
|
| 17 |
+
import shutil
|
| 18 |
+
import tempfile
|
| 19 |
+
import unittest
|
| 20 |
+
from unittest import mock
|
| 21 |
+
|
| 22 |
+
import certifi
|
| 23 |
+
# Importing this later causes import failures with pytest for some reason.
|
| 24 |
+
# TODO(ochang): Figure out why.
|
| 25 |
+
import parameterized
|
| 26 |
+
import google.cloud.ndb # pylint: disable=unused-import
|
| 27 |
+
from pyfakefs import fake_filesystem_unittest
|
| 28 |
+
from clusterfuzz.fuzz import engine
|
| 29 |
+
|
| 30 |
+
import clusterfuzz_deployment
|
| 31 |
+
import fuzz_target
|
| 32 |
+
import test_helpers
|
| 33 |
+
import workspace_utils
|
| 34 |
+
|
| 35 |
+
# NOTE: This integration test relies on
|
| 36 |
+
# https://github.com/google/oss-fuzz/tree/master/projects/example project.
|
| 37 |
+
EXAMPLE_PROJECT = 'example'
|
| 38 |
+
|
| 39 |
+
# An example fuzzer that triggers an error.
|
| 40 |
+
EXAMPLE_FUZZER = 'example_crash_fuzzer'
|
| 41 |
+
|
| 42 |
+
# Mock return values for engine_impl.reproduce.
|
| 43 |
+
EXECUTE_SUCCESS_RESULT = engine.ReproduceResult([], 0, 0, '')
|
| 44 |
+
EXECUTE_FAILURE_RESULT = engine.ReproduceResult([], 1, 0, '')
|
| 45 |
+
|
| 46 |
+
TEST_DATA_PATH = os.path.join(os.path.dirname(__file__), 'test_data')
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
def _create_config(**kwargs):
|
| 50 |
+
"""Creates a config object and then sets every attribute that is a key in
|
| 51 |
+
|kwargs| to the corresponding value. Asserts that each key in |kwargs| is an
|
| 52 |
+
attribute of Config."""
|
| 53 |
+
defaults = {
|
| 54 |
+
'cfl_platform': 'github',
|
| 55 |
+
'oss_fuzz_project_name': EXAMPLE_PROJECT,
|
| 56 |
+
'workspace': '/workspace'
|
| 57 |
+
}
|
| 58 |
+
for default_key, default_value in defaults.items():
|
| 59 |
+
if default_key not in kwargs:
|
| 60 |
+
kwargs[default_key] = default_value
|
| 61 |
+
|
| 62 |
+
return test_helpers.create_run_config(**kwargs)
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
def _create_deployment(**kwargs):
|
| 66 |
+
config = _create_config(**kwargs)
|
| 67 |
+
workspace = workspace_utils.Workspace(config)
|
| 68 |
+
return clusterfuzz_deployment.get_clusterfuzz_deployment(config, workspace)
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
@mock.patch('utils.get_container_name', return_value='container')
|
| 72 |
+
class IsReproducibleTest(fake_filesystem_unittest.TestCase):
|
| 73 |
+
"""Tests the is_reproducible method in the fuzz_target.FuzzTarget class."""
|
| 74 |
+
|
| 75 |
+
def setUp(self):
|
| 76 |
+
"""Sets up example fuzz target to test is_reproducible method."""
|
| 77 |
+
self.fuzz_target_name = 'fuzz-target'
|
| 78 |
+
deployment = _create_deployment()
|
| 79 |
+
self.config = deployment.config
|
| 80 |
+
self.workspace = deployment.workspace
|
| 81 |
+
self.fuzz_target_path = os.path.join(self.workspace.out,
|
| 82 |
+
self.fuzz_target_name)
|
| 83 |
+
self.setUpPyfakefs()
|
| 84 |
+
self.fs.create_file(self.fuzz_target_path)
|
| 85 |
+
self.testcase_path = '/testcase'
|
| 86 |
+
self.fs.create_file(self.testcase_path)
|
| 87 |
+
|
| 88 |
+
self.target = fuzz_target.FuzzTarget(self.fuzz_target_path,
|
| 89 |
+
fuzz_target.REPRODUCE_ATTEMPTS,
|
| 90 |
+
self.workspace, deployment,
|
| 91 |
+
deployment.config)
|
| 92 |
+
|
| 93 |
+
# ClusterFuzz requires ROOT_DIR.
|
| 94 |
+
root_dir = os.environ['ROOT_DIR']
|
| 95 |
+
test_helpers.patch_environ(self, empty=True)
|
| 96 |
+
os.environ['ROOT_DIR'] = root_dir
|
| 97 |
+
|
| 98 |
+
# There's an extremely bad issue that happens if this test is run: Other tests
|
| 99 |
+
# in this file fail in CI with stacktraces using referencing fakefs even if
|
| 100 |
+
# the tests do not use fakefs.
|
| 101 |
+
# TODO(metzman): Stop using fakefs.
|
| 102 |
+
@mock.patch('os.chmod')
|
| 103 |
+
@unittest.skip('Skip because of weird failures.')
|
| 104 |
+
def test_repro_timed_out(self, mock_chmod, mock_get_container_name):
|
| 105 |
+
"""Tests that is_reproducible behaves correctly when reproduction times
|
| 106 |
+
out."""
|
| 107 |
+
del mock_get_container_name
|
| 108 |
+
del mock_chmod
|
| 109 |
+
|
| 110 |
+
with mock.patch(
|
| 111 |
+
'clusterfuzz._internal.bot.fuzzers.libFuzzer.engine.LibFuzzerEngine.'
|
| 112 |
+
'reproduce',
|
| 113 |
+
side_effect=TimeoutError):
|
| 114 |
+
self.assertFalse(
|
| 115 |
+
self.target.is_reproducible('/testcase', self.target.target_path, []))
|
| 116 |
+
|
| 117 |
+
def test_reproducible(self, _):
|
| 118 |
+
"""Tests that is_reproducible returns True if crash is detected and that
|
| 119 |
+
is_reproducible uses the correct command to reproduce a crash."""
|
| 120 |
+
all_repro = [EXECUTE_FAILURE_RESULT] * fuzz_target.REPRODUCE_ATTEMPTS
|
| 121 |
+
with mock.patch('clusterfuzz.fuzz.get_engine') as mock_get_engine:
|
| 122 |
+
mock_get_engine().reproduce.side_effect = all_repro
|
| 123 |
+
|
| 124 |
+
result = self.target.is_reproducible(self.testcase_path,
|
| 125 |
+
self.fuzz_target_path, [])
|
| 126 |
+
mock_get_engine().reproduce.assert_called_once_with(
|
| 127 |
+
'/workspace/build-out/fuzz-target',
|
| 128 |
+
'/testcase',
|
| 129 |
+
arguments=[],
|
| 130 |
+
max_time=30)
|
| 131 |
+
self.assertTrue(result)
|
| 132 |
+
self.assertEqual(1, mock_get_engine().reproduce.call_count)
|
| 133 |
+
|
| 134 |
+
def test_flaky(self, _):
|
| 135 |
+
"""Tests that is_reproducible returns True if crash is detected on the last
|
| 136 |
+
attempt."""
|
| 137 |
+
last_time_repro = [EXECUTE_SUCCESS_RESULT] * 9 + [EXECUTE_FAILURE_RESULT]
|
| 138 |
+
with mock.patch('clusterfuzz.fuzz.get_engine') as mock_get_engine:
|
| 139 |
+
mock_get_engine().reproduce.side_effect = last_time_repro
|
| 140 |
+
self.assertTrue(
|
| 141 |
+
self.target.is_reproducible(self.testcase_path, self.fuzz_target_path,
|
| 142 |
+
[]))
|
| 143 |
+
self.assertEqual(fuzz_target.REPRODUCE_ATTEMPTS,
|
| 144 |
+
mock_get_engine().reproduce.call_count)
|
| 145 |
+
|
| 146 |
+
def test_nonexistent_fuzzer(self, _):
|
| 147 |
+
"""Tests that is_reproducible raises an error if it could not attempt
|
| 148 |
+
reproduction because the fuzzer doesn't exist."""
|
| 149 |
+
with self.assertRaises(fuzz_target.ReproduceError):
|
| 150 |
+
self.target.is_reproducible(self.testcase_path, '/non-existent-path', [])
|
| 151 |
+
|
| 152 |
+
def test_unreproducible(self, _):
|
| 153 |
+
"""Tests that is_reproducible returns False for a crash that did not
|
| 154 |
+
reproduce."""
|
| 155 |
+
all_unrepro = [EXECUTE_SUCCESS_RESULT] * fuzz_target.REPRODUCE_ATTEMPTS
|
| 156 |
+
with mock.patch('clusterfuzz.fuzz.get_engine') as mock_get_engine:
|
| 157 |
+
mock_get_engine().reproduce.side_effect = all_unrepro
|
| 158 |
+
result = self.target.is_reproducible(self.testcase_path,
|
| 159 |
+
self.fuzz_target_path, [])
|
| 160 |
+
self.assertFalse(result)
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
class IsCrashReportableTest(fake_filesystem_unittest.TestCase):
|
| 164 |
+
"""Tests the is_crash_reportable method of FuzzTarget."""
|
| 165 |
+
|
| 166 |
+
def setUp(self):
|
| 167 |
+
"""Sets up example fuzz target to test is_crash_reportable method."""
|
| 168 |
+
self.setUpPyfakefs()
|
| 169 |
+
self.fuzz_target_path = '/example/do_stuff_fuzzer'
|
| 170 |
+
deployment = _create_deployment()
|
| 171 |
+
self.target = fuzz_target.FuzzTarget(self.fuzz_target_path, 100,
|
| 172 |
+
deployment.workspace, deployment,
|
| 173 |
+
deployment.config)
|
| 174 |
+
self.oss_fuzz_build_path = '/oss-fuzz-build'
|
| 175 |
+
self.fs.create_file(self.fuzz_target_path)
|
| 176 |
+
self.oss_fuzz_target_path = os.path.join(
|
| 177 |
+
self.oss_fuzz_build_path, os.path.basename(self.fuzz_target_path))
|
| 178 |
+
self.fs.create_file(self.oss_fuzz_target_path)
|
| 179 |
+
self.testcase_path = '/testcase'
|
| 180 |
+
self.fs.create_file(self.testcase_path, contents='')
|
| 181 |
+
|
| 182 |
+
# Do this to prevent pyfakefs from messing with requests.
|
| 183 |
+
self.fs.add_real_directory(os.path.dirname(certifi.__file__))
|
| 184 |
+
|
| 185 |
+
@mock.patch('fuzz_target.FuzzTarget.is_reproducible',
|
| 186 |
+
side_effect=[True, False])
|
| 187 |
+
@mock.patch('logging.info')
|
| 188 |
+
def test_new_reproducible_crash(self, mock_info, _):
|
| 189 |
+
"""Tests that a new reproducible crash returns True."""
|
| 190 |
+
with tempfile.TemporaryDirectory() as tmp_dir:
|
| 191 |
+
self.target.out_dir = tmp_dir
|
| 192 |
+
self.assertTrue(self.target.is_crash_reportable(self.testcase_path, []))
|
| 193 |
+
mock_info.assert_called_with(
|
| 194 |
+
'The crash is not reproducible on previous build. '
|
| 195 |
+
'Code change (pr/commit) introduced crash.')
|
| 196 |
+
|
| 197 |
+
# yapf: disable
|
| 198 |
+
@parameterized.parameterized.expand([
|
| 199 |
+
# Reproducible on PR build, but also reproducible on OSS-Fuzz.
|
| 200 |
+
([True, True],),
|
| 201 |
+
|
| 202 |
+
# Not reproducible on PR build, but somehow reproducible on OSS-Fuzz.
|
| 203 |
+
# Unlikely to happen in real world except if test is flaky.
|
| 204 |
+
([False, True],),
|
| 205 |
+
|
| 206 |
+
# Not reproducible on PR build, and not reproducible on OSS-Fuzz.
|
| 207 |
+
([False, False],),
|
| 208 |
+
])
|
| 209 |
+
# yapf: enable
|
| 210 |
+
def test_invalid_crash(self, is_reproducible_retvals):
|
| 211 |
+
"""Tests that a nonreportable crash causes the method to return False."""
|
| 212 |
+
with mock.patch('fuzz_target.FuzzTarget.is_reproducible',
|
| 213 |
+
side_effect=is_reproducible_retvals):
|
| 214 |
+
with mock.patch('clusterfuzz_deployment.OSSFuzz.download_latest_build',
|
| 215 |
+
return_value=self.oss_fuzz_build_path):
|
| 216 |
+
self.assertFalse(self.target.is_crash_reportable(
|
| 217 |
+
self.testcase_path, []))
|
| 218 |
+
|
| 219 |
+
@mock.patch('logging.info')
|
| 220 |
+
@mock.patch('fuzz_target.FuzzTarget.is_reproducible', return_value=[True])
|
| 221 |
+
def test_reproducible_no_oss_fuzz_target(self, _, mock_info):
|
| 222 |
+
"""Tests that is_crash_reportable returns True when a crash reproduces on
|
| 223 |
+
the PR build but the target is not in the OSS-Fuzz build (usually because it
|
| 224 |
+
is new)."""
|
| 225 |
+
os.remove(self.oss_fuzz_target_path)
|
| 226 |
+
|
| 227 |
+
def is_reproducible_side_effect(testcase, target_path, reproduce_arguments):
|
| 228 |
+
del testcase
|
| 229 |
+
del reproduce_arguments
|
| 230 |
+
if os.path.dirname(target_path) == self.oss_fuzz_build_path:
|
| 231 |
+
raise fuzz_target.ReproduceError()
|
| 232 |
+
return True
|
| 233 |
+
|
| 234 |
+
with mock.patch(
|
| 235 |
+
'fuzz_target.FuzzTarget.is_reproducible',
|
| 236 |
+
side_effect=is_reproducible_side_effect) as mock_is_reproducible:
|
| 237 |
+
with mock.patch('clusterfuzz_deployment.OSSFuzz.download_latest_build',
|
| 238 |
+
return_value=self.oss_fuzz_build_path):
|
| 239 |
+
self.assertTrue(self.target.is_crash_reportable(self.testcase_path, []))
|
| 240 |
+
mock_is_reproducible.assert_any_call(self.testcase_path,
|
| 241 |
+
self.oss_fuzz_target_path, [])
|
| 242 |
+
mock_info.assert_called_with(
|
| 243 |
+
'Could not run previous build of target to determine if this code '
|
| 244 |
+
'change (pr/commit) introduced crash. Assuming crash was newly '
|
| 245 |
+
'introduced.')
|
| 246 |
+
|
| 247 |
+
|
| 248 |
+
class FuzzTest(fake_filesystem_unittest.TestCase):
|
| 249 |
+
"""Fuzz test."""
|
| 250 |
+
|
| 251 |
+
def setUp(self):
|
| 252 |
+
"""Sets up example fuzz target."""
|
| 253 |
+
self.setUpPyfakefs()
|
| 254 |
+
deployment = _create_deployment()
|
| 255 |
+
config = deployment.config
|
| 256 |
+
workspace = deployment.workspace
|
| 257 |
+
self.fuzz_target = fuzz_target.FuzzTarget('/path/fuzz-target', 10,
|
| 258 |
+
workspace, deployment, config)
|
| 259 |
+
|
| 260 |
+
def test_get_fuzz_target_artifact(self):
|
| 261 |
+
"""Tests that get_fuzz_target_artifact works as intended."""
|
| 262 |
+
# pylint: disable=protected-access
|
| 263 |
+
fuzz_target_artifact = self.fuzz_target._target_artifact_path()
|
| 264 |
+
self.assertEqual('/workspace/out/artifacts/fuzz-target/address',
|
| 265 |
+
fuzz_target_artifact)
|
| 266 |
+
|
| 267 |
+
|
| 268 |
+
class TimeoutIntegrationTest(unittest.TestCase):
|
| 269 |
+
"""Tests handling of fuzzer timeout (timeout crashes reported by
|
| 270 |
+
libFuzzer)."""
|
| 271 |
+
TIMEOUT_FUZZER_NAME = 'timeout_fuzzer'
|
| 272 |
+
|
| 273 |
+
@parameterized.parameterized.expand([(True, True), (False, False)])
|
| 274 |
+
def test_timeout_reported(self, report_timeouts, expect_crash):
|
| 275 |
+
"""Tests that timeouts are not reported."""
|
| 276 |
+
with test_helpers.temp_dir_copy(TEST_DATA_PATH) as temp_dir:
|
| 277 |
+
fuzz_target_path = os.path.join(temp_dir, 'build-out',
|
| 278 |
+
self.TIMEOUT_FUZZER_NAME)
|
| 279 |
+
shutil.copy(os.path.join(temp_dir, self.TIMEOUT_FUZZER_NAME),
|
| 280 |
+
fuzz_target_path)
|
| 281 |
+
deployment = _create_deployment(workspace=temp_dir,
|
| 282 |
+
report_timeouts=report_timeouts)
|
| 283 |
+
config = deployment.config
|
| 284 |
+
fuzz_target_obj = fuzz_target.FuzzTarget(fuzz_target_path,
|
| 285 |
+
fuzz_target.REPRODUCE_ATTEMPTS,
|
| 286 |
+
deployment.workspace, deployment,
|
| 287 |
+
config)
|
| 288 |
+
with mock.patch('clusterfuzz._internal.bot.fuzzers.libfuzzer.'
|
| 289 |
+
'fix_timeout_argument_for_reproduction') as _:
|
| 290 |
+
with mock.patch(
|
| 291 |
+
'clusterfuzz._internal.bot.fuzzers.libFuzzer.fuzzer.get_arguments',
|
| 292 |
+
return_value=['-timeout=1', '-rss_limit_mb=2560']):
|
| 293 |
+
fuzz_result = fuzz_target_obj.fuzz()
|
| 294 |
+
self.assertEqual(bool(fuzz_result.testcase), expect_crash)
|
| 295 |
+
|
| 296 |
+
|
| 297 |
+
if __name__ == '__main__':
|
| 298 |
+
unittest.main()
|
local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/generate_coverage_report.py
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2021 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
"""Module for generating coverage reports."""
|
| 15 |
+
import os
|
| 16 |
+
|
| 17 |
+
import base_runner_utils
|
| 18 |
+
import fuzz_target
|
| 19 |
+
import utils
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
def run_coverage_command(config, workspace):
|
| 23 |
+
"""Runs the coverage command in base-runner to generate a coverage report."""
|
| 24 |
+
env = base_runner_utils.get_env(config, workspace)
|
| 25 |
+
env['HTTP_PORT'] = ''
|
| 26 |
+
env['COVERAGE_EXTRA_ARGS'] = ''
|
| 27 |
+
env['CORPUS_DIR'] = workspace.corpora
|
| 28 |
+
env['COVERAGE_OUTPUT_DIR'] = workspace.coverage_report
|
| 29 |
+
command = 'coverage'
|
| 30 |
+
return utils.execute(command, env=env)
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
def download_corpora(fuzz_target_paths, clusterfuzz_deployment):
|
| 34 |
+
"""Downloads corpora for fuzz targets in |fuzz_target_paths| using
|
| 35 |
+
|clusterfuzz_deployment| to download corpora from ClusterFuzz/OSS-Fuzz."""
|
| 36 |
+
for target_path in fuzz_target_paths:
|
| 37 |
+
target_name = os.path.basename(target_path)
|
| 38 |
+
corpus_dir = fuzz_target.get_fuzz_target_corpus_dir(
|
| 39 |
+
clusterfuzz_deployment.workspace, target_name)
|
| 40 |
+
clusterfuzz_deployment.download_corpus(target_name, corpus_dir)
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
def generate_coverage_report(fuzz_target_paths, workspace,
|
| 44 |
+
clusterfuzz_deployment, config):
|
| 45 |
+
"""Generates a coverage report using Clang's source based coverage."""
|
| 46 |
+
download_corpora(fuzz_target_paths, clusterfuzz_deployment)
|
| 47 |
+
run_coverage_command(config, workspace)
|
| 48 |
+
clusterfuzz_deployment.upload_coverage()
|
local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/generate_coverage_report_test.py
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2021 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
"""Tests for generate_coverage_report."""
|
| 15 |
+
|
| 16 |
+
import unittest
|
| 17 |
+
from unittest import mock
|
| 18 |
+
|
| 19 |
+
import generate_coverage_report
|
| 20 |
+
import test_helpers
|
| 21 |
+
|
| 22 |
+
OUT_DIR = '/outdir'
|
| 23 |
+
PROJECT = 'example-project'
|
| 24 |
+
SANITIZER = 'coverage'
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
class TestRunCoverageCommand(unittest.TestCase):
|
| 28 |
+
"""Tests run_coverage_command"""
|
| 29 |
+
|
| 30 |
+
def setUp(self):
|
| 31 |
+
test_helpers.patch_environ(self, empty=True)
|
| 32 |
+
|
| 33 |
+
@mock.patch('utils.execute')
|
| 34 |
+
def test_run_coverage_command(self, mock_execute): # pylint: disable=no-self-use
|
| 35 |
+
"""Tests that run_coverage_command works as intended."""
|
| 36 |
+
config = test_helpers.create_run_config(oss_fuzz_project_name=PROJECT,
|
| 37 |
+
sanitizer=SANITIZER)
|
| 38 |
+
workspace = test_helpers.create_workspace()
|
| 39 |
+
generate_coverage_report.run_coverage_command(config, workspace)
|
| 40 |
+
expected_command = 'coverage'
|
| 41 |
+
expected_env = {
|
| 42 |
+
'SANITIZER': config.sanitizer,
|
| 43 |
+
'FUZZING_LANGUAGE': config.language,
|
| 44 |
+
'OUT': workspace.out,
|
| 45 |
+
'CIFUZZ': 'True',
|
| 46 |
+
'FUZZING_ENGINE': 'libfuzzer',
|
| 47 |
+
'ARCHITECTURE': 'x86_64',
|
| 48 |
+
'FUZZER_ARGS': '-rss_limit_mb=2560 -timeout=25',
|
| 49 |
+
'HTTP_PORT': '',
|
| 50 |
+
'COVERAGE_EXTRA_ARGS': '',
|
| 51 |
+
'CORPUS_DIR': workspace.corpora,
|
| 52 |
+
'COVERAGE_OUTPUT_DIR': workspace.coverage_report
|
| 53 |
+
}
|
| 54 |
+
mock_execute.assert_called_with(expected_command, env=expected_env)
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
class DownloadCorporaTest(unittest.TestCase):
|
| 58 |
+
"""Tests for download_corpora."""
|
| 59 |
+
|
| 60 |
+
def test_download_corpora(self): # pylint: disable=no-self-use
|
| 61 |
+
"""Tests that download_corpora works as intended."""
|
| 62 |
+
clusterfuzz_deployment = mock.Mock()
|
| 63 |
+
clusterfuzz_deployment.workspace = test_helpers.create_workspace()
|
| 64 |
+
fuzz_target_paths = ['/path/to/fuzzer1', '/path/to/fuzzer2']
|
| 65 |
+
expected_calls = [
|
| 66 |
+
mock.call('fuzzer1', '/workspace/cifuzz-corpus/fuzzer1'),
|
| 67 |
+
mock.call('fuzzer2', '/workspace/cifuzz-corpus/fuzzer2')
|
| 68 |
+
]
|
| 69 |
+
generate_coverage_report.download_corpora(fuzz_target_paths,
|
| 70 |
+
clusterfuzz_deployment)
|
| 71 |
+
clusterfuzz_deployment.download_corpus.assert_has_calls(expected_calls)
|
local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/get_coverage.py
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2021 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
"""Module for determining coverage of fuzz targets."""
|
| 15 |
+
import json
|
| 16 |
+
import logging
|
| 17 |
+
import os
|
| 18 |
+
import sys
|
| 19 |
+
|
| 20 |
+
import http_utils
|
| 21 |
+
|
| 22 |
+
# pylint: disable=wrong-import-position,import-error
|
| 23 |
+
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
| 24 |
+
import utils
|
| 25 |
+
|
| 26 |
+
# The path to get OSS-Fuzz project's latest report json file.`
|
| 27 |
+
OSS_FUZZ_LATEST_COVERAGE_INFO_PATH = 'oss-fuzz-coverage/latest_report_info/'
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
# pylint: disable=too-few-public-methods
|
| 31 |
+
class CoverageError(Exception):
|
| 32 |
+
"""Exceptions for project coverage."""
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
class BaseCoverage:
|
| 36 |
+
"""Gets coverage data for a project."""
|
| 37 |
+
|
| 38 |
+
def __init__(self, repo_path):
|
| 39 |
+
self.repo_path = _normalize_repo_path(repo_path)
|
| 40 |
+
|
| 41 |
+
def get_files_covered_by_target(self, target):
|
| 42 |
+
"""Returns a list of source files covered by the specific fuzz target.
|
| 43 |
+
|
| 44 |
+
Args:
|
| 45 |
+
target: The name of the fuzz target whose coverage is requested.
|
| 46 |
+
|
| 47 |
+
Returns:
|
| 48 |
+
A list of files that the fuzz target covers or None.
|
| 49 |
+
"""
|
| 50 |
+
target_cov = self.get_target_coverage(target)
|
| 51 |
+
if not target_cov:
|
| 52 |
+
logging.info('No coverage available for %s.', target)
|
| 53 |
+
return None
|
| 54 |
+
|
| 55 |
+
coverage_per_file = get_coverage_per_file(target_cov)
|
| 56 |
+
if not coverage_per_file:
|
| 57 |
+
logging.info('No files found in coverage report.')
|
| 58 |
+
return None
|
| 59 |
+
|
| 60 |
+
affected_file_list = []
|
| 61 |
+
for file_cov in coverage_per_file:
|
| 62 |
+
norm_file_path = os.path.normpath(file_cov['filename'])
|
| 63 |
+
if not norm_file_path.startswith(self.repo_path):
|
| 64 |
+
# Exclude files outside of the main repo.
|
| 65 |
+
continue
|
| 66 |
+
|
| 67 |
+
if not is_file_covered(file_cov):
|
| 68 |
+
# Don't consider a file affected if code in it is never executed.
|
| 69 |
+
continue
|
| 70 |
+
|
| 71 |
+
# TODO(metzman): It's weird to me that we access file_cov['filename']
|
| 72 |
+
# again and not norm_file_path, figure out if this makes sense.
|
| 73 |
+
relative_path = utils.remove_prefix(file_cov['filename'], self.repo_path)
|
| 74 |
+
affected_file_list.append(relative_path)
|
| 75 |
+
|
| 76 |
+
return affected_file_list
|
| 77 |
+
|
| 78 |
+
def get_target_coverage(self, target):
|
| 79 |
+
"""Get the coverage report for a specific fuzz target.
|
| 80 |
+
|
| 81 |
+
Args:
|
| 82 |
+
target: The name of the fuzz target whose coverage is requested.
|
| 83 |
+
|
| 84 |
+
Returns:
|
| 85 |
+
The target's coverage json dict or None on failure.
|
| 86 |
+
"""
|
| 87 |
+
raise NotImplementedError('Child class must implement method.')
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
class OSSFuzzCoverage(BaseCoverage):
|
| 91 |
+
"""Gets coverage data for a project from OSS-Fuzz."""
|
| 92 |
+
|
| 93 |
+
def __init__(self, repo_path, oss_fuzz_project_name):
|
| 94 |
+
"""Constructor for OSSFuzzCoverage."""
|
| 95 |
+
super().__init__(repo_path)
|
| 96 |
+
self.oss_fuzz_project_name = oss_fuzz_project_name
|
| 97 |
+
self.fuzzer_stats_url = _get_oss_fuzz_fuzzer_stats_dir_url(
|
| 98 |
+
self.oss_fuzz_project_name)
|
| 99 |
+
if self.fuzzer_stats_url is None:
|
| 100 |
+
raise CoverageError('Could not get latest coverage.')
|
| 101 |
+
|
| 102 |
+
def get_target_coverage(self, target):
|
| 103 |
+
"""Get the coverage report for a specific fuzz target.
|
| 104 |
+
|
| 105 |
+
Args:
|
| 106 |
+
target: The name of the fuzz target whose coverage is requested.
|
| 107 |
+
|
| 108 |
+
Returns:
|
| 109 |
+
The target's coverage json dict or None on failure.
|
| 110 |
+
"""
|
| 111 |
+
if not self.fuzzer_stats_url:
|
| 112 |
+
return None
|
| 113 |
+
|
| 114 |
+
target_url = utils.url_join(self.fuzzer_stats_url, target + '.json')
|
| 115 |
+
return http_utils.get_json_from_url(target_url)
|
| 116 |
+
|
| 117 |
+
|
| 118 |
+
def _get_oss_fuzz_latest_cov_report_info(oss_fuzz_project_name):
|
| 119 |
+
"""Gets and returns a dictionary containing the latest coverage report info
|
| 120 |
+
for |project|."""
|
| 121 |
+
latest_report_info_url = utils.url_join(utils.GCS_BASE_URL,
|
| 122 |
+
OSS_FUZZ_LATEST_COVERAGE_INFO_PATH,
|
| 123 |
+
oss_fuzz_project_name + '.json')
|
| 124 |
+
latest_cov_info = http_utils.get_json_from_url(latest_report_info_url)
|
| 125 |
+
if latest_cov_info is None:
|
| 126 |
+
logging.error('Could not get the coverage report json from url: %s.',
|
| 127 |
+
latest_report_info_url)
|
| 128 |
+
return None
|
| 129 |
+
return latest_cov_info
|
| 130 |
+
|
| 131 |
+
|
| 132 |
+
def _get_oss_fuzz_fuzzer_stats_dir_url(oss_fuzz_project_name):
|
| 133 |
+
"""Gets latest coverage report info for a specific OSS-Fuzz project from
|
| 134 |
+
GCS.
|
| 135 |
+
|
| 136 |
+
Args:
|
| 137 |
+
oss_fuzz_project_name: The name of the project.
|
| 138 |
+
|
| 139 |
+
Returns:
|
| 140 |
+
The projects coverage report info in json dict or None on failure.
|
| 141 |
+
"""
|
| 142 |
+
latest_cov_info = _get_oss_fuzz_latest_cov_report_info(oss_fuzz_project_name)
|
| 143 |
+
|
| 144 |
+
if not latest_cov_info:
|
| 145 |
+
return None
|
| 146 |
+
|
| 147 |
+
if 'fuzzer_stats_dir' not in latest_cov_info:
|
| 148 |
+
logging.error('fuzzer_stats_dir not in latest coverage info.')
|
| 149 |
+
return None
|
| 150 |
+
|
| 151 |
+
fuzzer_stats_dir_gs_url = latest_cov_info['fuzzer_stats_dir']
|
| 152 |
+
fuzzer_stats_dir_url = utils.gs_url_to_https(fuzzer_stats_dir_gs_url)
|
| 153 |
+
return fuzzer_stats_dir_url
|
| 154 |
+
|
| 155 |
+
|
| 156 |
+
class FilesystemCoverage(BaseCoverage):
|
| 157 |
+
"""Class that gets a project's coverage from the filesystem."""
|
| 158 |
+
|
| 159 |
+
def __init__(self, repo_path, project_coverage_dir):
|
| 160 |
+
super().__init__(repo_path)
|
| 161 |
+
self.project_coverage_dir = project_coverage_dir
|
| 162 |
+
|
| 163 |
+
def get_target_coverage(self, target):
|
| 164 |
+
"""Get the coverage report for a specific fuzz target.
|
| 165 |
+
|
| 166 |
+
Args:
|
| 167 |
+
target: The name of the fuzz target whose coverage is requested.
|
| 168 |
+
|
| 169 |
+
Returns:
|
| 170 |
+
The target's coverage json dict or None on failure.
|
| 171 |
+
"""
|
| 172 |
+
logging.info('Getting coverage for %s from filesystem.', target)
|
| 173 |
+
fuzzer_stats_json_path = os.path.join(self.project_coverage_dir,
|
| 174 |
+
'fuzzer_stats', target + '.json')
|
| 175 |
+
if not os.path.exists(fuzzer_stats_json_path):
|
| 176 |
+
logging.warning('%s does not exist.', fuzzer_stats_json_path)
|
| 177 |
+
return None
|
| 178 |
+
|
| 179 |
+
with open(fuzzer_stats_json_path) as fuzzer_stats_json_file_handle:
|
| 180 |
+
try:
|
| 181 |
+
return json.load(fuzzer_stats_json_file_handle)
|
| 182 |
+
except json.decoder.JSONDecodeError as err:
|
| 183 |
+
logging.error('Could not decode: %s. Error: %s.',
|
| 184 |
+
fuzzer_stats_json_path, err)
|
| 185 |
+
return None
|
| 186 |
+
|
| 187 |
+
|
| 188 |
+
def is_file_covered(file_cov):
|
| 189 |
+
"""Returns whether the file is covered."""
|
| 190 |
+
return file_cov['summary']['regions']['covered']
|
| 191 |
+
|
| 192 |
+
|
| 193 |
+
def get_coverage_per_file(target_cov):
|
| 194 |
+
"""Returns the coverage per file within |target_cov|."""
|
| 195 |
+
try:
|
| 196 |
+
return target_cov['data'][0]['files']
|
| 197 |
+
except (IndexError, TypeError, KeyError):
|
| 198 |
+
logging.error('target_cov: %s is malformed.', target_cov)
|
| 199 |
+
return None
|
| 200 |
+
|
| 201 |
+
|
| 202 |
+
def _normalize_repo_path(repo_path):
|
| 203 |
+
"""Normalizes and returns |repo_path| to make sure cases like /src/curl and
|
| 204 |
+
/src/curl/ are both handled."""
|
| 205 |
+
repo_path = os.path.normpath(repo_path)
|
| 206 |
+
if not repo_path.endswith('/'):
|
| 207 |
+
repo_path += '/'
|
| 208 |
+
return repo_path
|
local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/get_coverage_test.py
ADDED
|
@@ -0,0 +1,253 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2021 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
"""Tests for get_coverage.py"""
|
| 15 |
+
import os
|
| 16 |
+
import json
|
| 17 |
+
import unittest
|
| 18 |
+
from unittest import mock
|
| 19 |
+
|
| 20 |
+
import parameterized
|
| 21 |
+
from pyfakefs import fake_filesystem_unittest
|
| 22 |
+
import pytest
|
| 23 |
+
|
| 24 |
+
import get_coverage
|
| 25 |
+
|
| 26 |
+
# pylint: disable=protected-access
|
| 27 |
+
|
| 28 |
+
TEST_DATA_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)),
|
| 29 |
+
'test_data')
|
| 30 |
+
|
| 31 |
+
PROJECT_NAME = 'curl'
|
| 32 |
+
REPO_PATH = '/src/curl'
|
| 33 |
+
FUZZ_TARGET = 'curl_fuzzer'
|
| 34 |
+
PROJECT_COV_JSON_FILENAME = 'example_curl_cov.json'
|
| 35 |
+
FUZZ_TARGET_COV_JSON_FILENAME = 'example_curl_fuzzer_cov.json'
|
| 36 |
+
INVALID_TARGET = 'not-a-fuzz-target'
|
| 37 |
+
|
| 38 |
+
with open(os.path.join(TEST_DATA_PATH,
|
| 39 |
+
PROJECT_COV_JSON_FILENAME),) as cov_file_handle:
|
| 40 |
+
PROJECT_COV_INFO = json.loads(cov_file_handle.read())
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
class GetOssFuzzFuzzerStatsDirUrlTest(unittest.TestCase):
|
| 44 |
+
"""Tests _get_oss_fuzz_fuzzer_stats_dir_url."""
|
| 45 |
+
|
| 46 |
+
@mock.patch('http_utils.get_json_from_url',
|
| 47 |
+
return_value={
|
| 48 |
+
'fuzzer_stats_dir':
|
| 49 |
+
'gs://oss-fuzz-coverage/systemd/fuzzer_stats/20210303'
|
| 50 |
+
})
|
| 51 |
+
def test_get_valid_project(self, mock_get_json_from_url):
|
| 52 |
+
"""Tests that a project's coverage report can be downloaded and parsed.
|
| 53 |
+
|
| 54 |
+
NOTE: This test relies on the PROJECT_NAME repo's coverage report.
|
| 55 |
+
The "example" project was not used because it has no coverage reports.
|
| 56 |
+
"""
|
| 57 |
+
result = get_coverage._get_oss_fuzz_fuzzer_stats_dir_url(PROJECT_NAME)
|
| 58 |
+
(url,), _ = mock_get_json_from_url.call_args
|
| 59 |
+
self.assertEqual(
|
| 60 |
+
'https://storage.googleapis.com/oss-fuzz-coverage/'
|
| 61 |
+
'latest_report_info/curl.json', url)
|
| 62 |
+
|
| 63 |
+
expected_result = (
|
| 64 |
+
'https://storage.googleapis.com/oss-fuzz-coverage/systemd/fuzzer_stats/'
|
| 65 |
+
'20210303')
|
| 66 |
+
self.assertEqual(result, expected_result)
|
| 67 |
+
|
| 68 |
+
def test_get_invalid_project(self):
|
| 69 |
+
"""Tests that passing a bad project returns None."""
|
| 70 |
+
self.assertIsNone(
|
| 71 |
+
get_coverage._get_oss_fuzz_fuzzer_stats_dir_url('not-a-proj'))
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
class OSSFuzzCoverageGetTargetCoverageTest(unittest.TestCase):
|
| 75 |
+
"""Tests OSSFuzzCoverage.get_target_coverage."""
|
| 76 |
+
|
| 77 |
+
def setUp(self):
|
| 78 |
+
with mock.patch('get_coverage._get_oss_fuzz_latest_cov_report_info',
|
| 79 |
+
return_value=PROJECT_COV_INFO):
|
| 80 |
+
self.oss_fuzz_coverage = get_coverage.OSSFuzzCoverage(
|
| 81 |
+
REPO_PATH, PROJECT_NAME)
|
| 82 |
+
|
| 83 |
+
@mock.patch('http_utils.get_json_from_url', return_value={})
|
| 84 |
+
def test_valid_target(self, mock_get_json_from_url):
|
| 85 |
+
"""Tests that a target's coverage report can be downloaded and parsed."""
|
| 86 |
+
self.oss_fuzz_coverage.get_target_coverage(FUZZ_TARGET)
|
| 87 |
+
(url,), _ = mock_get_json_from_url.call_args
|
| 88 |
+
self.assertEqual(
|
| 89 |
+
'https://storage.googleapis.com/oss-fuzz-coverage/'
|
| 90 |
+
'curl/fuzzer_stats/20200226/curl_fuzzer.json', url)
|
| 91 |
+
|
| 92 |
+
def test_invalid_target(self):
|
| 93 |
+
"""Tests that passing an invalid target coverage report returns None."""
|
| 94 |
+
self.assertIsNone(
|
| 95 |
+
self.oss_fuzz_coverage.get_target_coverage(INVALID_TARGET))
|
| 96 |
+
|
| 97 |
+
@mock.patch('get_coverage._get_oss_fuzz_latest_cov_report_info',
|
| 98 |
+
return_value=None)
|
| 99 |
+
def test_invalid_project_json(self, _): # pylint: disable=no-self-use
|
| 100 |
+
"""Tests an invalid project JSON results in None being returned."""
|
| 101 |
+
with pytest.raises(get_coverage.CoverageError):
|
| 102 |
+
get_coverage.OSSFuzzCoverage(REPO_PATH, PROJECT_NAME)
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
def _get_expected_curl_covered_file_list():
|
| 106 |
+
"""Returns the expected covered file list for
|
| 107 |
+
FUZZ_TARGET_COV_JSON_FILENAME."""
|
| 108 |
+
curl_files_list_path = os.path.join(TEST_DATA_PATH,
|
| 109 |
+
'example_curl_file_list.json')
|
| 110 |
+
with open(curl_files_list_path) as file_handle:
|
| 111 |
+
return json.loads(file_handle.read())
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
def _get_example_curl_coverage():
|
| 115 |
+
"""Returns the contents of the fuzzer stats JSON file for
|
| 116 |
+
FUZZ_TARGET_COV_JSON_FILENAME."""
|
| 117 |
+
with open(os.path.join(TEST_DATA_PATH,
|
| 118 |
+
FUZZ_TARGET_COV_JSON_FILENAME)) as file_handle:
|
| 119 |
+
return json.loads(file_handle.read())
|
| 120 |
+
|
| 121 |
+
|
| 122 |
+
class OSSFuzzCoverageGetFilesCoveredByTargetTest(unittest.TestCase):
|
| 123 |
+
"""Tests OSSFuzzCoverage.get_files_covered_by_target."""
|
| 124 |
+
|
| 125 |
+
def setUp(self):
|
| 126 |
+
with mock.patch('get_coverage._get_oss_fuzz_latest_cov_report_info',
|
| 127 |
+
return_value=PROJECT_COV_INFO):
|
| 128 |
+
self.oss_fuzz_coverage = get_coverage.OSSFuzzCoverage(
|
| 129 |
+
REPO_PATH, PROJECT_NAME)
|
| 130 |
+
|
| 131 |
+
@parameterized.parameterized.expand([({
|
| 132 |
+
'data': []
|
| 133 |
+
},), ({
|
| 134 |
+
'data': [[]]
|
| 135 |
+
},), ({
|
| 136 |
+
'data': [{}]
|
| 137 |
+
},)])
|
| 138 |
+
def test_malformed_cov_data(self, coverage_data):
|
| 139 |
+
"""Tests that covered files can be retrieved from a coverage report."""
|
| 140 |
+
with mock.patch('get_coverage.OSSFuzzCoverage.get_target_coverage',
|
| 141 |
+
return_value=coverage_data):
|
| 142 |
+
self.oss_fuzz_coverage.get_files_covered_by_target(FUZZ_TARGET)
|
| 143 |
+
|
| 144 |
+
def test_valid_target(self):
|
| 145 |
+
"""Tests that covered files can be retrieved from a coverage report."""
|
| 146 |
+
fuzzer_cov_data = _get_example_curl_coverage()
|
| 147 |
+
with mock.patch('get_coverage.OSSFuzzCoverage.get_target_coverage',
|
| 148 |
+
return_value=fuzzer_cov_data):
|
| 149 |
+
file_list = self.oss_fuzz_coverage.get_files_covered_by_target(
|
| 150 |
+
FUZZ_TARGET)
|
| 151 |
+
|
| 152 |
+
expected_file_list = _get_expected_curl_covered_file_list()
|
| 153 |
+
self.assertCountEqual(file_list, expected_file_list)
|
| 154 |
+
|
| 155 |
+
def test_invalid_target(self):
|
| 156 |
+
"""Tests passing invalid fuzz target returns None."""
|
| 157 |
+
self.assertIsNone(
|
| 158 |
+
self.oss_fuzz_coverage.get_files_covered_by_target(INVALID_TARGET))
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
class FilesystemCoverageGetFilesCoveredByTargetTest(
|
| 162 |
+
fake_filesystem_unittest.TestCase):
|
| 163 |
+
"""Tests FilesystemCoverage.get_files_covered_by_target."""
|
| 164 |
+
|
| 165 |
+
def setUp(self):
|
| 166 |
+
_fuzzer_cov_data = _get_example_curl_coverage()
|
| 167 |
+
self._expected_file_list = _get_expected_curl_covered_file_list()
|
| 168 |
+
self.coverage_path = '/coverage'
|
| 169 |
+
self.filesystem_coverage = get_coverage.FilesystemCoverage(
|
| 170 |
+
REPO_PATH, self.coverage_path)
|
| 171 |
+
self.setUpPyfakefs()
|
| 172 |
+
self.fs.create_file(os.path.join(self.coverage_path, 'fuzzer_stats',
|
| 173 |
+
FUZZ_TARGET + '.json'),
|
| 174 |
+
contents=json.dumps(_fuzzer_cov_data))
|
| 175 |
+
|
| 176 |
+
def test_valid_target(self):
|
| 177 |
+
"""Tests that covered files can be retrieved from a coverage report."""
|
| 178 |
+
file_list = self.filesystem_coverage.get_files_covered_by_target(
|
| 179 |
+
FUZZ_TARGET)
|
| 180 |
+
self.assertCountEqual(file_list, self._expected_file_list)
|
| 181 |
+
|
| 182 |
+
def test_invalid_target(self):
|
| 183 |
+
"""Tests passing invalid fuzz target returns None."""
|
| 184 |
+
self.assertIsNone(
|
| 185 |
+
self.filesystem_coverage.get_files_covered_by_target(INVALID_TARGET))
|
| 186 |
+
|
| 187 |
+
|
| 188 |
+
class IsFileCoveredTest(unittest.TestCase):
|
| 189 |
+
"""Tests for is_file_covered."""
|
| 190 |
+
|
| 191 |
+
def test_is_file_covered_covered(self):
|
| 192 |
+
"""Tests that is_file_covered returns True for a covered file."""
|
| 193 |
+
file_coverage = {
|
| 194 |
+
'filename': '/src/systemd/src/basic/locale-util.c',
|
| 195 |
+
'summary': {
|
| 196 |
+
'regions': {
|
| 197 |
+
'count': 204,
|
| 198 |
+
'covered': 200,
|
| 199 |
+
'notcovered': 200,
|
| 200 |
+
'percent': 98.03
|
| 201 |
+
}
|
| 202 |
+
}
|
| 203 |
+
}
|
| 204 |
+
self.assertTrue(get_coverage.is_file_covered(file_coverage))
|
| 205 |
+
|
| 206 |
+
def test_is_file_covered_not_covered(self):
|
| 207 |
+
"""Tests that is_file_covered returns False for a not covered file."""
|
| 208 |
+
file_coverage = {
|
| 209 |
+
'filename': '/src/systemd/src/basic/locale-util.c',
|
| 210 |
+
'summary': {
|
| 211 |
+
'regions': {
|
| 212 |
+
'count': 204,
|
| 213 |
+
'covered': 0,
|
| 214 |
+
'notcovered': 0,
|
| 215 |
+
'percent': 0
|
| 216 |
+
}
|
| 217 |
+
}
|
| 218 |
+
}
|
| 219 |
+
self.assertFalse(get_coverage.is_file_covered(file_coverage))
|
| 220 |
+
|
| 221 |
+
|
| 222 |
+
class GetOssFuzzLatestCovReportInfo(unittest.TestCase):
|
| 223 |
+
"""Tests that _get_oss_fuzz_latest_cov_report_info works as
|
| 224 |
+
intended."""
|
| 225 |
+
|
| 226 |
+
PROJECT = 'project'
|
| 227 |
+
LATEST_REPORT_INFO_URL = ('https://storage.googleapis.com/oss-fuzz-coverage/'
|
| 228 |
+
'latest_report_info/project.json')
|
| 229 |
+
|
| 230 |
+
@mock.patch('logging.error')
|
| 231 |
+
@mock.patch('http_utils.get_json_from_url', return_value={'coverage': 1})
|
| 232 |
+
def test_get_oss_fuzz_latest_cov_report_info(self, mock_get_json_from_url,
|
| 233 |
+
mock_error):
|
| 234 |
+
"""Tests that _get_oss_fuzz_latest_cov_report_info works as intended."""
|
| 235 |
+
result = get_coverage._get_oss_fuzz_latest_cov_report_info(self.PROJECT)
|
| 236 |
+
self.assertEqual(result, {'coverage': 1})
|
| 237 |
+
mock_error.assert_not_called()
|
| 238 |
+
mock_get_json_from_url.assert_called_with(self.LATEST_REPORT_INFO_URL)
|
| 239 |
+
|
| 240 |
+
@mock.patch('logging.error')
|
| 241 |
+
@mock.patch('http_utils.get_json_from_url', return_value=None)
|
| 242 |
+
def test_get_oss_fuzz_latest_cov_report_info_fail(self, _, mock_error):
|
| 243 |
+
"""Tests that _get_oss_fuzz_latest_cov_report_info works as intended when we
|
| 244 |
+
can't get latest report info."""
|
| 245 |
+
result = get_coverage._get_oss_fuzz_latest_cov_report_info('project')
|
| 246 |
+
self.assertIsNone(result)
|
| 247 |
+
mock_error.assert_called_with(
|
| 248 |
+
'Could not get the coverage report json from url: %s.',
|
| 249 |
+
self.LATEST_REPORT_INFO_URL)
|
| 250 |
+
|
| 251 |
+
|
| 252 |
+
if __name__ == '__main__':
|
| 253 |
+
unittest.main()
|
local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/http_utils.py
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2021 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
"""Utility module for HTTP."""
|
| 15 |
+
import json
|
| 16 |
+
import logging
|
| 17 |
+
import os
|
| 18 |
+
import sys
|
| 19 |
+
import tempfile
|
| 20 |
+
import zipfile
|
| 21 |
+
|
| 22 |
+
import requests
|
| 23 |
+
|
| 24 |
+
# pylint: disable=wrong-import-position,import-error
|
| 25 |
+
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
| 26 |
+
import retry
|
| 27 |
+
|
| 28 |
+
_DOWNLOAD_URL_RETRIES = 3
|
| 29 |
+
_DOWNLOAD_URL_BACKOFF = 1
|
| 30 |
+
_HTTP_REQUEST_TIMEOUT = 10
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
def download_and_unpack_zip(url, extract_directory, headers=None):
|
| 34 |
+
"""Downloads and unpacks a zip file from an HTTP URL.
|
| 35 |
+
|
| 36 |
+
Args:
|
| 37 |
+
url: A url to the zip file to be downloaded and unpacked.
|
| 38 |
+
extract_directory: The path where the zip file should be extracted to.
|
| 39 |
+
headers: (Optional) HTTP headers to send with the download request.
|
| 40 |
+
|
| 41 |
+
Returns:
|
| 42 |
+
True on success.
|
| 43 |
+
"""
|
| 44 |
+
if headers is None:
|
| 45 |
+
headers = {}
|
| 46 |
+
|
| 47 |
+
if not os.path.exists(extract_directory):
|
| 48 |
+
logging.error('Extract directory: %s does not exist.', extract_directory)
|
| 49 |
+
return False
|
| 50 |
+
|
| 51 |
+
# Gives the temporary zip file a unique identifier in the case that
|
| 52 |
+
# that download_and_unpack_zip is done in parallel.
|
| 53 |
+
with tempfile.NamedTemporaryFile(suffix='.zip') as tmp_file:
|
| 54 |
+
if not download_url(url, tmp_file.name, headers=headers):
|
| 55 |
+
return False
|
| 56 |
+
|
| 57 |
+
try:
|
| 58 |
+
with zipfile.ZipFile(tmp_file.name, 'r') as zip_file:
|
| 59 |
+
zip_file.extractall(extract_directory)
|
| 60 |
+
except zipfile.BadZipFile:
|
| 61 |
+
logging.error('Error unpacking zip from %s. Bad Zipfile.', url)
|
| 62 |
+
return False
|
| 63 |
+
|
| 64 |
+
return True
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
def download_url(*args, **kwargs):
|
| 68 |
+
"""Wrapper around _download_url that returns False if _download_url
|
| 69 |
+
exceptions."""
|
| 70 |
+
try:
|
| 71 |
+
return _download_url(*args, **kwargs)
|
| 72 |
+
except Exception: # pylint: disable=broad-except
|
| 73 |
+
return False
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
def get_json_from_url(url):
|
| 77 |
+
"""Gets a json object from a specified HTTP URL.
|
| 78 |
+
|
| 79 |
+
Args:
|
| 80 |
+
url: The url of the json to be downloaded.
|
| 81 |
+
|
| 82 |
+
Returns:
|
| 83 |
+
A dictionary deserialized from JSON or None on failure.
|
| 84 |
+
"""
|
| 85 |
+
try:
|
| 86 |
+
return requests.get(url, timeout=_HTTP_REQUEST_TIMEOUT).json()
|
| 87 |
+
except (ValueError, TypeError, json.JSONDecodeError,
|
| 88 |
+
requests.exceptions.ReadTimeout) as err:
|
| 89 |
+
logging.error('Loading json from url %s failed with: %s.', url, str(err))
|
| 90 |
+
return None
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
@retry.wrap(_DOWNLOAD_URL_RETRIES, _DOWNLOAD_URL_BACKOFF)
|
| 94 |
+
def _download_url(url, filename, headers=None):
|
| 95 |
+
"""Downloads the file located at |url|, using HTTP to |filename|.
|
| 96 |
+
|
| 97 |
+
Args:
|
| 98 |
+
url: A url to a file to download.
|
| 99 |
+
filename: The path the file should be downloaded to.
|
| 100 |
+
headers: (Optional) HTTP headers to send with the download request.
|
| 101 |
+
|
| 102 |
+
Returns:
|
| 103 |
+
True on success.
|
| 104 |
+
"""
|
| 105 |
+
if headers is None:
|
| 106 |
+
headers = {}
|
| 107 |
+
|
| 108 |
+
response = requests.get(url, headers=headers)
|
| 109 |
+
|
| 110 |
+
if response.status_code != 200:
|
| 111 |
+
logging.error('Unable to download from: %s. Code: %d. Content: %s.', url,
|
| 112 |
+
response.status_code, response.content)
|
| 113 |
+
return False
|
| 114 |
+
|
| 115 |
+
with open(filename, 'wb') as file_handle:
|
| 116 |
+
file_handle.write(response.content)
|
| 117 |
+
|
| 118 |
+
return True
|
local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/platform_config/__init__.py
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2021 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
"""Module for getting the configuration CIFuzz needs to run."""
|
| 15 |
+
import logging
|
| 16 |
+
import os
|
| 17 |
+
|
| 18 |
+
import environment
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
class BasePlatformConfig:
|
| 22 |
+
"""Base class for PlatformConfig subclasses."""
|
| 23 |
+
|
| 24 |
+
@property
|
| 25 |
+
def project_src_path(self):
|
| 26 |
+
"""Returns the manually checked out path of the project's source if
|
| 27 |
+
specified or None."""
|
| 28 |
+
path = os.getenv('PROJECT_SRC_PATH')
|
| 29 |
+
if not path:
|
| 30 |
+
logging.debug('No PROJECT_SRC_PATH.')
|
| 31 |
+
return path
|
| 32 |
+
|
| 33 |
+
logging.debug('PROJECT_SRC_PATH: %s.', path)
|
| 34 |
+
return path
|
| 35 |
+
|
| 36 |
+
@property
|
| 37 |
+
def workspace(self):
|
| 38 |
+
"""Returns the workspace."""
|
| 39 |
+
return os.getenv('WORKSPACE')
|
| 40 |
+
|
| 41 |
+
# Optional config variables.
|
| 42 |
+
|
| 43 |
+
@property
|
| 44 |
+
def git_sha(self):
|
| 45 |
+
"""Returns the Git SHA to checkout and fuzz. This is used only by GitHub
|
| 46 |
+
projects when commit fuzzing. It is not used when PR fuzzing. It is
|
| 47 |
+
definitely needed by OSS-Fuzz on GitHub since they have no copy of the repo
|
| 48 |
+
on the host and the repo on the builder image is a clone from main/master.
|
| 49 |
+
Right now it is needed by external on GitHub because we need to clone a new
|
| 50 |
+
repo because the copy they give us doesn't work for diffing.
|
| 51 |
+
|
| 52 |
+
TODO(metzman): Try to eliminate the need for this by 1. Making the clone
|
| 53 |
+
from external github projects usable. 2. Forcing OSS-Fuzz on Github to clone
|
| 54 |
+
before starting CIFuzz."""
|
| 55 |
+
return None
|
| 56 |
+
|
| 57 |
+
@property
|
| 58 |
+
def base_commit(self):
|
| 59 |
+
"""Returns the base commit to diff against (commit fuzzing)."""
|
| 60 |
+
# TODO(metzman) Rename base_commit to git_base_commit.
|
| 61 |
+
return os.getenv('GIT_BASE_COMMIT')
|
| 62 |
+
|
| 63 |
+
@property
|
| 64 |
+
def base_ref(self):
|
| 65 |
+
"""Returns the base branch to diff against (pr fuzzing)."""
|
| 66 |
+
# TODO(metzman) Rename base_ref to git_base_ref.
|
| 67 |
+
return os.getenv('GIT_BASE_REF')
|
| 68 |
+
|
| 69 |
+
@property
|
| 70 |
+
def pr_ref(self):
|
| 71 |
+
"""Returns the pull request to checkout and fuzz. This is used only by
|
| 72 |
+
GitHub projects when PR fuzzing. It is not used when commit fuzzing. It is
|
| 73 |
+
definitely needed by OSS-Fuzz on GitHub since they have no copy of the repo
|
| 74 |
+
on the host and the repo on the builder image is a clone from main/master.
|
| 75 |
+
Right now it is needed by external on GitHub because we need to clone a new
|
| 76 |
+
repo because the copy they give us doesn't work for diffing.
|
| 77 |
+
|
| 78 |
+
TODO(metzman): Try to eliminate the need for this by 1. Making the clone
|
| 79 |
+
from external github projects usable. 2. Forcing OSS-Fuzz on Github to clone
|
| 80 |
+
before starting CIFuzz."""
|
| 81 |
+
return None
|
| 82 |
+
|
| 83 |
+
@property
|
| 84 |
+
def project_repo_owner(self):
|
| 85 |
+
"""Returns the project repo owner (githubism)."""
|
| 86 |
+
return None
|
| 87 |
+
|
| 88 |
+
@property
|
| 89 |
+
def project_repo_name(self):
|
| 90 |
+
"""Returns the project repo name."""
|
| 91 |
+
return os.environ.get('REPOSITORY')
|
| 92 |
+
|
| 93 |
+
@property
|
| 94 |
+
def actor(self):
|
| 95 |
+
"""Name of the actor for the CI."""
|
| 96 |
+
return None
|
| 97 |
+
|
| 98 |
+
@property
|
| 99 |
+
def token(self):
|
| 100 |
+
"""Returns the CI API token."""
|
| 101 |
+
return None
|
| 102 |
+
|
| 103 |
+
@property
|
| 104 |
+
def docker_in_docker(self):
|
| 105 |
+
"""Returns whether or not CFL is running using Docker in Docker."""
|
| 106 |
+
return environment.get_bool('DOCKER_IN_DOCKER', False)
|
| 107 |
+
|
| 108 |
+
@property
|
| 109 |
+
def filestore(self):
|
| 110 |
+
"""Returns the filestore used to store persistent data."""
|
| 111 |
+
return os.environ.get('FILESTORE')
|
| 112 |
+
|
| 113 |
+
@property
|
| 114 |
+
def git_url(self):
|
| 115 |
+
"""Returns the repo URL. This is only used by GitHub users. Right now it is
|
| 116 |
+
needed by external on GitHub because we need to clone a new repo because the
|
| 117 |
+
copy they give us doesn't work for diffing. It isn't used by OSS-Fuzz on
|
| 118 |
+
github users since the Git URL is determined using repo detection.
|
| 119 |
+
|
| 120 |
+
TODO(metzman): Try to eliminate the need for this by making the clone
|
| 121 |
+
from external github projects usable.
|
| 122 |
+
TODO(metzman): As an easier goal, maybe make OSS-Fuzz GitHub use this too
|
| 123 |
+
for: 1. Consistency 2. Maybe it will allow use on forks."""
|
| 124 |
+
return None
|
local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/platform_config/gcb.py
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2021 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
"""Module for getting the configuration CIFuzz needs to run on Github."""
|
| 15 |
+
import logging
|
| 16 |
+
import os
|
| 17 |
+
|
| 18 |
+
import platform_config
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
class PlatformConfig(platform_config.BasePlatformConfig):
|
| 22 |
+
"""CI environment for Google Cloud Build."""
|
| 23 |
+
|
| 24 |
+
@property
|
| 25 |
+
def project_src_path(self):
|
| 26 |
+
"""Returns the manually checked out path of the project's source if
|
| 27 |
+
specified or the default."""
|
| 28 |
+
project_src_path = os.getenv('PROJECT_SRC_PATH', '/workspace')
|
| 29 |
+
logging.debug('PROJECT_SRC_PATH: %s.', project_src_path)
|
| 30 |
+
return project_src_path
|
| 31 |
+
|
| 32 |
+
@property
|
| 33 |
+
def workspace(self):
|
| 34 |
+
"""Returns the workspace."""
|
| 35 |
+
return os.getenv('WORKSPACE', '/builder/home')
|
| 36 |
+
|
| 37 |
+
@property
|
| 38 |
+
def filestore(self):
|
| 39 |
+
"""Returns the filestore used to store persistent data."""
|
| 40 |
+
return os.environ.get('FILESTORE', 'gsutil')
|
local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/platform_config/github.py
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2021 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
"""Module for getting the configuration CIFuzz needs to run on Github."""
|
| 15 |
+
import json
|
| 16 |
+
import logging
|
| 17 |
+
import os
|
| 18 |
+
|
| 19 |
+
import platform_config
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
def _get_github_event_path():
|
| 23 |
+
return os.getenv('GITHUB_EVENT_PATH')
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def _get_event_data():
|
| 27 |
+
"""Returns the GitHub event data."""
|
| 28 |
+
github_event_path = _get_github_event_path()
|
| 29 |
+
with open(github_event_path, encoding='utf-8') as file_handle:
|
| 30 |
+
return json.load(file_handle)
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
class PlatformConfig(platform_config.BasePlatformConfig):
|
| 34 |
+
"""CI environment for GitHub."""
|
| 35 |
+
|
| 36 |
+
def __init__(self):
|
| 37 |
+
self._event_data = _get_event_data()
|
| 38 |
+
self._event = os.getenv('GITHUB_EVENT_NAME')
|
| 39 |
+
|
| 40 |
+
@property
|
| 41 |
+
def workspace(self):
|
| 42 |
+
"""Returns the workspace."""
|
| 43 |
+
return os.getenv('GITHUB_WORKSPACE')
|
| 44 |
+
|
| 45 |
+
@property
|
| 46 |
+
def git_sha(self):
|
| 47 |
+
"""Returns the Git SHA to checkout and fuzz. This is used only by GitHub
|
| 48 |
+
projects when commit fuzzing. It is not used when PR fuzzing. It is
|
| 49 |
+
definitely needed by OSS-Fuzz on GitHub since they have no copy of the repo
|
| 50 |
+
on the host and the repo on the builder image is a clone from main/master.
|
| 51 |
+
Right now it is needed by external on GitHub because we need to clone a new
|
| 52 |
+
repo because the copy they give us doesn't work for diffing.
|
| 53 |
+
|
| 54 |
+
TODO(metzman): Try to eliminate the need for this by 1. Making the clone
|
| 55 |
+
from external github projects usable. 2. Forcing OSS-Fuzz on Github to clone
|
| 56 |
+
before starting CIFuzz."""
|
| 57 |
+
return os.getenv('GITHUB_SHA')
|
| 58 |
+
|
| 59 |
+
@property
|
| 60 |
+
def actor(self):
|
| 61 |
+
"""Name of the actor for the CI."""
|
| 62 |
+
return os.getenv('GITHUB_ACTOR')
|
| 63 |
+
|
| 64 |
+
@property
|
| 65 |
+
def token(self):
|
| 66 |
+
"""Returns the CI API token."""
|
| 67 |
+
return os.getenv('GITHUB_TOKEN')
|
| 68 |
+
|
| 69 |
+
@property
|
| 70 |
+
def project_src_path(self):
|
| 71 |
+
"""Returns the manually checked out path of the project's source if
|
| 72 |
+
specified or None. The path returned is relative to |self.workspace| since
|
| 73 |
+
on github the checkout will be relative to there."""
|
| 74 |
+
project_src_path = super().project_src_path
|
| 75 |
+
if project_src_path is None:
|
| 76 |
+
# Not set for internal GitHub users.
|
| 77 |
+
return project_src_path
|
| 78 |
+
# On GitHub (external users), this path is relative to |workspace|.
|
| 79 |
+
return os.path.join(self.workspace, project_src_path)
|
| 80 |
+
|
| 81 |
+
@property
|
| 82 |
+
def _project_repo_owner_and_name(self):
|
| 83 |
+
"""Returns a tuple containing the project repo owner and the name of the
|
| 84 |
+
repo."""
|
| 85 |
+
# On GitHub this includes owner and repo name.
|
| 86 |
+
repository = os.getenv('GITHUB_REPOSITORY')
|
| 87 |
+
# Use os.path.split to split owner from repo.
|
| 88 |
+
return os.path.split(repository)
|
| 89 |
+
|
| 90 |
+
@property
|
| 91 |
+
def project_repo_owner(self):
|
| 92 |
+
"""Returns the project repo owner (githubism)."""
|
| 93 |
+
return self._project_repo_owner_and_name[0]
|
| 94 |
+
|
| 95 |
+
@property
|
| 96 |
+
def project_repo_name(self):
|
| 97 |
+
"""Returns the project repo name."""
|
| 98 |
+
return self._project_repo_owner_and_name[1]
|
| 99 |
+
|
| 100 |
+
@property
|
| 101 |
+
def git_url(self):
|
| 102 |
+
"""Returns the repo URL. This is only used by GitHub users. Right now it is
|
| 103 |
+
needed by external on GitHub because we need to clone a new repo because the
|
| 104 |
+
copy they give us doesn't work for diffing. It isn't used by OSS-Fuzz on
|
| 105 |
+
github users since the Git URL is determined using repo detection.
|
| 106 |
+
|
| 107 |
+
TODO(metzman): Try to eliminate the need for this by making the clone
|
| 108 |
+
from external github projects usable.
|
| 109 |
+
TODO(metzman): As an easier goal, maybe make OSS-Fuzz GitHub use this too
|
| 110 |
+
for: 1. Consistency 2. Maybe it will allow use on forks."""
|
| 111 |
+
repository = os.getenv('GITHUB_REPOSITORY')
|
| 112 |
+
github_server_url = os.getenv('GITHUB_SERVER_URL', 'https://github.com')
|
| 113 |
+
# TODO(metzman): Probably need to change this to github.server_url.
|
| 114 |
+
return os.path.join(github_server_url, repository)
|
| 115 |
+
|
| 116 |
+
@property
|
| 117 |
+
def base_commit(self):
|
| 118 |
+
"""Returns the base commit to diff against (commit fuzzing)."""
|
| 119 |
+
base_commit = None
|
| 120 |
+
if self._event == 'push':
|
| 121 |
+
base_commit = self._event_data['before']
|
| 122 |
+
logging.debug('base_commit: %s', base_commit)
|
| 123 |
+
return base_commit
|
| 124 |
+
|
| 125 |
+
@property
|
| 126 |
+
def pr_ref(self):
|
| 127 |
+
"""Returns the pull request to checkout and fuzz. This is used only by
|
| 128 |
+
GitHub projects when PR fuzzing. It is not used when commit fuzzing. It is
|
| 129 |
+
definitely needed by OSS-Fuzz on GitHub since they have no copy of the repo
|
| 130 |
+
on the host and the repo on the builder image is a clone from main/master.
|
| 131 |
+
Right now it is needed by external on GitHub because we need to clone a new
|
| 132 |
+
repo because the copy they give us doesn't work for diffing.
|
| 133 |
+
|
| 134 |
+
TODO(metzman): Try to eliminate the need for this by 1. Making the clone
|
| 135 |
+
from external github projects usable. 2. Forcing OSS-Fuzz on Github to clone
|
| 136 |
+
before starting CIFuzz."""
|
| 137 |
+
if self._event == 'pull_request':
|
| 138 |
+
pr_ref = f'refs/pull/{self._event_data["pull_request"]["number"]}/merge'
|
| 139 |
+
logging.debug('pr_ref: %s', pr_ref)
|
| 140 |
+
return pr_ref
|
| 141 |
+
return None
|
| 142 |
+
|
| 143 |
+
@property
|
| 144 |
+
def base_ref(self):
|
| 145 |
+
"""Returns the base branch to diff against (pr fuzzing)."""
|
| 146 |
+
return os.getenv('GITHUB_BASE_REF')
|
local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/platform_config/github_test.py
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2021 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
"""Tests for platform_config.github."""
|
| 15 |
+
import os
|
| 16 |
+
import unittest
|
| 17 |
+
from unittest import mock
|
| 18 |
+
|
| 19 |
+
import platform_config.github
|
| 20 |
+
import test_helpers
|
| 21 |
+
|
| 22 |
+
# pylint: disable=arguments-differ
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
class GetProjectRepoOwnerAndNameTest(unittest.TestCase):
|
| 26 |
+
"""Tests for get_project_repo_owner and get_project_repo_name."""
|
| 27 |
+
|
| 28 |
+
@mock.patch('platform_config.github._get_event_data', return_value={})
|
| 29 |
+
def setUp(self, _):
|
| 30 |
+
test_helpers.patch_environ(self)
|
| 31 |
+
self.repo_owner = 'repo-owner'
|
| 32 |
+
self.repo_name = 'repo-name'
|
| 33 |
+
os.environ['GITHUB_REPOSITORY'] = f'{self.repo_owner}/{self.repo_name}'
|
| 34 |
+
self.platform_conf = platform_config.github.PlatformConfig()
|
| 35 |
+
|
| 36 |
+
def test_github_repository_owner(self):
|
| 37 |
+
"""Tests that the correct result is returned when repository contains the
|
| 38 |
+
owner and repo name (as it does on GitHub)."""
|
| 39 |
+
self.assertEqual(self.platform_conf.project_repo_owner, self.repo_owner)
|
| 40 |
+
|
| 41 |
+
def test_github_repository_name(self):
|
| 42 |
+
"""Tests that the correct result is returned when repository contains the
|
| 43 |
+
owner and repo name (as it does on GitHub)."""
|
| 44 |
+
os.environ['GITHUB_REPOSITORY'] = f'{self.repo_owner}/{self.repo_name}'
|
| 45 |
+
self.assertEqual(self.platform_conf.project_repo_name, self.repo_name)
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
class ProjectSrcPathTest(unittest.TestCase):
|
| 49 |
+
"""Tests for project_src_path."""
|
| 50 |
+
|
| 51 |
+
def setUp(self):
|
| 52 |
+
test_helpers.patch_environ(self)
|
| 53 |
+
self.workspace = '/workspace'
|
| 54 |
+
os.environ['GITHUB_WORKSPACE'] = self.workspace
|
| 55 |
+
self.project_src_dir_name = 'project-src'
|
| 56 |
+
|
| 57 |
+
@mock.patch('platform_config.github._get_event_data', return_value={})
|
| 58 |
+
def test_github_unset(self, _):
|
| 59 |
+
"""Tests that project_src_path returns None when no PROJECT_SRC_PATH is
|
| 60 |
+
set."""
|
| 61 |
+
github_env = platform_config.github.PlatformConfig()
|
| 62 |
+
self.assertIsNone(github_env.project_src_path)
|
| 63 |
+
|
| 64 |
+
@mock.patch('platform_config.github._get_event_data', return_value={})
|
| 65 |
+
def test_github(self, _):
|
| 66 |
+
"""Tests that project_src_path returns the correct result on GitHub."""
|
| 67 |
+
os.environ['PROJECT_SRC_PATH'] = self.project_src_dir_name
|
| 68 |
+
expected_project_src_path = os.path.join(self.workspace,
|
| 69 |
+
self.project_src_dir_name)
|
| 70 |
+
github_env = platform_config.github.PlatformConfig()
|
| 71 |
+
self.assertEqual(github_env.project_src_path, expected_project_src_path)
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
class GetGitUrlTest(unittest.TestCase):
|
| 75 |
+
"""Tests for GenericPlatformConfig.git_url."""
|
| 76 |
+
|
| 77 |
+
@mock.patch('platform_config.github._get_event_data', return_value={})
|
| 78 |
+
def setUp(self, _):
|
| 79 |
+
test_helpers.patch_environ(self)
|
| 80 |
+
self.platform_conf = platform_config.github.PlatformConfig()
|
| 81 |
+
|
| 82 |
+
def test_repository(self):
|
| 83 |
+
"""Tests that the correct result is returned when repository contains the
|
| 84 |
+
owner and repo name (as it does on GitHub)."""
|
| 85 |
+
os.environ['GITHUB_REPOSITORY'] = 'repo/owner'
|
| 86 |
+
self.assertEqual('https://github.com/repo/owner',
|
| 87 |
+
self.platform_conf.git_url)
|
local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/platform_config/gitlab.py
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2022 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
"""Module for getting the configuration CIFuzz needs to run on GitLab."""
|
| 15 |
+
import logging
|
| 16 |
+
import os
|
| 17 |
+
|
| 18 |
+
import environment
|
| 19 |
+
import platform_config
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
class PlatformConfig(platform_config.BasePlatformConfig):
|
| 23 |
+
"""CI environment for GitLab."""
|
| 24 |
+
|
| 25 |
+
@property
|
| 26 |
+
def workspace(self):
|
| 27 |
+
"""Returns the workspace."""
|
| 28 |
+
return os.path.join(os.getenv('CI_BUILDS_DIR'), os.getenv('CI_JOB_ID'))
|
| 29 |
+
|
| 30 |
+
@property
|
| 31 |
+
def git_sha(self):
|
| 32 |
+
"""Returns the Git SHA to checkout and fuzz."""
|
| 33 |
+
return os.getenv('CI_COMMIT_SHA')
|
| 34 |
+
|
| 35 |
+
@property
|
| 36 |
+
def project_src_path(self):
|
| 37 |
+
"""Returns the directory with the source of the project"""
|
| 38 |
+
return os.getenv('CI_PROJECT_DIR')
|
| 39 |
+
|
| 40 |
+
@property
|
| 41 |
+
def token(self):
|
| 42 |
+
"""Returns the job token"""
|
| 43 |
+
return os.getenv('CI_JOB_TOKEN')
|
| 44 |
+
|
| 45 |
+
@property
|
| 46 |
+
def project_repo_name(self):
|
| 47 |
+
"""Returns the project's name"""
|
| 48 |
+
return os.getenv('CI_PROJECT_NAME')
|
| 49 |
+
|
| 50 |
+
@property
|
| 51 |
+
def base_commit(self):
|
| 52 |
+
"""Returns the previous commit sha for commit-fuzzing"""
|
| 53 |
+
base_commit = None
|
| 54 |
+
if os.getenv('CI_PIPELINE_SOURCE') == 'push':
|
| 55 |
+
base_commit = os.getenv('CI_COMMIT_BEFORE_SHA')
|
| 56 |
+
logging.debug('base_commit: %s.', base_commit)
|
| 57 |
+
return base_commit
|
| 58 |
+
|
| 59 |
+
@property
|
| 60 |
+
def base_ref(self):
|
| 61 |
+
"""Returns the base commit sha for a merge request"""
|
| 62 |
+
# Could also be CI_MERGE_REQUEST_TARGET_BRANCH_NAME.
|
| 63 |
+
return os.getenv('CI_MERGE_REQUEST_DIFF_BASE_SHA')
|
| 64 |
+
|
| 65 |
+
@property
|
| 66 |
+
def filestore(self):
|
| 67 |
+
"""Returns the filestore used to store persistent data."""
|
| 68 |
+
return os.environ.get('FILESTORE', 'gitlab')
|
| 69 |
+
|
| 70 |
+
@property
|
| 71 |
+
def artifacts_dir(self):
|
| 72 |
+
"""Gitlab: returns the directory to put artifacts"""
|
| 73 |
+
return environment.get('CFL_ARTIFACTS_DIR', 'artifacts')
|
| 74 |
+
|
| 75 |
+
@property
|
| 76 |
+
def cache_dir(self):
|
| 77 |
+
"""Gitlab: returns the directory to use as cache"""
|
| 78 |
+
return environment.get('CFL_CACHE_DIR', 'cache')
|
local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/platform_config/platform_config_test.py
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2021 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
"""Tests for platform_config."""
|
| 15 |
+
import os
|
| 16 |
+
import unittest
|
| 17 |
+
|
| 18 |
+
import platform_config
|
| 19 |
+
import test_helpers
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
class GetProjectRepoOwnerAndNameTest(unittest.TestCase):
|
| 23 |
+
"""Tests for get_project_repo_owner and get_project_repo_name."""
|
| 24 |
+
|
| 25 |
+
def setUp(self):
|
| 26 |
+
test_helpers.patch_environ(self)
|
| 27 |
+
self.repo_owner = 'repo-owner'
|
| 28 |
+
self.repo_name = 'repo-name'
|
| 29 |
+
self.env = platform_config.BasePlatformConfig()
|
| 30 |
+
|
| 31 |
+
def test_unset_repository(self):
|
| 32 |
+
"""Tests that the correct result is returned when repository is not set."""
|
| 33 |
+
self.assertIsNone(self.env.project_repo_name)
|
| 34 |
+
|
| 35 |
+
def test_owner(self):
|
| 36 |
+
"""Tests that the correct result is returned for owner."""
|
| 37 |
+
self.assertIsNone(self.env.project_repo_owner)
|
| 38 |
+
|
| 39 |
+
def test_empty_repository(self):
|
| 40 |
+
"""Tests that the correct result is returned when repository is an empty
|
| 41 |
+
string."""
|
| 42 |
+
os.environ['REPOSITORY'] = ''
|
| 43 |
+
self.assertEqual(self.env.project_repo_name, '')
|
| 44 |
+
|
| 45 |
+
def test_repository(self):
|
| 46 |
+
"""Tests that the correct result is returned when repository contains the
|
| 47 |
+
just the repo name (as it does outside of GitHub)."""
|
| 48 |
+
os.environ['REPOSITORY'] = self.repo_name
|
| 49 |
+
self.assertEqual(self.env.project_repo_name, self.repo_name)
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
class ProjectSrcPathTest(unittest.TestCase):
|
| 53 |
+
"""Tests for project_src_path."""
|
| 54 |
+
|
| 55 |
+
def setUp(self):
|
| 56 |
+
test_helpers.patch_environ(self)
|
| 57 |
+
|
| 58 |
+
def test_not_github(self):
|
| 59 |
+
"""Tests that project_src_path returns the correct result not on
|
| 60 |
+
GitHub."""
|
| 61 |
+
project_src_path = 'project-src'
|
| 62 |
+
os.environ['PROJECT_SRC_PATH'] = project_src_path
|
| 63 |
+
generic_ci_env = platform_config.BasePlatformConfig()
|
| 64 |
+
self.assertEqual(generic_ci_env.project_src_path, project_src_path)
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
class GetGitUrlTest(unittest.TestCase):
|
| 68 |
+
"""Tests for BasePlatformConfig.git_url."""
|
| 69 |
+
|
| 70 |
+
def setUp(self):
|
| 71 |
+
test_helpers.patch_environ(self)
|
| 72 |
+
self.env = platform_config.BasePlatformConfig()
|
| 73 |
+
|
| 74 |
+
def test_unset_repository(self):
|
| 75 |
+
"""Tests that the correct result is returned when repository is not set."""
|
| 76 |
+
self.assertEqual(self.env.git_url, None)
|
| 77 |
+
|
| 78 |
+
def test_repository(self):
|
| 79 |
+
"""Tests that the correct result is returned when GITHUB_REPOSITORY is
|
| 80 |
+
set."""
|
| 81 |
+
os.environ['GITHUB_REPOSITORY'] = 'repo/owner'
|
| 82 |
+
self.assertIsNone(self.env.git_url)
|
local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/platform_config/prow.py
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2021 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
"""Module for getting the configuration CIFuzz needs to run on prow."""
|
| 15 |
+
import logging
|
| 16 |
+
import os
|
| 17 |
+
|
| 18 |
+
import platform_config
|
| 19 |
+
|
| 20 |
+
# pylint: disable=too-few-public-methods
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
class PlatformConfig(platform_config.BasePlatformConfig):
|
| 24 |
+
"""CI environment for Prow."""
|
| 25 |
+
|
| 26 |
+
@property
|
| 27 |
+
def project_src_path(self):
|
| 28 |
+
"""Returns the manually checked out path of the project's source if
|
| 29 |
+
specified or the current directory if not. Prow will run ClusterfuzzLite
|
| 30 |
+
at the directory head for the repo."""
|
| 31 |
+
project_src_path = os.getenv('PROJECT_SRC_PATH', os.getcwd())
|
| 32 |
+
logging.debug('PROJECT_SRC_PATH: %s.', project_src_path)
|
| 33 |
+
return project_src_path
|
| 34 |
+
|
| 35 |
+
@property
|
| 36 |
+
def workspace(self):
|
| 37 |
+
"""Returns the workspace."""
|
| 38 |
+
# Let Prow user override workspace, but default to using artifacts dir
|
| 39 |
+
return os.getenv('WORKSPACE', os.getenv('ARTIFACTS'))
|
| 40 |
+
|
| 41 |
+
@property
|
| 42 |
+
def base_ref(self):
|
| 43 |
+
"""Returns the base branch to diff against (pr fuzzing)."""
|
| 44 |
+
return os.getenv('PULL_BASE_REF')
|
| 45 |
+
|
| 46 |
+
@property
|
| 47 |
+
def project_repo_name(self):
|
| 48 |
+
"""Returns the project repo name."""
|
| 49 |
+
return os.getenv('REPO_NAME')
|
| 50 |
+
|
| 51 |
+
@property
|
| 52 |
+
def base_commit(self):
|
| 53 |
+
"""Returns the base commit to diff against (commit fuzzing)."""
|
| 54 |
+
return os.getenv('PULL_BASE_SHA')
|
| 55 |
+
|
| 56 |
+
@property
|
| 57 |
+
def docker_in_docker(self):
|
| 58 |
+
"""Returns True if using Docker in Docker."""
|
| 59 |
+
return True
|
| 60 |
+
|
| 61 |
+
@property
|
| 62 |
+
def filestore(self):
|
| 63 |
+
"""Returns the filestore used to store persistent data."""
|
| 64 |
+
return os.environ.get('FILESTORE', 'gsutil')
|
local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/platform_config/standalone.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2022 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
"""Module for getting the configuration CIFuzz needs to run standalone."""
|
| 15 |
+
import os
|
| 16 |
+
|
| 17 |
+
import platform_config
|
| 18 |
+
|
| 19 |
+
# pylint: disable=too-few-public-methods
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
class PlatformConfig(platform_config.BasePlatformConfig):
|
| 23 |
+
"""CI environment for Standalone."""
|
| 24 |
+
|
| 25 |
+
@property
|
| 26 |
+
def filestore(self):
|
| 27 |
+
"""Returns the filestore used to store persistent data."""
|
| 28 |
+
return os.environ.get('FILESTORE', 'filesystem')
|
| 29 |
+
|
| 30 |
+
@property
|
| 31 |
+
def filestore_root_dir(self):
|
| 32 |
+
"""Returns the filestore used to store persistent data."""
|
| 33 |
+
return os.environ['FILESTORE_ROOT_DIR']
|
local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/run_fuzzers.py
ADDED
|
@@ -0,0 +1,321 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2021 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
"""Module for running fuzzers."""
|
| 15 |
+
import enum
|
| 16 |
+
import logging
|
| 17 |
+
import os
|
| 18 |
+
import sys
|
| 19 |
+
import time
|
| 20 |
+
|
| 21 |
+
import clusterfuzz_deployment
|
| 22 |
+
import fuzz_target
|
| 23 |
+
import generate_coverage_report
|
| 24 |
+
import workspace_utils
|
| 25 |
+
import sarif_utils
|
| 26 |
+
|
| 27 |
+
# pylint: disable=wrong-import-position,import-error
|
| 28 |
+
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
| 29 |
+
|
| 30 |
+
import utils
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
class RunFuzzersResult(enum.Enum):
|
| 34 |
+
"""Enum result from running fuzzers."""
|
| 35 |
+
ERROR = 0
|
| 36 |
+
BUG_FOUND = 1
|
| 37 |
+
NO_BUG_FOUND = 2
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
class BaseFuzzTargetRunner:
|
| 41 |
+
"""Base class for fuzzer runners."""
|
| 42 |
+
|
| 43 |
+
def __init__(self, config):
|
| 44 |
+
self.config = config
|
| 45 |
+
self.workspace = workspace_utils.Workspace(config)
|
| 46 |
+
self.clusterfuzz_deployment = (
|
| 47 |
+
clusterfuzz_deployment.get_clusterfuzz_deployment(
|
| 48 |
+
self.config, self.workspace))
|
| 49 |
+
|
| 50 |
+
# Set by the initialize method.
|
| 51 |
+
self.fuzz_target_paths = None
|
| 52 |
+
|
| 53 |
+
def get_fuzz_targets(self):
|
| 54 |
+
"""Returns fuzz targets in out directory."""
|
| 55 |
+
return utils.get_fuzz_targets(self.workspace.out)
|
| 56 |
+
|
| 57 |
+
def initialize(self):
|
| 58 |
+
"""Initialization method. Must be called before calling run_fuzz_targets.
|
| 59 |
+
Returns True on success."""
|
| 60 |
+
# Use a separate initialization function so we can return False on failure
|
| 61 |
+
# instead of exceptioning like we need to do if this were done in the
|
| 62 |
+
# __init__ method.
|
| 63 |
+
|
| 64 |
+
logging.info('Using %s sanitizer.', self.config.sanitizer)
|
| 65 |
+
|
| 66 |
+
# TODO(metzman) Add a check to ensure we aren't over time limit.
|
| 67 |
+
if not self.config.fuzz_seconds or self.config.fuzz_seconds < 1:
|
| 68 |
+
logging.error(
|
| 69 |
+
'Fuzz_seconds argument must be greater than 1, but was: %s.',
|
| 70 |
+
self.config.fuzz_seconds)
|
| 71 |
+
return False
|
| 72 |
+
|
| 73 |
+
if not os.path.exists(self.workspace.out):
|
| 74 |
+
logging.error('Out directory: %s does not exist.', self.workspace.out)
|
| 75 |
+
return False
|
| 76 |
+
|
| 77 |
+
if not os.path.exists(self.workspace.artifacts):
|
| 78 |
+
os.makedirs(self.workspace.artifacts)
|
| 79 |
+
elif (not os.path.isdir(self.workspace.artifacts) or
|
| 80 |
+
os.listdir(self.workspace.artifacts)):
|
| 81 |
+
logging.error('Artifacts path: %s exists and is not an empty directory.',
|
| 82 |
+
self.workspace.artifacts)
|
| 83 |
+
return False
|
| 84 |
+
|
| 85 |
+
self.fuzz_target_paths = self.get_fuzz_targets()
|
| 86 |
+
logging.info('Fuzz targets: %s', self.fuzz_target_paths)
|
| 87 |
+
if not self.fuzz_target_paths:
|
| 88 |
+
logging.error('No fuzz targets were found in out directory: %s.',
|
| 89 |
+
self.workspace.out)
|
| 90 |
+
return False
|
| 91 |
+
|
| 92 |
+
return True
|
| 93 |
+
|
| 94 |
+
def cleanup_after_fuzz_target_run(self, fuzz_target_obj): # pylint: disable=no-self-use
|
| 95 |
+
"""Cleans up after running |fuzz_target_obj|."""
|
| 96 |
+
raise NotImplementedError('Child class must implement method.')
|
| 97 |
+
|
| 98 |
+
def run_fuzz_target(self, fuzz_target_obj): # pylint: disable=no-self-use
|
| 99 |
+
"""Fuzzes with |fuzz_target_obj| and returns the result."""
|
| 100 |
+
raise NotImplementedError('Child class must implement method.')
|
| 101 |
+
|
| 102 |
+
@property
|
| 103 |
+
def quit_on_bug_found(self):
|
| 104 |
+
"""Property that is checked to determine if fuzzing should quit after first
|
| 105 |
+
bug is found."""
|
| 106 |
+
raise NotImplementedError('Child class must implement method.')
|
| 107 |
+
|
| 108 |
+
def create_fuzz_target_obj(self, target_path, run_seconds):
|
| 109 |
+
"""Returns a fuzz target object."""
|
| 110 |
+
return fuzz_target.FuzzTarget(target_path, run_seconds, self.workspace,
|
| 111 |
+
self.clusterfuzz_deployment, self.config)
|
| 112 |
+
|
| 113 |
+
def run_fuzz_targets(self):
|
| 114 |
+
"""Runs fuzz targets. Returns True if a bug was found."""
|
| 115 |
+
fuzzers_left_to_run = len(self.fuzz_target_paths)
|
| 116 |
+
|
| 117 |
+
# Make a copy since we will mutate it.
|
| 118 |
+
fuzz_seconds = self.config.fuzz_seconds
|
| 119 |
+
|
| 120 |
+
min_seconds_per_fuzzer = fuzz_seconds // fuzzers_left_to_run
|
| 121 |
+
bug_found = False
|
| 122 |
+
for target_path in self.fuzz_target_paths:
|
| 123 |
+
# By doing this, we can ensure that every fuzz target runs for at least
|
| 124 |
+
# min_seconds_per_fuzzer, but that other fuzzers will have longer to run
|
| 125 |
+
# if one ends early.
|
| 126 |
+
run_seconds = max(fuzz_seconds // fuzzers_left_to_run,
|
| 127 |
+
min_seconds_per_fuzzer)
|
| 128 |
+
|
| 129 |
+
target = self.create_fuzz_target_obj(target_path, run_seconds)
|
| 130 |
+
start_time = time.time()
|
| 131 |
+
result = self.run_fuzz_target(target)
|
| 132 |
+
self.cleanup_after_fuzz_target_run(target)
|
| 133 |
+
|
| 134 |
+
# It's OK if this goes negative since we take max when determining
|
| 135 |
+
# run_seconds.
|
| 136 |
+
fuzz_seconds -= time.time() - start_time
|
| 137 |
+
|
| 138 |
+
fuzzers_left_to_run -= 1
|
| 139 |
+
if not result.testcase or not result.stacktrace:
|
| 140 |
+
logging.info('Fuzzer %s finished running without reportable crashes.',
|
| 141 |
+
target.target_name)
|
| 142 |
+
continue
|
| 143 |
+
|
| 144 |
+
bug_found = True
|
| 145 |
+
if self.quit_on_bug_found:
|
| 146 |
+
logging.info('Bug found. Stopping fuzzing.')
|
| 147 |
+
break
|
| 148 |
+
|
| 149 |
+
# pylint: disable=undefined-loop-variable
|
| 150 |
+
if not target_path:
|
| 151 |
+
logging.error('Ran no fuzz targets.')
|
| 152 |
+
elif self.config.output_sarif:
|
| 153 |
+
# TODO(metzman): Handle multiple crashes.
|
| 154 |
+
write_fuzz_result_to_sarif(result, target_path, self.workspace)
|
| 155 |
+
self.clusterfuzz_deployment.upload_crashes()
|
| 156 |
+
return bug_found
|
| 157 |
+
|
| 158 |
+
|
| 159 |
+
def write_fuzz_result_to_sarif(fuzz_result, target_path, workspace):
|
| 160 |
+
"""Write results of fuzzing to SARIF."""
|
| 161 |
+
logging.info('Writing sarif results.')
|
| 162 |
+
sarif_utils.write_stacktrace_to_sarif(fuzz_result.stacktrace, target_path,
|
| 163 |
+
workspace)
|
| 164 |
+
|
| 165 |
+
|
| 166 |
+
class PruneTargetRunner(BaseFuzzTargetRunner):
|
| 167 |
+
"""Runner that prunes corpora."""
|
| 168 |
+
|
| 169 |
+
@property
|
| 170 |
+
def quit_on_bug_found(self):
|
| 171 |
+
return False
|
| 172 |
+
|
| 173 |
+
def run_fuzz_target(self, fuzz_target_obj):
|
| 174 |
+
"""Prunes with |fuzz_target_obj| and returns the result."""
|
| 175 |
+
result = fuzz_target_obj.prune()
|
| 176 |
+
logging.debug('Corpus path contents: %s.', os.listdir(result.corpus_path))
|
| 177 |
+
self.clusterfuzz_deployment.upload_corpus(fuzz_target_obj.target_name,
|
| 178 |
+
result.corpus_path,
|
| 179 |
+
replace=True)
|
| 180 |
+
return result
|
| 181 |
+
|
| 182 |
+
def cleanup_after_fuzz_target_run(self, fuzz_target_obj): # pylint: disable=no-self-use
|
| 183 |
+
"""Cleans up after pruning with |fuzz_target_obj|."""
|
| 184 |
+
fuzz_target_obj.free_disk_if_needed()
|
| 185 |
+
|
| 186 |
+
|
| 187 |
+
NON_FUZZ_TARGETS_FOR_COVERAGE = {
|
| 188 |
+
'llvm-symbolizer',
|
| 189 |
+
'jazzer_agent_deploy.jar',
|
| 190 |
+
'jazzer_driver',
|
| 191 |
+
'jazzer_driver_with_sanitizer',
|
| 192 |
+
}
|
| 193 |
+
|
| 194 |
+
|
| 195 |
+
def is_coverage_fuzz_target(file_path):
|
| 196 |
+
"""Returns whether |file_path| is a fuzz target binary for the purposes of a
|
| 197 |
+
coverage report. Inspired by infra/base-images/base-runner/coverage."""
|
| 198 |
+
if not os.path.isfile(file_path):
|
| 199 |
+
return False
|
| 200 |
+
if not utils.is_executable(file_path):
|
| 201 |
+
return False
|
| 202 |
+
filename = os.path.basename(file_path)
|
| 203 |
+
return filename not in NON_FUZZ_TARGETS_FOR_COVERAGE
|
| 204 |
+
|
| 205 |
+
|
| 206 |
+
def get_coverage_fuzz_targets(out):
|
| 207 |
+
"""Returns a list of fuzz targets in |out| for coverage."""
|
| 208 |
+
# We only want fuzz targets from the root because during the coverage build,
|
| 209 |
+
# a lot of the image's filesystem is copied into /out for the purpose of
|
| 210 |
+
# generating coverage reports.
|
| 211 |
+
fuzz_targets = []
|
| 212 |
+
for filename in os.listdir(out):
|
| 213 |
+
file_path = os.path.join(out, filename)
|
| 214 |
+
if is_coverage_fuzz_target(file_path):
|
| 215 |
+
fuzz_targets.append(file_path)
|
| 216 |
+
return fuzz_targets
|
| 217 |
+
|
| 218 |
+
|
| 219 |
+
class CoverageTargetRunner(BaseFuzzTargetRunner):
|
| 220 |
+
"""Runner that runs the 'coverage' command."""
|
| 221 |
+
|
| 222 |
+
@property
|
| 223 |
+
def quit_on_bug_found(self):
|
| 224 |
+
raise NotImplementedError('Not implemented for CoverageTargetRunner.')
|
| 225 |
+
|
| 226 |
+
def get_fuzz_targets(self):
|
| 227 |
+
"""Returns fuzz targets in out directory."""
|
| 228 |
+
return get_coverage_fuzz_targets(self.workspace.out)
|
| 229 |
+
|
| 230 |
+
def run_fuzz_targets(self):
|
| 231 |
+
"""Generates a coverage report. Always returns False since it never finds
|
| 232 |
+
any bugs."""
|
| 233 |
+
generate_coverage_report.generate_coverage_report(
|
| 234 |
+
self.fuzz_target_paths, self.workspace, self.clusterfuzz_deployment,
|
| 235 |
+
self.config)
|
| 236 |
+
return False
|
| 237 |
+
|
| 238 |
+
def run_fuzz_target(self, fuzz_target_obj): # pylint: disable=no-self-use
|
| 239 |
+
"""Fuzzes with |fuzz_target_obj| and returns the result."""
|
| 240 |
+
raise NotImplementedError('Not implemented for CoverageTargetRunner.')
|
| 241 |
+
|
| 242 |
+
def cleanup_after_fuzz_target_run(self, fuzz_target_obj): # pylint: disable=no-self-use
|
| 243 |
+
"""Cleans up after running |fuzz_target_obj|."""
|
| 244 |
+
raise NotImplementedError('Not implemented for CoverageTargetRunner.')
|
| 245 |
+
|
| 246 |
+
|
| 247 |
+
class CiFuzzTargetRunner(BaseFuzzTargetRunner):
|
| 248 |
+
"""Runner for fuzz targets used in CI (patch-fuzzing) context."""
|
| 249 |
+
|
| 250 |
+
@property
|
| 251 |
+
def quit_on_bug_found(self):
|
| 252 |
+
return True
|
| 253 |
+
|
| 254 |
+
def cleanup_after_fuzz_target_run(self, fuzz_target_obj): # pylint: disable=no-self-use
|
| 255 |
+
"""Cleans up after running |fuzz_target_obj|."""
|
| 256 |
+
fuzz_target_obj.free_disk_if_needed()
|
| 257 |
+
|
| 258 |
+
def run_fuzz_target(self, fuzz_target_obj): # pylint: disable=no-self-use
|
| 259 |
+
return fuzz_target_obj.fuzz()
|
| 260 |
+
|
| 261 |
+
|
| 262 |
+
class BatchFuzzTargetRunner(BaseFuzzTargetRunner):
|
| 263 |
+
"""Runner for fuzz targets used in batch fuzzing context."""
|
| 264 |
+
|
| 265 |
+
@property
|
| 266 |
+
def quit_on_bug_found(self):
|
| 267 |
+
return False
|
| 268 |
+
|
| 269 |
+
def run_fuzz_target(self, fuzz_target_obj):
|
| 270 |
+
"""Fuzzes with |fuzz_target_obj| and returns the result."""
|
| 271 |
+
result = fuzz_target_obj.fuzz(batch=True)
|
| 272 |
+
logging.debug('Corpus path contents: %s.', os.listdir(result.corpus_path))
|
| 273 |
+
self.clusterfuzz_deployment.upload_corpus(fuzz_target_obj.target_name,
|
| 274 |
+
result.corpus_path)
|
| 275 |
+
return result
|
| 276 |
+
|
| 277 |
+
def cleanup_after_fuzz_target_run(self, fuzz_target_obj):
|
| 278 |
+
"""Cleans up after running |fuzz_target_obj|."""
|
| 279 |
+
# This must be done after we upload the corpus, otherwise it will be deleted
|
| 280 |
+
# before we get a chance to upload it. We can't delete the fuzz target
|
| 281 |
+
# because it is needed when we upload the build.
|
| 282 |
+
fuzz_target_obj.free_disk_if_needed(delete_fuzz_target=False)
|
| 283 |
+
|
| 284 |
+
|
| 285 |
+
_MODE_RUNNER_MAPPING = {
|
| 286 |
+
'batch': BatchFuzzTargetRunner,
|
| 287 |
+
'coverage': CoverageTargetRunner,
|
| 288 |
+
'prune': PruneTargetRunner,
|
| 289 |
+
'code-change': CiFuzzTargetRunner,
|
| 290 |
+
}
|
| 291 |
+
|
| 292 |
+
|
| 293 |
+
def get_fuzz_target_runner(config):
|
| 294 |
+
"""Returns a fuzz target runner object based on the mode of
|
| 295 |
+
|config|."""
|
| 296 |
+
runner = _MODE_RUNNER_MAPPING[config.mode](config)
|
| 297 |
+
logging.info('run fuzzers MODE is: %s. Runner: %s.', config.mode, runner)
|
| 298 |
+
return runner
|
| 299 |
+
|
| 300 |
+
|
| 301 |
+
def run_fuzzers(config): # pylint: disable=too-many-locals
|
| 302 |
+
"""Runs fuzzers for a specific OSS-Fuzz project.
|
| 303 |
+
|
| 304 |
+
Args:
|
| 305 |
+
config: A RunFuzzTargetsConfig.
|
| 306 |
+
|
| 307 |
+
Returns:
|
| 308 |
+
A RunFuzzersResult enum value indicating what happened during fuzzing.
|
| 309 |
+
"""
|
| 310 |
+
fuzz_target_runner = get_fuzz_target_runner(config)
|
| 311 |
+
if not fuzz_target_runner.initialize():
|
| 312 |
+
# We didn't fuzz at all because of internal (CIFuzz) errors. And we didn't
|
| 313 |
+
# find any bugs.
|
| 314 |
+
return RunFuzzersResult.ERROR
|
| 315 |
+
|
| 316 |
+
if not fuzz_target_runner.run_fuzz_targets():
|
| 317 |
+
# We fuzzed successfully, but didn't find any bugs (in the fuzz target).
|
| 318 |
+
return RunFuzzersResult.NO_BUG_FOUND
|
| 319 |
+
|
| 320 |
+
# We fuzzed successfully and found bug(s) in the fuzz targets.
|
| 321 |
+
return RunFuzzersResult.BUG_FOUND
|
local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/test_data/TimeoutFuzzer.cpp
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright 2021 Google LLC
|
| 2 |
+
//
|
| 3 |
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
// you may not use this file except in compliance with the License.
|
| 5 |
+
// You may obtain a copy of the License at
|
| 6 |
+
//
|
| 7 |
+
// http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
//
|
| 9 |
+
// Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
// See the License for the specific language governing permissions and
|
| 13 |
+
// limitations under the License.
|
| 14 |
+
|
| 15 |
+
// Example of a standalone runner for "fuzz targets".
|
| 16 |
+
// It reads all files passed as parameters and feeds their contents
|
| 17 |
+
// one by one into the fuzz target (LLVMFuzzerTestOneInput).
|
| 18 |
+
// This runner does not do any fuzzing, but allows us to run the fuzz target
|
| 19 |
+
// on the test corpus (e.g. "do_stuff_test_data") or on a single file,
|
| 20 |
+
// e.g. the one that comes from a bug report.
|
| 21 |
+
|
| 22 |
+
// This is a fuzz target that times out on every input by infinite looping.
|
| 23 |
+
// This is used for testing.
|
| 24 |
+
// Build instructions:
|
| 25 |
+
// 1. clang++ -fsanitize=fuzzer TimeoutFuzzer.cpp -o timeout_fuzzer
|
| 26 |
+
// 2. strip timeout_fuzzer
|
| 27 |
+
// The binary is stripped to save space in the git repo.
|
| 28 |
+
|
| 29 |
+
#include <stddef.h>
|
| 30 |
+
#include <stdint.h>
|
| 31 |
+
|
| 32 |
+
extern "C" int LLVMFuzzerTestOneInput(uint8_t* data, size_t size) {
|
| 33 |
+
while (true)
|
| 34 |
+
;
|
| 35 |
+
return 0;
|
| 36 |
+
}
|
local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/test_data/example_crash_fuzzer_bug_summary.txt
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
AddressSanitizer: heap-buffer-overflow on address 0x62500001b530 at pc 0x00000052138a bp 0x7ffe62db2c10 sp 0x7ffe62db23d8
|
| 2 |
+
READ of size 52 at 0x62500001b530 thread T0
|
| 3 |
+
SCARINESS: 26 (multi-byte-read-heap-buffer-overflow)
|
| 4 |
+
#0 0x521389 in __asan_memcpy /src/llvm-project/compiler-rt/lib/asan/asan_interceptors_memintrinsics.cpp:22:3
|
| 5 |
+
#1 0x567590 in yr_object_set_string /src/yara/libyara/object.c:1122:5
|
| 6 |
+
#2 0x5afced in dex_parse /src/yara/libyara/modules/dex/dex.c:781:5
|
| 7 |
+
#3 0x5b4a8b in dex__load /src/yara/libyara/modules/dex/dex.c:1218:7
|
| 8 |
+
#4 0x56537c in yr_modules_load /src/yara/libyara/modules.c:179:16
|
| 9 |
+
#5 0x5d6583 in yr_execute_code /src/yara/libyara/exec.c:1276:18
|
| 10 |
+
#6 0x56f5c0 in yr_scanner_scan_mem_blocks /src/yara/libyara/scanner.c:444:3
|
| 11 |
+
#7 0x56bf23 in yr_rules_scan_mem_blocks /src/yara/libyara/rules.c:235:12
|
| 12 |
+
#8 0x56c182 in yr_rules_scan_mem /src/yara/libyara/rules.c:285:10
|
| 13 |
+
#9 0x5548d2 in LLVMFuzzerTestOneInput /src/yara/tests/oss-fuzz/dex_fuzzer.cc:40:3
|
| 14 |
+
#10 0x45a3b1 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:556:15
|
| 15 |
+
#11 0x459ad5 in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:470:3
|
| 16 |
+
#12 0x45be77 in fuzzer::Fuzzer::MutateAndTestOne() /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:698:19
|
| 17 |
+
#13 0x45cc05 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:830:5
|
| 18 |
+
#14 0x44ac88 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:824:6
|
| 19 |
+
#15 0x474ab2 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:19:10
|
| 20 |
+
#16 0x7f4409b7a82f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
|
| 21 |
+
#17 0x41e348 in _start (out/dex_fuzzer+0x41e348)
|
| 22 |
+
|
| 23 |
+
0x62500001b530 is located 0 bytes to the right of 9264-byte region [0x625000019100,0x62500001b530)
|
| 24 |
+
allocated by thread T0 here:
|
| 25 |
+
#0 0x521f4d in malloc /src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:145:3
|
| 26 |
+
#1 0x4331b7 in operator new(unsigned long) (out/dex_fuzzer+0x4331b7)
|
| 27 |
+
#2 0x459ad5 in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:470:3
|
| 28 |
+
#3 0x45be77 in fuzzer::Fuzzer::MutateAndTestOne() /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:698:19
|
| 29 |
+
#4 0x45cc05 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:830:5
|
| 30 |
+
#5 0x44ac88 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:824:6
|
| 31 |
+
#6 0x474ab2 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:19:10
|
| 32 |
+
#7 0x7f4409b7a82f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
|
| 33 |
+
|
| 34 |
+
SUMMARY: AddressSanitizer: heap-buffer-overflow /src/llvm-project/compiler-rt/lib/asan/asan_interceptors_memintrinsics.cpp:22:3 in __asan_memcpy
|
| 35 |
+
Shadow bytes around the buggy address:
|
| 36 |
+
0x0c4a7fffb650: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|
| 37 |
+
0x0c4a7fffb660: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|
| 38 |
+
0x0c4a7fffb670: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|
| 39 |
+
0x0c4a7fffb680: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|
| 40 |
+
0x0c4a7fffb690: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|
| 41 |
+
=>0x0c4a7fffb6a0: 00 00 00 00 00 00[fa]fa fa fa fa fa fa fa fa fa
|
| 42 |
+
0x0c4a7fffb6b0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
| 43 |
+
0x0c4a7fffb6c0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
| 44 |
+
0x0c4a7fffb6d0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
| 45 |
+
0x0c4a7fffb6e0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
| 46 |
+
0x0c4a7fffb6f0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
| 47 |
+
|
| 48 |
+
Shadow byte legend (one shadow byte represents 8 application bytes):
|
| 49 |
+
Addressable: 00
|
| 50 |
+
Partially addressable: 01 02 03 04 05 06 07
|
| 51 |
+
Heap left redzone: fa
|
| 52 |
+
Freed heap region: fd
|
| 53 |
+
Stack left redzone: f1
|
| 54 |
+
Stack mid redzone: f2
|
| 55 |
+
Stack right redzone: f3
|
| 56 |
+
Stack after return: f5
|
| 57 |
+
Stack use after scope: f8
|
| 58 |
+
Global redzone: f9
|
| 59 |
+
Global init order: f6
|
| 60 |
+
Poisoned by user: f7
|
| 61 |
+
Container overflow: fc
|
| 62 |
+
Array cookie: ac
|
| 63 |
+
Intra object redzone: bb
|
| 64 |
+
ASan internal: fe
|
| 65 |
+
Left alloca redzone: ca
|
| 66 |
+
Right alloca redzone: cb
|
| 67 |
+
Shadow gap: cc
|
| 68 |
+
==12==ABORTING
|
local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/test_data/example_crash_fuzzer_output.txt
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/github/workspace/build-out/do_stuff_fuzzer -timeout=25 -rss_limit_mb=2560 -dict=/github/workspace/build-out/do_stuff_fuzzer.dict -len_control=0 -seed=1337 -artifact_prefix=/tmp/tmp9p1w4p8r/ -max_total_time=600 -print_final_stats=1 /github/workspace/cifuzz-corpus/do_stuff_fuzzer >fuzz-0.log 2>&1
|
| 2 |
+
================== Job 0 exited with exit code 77 ============
|
| 3 |
+
Dictionary: 3 entries
|
| 4 |
+
INFO: Running with entropic power schedule (0xFF, 100).
|
| 5 |
+
INFO: Seed: 1337
|
| 6 |
+
INFO: Loaded 1 modules (86 inline 8-bit counters): 86 [0x6150e0, 0x615136),
|
| 7 |
+
INFO: Loaded 1 PC tables (86 PCs): 86 [0x5c8b08,0x5c9068),
|
| 8 |
+
INFO: 5 files found in /github/workspace/cifuzz-corpus/do_stuff_fuzzer
|
| 9 |
+
INFO: -max_len is not provided; libFuzzer will not generate inputs larger than 4096 bytes
|
| 10 |
+
INFO: seed corpus: files: 5 min: 3b max: 44b total: 64b rss: 31Mb
|
| 11 |
+
#6 INITED cov: 64 ft: 70 corp: 5/64b exec/s: 0 rss: 32Mb
|
| 12 |
+
#9 NEW cov: 64 ft: 72 corp: 6/74b lim: 4096 exec/s: 0 rss: 32Mb L: 10/44 MS: 3 ChangeBit-InsertByte-ManualDict- DE: "foo"-
|
| 13 |
+
#17 NEW cov: 64 ft: 74 corp: 7/86b lim: 4096 exec/s: 0 rss: 32Mb L: 12/44 MS: 3 ChangeBit-ManualDict-PersAutoDict- DE: "ouch"-"foo"-
|
| 14 |
+
#18 NEW cov: 64 ft: 76 corp: 8/100b lim: 4096 exec/s: 0 rss: 32Mb L: 14/44 MS: 1 CrossOver-
|
| 15 |
+
#22 NEW cov: 64 ft: 78 corp: 9/141b lim: 4096 exec/s: 0 rss: 32Mb L: 41/44 MS: 4 InsertRepeatedBytes-CopyPart-ChangeBinInt-ChangeBit-
|
| 16 |
+
#24 NEW cov: 64 ft: 80 corp: 10/151b lim: 4096 exec/s: 0 rss: 32Mb L: 10/44 MS: 2 CrossOver-CopyPart-
|
| 17 |
+
#28 NEW cov: 64 ft: 81 corp: 11/171b lim: 4096 exec/s: 0 rss: 32Mb L: 20/44 MS: 4 InsertByte-PersAutoDict-ShuffleBytes-ManualDict- DE: "foo"-"ouch"-
|
| 18 |
+
#43 NEW cov: 65 ft: 83 corp: 12/175b lim: 4096 exec/s: 0 rss: 32Mb L: 4/44 MS: 5 InsertByte-ChangeBit-ManualDict-ManualDict-EraseBytes- DE: "bar"-"bar"-
|
| 19 |
+
#54 NEW cov: 65 ft: 84 corp: 13/191b lim: 4096 exec/s: 0 rss: 32Mb L: 16/44 MS: 1 CrossOver-
|
| 20 |
+
#64 NEW cov: 65 ft: 86 corp: 14/209b lim: 4096 exec/s: 0 rss: 32Mb L: 18/44 MS: 5 InsertByte-ChangeBinInt-CMP-PersAutoDict-CopyPart- DE: "\000\000"-"foo"-
|
| 21 |
+
#75 REDUCE cov: 65 ft: 86 corp: 14/203b lim: 4096 exec/s: 0 rss: 32Mb L: 35/44 MS: 1 EraseBytes-
|
| 22 |
+
#76 REDUCE cov: 65 ft: 86 corp: 14/195b lim: 4096 exec/s: 0 rss: 32Mb L: 36/36 MS: 1 EraseBytes-
|
| 23 |
+
=================================================================
|
| 24 |
+
==26==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x603000003114 at pc 0x00000056d1db bp 0x7fffd6a72bf0 sp 0x7fffd6a72be8
|
| 25 |
+
READ of size 4 at 0x603000003114 thread T0
|
| 26 |
+
SCARINESS: 17 (4-byte-read-heap-buffer-overflow)
|
| 27 |
+
#0 0x56d1da in DoStuff(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) /src/cifuzz-example/my_api.cpp:26:10
|
| 28 |
+
#1 0x56c5d6 in LLVMFuzzerTestOneInput /src/cifuzz-example/do_stuff_fuzzer.cpp:15:3
|
| 29 |
+
#2 0x43de23 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:611:15
|
| 30 |
+
#3 0x43d60a in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:514:3
|
| 31 |
+
#4 0x43ecd9 in fuzzer::Fuzzer::MutateAndTestOne() /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:757:19
|
| 32 |
+
#5 0x43f9a5 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:895:5
|
| 33 |
+
#6 0x42ed0f in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:912:6
|
| 34 |
+
#7 0x458362 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
|
| 35 |
+
#8 0x7fcfaa2aa082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 1878e6b475720c7c51969e69ab2d276fae6d1dee)
|
| 36 |
+
#9 0x41f74d in _start (build-out/do_stuff_fuzzer+0x41f74d)
|
| 37 |
+
|
| 38 |
+
DEDUP_TOKEN: DoStuff(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)--LLVMFuzzerTestOneInput--fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long)
|
| 39 |
+
0x603000003114 is located 0 bytes to the right of 20-byte region [0x603000003100,0x603000003114)
|
| 40 |
+
allocated by thread T0 here:
|
| 41 |
+
#0 0x569dfd in operator new(unsigned long) /src/llvm-project/compiler-rt/lib/asan/asan_new_delete.cpp:95:3
|
| 42 |
+
#1 0x56c9d4 in __libcpp_operator_new<unsigned long> /usr/local/bin/../include/c++/v1/new:245:10
|
| 43 |
+
#2 0x56c9d4 in __libcpp_allocate /usr/local/bin/../include/c++/v1/new:271:10
|
| 44 |
+
#3 0x56c9d4 in allocate /usr/local/bin/../include/c++/v1/__memory/allocator.h:105:38
|
| 45 |
+
#4 0x56c9d4 in allocate /usr/local/bin/../include/c++/v1/__memory/allocator_traits.h:262:20
|
| 46 |
+
#5 0x56c9d4 in __vallocate /usr/local/bin/../include/c++/v1/vector:931:37
|
| 47 |
+
#6 0x56c9d4 in vector /usr/local/bin/../include/c++/v1/vector:1236:9
|
| 48 |
+
#7 0x56c9d4 in DoStuff(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) /src/cifuzz-example/my_api.cpp:14:20
|
| 49 |
+
#8 0x56c5d6 in LLVMFuzzerTestOneInput /src/cifuzz-example/do_stuff_fuzzer.cpp:15:3
|
| 50 |
+
#9 0x43de23 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:611:15
|
| 51 |
+
#10 0x43d60a in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:514:3
|
| 52 |
+
#11 0x43ecd9 in fuzzer::Fuzzer::MutateAndTestOne() /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:757:19
|
| 53 |
+
#12 0x43f9a5 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:895:5
|
| 54 |
+
#13 0x42ed0f in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:912:6
|
| 55 |
+
#14 0x458362 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
|
| 56 |
+
#15 0x7fcfaa2aa082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 1878e6b475720c7c51969e69ab2d276fae6d1dee)
|
| 57 |
+
|
| 58 |
+
DEDUP_TOKEN: operator new(unsigned long)--__libcpp_operator_new<unsigned long>--__libcpp_allocate
|
| 59 |
+
SUMMARY: AddressSanitizer: heap-buffer-overflow /src/cifuzz-example/my_api.cpp:26:10 in DoStuff(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)
|
| 60 |
+
Shadow bytes around the buggy address:
|
| 61 |
+
0x0c067fff85d0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
| 62 |
+
0x0c067fff85e0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
| 63 |
+
0x0c067fff85f0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
| 64 |
+
0x0c067fff8600: fa fa fd fd fd fa fa fa fd fd fd fa fa fa fd fd
|
| 65 |
+
0x0c067fff8610: fd fa fa fa fd fd fd fa fa fa 00 00 00 00 fa fa
|
| 66 |
+
=>0x0c067fff8620: 00 00[04]fa fa fa fa fa fa fa fa fa fa fa fa fa
|
| 67 |
+
0x0c067fff8630: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
| 68 |
+
0x0c067fff8640: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
| 69 |
+
0x0c067fff8650: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
| 70 |
+
0x0c067fff8660: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
| 71 |
+
0x0c067fff8670: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
| 72 |
+
Shadow byte legend (one shadow byte represents 8 application bytes):
|
| 73 |
+
Addressable: 00
|
| 74 |
+
Partially addressable: 01 02 03 04 05 06 07
|
| 75 |
+
Heap left redzone: fa
|
| 76 |
+
Freed heap region: fd
|
| 77 |
+
Stack left redzone: f1
|
| 78 |
+
Stack mid redzone: f2
|
| 79 |
+
Stack right redzone: f3
|
| 80 |
+
Stack after return: f5
|
| 81 |
+
Stack use after scope: f8
|
| 82 |
+
Global redzone: f9
|
| 83 |
+
Global init order: f6
|
| 84 |
+
Poisoned by user: f7
|
| 85 |
+
Container overflow: fc
|
| 86 |
+
Array cookie: ac
|
| 87 |
+
Intra object redzone: bb
|
| 88 |
+
ASan internal: fe
|
| 89 |
+
Left alloca redzone: ca
|
| 90 |
+
Right alloca redzone: cb
|
| 91 |
+
==26==ABORTING
|
| 92 |
+
MS: 4 PersAutoDict-ManualDict-CrossOver-PersAutoDict- DE: "foo"-"ouch"-"bar"-; base unit: 1a25c32303e03f997166aee1c665b5ae9f66ec7d
|
| 93 |
+
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x66,0x6f,0x6f,0xff,0x1,0x62,0x61,0x72,0x63,0x68,0x6f,0x75,0x63,0x68,0x66,0x6f,0x66,0x6e,0x6f,0x6d,0x67,0x6d,
|
| 94 |
+
\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377foo\377\001barchouchfofnomgm
|
| 95 |
+
artifact_prefix='/tmp/tmp9p1w4p8r/'; Test unit written to /tmp/tmp9p1w4p8r/crash-1c750df432fe458b738987ba69cd20a598708775
|
| 96 |
+
Base64: //////////////////////9mb2//AWJhcmNob3VjaGZvZm5vbWdt
|
| 97 |
+
stat::number_of_executed_units: 90
|
| 98 |
+
stat::average_exec_per_sec: 0
|
| 99 |
+
stat::new_units_added: 11
|
| 100 |
+
stat::slowest_unit_time_sec: 0
|
| 101 |
+
stat::peak_rss_mb: 33
|
| 102 |
+
/github/workspace/build-out/do_stuff_fuzzer -timeout=25 -rss_limit_mb=2560 -dict=/github/workspace/build-out/do_stuff_fuzzer.dict -len_control=0 -seed=1337 -artifact_prefix=/tmp/tmp9p1w4p8r/ -max_total_time=600 -print_final_stats=1 /github/workspace/cifuzz-corpus/do_stuff_fuzzer >fuzz-1.log 2>&1
|
| 103 |
+
================== Job 1 exited with exit code 77 ============
|
| 104 |
+
Dictionary: 3 entries
|
| 105 |
+
INFO: Running with entropic power schedule (0xFF, 100).
|
| 106 |
+
INFO: Seed: 1337
|
| 107 |
+
INFO: Loaded 1 modules (86 inline 8-bit counters): 86 [0x6150e0, 0x615136),
|
| 108 |
+
INFO: Loaded 1 PC tables (86 PCs): 86 [0x5c8b08,0x5c9068),
|
| 109 |
+
INFO: 15 files found in /github/workspace/cifuzz-corpus/do_stuff_fuzzer
|
| 110 |
+
INFO: -max_len is not provided; libFuzzer will not generate inputs larger than 4096 bytes
|
| 111 |
+
INFO: seed corpus: files: 15 min: 3b max: 44b total: 239b rss: 31Mb
|
| 112 |
+
#16 INITED cov: 65 ft: 86 corp: 13/159b exec/s: 0 rss: 32Mb
|
| 113 |
+
#38 NEW cov: 65 ft: 88 corp: 14/188b lim: 4096 exec/s: 0 rss: 32Mb L: 29/35 MS: 2 InsertByte-CopyPart-
|
| 114 |
+
#43 REDUCE cov: 65 ft: 88 corp: 14/187b lim: 4096 exec/s: 0 rss: 32Mb L: 2/35 MS: 5 InsertByte-ChangeByte-ChangeBinInt-EraseBytes-EraseBytes-
|
| 115 |
+
#64 NEW cov: 66 ft: 89 corp: 15/191b lim: 4096 exec/s: 0 rss: 32Mb L: 4/35 MS: 1 ChangeByte-
|
| 116 |
+
#78 REDUCE cov: 66 ft: 89 corp: 15/190b lim: 4096 exec/s: 0 rss: 32Mb L: 15/35 MS: 4 ChangeBinInt-CopyPart-EraseBytes-EraseBytes-
|
| 117 |
+
#95 REDUCE cov: 66 ft: 89 corp: 15/188b lim: 4096 exec/s: 0 rss: 32Mb L: 16/35 MS: 2 ChangeBinInt-EraseBytes-
|
| 118 |
+
#110 REDUCE cov: 66 ft: 89 corp: 15/184b lim: 4096 exec/s: 0 rss: 32Mb L: 31/31 MS: 5 CrossOver-ChangeByte-ShuffleBytes-InsertByte-EraseBytes-
|
| 119 |
+
#146 REDUCE cov: 66 ft: 89 corp: 15/183b lim: 4096 exec/s: 0 rss: 32Mb L: 1/31 MS: 1 EraseBytes-
|
| 120 |
+
#157 NEW cov: 66 ft: 90 corp: 16/210b lim: 4096 exec/s: 0 rss: 32Mb L: 27/31 MS: 1 CrossOver-
|
| 121 |
+
#230 REDUCE cov: 66 ft: 92 corp: 17/318b lim: 4096 exec/s: 0 rss: 32Mb L: 108/108 MS: 3 CopyPart-InsertRepeatedBytes-CrossOver-
|
| 122 |
+
#277 NEW cov: 66 ft: 94 corp: 18/429b lim: 4096 exec/s: 0 rss: 32Mb L: 111/111 MS: 2 ManualDict-CMP- DE: "bar"-"\000\000\000\000"-
|
| 123 |
+
#337 NEW cov: 67 ft: 95 corp: 19/439b lim: 4096 exec/s: 0 rss: 32Mb L: 10/111 MS: 5 ChangeByte-ChangeBit-ManualDict-CopyPart-EraseBytes- DE: "bar"-
|
| 124 |
+
=================================================================
|
| 125 |
+
==30==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x603000007d94 at pc 0x00000056d1db bp 0x7ffdb9da4b50 sp 0x7ffdb9da4b48
|
| 126 |
+
READ of size 4 at 0x603000007d94 thread T0
|
| 127 |
+
SCARINESS: 17 (4-byte-read-heap-buffer-overflow)
|
| 128 |
+
#0 0x56d1da in DoStuff(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) /src/cifuzz-example/my_api.cpp:26:10
|
| 129 |
+
#1 0x56c5d6 in LLVMFuzzerTestOneInput /src/cifuzz-example/do_stuff_fuzzer.cpp:15:3
|
| 130 |
+
#2 0x43de23 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:611:15
|
| 131 |
+
#3 0x43d60a in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:514:3
|
| 132 |
+
#4 0x43ecd9 in fuzzer::Fuzzer::MutateAndTestOne() /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:757:19
|
| 133 |
+
#5 0x43f9a5 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:895:5
|
| 134 |
+
#6 0x42ed0f in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:912:6
|
| 135 |
+
#7 0x458362 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
|
| 136 |
+
#8 0x7fc2c6bd3082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 1878e6b475720c7c51969e69ab2d276fae6d1dee)
|
| 137 |
+
#9 0x41f74d in _start (build-out/do_stuff_fuzzer+0x41f74d)
|
| 138 |
+
|
| 139 |
+
DEDUP_TOKEN: DoStuff(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)--LLVMFuzzerTestOneInput--fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long)
|
| 140 |
+
0x603000007d94 is located 0 bytes to the right of 20-byte region [0x603000007d80,0x603000007d94)
|
| 141 |
+
allocated by thread T0 here:
|
| 142 |
+
#0 0x569dfd in operator new(unsigned long) /src/llvm-project/compiler-rt/lib/asan/asan_new_delete.cpp:95:3
|
| 143 |
+
#1 0x56c9d4 in __libcpp_operator_new<unsigned long> /usr/local/bin/../include/c++/v1/new:245:10
|
| 144 |
+
#2 0x56c9d4 in __libcpp_allocate /usr/local/bin/../include/c++/v1/new:271:10
|
| 145 |
+
#3 0x56c9d4 in allocate /usr/local/bin/../include/c++/v1/__memory/allocator.h:105:38
|
| 146 |
+
#4 0x56c9d4 in allocate /usr/local/bin/../include/c++/v1/__memory/allocator_traits.h:262:20
|
| 147 |
+
#5 0x56c9d4 in __vallocate /usr/local/bin/../include/c++/v1/vector:931:37
|
| 148 |
+
#6 0x56c9d4 in vector /usr/local/bin/../include/c++/v1/vector:1236:9
|
| 149 |
+
#7 0x56c9d4 in DoStuff(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) /src/cifuzz-example/my_api.cpp:14:20
|
| 150 |
+
#8 0x56c5d6 in LLVMFuzzerTestOneInput /src/cifuzz-example/do_stuff_fuzzer.cpp:15:3
|
| 151 |
+
#9 0x43de23 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:611:15
|
| 152 |
+
#10 0x43d60a in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:514:3
|
| 153 |
+
#11 0x43ecd9 in fuzzer::Fuzzer::MutateAndTestOne() /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:757:19
|
| 154 |
+
#12 0x43f9a5 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:895:5
|
| 155 |
+
#13 0x42ed0f in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:912:6
|
| 156 |
+
#14 0x458362 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
|
| 157 |
+
#15 0x7fc2c6bd3082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 1878e6b475720c7c51969e69ab2d276fae6d1dee)
|
| 158 |
+
|
| 159 |
+
DEDUP_TOKEN: operator new(unsigned long)--__libcpp_operator_new<unsigned long>--__libcpp_allocate
|
| 160 |
+
SUMMARY: AddressSanitizer: heap-buffer-overflow /src/cifuzz-example/my_api.cpp:26:10 in DoStuff(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)
|
| 161 |
+
Shadow bytes around the buggy address:
|
| 162 |
+
0x0c067fff8f60: fa fa fd fd fd fa fa fa fd fd fd fa fa fa fd fd
|
| 163 |
+
0x0c067fff8f70: fd fa fa fa fd fd fd fa fa fa fd fd fd fa fa fa
|
| 164 |
+
0x0c067fff8f80: fd fd fd fa fa fa fd fd fd fa fa fa fd fd fd fa
|
| 165 |
+
0x0c067fff8f90: fa fa fd fd fd fa fa fa fd fd fd fa fa fa fd fd
|
| 166 |
+
0x0c067fff8fa0: fd fa fa fa fd fd fd fa fa fa fd fd fd fa fa fa
|
| 167 |
+
=>0x0c067fff8fb0: 00 00[04]fa fa fa fa fa fa fa fa fa fa fa fa fa
|
| 168 |
+
0x0c067fff8fc0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
| 169 |
+
0x0c067fff8fd0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
| 170 |
+
0x0c067fff8fe0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
| 171 |
+
0x0c067fff8ff0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
| 172 |
+
0x0c067fff9000: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
| 173 |
+
Shadow byte legend (one shadow byte represents 8 application bytes):
|
| 174 |
+
Addressable: 00
|
| 175 |
+
Partially addressable: 01 02 03 04 05 06 07
|
| 176 |
+
Heap left redzone: fa
|
| 177 |
+
Freed heap region: fd
|
| 178 |
+
Stack left redzone: f1
|
| 179 |
+
Stack mid redzone: f2
|
| 180 |
+
Stack right redzone: f3
|
| 181 |
+
Stack after return: f5
|
| 182 |
+
Stack use after scope: f8
|
| 183 |
+
Global redzone: f9
|
| 184 |
+
Global init order: f6
|
| 185 |
+
Poisoned by user: f7
|
| 186 |
+
Container overflow: fc
|
| 187 |
+
Array cookie: ac
|
| 188 |
+
Intra object redzone: bb
|
| 189 |
+
ASan internal: fe
|
| 190 |
+
Left alloca redzone: ca
|
| 191 |
+
Right alloca redzone: cb
|
| 192 |
+
==30==ABORTING
|
| 193 |
+
MS: 4 ShuffleBytes-ManualDict-CrossOver-PersAutoDict- DE: "foo"-"bar"-; base unit: 8fc7da8d952ed1aa5c7415e21b3d52b42402973d
|
| 194 |
+
0x66,0x6f,0x6f,0x63,0x6f,0x75,0x6f,0x75,0x63,0x68,0x63,0x68,0x66,0x62,0x61,0x72,0x6f,0x6f,0x6d,0x67,0x66,0x6f,0x6f,0x2f,0x99,0x6f,0x6f,0x90,0x6f,0x6f,0x6d,0x0,0x0,0x67,0x2f,
|
| 195 |
+
foocououchchfbaroomgfoo/\231oo\220oom\000\000g/
|
| 196 |
+
artifact_prefix='/tmp/tmp9p1w4p8r/'; Test unit written to /tmp/tmp9p1w4p8r/crash-f8a2a1e84f58a2d676e5ad8078119a39b78df901
|
| 197 |
+
Base64: Zm9vY291b3VjaGNoZmJhcm9vbWdmb28vmW9vkG9vbQAAZy8=
|
| 198 |
+
stat::number_of_executed_units: 366
|
| 199 |
+
stat::average_exec_per_sec: 0
|
| 200 |
+
stat::new_units_added: 11
|
| 201 |
+
stat::slowest_unit_time_sec: 0
|
| 202 |
+
stat::peak_rss_mb: 33
|
local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/test_data/msan_crash_fuzzer_bug_summary.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MemorySanitizer: use-of-uninitialized-value
|
| 2 |
+
#0 0x52675f in LLVMFuzzerTestOneInput /src/cifuzz-example/do_stuff_fuzzer.cpp:13:7
|
| 3 |
+
#1 0x45a431 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:599:15
|
| 4 |
+
#2 0x45ba46 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:792:3
|
| 5 |
+
#3 0x45bed9 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:845:3
|
| 6 |
+
#4 0x44a4bc in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:906:6
|
| 7 |
+
#5 0x474432 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
|
| 8 |
+
#6 0x7eff5562683f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2083f)
|
| 9 |
+
#7 0x41eab8 in _start (out/do_stuff_fuzzer+0x41eab8)
|
| 10 |
+
|
| 11 |
+
DEDUP_TOKEN: LLVMFuzzerTestOneInput--fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long)--fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&)
|
| 12 |
+
Uninitialized value was created by a heap allocation
|
| 13 |
+
#0 0x4d57ad in malloc /src/llvm-project/compiler-rt/lib/msan/msan_interceptors.cpp:901:3
|
| 14 |
+
#1 0x437c07 in operator new(unsigned long) (out/do_stuff_fuzzer+0x437c07)
|
| 15 |
+
#2 0x45ba46 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:792:3
|
| 16 |
+
#3 0x45bed9 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:845:3
|
| 17 |
+
#4 0x44a4bc in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:906:6
|
| 18 |
+
#5 0x474432 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
|
| 19 |
+
#6 0x7eff5562683f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2083f)
|
| 20 |
+
DEDUP_TOKEN: malloc--operator new(unsigned long)--fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&)
|
| 21 |
+
|
| 22 |
+
SUMMARY:
|
local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/test_data/msan_crash_fuzzer_output.txt
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Dictionary: 3 entries
|
| 2 |
+
INFO: Running with entropic power schedule (0xFF, 100).
|
| 3 |
+
INFO: Seed: 1337
|
| 4 |
+
INFO: Loaded 1 modules (184 inline 8-bit counters): 184 [0x829300, 0x8293b8),
|
| 5 |
+
INFO: Loaded 1 PC tables (184 PCs): 184 [0x5dc910,0x5dd490),
|
| 6 |
+
INFO: 5 files found in /tmp/do_stuff_fuzzer_corpus
|
| 7 |
+
INFO: -max_len is not provided; libFuzzer will not generate inputs larger than 4096 bytes
|
| 8 |
+
==13==WARNING: MemorySanitizer: use-of-uninitialized-value
|
| 9 |
+
#0 0x52675f in LLVMFuzzerTestOneInput /src/cifuzz-example/do_stuff_fuzzer.cpp:13:7
|
| 10 |
+
#1 0x45a431 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:599:15
|
| 11 |
+
#2 0x45ba46 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:792:3
|
| 12 |
+
#3 0x45bed9 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:845:3
|
| 13 |
+
#4 0x44a4bc in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:906:6
|
| 14 |
+
#5 0x474432 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
|
| 15 |
+
#6 0x7eff5562683f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2083f)
|
| 16 |
+
#7 0x41eab8 in _start (out/do_stuff_fuzzer+0x41eab8)
|
| 17 |
+
|
| 18 |
+
DEDUP_TOKEN: LLVMFuzzerTestOneInput--fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long)--fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&)
|
| 19 |
+
Uninitialized value was created by a heap allocation
|
| 20 |
+
#0 0x4d57ad in malloc /src/llvm-project/compiler-rt/lib/msan/msan_interceptors.cpp:901:3
|
| 21 |
+
#1 0x437c07 in operator new(unsigned long) (out/do_stuff_fuzzer+0x437c07)
|
| 22 |
+
#2 0x45ba46 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:792:3
|
| 23 |
+
#3 0x45bed9 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:845:3
|
| 24 |
+
#4 0x44a4bc in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:906:6
|
| 25 |
+
#5 0x474432 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
|
| 26 |
+
#6 0x7eff5562683f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2083f)
|
| 27 |
+
DEDUP_TOKEN: malloc--operator new(unsigned long)--fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&)
|
| 28 |
+
|
| 29 |
+
SUMMARY: MemorySanitizer: use-of-uninitialized-value /src/cifuzz-example/do_stuff_fuzzer.cpp:13:7 in LLVMFuzzerTestOneInput
|
| 30 |
+
Unique heap origins: 65
|
| 31 |
+
Stack depot allocated bytes: 4424
|
| 32 |
+
Unique origin histories: 29
|
| 33 |
+
History depot allocated bytes: 696
|
| 34 |
+
Exiting
|
| 35 |
+
MS: 0 ; base unit: 0000000000000000000000000000000000000000
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
artifact_prefix='./'; Test unit written to ./crash-da39a3ee5e6b4b0d3255bfef95601890afd80709
|
| 39 |
+
Base64:
|
local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/test_data/sarif_utils_msan_stack.txt
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Dictionary: 3 entries
|
| 2 |
+
2024-05-07 18:49:02,343 - root - INFO - Fuzzer: do_stuff_fuzzer. Detected bug.
|
| 3 |
+
INFO: Running with entropic power schedule (0xFF, 100).
|
| 4 |
+
INFO: Seed: 1337
|
| 5 |
+
INFO: Loaded 1 modules (83 inline 8-bit counters): 83 [0x563ff0e03e98, 0x563ff0e03eeb),
|
| 6 |
+
INFO: Loaded 1 PC tables (83 PCs): 83 [0x563ff0e03ef0,0x563ff0e04420),
|
| 7 |
+
INFO: 0 files found in /github/workspace/cifuzz-corpus/do_stuff_fuzzer
|
| 8 |
+
INFO: -max_len is not provided; libFuzzer will not generate inputs larger than 4096 bytes
|
| 9 |
+
INFO: A corpus is not provided, starting from an empty corpus
|
| 10 |
+
#2 INITED cov: 2 ft: 2 corp: 1/1b exec/s: 0 rss: 69Mb
|
| 11 |
+
#4 NEW cov: 3 ft: 3 corp: 2/3b lim: 4096 exec/s: 0 rss: 69Mb L: 2/2 MS: 2 ChangeBit-InsertByte-
|
| 12 |
+
==23==WARNING: MemorySanitizer: use-of-uninitialized-value
|
| 13 |
+
#0 0x563ff0d278f0 in LLVMFuzzerTestOneInput /src/cifuzz-external-example/do_stuff_fuzzer.cpp:24:1
|
| 14 |
+
#1 0x563ff0c24340 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:614:13
|
| 15 |
+
#2 0x563ff0c23b65 in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:516:7
|
| 16 |
+
#3 0x563ff0c25335 in fuzzer::Fuzzer::MutateAndTestOne() /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:760:19
|
| 17 |
+
#4 0x563ff0c26125 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile>>&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:905:5
|
| 18 |
+
#5 0x563ff0c14436 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:914:6
|
| 19 |
+
#6 0x563ff0c40962 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
|
| 20 |
+
#7 0x7f4c156ed082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 87b331c034a6458c64ce09c03939e947212e18ce)
|
| 21 |
+
#8 0x563ff0c055ad in _start (build-out/do_stuff_fuzzer+0x4a5ad)
|
| 22 |
+
|
| 23 |
+
DEDUP_TOKEN: LLVMFuzzerTestOneInput--fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long)--fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*)
|
| 24 |
+
Uninitialized value was stored to memory at
|
| 25 |
+
#0 0x563ff0d278e9 in LLVMFuzzerTestOneInput /src/cifuzz-external-example/do_stuff_fuzzer.cpp
|
| 26 |
+
#1 0x563ff0c24340 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:614:13
|
| 27 |
+
#2 0x563ff0c23b65 in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:516:7
|
| 28 |
+
#3 0x563ff0c25335 in fuzzer::Fuzzer::MutateAndTestOne() /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:760:19
|
| 29 |
+
#4 0x563ff0c26125 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile>>&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:905:5
|
| 30 |
+
#5 0x563ff0c14436 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:914:6
|
| 31 |
+
#6 0x563ff0c40962 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
|
| 32 |
+
#7 0x7f4c156ed082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 87b331c034a6458c64ce09c03939e947212e18ce)
|
| 33 |
+
|
| 34 |
+
DEDUP_TOKEN: LLVMFuzzerTestOneInput--fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long)--fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*)
|
| 35 |
+
Uninitialized value was created by a heap deallocation
|
| 36 |
+
#0 0x563ff0cc7480 in free /src/llvm-project/compiler-rt/lib/msan/msan_interceptors.cpp:218:3
|
| 37 |
+
#1 0x563ff0d27800 in LLVMFuzzerTestOneInput /src/cifuzz-external-example/do_stuff_fuzzer.cpp:21:5
|
| 38 |
+
#2 0x563ff0c24340 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:614:13
|
| 39 |
+
#3 0x563ff0c23b65 in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:516:7
|
| 40 |
+
#4 0x563ff0c25335 in fuzzer::Fuzzer::MutateAndTestOne() /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:760:19
|
| 41 |
+
#5 0x563ff0c26125 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile>>&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:905:5
|
| 42 |
+
#6 0x563ff0c14436 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:914:6
|
| 43 |
+
#7 0x563ff0c40962 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
|
| 44 |
+
#8 0x7f4c156ed082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 87b331c034a6458c64ce09c03939e947212e18ce)
|
| 45 |
+
|
| 46 |
+
DEDUP_TOKEN: __interceptor_free--LLVMFuzzerTestOneInput--fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long)
|
| 47 |
+
SUMMARY: MemorySanitizer: use-of-uninitialized-value /src/cifuzz-external-example/do_stuff_fuzzer.cpp:24:1 in LLVMFuzzerTestOneInput
|
| 48 |
+
Unique heap origins: 201
|
| 49 |
+
Stack depot allocated bytes: 9764880
|
| 50 |
+
Unique origin histories: 181
|
| 51 |
+
History depot allocated bytes: 196608
|
| 52 |
+
Exiting
|
| 53 |
+
MS: 5 ShuffleBytes-CopyPart-InsertByte-CopyPart-ManualDict- DE: "bar"-; base unit: adc83b19e793491b1c6ea0fd8b46cd9f32e592fc
|
| 54 |
+
0xa,0x62,0x61,0x72,0xa,
|
| 55 |
+
\012bar\012
|
| 56 |
+
artifact_prefix='/tmp/tmp1tc5b3m2/'; Test unit written to /tmp/tmp1tc5b3m2/crash-c935b6724d7e27401ac9af3773700ca86ac38dea
|
| 57 |
+
Base64: CmJhcgo=
|
| 58 |
+
stat::number_of_executed_units: 159
|
| 59 |
+
stat::average_exec_per_sec: 0
|
| 60 |
+
stat::new_units_added: 1
|
| 61 |
+
stat::slowest_unit_time_sec: 0
|
| 62 |
+
stat::peak_rss_mb: 69
|
local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/test_data/sarif_utils_only_llvmfuzzer_stack.txt
ADDED
|
@@ -0,0 +1,302 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/github/workspace/build-out/fuzz-bus-label -timeout=25 -rss_limit_mb=2560 -len_control=0 -seed=1337 -artifact_prefix=/tmp/tmpsngf52cy/ -max_total_time=13 -print_final_stats=1 /github/workspace/cifuzz-corpus/fuzz-bus-label >fuzz-0.log 2>&1
|
| 2 |
+
================== Job 0 exited with exit code 0 ============
|
| 3 |
+
INFO: Running with entropic power schedule (0xFF, 100).
|
| 4 |
+
INFO: Seed: 1337
|
| 5 |
+
INFO: Loaded 2 modules (82577 inline 8-bit counters): 82573 [0x7fc55e6bedf0, 0x7fc55e6d307d), 4 [0x5e9c28, 0x5e9c2c),
|
| 6 |
+
2023-05-04 01:02:55,065 - root - INFO - Not reporting crash in fuzz-bus-label because process timed out.
|
| 7 |
+
2023-05-04 01:02:55,069 - root - INFO - Deleting corpus and seed corpus of fuzz-bus-label to save disk.
|
| 8 |
+
INFO: Loaded 2 PC tables (82577 PCs): 82573 [0x7fc55e6d3080,0x7fc55e815950), 4 [0x5a6c78,0x5a6cb8),
|
| 9 |
+
INFO: 256 files found in /github/workspace/cifuzz-corpus/fuzz-bus-label
|
| 10 |
+
INFO: -max_len is not provided; libFuzzer will not generate inputs larger than 1048576 bytes
|
| 11 |
+
INFO: seed corpus: files: 256 min: 1b max: 5242880b total: 30968483b rss: 48Mb
|
| 12 |
+
#257 INITED cov: 41 ft: 230 corp: 111/4360b exec/s: 0 rss: 73Mb
|
| 13 |
+
#131072 pulse cov: 41 ft: 230 corp: 111/4360b lim: 1048576 exec/s: 43690 rss: 76Mb
|
| 14 |
+
#262144 pulse cov: 41 ft: 230 corp: 111/4360b lim: 1048576 exec/s: 43690 rss: 76Mb
|
| 15 |
+
#524288 pulse cov: 41 ft: 230 corp: 111/4360b lim: 1048576 exec/s: 43690 rss: 77Mb
|
| 16 |
+
#609082 DONE cov: 41 ft: 230 corp: 111/4360b lim: 1048576 exec/s: 43505 rss: 77Mb
|
| 17 |
+
Done 609082 runs in 14 second(s)
|
| 18 |
+
stat::number_of_executed_units: 609082
|
| 19 |
+
stat::average_exec_per_sec: 43505
|
| 20 |
+
stat::new_units_added: 0
|
| 21 |
+
stat::slowest_unit_time_sec: 0
|
| 22 |
+
stat::peak_rss_mb: 77
|
| 23 |
+
/github/workspace/build-out/fuzz-bus-label -timeout=25 -rss_limit_mb=2560 -len_control=0 -seed=1337 -artifact_prefix=/tmp/tmpsngf52cy/ -max_total_time=13 -print_final_stats=1 /github/workspace/cifuzz-corpus/fuzz-bus-label >fuzz-1.log 2>&1
|
| 24 |
+
2023-05-04 01:02:55,082 - root - INFO - Deleting fuzz target: fuzz-bus-label.
|
| 25 |
+
2023-05-04 01:02:55,083 - root - INFO - Done deleting.
|
| 26 |
+
2023-05-04 01:02:55,084 - root - INFO - Fuzzer fuzz-bus-label finished running without reportable crashes.
|
| 27 |
+
2023-05-04 01:02:55,084 - root - INFO - Running fuzzer: fuzz-dhcp-server.
|
| 28 |
+
2023-05-04 01:02:55,085 - root - INFO - Downloading corpus from OSS-Fuzz: https://storage.googleapis.com/systemd-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/systemd_fuzz-dhcp-server/public.zip
|
| 29 |
+
2023-05-04 01:02:55,088 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): storage.googleapis.com:443
|
| 30 |
+
2023-05-04 01:02:55,145 - urllib3.connectionpool - DEBUG - https://storage.googleapis.com:443 "GET /systemd-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/systemd_fuzz-dhcp-server/public.zip HTTP/1.1" 200 806749
|
| 31 |
+
2023-05-04 01:02:55,350 - root - INFO - Starting fuzzing
|
| 32 |
+
Fuzzing logs:
|
| 33 |
+
/github/workspace/build-out/fuzz-dhcp-server -timeout=25 -rss_limit_mb=2560 -len_control=0 -seed=1337 -artifact_prefix=/tmp/tmpyxgwwsvr/ -max_total_time=13 -print_final_stats=1 /github/workspace/cifuzz-corpus/fuzz-dhcp-server >fuzz-0.log 2>&1
|
| 34 |
+
================== Job 0 exited with exit code 0 ============
|
| 35 |
+
INFO: Running with entropic power schedule (0xFF, 100).
|
| 36 |
+
INFO: Seed: 1337
|
| 37 |
+
INFO: Loaded 2 modules (83640 inline 8-bit counters): 82573 [0x7fe86ff70df0, 0x7fe86ff8507d), 1067 [0x60c638, 0x60ca63),
|
| 38 |
+
INFO: Loaded 2 PC tables (83640 PCs): 82573 [0x7fe86ff85080,0x7fe8700c7950), 1067 [0x60ca68,0x610d18),
|
| 39 |
+
INFO: 1153 files found in /github/workspace/cifuzz-corpus/fuzz-dhcp-server
|
| 40 |
+
INFO: -max_len is not provided; libFuzzer will not generate inputs larger than 1048576 bytes
|
| 41 |
+
INFO: seed corpus: files: 1153 min: 1b max: 5242879b total: 17056071b rss: 50Mb
|
| 42 |
+
#1155 INITED cov: 577 ft: 1116 corp: 203/54Kb exec/s: 0 rss: 86Mb
|
| 43 |
+
#1167 NEW cov: 577 ft: 1117 corp: 204/54Kb lim: 1048576 exec/s: 0 rss: 86Mb L: 243/1071 MS: 2 ChangeASCIIInt-CrossOver-
|
| 44 |
+
#1509 NEW cov: 577 ft: 1118 corp: 205/54Kb lim: 1048576 exec/s: 0 rss: 86Mb L: 243/1071 MS: 2 ChangeBit-CopyPart-
|
| 45 |
+
#63018 NEW cov: 577 ft: 1119 corp: 206/55Kb lim: 1048576 exec/s: 21006 rss: 86Mb L: 245/1071 MS: 4 InsertByte-ChangeByte-CMP-InsertByte- DE: "2\000\000\000\000\000\000\000"-
|
| 46 |
+
#65536 pulse cov: 577 ft: 1119 corp: 206/55Kb lim: 1048576 exec/s: 21845 rss: 86Mb
|
| 47 |
+
Loaded 1024/1155 files from /github/workspace/cifuzz-corpus/fuzz-dhcp-server
|
| 48 |
+
#99784 NEW cov: 577 ft: 1120 corp: 207/55Kb lim: 1048576 exec/s: 19956 rss: 105Mb L: 243/1071 MS: 2 ChangeASCIIInt-ChangeBinInt-
|
| 49 |
+
#131072 pulse cov: 577 ft: 1120 corp: 207/55Kb lim: 1048576 exec/s: 21845 rss: 105Mb
|
| 50 |
+
#262144 pulse cov: 577 ft: 1120 corp: 207/55Kb lim: 1048576 exec/s: 20164 rss: 105Mb
|
| 51 |
+
#275639 DONE cov: 577 ft: 1120 corp: 207/55Kb lim: 1048576 exec/s: 19688 rss: 105Mb
|
| 52 |
+
###### Recommended dictionary. ######
|
| 53 |
+
"2\000\000\000\000\000\000\000" # Uses: 17879
|
| 54 |
+
###### End of recommended dictionary. ######
|
| 55 |
+
Done 275639 runs in 14 second(s)
|
| 56 |
+
stat::number_of_executed_units: 275639
|
| 57 |
+
stat::average_exec_per_sec: 19688
|
| 58 |
+
stat::new_units_added: 4
|
| 59 |
+
stat::slowest_unit_time_sec: 0
|
| 60 |
+
stat::peak_rss_mb: 105
|
| 61 |
+
/github/workspace/build-out/fuzz-dhcp-server -timeout=25 -rss_limit_mb=2560 -len_control=0 -seed=1337 -artifact_prefix=/tmp/tmpyxgwwsvr/ -max_total_time=13 -print_final_stats=1 /github/workspace/cifuzz-corpus/fuzz-dhcp-server >fuzz-1.log 2>&1
|
| 62 |
+
2023-05-04 01:03:18,374 - root - INFO - Not reporting crash in fuzz-dhcp-server because process timed out.
|
| 63 |
+
2023-05-04 01:03:18,377 - root - INFO - Deleting corpus and seed corpus of fuzz-dhcp-server to save disk.
|
| 64 |
+
2023-05-04 01:03:18,399 - root - INFO - Deleting fuzz target: fuzz-dhcp-server.
|
| 65 |
+
2023-05-04 01:03:18,400 - root - INFO - Done deleting.
|
| 66 |
+
2023-05-04 01:03:18,400 - root - INFO - Fuzzer fuzz-dhcp-server finished running without reportable crashes.
|
| 67 |
+
2023-05-04 01:03:18,401 - root - INFO - Running fuzzer: fuzz-bcd.
|
| 68 |
+
2023-05-04 01:03:18,401 - root - INFO - Downloading corpus from OSS-Fuzz: https://storage.googleapis.com/systemd-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/systemd_fuzz-bcd/public.zip
|
| 69 |
+
2023-05-04 01:03:18,404 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): storage.googleapis.com:443
|
| 70 |
+
2023-05-04 01:03:18,582 - urllib3.connectionpool - DEBUG - https://storage.googleapis.com:443 "GET /systemd-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/systemd_fuzz-bcd/public.zip HTTP/1.1" 200 2293254
|
| 71 |
+
2023-05-04 01:03:18,804 - root - INFO - Starting fuzzing
|
| 72 |
+
Fuzzing logs:
|
| 73 |
+
/github/workspace/build-out/fuzz-bcd -timeout=25 -rss_limit_mb=2560 -len_control=0 -seed=1337 -artifact_prefix=/tmp/tmpgvqlyr8q/ -max_total_time=13 -print_final_stats=1 /github/workspace/cifuzz-corpus/fuzz-bcd >fuzz-0.log 2>&1
|
| 74 |
+
================== Job 0 exited with exit code 0 ============
|
| 75 |
+
INFO: Running with entropic power schedule (0xFF, 100).
|
| 76 |
+
INFO: Seed: 1337
|
| 77 |
+
INFO: Loaded 2 modules (83175 inline 8-bit counters): 82573 [0x7f1b5387edf0, 0x7f1b5389307d), 602 [0x5f8718, 0x5f8972),
|
| 78 |
+
INFO: Loaded 2 PC tables (83175 PCs): 82573 [0x7f1b53893080,0x7f1b539d5950), 602 [0x5f8978,0x5faf18),
|
| 79 |
+
INFO: 1260 files found in /github/workspace/cifuzz-corpus/fuzz-bcd
|
| 80 |
+
INFO: -max_len is not provided; libFuzzer will not generate inputs larger than 946175 bytes
|
| 81 |
+
INFO: seed corpus: files: 1260 min: 1b max: 946175b total: 10373697b rss: 48Mb
|
| 82 |
+
#1261 INITED cov: 137 ft: 653 corp: 282/1416Kb exec/s: 0 rss: 91Mb
|
| 83 |
+
#65536 pulse cov: 137 ft: 653 corp: 282/1416Kb lim: 946175 exec/s: 32768 rss: 98Mb
|
| 84 |
+
#131072 pulse cov: 137 ft: 653 corp: 282/1416Kb lim: 946175 exec/s: 32768 rss: 98Mb
|
| 85 |
+
#262144 pulse cov: 137 ft: 653 corp: 282/1416Kb lim: 946175 exec/s: 37449 rss: 98Mb
|
| 86 |
+
#475081 DONE cov: 137 ft: 653 corp: 282/1416Kb lim: 946175 exec/s: 33934 rss: 98Mb
|
| 87 |
+
Done 475081 runs in 14 second(s)
|
| 88 |
+
stat::number_of_executed_units: 475081
|
| 89 |
+
stat::average_exec_per_sec: 33934
|
| 90 |
+
stat::new_units_added: 0
|
| 91 |
+
stat::slowest_unit_time_sec: 0
|
| 92 |
+
stat::peak_rss_mb: 98
|
| 93 |
+
/github/workspace/build-out/fuzz-bcd -timeout=25 -rss_limit_mb=2560 -len_control=0 -seed=1337 -artifact_prefix=/tmp/tmpgvqlyr8q/ -max_total_time=13 -print_final_stats=1 /github/workspace/cifuzz-corpus/fuzz-bcd >fuzz-1.log 2>&1
|
| 94 |
+
2023-05-04 01:03:41,821 - root - INFO - Not reporting crash in fuzz-bcd because process timed out.
|
| 95 |
+
2023-05-04 01:03:41,822 - root - INFO - Deleting corpus and seed corpus of fuzz-bcd to save disk.
|
| 96 |
+
2023-05-04 01:03:41,848 - root - INFO - Deleting fuzz target: fuzz-bcd.
|
| 97 |
+
2023-05-04 01:03:41,848 - root - INFO - Done deleting.
|
| 98 |
+
2023-05-04 01:03:41,848 - root - INFO - Fuzzer fuzz-bcd finished running without reportable crashes.
|
| 99 |
+
2023-05-04 01:03:41,848 - root - INFO - Running fuzzer: fuzz-varlink.
|
| 100 |
+
2023-05-04 01:03:41,849 - root - INFO - Downloading corpus from OSS-Fuzz: https://storage.googleapis.com/systemd-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/systemd_fuzz-varlink/public.zip
|
| 101 |
+
2023-05-04 01:03:41,852 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): storage.googleapis.com:443
|
| 102 |
+
2023-05-04 01:03:41,906 - urllib3.connectionpool - DEBUG - https://storage.googleapis.com:443 "GET /systemd-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/systemd_fuzz-varlink/public.zip HTTP/1.1" 200 2586434
|
| 103 |
+
2023-05-04 01:03:42,671 - root - INFO - Starting fuzzing
|
| 104 |
+
2023-05-04 01:04:05,709 - root - INFO - Not reporting crash in fuzz-varlink because process timed out.
|
| 105 |
+
Fuzzing logs:
|
| 106 |
+
/github/workspace/build-out/fuzz-varlink -timeout=25 -rss_limit_mb=2560 -len_control=0 -seed=1337 -artifact_prefix=/tmp/tmpbtf4f932/ -max_total_time=13 -print_final_stats=1 /github/workspace/cifuzz-corpus/fuzz-varlink >fuzz-0.log 2>&1
|
| 107 |
+
2023-05-04 01:04:05,709 - root - INFO - Deleting corpus and seed corpus of fuzz-varlink to save disk.
|
| 108 |
+
2023-05-04 01:04:05,806 - root - INFO - Deleting fuzz target: fuzz-varlink.
|
| 109 |
+
2023-05-04 01:04:05,806 - root - INFO - Done deleting.
|
| 110 |
+
2023-05-04 01:04:05,806 - root - INFO - Fuzzer fuzz-varlink finished running without reportable crashes.
|
| 111 |
+
2023-05-04 01:04:05,806 - root - INFO - Running fuzzer: fuzz-unit-file.
|
| 112 |
+
2023-05-04 01:04:05,807 - root - INFO - Downloading corpus from OSS-Fuzz: https://storage.googleapis.com/systemd-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/systemd_fuzz-unit-file/public.zip
|
| 113 |
+
2023-05-04 01:04:05,809 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): storage.googleapis.com:443
|
| 114 |
+
2023-05-04 01:04:05,897 - urllib3.connectionpool - DEBUG - https://storage.googleapis.com:443 "GET /systemd-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/systemd_fuzz-unit-file/public.zip HTTP/1.1" 200 4999974
|
| 115 |
+
2023-05-04 01:04:07,869 - root - INFO - Starting fuzzing
|
| 116 |
+
2023-05-04 01:04:09,516 - root - INFO - Fuzzer: fuzz-unit-file. Detected bug.
|
| 117 |
+
Fuzzing logs:
|
| 118 |
+
/github/workspace/build-out/fuzz-unit-file -timeout=25 -rss_limit_mb=2560 -len_control=0 -seed=1337 -artifact_prefix=/tmp/tmpjhswtxiw/ -max_total_time=13 -print_final_stats=1 /github/workspace/cifuzz-corpus/fuzz-unit-file >fuzz-0.log 2>&1
|
| 119 |
+
2023-05-04 01:04:09,517 - root - INFO - Trying to reproduce crash using: /tmp/tmpjhswtxiw/crash-7be9e0f3a71d95f8d5e67c5a9d84273d6f4e3c03.
|
| 120 |
+
================== Job 0 exited with exit code 77 ============
|
| 121 |
+
INFO: Running with entropic power schedule (0xFF, 100).
|
| 122 |
+
INFO: Seed: 1337
|
| 123 |
+
INFO: Loaded 2 modules (82576 inline 8-bit counters): 82573 [0x7f3b0de4cdf0, 0x7f3b0de6107d), 3 [0x5e9b28, 0x5e9b2b),
|
| 124 |
+
INFO: Loaded 2 PC tables (82576 PCs): 82573 [0x7f3b0de61080,0x7f3b0dfa3950), 3 [0x5a6af8,0x5a6b28),
|
| 125 |
+
INFO: 20907 files found in /github/workspace/cifuzz-corpus/fuzz-unit-file
|
| 126 |
+
INFO: -max_len is not provided; libFuzzer will not generate inputs larger than 604973 bytes
|
| 127 |
+
INFO: seed corpus: files: 20907 min: 1b max: 604973b total: 16005340b rss: 61Mb
|
| 128 |
+
=================================================================
|
| 129 |
+
==74==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x602000005078 at pc 0x0000004ddffa bp 0x7fffeea64fe0 sp 0x7fffeea64fd8
|
| 130 |
+
READ of size 4 at 0x602000005078 thread T0
|
| 131 |
+
SCARINESS: 27 (4-byte-read-heap-buffer-overflow-far-from-bounds)
|
| 132 |
+
#0 0x4ddff9 in LLVMFuzzerTestOneInput /work/build/../../src/systemd/src/core/fuzz-unit-file.c:30:16
|
| 133 |
+
#1 0x4fc653 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:611:15
|
| 134 |
+
#2 0x4fbe3a in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:514:3
|
| 135 |
+
#3 0x4fdca4 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:826:7
|
| 136 |
+
#4 0x4fded9 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:857:3
|
| 137 |
+
#5 0x4ed53f in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:912:6
|
| 138 |
+
#6 0x516b92 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
|
| 139 |
+
#7 0x7f3b0ce20082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 1878e6b475720c7c51969e69ab2d276fae6d1dee)
|
| 140 |
+
#8 0x41f6ed in _start (build-out/fuzz-unit-file+0x41f6ed)
|
| 141 |
+
|
| 142 |
+
DEDUP_TOKEN: LLVMFuzzerTestOneInput--fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long)--fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*)
|
| 143 |
+
0x602000005078 is located 38 bytes to the right of 2-byte region [0x602000005050,0x602000005052)
|
| 144 |
+
freed by thread T0 here:
|
| 145 |
+
#0 0x4a0882 in __interceptor_free /src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:52:3
|
| 146 |
+
#1 0x4ddfb7 in LLVMFuzzerTestOneInput /work/build/../../src/systemd/src/core/fuzz-unit-file.c:29:9
|
| 147 |
+
#2 0x4fc653 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:611:15
|
| 148 |
+
#3 0x4fbe3a in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:514:3
|
| 149 |
+
#4 0x4fdca4 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:826:7
|
| 150 |
+
#5 0x4fded9 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:857:3
|
| 151 |
+
#6 0x4ed53f in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:912:6
|
| 152 |
+
#7 0x516b92 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
|
| 153 |
+
#8 0x7f3b0ce20082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 1878e6b475720c7c51969e69ab2d276fae6d1dee)
|
| 154 |
+
|
| 155 |
+
DEDUP_TOKEN: __interceptor_free--LLVMFuzzerTestOneInput--fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long)
|
| 156 |
+
previously allocated by thread T0 here:
|
| 157 |
+
#0 0x4a0b26 in malloc /src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:69:3
|
| 158 |
+
#1 0x4ddfac in LLVMFuzzerTestOneInput /work/build/../../src/systemd/src/core/fuzz-unit-file.c:28:25
|
| 159 |
+
#2 0x4fc653 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:611:15
|
| 160 |
+
#3 0x4fbe3a in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:514:3
|
| 161 |
+
#4 0x4fdca4 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:826:7
|
| 162 |
+
#5 0x4fded9 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:857:3
|
| 163 |
+
#6 0x4ed53f in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:912:6
|
| 164 |
+
#7 0x516b92 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
|
| 165 |
+
#8 0x7f3b0ce20082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 1878e6b475720c7c51969e69ab2d276fae6d1dee)
|
| 166 |
+
|
| 167 |
+
DEDUP_TOKEN: malloc--LLVMFuzzerTestOneInput--fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long)
|
| 168 |
+
SUMMARY: AddressSanitizer: heap-buffer-overflow /work/build/../../src/systemd/src/core/fuzz-unit-file.c:30:16 in LLVMFuzzerTestOneInput
|
| 169 |
+
Shadow bytes around the buggy address:
|
| 170 |
+
0x0c047fff89b0: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
|
| 171 |
+
0x0c047fff89c0: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
|
| 172 |
+
0x0c047fff89d0: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
|
| 173 |
+
0x0c047fff89e0: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
|
| 174 |
+
0x0c047fff89f0: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
|
| 175 |
+
=>0x0c047fff8a00: fa fa 00 02 fa fa 00 02 fa fa fd fa fa fa fa[fa]
|
| 176 |
+
0x0c047fff8a10: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
| 177 |
+
0x0c047fff8a20: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
| 178 |
+
0x0c047fff8a30: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
| 179 |
+
0x0c047fff8a40: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
| 180 |
+
0x0c047fff8a50: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
| 181 |
+
Shadow byte legend (one shadow byte represents 8 application bytes):
|
| 182 |
+
Addressable: 00
|
| 183 |
+
Partially addressable: 01 02 03 04 05 06 07
|
| 184 |
+
Heap left redzone: fa
|
| 185 |
+
Freed heap region: fd
|
| 186 |
+
Stack left redzone: f1
|
| 187 |
+
Stack mid redzone: f2
|
| 188 |
+
Stack right redzone: f3
|
| 189 |
+
Stack after return: f5
|
| 190 |
+
Stack use after scope: f8
|
| 191 |
+
Global redzone: f9
|
| 192 |
+
Global init order: f6
|
| 193 |
+
Poisoned by user: f7
|
| 194 |
+
Container overflow: fc
|
| 195 |
+
Array cookie: ac
|
| 196 |
+
Intra object redzone: bb
|
| 197 |
+
ASan internal: fe
|
| 198 |
+
Left alloca redzone: ca
|
| 199 |
+
Right alloca redzone: cb
|
| 200 |
+
==74==ABORTING
|
| 201 |
+
MS: 0 ; base unit: 0000000000000000000000000000000000000000
|
| 202 |
+
0x61,0x75,0x74,0x6f,0x6d,0x6f,0x75,0x6e,0x74,0x48,
|
| 203 |
+
automountH
|
| 204 |
+
artifact_prefix='/tmp/tmpjhswtxiw/'; Test unit written to /tmp/tmpjhswtxiw/crash-7be9e0f3a71d95f8d5e67c5a9d84273d6f4e3c03
|
| 205 |
+
Base64: YXV0b21vdW50SA==
|
| 206 |
+
stat::number_of_executed_units: 314
|
| 207 |
+
stat::average_exec_per_sec: 0
|
| 208 |
+
stat::new_units_added: 0
|
| 209 |
+
stat::slowest_unit_time_sec: 0
|
| 210 |
+
stat::peak_rss_mb: 67
|
| 211 |
+
/github/workspace/build-out/fuzz-unit-file -timeout=25 -rss_limit_mb=2560 -len_control=0 -seed=1337 -artifact_prefix=/tmp/tmpjhswtxiw/ -max_total_time=13 -print_final_stats=1 /github/workspace/cifuzz-corpus/fuzz-unit-file >fuzz-1.log 2>&1
|
| 212 |
+
================== Job 1 exited with exit code 77 ============
|
| 213 |
+
INFO: Running with entropic power schedule (0xFF, 100).
|
| 214 |
+
INFO: Seed: 1337
|
| 215 |
+
INFO: Loaded 2 modules (82576 inline 8-bit counters): 82573 [0x7ff1ba038df0, 0x7ff1ba04d07d), 3 [0x5e9b28, 0x5e9b2b),
|
| 216 |
+
INFO: Loaded 2 PC tables (82576 PCs): 82573 [0x7ff1ba04d080,0x7ff1ba18f950), 3 [0x5a6af8,0x5a6b28),
|
| 217 |
+
INFO: 20907 files found in /github/workspace/cifuzz-corpus/fuzz-unit-file
|
| 218 |
+
INFO: -max_len is not provided; libFuzzer will not generate inputs larger than 604973 bytes
|
| 219 |
+
INFO: seed corpus: files: 20907 min: 1b max: 604973b total: 16005340b rss: 61Mb
|
| 220 |
+
=================================================================
|
| 221 |
+
==78==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x602000005078 at pc 0x0000004ddffa bp 0x7ffc2e6825c0 sp 0x7ffc2e6825b8
|
| 222 |
+
READ of size 4 at 0x602000005078 thread T0
|
| 223 |
+
SCARINESS: 27 (4-byte-read-heap-buffer-overflow-far-from-bounds)
|
| 224 |
+
#0 0x4ddff9 in LLVMFuzzerTestOneInput /work/build/../../src/systemd/src/core/fuzz-unit-file.c:30:16
|
| 225 |
+
#1 0x4fc653 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:611:15
|
| 226 |
+
#2 0x4fbe3a in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:514:3
|
| 227 |
+
#3 0x4fdca4 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:826:7
|
| 228 |
+
#4 0x4fded9 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:857:3
|
| 229 |
+
#5 0x4ed53f in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:912:6
|
| 230 |
+
#6 0x516b92 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
|
| 231 |
+
#7 0x7ff1b900c082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 1878e6b475720c7c51969e69ab2d276fae6d1dee)
|
| 232 |
+
#8 0x41f6ed in _start (build-out/fuzz-unit-file+0x41f6ed)
|
| 233 |
+
|
| 234 |
+
DEDUP_TOKEN: LLVMFuzzerTestOneInput--fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long)--fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*)
|
| 235 |
+
0x602000005078 is located 38 bytes to the right of 2-byte region [0x602000005050,0x602000005052)
|
| 236 |
+
freed by thread T0 here:
|
| 237 |
+
#0 0x4a0882 in __interceptor_free /src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:52:3
|
| 238 |
+
#1 0x4ddfb7 in LLVMFuzzerTestOneInput /work/build/../../src/systemd/src/core/fuzz-unit-file.c:29:9
|
| 239 |
+
#2 0x4fc653 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:611:15
|
| 240 |
+
#3 0x4fbe3a in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:514:3
|
| 241 |
+
#4 0x4fdca4 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:826:7
|
| 242 |
+
#5 0x4fded9 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:857:3
|
| 243 |
+
#6 0x4ed53f in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:912:6
|
| 244 |
+
#7 0x516b92 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
|
| 245 |
+
#8 0x7ff1b900c082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 1878e6b475720c7c51969e69ab2d276fae6d1dee)
|
| 246 |
+
|
| 247 |
+
DEDUP_TOKEN: __interceptor_free--LLVMFuzzerTestOneInput--fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long)
|
| 248 |
+
previously allocated by thread T0 here:
|
| 249 |
+
#0 0x4a0b26 in malloc /src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:69:3
|
| 250 |
+
#1 0x4ddfac in LLVMFuzzerTestOneInput /work/build/../../src/systemd/src/core/fuzz-unit-file.c:28:25
|
| 251 |
+
#2 0x4fc653 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:611:15
|
| 252 |
+
#3 0x4fbe3a in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:514:3
|
| 253 |
+
#4 0x4fdca4 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:826:7
|
| 254 |
+
#5 0x4fded9 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:857:3
|
| 255 |
+
#6 0x4ed53f in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:912:6
|
| 256 |
+
#7 0x516b92 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
|
| 257 |
+
#8 0x7ff1b900c082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 1878e6b475720c7c51969e69ab2d276fae6d1dee)
|
| 258 |
+
|
| 259 |
+
DEDUP_TOKEN: malloc--samLLVM2FuzzerTestOneInput --fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long)
|
| 260 |
+
SUMMARY: AddressSanitizer: heap-buffer-overflow /work/build/../../src/systemd/src/core/fuzz-unit-file.c:30:16 in samsamLLVM2FuzzerTestOneInput
|
| 261 |
+
Shadow bytes around the buggy address:
|
| 262 |
+
0x0c047fff89b0: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
|
| 263 |
+
0x0c047fff89c0: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
|
| 264 |
+
0x0c047fff89d0: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
|
| 265 |
+
0x0c047fff89e0: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
|
| 266 |
+
0x0c047fff89f0: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
|
| 267 |
+
=>0x0c047fff8a00: fa fa 00 02 fa fa 00 02 fa fa fd fa fa fa fa[fa]
|
| 268 |
+
0x0c047fff8a10: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
| 269 |
+
0x0c047fff8a20: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
| 270 |
+
0x0c047fff8a30: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
| 271 |
+
0x0c047fff8a40: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
| 272 |
+
0x0c047fff8a50: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
| 273 |
+
Shadow byte legend (one shadow byte represents 8 application bytes):
|
| 274 |
+
Addressable: 00
|
| 275 |
+
Partially addressable: 01 02 03 04 05 06 07
|
| 276 |
+
Heap left redzone: fa
|
| 277 |
+
Freed heap region: fd
|
| 278 |
+
Stack left redzone: f1
|
| 279 |
+
Stack mid redzone: f2
|
| 280 |
+
Stack right redzone: f3
|
| 281 |
+
Stack after return: f5
|
| 282 |
+
Stack use after scope: f8
|
| 283 |
+
Global redzone: f9
|
| 284 |
+
Global init order: f6
|
| 285 |
+
Poisoned by user: f7
|
| 286 |
+
Container overflow: fc
|
| 287 |
+
Array cookie: ac
|
| 288 |
+
Intra object redzone: bb
|
| 289 |
+
ASan internal: fe
|
| 290 |
+
Left alloca redzone: ca
|
| 291 |
+
Right alloca redzone: cb
|
| 292 |
+
==78==ABORTING
|
| 293 |
+
MS: 0 ; base unit: 0000000000000000000000000000000000000000
|
| 294 |
+
0x61,0x75,0x74,0x6f,0x6d,0x6f,0x75,0x6e,0x74,0x48,
|
| 295 |
+
automountH
|
| 296 |
+
artifact_prefix='/tmp/tmpjhswtxiw/'; Test unit written to /tmp/tmpjhswtxiw/crash-7be9e0f3a71d95f8d5e67c5a9d84273d6f4e3c03
|
| 297 |
+
Base64: YXV0b21vdW50SA==
|
| 298 |
+
stat::number_of_executed_units: 314
|
| 299 |
+
stat::average_exec_per_sec: 0
|
| 300 |
+
stat::new_units_added: 0
|
| 301 |
+
stat::slowest_unit_time_sec: 0
|
| 302 |
+
stat::peak_rss_mb: 68
|
local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/cifuzz/test_data/sarif_utils_systemd_stack.txt
ADDED
|
@@ -0,0 +1,302 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/github/workspace/build-out/fuzz-bus-label -timeout=25 -rss_limit_mb=2560 -len_control=0 -seed=1337 -artifact_prefix=/tmp/tmpsngf52cy/ -max_total_time=13 -print_final_stats=1 /github/workspace/cifuzz-corpus/fuzz-bus-label >fuzz-0.log 2>&1
|
| 2 |
+
================== Job 0 exited with exit code 0 ============
|
| 3 |
+
INFO: Running with entropic power schedule (0xFF, 100).
|
| 4 |
+
INFO: Seed: 1337
|
| 5 |
+
INFO: Loaded 2 modules (82577 inline 8-bit counters): 82573 [0x7fc55e6bedf0, 0x7fc55e6d307d), 4 [0x5e9c28, 0x5e9c2c),
|
| 6 |
+
2023-05-04 01:02:55,065 - root - INFO - Not reporting crash in fuzz-bus-label because process timed out.
|
| 7 |
+
2023-05-04 01:02:55,069 - root - INFO - Deleting corpus and seed corpus of fuzz-bus-label to save disk.
|
| 8 |
+
INFO: Loaded 2 PC tables (82577 PCs): 82573 [0x7fc55e6d3080,0x7fc55e815950), 4 [0x5a6c78,0x5a6cb8),
|
| 9 |
+
INFO: 256 files found in /github/workspace/cifuzz-corpus/fuzz-bus-label
|
| 10 |
+
INFO: -max_len is not provided; libFuzzer will not generate inputs larger than 1048576 bytes
|
| 11 |
+
INFO: seed corpus: files: 256 min: 1b max: 5242880b total: 30968483b rss: 48Mb
|
| 12 |
+
#257 INITED cov: 41 ft: 230 corp: 111/4360b exec/s: 0 rss: 73Mb
|
| 13 |
+
#131072 pulse cov: 41 ft: 230 corp: 111/4360b lim: 1048576 exec/s: 43690 rss: 76Mb
|
| 14 |
+
#262144 pulse cov: 41 ft: 230 corp: 111/4360b lim: 1048576 exec/s: 43690 rss: 76Mb
|
| 15 |
+
#524288 pulse cov: 41 ft: 230 corp: 111/4360b lim: 1048576 exec/s: 43690 rss: 77Mb
|
| 16 |
+
#609082 DONE cov: 41 ft: 230 corp: 111/4360b lim: 1048576 exec/s: 43505 rss: 77Mb
|
| 17 |
+
Done 609082 runs in 14 second(s)
|
| 18 |
+
stat::number_of_executed_units: 609082
|
| 19 |
+
stat::average_exec_per_sec: 43505
|
| 20 |
+
stat::new_units_added: 0
|
| 21 |
+
stat::slowest_unit_time_sec: 0
|
| 22 |
+
stat::peak_rss_mb: 77
|
| 23 |
+
/github/workspace/build-out/fuzz-bus-label -timeout=25 -rss_limit_mb=2560 -len_control=0 -seed=1337 -artifact_prefix=/tmp/tmpsngf52cy/ -max_total_time=13 -print_final_stats=1 /github/workspace/cifuzz-corpus/fuzz-bus-label >fuzz-1.log 2>&1
|
| 24 |
+
2023-05-04 01:02:55,082 - root - INFO - Deleting fuzz target: fuzz-bus-label.
|
| 25 |
+
2023-05-04 01:02:55,083 - root - INFO - Done deleting.
|
| 26 |
+
2023-05-04 01:02:55,084 - root - INFO - Fuzzer fuzz-bus-label finished running without reportable crashes.
|
| 27 |
+
2023-05-04 01:02:55,084 - root - INFO - Running fuzzer: fuzz-dhcp-server.
|
| 28 |
+
2023-05-04 01:02:55,085 - root - INFO - Downloading corpus from OSS-Fuzz: https://storage.googleapis.com/systemd-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/systemd_fuzz-dhcp-server/public.zip
|
| 29 |
+
2023-05-04 01:02:55,088 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): storage.googleapis.com:443
|
| 30 |
+
2023-05-04 01:02:55,145 - urllib3.connectionpool - DEBUG - https://storage.googleapis.com:443 "GET /systemd-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/systemd_fuzz-dhcp-server/public.zip HTTP/1.1" 200 806749
|
| 31 |
+
2023-05-04 01:02:55,350 - root - INFO - Starting fuzzing
|
| 32 |
+
Fuzzing logs:
|
| 33 |
+
/github/workspace/build-out/fuzz-dhcp-server -timeout=25 -rss_limit_mb=2560 -len_control=0 -seed=1337 -artifact_prefix=/tmp/tmpyxgwwsvr/ -max_total_time=13 -print_final_stats=1 /github/workspace/cifuzz-corpus/fuzz-dhcp-server >fuzz-0.log 2>&1
|
| 34 |
+
================== Job 0 exited with exit code 0 ============
|
| 35 |
+
INFO: Running with entropic power schedule (0xFF, 100).
|
| 36 |
+
INFO: Seed: 1337
|
| 37 |
+
INFO: Loaded 2 modules (83640 inline 8-bit counters): 82573 [0x7fe86ff70df0, 0x7fe86ff8507d), 1067 [0x60c638, 0x60ca63),
|
| 38 |
+
INFO: Loaded 2 PC tables (83640 PCs): 82573 [0x7fe86ff85080,0x7fe8700c7950), 1067 [0x60ca68,0x610d18),
|
| 39 |
+
INFO: 1153 files found in /github/workspace/cifuzz-corpus/fuzz-dhcp-server
|
| 40 |
+
INFO: -max_len is not provided; libFuzzer will not generate inputs larger than 1048576 bytes
|
| 41 |
+
INFO: seed corpus: files: 1153 min: 1b max: 5242879b total: 17056071b rss: 50Mb
|
| 42 |
+
#1155 INITED cov: 577 ft: 1116 corp: 203/54Kb exec/s: 0 rss: 86Mb
|
| 43 |
+
#1167 NEW cov: 577 ft: 1117 corp: 204/54Kb lim: 1048576 exec/s: 0 rss: 86Mb L: 243/1071 MS: 2 ChangeASCIIInt-CrossOver-
|
| 44 |
+
#1509 NEW cov: 577 ft: 1118 corp: 205/54Kb lim: 1048576 exec/s: 0 rss: 86Mb L: 243/1071 MS: 2 ChangeBit-CopyPart-
|
| 45 |
+
#63018 NEW cov: 577 ft: 1119 corp: 206/55Kb lim: 1048576 exec/s: 21006 rss: 86Mb L: 245/1071 MS: 4 InsertByte-ChangeByte-CMP-InsertByte- DE: "2\000\000\000\000\000\000\000"-
|
| 46 |
+
#65536 pulse cov: 577 ft: 1119 corp: 206/55Kb lim: 1048576 exec/s: 21845 rss: 86Mb
|
| 47 |
+
Loaded 1024/1155 files from /github/workspace/cifuzz-corpus/fuzz-dhcp-server
|
| 48 |
+
#99784 NEW cov: 577 ft: 1120 corp: 207/55Kb lim: 1048576 exec/s: 19956 rss: 105Mb L: 243/1071 MS: 2 ChangeASCIIInt-ChangeBinInt-
|
| 49 |
+
#131072 pulse cov: 577 ft: 1120 corp: 207/55Kb lim: 1048576 exec/s: 21845 rss: 105Mb
|
| 50 |
+
#262144 pulse cov: 577 ft: 1120 corp: 207/55Kb lim: 1048576 exec/s: 20164 rss: 105Mb
|
| 51 |
+
#275639 DONE cov: 577 ft: 1120 corp: 207/55Kb lim: 1048576 exec/s: 19688 rss: 105Mb
|
| 52 |
+
###### Recommended dictionary. ######
|
| 53 |
+
"2\000\000\000\000\000\000\000" # Uses: 17879
|
| 54 |
+
###### End of recommended dictionary. ######
|
| 55 |
+
Done 275639 runs in 14 second(s)
|
| 56 |
+
stat::number_of_executed_units: 275639
|
| 57 |
+
stat::average_exec_per_sec: 19688
|
| 58 |
+
stat::new_units_added: 4
|
| 59 |
+
stat::slowest_unit_time_sec: 0
|
| 60 |
+
stat::peak_rss_mb: 105
|
| 61 |
+
/github/workspace/build-out/fuzz-dhcp-server -timeout=25 -rss_limit_mb=2560 -len_control=0 -seed=1337 -artifact_prefix=/tmp/tmpyxgwwsvr/ -max_total_time=13 -print_final_stats=1 /github/workspace/cifuzz-corpus/fuzz-dhcp-server >fuzz-1.log 2>&1
|
| 62 |
+
2023-05-04 01:03:18,374 - root - INFO - Not reporting crash in fuzz-dhcp-server because process timed out.
|
| 63 |
+
2023-05-04 01:03:18,377 - root - INFO - Deleting corpus and seed corpus of fuzz-dhcp-server to save disk.
|
| 64 |
+
2023-05-04 01:03:18,399 - root - INFO - Deleting fuzz target: fuzz-dhcp-server.
|
| 65 |
+
2023-05-04 01:03:18,400 - root - INFO - Done deleting.
|
| 66 |
+
2023-05-04 01:03:18,400 - root - INFO - Fuzzer fuzz-dhcp-server finished running without reportable crashes.
|
| 67 |
+
2023-05-04 01:03:18,401 - root - INFO - Running fuzzer: fuzz-bcd.
|
| 68 |
+
2023-05-04 01:03:18,401 - root - INFO - Downloading corpus from OSS-Fuzz: https://storage.googleapis.com/systemd-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/systemd_fuzz-bcd/public.zip
|
| 69 |
+
2023-05-04 01:03:18,404 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): storage.googleapis.com:443
|
| 70 |
+
2023-05-04 01:03:18,582 - urllib3.connectionpool - DEBUG - https://storage.googleapis.com:443 "GET /systemd-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/systemd_fuzz-bcd/public.zip HTTP/1.1" 200 2293254
|
| 71 |
+
2023-05-04 01:03:18,804 - root - INFO - Starting fuzzing
|
| 72 |
+
Fuzzing logs:
|
| 73 |
+
/github/workspace/build-out/fuzz-bcd -timeout=25 -rss_limit_mb=2560 -len_control=0 -seed=1337 -artifact_prefix=/tmp/tmpgvqlyr8q/ -max_total_time=13 -print_final_stats=1 /github/workspace/cifuzz-corpus/fuzz-bcd >fuzz-0.log 2>&1
|
| 74 |
+
================== Job 0 exited with exit code 0 ============
|
| 75 |
+
INFO: Running with entropic power schedule (0xFF, 100).
|
| 76 |
+
INFO: Seed: 1337
|
| 77 |
+
INFO: Loaded 2 modules (83175 inline 8-bit counters): 82573 [0x7f1b5387edf0, 0x7f1b5389307d), 602 [0x5f8718, 0x5f8972),
|
| 78 |
+
INFO: Loaded 2 PC tables (83175 PCs): 82573 [0x7f1b53893080,0x7f1b539d5950), 602 [0x5f8978,0x5faf18),
|
| 79 |
+
INFO: 1260 files found in /github/workspace/cifuzz-corpus/fuzz-bcd
|
| 80 |
+
INFO: -max_len is not provided; libFuzzer will not generate inputs larger than 946175 bytes
|
| 81 |
+
INFO: seed corpus: files: 1260 min: 1b max: 946175b total: 10373697b rss: 48Mb
|
| 82 |
+
#1261 INITED cov: 137 ft: 653 corp: 282/1416Kb exec/s: 0 rss: 91Mb
|
| 83 |
+
#65536 pulse cov: 137 ft: 653 corp: 282/1416Kb lim: 946175 exec/s: 32768 rss: 98Mb
|
| 84 |
+
#131072 pulse cov: 137 ft: 653 corp: 282/1416Kb lim: 946175 exec/s: 32768 rss: 98Mb
|
| 85 |
+
#262144 pulse cov: 137 ft: 653 corp: 282/1416Kb lim: 946175 exec/s: 37449 rss: 98Mb
|
| 86 |
+
#475081 DONE cov: 137 ft: 653 corp: 282/1416Kb lim: 946175 exec/s: 33934 rss: 98Mb
|
| 87 |
+
Done 475081 runs in 14 second(s)
|
| 88 |
+
stat::number_of_executed_units: 475081
|
| 89 |
+
stat::average_exec_per_sec: 33934
|
| 90 |
+
stat::new_units_added: 0
|
| 91 |
+
stat::slowest_unit_time_sec: 0
|
| 92 |
+
stat::peak_rss_mb: 98
|
| 93 |
+
/github/workspace/build-out/fuzz-bcd -timeout=25 -rss_limit_mb=2560 -len_control=0 -seed=1337 -artifact_prefix=/tmp/tmpgvqlyr8q/ -max_total_time=13 -print_final_stats=1 /github/workspace/cifuzz-corpus/fuzz-bcd >fuzz-1.log 2>&1
|
| 94 |
+
2023-05-04 01:03:41,821 - root - INFO - Not reporting crash in fuzz-bcd because process timed out.
|
| 95 |
+
2023-05-04 01:03:41,822 - root - INFO - Deleting corpus and seed corpus of fuzz-bcd to save disk.
|
| 96 |
+
2023-05-04 01:03:41,848 - root - INFO - Deleting fuzz target: fuzz-bcd.
|
| 97 |
+
2023-05-04 01:03:41,848 - root - INFO - Done deleting.
|
| 98 |
+
2023-05-04 01:03:41,848 - root - INFO - Fuzzer fuzz-bcd finished running without reportable crashes.
|
| 99 |
+
2023-05-04 01:03:41,848 - root - INFO - Running fuzzer: fuzz-varlink.
|
| 100 |
+
2023-05-04 01:03:41,849 - root - INFO - Downloading corpus from OSS-Fuzz: https://storage.googleapis.com/systemd-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/systemd_fuzz-varlink/public.zip
|
| 101 |
+
2023-05-04 01:03:41,852 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): storage.googleapis.com:443
|
| 102 |
+
2023-05-04 01:03:41,906 - urllib3.connectionpool - DEBUG - https://storage.googleapis.com:443 "GET /systemd-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/systemd_fuzz-varlink/public.zip HTTP/1.1" 200 2586434
|
| 103 |
+
2023-05-04 01:03:42,671 - root - INFO - Starting fuzzing
|
| 104 |
+
2023-05-04 01:04:05,709 - root - INFO - Not reporting crash in fuzz-varlink because process timed out.
|
| 105 |
+
Fuzzing logs:
|
| 106 |
+
/github/workspace/build-out/fuzz-varlink -timeout=25 -rss_limit_mb=2560 -len_control=0 -seed=1337 -artifact_prefix=/tmp/tmpbtf4f932/ -max_total_time=13 -print_final_stats=1 /github/workspace/cifuzz-corpus/fuzz-varlink >fuzz-0.log 2>&1
|
| 107 |
+
2023-05-04 01:04:05,709 - root - INFO - Deleting corpus and seed corpus of fuzz-varlink to save disk.
|
| 108 |
+
2023-05-04 01:04:05,806 - root - INFO - Deleting fuzz target: fuzz-varlink.
|
| 109 |
+
2023-05-04 01:04:05,806 - root - INFO - Done deleting.
|
| 110 |
+
2023-05-04 01:04:05,806 - root - INFO - Fuzzer fuzz-varlink finished running without reportable crashes.
|
| 111 |
+
2023-05-04 01:04:05,806 - root - INFO - Running fuzzer: fuzz-unit-file.
|
| 112 |
+
2023-05-04 01:04:05,807 - root - INFO - Downloading corpus from OSS-Fuzz: https://storage.googleapis.com/systemd-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/systemd_fuzz-unit-file/public.zip
|
| 113 |
+
2023-05-04 01:04:05,809 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): storage.googleapis.com:443
|
| 114 |
+
2023-05-04 01:04:05,897 - urllib3.connectionpool - DEBUG - https://storage.googleapis.com:443 "GET /systemd-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/systemd_fuzz-unit-file/public.zip HTTP/1.1" 200 4999974
|
| 115 |
+
2023-05-04 01:04:07,869 - root - INFO - Starting fuzzing
|
| 116 |
+
2023-05-04 01:04:09,516 - root - INFO - Fuzzer: fuzz-unit-file. Detected bug.
|
| 117 |
+
Fuzzing logs:
|
| 118 |
+
/github/workspace/build-out/fuzz-unit-file -timeout=25 -rss_limit_mb=2560 -len_control=0 -seed=1337 -artifact_prefix=/tmp/tmpjhswtxiw/ -max_total_time=13 -print_final_stats=1 /github/workspace/cifuzz-corpus/fuzz-unit-file >fuzz-0.log 2>&1
|
| 119 |
+
2023-05-04 01:04:09,517 - root - INFO - Trying to reproduce crash using: /tmp/tmpjhswtxiw/crash-7be9e0f3a71d95f8d5e67c5a9d84273d6f4e3c03.
|
| 120 |
+
================== Job 0 exited with exit code 77 ============
|
| 121 |
+
INFO: Running with entropic power schedule (0xFF, 100).
|
| 122 |
+
INFO: Seed: 1337
|
| 123 |
+
INFO: Loaded 2 modules (82576 inline 8-bit counters): 82573 [0x7f3b0de4cdf0, 0x7f3b0de6107d), 3 [0x5e9b28, 0x5e9b2b),
|
| 124 |
+
INFO: Loaded 2 PC tables (82576 PCs): 82573 [0x7f3b0de61080,0x7f3b0dfa3950), 3 [0x5a6af8,0x5a6b28),
|
| 125 |
+
INFO: 20907 files found in /github/workspace/cifuzz-corpus/fuzz-unit-file
|
| 126 |
+
INFO: -max_len is not provided; libFuzzer will not generate inputs larger than 604973 bytes
|
| 127 |
+
INFO: seed corpus: files: 20907 min: 1b max: 604973b total: 16005340b rss: 61Mb
|
| 128 |
+
=================================================================
|
| 129 |
+
==74==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x602000005078 at pc 0x0000004ddffa bp 0x7fffeea64fe0 sp 0x7fffeea64fd8
|
| 130 |
+
READ of size 4 at 0x602000005078 thread T0
|
| 131 |
+
SCARINESS: 27 (4-byte-read-heap-buffer-overflow-far-from-bounds)
|
| 132 |
+
#0 0x4ddff9 in samLLVM2FuzzerTestOneInput /work/build/../../src/systemd/src/core/fuzz-unit-file.c:30:16
|
| 133 |
+
#1 0x4fc653 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:611:15
|
| 134 |
+
#2 0x4fbe3a in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:514:3
|
| 135 |
+
#3 0x4fdca4 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:826:7
|
| 136 |
+
#4 0x4fded9 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:857:3
|
| 137 |
+
#5 0x4ed53f in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:912:6
|
| 138 |
+
#6 0x516b92 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
|
| 139 |
+
#7 0x7f3b0ce20082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 1878e6b475720c7c51969e69ab2d276fae6d1dee)
|
| 140 |
+
#8 0x41f6ed in _start (build-out/fuzz-unit-file+0x41f6ed)
|
| 141 |
+
|
| 142 |
+
DEDUP_TOKEN: samLLVM2FuzzerTestOneInput--fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long)--fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*)
|
| 143 |
+
0x602000005078 is located 38 bytes to the right of 2-byte region [0x602000005050,0x602000005052)
|
| 144 |
+
freed by thread T0 here:
|
| 145 |
+
#0 0x4a0882 in __interceptor_free /src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:52:3
|
| 146 |
+
#1 0x4ddfb7 in samLLVM2FuzzerTestOneInput /work/build/../../src/systemd/src/core/fuzz-unit-file.c:29:9
|
| 147 |
+
#2 0x4fc653 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:611:15
|
| 148 |
+
#3 0x4fbe3a in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:514:3
|
| 149 |
+
#4 0x4fdca4 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:826:7
|
| 150 |
+
#5 0x4fded9 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:857:3
|
| 151 |
+
#6 0x4ed53f in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:912:6
|
| 152 |
+
#7 0x516b92 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
|
| 153 |
+
#8 0x7f3b0ce20082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 1878e6b475720c7c51969e69ab2d276fae6d1dee)
|
| 154 |
+
|
| 155 |
+
DEDUP_TOKEN: __interceptor_free--samLLVM2FuzzerTestOneInput--fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long)
|
| 156 |
+
previously allocated by thread T0 here:
|
| 157 |
+
#0 0x4a0b26 in malloc /src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:69:3
|
| 158 |
+
#1 0x4ddfac in samLLVM2FuzzerTestOneInput /work/build/../../src/systemd/src/core/fuzz-unit-file.c:28:25
|
| 159 |
+
#2 0x4fc653 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:611:15
|
| 160 |
+
#3 0x4fbe3a in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:514:3
|
| 161 |
+
#4 0x4fdca4 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:826:7
|
| 162 |
+
#5 0x4fded9 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:857:3
|
| 163 |
+
#6 0x4ed53f in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:912:6
|
| 164 |
+
#7 0x516b92 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
|
| 165 |
+
#8 0x7f3b0ce20082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 1878e6b475720c7c51969e69ab2d276fae6d1dee)
|
| 166 |
+
|
| 167 |
+
DEDUP_TOKEN: malloc--samLLVM2FuzzerTestOneInput--fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long)
|
| 168 |
+
SUMMARY: AddressSanitizer: heap-buffer-overflow /work/build/../../src/systemd/src/core/fuzz-unit-file.c:30:16 in samLLVM2FuzzerTestOneInput
|
| 169 |
+
Shadow bytes around the buggy address:
|
| 170 |
+
0x0c047fff89b0: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
|
| 171 |
+
0x0c047fff89c0: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
|
| 172 |
+
0x0c047fff89d0: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
|
| 173 |
+
0x0c047fff89e0: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
|
| 174 |
+
0x0c047fff89f0: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
|
| 175 |
+
=>0x0c047fff8a00: fa fa 00 02 fa fa 00 02 fa fa fd fa fa fa fa[fa]
|
| 176 |
+
0x0c047fff8a10: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
| 177 |
+
0x0c047fff8a20: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
| 178 |
+
0x0c047fff8a30: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
| 179 |
+
0x0c047fff8a40: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
| 180 |
+
0x0c047fff8a50: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
| 181 |
+
Shadow byte legend (one shadow byte represents 8 application bytes):
|
| 182 |
+
Addressable: 00
|
| 183 |
+
Partially addressable: 01 02 03 04 05 06 07
|
| 184 |
+
Heap left redzone: fa
|
| 185 |
+
Freed heap region: fd
|
| 186 |
+
Stack left redzone: f1
|
| 187 |
+
Stack mid redzone: f2
|
| 188 |
+
Stack right redzone: f3
|
| 189 |
+
Stack after return: f5
|
| 190 |
+
Stack use after scope: f8
|
| 191 |
+
Global redzone: f9
|
| 192 |
+
Global init order: f6
|
| 193 |
+
Poisoned by user: f7
|
| 194 |
+
Container overflow: fc
|
| 195 |
+
Array cookie: ac
|
| 196 |
+
Intra object redzone: bb
|
| 197 |
+
ASan internal: fe
|
| 198 |
+
Left alloca redzone: ca
|
| 199 |
+
Right alloca redzone: cb
|
| 200 |
+
==74==ABORTING
|
| 201 |
+
MS: 0 ; base unit: 0000000000000000000000000000000000000000
|
| 202 |
+
0x61,0x75,0x74,0x6f,0x6d,0x6f,0x75,0x6e,0x74,0x48,
|
| 203 |
+
automountH
|
| 204 |
+
artifact_prefix='/tmp/tmpjhswtxiw/'; Test unit written to /tmp/tmpjhswtxiw/crash-7be9e0f3a71d95f8d5e67c5a9d84273d6f4e3c03
|
| 205 |
+
Base64: YXV0b21vdW50SA==
|
| 206 |
+
stat::number_of_executed_units: 314
|
| 207 |
+
stat::average_exec_per_sec: 0
|
| 208 |
+
stat::new_units_added: 0
|
| 209 |
+
stat::slowest_unit_time_sec: 0
|
| 210 |
+
stat::peak_rss_mb: 67
|
| 211 |
+
/github/workspace/build-out/fuzz-unit-file -timeout=25 -rss_limit_mb=2560 -len_control=0 -seed=1337 -artifact_prefix=/tmp/tmpjhswtxiw/ -max_total_time=13 -print_final_stats=1 /github/workspace/cifuzz-corpus/fuzz-unit-file >fuzz-1.log 2>&1
|
| 212 |
+
================== Job 1 exited with exit code 77 ============
|
| 213 |
+
INFO: Running with entropic power schedule (0xFF, 100).
|
| 214 |
+
INFO: Seed: 1337
|
| 215 |
+
INFO: Loaded 2 modules (82576 inline 8-bit counters): 82573 [0x7ff1ba038df0, 0x7ff1ba04d07d), 3 [0x5e9b28, 0x5e9b2b),
|
| 216 |
+
INFO: Loaded 2 PC tables (82576 PCs): 82573 [0x7ff1ba04d080,0x7ff1ba18f950), 3 [0x5a6af8,0x5a6b28),
|
| 217 |
+
INFO: 20907 files found in /github/workspace/cifuzz-corpus/fuzz-unit-file
|
| 218 |
+
INFO: -max_len is not provided; libFuzzer will not generate inputs larger than 604973 bytes
|
| 219 |
+
INFO: seed corpus: files: 20907 min: 1b max: 604973b total: 16005340b rss: 61Mb
|
| 220 |
+
=================================================================
|
| 221 |
+
==78==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x602000005078 at pc 0x0000004ddffa bp 0x7ffc2e6825c0 sp 0x7ffc2e6825b8
|
| 222 |
+
READ of size 4 at 0x602000005078 thread T0
|
| 223 |
+
SCARINESS: 27 (4-byte-read-heap-buffer-overflow-far-from-bounds)
|
| 224 |
+
#0 0x4ddff9 in samLLVM2FuzzerTestOneInput /work/build/../../src/systemd/src/core/fuzz-unit-file.c:30:16
|
| 225 |
+
#1 0x4fc653 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:611:15
|
| 226 |
+
#2 0x4fbe3a in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:514:3
|
| 227 |
+
#3 0x4fdca4 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:826:7
|
| 228 |
+
#4 0x4fded9 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:857:3
|
| 229 |
+
#5 0x4ed53f in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:912:6
|
| 230 |
+
#6 0x516b92 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
|
| 231 |
+
#7 0x7ff1b900c082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 1878e6b475720c7c51969e69ab2d276fae6d1dee)
|
| 232 |
+
#8 0x41f6ed in _start (build-out/fuzz-unit-file+0x41f6ed)
|
| 233 |
+
|
| 234 |
+
DEDUP_TOKEN: samLLVM2FuzzerTestOneInput--fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long)--fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*)
|
| 235 |
+
0x602000005078 is located 38 bytes to the right of 2-byte region [0x602000005050,0x602000005052)
|
| 236 |
+
freed by thread T0 here:
|
| 237 |
+
#0 0x4a0882 in __interceptor_free /src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:52:3
|
| 238 |
+
#1 0x4ddfb7 in samLLVM2FuzzerTestOneInput /work/build/../../src/systemd/src/core/fuzz-unit-file.c:29:9
|
| 239 |
+
#2 0x4fc653 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:611:15
|
| 240 |
+
#3 0x4fbe3a in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:514:3
|
| 241 |
+
#4 0x4fdca4 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:826:7
|
| 242 |
+
#5 0x4fded9 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:857:3
|
| 243 |
+
#6 0x4ed53f in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:912:6
|
| 244 |
+
#7 0x516b92 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
|
| 245 |
+
#8 0x7ff1b900c082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 1878e6b475720c7c51969e69ab2d276fae6d1dee)
|
| 246 |
+
|
| 247 |
+
DEDUP_TOKEN: __interceptor_free--samLLVM2FuzzerTestOneInput--fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long)
|
| 248 |
+
previously allocated by thread T0 here:
|
| 249 |
+
#0 0x4a0b26 in malloc /src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:69:3
|
| 250 |
+
#1 0x4ddfac in samLLVM2FuzzerTestOneInput /work/build/../../src/systemd/src/core/fuzz-unit-file.c:28:25
|
| 251 |
+
#2 0x4fc653 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:611:15
|
| 252 |
+
#3 0x4fbe3a in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:514:3
|
| 253 |
+
#4 0x4fdca4 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:826:7
|
| 254 |
+
#5 0x4fded9 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:857:3
|
| 255 |
+
#6 0x4ed53f in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:912:6
|
| 256 |
+
#7 0x516b92 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
|
| 257 |
+
#8 0x7ff1b900c082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 1878e6b475720c7c51969e69ab2d276fae6d1dee)
|
| 258 |
+
|
| 259 |
+
DEDUP_TOKEN: malloc--samLLVM2FuzzerTestOneInput--fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long)
|
| 260 |
+
SUMMARY: AddressSanitizer: heap-buffer-overflow /work/build/../../src/systemd/src/core/fuzz-unit-file.c:30:16 in samsamLLVM2FuzzerTestOneInput
|
| 261 |
+
Shadow bytes around the buggy address:
|
| 262 |
+
0x0c047fff89b0: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
|
| 263 |
+
0x0c047fff89c0: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
|
| 264 |
+
0x0c047fff89d0: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
|
| 265 |
+
0x0c047fff89e0: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
|
| 266 |
+
0x0c047fff89f0: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
|
| 267 |
+
=>0x0c047fff8a00: fa fa 00 02 fa fa 00 02 fa fa fd fa fa fa fa[fa]
|
| 268 |
+
0x0c047fff8a10: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
| 269 |
+
0x0c047fff8a20: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
| 270 |
+
0x0c047fff8a30: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
| 271 |
+
0x0c047fff8a40: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
| 272 |
+
0x0c047fff8a50: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
|
| 273 |
+
Shadow byte legend (one shadow byte represents 8 application bytes):
|
| 274 |
+
Addressable: 00
|
| 275 |
+
Partially addressable: 01 02 03 04 05 06 07
|
| 276 |
+
Heap left redzone: fa
|
| 277 |
+
Freed heap region: fd
|
| 278 |
+
Stack left redzone: f1
|
| 279 |
+
Stack mid redzone: f2
|
| 280 |
+
Stack right redzone: f3
|
| 281 |
+
Stack after return: f5
|
| 282 |
+
Stack use after scope: f8
|
| 283 |
+
Global redzone: f9
|
| 284 |
+
Global init order: f6
|
| 285 |
+
Poisoned by user: f7
|
| 286 |
+
Container overflow: fc
|
| 287 |
+
Array cookie: ac
|
| 288 |
+
Intra object redzone: bb
|
| 289 |
+
ASan internal: fe
|
| 290 |
+
Left alloca redzone: ca
|
| 291 |
+
Right alloca redzone: cb
|
| 292 |
+
==78==ABORTING
|
| 293 |
+
MS: 0 ; base unit: 0000000000000000000000000000000000000000
|
| 294 |
+
0x61,0x75,0x74,0x6f,0x6d,0x6f,0x75,0x6e,0x74,0x48,
|
| 295 |
+
automountH
|
| 296 |
+
artifact_prefix='/tmp/tmpjhswtxiw/'; Test unit written to /tmp/tmpjhswtxiw/crash-7be9e0f3a71d95f8d5e67c5a9d84273d6f4e3c03
|
| 297 |
+
Base64: YXV0b21vdW50SA==
|
| 298 |
+
stat::number_of_executed_units: 314
|
| 299 |
+
stat::average_exec_per_sec: 0
|
| 300 |
+
stat::new_units_added: 0
|
| 301 |
+
stat::slowest_unit_time_sec: 0
|
| 302 |
+
stat::peak_rss_mb: 68
|
local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/experimental/SystemSan/Makefile
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.POSIX:
|
| 2 |
+
CXX = clang++
|
| 3 |
+
CFLAGS = -std=c++17 -Wall -Wextra -O3 -g3 -Werror
|
| 4 |
+
|
| 5 |
+
all: SystemSan target target_file target_dns
|
| 6 |
+
|
| 7 |
+
SystemSan: SystemSan.cpp inspect_dns.cpp inspect_utils.cpp
|
| 8 |
+
$(CXX) $(CFLAGS) -lpthread -o $@ $^
|
| 9 |
+
|
| 10 |
+
# Needs atheris.
|
| 11 |
+
python-test: all
|
| 12 |
+
./SystemSan python shell_injection_poc_fuzzer.py
|
| 13 |
+
|
| 14 |
+
target: target.cpp
|
| 15 |
+
$(CXX) $(CFLAGS) -fsanitize=address,fuzzer -o $@ $^
|
| 16 |
+
|
| 17 |
+
target_file: target_file.cpp
|
| 18 |
+
$(CXX) $(CFLAGS) -fsanitize=address,fuzzer -o $@ $^
|
| 19 |
+
|
| 20 |
+
target_dns: target_dns.cpp
|
| 21 |
+
$(CXX) $(CFLAGS) -fsanitize=address,fuzzer -o $@ $^
|
| 22 |
+
|
| 23 |
+
test: all vuln.dict
|
| 24 |
+
./SystemSan ./target -dict=vuln.dict
|
| 25 |
+
./SystemSan ./target_file -dict=vuln.dict
|
| 26 |
+
./SystemSan ./target_dns -dict=vuln.dict
|
| 27 |
+
|
| 28 |
+
pytorch-lightning-1.5.10:
|
| 29 |
+
cp SystemSan.cpp PoEs/pytorch-lightning-1.5.10/; \
|
| 30 |
+
cd PoEs/pytorch-lightning-1.5.10/; \
|
| 31 |
+
docker build . --tag syssan_pytorch-lightning; \
|
| 32 |
+
docker run -t systemsan_pytorch-lightning:latest;
|
| 33 |
+
|
| 34 |
+
node-shell-quote-v1.7.3:
|
| 35 |
+
cp SystemSan.cpp PoEs/node-shell-quote-v1.7.3/; \
|
| 36 |
+
cd PoEs/node-shell-quote-v1.7.3/; \
|
| 37 |
+
docker build . --tag systemsan_node-shell-quote; \
|
| 38 |
+
docker run -t systemsan_node-shell-quote:latest;
|
| 39 |
+
|
| 40 |
+
clean:
|
| 41 |
+
rm -f SystemSan /tmp/tripwire target target_file target_dns
|
local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/experimental/SystemSan/PoEs/node-shell-quote-v1.7.3/Dockerfile
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2022 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
#
|
| 15 |
+
# Build and run the proof of error in shell-quote v1.7.3.
|
| 16 |
+
|
| 17 |
+
FROM ghcr.io/aixcc-finals/base-builder
|
| 18 |
+
|
| 19 |
+
RUN apt update && \
|
| 20 |
+
apt install -y \
|
| 21 |
+
vim \
|
| 22 |
+
npm && \
|
| 23 |
+
git clone \
|
| 24 |
+
--depth 1 \
|
| 25 |
+
https://github.com/substack/node-shell-quote.git && \
|
| 26 |
+
npm config set @gitlab-org:registry \
|
| 27 |
+
https://gitlab.com/api/v4/packages/npm/
|
| 28 |
+
|
| 29 |
+
COPY ./build.sh $SRC
|
| 30 |
+
RUN ./build.sh
|
| 31 |
+
|
| 32 |
+
COPY . $SRC
|
| 33 |
+
RUN make SystemSan
|
| 34 |
+
|
| 35 |
+
CMD ["make", "run"]
|
local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/experimental/SystemSan/PoEs/node-shell-quote-v1.7.3/Makefile
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.POSIX:
|
| 2 |
+
CXX = clang++
|
| 3 |
+
CFLAGS = -std=c++17 -Wall -Wextra -O3 -g3
|
| 4 |
+
|
| 5 |
+
SystemSan: SystemSan.cpp
|
| 6 |
+
$(CXX) $(CFLAGS) -lpthread -o $@ $^
|
| 7 |
+
|
| 8 |
+
run: clean SystemSan target.js
|
| 9 |
+
./SystemSan jsfuzz ./target.js
|
| 10 |
+
|
| 11 |
+
clean:
|
| 12 |
+
rm -f SystemSan /tmp/tripwire
|
local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/experimental/SystemSan/PoEs/node-shell-quote-v1.7.3/build.sh
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash -eu
|
| 2 |
+
# Copyright 2022 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
################################################################################
|
| 17 |
+
|
| 18 |
+
# Build and install project (using current CFLAGS, CXXFLAGS).
|
| 19 |
+
npm install ./node-shell-quote/
|
| 20 |
+
|
| 21 |
+
# Build fuzzers.
|
| 22 |
+
npm i -g @gitlab-org/jsfuzz
|
local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/experimental/SystemSan/PoEs/node-shell-quote-v1.7.3/target.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2022 Google LLC
|
| 3 |
+
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
/* Exploit shell quote with fuzzer's input as a parameter of echo.
|
| 17 |
+
* This PoC is extended from a report in GitHub Advisory Database:
|
| 18 |
+
* https://github.com/advisories/GHSA-g4rg-993r-mgx7
|
| 19 |
+
* The original report records a shell injection exploit in shell-quote v1.7.2,
|
| 20 |
+
* we show that a similar shell corruption exploit still persists in v1.7.3,
|
| 21 |
+
* after a commit that intends to fix the original exploit.
|
| 22 |
+
* */
|
| 23 |
+
|
| 24 |
+
/* Fuzz the target program with buf generated by Jsfuzz. */
|
| 25 |
+
function fuzz(buf) {
|
| 26 |
+
buf = String(buf)
|
| 27 |
+
const childProcess = require('child_process');
|
| 28 |
+
const shellQuote = require('shell-quote');
|
| 29 |
+
childProcess.execSync(shellQuote.quote(['echo', buf]));
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
/* Run Jsfuzz. */
|
| 33 |
+
module.exports = {
|
| 34 |
+
fuzz
|
| 35 |
+
};
|
local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/experimental/SystemSan/PoEs/pytorch-lightning-1.5.10/Dockerfile
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2022 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
#
|
| 15 |
+
# Build and run the proof of error in pytorch-lightning.
|
| 16 |
+
|
| 17 |
+
FROM ghcr.io/aixcc-finals/base-builder-python
|
| 18 |
+
|
| 19 |
+
RUN apt update && \
|
| 20 |
+
apt install -y vim && \
|
| 21 |
+
git clone \
|
| 22 |
+
--depth 1 \
|
| 23 |
+
--branch 1.5.10 \
|
| 24 |
+
https://github.com/PyTorchLightning/pytorch-lightning.git
|
| 25 |
+
|
| 26 |
+
COPY ./build.sh $SRC
|
| 27 |
+
RUN ./build.sh
|
| 28 |
+
|
| 29 |
+
COPY . $SRC
|
| 30 |
+
RUN make SystemSan
|
| 31 |
+
|
| 32 |
+
CMD ["make", "run"]
|
local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/experimental/SystemSan/PoEs/pytorch-lightning-1.5.10/Makefile
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.POSIX:
|
| 2 |
+
CXX = clang++
|
| 3 |
+
CFLAGS = -std=c++17 -Wall -Wextra -O3 -g3
|
| 4 |
+
|
| 5 |
+
SystemSan: SystemSan.cpp
|
| 6 |
+
$(CXX) $(CFLAGS) -lpthread -o $@ $^
|
| 7 |
+
|
| 8 |
+
run: clean SystemSan fuzz_pytorch_lightning.py
|
| 9 |
+
./SystemSan ./fuzz_pytorch_lightning.py -dict=vuln.dict
|
| 10 |
+
|
| 11 |
+
clean:
|
| 12 |
+
rm -f SystemSan /tmp/tripwire
|
local-test-commons-compress-full-01-vuln_0/fuzz-tooling/infra/experimental/SystemSan/PoEs/pytorch-lightning-1.5.10/build.sh
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash -eu
|
| 2 |
+
# Copyright 2022 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
################################################################################
|
| 17 |
+
|
| 18 |
+
# Build and install project (using current CFLAGS, CXXFLAGS).
|
| 19 |
+
cd pytorch-lightning
|
| 20 |
+
pip3 install .
|
| 21 |
+
|
| 22 |
+
# Build fuzzers in $OUT.
|
| 23 |
+
for fuzzer in $(find $SRC -name '*_fuzzer.py'); do
|
| 24 |
+
compile_python_fuzzer $fuzzer
|
| 25 |
+
done
|