Skip to content
36 changes: 18 additions & 18 deletions infra/build/functions/build_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ def __init__(self, name, project_yaml, dockerfile):
self.labels = project_yaml['labels']
self.fuzzing_language = project_yaml['language']
self.run_tests = project_yaml['run_tests']
self.ubuntu_version = project_yaml.get('ubuntu_version', 'legacy')
if 'main_repo' in project_yaml:
self.main_repo = project_yaml['main_repo']
else:
Expand Down Expand Up @@ -347,22 +348,15 @@ def get_id(step_type, build):
f'-{build.architecture}')


def get_build_steps( # pylint: disable=too-many-locals, too-many-statements, too-many-branches, too-many-arguments
project_name,
project_yaml,
dockerfile,
config,
additional_env=None,
use_caching=False,
timestamp=None):
"""Returns build steps for project."""
def get_build_steps(project_name, project_yaml, dockerfile_contents, config):
"""Returns the build steps for a project."""

project = Project(project_name, project_yaml, dockerfile)
project = Project(project_name, project_yaml, dockerfile_contents)
return get_build_steps_for_project(project,
config,
additional_env=additional_env,
use_caching=use_caching,
timestamp=timestamp), None
additional_env=None,
use_caching=False,
timestamp=None), None


def get_build_steps_for_project(project,
Expand Down Expand Up @@ -488,7 +482,8 @@ def get_build_steps_for_project(project,
# Generate targets list.
{
'name':
build_lib.get_runner_image_name(config.test_image_suffix),
build_lib.get_runner_image_name(config.test_image_suffix,
config.base_image_tag),
'env':
env,
'args': [
Expand Down Expand Up @@ -828,11 +823,12 @@ def parse_args(description, args):
return parser.parse_args(args)


def create_config(args, build_type):
def create_config(args, build_type, base_image_tag=None):
"""Create a Config object from parsed command line |args|."""
upload = not args.experiment
return Config(testing=args.testing,
test_image_suffix=args.test_image_suffix,
base_image_tag=base_image_tag,
branch=args.branch,
parallel=args.parallel,
upload=upload,
Expand All @@ -855,7 +851,6 @@ def build_script_main(script_description,

credentials = oauth2client.client.GoogleCredentials.get_application_default()
error = False
config = create_config(args, build_type)
for project_name in args.projects:
try:
project_yaml, dockerfile_contents = get_project_data(project_name)
Expand All @@ -864,8 +859,13 @@ def build_script_main(script_description,
error = True
continue

steps = get_build_steps_func(project_name, project_yaml,
dockerfile_contents, config)
base_image_tag = project_yaml.get('ubuntu_version')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be base_os_version?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, I fixed it.

if base_image_tag == 'legacy':
base_image_tag = None
config = create_config(args, build_type, base_image_tag=base_image_tag)

steps, _ = get_build_steps_func(project_name, project_yaml,
dockerfile_contents, config)
if not steps:
logging.error('No steps. Skipping %s.', project_name)
error = True
Expand Down
144 changes: 144 additions & 0 deletions infra/build/functions/test_data/expected_build_steps.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,22 @@
"targets_list > /workspace/targets.list.address"
]
},
{
"name": "gcr.io/oss-fuzz-base/base-runner:ubuntu-24-04",
"env": [
"ARCHITECTURE=x86_64",
"FUZZING_ENGINE=afl",
"FUZZING_LANGUAGE=c++",
"HOME=/root",
"OUT=/workspace/out/afl-address-x86_64-ubuntu-24-04",
"SANITIZER=address"
],
"args": [
"bash",
"-c",
"targets_list > /workspace/targets.list.address"
]
},
{
"name": "gcr.io/oss-fuzz/test-project",
"args": [
Expand Down Expand Up @@ -309,6 +325,22 @@
"targets_list > /workspace/targets.list.address"
]
},
{
"name": "gcr.io/oss-fuzz-base/base-runner:ubuntu-24-04",
"env": [
"ARCHITECTURE=x86_64",
"FUZZING_ENGINE=centipede",
"FUZZING_LANGUAGE=c++",
"HOME=/root",
"OUT=/workspace/out/centipede-address-x86_64-ubuntu-24-04",
"SANITIZER=address"
],
"args": [
"bash",
"-c",
"targets_list > /workspace/targets.list.address"
]
},
{
"name": "gcr.io/oss-fuzz/test-project",
"args": [
Expand Down Expand Up @@ -450,6 +482,22 @@
"targets_list > /workspace/targets.list.none"
]
},
{
"name": "gcr.io/oss-fuzz-base/base-runner:ubuntu-24-04",
"env": [
"ARCHITECTURE=x86_64",
"FUZZING_ENGINE=centipede",
"FUZZING_LANGUAGE=c++",
"HOME=/root",
"OUT=/workspace/out/centipede-none-x86_64-ubuntu-24-04",
"SANITIZER=none"
],
"args": [
"bash",
"-c",
"targets_list > /workspace/targets.list.none"
]
},
{
"name": "gcr.io/oss-fuzz/test-project",
"args": [
Expand Down Expand Up @@ -591,6 +639,22 @@
"targets_list > /workspace/targets.list.address"
]
},
{
"name": "gcr.io/oss-fuzz-base/base-runner:ubuntu-24-04",
"env": [
"ARCHITECTURE=x86_64",
"FUZZING_ENGINE=honggfuzz",
"FUZZING_LANGUAGE=c++",
"HOME=/root",
"OUT=/workspace/out/honggfuzz-address-x86_64-ubuntu-24-04",
"SANITIZER=address"
],
"args": [
"bash",
"-c",
"targets_list > /workspace/targets.list.address"
]
},
{
"name": "gcr.io/oss-fuzz/test-project",
"args": [
Expand Down Expand Up @@ -732,6 +796,22 @@
"targets_list > /workspace/targets.list.address"
]
},
{
"name": "gcr.io/oss-fuzz-base/base-runner:ubuntu-24-04",
"env": [
"ARCHITECTURE=x86_64",
"FUZZING_ENGINE=libfuzzer",
"FUZZING_LANGUAGE=c++",
"HOME=/root",
"OUT=/workspace/out/libfuzzer-address-x86_64-ubuntu-24-04",
"SANITIZER=address"
],
"args": [
"bash",
"-c",
"targets_list > /workspace/targets.list.address"
]
},
{
"name": "gcr.io/oss-fuzz/test-project",
"args": [
Expand Down Expand Up @@ -873,6 +953,22 @@
"targets_list > /workspace/targets.list.address"
]
},
{
"name": "gcr.io/oss-fuzz-base/base-runner:ubuntu-24-04",
"env": [
"ARCHITECTURE=i386",
"FUZZING_ENGINE=libfuzzer",
"FUZZING_LANGUAGE=c++",
"HOME=/root",
"OUT=/workspace/out/libfuzzer-address-i386",
"SANITIZER=address"
],
"args": [
"bash",
"-c",
"targets_list > /workspace/targets.list.address"
]
},
{
"name": "gcr.io/oss-fuzz/test-project",
"args": [
Expand Down Expand Up @@ -1014,6 +1110,22 @@
"targets_list > /workspace/targets.list.address"
]
},
{
"name": "gcr.io/oss-fuzz-base/base-runner:ubuntu-24-04",
"env": [
"ARCHITECTURE=aarch64",
"FUZZING_ENGINE=libfuzzer",
"FUZZING_LANGUAGE=c++",
"HOME=/root",
"OUT=/workspace/out/libfuzzer-address-aarch64",
"SANITIZER=address"
],
"args": [
"bash",
"-c",
"targets_list > /workspace/targets.list.address"
]
},
{
"name": "gcr.io/oss-fuzz/test-project",
"args": [
Expand Down Expand Up @@ -1155,6 +1267,22 @@
"targets_list > /workspace/targets.list.memory"
]
},
{
"name": "gcr.io/oss-fuzz-base/base-runner:ubuntu-24-04",
"env": [
"ARCHITECTURE=x86_64",
"FUZZING_ENGINE=libfuzzer",
"FUZZING_LANGUAGE=c++",
"HOME=/root",
"OUT=/workspace/out/libfuzzer-memory-x86_64-ubuntu-24-04",
"SANITIZER=memory"
],
"args": [
"bash",
"-c",
"targets_list > /workspace/targets.list.memory"
]
},
{
"name": "gcr.io/oss-fuzz/test-project",
"args": [
Expand Down Expand Up @@ -1296,6 +1424,22 @@
"targets_list > /workspace/targets.list.undefined"
]
},
{
"name": "gcr.io/oss-fuzz-base/base-runner:ubuntu-24-04",
"env": [
"ARCHITECTURE=x86_64",
"FUZZING_ENGINE=libfuzzer",
"FUZZING_LANGUAGE=c++",
"HOME=/root",
"OUT=/workspace/out/libfuzzer-undefined-x86_64-ubuntu-24-04",
"SANITIZER=undefined"
],
"args": [
"bash",
"-c",
"targets_list > /workspace/targets.list.undefined"
]
},
{
"name": "gcr.io/oss-fuzz/test-project",
"args": [
Expand Down
Loading