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
use crate::{corpus_from_strategy, fuzz_data_to_value, FuzzTargetImpl};
use diem_proptest_helpers::ValueGenerator;
use safety_rules::fuzzing_utils::{
arb_block_data, arb_epoch_change_proof, arb_maybe_signed_vote_proposal, arb_safety_rules_input,
arb_timeout,
fuzzing::{
fuzz_construct_and_sign_vote, fuzz_handle_message, fuzz_initialize, fuzz_sign_proposal,
fuzz_sign_timeout,
},
};
#[derive(Clone, Debug, Default)]
pub struct SafetyRulesHandleMessage;
impl FuzzTargetImpl for SafetyRulesHandleMessage {
fn description(&self) -> &'static str {
"Safety rules: handle_message()"
}
fn generate(&self, _idx: usize, _gen: &mut ValueGenerator) -> Option<Vec<u8>> {
Some(corpus_from_strategy(arb_safety_rules_input()))
}
fn fuzz(&self, data: &[u8]) {
let safety_rules_input = fuzz_data_to_value(data, arb_safety_rules_input());
let _ = fuzz_handle_message(safety_rules_input);
}
}
#[derive(Clone, Debug, Default)]
pub struct SafetyRulesInitialize;
impl FuzzTargetImpl for SafetyRulesInitialize {
fn description(&self) -> &'static str {
"Safety rules: initialize()"
}
fn generate(&self, _idx: usize, _gen: &mut ValueGenerator) -> Option<Vec<u8>> {
Some(corpus_from_strategy(arb_epoch_change_proof()))
}
fn fuzz(&self, data: &[u8]) {
let epoch_change_proof = fuzz_data_to_value(data, arb_epoch_change_proof());
let _ = fuzz_initialize(epoch_change_proof);
}
}
#[derive(Clone, Debug, Default)]
pub struct SafetyRulesConstructAndSignVote;
impl FuzzTargetImpl for SafetyRulesConstructAndSignVote {
fn description(&self) -> &'static str {
"Safety rules: construct_and_sign_vote()"
}
fn generate(&self, _idx: usize, _gen: &mut ValueGenerator) -> Option<Vec<u8>> {
Some(corpus_from_strategy(arb_maybe_signed_vote_proposal()))
}
fn fuzz(&self, data: &[u8]) {
let maybe_signed_vote_proposal = fuzz_data_to_value(data, arb_maybe_signed_vote_proposal());
let _ = fuzz_construct_and_sign_vote(maybe_signed_vote_proposal);
}
}
#[derive(Clone, Debug, Default)]
pub struct SafetyRulesSignProposal;
impl FuzzTargetImpl for SafetyRulesSignProposal {
fn description(&self) -> &'static str {
"Safety rules: sign_proposal()"
}
fn generate(&self, _idx: usize, _gen: &mut ValueGenerator) -> Option<Vec<u8>> {
Some(corpus_from_strategy(arb_block_data()))
}
fn fuzz(&self, data: &[u8]) {
let block_data = fuzz_data_to_value(data, arb_block_data());
let _ = fuzz_sign_proposal(&block_data);
}
}
#[derive(Clone, Debug, Default)]
pub struct SafetyRulesSignTimeout;
impl FuzzTargetImpl for SafetyRulesSignTimeout {
fn description(&self) -> &'static str {
"Safety rules: sign_timeout()"
}
fn generate(&self, _idx: usize, _gen: &mut ValueGenerator) -> Option<Vec<u8>> {
Some(corpus_from_strategy(arb_timeout()))
}
fn fuzz(&self, data: &[u8]) {
let timeout = fuzz_data_to_value(data, arb_timeout());
let _ = fuzz_sign_timeout(timeout);
}
}