mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 16:02:26 +00:00
- Add `scripts/agent/fuzz-nostr-schemas.mjs` to fuzz event builders and validation - Add `scripts/agent/fuzz-dm-decryptor.mjs` to fuzz DM unwrapping - Add `scripts/agent/fuzz-magnet-utils.mjs` to fuzz magnet normalization - Utilize `scripts/agent/fuzz-lib.mjs` for randomization and reporting - Verify that `scripts/agent/setup-test-env.js` is imported to polyfill globals - Output reports to `artifacts/` No crashes were found during the initial fuzzing run (5000 iterations per target).
39 lines
1.1 KiB
JavaScript
39 lines
1.1 KiB
JavaScript
import "./setup-test-env.js";
|
|
import { Fuzzer } from "./fuzz-lib.mjs";
|
|
import { normalizeAndAugmentMagnet } from "../../js/magnetUtils.js";
|
|
|
|
const fuzzer = new Fuzzer("magnet-utils");
|
|
|
|
async function fuzzTest(fuzzer, state) {
|
|
// Generate inputs
|
|
const rawValue = fuzzer.randBool() ? fuzzer.randString(100) : "magnet:?xt=urn:btih:" + fuzzer.randString(40, "0123456789abcdef");
|
|
|
|
// Inject garbage into magnet link
|
|
let malformedValue = rawValue;
|
|
if (fuzzer.randBool()) {
|
|
// url encode some chars
|
|
malformedValue = encodeURIComponent(rawValue);
|
|
}
|
|
|
|
const options = {
|
|
webSeed: fuzzer.randBool() ? fuzzer.randString(50) : [fuzzer.randString(50)],
|
|
torrentUrl: fuzzer.randString(50),
|
|
xs: fuzzer.randString(50),
|
|
extraTrackers: fuzzer.randArray(() => fuzzer.randString(30), 0, 3),
|
|
appProtocol: fuzzer.randBool() ? "http:" : "https:"
|
|
};
|
|
|
|
state.input = {
|
|
rawValue: malformedValue,
|
|
options
|
|
};
|
|
|
|
try {
|
|
normalizeAndAugmentMagnet(malformedValue, options);
|
|
} catch (err) {
|
|
throw err;
|
|
}
|
|
}
|
|
|
|
fuzzer.runFuzzLoop(5000, fuzzTest).catch(console.error);
|