Skip to content

Commit 9edd63a

Browse files
committed
Add in dynamic matrix generation for curl fuzzers
1 parent 02120b1 commit 9edd63a

File tree

3 files changed

+56
-21
lines changed

3 files changed

+56
-21
lines changed

.github/workflows/ci.yml

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,23 @@ concurrency:
1717
cancel-in-progress: true
1818

1919
jobs:
20+
DetermineMatrix:
21+
runs-on: ubuntu-latest
22+
outputs:
23+
matrix: ${{ steps.set-matrix.outputs.matrix }}
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
27+
with:
28+
repository: curl/curl-fuzzer
29+
- name: Install uv
30+
uses: astral-sh/setup-uv@v5
31+
- name: Set matrix
32+
id: set-matrix
33+
run: |
34+
. ./scripts/fuzz_targets
35+
uv run generate_matrix | tee $GITHUB_OUTPUT
36+
2037
BuildFuzzers:
2138
runs-on: ubuntu-latest
2239
steps:
@@ -40,28 +57,10 @@ jobs:
4057
path: fuzz.tar
4158

4259
RunFuzzers:
43-
needs: BuildFuzzers
60+
needs: [ BuildFuzzers, DetermineMatrix ]
4461
runs-on: ubuntu-latest
4562
strategy:
46-
matrix:
47-
fuzzer:
48-
- curl_fuzzer_bufq
49-
- curl_fuzzer_dict
50-
- curl_fuzzer_file
51-
- curl_fuzzer_ftp
52-
- curl_fuzzer_gopher
53-
- curl_fuzzer_http
54-
- curl_fuzzer_https
55-
- curl_fuzzer_imap
56-
- curl_fuzzer_mqtt
57-
- curl_fuzzer_pop3
58-
- curl_fuzzer_rtsp
59-
- curl_fuzzer_smb
60-
- curl_fuzzer_smtp
61-
- curl_fuzzer_tftp
62-
- curl_fuzzer_ws
63-
- curl_fuzzer
64-
- fuzz_url
63+
matrix: ${{ fromJSON(needs.DetermineMatrix.outputs.matrix) }}
6564
steps:
6665
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
6766
with:
@@ -113,7 +112,7 @@ jobs:
113112
- name: Checkout
114113
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
115114
with:
116-
repository: curl/curl-fuzzer
115+
repository: curl/curl-fuzzer
117116
- name: Install Dependencies
118117
run: |
119118
sudo apt-get update

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ dependencies = ["scapy (>=2.6.1,<3.0.0)"]
2828
read_corpus = "curl_fuzzer_tools.read_corpus:run"
2929
generate_corpus = "curl_fuzzer_tools.generate_corpus:run"
3030
corpus_to_pcap = "curl_fuzzer_tools.corpus_to_pcap:run"
31+
generate_matrix = "curl_fuzzer_tools.generate_matrix:run"
3132

3233
[build-system]
3334
requires = ["setuptools>=61.0"]
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env python3
2+
"""Generate a matrix of fuzzers for Github Actions"""
3+
4+
import json
5+
import logging
6+
import os
7+
import sys
8+
9+
log = logging.getLogger(__name__)
10+
11+
def main() -> None:
12+
"""Main function"""
13+
# Get FUZZ_TARGETS from the environment
14+
fuzz_targets = os.getenv("FUZZ_TARGETS", "")
15+
log.info("Fuzz targets: %s", fuzz_targets)
16+
if not fuzz_targets:
17+
log.error("No fuzz targets found in the environment variable FUZZ_TARGETS")
18+
19+
# Split the targets by whitespace
20+
targets = fuzz_targets.split()
21+
log.info("Parsed targets: %s", targets)
22+
23+
# Generate a matrix for Github Actions
24+
output_data = {
25+
"fuzzer": targets
26+
}
27+
print(f"matrix={json.dumps(output_data)}")
28+
29+
def run() -> None:
30+
"""Run the main function"""
31+
logging.basicConfig(level=logging.INFO, stream=sys.stderr)
32+
main()
33+
34+
if __name__ == "__main__":
35+
run()

0 commit comments

Comments
 (0)