curl-fuzzer C++ reference
Loading...
Searching...
No Matches
transfer_session.h
Go to the documentation of this file.
1/*
2 * Copyright (C) Max Dymond, <cmeister2@gmail.com>, et al.
3 *
4 * SPDX-License-Identifier: curl
5 */
6
9
10#ifndef PROTO_FUZZER_TRANSFER_SESSION_H_
11#define PROTO_FUZZER_TRANSFER_SESSION_H_
12
13#include <memory>
14#include <optional>
15#include <string>
16#include <string_view>
17
18#include "curl_fuzzer.pb.h"
22
23namespace proto_fuzzer {
24
25class ApiLifecycle;
26
32class TransferSession {
33 public:
34 TransferSession();
35 ~TransferSession();
36
37 TransferSession(const TransferSession&) = delete;
38 TransferSession& operator=(const TransferSession&) = delete;
39 TransferSession(TransferSession&&) = delete;
40 TransferSession& operator=(TransferSession&&) = delete;
41
42 bool Initialize();
43
44 CURL* easy() const;
45
46 void ApplyBaseline(const curl::fuzzer::proto::Scenario& scenario);
47
48 bool ResetConfiguration();
49
50 bool PrepareInputFiles(const curl::fuzzer::proto::Scenario& scenario, ScenarioRunMode mode);
51
52 const char* FileSourcePath() const;
53
54 void ApplyInputFiles();
55
57
58 void ConfigureAltSvcRouting(const std::string& host_path);
59
60 ScenarioRequestData* InstallRequestData(const curl::fuzzer::proto::Scenario& scenario,
61 bool apply_resolve_entries = false);
62 ScenarioRequestData* InstallRequestData(curl::fuzzer::proto::Scenario&&, bool = false) = delete;
63 ScenarioRequestData* InstallRequestData(const curl::fuzzer::proto::Scenario&&, bool = false) = delete;
64
65 ApiLifecycle* InstallApiLifecycle(const curl::fuzzer::proto::ApiPlan& plan, std::string_view url);
66 ApiLifecycle* InstallApiLifecycle(curl::fuzzer::proto::ApiPlan&&, std::string_view) = delete;
67 ApiLifecycle* InstallApiLifecycle(const curl::fuzzer::proto::ApiPlan&&, std::string_view) = delete;
68
69 void Close();
70
71 private:
72 struct ParserInputs;
73
74 std::unique_ptr<ParserInputs> parser_inputs_;
75 CurlSlistPtr connect_to_;
76 CurlSlistPtr altsvc_resolve_;
77 std::unique_ptr<ApiLifecycle> api_lifecycle_;
78 CurlEasyPtr easy_;
79 std::optional<ScenarioRequestData> request_data_;
80};
81
82} // namespace proto_fuzzer
83
84#endif // PROTO_FUZZER_TRANSFER_SESSION_H_
Exercises public easy/share/query APIs while preserving all caller- owned option and callback lifetim...
Builds HTTP headers or TELNET options, MIME state, and upload callbacks whose storage or userdata lib...
bool Initialize()
Allocate the easy lazily so unused concurrent-transfer slots stay empty.
CURL * easy() const
Borrow the owned easy; callers must not clean it themselves.
const char * FileSourcePath() const
Return the pathname of the prepared FILE source/sink.
void ApplyInputFiles()
Apply prepared parser paths after baseline and peer installation.
ScenarioRequestData * InstallRequestData(const curl::fuzzer::proto::Scenario &scenario, bool apply_resolve_entries=false)
Install owned request attachments.
void Close()
Release all resources in their required order. Safe to call repeatedly.
bool ResetConfiguration()
Reset pre-transfer configuration while preserving prepared parser files.
void ConfigureAltSvcRouting(const std::string &host_path)
Enable isolated Alt-Svc routing for the canonical deep-HTTP authority.
void ApplyPinnedPublicKeyFile()
Install the prepared public-key pin path after generic scalar options.
void ApplyBaseline(const curl::fuzzer::proto::Scenario &scenario)
Apply baseline options and retain their CONNECT_TO storage.
bool PrepareInputFiles(const curl::fuzzer::proto::Scenario &scenario, ScenarioRunMode mode)
Copy bounded parser inputs into lazily allocated anonymous files.
ApiLifecycle * InstallApiLifecycle(const curl::fuzzer::proto::ApiPlan &plan, std::string_view url)
Install API/share state that survives easy cleanup.
Common ownership types for independently cleaned-up curl handles.
std::unique_ptr< curl_slist, CurlSlistDeleter > CurlSlistPtr
Unique ownership of a caller-owned curl_slist.
Definition curl_raii.h:60
std::unique_ptr< CURL, CurlEasyDeleter > CurlEasyPtr
Unique ownership of a CURL easy handle.
Definition curl_raii.h:56
Owns pointer-valued HTTP headers, TELNET options, MIME state, and upload callback state derived from ...
Compile-time identities and execution modes for proto fuzz targets.
ScenarioRunMode
Selects one of the complete, valid RunScenario behaviours.