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
use crate::{FuzzTarget, FuzzTargetImpl};
use anyhow::{format_err, Result};
use once_cell::sync::Lazy;
use std::{collections::BTreeMap, env};
mod consensus;
mod executor;
mod mempool;
mod move_vm;
mod network;
mod proof;
mod safety_rules;
mod secure_storage_vault;
mod state_sync;
mod storage;
mod transaction;
mod vm;
static ALL_TARGETS: Lazy<BTreeMap<&'static str, Box<dyn FuzzTargetImpl>>> = Lazy::new(|| {
let targets: Vec<Box<dyn FuzzTargetImpl>> = vec![
Box::new(consensus::ConsensusProposal::default()),
Box::new(executor::ExecuteAndCommitBlocks::default()),
Box::new(executor::ExecuteAndCommitChunk::default()),
Box::new(mempool::MempoolIncomingTransactions::default()),
Box::new(move_vm::ValueTarget::default()),
Box::new(proof::TestAccumulatorProofFuzzer::default()),
Box::new(proof::SparseMerkleProofFuzzer::default()),
Box::new(proof::TestAccumulatorRangeProofFuzzer::default()),
Box::new(proof::TransactionInfoWithProofFuzzer::default()),
Box::new(proof::TransactionInfoListWithProofFuzzer::default()),
Box::new(network::NetworkNoiseInitiator::default()),
Box::new(network::NetworkNoiseResponder::default()),
Box::new(network::NetworkNoiseStream::default()),
Box::new(network::NetworkHandshakeExchange::default()),
Box::new(network::NetworkHandshakeNegotiation::default()),
Box::new(network::PeerNetworkMessagesReceive::default()),
Box::new(safety_rules::SafetyRulesConstructAndSignVote::default()),
Box::new(safety_rules::SafetyRulesInitialize::default()),
Box::new(safety_rules::SafetyRulesHandleMessage::default()),
Box::new(safety_rules::SafetyRulesSignProposal::default()),
Box::new(safety_rules::SafetyRulesSignTimeout::default()),
Box::new(secure_storage_vault::VaultGenericResponse::default()),
Box::new(secure_storage_vault::VaultPolicyReadResponse::default()),
Box::new(secure_storage_vault::VaultPolicyListResponse::default()),
Box::new(secure_storage_vault::VaultSecretListResponse::default()),
Box::new(secure_storage_vault::VaultSecretReadResponse::default()),
Box::new(secure_storage_vault::VaultTokenCreateResponse::default()),
Box::new(secure_storage_vault::VaultTokenRenewResponse::default()),
Box::new(secure_storage_vault::VaultTransitCreateResponse::default()),
Box::new(secure_storage_vault::VaultTransitExportResponse::default()),
Box::new(secure_storage_vault::VaultTransitListResponse::default()),
Box::new(secure_storage_vault::VaultTransitReadResponse::default()),
Box::new(secure_storage_vault::VaultTransitRestoreResponse::default()),
Box::new(secure_storage_vault::VaultTransitSignResponse::default()),
Box::new(secure_storage_vault::VaultUnsealedResponse::default()),
Box::new(state_sync::StateSyncMsg::default()),
Box::new(storage::StorageSchemaDecode::default()),
Box::new(storage::JellyfishGetWithProofWithDistinctLastNibble::default()),
Box::new(storage::JellyfishGetRangeProof::default()),
Box::new(storage::JellyfishGetLeafCount::default()),
Box::new(storage::AccumulatorFrozenSubtreeHashes::default()),
Box::new(storage::AccumulatorProof::default()),
Box::new(storage::AccumulatorConsistencyProof::default()),
Box::new(storage::AccumulatorRangeProof::default()),
Box::new(storage::AccumulatorAppendMany::default()),
Box::new(storage::AccumulatorAppendEmpty::default()),
Box::new(storage::SparseMerkleCorrectness::default()),
Box::new(transaction::LanguageTransactionExecution::default()),
Box::new(transaction::SignedTransactionTarget::default()),
Box::new(transaction::MutatedSignedTransaction::default()),
Box::new(transaction::TwoSignedTransactions::default()),
Box::new(vm::CompiledModuleTarget::default()),
];
targets
.into_iter()
.map(|target| (target.name(), target))
.collect()
});
impl FuzzTarget {
pub(crate) const ENV_VAR: &'static str = "FUZZ_TARGET";
pub fn from_env() -> Result<Self> {
let name = env::var(Self::ENV_VAR)?;
Self::by_name(&name).ok_or_else(|| format_err!("Unknown fuzz target '{}'", name))
}
pub fn by_name(name: &str) -> Option<Self> {
ALL_TARGETS.get(name).map(|target| FuzzTarget(&**target))
}
pub fn all_targets() -> impl Iterator<Item = Self> {
ALL_TARGETS.values().map(|target| FuzzTarget(&**target))
}
}