Skip to content

Commit

Permalink
Add AFL++ support
Browse files Browse the repository at this point in the history
  • Loading branch information
jschwartzentruber committed Apr 30, 2024
1 parent aa8ed96 commit 1213cc9
Show file tree
Hide file tree
Showing 7 changed files with 311 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/fuzzfetch/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ def __init__(self) -> None:
action="store_true",
help="Download AddressSanitizer builds.",
)
build_group.add_argument(
"--afl", action="store_true", help="Download AFL++ builds."
)
build_group.add_argument(
"-t", "--tsan", action="store_true", help="Download ThreadSanitizer builds."
)
Expand Down
14 changes: 13 additions & 1 deletion src/fuzzfetch/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def __init__(
build: build identifier. acceptable identifiers are: TaskCluster
namespace, hg changeset, date, 'latest'
flags: ('asan', 'debug', 'fuzzing', 'coverage', 'valgrind', 'tsan',
'no_opt', 'fuzzilli', 'nyx'),
'no_opt', 'fuzzilli', 'nyx', 'searchfox', 'afl'),
each a bool, not all combinations exist in TaskCluster
platform: force platform if different than current system
nearest: Search for nearest build, not exact
Expand Down Expand Up @@ -115,11 +115,14 @@ def __init__(
fuzzilli,
nyx,
searchfox,
afl,
) = self._flags
if not debug:
debug = "-debug" in build or "-dbg" in build
if not asan:
asan = "-asan" in build
if not afl:
afl = "-afl" in build
if not tsan:
tsan = "-tsan" in build
if not fuzzing:
Expand All @@ -136,6 +139,8 @@ def __init__(
nyx = "-nyx" in build
if not searchfox:
searchfox = "-searchfox" in build
if not afl:
afl = "-afl" in build

self._flags = BuildFlags(
asan,
Expand All @@ -148,6 +153,7 @@ def __init__(
fuzzilli,
nyx,
searchfox,
afl,
)

# Validate flags
Expand Down Expand Up @@ -201,6 +207,11 @@ def __init__(
"'build' is not a searchfox build, but searchfox=True given "
f"(build={build})"
)
if self._flags.afl and "-afl" not in build:
raise FetcherException(
"'build' is not an AFL++ build, but afl=True given "
f"(build={build})"
)

# Attempt to fetch the build. If it fails and nearest is set, try and find
# the nearest build that matches
Expand Down Expand Up @@ -795,6 +806,7 @@ def from_args(
args.fuzzilli,
args.nyx,
args.searchfox,
args.afl,
)
obj = cls(
args.branch,
Expand Down
2 changes: 2 additions & 0 deletions src/fuzzfetch/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class BuildFlags(
"fuzzilli",
"nyx",
"searchfox",
"afl",
),
)
):
Expand All @@ -53,6 +54,7 @@ def build_string(self) -> str:
+ ("-fuzzing" if self.fuzzing else "")
+ ("-asan" if self.asan else "")
+ ("-tsan" if self.tsan else "")
+ ("-afl" if self.afl else "")
+ ("-nyx" if self.nyx else "")
+ ("-valgrind" if self.valgrind else "")
+ ("-noopt" if self.no_opt else "")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"namespace": "gecko.v2.mozilla-central.latest.firefox.linux64-fuzzing-asan-afl-opt",
"taskId": "Qsu15jVeRGeYGaPva8g7Xw",
"rank": 1714491282,
"data": {},
"expires": "2025-04-30T15:40:22.845Z"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,256 @@
{
"artifacts": [
{
"storageType": "s3",
"name": "public/build/buildhub.json",
"expires": "2025-04-30T15:40:22.845Z",
"contentType": "application/json"
},
{
"storageType": "s3",
"name": "public/build/config.status",
"expires": "2025-04-30T15:40:22.845Z",
"contentType": "application/octet-stream"
},
{
"storageType": "s3",
"name": "public/build/host/bin/mar",
"expires": "2025-04-30T15:40:22.845Z",
"contentType": "application/octet-stream"
},
{
"storageType": "s3",
"name": "public/build/host/bin/mbsdiff",
"expires": "2025-04-30T15:40:22.845Z",
"contentType": "application/octet-stream"
},
{
"storageType": "s3",
"name": "public/build/mozharness.zip",
"expires": "2025-04-30T15:40:22.845Z",
"contentType": "application/zip"
},
{
"storageType": "s3",
"name": "public/build/profile_build_resources.json",
"expires": "2025-04-30T15:40:22.845Z",
"contentType": "application/json"
},
{
"storageType": "s3",
"name": "public/build/target.awsy.tests.tar.gz",
"expires": "2025-04-30T15:40:22.845Z",
"contentType": "application/gzip"
},
{
"storageType": "s3",
"name": "public/build/target.checksums",
"expires": "2025-04-30T15:40:22.845Z",
"contentType": "application/octet-stream"
},
{
"storageType": "s3",
"name": "public/build/target.common.tests.tar.gz",
"expires": "2025-04-30T15:40:22.845Z",
"contentType": "application/gzip"
},
{
"storageType": "s3",
"name": "public/build/target.condprof.tests.tar.gz",
"expires": "2025-04-30T15:40:22.845Z",
"contentType": "application/gzip"
},
{
"storageType": "s3",
"name": "public/build/target.cppunittest.tests.tar.gz",
"expires": "2025-04-30T15:40:22.845Z",
"contentType": "application/gzip"
},
{
"storageType": "s3",
"name": "public/build/target.fuzztest.tests.tar.gz",
"expires": "2025-04-30T15:40:22.845Z",
"contentType": "application/gzip"
},
{
"storageType": "s3",
"name": "public/build/target.generated-files.tar.gz",
"expires": "2025-04-30T15:40:22.845Z",
"contentType": "application/gzip"
},
{
"storageType": "s3",
"name": "public/build/target.gtest.tests.tar.gz",
"expires": "2025-04-30T15:40:22.845Z",
"contentType": "application/gzip"
},
{
"storageType": "s3",
"name": "public/build/target_info.txt",
"expires": "2025-04-30T15:40:22.845Z",
"contentType": "text/plain"
},
{
"storageType": "s3",
"name": "public/build/target.jittest.tests.tar.gz",
"expires": "2025-04-30T15:40:22.845Z",
"contentType": "application/gzip"
},
{
"storageType": "s3",
"name": "public/build/target.json",
"expires": "2025-04-30T15:40:22.845Z",
"contentType": "application/json"
},
{
"storageType": "s3",
"name": "public/build/target.jsreftest.tests.tar.gz",
"expires": "2025-04-30T15:40:22.845Z",
"contentType": "application/gzip"
},
{
"storageType": "s3",
"name": "public/build/target.jsshell.zip",
"expires": "2025-04-30T15:40:22.845Z",
"contentType": "application/zip"
},
{
"storageType": "s3",
"name": "public/build/target.langpack.xpi",
"expires": "2025-04-30T15:40:22.845Z",
"contentType": "application/x-xpinstall"
},
{
"storageType": "s3",
"name": "public/build/target.mochitest.tests.tar.gz",
"expires": "2025-04-30T15:40:22.845Z",
"contentType": "application/gzip"
},
{
"storageType": "s3",
"name": "public/build/target.mozinfo.json",
"expires": "2025-04-30T15:40:22.845Z",
"contentType": "application/json"
},
{
"storageType": "s3",
"name": "public/build/target.perftests.tests.tar.gz",
"expires": "2025-04-30T15:40:22.845Z",
"contentType": "application/gzip"
},
{
"storageType": "s3",
"name": "public/build/target.raptor.tests.tar.gz",
"expires": "2025-04-30T15:40:22.845Z",
"contentType": "application/gzip"
},
{
"storageType": "s3",
"name": "public/build/target.reftest.tests.tar.gz",
"expires": "2025-04-30T15:40:22.845Z",
"contentType": "application/gzip"
},
{
"storageType": "s3",
"name": "public/build/target.talos.tests.tar.gz",
"expires": "2025-04-30T15:40:22.845Z",
"contentType": "application/gzip"
},
{
"storageType": "s3",
"name": "public/build/target.tar.bz2",
"expires": "2025-04-30T15:40:22.845Z",
"contentType": "application/x-bzip2"
},
{
"storageType": "s3",
"name": "public/build/target.test_packages.json",
"expires": "2025-04-30T15:40:22.845Z",
"contentType": "application/json"
},
{
"storageType": "s3",
"name": "public/build/target.txt",
"expires": "2025-04-30T15:40:22.845Z",
"contentType": "text/plain"
},
{
"storageType": "s3",
"name": "public/build/target.updater-dep.tests.tar.gz",
"expires": "2025-04-30T15:40:22.845Z",
"contentType": "application/gzip"
},
{
"storageType": "s3",
"name": "public/build/target.web-platform.tests.tar.gz",
"expires": "2025-04-30T15:40:22.845Z",
"contentType": "application/gzip"
},
{
"storageType": "s3",
"name": "public/build/target.xpcshell.tests.tar.gz",
"expires": "2025-04-30T15:40:22.845Z",
"contentType": "application/gzip"
},
{
"storageType": "s3",
"name": "public/build/target.xpt_artifacts.zip",
"expires": "2025-04-30T15:40:22.845Z",
"contentType": "application/zip"
},
{
"storageType": "s3",
"name": "public/chain-of-trust.json",
"expires": "2025-04-30T15:40:22.845Z",
"contentType": "text/plain"
},
{
"storageType": "s3",
"name": "public/chain-of-trust.json.sig",
"expires": "2025-04-30T15:40:22.845Z",
"contentType": "application/octet-stream"
},
{
"storageType": "s3",
"name": "public/cidata/sccache.log",
"expires": "2024-05-07T15:40:22.845Z",
"contentType": "text/plain"
},
{
"storageType": "s3",
"name": "public/cidata/sccache-stats.json",
"expires": "2024-05-07T15:40:22.845Z",
"contentType": "application/json"
},
{
"storageType": "error",
"name": "public/cidata/target.crashreporter-symbols-full.tar.zst",
"expires": "2024-05-07T15:40:22.845Z",
"contentType": "application/binary"
},
{
"storageType": "s3",
"name": "public/logs/certified.log",
"expires": "2025-04-30T15:40:22.845Z",
"contentType": "text/plain"
},
{
"storageType": "s3",
"name": "public/logs/live_backing.log",
"expires": "2025-04-30T15:40:22.845Z",
"contentType": "text/plain; charset=utf-8"
},
{
"storageType": "reference",
"name": "public/logs/live.log",
"expires": "2025-04-30T15:40:22.845Z",
"contentType": "text/plain; charset=utf-8"
},
{
"storageType": "s3",
"name": "public/logs/localconfig.json",
"expires": "2025-04-30T15:40:22.845Z",
"contentType": "application/json"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"as": "/builds/worker/fetches/sccache/sccache /builds/worker/fetches/afl-instrumentation/bin/afl-clang-fast --sysroot /builds/worker/fetches/sysroot-x86_64-linux-gnu -std=gnu99",
"buildid": "20240430153442",
"cc": "/builds/worker/fetches/sccache/sccache /builds/worker/fetches/afl-instrumentation/bin/afl-clang-fast --sysroot /builds/worker/fetches/sysroot-x86_64-linux-gnu -std=gnu99",
"cxx": "/builds/worker/fetches/sccache/sccache /builds/worker/fetches/afl-instrumentation/bin/afl-clang-fast++ --sysroot /builds/worker/fetches/sysroot-x86_64-linux-gnu",
"host_alias": "x86_64-pc-linux-gnu",
"moz_app_id": "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}",
"moz_app_maxversion": "127.0a1",
"moz_app_name": "firefox",
"moz_app_vendor": "Mozilla",
"moz_app_version": "127.0a1",
"moz_pkg_platform": "linux-x86_64-asan",
"moz_source_repo": "https://hg.mozilla.org/mozilla-central",
"moz_source_stamp": "5502377f2629549b2b7c5368c980d0487ed281d4",
"moz_update_channel": "default",
"target_alias": "x86_64-pc-linux-gnu"
}
13 changes: 13 additions & 0 deletions tests/test_fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,3 +300,16 @@ def test_searchfox_data():
build_flags_factory(searchfox=True, debug=True),
["searchfox"],
)


@pytest.mark.usefixtures("fetcher_mock_resolve_targets", "requests_mock_cache")
def test_afl_builds():
"""
Test for retrieving AFL++ enabled builds
"""
Fetcher(
"central",
"latest",
build_flags_factory(asan=True, fuzzing=True, afl=True),
DEFAULT_TARGETS,
)

0 comments on commit 1213cc9

Please sign in to comment.