Coverage Report

Created: 2026-09-04 07:25

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/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 an HTTP/1.1 origin through an HTTPS/HTTP2 CONNECT proxy.
28
  kH2Proxy,
29
  /// Exercise plaintext WebSocket framing without wall-clock waits.
30
  kFastWebSocket,
31
  /// Exercise secure WebSocket setup without wall-clock waits.
32
  kFastSecureWebSocket,
33
  /// Exercise bounded TELNET negotiation and callback-backed input.
34
  kFastTelnet,
35
  /// Exercise FTP control and passive data connections without external I/O.
36
  kFastFtp,
37
  /// Exercise packet-preserving TFTP exchanges over the loopback UDP peer.
38
  kFastTftp,
39
  /// Exercise easy, share, multi, URL, and result API lifecycles.
40
  kApi,
41
  /// Exercise several easy handles through one shared multi handle.
42
  kMulti,
43
  /// Isolate deterministic backpressure and timed-wait behavior.
44
  kTiming,
45
};
46
47
/// Selects one of the complete, valid ScenarioRunner behaviours. Keeping this
48
/// closed set avoids boolean combinations that have no useful interpretation.
49
enum class ScenarioRunMode {
50
  /// Drive the protocol without charging its hot loop for generic API probes.
51
  kFastProtocol,
52
  /// Drive the protocol and inspect a compact set of public result APIs.
53
  kProtocolCoverage,
54
  /// Drive HTTPS through a real TLS peer and inspect live TLS result state.
55
  kTlsCoverage,
56
  /// Drive raw HTTP/2 proxy frames around one CONNECT tunnel.
57
  kH2ProxyCoverage,
58
  /// Drive FTP through its concurrent control/passive-data peer.
59
  kFtpCoverage,
60
  /// Drive TFTP through its datagram-preserving loopback peer.
61
  kTftpCoverage,
62
  /// Honour ApiPlan and run the dedicated lifecycle and typed-result probes.
63
  kApiLifecycle,
64
  /// Honour MultiPlan and drive several HTTP transfers through one multi.
65
  kMultiTransfer,
66
};
67
68
/// Derive runtime behaviour from the compiled target identity. Mutation policy
69
/// remains profile-specific, while targets that need the same execution cost
70
/// deliberately share a run mode.
71
/// @param profile Compiled target whose runner behaviour is required.
72
/// @return The only ScenarioRunner mode valid for that target.
73
137k
constexpr ScenarioRunMode RunModeFor(TargetProfile profile) {
74
137k
  switch (profile) {
75
14.6k
    case TargetProfile::kFastHttp:
76
18.8k
    case TargetProfile::kFastTelnet:
77
18.8k
      return ScenarioRunMode::kFastProtocol;
78
79
11.9k
    case TargetProfile::kApi:
80
11.9k
      return ScenarioRunMode::kApiLifecycle;
81
82
502
    case TargetProfile::kMulti:
83
502
      return ScenarioRunMode::kMultiTransfer;
84
85
17.8k
    case TargetProfile::kFastHttps:
86
17.8k
      return ScenarioRunMode::kTlsCoverage;
87
88
5.54k
    case TargetProfile::kH2Proxy:
89
5.54k
      return ScenarioRunMode::kH2ProxyCoverage;
90
91
7.19k
    case TargetProfile::kFastFtp:
92
7.19k
      return ScenarioRunMode::kFtpCoverage;
93
94
2.01k
    case TargetProfile::kFastTftp:
95
2.01k
      return ScenarioRunMode::kTftpCoverage;
96
97
20.7k
    case TargetProfile::kCompatibility:
98
40.7k
    case TargetProfile::kDeepHttp:
99
51.4k
    case TargetProfile::kFastWebSocket:
100
60.2k
    case TargetProfile::kFastSecureWebSocket:
101
73.5k
    case TargetProfile::kTiming:
102
73.5k
      return ScenarioRunMode::kProtocolCoverage;
103
137k
  }
104
0
  return ScenarioRunMode::kProtocolCoverage;
105
137k
}
106
107
}  // namespace proto_fuzzer
108
109
#endif  // PROTO_FUZZER_TARGET_PROFILE_H_