Files
bitvid/scripts/agent/summarize-fuzz.mjs
T
google-labs-jules[bot]andPR0M3TH3AN 21220a635d Add fuzzing suite for Nostr parsing, DM decryption, and Magnet normalization
- Added `scripts/agent/fuzz-utils.mjs` with random input generators.
- Added `scripts/agent/fuzz-nostrEventSchemas.mjs` to fuzz event builders and validation.
- Added `scripts/agent/fuzz-dmDecryptor.mjs` to fuzz DM decryption logic.
- Added `scripts/agent/fuzz-magnetUtils.mjs` to fuzz magnet URI normalization.
- Added `scripts/agent/summarize-fuzz.mjs` to aggregate reports.
- Generated initial fuzzing reports in `artifacts/`.
- Verified that target functions are robust against malformed inputs.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-10 16:10:50 +00:00

78 lines
2.1 KiB
JavaScript

import fs from "fs";
import path from "path";
import { fileURLToPath } from "url";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const ARTIFACTS_DIR = path.resolve(__dirname, "../../artifacts");
const TARGETS = {
nostrEventSchemas: [
"sanitizeAdditionalTags",
"validateEventStructure",
"buildVideoPostEvent",
"buildHttpAuthEvent",
"buildReportEvent",
"buildGiftWrapEvent",
"buildSealEvent",
"buildChatMessageEvent",
"buildVideoMirrorEvent",
"buildRepostEvent",
"buildShareEvent",
"buildRelayListEvent",
"buildDmRelayListEvent",
"buildProfileMetadataEvent",
"buildMuteListEvent",
"buildDeletionEvent",
"buildLegacyDirectMessageEvent",
"buildDmAttachmentEvent",
"buildDmReadReceiptEvent",
"buildDmTypingIndicatorEvent",
"buildViewEvent",
"buildZapRequestEvent",
"buildReactionEvent",
"buildCommentEvent",
"buildWatchHistoryEvent",
"buildSubscriptionListEvent",
"buildBlockListEvent",
"buildHashtagPreferenceEvent",
"buildAdminListEvent",
],
dmDecryptor: ["decryptDM"],
magnetUtils: [
"safeDecodeMagnet",
"extractBtihFromMagnet",
"normalizeInfoHash",
"normalizeAndAugmentMagnet",
],
};
function main() {
for (const [target, functions] of Object.entries(TARGETS)) {
const summary = {
target,
totalFailures: 0,
details: {},
};
for (const fn of functions) {
const reportFile = path.join(ARTIFACTS_DIR, `fuzz-report-${fn}.json`);
if (fs.existsSync(reportFile)) {
try {
const data = JSON.parse(fs.readFileSync(reportFile, "utf8"));
summary.details[fn] = data;
summary.totalFailures += data.length;
} catch (e) {
console.error(`Failed to read report for ${fn}:`, e);
}
}
}
const summaryPath = path.join(ARTIFACTS_DIR, `fuzz-report-${target}.json`);
fs.writeFileSync(summaryPath, JSON.stringify(summary, null, 2));
console.log(`Generated summary for ${target} at ${summaryPath}`);
}
}
main();