[test] add tbor sd fuzz targets - #682
Conversation
bd93467 to
6b5c9f0
Compare
6b5c9f0 to
68c598c
Compare
There was a problem hiding this comment.
🟢 Approval recommended
The changes are additive test/fuzz targets with only minor maintainability/lint nits (e.g., unused imports, naming schema limits) noted.
Pull request overview
Adds new libFuzzer targets for TBOR “security domain” (SD) DDI commands, expanding fuzz coverage of request encoding/dispatch through the existing azihsm_ddi_tbor_test_harness::TestCtx harness.
Changes:
- Added 6 new TBOR SD fuzz targets (create peer/remote backup, reseal/restore backups, sealing-key generation).
- Registered the new fuzz binaries in
fuzz/Cargo.tomlso they can be built/invoked as individual fuzz targets.
File summaries
| File | Description |
|---|---|
| fuzz/fuzz_targets/ddi/tbor/fuzz_tbor_sd_sealing_key_gen.rs | New fuzz target for TborSdSealingKeyGenReq. |
| fuzz/fuzz_targets/ddi/tbor/fuzz_tbor_sd_create_peer_backup.rs | New fuzz target for TborSdCreatePeerBackupReq. |
| fuzz/fuzz_targets/ddi/tbor/fuzz_tbor_sd_create_remote_backup.rs | New fuzz target for TborSdCreateRemoteBackupReq. |
| fuzz/fuzz_targets/ddi/tbor/fuzz_tbor_sd_reseal_remote_backup.rs | New fuzz target for TborSdResealRemoteBackupReq. |
| fuzz/fuzz_targets/ddi/tbor/fuzz_tbor_sd_restore_local_backup.rs | New fuzz target for TborSdRestoreLocalBackupReq with bounded variable-length blobs. |
| fuzz/fuzz_targets/ddi/tbor/fuzz_tbor_sd_restore_peer_backup.rs | New fuzz target for TborSdRestorePeerBackupReq. |
| fuzz/Cargo.toml | Registers the new fuzz target binaries. |
Review details
- Files reviewed: 7/7 changed files
- Comments generated: 6
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| use azihsm_ddi_tbor_types::ReportDescriptor; | ||
| use azihsm_ddi_tbor_types::SessionType; | ||
| use azihsm_ddi_tbor_types::TborSdCreatePeerBackupReq; | ||
| use libfuzzer_sys::arbitrary; |
| use azihsm_ddi_tbor_types::ReportDescriptor; | ||
| use azihsm_ddi_tbor_types::SessionType; | ||
| use azihsm_ddi_tbor_types::TborSdCreateRemoteBackupReq; | ||
| use libfuzzer_sys::arbitrary; |
| use azihsm_ddi_tbor_types::ReportDescriptor; | ||
| use azihsm_ddi_tbor_types::SessionType; | ||
| use azihsm_ddi_tbor_types::TborSdResealRemoteBackupReq; | ||
| use libfuzzer_sys::arbitrary; |
| use azihsm_ddi_tbor_test_harness::TestCtx; | ||
| use azihsm_ddi_tbor_types::SessionType; | ||
| use azihsm_ddi_tbor_types::TborSdRestoreLocalBackupReq; | ||
| use libfuzzer_sys::arbitrary; | ||
| use libfuzzer_sys::arbitrary::Arbitrary; | ||
| use libfuzzer_sys::fuzz_target; | ||
|
|
||
| const CU: u8 = 1; | ||
| static CTX: std::sync::OnceLock<TestCtx> = std::sync::OnceLock::new(); | ||
|
|
||
| fn bounded_pok(u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result<Vec<u8>> { | ||
| let len = usize::arbitrary(u)? % (180 + 1); | ||
| Ok(u.bytes(len)?.to_vec()) | ||
| } | ||
|
|
||
| fn bounded_sd_mk(u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result<Vec<u8>> { | ||
| let len = usize::arbitrary(u)? % (164 + 1); | ||
| Ok(u.bytes(len)?.to_vec()) | ||
| } |
| use azihsm_ddi_tbor_types::SD_MK_BACKUP_LEN; | ||
| use azihsm_ddi_tbor_types::SessionType; | ||
| use azihsm_ddi_tbor_types::TborSdRestorePeerBackupReq; | ||
| use libfuzzer_sys::arbitrary; |
| use azihsm_ddi_tbor_test_harness::TestCtx; | ||
| use azihsm_ddi_tbor_types::SessionType; | ||
| use azihsm_ddi_tbor_types::TborSdSealingKeyGenReq; | ||
| use libfuzzer_sys::arbitrary; |
68c598c to
29dd1a8
Compare
…zure/azihsm-sdk into user/v-davidz/add_tbor_sd_fuzz
There was a problem hiding this comment.
🟢 Approval recommended
The changes are additive fuzz targets with low risk to production code, and the only feedback is minor maintainability cleanup.
Review details
Suppressed comments (2)
fuzz/fuzz_targets/ddi/tbor/fuzz_tbor_sd_restore_local_backup.rs:19
- Avoid hard-coded length bounds here; the maximum size for
pok_local_backupis already defined asMASKED_SD_LENinazihsm_ddi_tbor_types. Using the constant keeps the fuzz target aligned with the TBOR schema if the envelope size changes.
fn bounded_pok(u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result<Vec<u8>> {
let len = usize::arbitrary(u)? % (180 + 1);
Ok(u.bytes(len)?.to_vec())
}
fuzz/fuzz_targets/ddi/tbor/fuzz_tbor_sd_restore_local_backup.rs:24
- Avoid hard-coded length bounds here;
sd_mk_backup's maximum size is already available asSD_MK_BACKUP_LENinazihsm_ddi_tbor_types. Reusing it prevents this fuzzer from silently diverging from the schema.
fn bounded_sd_mk(u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result<Vec<u8>> {
let len = usize::arbitrary(u)? % (164 + 1);
Ok(u.bytes(len)?.to_vec())
}
- Files reviewed: 7/7 changed files
- Comments generated: 0 new
- Review effort level: Lite
No description provided.