[infra] gcb: Build afl fuzzers.

This commit is contained in:
Oliver Chang 2017-03-14 17:16:01 -07:00
parent 2b14cbe441
commit de5418888c
1 changed files with 78 additions and 53 deletions

View File

@ -6,6 +6,7 @@ Usage: build.py <project_dir>
"""
import base64
import collections
import datetime
import os
import subprocess
@ -18,15 +19,28 @@ from oauth2client.client import GoogleCredentials
from oauth2client.service_account import ServiceAccountCredentials
from googleapiclient.discovery import build
CONFIGURATIONS = {
'sanitizer-address' : [ 'SANITIZER=address' ],
'sanitizer-memory' : [ 'SANITIZER=memory' ],
'sanitizer-undefined' : [ 'SANITIZER=undefined' ],
'engine-libfuzzer' : [ 'FUZZING_ENGINE=libfuzzer' ],
'engine-afl' : [ 'FUZZING_ENGINE=afl' ],
}
EngineInfo = collections.namedtuple(
'EngineInfo', ['upload_bucket', 'supported_sanitizers'])
ENGINE_INFO = {
'libfuzzer': EngineInfo(
upload_bucket='clusterfuzz-builds-test',
supported_sanitizers=['address', 'memory', 'undefined']),
'afl': EngineInfo(
upload_bucket='clusterfuzz-builds-afl-test',
supported_sanitizers=['address']),
}
DEFAULT_ENGINES = ['libfuzzer', 'afl']
DEFAULT_SANITIZERS = ['address', 'undefined']
UPLOAD_BUCKET = 'clusterfuzz-builds-test'
def usage():
@ -44,6 +58,7 @@ def load_project_yaml(project_dir):
project_yaml.setdefault('image',
'gcr.io/clusterfuzz-external/oss-fuzz/' + project_name)
project_yaml.setdefault('sanitizers', DEFAULT_SANITIZERS)
project_yaml.setdefault('fuzzing_engines', DEFAULT_ENGINES)
return project_yaml
@ -66,6 +81,10 @@ def get_signed_url(path):
urllib.urlencode(values))
def is_supported_configuration(fuzzing_engine, sanitizer):
return sanitizer in ENGINE_INFO[fuzzing_engine].supported_sanitizers
def get_build_steps(project_yaml):
name = project_yaml['name']
image = project_yaml['image']
@ -94,16 +113,22 @@ def get_build_steps(project_yaml):
},
]
for fuzzing_engine in project_yaml['fuzzing_engines']:
for sanitizer in project_yaml['sanitizers']:
env = CONFIGURATIONS["sanitizer-" + sanitizer][:]
if not is_supported_configuration(fuzzing_engine, sanitizer):
continue
env = CONFIGURATIONS['engine-' + fuzzing_engine][:]
env.extend(CONFIGURATIONS['sanitizer-' + sanitizer])
out = '/workspace/out/' + sanitizer
stamped_name = name + '-' + sanitizer + '-' + ts
zip_file = stamped_name + '.zip'
stamped_srcmap_file = stamped_name + '.srcmap.json'
bucket = ENGINE_INFO[fuzzing_engine].upload_bucket
upload_url = get_signed_url('/{0}/{1}/{2}'.format(
UPLOAD_BUCKET, name, zip_file))
bucket, name, zip_file))
srcmap_url = get_signed_url('/{0}/{1}/{2}'.format(
UPLOAD_BUCKET, name, stamped_srcmap_file))
bucket, name, stamped_srcmap_file))
env.append('OUT=' + out)