/src/curl_fuzzer/proto_fuzzer/target_profile.h
Line | Count | Source |
1 | | /* |
2 | | * Copyright (C) Max Dymond, <cmeister2@gmail.com>, et al. |
3 | | * |
4 | | * SPDX-License-Identifier: curl |
5 | | */ |
6 | | |
7 | | /// @file |
8 | | /// @brief Compile-time identities and execution modes for proto fuzz targets. |
9 | | |
10 | | #ifndef PROTO_FUZZER_TARGET_PROFILE_H_ |
11 | | #define PROTO_FUZZER_TARGET_PROFILE_H_ |
12 | | |
13 | | namespace proto_fuzzer { |
14 | | |
15 | | /// Identifies one compiled proto-fuzzer lane. A profile is the single source |
16 | | /// of truth for both mutation constraints and runtime coverage policy, which |
17 | | /// prevents independent flags from describing combinations no target uses. |
18 | | enum class TargetProfile { |
19 | | /// Preserve the original mixed target and its accumulated corpus exactly. |
20 | | kCompatibility, |
21 | | /// Keep ordinary HTTP iterations competitive with the legacy byte fuzzers. |
22 | | kFastHttp, |
23 | | /// Retain HTTP's complete structured request and response surface. |
24 | | kDeepHttp, |
25 | | /// Exercise a complete HTTPS exchange against the in-process TLS peer. |
26 | | kFastHttps, |
27 | | /// Exercise raw HTTP/2 origin frames after a verified TLS/ALPN handshake. |
28 | | kHttpsH2, |
29 | | /// Exercise HTTP/3 over a valid in-process QUIC/TLS connection. |
30 | | kFastHttp3, |
31 | | /// Exercise an HTTP/1.1 origin through an HTTPS/HTTP2 CONNECT proxy. |
32 | | kH2Proxy, |
33 | | /// Exercise HTTP through an in-process SOCKS4/SOCKS4A proxy. |
34 | | kSocks4, |
35 | | /// Exercise localhost lookup and structured CURLOPT_RESOLVE host-cache work. |
36 | | kResolver, |
37 | | /// Exercise plaintext WebSocket framing without wall-clock waits. |
38 | | kFastWebSocket, |
39 | | /// Exercise secure WebSocket setup without wall-clock waits. |
40 | | kFastSecureWebSocket, |
41 | | /// Exercise bounded TELNET negotiation and callback-backed input. |
42 | | kFastTelnet, |
43 | | /// Exercise FTP control and passive data connections without external I/O. |
44 | | kFastFtp, |
45 | | /// Exercise packet-preserving TFTP exchanges over the loopback UDP peer. |
46 | | kFastTftp, |
47 | | /// Exercise Gopher selectors through the bounded stream peer. |
48 | | kFastGopher, |
49 | | /// Exercise easy, share, multi, URL, and result API lifecycles. |
50 | | kApi, |
51 | | /// Exercise several easy handles through one shared multi handle. |
52 | | kMulti, |
53 | | /// Isolate deterministic backpressure and timed-wait behavior. |
54 | | kTiming, |
55 | | }; |
56 | | |
57 | | /// Selects one of the complete, valid RunScenario behaviours. Keeping this |
58 | | /// closed set avoids boolean combinations that have no useful interpretation. |
59 | | enum class ScenarioRunMode { |
60 | | /// Drive the protocol without charging its hot loop for generic API probes. |
61 | | kFastProtocol, |
62 | | /// Drive the protocol and inspect a compact set of public result APIs. |
63 | | kProtocolCoverage, |
64 | | /// Drive deep HTTP plus its bounded filename-backed parser inputs. |
65 | | kDeepHttpCoverage, |
66 | | /// Drive HTTPS through a real TLS peer and inspect live TLS result state. |
67 | | kTlsCoverage, |
68 | | /// Drive an HTTPS origin through fixed ALPN h2 with push/upkeep probes. |
69 | | kTlsHttp2Coverage, |
70 | | /// Drive ordered plaintext HTTP/3 actions through the QUIC peer. |
71 | | kHttp3Coverage, |
72 | | /// Drive raw HTTP/2 proxy frames around one CONNECT tunnel. |
73 | | kH2ProxyCoverage, |
74 | | /// Drive a request-triggered SOCKS4 reply followed by tunneled HTTP. |
75 | | kSocks4Coverage, |
76 | | /// Let curl resolve the origin while the socket callback still owns I/O. |
77 | | kResolverCoverage, |
78 | | /// Drive FTP through its concurrent control/passive-data peer. |
79 | | kFtpCoverage, |
80 | | /// Drive TFTP through its datagram-preserving loopback peer. |
81 | | kTftpCoverage, |
82 | | /// Drive Gopher through the bounded stream peer. |
83 | | kGopherCoverage, |
84 | | /// Honour ApiPlan and run the dedicated lifecycle and typed-result probes. |
85 | | kApiLifecycle, |
86 | | /// Honour MultiPlan and drive several HTTP transfers through one multi. |
87 | | kMultiTransfer, |
88 | | }; |
89 | | |
90 | | /// Derive runtime behaviour from the compiled target identity. Mutation policy |
91 | | /// remains profile-specific, while targets that need the same execution cost |
92 | | /// deliberately share a run mode. |
93 | | /// @param profile Compiled target whose runner behaviour is required. |
94 | | /// @return The only RunScenario mode valid for that target. |
95 | 287k | constexpr ScenarioRunMode RunModeFor(TargetProfile profile) { |
96 | 287k | switch (profile) { |
97 | 19.6k | case TargetProfile::kFastHttp: |
98 | 23.6k | case TargetProfile::kFastTelnet: |
99 | 23.6k | return ScenarioRunMode::kFastProtocol; |
100 | | |
101 | 20.6k | case TargetProfile::kApi: |
102 | 20.6k | return ScenarioRunMode::kApiLifecycle; |
103 | | |
104 | 19.9k | case TargetProfile::kMulti: |
105 | 19.9k | return ScenarioRunMode::kMultiTransfer; |
106 | | |
107 | 55.6k | case TargetProfile::kFastHttps: |
108 | 55.6k | return ScenarioRunMode::kTlsCoverage; |
109 | | |
110 | 10.8k | case TargetProfile::kHttpsH2: |
111 | 10.8k | return ScenarioRunMode::kTlsHttp2Coverage; |
112 | | |
113 | 7.04k | case TargetProfile::kFastHttp3: |
114 | 7.04k | return ScenarioRunMode::kHttp3Coverage; |
115 | | |
116 | 11.3k | case TargetProfile::kH2Proxy: |
117 | 11.3k | return ScenarioRunMode::kH2ProxyCoverage; |
118 | | |
119 | 11.7k | case TargetProfile::kSocks4: |
120 | 11.7k | return ScenarioRunMode::kSocks4Coverage; |
121 | | |
122 | 12.5k | case TargetProfile::kResolver: |
123 | 12.5k | return ScenarioRunMode::kResolverCoverage; |
124 | | |
125 | 9.03k | case TargetProfile::kFastFtp: |
126 | 9.03k | return ScenarioRunMode::kFtpCoverage; |
127 | | |
128 | 2.01k | case TargetProfile::kFastTftp: |
129 | 2.01k | return ScenarioRunMode::kTftpCoverage; |
130 | | |
131 | 9.63k | case TargetProfile::kFastGopher: |
132 | 9.63k | return ScenarioRunMode::kGopherCoverage; |
133 | | |
134 | 25.7k | case TargetProfile::kCompatibility: |
135 | 38.2k | case TargetProfile::kFastWebSocket: |
136 | 48.6k | case TargetProfile::kFastSecureWebSocket: |
137 | 66.2k | case TargetProfile::kTiming: |
138 | 66.2k | return ScenarioRunMode::kProtocolCoverage; |
139 | | |
140 | 26.8k | case TargetProfile::kDeepHttp: |
141 | 26.8k | return ScenarioRunMode::kDeepHttpCoverage; |
142 | 287k | } |
143 | 0 | return ScenarioRunMode::kProtocolCoverage; |
144 | 287k | } |
145 | | |
146 | | } // namespace proto_fuzzer |
147 | | |
148 | | #endif // PROTO_FUZZER_TARGET_PROFILE_H_ |