• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2016 Google Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#      http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14#
15################################################################################
16"""Templates for OSS-Fuzz project files."""
17
18PROJECT_YAML_TEMPLATE = """\
19homepage: "<your_project_homepage>"
20language: %(language)s"
21primary_contact: "<primary_contact_email>"
22main_repo: "https://path/to/main/repo.git"
23"""
24
25DOCKER_TEMPLATE = """\
26# Copyright %(year)d Google LLC
27#
28# Licensed under the Apache License, Version 2.0 (the "License");
29# you may not use this file except in compliance with the License.
30# You may obtain a copy of the License at
31#
32#      http://www.apache.org/licenses/LICENSE-2.0
33#
34# Unless required by applicable law or agreed to in writing, software
35# distributed under the License is distributed on an "AS IS" BASIS,
36# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
37# See the License for the specific language governing permissions and
38# limitations under the License.
39#
40################################################################################
41
42FROM gcr.io/oss-fuzz-base/%(base_builder)s
43RUN apt-get update && apt-get install -y make autoconf automake libtool
44RUN git clone --depth 1 <git_url> %(project_name)s     # or use other version control
45WORKDIR %(project_name)s
46COPY build.sh $SRC/
47"""
48
49EXTERNAL_DOCKER_TEMPLATE = """\
50FROM gcr.io/oss-fuzz-base/%(base_builder)s:v1
51RUN apt-get update && apt-get install -y make autoconf automake libtool
52RUN COPY . $SRC/%(project_name)s
53WORKDIR %(project_name)s
54COPY .clusterfuzzlite/build.sh $SRC/
55"""
56
57BUILD_TEMPLATE = """\
58#!/bin/bash -eu
59# Copyright %(year)d Google LLC
60#
61# Licensed under the Apache License, Version 2.0 (the "License");
62# you may not use this file except in compliance with the License.
63# You may obtain a copy of the License at
64#
65#      http://www.apache.org/licenses/LICENSE-2.0
66#
67# Unless required by applicable law or agreed to in writing, software
68# distributed under the License is distributed on an "AS IS" BASIS,
69# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
70# See the License for the specific language governing permissions and
71# limitations under the License.
72#
73################################################################################
74
75# build project
76# e.g.
77# ./autogen.sh
78# ./configure
79# make -j$(nproc) all
80
81# build fuzzers
82# e.g.
83# $CXX $CXXFLAGS -std=c++11 -Iinclude \\
84#     /path/to/name_of_fuzzer.cc -o $OUT/name_of_fuzzer \\
85#     $LIB_FUZZING_ENGINE /path/to/library.a
86"""
87
88EXTERNAL_BUILD_TEMPLATE = """\
89#!/bin/bash -eu
90
91# build project
92# e.g.
93# ./autogen.sh
94# ./configure
95# make -j$(nproc) all
96
97# build fuzzers
98# e.g.
99# $CXX $CXXFLAGS -std=c++11 -Iinclude \\
100#     /path/to/name_of_fuzzer.cc -o $OUT/name_of_fuzzer \\
101#     $LIB_FUZZING_ENGINE /path/to/library.a
102"""
103
104TEMPLATES = {
105    'build.sh': BUILD_TEMPLATE,
106    'Dockerfile': DOCKER_TEMPLATE,
107    'project.yaml': PROJECT_YAML_TEMPLATE
108}
109
110EXTERNAL_TEMPLATES = {
111    'build.sh': EXTERNAL_BUILD_TEMPLATE,
112    'Dockerfile': EXTERNAL_DOCKER_TEMPLATE
113}
114