mirror of https://github.com/google/oss-fuzz.git
[infra] gcb: Build afl fuzzers.
This commit is contained in:
parent
2b14cbe441
commit
de5418888c
|
@ -6,6 +6,7 @@ Usage: build.py <project_dir>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import base64
|
import base64
|
||||||
|
import collections
|
||||||
import datetime
|
import datetime
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
@ -18,15 +19,28 @@ from oauth2client.client import GoogleCredentials
|
||||||
from oauth2client.service_account import ServiceAccountCredentials
|
from oauth2client.service_account import ServiceAccountCredentials
|
||||||
from googleapiclient.discovery import build
|
from googleapiclient.discovery import build
|
||||||
|
|
||||||
|
|
||||||
CONFIGURATIONS = {
|
CONFIGURATIONS = {
|
||||||
'sanitizer-address' : [ 'SANITIZER=address' ],
|
'sanitizer-address' : [ 'SANITIZER=address' ],
|
||||||
'sanitizer-memory' : [ 'SANITIZER=memory' ],
|
'sanitizer-memory' : [ 'SANITIZER=memory' ],
|
||||||
'sanitizer-undefined' : [ 'SANITIZER=undefined' ],
|
'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']
|
DEFAULT_SANITIZERS = ['address', 'undefined']
|
||||||
UPLOAD_BUCKET = 'clusterfuzz-builds-test'
|
|
||||||
|
|
||||||
|
|
||||||
def usage():
|
def usage():
|
||||||
|
@ -44,6 +58,7 @@ def load_project_yaml(project_dir):
|
||||||
project_yaml.setdefault('image',
|
project_yaml.setdefault('image',
|
||||||
'gcr.io/clusterfuzz-external/oss-fuzz/' + project_name)
|
'gcr.io/clusterfuzz-external/oss-fuzz/' + project_name)
|
||||||
project_yaml.setdefault('sanitizers', DEFAULT_SANITIZERS)
|
project_yaml.setdefault('sanitizers', DEFAULT_SANITIZERS)
|
||||||
|
project_yaml.setdefault('fuzzing_engines', DEFAULT_ENGINES)
|
||||||
return project_yaml
|
return project_yaml
|
||||||
|
|
||||||
|
|
||||||
|
@ -66,6 +81,10 @@ def get_signed_url(path):
|
||||||
urllib.urlencode(values))
|
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):
|
def get_build_steps(project_yaml):
|
||||||
name = project_yaml['name']
|
name = project_yaml['name']
|
||||||
image = project_yaml['image']
|
image = project_yaml['image']
|
||||||
|
@ -94,60 +113,66 @@ def get_build_steps(project_yaml):
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
for sanitizer in project_yaml['sanitizers']:
|
for fuzzing_engine in project_yaml['fuzzing_engines']:
|
||||||
env = CONFIGURATIONS["sanitizer-" + sanitizer][:]
|
for sanitizer in project_yaml['sanitizers']:
|
||||||
out = '/workspace/out/' + sanitizer
|
if not is_supported_configuration(fuzzing_engine, sanitizer):
|
||||||
stamped_name = name + '-' + sanitizer + '-' + ts
|
continue
|
||||||
zip_file = stamped_name + '.zip'
|
|
||||||
stamped_srcmap_file = stamped_name + '.srcmap.json'
|
|
||||||
upload_url = get_signed_url('/{0}/{1}/{2}'.format(
|
|
||||||
UPLOAD_BUCKET, name, zip_file))
|
|
||||||
srcmap_url = get_signed_url('/{0}/{1}/{2}'.format(
|
|
||||||
UPLOAD_BUCKET, name, stamped_srcmap_file))
|
|
||||||
|
|
||||||
env.append('OUT=' + out)
|
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(
|
||||||
|
bucket, name, zip_file))
|
||||||
|
srcmap_url = get_signed_url('/{0}/{1}/{2}'.format(
|
||||||
|
bucket, name, stamped_srcmap_file))
|
||||||
|
|
||||||
build_steps.extend([
|
env.append('OUT=' + out)
|
||||||
# compile
|
|
||||||
{'name': image,
|
build_steps.extend([
|
||||||
'env' : env,
|
# compile
|
||||||
'args': [
|
{'name': image,
|
||||||
'bash',
|
'env' : env,
|
||||||
'-c',
|
'args': [
|
||||||
'cd /src/{1} && mkdir -p {0} && compile'.format(out, name),
|
'bash',
|
||||||
|
'-c',
|
||||||
|
'cd /src/{1} && mkdir -p {0} && compile'.format(out, name),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
# zip binaries
|
||||||
|
{'name': image,
|
||||||
|
'args': [
|
||||||
|
'bash',
|
||||||
|
'-c',
|
||||||
|
'cd {0} && zip -r {1} *'.format(out, zip_file)
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
# zip binaries
|
# upload binaries
|
||||||
{'name': image,
|
{'name': 'gcr.io/clusterfuzz-external/uploader',
|
||||||
'args': [
|
'args': [
|
||||||
'bash',
|
os.path.join(out, zip_file),
|
||||||
'-c',
|
upload_url,
|
||||||
'cd {0} && zip -r {1} *'.format(out, zip_file)
|
],
|
||||||
],
|
},
|
||||||
},
|
# upload srcmap
|
||||||
# upload binaries
|
{'name': 'gcr.io/clusterfuzz-external/uploader',
|
||||||
{'name': 'gcr.io/clusterfuzz-external/uploader',
|
'args': [
|
||||||
'args': [
|
'/workspace/srcmap.json',
|
||||||
os.path.join(out, zip_file),
|
srcmap_url,
|
||||||
upload_url,
|
],
|
||||||
],
|
},
|
||||||
},
|
# cleanup
|
||||||
# upload srcmap
|
{'name': image,
|
||||||
{'name': 'gcr.io/clusterfuzz-external/uploader',
|
'args': [
|
||||||
'args': [
|
'bash',
|
||||||
'/workspace/srcmap.json',
|
'-c',
|
||||||
srcmap_url,
|
'rm -r ' + out,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
# cleanup
|
])
|
||||||
{'name': image,
|
|
||||||
'args': [
|
|
||||||
'bash',
|
|
||||||
'-c',
|
|
||||||
'rm -r ' + out,
|
|
||||||
],
|
|
||||||
},
|
|
||||||
])
|
|
||||||
|
|
||||||
return build_steps
|
return build_steps
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue