-
Notifications
You must be signed in to change notification settings - Fork 7
/
index.js
48 lines (37 loc) · 1.14 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
'use strict';
const blns = require('./data/blns.json');
const debug = require('debug')('plugin:fuzzer');
module.exports.Plugin = FuzzerPlugin;
module.exports.pluginInterfaceVersion = 2;
function FuzzerPlugin (script, events) {
this.script = script;
this.events = events;
if (!script.config.processor) {
script.config.processor = {};
}
script.config.processor.fuzzerPluginCreateVariable = fuzzerPluginCreateVariable;
script.scenarios.forEach(function (scenario) {
if (!scenario.beforeRequest) {
scenario.beforeRequest = [];
}
scenario.beforeRequest.push('fuzzerPluginCreateVariable');
if (scenario.engine === 'socketio') {
scenario.flow.unshift({function: 'fuzzerPluginCreateVariable'});
}
});
debug('Plugin initialized');
return this;
}
function fuzzerPluginCreateVariable (req, userContext, events, done) {
let ctx = userContext;
let cb = done;
if (arguments.length === 3) {
// called as a "function"
ctx = req;
cb = events;
}
const ns = blns[Math.floor(Math.random() * blns.length)];
ctx.vars.naughtyString = ns;
debug(`fuzzerPluginCreateVariable: ${ns}`);
return cb();
}