mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-01 18:32:27 +00:00
feat: add fuzz testing infrastructure and fix nostrEventSchemas crash
- Added `scripts/agent/fuzz-schemas.mjs`, `fuzz-dm.mjs`, `fuzz-magnet.mjs` and `fuzz-setup.mjs`. - Fixed crash in `js/nostrEventSchemas.js` (buildAdminListEvent log and getNostrEventSchema type check). - Added crash reproducers in `examples/reproducers/`. - Fuzzers output reports to `artifacts/`. - Updated fuzzers to deduplicate crashes and safely stringify inputs.
This commit is contained in:
1 parent
8b1358a619
commit
241ad32dc4
8 files changed
+567
-1
No files matched your search
@@ -0,0 +1,55 @@
|
||||
import crypto from 'node:crypto';
|
||||
|
||||
// Mock localStorage
|
||||
const localStorageStore = new Map();
|
||||
const localStorageMock = {
|
||||
getItem: (key) => localStorageStore.get(String(key)) ?? null,
|
||||
setItem: (key, value) => localStorageStore.set(String(key), String(value)),
|
||||
removeItem: (key) => localStorageStore.delete(String(key)),
|
||||
clear: () => localStorageStore.clear(),
|
||||
key: (index) => Array.from(localStorageStore.keys())[index] ?? null,
|
||||
get length() {
|
||||
return localStorageStore.size;
|
||||
},
|
||||
};
|
||||
|
||||
// Mock window
|
||||
const windowMock = {
|
||||
localStorage: localStorageMock,
|
||||
crypto: {
|
||||
getRandomValues: (buffer) => crypto.getRandomValues(buffer),
|
||||
subtle: crypto.webcrypto.subtle,
|
||||
},
|
||||
location: {
|
||||
protocol: 'https:',
|
||||
hostname: 'bitvid.network',
|
||||
href: 'https://bitvid.network/',
|
||||
},
|
||||
};
|
||||
|
||||
// Polyfill globals
|
||||
if (typeof globalThis.window === 'undefined') {
|
||||
globalThis.window = windowMock;
|
||||
}
|
||||
|
||||
if (typeof globalThis.localStorage === 'undefined') {
|
||||
globalThis.localStorage = localStorageMock;
|
||||
}
|
||||
|
||||
if (typeof globalThis.crypto === 'undefined') {
|
||||
globalThis.crypto = windowMock.crypto;
|
||||
}
|
||||
|
||||
if (typeof globalThis.WebSocket === 'undefined') {
|
||||
globalThis.WebSocket = class WebSocket {
|
||||
constructor(url) {
|
||||
this.url = url;
|
||||
this.readyState = 0;
|
||||
}
|
||||
send() {}
|
||||
close() {}
|
||||
};
|
||||
}
|
||||
|
||||
// Mock bitvid-specific globals if needed (though config.js sets them on window)
|
||||
globalThis.bitvidNostrEventOverrides = {};
|
||||
Reference in new issue
Block a user