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
use crate::{corpus_from_strategy, fuzz_data_to_value, FuzzTargetImpl};
use diem_proptest_helpers::ValueGenerator;
use network::noise::fuzzing::{
fuzz_initiator, fuzz_post_handshake, fuzz_responder, generate_corpus,
};
#[derive(Clone, Debug, Default)]
pub struct NetworkNoiseInitiator;
impl FuzzTargetImpl for NetworkNoiseInitiator {
fn description(&self) -> &'static str {
"Network Noise crate initiator side"
}
fn generate(&self, _idx: usize, gen: &mut ValueGenerator) -> Option<Vec<u8>> {
Some(generate_corpus(gen))
}
fn fuzz(&self, data: &[u8]) {
fuzz_initiator(data);
}
}
#[derive(Clone, Debug, Default)]
pub struct NetworkNoiseResponder;
impl FuzzTargetImpl for NetworkNoiseResponder {
fn description(&self) -> &'static str {
"Network Noise crate responder side"
}
fn generate(&self, _idx: usize, gen: &mut ValueGenerator) -> Option<Vec<u8>> {
Some(generate_corpus(gen))
}
fn fuzz(&self, data: &[u8]) {
fuzz_responder(data);
}
}
#[derive(Clone, Debug, Default)]
pub struct NetworkNoiseStream;
impl FuzzTargetImpl for NetworkNoiseStream {
fn description(&self) -> &'static str {
"Network Noise crate stream"
}
fn generate(&self, _idx: usize, gen: &mut ValueGenerator) -> Option<Vec<u8>> {
Some(generate_corpus(gen))
}
fn fuzz(&self, data: &[u8]) {
fuzz_post_handshake(data);
}
}
use network::fuzzing::{
exchange_handshake_input, fuzz_network_handshake_protocol_exchange,
fuzz_network_handshake_protocol_negotiation, perform_handshake_input,
};
#[derive(Clone, Debug, Default)]
pub struct NetworkHandshakeExchange;
impl FuzzTargetImpl for NetworkHandshakeExchange {
fn description(&self) -> &'static str {
"network handshake protocol starting with the exchange of HandshakeMsg"
}
fn generate(&self, _idx: usize, _gen: &mut ValueGenerator) -> Option<Vec<u8>> {
Some(corpus_from_strategy(exchange_handshake_input()))
}
fn fuzz(&self, data: &[u8]) {
let (own_handshake, their_handshake) = fuzz_data_to_value(data, exchange_handshake_input());
fuzz_network_handshake_protocol_exchange(&own_handshake, their_handshake);
}
}
#[derive(Clone, Debug, Default)]
pub struct NetworkHandshakeNegotiation;
impl FuzzTargetImpl for NetworkHandshakeNegotiation {
fn description(&self) -> &'static str {
"network handshake protocol skipping the exchange straight to the negotiation"
}
fn generate(&self, _idx: usize, _gen: &mut ValueGenerator) -> Option<Vec<u8>> {
Some(corpus_from_strategy(perform_handshake_input()))
}
fn fuzz(&self, data: &[u8]) {
let (own_handshake, their_handshake) = fuzz_data_to_value(data, perform_handshake_input());
fuzz_network_handshake_protocol_negotiation(&own_handshake, &their_handshake);
}
}
use network::peer;
#[derive(Clone, Debug, Default)]
pub struct PeerNetworkMessagesReceive;
impl FuzzTargetImpl for PeerNetworkMessagesReceive {
fn description(&self) -> &'static str {
"network peer actor reading and deserializing multiple inbound NetworkMessages"
}
fn generate(&self, _idx: usize, gen: &mut ValueGenerator) -> Option<Vec<u8>> {
Some(peer::fuzzing::generate_corpus(gen))
}
fn fuzz(&self, data: &[u8]) {
peer::fuzzing::fuzz(data);
}
}