• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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"""
15import logging
16import sys
17
18import build_fuzzers_entrypoint
19import run_fuzzers_entrypoint
20
21
22def main():
23  """Builds and runs fuzzers for CI tools.
24
25  NOTE: Any crash report will be in the filepath:
26  ${GITHUB_WORKSPACE}/out/testcase
27 This can be used with GitHub's upload-artifact action to surface the logs.
28
29  Required environment variables:
30    OSS_FUZZ_PROJECT_NAME: The name of OSS-Fuzz project.
31    GITHUB_REPOSITORY: The name of the Github repo that called this script.
32    GITHUB_SHA: The commit SHA that triggered this script.
33    GITHUB_EVENT_NAME: The name of the hook event that triggered this script.
34    GITHUB_EVENT_PATH:
35      The path to the file containing the POST payload of the webhook:
36      https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners#filesystems-on-github-hosted-runners
37    GITHUB_WORKSPACE: The shared volume directory where input artifacts are.
38    DRY_RUN: If true, no failures will surface.
39    SANITIZER: The sanitizer to use when running fuzzers.
40    FUZZ_SECONDS: The length of time in seconds that fuzzers are to be run.
41
42  Returns:
43    0 on success or 1 on failure.
44  """
45  logging.debug("Using cifuzz_combined_entrypoint.")
46  result = build_fuzzers_entrypoint.build_fuzzers_entrypoint()
47  if result != 0:
48    return result
49  return run_fuzzers_entrypoint.run_fuzzers_entrypoint()
50
51
52if __name__ == '__main__':
53  sys.exit(main())
54