1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
//! subscribable events for introspection into some of the more opaque parts of the fuzzer
//!
//! Custom events can be defined by simply adding a new type to the [`SharedState`]'s
//! `events` map. The [`EventPublisher`] trait provides a simple interface for subscribing
//! to and notifying listeners of events.
//!
//! [`SharedState`]: crate::state::SharedState
//!
//! # Examples
//!
//! Subscribe to the [`ModifiedCorpus`] event:
//!
//! ```
//! use feroxfuzz::events::{EventPublisher, ModifiedCorpus};
//! use feroxfuzz::state::SharedState;
//! use feroxfuzz::corpora::Wordlist;
//!
//! let wordlist = Wordlist::with_words(["test"])
//! .name("words")
//! .build();
//!
//! let mut state = SharedState::with_corpus(wordlist);
//!
//! let listener_id = state.events().subscribe(|event: ModifiedCorpus| {
//! println!("{:?}", event);
//! });
//!
//! // ... fuzzer calls state.events().notify(ModifiedCorpus { .. }) ...
//!
//! // unsubscribe from the event
//! state.events().unsubscribe::<ModifiedCorpus>(listener_id.unwrap());
//!
//! assert!(!state.events().has_listeners::<ModifiedCorpus>());
//! ```
//!
//! Define a custom event
//!
//! ```
//! use feroxfuzz::events::{EventPublisher, Publisher};
//! use feroxfuzz::state::SharedState;
//! use feroxfuzz::corpora::Wordlist;
//!
//! let wordlist = Wordlist::with_words(["test"])
//! .name("words")
//! .build();
//!
//! let mut state = SharedState::with_corpus(wordlist);
//!
//! // define a custom event (must be Clone)
//! #[derive(Clone)]
//! struct CustomEvent {
//! message: String,
//! }
//!
//! // subscribe to the event
//! let listener_id = state.events().subscribe(|event: CustomEvent| {
//! assert_eq!(event.message, "hello world");
//! });
//!
//! // notify listeners of the event
//! state.events().notify(CustomEvent {
//! message: "hello world".to_string(),
//! });
//!
//! // unsubscribe from the event
//! state.events().unsubscribe::<CustomEvent>(listener_id.unwrap());
//!
//! assert!(!state.events().has_listeners::<CustomEvent>());
//! ```
use crateData;
use crateRequestId;
use crateLogicOperation;
pub use ;
/// This event is emitted when an [`Action::AddToCorpus`] is performed
/// by the fuzzer.
///
/// [`Action::AddToCorpus`]: crate::actions::Action::AddToCorpus
/// This event is emitted when a [`Request`] is discarded prior to
/// being sent to the target.
///
/// [`Request`]: crate::requests::Request
/// This event is emitted when a [`Request`] is retained and allowed to
/// be sent to the target.
///
/// [`Request`]: crate::requests::Request
/// This event is emitted when a [`Response`] is discarded after
/// being received from the target.
///
/// [`Response`]: crate::responses::Response
/// This event is emitted when a [`Response`] is retained after being
/// received from the target.
///
/// [`Response`]: crate::responses::Response
/// This event is emitted when a fuzzer enters its fuzzing loop via the
/// [`Fuzzer::fuzz`] method.
///
/// [`Fuzzer::fuzz`]: crate::fuzzers::AsyncFuzzing::fuzz
;
/// This event is emitted when a fuzzer enters its fuzzing loop via the
/// [`Fuzzer::fuzz_n_iterations`] method.
///
/// [`Fuzzer::fuzz_n_iterations`]: crate::fuzzers::AsyncFuzzing::fuzz_n_iterations
/// This event is emitted when a fuzzer enters its fuzzing loop via the
/// [`Fuzzer::fuzz_once`] method.
///
/// If the fuzzer was started with [`Fuzzer::fuzz_n_iterations`]
/// or [`Fuzzer::fuzz`], this event will be emitted once per iteration.
///
/// [`Fuzzer::fuzz_once`]: crate::fuzzers::AsyncFuzzing::fuzz_once
/// [`Fuzzer::fuzz_n_iterations`]: crate::fuzzers::AsyncFuzzing::fuzz_n_iterations
/// [`Fuzzer::fuzz`]: crate::fuzzers::AsyncFuzzing::fuzz
/// This event is emitted when a fuzzer exits the fuzzing loop.
///
/// This can happen when the fuzzer has iterated over the entire
/// corpus for the specified number of times, or when the fuzzer
/// exits early due to an [`Action::StopFuzzing`]
///
/// [`Action::StopFuzzing`]: crate::actions::Action::StopFuzzing
;
/// This event is fired when a [`Request`] is mutated by a [`Mutator`]. It contains the
/// [`RequestId`] of the mutated request and the name of the field that was mutated.
///
/// # Note
///
/// This event is useful for debugging purposes. It is not recommended to use this event
/// where speed is a concern. Each mutation will fire this event, and they're in the
/// critical path of the fuzzer.
///
/// Additionally, the `mutation` field of this event is a [`Data`] variant, and must
/// be cloned. This can be expensive for large inputs.
///
/// [`Mutator`]: crate::mutators::Mutator
/// [`Request`]: crate::requests::Request