From c3b7e65eb333c3c081679db3664b86dd600aad31 Mon Sep 17 00:00:00 2001 From: Doron Tzur Date: Thu, 27 Jun 2019 12:24:02 +0300 Subject: [PATCH] Added version. Fixed issue of non-supported policies --- README.md | 1 + settings.js | 14 +++++++++----- spv.js | 1 + utils.js | 7 ++++++- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 0decd31..29d42b9 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ The tool can be used with it's default settings or if needed, user may change th - **protectionDisplay** - Use these settings to control the display of whether a setting is considered protected or not. - **printDebugInfo** - (default false) - *true* to print debug info during execution - **numConcurrentConnections** - (default 15) - Number of concurrent open API sessions + - **defaultProtectionDisplayPolicy** - This is used if specific action was not set in protectionDisplay - **originServerConnectionTimeout** - (default 10000 miliseconds) Timeout for connection request to origin-server. Note that if the number is too low it may cause timeout before server actually responds which implies server is protected ## Run tool diff --git a/settings.js b/settings.js index 4431555..e473bc0 100644 --- a/settings.js +++ b/settings.js @@ -1,5 +1,5 @@ module.exports = Object.freeze({ -//Configuration + //Configuration accountId: "", // Your account ID - Mandatory apiId: "", // Your api id - Mandatory apiKey: "", // Your api key - Mandatory @@ -17,7 +17,6 @@ module.exports = Object.freeze({ originServerFileNamePrefix: "", // When empty string will use 'Origin-servers' String used as prefix for origin server csv file // Advanced configuration - //When origin servers are checked, if one of these codes is returned, it implies that the origin server was NOT reached - it is protected // Some common error codes can be found in https://nodejs.org/api/errors.html originServerProtectedCode: [ @@ -25,7 +24,7 @@ module.exports = Object.freeze({ "ECONNREFUSED", //(Connection refused): No connection could be made because the target machine actively refused it. This usually results from trying to connect to a service that is inactive on the foreign host. (from https://www.codingdefined.com/2015/06/nodejs-error-errno-eaiagain.html) "ECONNRESET", //(Connection reset by peer): A connection was forcibly closed by a peer. This normally results from a loss of the connection on the remote socket due to a timeout or reboot. Commonly encountered via the http and net modules "ENOTFOUND", //(DNS lookup failed): Indicates a DNS failure of either EAI_NODATA or EAI_NONAME. This is not a standard POSIX error - "ETIMEDOUT" //(Operation timed out): A connect or send request failed because the connected party did not properly respond after a period of time. Usually encountered by http or net — often a sign that a socket.end() was not properly called + "ETIMEDOUT" //(Operation timed out): A connect or send request failed because the connected party did not properly respond after a period of time. Usually encountered by http or net � often a sign that a socket.end() was not properly called ], /* These settings will defines per rule if protected. Per rule (id). The received paramters values from the API are compared and if equal to @@ -71,14 +70,19 @@ module.exports = Object.freeze({ } ], + defaultProtectionDisplayPolicy: "api.threats.action.block_request", //This is used if specific action was not set in protectionDisplay + printDebugInfo: false, numConcurrentConnections: 15, //Number of concurrent open API sessions /*After this time the connection request will timeout. Note that if the number is too low it may cause timeout before server actually responds which implies server is protected */ originServerConnectionTimeout: 10000, //(In milliseconds) - - pageSize: 100 //Internal usage + +//Internal usage + + version: "2.0", + pageSize: 100 }); diff --git a/spv.js b/spv.js index 38c4ec5..d49d63e 100644 --- a/spv.js +++ b/spv.js @@ -73,6 +73,7 @@ if (validData == false) var fullPage = {sites: []}; +console.log("site-protection-viewer version: " + settings.version); console.log("Start generating report"); if (checkOriginServers) console.log("Note that checkOriginServers = true. This means that total run time will be longer") diff --git a/utils.js b/utils.js index ee0eec3..71d2add 100644 --- a/utils.js +++ b/utils.js @@ -16,15 +16,20 @@ function saveToFile(filename, data) function getDisplayPolicy(id) { - var policy; + var policy = settings.defaultProtectionDisplayPolicy; + var found = false; for (var i = 0; i < settings.protectionDisplay.length; i++) { if (settings.protectionDisplay[i].id == id) { policy = settings.protectionDisplay[i]; + found = true; break; } } + + if (!found) + console.log(id + " is not supported by this tool" ) return (policy); }