UNPKG

@passmarked/malware

Version:

Rules that check if the page or linked pages on the same domain (or external) contain any unwanted software,malware or reported phishing attacks

75 lines (53 loc) 1.33 kB
/** * Required modules **/ const async = require('async'); const url = require('url'); const request = require('request'); const S = require('string'); const _ = require('underscore'); const Constants = require('../constants'); /** * Object to expose **/ var Driver = {}; /** * Load in our providers to use **/ Driver.drivers = [ require('./phistank'), require('./safebrowsing') ]; /** * Does the actual check **/ Driver.check = function(payload, links, fn) { // problems we found var detections = []; // run each link async.eachLimit(links || [], 20, function(link, cbb) { // loop and check them all async.each(Driver.drivers, function(driverFunc, cb) { // run the driver driverFunc.check(payload, link, function(err, driverDetections) { // add all the returned issues for(var i = 0; i < (driverDetections || []).length; i++) { // add to our list detections.push(driverDetections[i]); } // finish cb(err); }); }, function(err) { // done cbb(err); }); }, function(err) { // ignore error here as we do this at each driver to more detailed errors fn(err, detections); }); }; /** * Expose the given object **/ module.exports = exports = Driver;