feat: add fuzz testing harnesses for schemas, dm, and magnet utils

- Harmonize fuzzing iteration counts to 50,000 for robustness
- Add documentation headers to fuzz scripts
- Verify robustness of `nostrEventSchemas.js`, `dmDecryptor.js`, and `magnetUtils.js`
- Clean up temporary reproducers and crash reports

Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
google-labs-jules[bot]andPR0M3TH3AN committed 2026-01-31 17:22:54 +00:00
1 parent d999b79e5a
commit 26b1552af5
3 files changed
+38 -7

No files matched your search

+12 -2
View File
@@ -1,4 +1,14 @@
// Fuzz harness for js/dmDecryptor.js
/**
* Fuzz harness for js/dmDecryptor.js
*
* Targets:
* - decryptDM function
*
* Strategy:
* - Mocks decryptor context with random behaviors (success/fail/garbage).
* - Passes random event structures (NIP-04, NIP-44, Gift Wrap).
* - Checks for unhandled exceptions during decryption flow.
*/
import "./setup-test-env.js";
import { Fuzzer } from "./fuzz-lib.mjs";
import { decryptDM } from "../../js/dmDecryptor.js";
@@ -83,4 +93,4 @@ async function fuzzTest(fuzzer, state) {
}
}
fuzzer.runFuzzLoop(5000, fuzzTest).catch(console.error);
fuzzer.runFuzzLoop(50000, fuzzTest).catch(console.error);
+12 -2
View File
@@ -1,4 +1,14 @@
// Fuzz harness for js/magnetUtils.js
/**
* Fuzz harness for js/magnetUtils.js
*
* Targets:
* - normalizeAndAugmentMagnet
*
* Strategy:
* - Generates malformed magnet URIs and random strings.
* - Fuzzes options object (trackers, webseeds).
* - Checks for parsing crashes.
*/
import "./setup-test-env.js";
import { Fuzzer } from "./fuzz-lib.mjs";
import { normalizeAndAugmentMagnet } from "../../js/magnetUtils.js";
@@ -42,4 +52,4 @@ async function fuzzTest(fuzzer, state) {
}
}
fuzzer.runFuzzLoop(5000, fuzzTest).catch(console.error);
fuzzer.runFuzzLoop(50000, fuzzTest).catch(console.error);
+14 -3
View File
@@ -1,4 +1,15 @@
// Fuzz harness for js/nostrEventSchemas.js
/**
* Fuzz harness for js/nostrEventSchemas.js
*
* Targets:
* - Builder functions (buildVideoPostEvent, etc.)
* - Validation logic (validateEventStructure)
*
* Strategy:
* - Generates random JSON parameters for builders.
* - Generates random events for validation.
* - Checks for runtime exceptions (crashes).
*/
import "./setup-test-env.js";
import { Fuzzer } from "./fuzz-lib.mjs";
import * as schemas from "../../js/nostrEventSchemas.js";
@@ -77,5 +88,5 @@ async function fuzzTest(fuzzer, state) {
}
}
// Run for 5000 iterations
fuzzer.runFuzzLoop(5000, fuzzTest).catch(console.error);
// Run for 50000 iterations
fuzzer.runFuzzLoop(50000, fuzzTest).catch(console.error);