/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 plaintext WebSocket framing without wall-clock waits. |
28 | | kFastWebSocket, |
29 | | /// Exercise secure WebSocket setup without wall-clock waits. |
30 | | kFastSecureWebSocket, |
31 | | /// Exercise bounded TELNET negotiation and callback-backed input. |
32 | | kFastTelnet, |
33 | | /// Exercise FTP control and passive data connections without external I/O. |
34 | | kFastFtp, |
35 | | /// Exercise packet-preserving TFTP exchanges over the loopback UDP peer. |
36 | | kFastTftp, |
37 | | /// Exercise easy, share, multi, URL, and result API lifecycles. |
38 | | kApi, |
39 | | /// Isolate deterministic backpressure and timed-wait behavior. |
40 | | kTiming, |
41 | | }; |
42 | | |
43 | | /// Selects one of the complete, valid ScenarioRunner behaviours. Keeping this |
44 | | /// closed set avoids boolean combinations that have no useful interpretation. |
45 | | enum class ScenarioRunMode { |
46 | | /// Drive the protocol without charging its hot loop for generic API probes. |
47 | | kFastProtocol, |
48 | | /// Drive the protocol and inspect a compact set of public result APIs. |
49 | | kProtocolCoverage, |
50 | | /// Drive HTTPS through a real TLS peer and inspect live TLS result state. |
51 | | kTlsCoverage, |
52 | | /// Drive FTP through its concurrent control/passive-data peer. |
53 | | kFtpCoverage, |
54 | | /// Drive TFTP through its datagram-preserving loopback peer. |
55 | | kTftpCoverage, |
56 | | /// Honour ApiPlan and run the dedicated lifecycle and typed-result probes. |
57 | | kApiLifecycle, |
58 | | }; |
59 | | |
60 | | /// Derive runtime behaviour from the compiled target identity. Mutation policy |
61 | | /// remains profile-specific, while targets that need the same execution cost |
62 | | /// deliberately share a run mode. |
63 | | /// @param profile Compiled target whose runner behaviour is required. |
64 | | /// @return The only ScenarioRunner mode valid for that target. |
65 | 38.3k | constexpr ScenarioRunMode RunModeFor(TargetProfile profile) { |
66 | 38.3k | switch (profile) { |
67 | 4.51k | case TargetProfile::kFastHttp: |
68 | 7.08k | case TargetProfile::kFastTelnet: |
69 | 7.08k | return ScenarioRunMode::kFastProtocol; |
70 | | |
71 | 0 | case TargetProfile::kApi: |
72 | 0 | return ScenarioRunMode::kApiLifecycle; |
73 | | |
74 | 3.73k | case TargetProfile::kFastHttps: |
75 | 3.73k | return ScenarioRunMode::kTlsCoverage; |
76 | | |
77 | 0 | case TargetProfile::kFastFtp: |
78 | 0 | return ScenarioRunMode::kFtpCoverage; |
79 | | |
80 | 0 | case TargetProfile::kFastTftp: |
81 | 0 | return ScenarioRunMode::kTftpCoverage; |
82 | | |
83 | 15.6k | case TargetProfile::kCompatibility: |
84 | 20.6k | case TargetProfile::kDeepHttp: |
85 | 20.6k | case TargetProfile::kFastWebSocket: |
86 | 23.8k | case TargetProfile::kFastSecureWebSocket: |
87 | 27.5k | case TargetProfile::kTiming: |
88 | 27.5k | return ScenarioRunMode::kProtocolCoverage; |
89 | 38.3k | } |
90 | 0 | return ScenarioRunMode::kProtocolCoverage; |
91 | 38.3k | } |
92 | | |
93 | | } // namespace proto_fuzzer |
94 | | |
95 | | #endif // PROTO_FUZZER_TARGET_PROFILE_H_ |