From 3f88164a130e1e22575cf4592c2d9b304ed7f456 Mon Sep 17 00:00:00 2001 From: chenzimmer2 Date: Tue, 28 Mar 2023 17:14:47 +0300 Subject: [PATCH 1/4] Released version 7.7.0 --- CHANGELOG.md | 7 +++++++ README.md | 21 ++++++++++++++++++++- lib/pxenforcer.js | 2 +- package.json | 4 ++-- px_metadata.json | 3 ++- 5 files changed, 32 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f6c6930..61207c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ 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/). +## [7.7.0] - 2023-03-28 + +### Added + +- Support for handling graphQL requests with empty query field +- Support custom is sensitive request via function + ## [7.6.0] - 2023-01-26 ### Added diff --git a/README.md b/README.md index 2bffa8c..9b777d1 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ # [PerimeterX](http://www.perimeterx.com) Express.js Middleware -> Latest stable version: [v7.6.0](https://www.npmjs.com/package/perimeterx-node-express) +> Latest stable version: [v7.7.0](https://www.npmjs.com/package/perimeterx-node-express) ## Table of Contents @@ -931,6 +931,25 @@ const pxConfig = { }; ``` +#### Custom Is Sensitive Request +Allows writing your own logic to decide whether the request is sensitive. +The custom sensitive request function gets the request object as a parameter and should return true, otherwise, return false. Throwing an exception is equivalent to `false`. + +**Default**: Empty + +```javascript +const pxConfig = { + ... + px_custom_is_sensitive_request: function(req) { + if (req.method === 'GET' && req.body && req.body.test) { + return true; + } + return false; + } + ... +``` + + **Default:** `null` ## Code Defender Middleware - cdMiddleware diff --git a/lib/pxenforcer.js b/lib/pxenforcer.js index 3cc2584..0a01ec4 100644 --- a/lib/pxenforcer.js +++ b/lib/pxenforcer.js @@ -4,7 +4,7 @@ const { PxEnforcer, PxCdFirstParty } = require('perimeterx-node-core'); const PxExpressClient = require('./pxclient'); const PxCdEnforcer = require('./pxcdenforcer'); -const MODULE_VERSION = 'NodeJS Module v7.6.0'; +const MODULE_VERSION = 'NodeJS Module v7.7.0'; const MILLISECONDS_IN_MINUTE = 60000; function parseCookies(req, res) { diff --git a/package.json b/package.json index 6f73f9a..3d332a3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "perimeterx-node-express", - "version": "7.6.0", + "version": "7.7.0", "description": "PerimeterX Express.js middleware to monitor and block traffic according to PerimeterX risk score", "main": "index.js", "directories": { @@ -31,7 +31,7 @@ "dependencies": { "axios": "^0.21.1", "cookie-parser": "^1.4.1", - "perimeterx-node-core": "^3.9.0" + "perimeterx-node-core": "3.10.0" }, "devDependencies": { "chai": "^4.3.6", diff --git a/px_metadata.json b/px_metadata.json index 56dc4ea..a1e8108 100644 --- a/px_metadata.json +++ b/px_metadata.json @@ -1,5 +1,5 @@ { - "version": "7.6.0", + "version": "7.7.0", "supported_features": [ "additional_activity_handler", "advanced_blocking_response", @@ -19,6 +19,7 @@ "custom_logo", "custom_parameters", "custom_proxy", + "custom_sensitive_request", "enforced_routes", "filter_by_route", "filter_by_http_method", From da7245732159221241daf2ab6db2912267022145 Mon Sep 17 00:00:00 2001 From: chenzimmer2 Date: Sun, 2 Apr 2023 13:08:38 +0300 Subject: [PATCH 2/4] changed node core version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3d332a3..f1513b2 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "dependencies": { "axios": "^0.21.1", "cookie-parser": "^1.4.1", - "perimeterx-node-core": "3.10.0" + "perimeterx-node-core": "^3.10.1" }, "devDependencies": { "chai": "^4.3.6", From e2514d88d39234a37c2bc17b39b7da31fb23bab8 Mon Sep 17 00:00:00 2001 From: chenzimmer2 Date: Sun, 2 Apr 2023 13:23:35 +0300 Subject: [PATCH 3/4] Fixed comments --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9b777d1..1cfcb47 100644 --- a/README.md +++ b/README.md @@ -941,7 +941,7 @@ The custom sensitive request function gets the request object as a parameter and const pxConfig = { ... px_custom_is_sensitive_request: function(req) { - if (req.method === 'GET' && req.body && req.body.test) { + if (req.method === 'POST' && req.body && req.body.test) { return true; } return false; From a0646807aaf9445ee982776541c7777bb650ad2f Mon Sep 17 00:00:00 2001 From: chenzimmer2 Date: Sun, 2 Apr 2023 13:24:58 +0300 Subject: [PATCH 4/4] Fixed comments --- README.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/README.md b/README.md index 1cfcb47..7009532 100644 --- a/README.md +++ b/README.md @@ -941,10 +941,7 @@ The custom sensitive request function gets the request object as a parameter and const pxConfig = { ... px_custom_is_sensitive_request: function(req) { - if (req.method === 'POST' && req.body && req.body.test) { - return true; - } - return false; + return req.method === 'POST' && req.body && req.body.test; } ... ```