Skip to content

Commit

Permalink
Added version.
Browse files Browse the repository at this point in the history
Fixed issue of non-supported policies
  • Loading branch information
dtzur1 committed Jun 27, 2019
1 parent e8519a7 commit c3b7e65
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 9 additions & 5 deletions settings.js
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -17,15 +17,14 @@ 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: [
"EAI_AGAIN", // This is a DNS lookup timed out error means it is either a network connectivity error or some proxy related error
"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
Expand Down Expand Up @@ -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

});

Expand Down
1 change: 1 addition & 0 deletions spv.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
7 changes: 6 additions & 1 deletion utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit c3b7e65

Please sign in to comment.