Skip to content

Commit b89d883

Browse files
committed
fix(build): Dynamically tag base images for Ubuntu 24.04
This commit addresses the issue where builds for Ubuntu 24.04 projects were incorrectly using the ':latest' tag for base images, leading to build failures. Changes include: - Added 'ubuntu_version' to the 'Project' class, defaulting to 'legacy'. - Modified 'create_config' to accept and pass 'base_image_tag' to the 'Config' object. - Updated calls to 'build_lib.get_runner_image_name' to use 'config.base_image_tag'. - Updated 'expected_build_steps.json' to reflect the new 'ubuntu-24-04' image tags in test data. This ensures that projects specifying 'ubuntu-24-04' in their 'project.yaml' will correctly pull the versioned base images, while projects without a specified version will continue to use ':latest' (legacy).
1 parent c92fcc1 commit b89d883

File tree

2 files changed

+151
-3
lines changed

2 files changed

+151
-3
lines changed

infra/build/functions/build_project.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ def __init__(self, name, project_yaml, dockerfile):
179179
self.labels = project_yaml['labels']
180180
self.fuzzing_language = project_yaml['language']
181181
self.run_tests = project_yaml['run_tests']
182+
self.ubuntu_version = project_yaml.get('ubuntu_version', 'legacy')
182183
if 'main_repo' in project_yaml:
183184
self.main_repo = project_yaml['main_repo']
184185
else:
@@ -488,7 +489,7 @@ def get_build_steps_for_project(project,
488489
# Generate targets list.
489490
{
490491
'name':
491-
build_lib.get_runner_image_name(config.test_image_suffix),
492+
build_lib.get_runner_image_name(config.test_image_suffix, config.base_image_tag),
492493
'env':
493494
env,
494495
'args': [
@@ -828,11 +829,12 @@ def parse_args(description, args):
828829
return parser.parse_args(args)
829830

830831

831-
def create_config(args, build_type):
832+
def create_config(args, build_type, base_image_tag=None):
832833
"""Create a Config object from parsed command line |args|."""
833834
upload = not args.experiment
834835
return Config(testing=args.testing,
835836
test_image_suffix=args.test_image_suffix,
837+
base_image_tag=base_image_tag,
836838
branch=args.branch,
837839
parallel=args.parallel,
838840
upload=upload,
@@ -855,7 +857,6 @@ def build_script_main(script_description,
855857

856858
credentials = oauth2client.client.GoogleCredentials.get_application_default()
857859
error = False
858-
config = create_config(args, build_type)
859860
for project_name in args.projects:
860861
try:
861862
project_yaml, dockerfile_contents = get_project_data(project_name)
@@ -864,6 +865,9 @@ def build_script_main(script_description,
864865
error = True
865866
continue
866867

868+
ubuntu_version = project_yaml.get('ubuntu_version', 'legacy')
869+
config = create_config(args, build_type, base_image_tag=ubuntu_version)
870+
867871
steps = get_build_steps_func(project_name, project_yaml,
868872
dockerfile_contents, config)
869873
if not steps:

infra/build/functions/test_data/expected_build_steps.json

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,22 @@
168168
"targets_list > /workspace/targets.list.address"
169169
]
170170
},
171+
{
172+
"name": "gcr.io/oss-fuzz-base/base-runner:ubuntu-24-04",
173+
"env": [
174+
"ARCHITECTURE=x86_64",
175+
"FUZZING_ENGINE=afl",
176+
"FUZZING_LANGUAGE=c++",
177+
"HOME=/root",
178+
"OUT=/workspace/out/afl-address-x86_64-ubuntu-24-04",
179+
"SANITIZER=address"
180+
],
181+
"args": [
182+
"bash",
183+
"-c",
184+
"targets_list > /workspace/targets.list.address"
185+
]
186+
},
171187
{
172188
"name": "gcr.io/oss-fuzz/test-project",
173189
"args": [
@@ -309,6 +325,22 @@
309325
"targets_list > /workspace/targets.list.address"
310326
]
311327
},
328+
{
329+
"name": "gcr.io/oss-fuzz-base/base-runner:ubuntu-24-04",
330+
"env": [
331+
"ARCHITECTURE=x86_64",
332+
"FUZZING_ENGINE=centipede",
333+
"FUZZING_LANGUAGE=c++",
334+
"HOME=/root",
335+
"OUT=/workspace/out/centipede-address-x86_64-ubuntu-24-04",
336+
"SANITIZER=address"
337+
],
338+
"args": [
339+
"bash",
340+
"-c",
341+
"targets_list > /workspace/targets.list.address"
342+
]
343+
},
312344
{
313345
"name": "gcr.io/oss-fuzz/test-project",
314346
"args": [
@@ -450,6 +482,22 @@
450482
"targets_list > /workspace/targets.list.none"
451483
]
452484
},
485+
{
486+
"name": "gcr.io/oss-fuzz-base/base-runner:ubuntu-24-04",
487+
"env": [
488+
"ARCHITECTURE=x86_64",
489+
"FUZZING_ENGINE=centipede",
490+
"FUZZING_LANGUAGE=c++",
491+
"HOME=/root",
492+
"OUT=/workspace/out/centipede-none-x86_64-ubuntu-24-04",
493+
"SANITIZER=none"
494+
],
495+
"args": [
496+
"bash",
497+
"-c",
498+
"targets_list > /workspace/targets.list.none"
499+
]
500+
},
453501
{
454502
"name": "gcr.io/oss-fuzz/test-project",
455503
"args": [
@@ -591,6 +639,22 @@
591639
"targets_list > /workspace/targets.list.address"
592640
]
593641
},
642+
{
643+
"name": "gcr.io/oss-fuzz-base/base-runner:ubuntu-24-04",
644+
"env": [
645+
"ARCHITECTURE=x86_64",
646+
"FUZZING_ENGINE=honggfuzz",
647+
"FUZZING_LANGUAGE=c++",
648+
"HOME=/root",
649+
"OUT=/workspace/out/honggfuzz-address-x86_64-ubuntu-24-04",
650+
"SANITIZER=address"
651+
],
652+
"args": [
653+
"bash",
654+
"-c",
655+
"targets_list > /workspace/targets.list.address"
656+
]
657+
},
594658
{
595659
"name": "gcr.io/oss-fuzz/test-project",
596660
"args": [
@@ -732,6 +796,22 @@
732796
"targets_list > /workspace/targets.list.address"
733797
]
734798
},
799+
{
800+
"name": "gcr.io/oss-fuzz-base/base-runner:ubuntu-24-04",
801+
"env": [
802+
"ARCHITECTURE=x86_64",
803+
"FUZZING_ENGINE=libfuzzer",
804+
"FUZZING_LANGUAGE=c++",
805+
"HOME=/root",
806+
"OUT=/workspace/out/libfuzzer-address-x86_64-ubuntu-24-04",
807+
"SANITIZER=address"
808+
],
809+
"args": [
810+
"bash",
811+
"-c",
812+
"targets_list > /workspace/targets.list.address"
813+
]
814+
},
735815
{
736816
"name": "gcr.io/oss-fuzz/test-project",
737817
"args": [
@@ -873,6 +953,22 @@
873953
"targets_list > /workspace/targets.list.address"
874954
]
875955
},
956+
{
957+
"name": "gcr.io/oss-fuzz-base/base-runner:ubuntu-24-04",
958+
"env": [
959+
"ARCHITECTURE=i386",
960+
"FUZZING_ENGINE=libfuzzer",
961+
"FUZZING_LANGUAGE=c++",
962+
"HOME=/root",
963+
"OUT=/workspace/out/libfuzzer-address-i386",
964+
"SANITIZER=address"
965+
],
966+
"args": [
967+
"bash",
968+
"-c",
969+
"targets_list > /workspace/targets.list.address"
970+
]
971+
},
876972
{
877973
"name": "gcr.io/oss-fuzz/test-project",
878974
"args": [
@@ -1014,6 +1110,22 @@
10141110
"targets_list > /workspace/targets.list.address"
10151111
]
10161112
},
1113+
{
1114+
"name": "gcr.io/oss-fuzz-base/base-runner:ubuntu-24-04",
1115+
"env": [
1116+
"ARCHITECTURE=aarch64",
1117+
"FUZZING_ENGINE=libfuzzer",
1118+
"FUZZING_LANGUAGE=c++",
1119+
"HOME=/root",
1120+
"OUT=/workspace/out/libfuzzer-address-aarch64",
1121+
"SANITIZER=address"
1122+
],
1123+
"args": [
1124+
"bash",
1125+
"-c",
1126+
"targets_list > /workspace/targets.list.address"
1127+
]
1128+
},
10171129
{
10181130
"name": "gcr.io/oss-fuzz/test-project",
10191131
"args": [
@@ -1155,6 +1267,22 @@
11551267
"targets_list > /workspace/targets.list.memory"
11561268
]
11571269
},
1270+
{
1271+
"name": "gcr.io/oss-fuzz-base/base-runner:ubuntu-24-04",
1272+
"env": [
1273+
"ARCHITECTURE=x86_64",
1274+
"FUZZING_ENGINE=libfuzzer",
1275+
"FUZZING_LANGUAGE=c++",
1276+
"HOME=/root",
1277+
"OUT=/workspace/out/libfuzzer-memory-x86_64-ubuntu-24-04",
1278+
"SANITIZER=memory"
1279+
],
1280+
"args": [
1281+
"bash",
1282+
"-c",
1283+
"targets_list > /workspace/targets.list.memory"
1284+
]
1285+
},
11581286
{
11591287
"name": "gcr.io/oss-fuzz/test-project",
11601288
"args": [
@@ -1296,6 +1424,22 @@
12961424
"targets_list > /workspace/targets.list.undefined"
12971425
]
12981426
},
1427+
{
1428+
"name": "gcr.io/oss-fuzz-base/base-runner:ubuntu-24-04",
1429+
"env": [
1430+
"ARCHITECTURE=x86_64",
1431+
"FUZZING_ENGINE=libfuzzer",
1432+
"FUZZING_LANGUAGE=c++",
1433+
"HOME=/root",
1434+
"OUT=/workspace/out/libfuzzer-undefined-x86_64-ubuntu-24-04",
1435+
"SANITIZER=undefined"
1436+
],
1437+
"args": [
1438+
"bash",
1439+
"-c",
1440+
"targets_list > /workspace/targets.list.undefined"
1441+
]
1442+
},
12991443
{
13001444
"name": "gcr.io/oss-fuzz/test-project",
13011445
"args": [

0 commit comments

Comments
 (0)