Skip to content
This repository was archived by the owner on Oct 29, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ language: node_js
node_js:
- "lts/*"
- "12"
- "11"
- "10"
- "8"

sudo: required
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [2.2.1] - 2019-05-24
### Added
- fixed timeout error, lint fixes
- removed node 11 from tests because it turned EOL

## [2.2.0] - 2019-05-06
### Added
- Send telemetry by command
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[PerimeterX](http://www.perimeterx.com) Shared base for NodeJS enforcers
=============================================================

> Latest stable version: [v2.2.0](https://www.npmjs.com/package/perimeterx-node-core)
> Latest stable version: [v2.2.1](https://www.npmjs.com/package/perimeterx-node-core)

This is a shared base implementation for PerimeterX Express enforcer and future NodeJS enforcers. For a fully functioning implementation example, see the [Node-Express enforcer](https://github.com/PerimeterX/perimeterx-node-express/) implementation.

Expand Down
2 changes: 1 addition & 1 deletion lib/configloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ConfigLoader {
};
request.get(callData, this.config, (error, response) => {
if (error || !response || !(response.statusCode === 200 || response.statusCode === 204)) {
this.config.logger.error(`Failed to get configurations: ${error}`);
this.config.logger.debug(`Failed to get configurations: ${error}`);
if (!checksum) { //no configuration loaded and we can't get configuration - disable module
this.config.logger.debug('Failed to pull initial config, switching module to disable until remote configuration found');
this.config.ENABLE_MODULE = false;
Expand Down
2 changes: 1 addition & 1 deletion lib/pxapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function callServer(ctx, config, callback) {
data.additional['px_decoded_original_token'] = ctx.decodedOriginalToken;
}

if(ctx.hmac) {
if (ctx.hmac) {
data.additional['px_cookie_hmac'] = ctx.hmac;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/pxconfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class PxConfig {
}
}
mergedParams = Object.assign(configParams, fileMappedConfig);
} catch(err) {
} catch (err) {
this.logger.error('Failed while trying to read the config json file, ' + err);
}
return mergedParams;
Expand Down
4 changes: 2 additions & 2 deletions lib/pxenforcer.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class PxEnforcer {
}

try {
if(telemetryHandler.isTelemetryCommand(req, this._config)) {
if (telemetryHandler.isTelemetryCommand(req, this._config)) {
this.pxClient.sendEnforcerTelemetry('command', this._config);
}
} catch (err) {
Expand Down Expand Up @@ -134,7 +134,7 @@ class PxEnforcer {
return callback(this._config.SCORE_EVALUATE_ACTION.S2S_BLOCK_TRAFFIC);
}

if(action === this._config.SCORE_EVALUATE_ACTION.S2S_TIMEOUT_PASS) {
if (action === this._config.SCORE_EVALUATE_ACTION.S2S_TIMEOUT_PASS) {
this.logger.debug(`Risk API timed out , round_trip_time: ${ctx.riskRtt}ms`);
return callback(this._config.SCORE_EVALUATE_ACTION.S2S_TIMEOUT_PASS);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/pxhttpc.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function callServer(data, headers, uri, callType, config, callback) {
request.post(callData, config, function (err, response) {
let data;
if (err) {
if (err === 'Error: Timeout has been reached.' || err === 'Error: Timeout reached') {
if (err.toString().toLowerCase().includes('timeout')) {
return callback('timeout');
} else {
return callback(`perimeterx server did not return a valid response. Error: ${err}`);
Expand Down
4 changes: 2 additions & 2 deletions lib/pxutil.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function filterSensitiveHeaders(headers, sensitiveKeys) {
}
}
return retval;
} catch(e) {
} catch (e) {
return headers;
}
}
Expand All @@ -81,7 +81,7 @@ function generateProxyHeaders(headers, ip, sensitiveHeaders, forwardedForHeader)
filteredHeaders[forwardedForHeader] = ip;
}
return filteredHeaders;
} catch(e) {
} catch (e) {
return headers;
}
}
Expand Down
6 changes: 3 additions & 3 deletions lib/telemetry_handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function isTelemetryCommand(req, config) {
const logger = new PxLogger();
const headerVal = req.headers[config.TELEMETRY_COMMAND_HEADER];

if(!headerVal) {
if (!headerVal) {
return false;
}

Expand All @@ -22,15 +22,15 @@ function isTelemetryCommand(req, config) {
// value is in the form of timestamp:hmac_val
const splittedValue = decodedString.split(':');

if(splittedValue.length !== 2) {
if (splittedValue.length !== 2) {
logger.debug('Malformed header value - ${config.TELEMETRY_COMMAND_HEADER} = ${headerVal}');
return false;
}

const [timestamp, hmac] = splittedValue;

// timestamp
if(Number(timestamp) < new Date().getTime()) {
if (Number(timestamp) < new Date().getTime()) {
logger.debug('Telemetry command has expired');
return false;
}
Expand Down
24 changes: 10 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "perimeterx-node-core",
"version": "2.2.0",
"version": "2.2.1",
"description": "PerimeterX NodeJS shared core for various applications to monitor and block traffic according to PerimeterX risk score",
"main": "index.js",
"scripts": {
Expand All @@ -27,7 +27,7 @@
},
"devDependencies": {
"eslint": "^5.16.0",
"eslint-config-perimeterx": "^0.2.0",
"eslint-config-perimeterx": "^0.3.0",
"mocha": "^5.2.0",
"rewire": "^2.5.2",
"should": "^8.3.0",
Expand Down