Kate: What are they, Billy?
Billy Peltzer: They're gremlins, Kate, just like Mr. Futterman said.
horde
is an army of specialized gremlins ready to shake up your application. Release ( unleash
) them to start stress tests: var horde = gremlins.createHorde() horde.unleash(); // , 10ms, 100
gremlin formFiller input 5 in <input type="number" name="age"> gremlin formFiller input pzdoyzshh0k9@o8cpskdb73nmi.r7r in <input type="email" name="email"> gremlin clicker click at 1219 301 gremlin scroller scroll to 100 25 ...
mogwais
). Mogvai only monitor the activity of the application and write a melon in the log. For example, “fps” every 500ms shows the number of frames per second (FPS). mogwai fps 33.21 mogwai fps 59.45 mogwai fps 12.67 ...
mogwai fps 12.67 mogwai fps 23.56 err > mogwai fps 7.54 < err mogwai fps 15.76 ...
Gizmo
will stop testing and all released gremlins. In the end, after the first 10 mistakes, you already know what you need to do to make your application more sustainable. // , .blur() horde.gremlin(function() { document.activeElement.blur(); });
gremlins.min.js
can be added as a third-party library, after which gremlins
will be available in the global namespace: <script src="path/to/gremlins.min.js"></script> <script> gremlins.createHorde().unleash(); </script>
gremlins.min.js
as a RequireJS module, without littering the global namespace: require.config({ paths: { gremlins: 'path/to/gremlins.min' } }); require(['gremlins'], function(gremlins) { gremlins.createHorde().unleash(); });
horde
).horde
object's gremlin()
method: gremlins.createHorde() .gremlin(gremlins.species.formFiller()) .gremlin(gremlins.species.clicker().clickTypes(['click'])) .gremlin(gremlins.species.scroller()) .gremlin(function() { window.$ = function() {}; }) .unleash();
allGremlins()
method: gremlins.createHorde() .allGremlins() .gremlin(function() { window.$ = function() {}; }) .unleash();
mogwai()
and allMogwais()
methods in the same way.gremlins.js
supplies several gremlins and mogvays:gremlins.js
are configurable functions
, that is, you can change the logic of their methods. var clickerGremlin = gremlins.species.clicker(); clickerGremin(); //
clicker
has the following methods for customization: gremlins.species.clicker() .clickTypes(['click']) // .canClick(function(element) { // bar return $(element).parents('#bar').length; // canClick false, // , maxNbTries }) .showAction(function(x, y) { // clicker // showAction() })
// seed the randomizer horde.seed(1234);
horde
object has a before()
method, with a single argument that accepts callback: horde.before(function startProfiler() { console.profile('gremlins'); });
horde
object also provides the after()
method: horde.after(function stopProfiler() { console.profileEnd(); });
horde.before(function waitFiveSeconds(done) { window.setTimeout(done, 5000); });
horde.strategy()
method: horde.strategy(gremlins.strategies.distribution() .delay(50) // 50ms .distribution([0.3, 0.3, 0.3, 0.1]) // )
unleash()
result), and a final callback. Included are two more built-in strategies ( allTogether and bySpecies ) and it should be extremely easy to implement your own strategy for more specific attack scenarios.horde.stop()
. Gizmo
uses this method to prevent a subsequent attack on the application after 10 errors. You can also use this method if you do not want the attack to continue.logger
object with four methods (log, info, warn, and error) to the logger()
method : var customLogger = { log: function(msg) { /* .. */ }, info: function(msg) { /* .. */ }, warn: function(msg) { /* .. */ }, error: function(msg) { /* .. */ } }; horde.logger(customLogger);
Source: https://habr.com/ru/post/216805/
All Articles