Skip to content
This repository was archived by the owner on Oct 29, 2025. It is now read-only.

Commit 7a038e8

Browse files
authored
Merge pull request #284 from PerimeterX/bugfix/pxCookieValidator_customIsSensitive
Bugfix/px cookie validator custom is sensitive
2 parents 60200c6 + e93cea9 commit 7a038e8

File tree

7 files changed

+37
-22
lines changed

7 files changed

+37
-22
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

8-
## [3.10.0] - 2023-03-28
8+
9+
## [3.10.1] - 2023-03-29
10+
11+
### Fixed
12+
- Bug fixed in pxCookieValidator which fails on invalid variable name.
13+
14+
## [3.10.0] - 2023-03-28 (removed)
915

1016
### Added
1117
- Support for handling graphQL requests with empty query field

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[PerimeterX](http://www.perimeterx.com) Shared base for NodeJS enforcers
77
=============================================================
88

9-
> Latest stable version: [v3.10.0](https://www.npmjs.com/package/perimeterx-node-core)
9+
> Latest stable version: [v3.10.1](https://www.npmjs.com/package/perimeterx-node-core)
1010
1111
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.
1212

lib/pxcookie.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ function evalCookie(ctx, config) {
8181
return ScoreEvaluateAction.COOKIE_INVALID;
8282
}
8383

84-
if (ctx.sensitiveRoute()) {
84+
if (ctx.sensitiveRequest()) {
8585
config.logger.debug(`Sensitive route match, sending Risk API. path: ${ctx.uri}`);
8686
ctx.s2sCallReason = 'sensitive_route';
8787
return ScoreEvaluateAction.SENSITIVE_ROUTE;

lib/pxenforcer.js

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,15 @@ class PxEnforcer {
4646
}
4747
this.reversePrefix = this.pxConfig.conf.PX_APP_ID.substring(2);
4848
this.initializeCredentialsIntelligence(this.logger, this._config);
49-
5049
}
5150

5251
initializeCredentialsIntelligence(logger, config) {
5352
if (config.ENABLE_LOGIN_CREDS_EXTRACTION && config.LOGIN_CREDS_EXTRACTION.length > 0) {
54-
this.loginCredentialsExtractor = new LoginCredentialsExtractor(logger, config.CREDENTIALS_INTELLIGENCE_VERSION, config.LOGIN_CREDS_EXTRACTION);
53+
this.loginCredentialsExtractor = new LoginCredentialsExtractor(
54+
logger,
55+
config.CREDENTIALS_INTELLIGENCE_VERSION,
56+
config.LOGIN_CREDS_EXTRACTION,
57+
);
5558
this.loginSuccessfulParser = LoginSuccessfulParserFactory.Create(config);
5659
}
5760
}
@@ -335,8 +338,8 @@ class PxEnforcer {
335338
const isJsonResponse =
336339
this._config.ADVANCED_BLOCKING_RESPONSE &&
337340
acceptHeaderValue &&
338-
acceptHeaderValue.split(',').find((value) => value.toLowerCase() === 'application/json') &&
339-
(ctx.cookieOrigin !== CookieOrigin.HEADER) &&
341+
acceptHeaderValue.split(',').find((value) => value.trim().toLowerCase() === 'application/json') &&
342+
ctx.cookieOrigin !== CookieOrigin.HEADER &&
340343
ctx.blockAction !== 'r';
341344

342345
this.logger.debug(
@@ -346,7 +349,7 @@ class PxEnforcer {
346349
);
347350
const config = this._config;
348351

349-
this.generateResponse(ctx, isJsonResponse, function(responseObject) {
352+
this.generateResponse(ctx, isJsonResponse, function (responseObject) {
350353
const response = {
351354
status: '403',
352355
statusDescription: 'Forbidden',
@@ -373,11 +376,11 @@ class PxEnforcer {
373376
hostUrl: responseObject.hostUrl,
374377
blockScript: responseObject.blockScript,
375378
altBlockScript: responseObject.altBlockScript,
376-
customLogo: responseObject.customLogo
379+
customLogo: responseObject.customLogo,
377380
};
378381
return cb(null, response);
379382
}
380-
383+
381384
pxUtil.appendContentType(response, 'text/html');
382385

383386
response.body = responseObject;
@@ -422,7 +425,7 @@ class PxEnforcer {
422425
const details = {
423426
...this.getActivityDetails(ctx),
424427
px_cookie: ctx.decodedCookie,
425-
pass_reason: ctx.passReason
428+
pass_reason: ctx.passReason,
426429
};
427430
if (ctx.serverInfoRegion) {
428431
details['server_info_region'] = ctx.serverInfoRegion;
@@ -432,7 +435,11 @@ class PxEnforcer {
432435
this.setS2SErrorInfo(details, ctx.s2sErrorInfo);
433436
}
434437

435-
if (this._config.ENABLE_LOGIN_CREDS_EXTRACTION && ctx.additionalFields && ctx.additionalFields.loginCredentials) {
438+
if (
439+
this._config.ENABLE_LOGIN_CREDS_EXTRACTION &&
440+
ctx.additionalFields &&
441+
ctx.additionalFields.loginCredentials
442+
) {
436443
this.handleCredentialsIntelligenceInPageRequestedActivity(ctx, req, details);
437444
}
438445

@@ -451,9 +458,11 @@ class PxEnforcer {
451458

452459
if (this._config.ENABLE_ADDITIONAL_S2S_ACTIVITY_HEADER) {
453460
req.headers[Constants.DEFAULT_ADDITIONAL_ACTIVITY_HEADER_NAME] = JSON.stringify(
454-
this.pxClient.generateAdditionalS2SActivity(ctx, this._config)
461+
this.pxClient.generateAdditionalS2SActivity(ctx, this._config),
455462
);
456-
req.headers[Constants.DEFAULT_ADDITIONAL_ACTIVITY_URL_HEADER_NAME] = `${this._config.BACKEND_URL}${this._config.SERVER_COLLECT_URI}`;
463+
req.headers[
464+
Constants.DEFAULT_ADDITIONAL_ACTIVITY_URL_HEADER_NAME
465+
] = `${this._config.BACKEND_URL}${this._config.SERVER_COLLECT_URI}`;
457466
}
458467
}
459468

@@ -561,9 +570,9 @@ class PxEnforcer {
561570

562571
getProps(ctx) {
563572
let jsClientSrc = `//${this._config.CLIENT_HOST}/${this._config.PX_APP_ID}/main.min.js`;
564-
const captchaParams = `/captcha.js?a=${ctx.blockAction}&u=${
565-
ctx.uuid
566-
}&v=${ctx.vid || ''}&m=${ctx.isMobile() ? '1' : '0'}`;
573+
const captchaParams = `/captcha.js?a=${ctx.blockAction}&u=${ctx.uuid}&v=${ctx.vid || ''}&m=${
574+
ctx.isMobile() ? '1' : '0'
575+
}`;
567576
let captchaSrc = `//${this._config.CAPTCHA_HOST}/${this._config.PX_APP_ID}${captchaParams}`;
568577
let hostUrl = ctx.collectorUrl;
569578

@@ -586,7 +595,7 @@ class PxEnforcer {
586595
firstPartyEnabled: this._config.FIRST_PARTY_ENABLED,
587596
isMobile: ctx.isMobile(),
588597
blockScript: captchaSrc,
589-
altBlockScript: `${this._config.BACKUP_CAPTCHA_HOST}/${this._config.PX_APP_ID}${captchaParams}`
598+
altBlockScript: `${this._config.BACKUP_CAPTCHA_HOST}/${this._config.PX_APP_ID}${captchaParams}`,
590599
};
591600
}
592601

lib/pxtesthandler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function customRequestHandler(ctx, config, req, res) {
1717
headers: ctx.headers,
1818
user_agent: ctx.userAgent,
1919
is_made_s2s_api_call: ctx.hasMadeServerCall || false,
20-
sensitive_route: ctx.sensitiveRoute,
20+
sensitive_route: ctx.sensitiveRequest(),
2121
sensitive_routes_list: config.SENSITIVE_ROUTES,
2222
whitelist_routes: config.WHITELIST_ROUTES,
2323
decoded_px_cookie: ctx.decodedCookie,

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "perimeterx-node-core",
3-
"version": "3.10.0",
3+
"version": "3.10.1",
44
"description": "PerimeterX NodeJS shared core for various applications to monitor and block traffic according to PerimeterX risk score",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)