@contrast/protect 1.57.0 → 1.59.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -21,7 +21,7 @@ module.exports = function(core) {
21
21
  const inputAnalysis = core.protect.inputAnalysis = {};
22
22
 
23
23
  // inputAnalysis handlers
24
- require('./handlers')(core);
24
+ core.initComponentSync(require('./handlers'));
25
25
 
26
26
  // http(s) modules instrumentation
27
27
  require('./install/http')(core);
@@ -328,7 +328,7 @@ module.exports = function(core) {
328
328
  * @returns {AnalysisResult[]}
329
329
  */
330
330
  function getResultsByRuleId(ruleId, context) {
331
- if (context.policy[ruleId] === OFF) {
331
+ if (!context.policy || context.policy[ruleId] === OFF) {
332
332
  return;
333
333
  }
334
334
  // because agent-lib stores all nosql-injection results under nosql-injection-mongo
@@ -36,7 +36,7 @@ module.exports = function init(core) {
36
36
  // obtain the Protect sourceContext
37
37
  const sourceContext = core.protect.getSourceContext();
38
38
 
39
- if (!sourceContext) return;
39
+ if (!sourceContext || sourceContext.allowed) return;
40
40
 
41
41
  // build list of values on which to perform INPUT TRACING
42
42
  const values = getValues(indices, args);
@@ -22,7 +22,13 @@ module.exports = function(core) {
22
22
  protect: { getPolicy }
23
23
  } = core;
24
24
 
25
+ const disabledPolicy = { allowed: true };
26
+
25
27
  function makeSourceContext(req, res) {
28
+ if (!core.config.getEffectiveValue('protect.enable')) {
29
+ return disabledPolicy;
30
+ }
31
+
26
32
  // make the abstract request. it is an abstraction of a request that
27
33
  // contains only the pieces of the request required by handlers. this
28
34
  // is done to make an explicit contract for data that is required by
@@ -47,7 +53,7 @@ module.exports = function(core) {
47
53
 
48
54
  // URL exclusions can disable all rules
49
55
  if (!policy || policy.rulesMask === 0) {
50
- return { allowed: true };
56
+ return disabledPolicy;
51
57
  }
52
58
 
53
59
  // lowercase header keys and capture content-type
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrast/protect",
3
- "version": "1.57.0",
3
+ "version": "1.59.0",
4
4
  "description": "Contrast service providing framework-agnostic Protect support",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": "Contrast Security <nodejs@contrastsecurity.com> (https://www.contrastsecurity.com)",
@@ -22,15 +22,15 @@
22
22
  "dependencies": {
23
23
  "@contrast/agent-lib": "^9.1.0",
24
24
  "@contrast/common": "1.32.0",
25
- "@contrast/config": "1.43.0",
26
- "@contrast/core": "1.48.0",
27
- "@contrast/dep-hooks": "1.17.0",
28
- "@contrast/esm-hooks": "2.22.0",
29
- "@contrast/instrumentation": "1.27.0",
30
- "@contrast/logger": "1.21.0",
31
- "@contrast/patcher": "1.20.0",
32
- "@contrast/rewriter": "1.24.0",
33
- "@contrast/scopes": "1.18.0",
25
+ "@contrast/config": "1.45.0",
26
+ "@contrast/core": "1.50.0",
27
+ "@contrast/dep-hooks": "1.19.0",
28
+ "@contrast/esm-hooks": "2.24.0",
29
+ "@contrast/instrumentation": "1.29.0",
30
+ "@contrast/logger": "1.23.0",
31
+ "@contrast/patcher": "1.22.0",
32
+ "@contrast/rewriter": "1.26.0",
33
+ "@contrast/scopes": "1.20.0",
34
34
  "async-hook-domain": "^4.0.1",
35
35
  "ipaddr.js": "^2.0.1",
36
36
  "on-finished": "^2.4.1",