@contrast/protect 1.3.0 → 1.5.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.
Files changed (49) hide show
  1. package/lib/error-handlers/index.js +7 -4
  2. package/lib/error-handlers/install/express4.js +2 -3
  3. package/lib/error-handlers/install/{fastify3.js → fastify.js} +13 -15
  4. package/lib/error-handlers/install/hapi.js +75 -0
  5. package/lib/error-handlers/install/koa2.js +1 -2
  6. package/lib/{cli-rewriter.js → get-source-context.js} +13 -15
  7. package/lib/hardening/constants.js +20 -0
  8. package/lib/hardening/handlers.js +65 -0
  9. package/lib/hardening/index.js +29 -0
  10. package/lib/hardening/install/node-serialize0.js +59 -0
  11. package/lib/index.d.ts +3 -21
  12. package/lib/index.js +6 -46
  13. package/lib/input-analysis/handlers.js +198 -39
  14. package/lib/input-analysis/index.js +9 -6
  15. package/lib/input-analysis/install/body-parser1.js +20 -18
  16. package/lib/input-analysis/install/cookie-parser1.js +13 -15
  17. package/lib/input-analysis/install/express4.js +8 -13
  18. package/lib/input-analysis/install/fastify.js +86 -0
  19. package/lib/input-analysis/install/formidable1.js +4 -5
  20. package/lib/input-analysis/install/hapi.js +106 -0
  21. package/lib/input-analysis/install/http.js +80 -30
  22. package/lib/input-analysis/install/koa-body5.js +5 -10
  23. package/lib/input-analysis/install/koa-bodyparser4.js +6 -10
  24. package/lib/input-analysis/install/koa2.js +13 -24
  25. package/lib/input-analysis/install/multer1.js +5 -6
  26. package/lib/input-analysis/install/qs6.js +7 -11
  27. package/lib/input-analysis/install/universal-cookie4.js +3 -7
  28. package/lib/input-analysis/ip-analysis.js +76 -0
  29. package/lib/input-analysis/virtual-patches.js +109 -0
  30. package/lib/input-tracing/handlers/index.js +92 -23
  31. package/lib/input-tracing/index.js +14 -18
  32. package/lib/input-tracing/install/child-process.js +13 -7
  33. package/lib/input-tracing/install/eval.js +60 -0
  34. package/lib/input-tracing/install/fs.js +4 -2
  35. package/lib/input-tracing/install/function.js +60 -0
  36. package/lib/input-tracing/install/http.js +63 -0
  37. package/lib/input-tracing/install/mongodb.js +20 -20
  38. package/lib/input-tracing/install/mysql.js +3 -2
  39. package/lib/input-tracing/install/postgres.js +5 -4
  40. package/lib/input-tracing/install/sequelize.js +7 -5
  41. package/lib/input-tracing/install/sqlite3.js +6 -4
  42. package/lib/input-tracing/install/vm.js +132 -0
  43. package/lib/make-source-context.js +8 -49
  44. package/lib/policy.js +134 -0
  45. package/lib/semantic-analysis/handlers.js +161 -0
  46. package/lib/semantic-analysis/index.js +38 -0
  47. package/package.json +7 -9
  48. package/lib/input-analysis/install/fastify3.js +0 -107
  49. package/lib/utils.js +0 -84
@@ -18,14 +18,17 @@
18
18
  module.exports = function(core) {
19
19
  const errorHandlers = core.protect.errorHandlers = {};
20
20
 
21
- require('./install/fastify3')(core);
21
+ require('./install/fastify')(core);
22
22
  require('./install/koa2')(core);
23
23
  require('./install/express4')(core);
24
+ require('./install/hapi')(core);
24
25
 
25
26
  errorHandlers.install = function() {
26
- errorHandlers.fastify3ErrorHandler.install();
27
- errorHandlers.koa2ErrorHandler.install();
28
- errorHandlers.express4ErrorHandler.install();
27
+ for (const component of Object.values(errorHandlers)) {
28
+ if (component.install) {
29
+ component.install();
30
+ }
31
+ }
29
32
  };
30
33
 
31
34
  return errorHandlers;
@@ -24,7 +24,6 @@ module.exports = function(core) {
24
24
  logger,
25
25
  depHooks,
26
26
  patcher,
27
- scopes: { sources },
28
27
  protect,
29
28
  } = core;
30
29
 
@@ -41,7 +40,7 @@ module.exports = function(core) {
41
40
  patchType,
42
41
  around(org, data) {
43
42
  const [err] = data.args;
44
- const sourceContext = sources.getStore()?.protect;
43
+ const sourceContext = protect.getSourceContext('finalHandler');
45
44
  const isSecurityException = SecurityException.isSecurityException(err);
46
45
 
47
46
  if (isSecurityException && sourceContext) {
@@ -67,7 +66,7 @@ module.exports = function(core) {
67
66
  patchType,
68
67
  around(org, data) {
69
68
  const [err] = data.args;
70
- const sourceContext = sources.getStore()?.protect;
69
+ const sourceContext = protect.getSourceContext('express.Layer.handle_error');
71
70
  const isSecurityException = SecurityException.isSecurityException(err);
72
71
 
73
72
  if (isSecurityException && sourceContext) {
@@ -20,14 +20,12 @@ const { patchType } = require('../constants');
20
20
 
21
21
  module.exports = function(core) {
22
22
  const {
23
- logger,
24
23
  depHooks,
25
24
  patcher,
26
- scopes: { sources },
27
25
  protect,
28
26
  } = core;
29
27
 
30
- const fastify3ErrorHandler = protect.errorHandlers.fastify3ErrorHandler = {
28
+ const fastifyErrorHandler = protect.errorHandlers.fastifyErrorHandler = {
31
29
  _userHandler: null
32
30
  };
33
31
 
@@ -35,7 +33,7 @@ module.exports = function(core) {
35
33
  * This is the default handler from fastify's source code. If it's not a
36
34
  * Contrast error and the user didn't supply their own we should use this.
37
35
  */
38
- fastify3ErrorHandler.defaultErrorHandler = function (error, request, reply) {
36
+ fastifyErrorHandler.defaultErrorHandler = function (error, request, reply) {
39
37
  if (reply.statusCode < 500) {
40
38
  reply.log.info({ res: reply, err: error }, error && error.message);
41
39
  } else {
@@ -49,19 +47,19 @@ module.exports = function(core) {
49
47
 
50
48
  /**
51
49
  * Check if the error being handled was thrown by Contrast. If not,
52
- * use either the default fastify3 error handler or the user-defined handler
50
+ * use either the default fastify error handler or the user-defined handler
53
51
  * if one was specified by calling fastify.setErrorHandler(fn).
54
52
  * @param {error} err error being handled
55
53
  * @param {object} request fastify request
56
54
  * @param {object} reply fastify repoly
57
55
  */
58
- fastify3ErrorHandler.handler = function(err, request, reply) {
59
- const normalHandler = fastify3ErrorHandler._userHandler || fastify3ErrorHandler.defaultErrorHandler;
56
+ fastifyErrorHandler.handler = function(err, request, reply) {
57
+ const normalHandler = fastifyErrorHandler._userHandler || fastifyErrorHandler.defaultErrorHandler;
60
58
 
61
59
  if (isSecurityException(err)) {
62
- const sourceContext = sources.getStore()?.protect;
60
+ const sourceContext = protect.getSourceContext('fastify.errorHandler');
61
+
63
62
  if (!sourceContext) {
64
- logger.info('source context not found; unable to handle response');
65
63
  normalHandler.call(this, err, request, reply);
66
64
  } else {
67
65
  const blockInfo = sourceContext.findings.securityException;
@@ -75,14 +73,14 @@ module.exports = function(core) {
75
73
  /**
76
74
  * Instruments fastify in order to add our custom error handler.
77
75
  */
78
- fastify3ErrorHandler.install = function() {
79
- depHooks.resolve({ name: 'fastify', version: '<=4.0.0' }, (fastify) => patcher.patch(fastify, {
76
+ fastifyErrorHandler.install = function() {
77
+ depHooks.resolve({ name: 'fastify', version: '<=3 <5' }, (fastify) => patcher.patch(fastify, {
80
78
  name: 'fastify',
81
79
  patchType,
82
80
  post(data) {
83
81
  const { result: server } = data;
84
82
  // Set our custom handler initially
85
- server.setErrorHandler(fastify3ErrorHandler.handler);
83
+ server.setErrorHandler(fastifyErrorHandler.handler);
86
84
 
87
85
  // Patch, so that if someone sets their own, we override with ours. But,
88
86
  // we do need to keep a reference to it so we can still call it for when
@@ -91,13 +89,13 @@ module.exports = function(core) {
91
89
  name: 'fastify.setErrorHandler',
92
90
  patchType,
93
91
  pre({ args }) {
94
- fastify3ErrorHandler._userHandler = args[0];
95
- args[0] = fastify3ErrorHandler.handler;
92
+ fastifyErrorHandler._userHandler = args[0];
93
+ args[0] = fastifyErrorHandler.handler;
96
94
  }
97
95
  });
98
96
  }
99
97
  }));
100
98
  };
101
99
 
102
- return fastify3ErrorHandler;
100
+ return fastifyErrorHandler;
103
101
  };
@@ -0,0 +1,75 @@
1
+ /*
2
+ * Copyright: 2022 Contrast Security, Inc
3
+ * Contact: support@contrastsecurity.com
4
+ * License: Commercial
5
+
6
+ * NOTICE: This Software and the patented inventions embodied within may only be
7
+ * used as part of Contrast Security’s commercial offerings. Even though it is
8
+ * made available through public repositories, use of this Software is subject to
9
+ * the applicable End User Licensing Agreement found at
10
+ * https://www.contrastsecurity.com/enduser-terms-0317a or as otherwise agreed
11
+ * between Contrast Security and the End User. The Software may not be reverse
12
+ * engineered, modified, repackaged, sold, redistributed or otherwise used in a
13
+ * way not consistent with the End User License Agreement.
14
+ */
15
+
16
+ 'use strict';
17
+
18
+ const SecurityException = require('../../security-exception');
19
+ const { patchType } = require('../constants');
20
+
21
+
22
+ module.exports = function (core) {
23
+ const {
24
+ logger,
25
+ depHooks,
26
+ patcher,
27
+ protect,
28
+ } = core;
29
+
30
+ const hapiErrorHandler = protect.errorHandlers.hapiErrorHandler = {};
31
+
32
+ const registerErrorHandler = (boom, name) => {
33
+ patcher.patch(boom, 'boomify', {
34
+ name: `${name}.boomify`,
35
+ patchType,
36
+ post(data) {
37
+ const [err] = data.args;
38
+ const sourceContext = protect.getSourceContext('Hapi.boom.boomify');
39
+ const isSecurityException = SecurityException.isSecurityException(err);
40
+
41
+ if (isSecurityException && sourceContext && err.output.statusCode !== 403) {
42
+ const [mode, ruleId] = sourceContext.findings.securityException;
43
+ sourceContext.block('block', 'cmd-injection');
44
+
45
+ err.output.statusCode = 403;
46
+ err.reformat();
47
+ err.output.payload = undefined;
48
+ data.result = null;
49
+
50
+ logger.info({ mode, ruleId }, 'Request blocked');
51
+
52
+ return;
53
+ }
54
+
55
+ if (!sourceContext && isSecurityException) {
56
+ logger.info('source context not found; unable to handle response');
57
+ }
58
+ }
59
+ });
60
+ };
61
+
62
+ hapiErrorHandler.install = function () {
63
+ depHooks.resolve(
64
+ { name: 'boom' },
65
+ (boom) => registerErrorHandler(boom, 'boom'),
66
+ );
67
+
68
+ depHooks.resolve(
69
+ { name: '@hapi/boom' },
70
+ (boom) => registerErrorHandler(boom, '@hapi/boom'),
71
+ );
72
+ };
73
+
74
+ return hapiErrorHandler;
75
+ };
@@ -24,7 +24,6 @@ module.exports = function(core) {
24
24
  logger,
25
25
  depHooks,
26
26
  patcher,
27
- scopes: { sources },
28
27
  protect,
29
28
  } = core;
30
29
 
@@ -42,7 +41,7 @@ module.exports = function(core) {
42
41
  patchType,
43
42
  around(org, data) {
44
43
  const [err] = data.args;
45
- const sourceContext = sources.getStore()?.protect;
44
+ const sourceContext = protect.getSourceContext('Koa.Application.handleRequest');
46
45
  const isSecurityException = SecurityException.isSecurityException(err);
47
46
 
48
47
  if (isSecurityException && sourceContext) {
@@ -1,5 +1,3 @@
1
- #!/usr/bin/env node
2
-
3
1
  /*
4
2
  * Copyright: 2022 Contrast Security, Inc
5
3
  * Contact: support@contrastsecurity.com
@@ -17,19 +15,19 @@
17
15
 
18
16
  'use strict';
19
17
 
20
- const { cliRewriter } = require('@contrast/core')();
18
+ module.exports = function(core) {
19
+ const { scopes: { sources }, logger } = core;
20
+
21
+ function getSourceContext(callPoint) {
22
+ const sourceContext = sources.getStore()?.protect;
21
23
 
22
- cliRewriter((deps) => {
23
- if (deps.config.protect.enable) {
24
- try {
25
- const protect = require('./index')(deps);
26
- protect.rewriting.install();
27
- } catch (err) {
28
- // TODO: something else
29
- throw err;
24
+ if (!sourceContext) {
25
+ logger.debug(`source context not available in ${callPoint}`);
26
+ return null;
30
27
  }
31
- } else {
32
- deps.logger.error('Configuration Error: mode \'Protect\' is not enabled');
33
- process.exit(1);
28
+
29
+ return sourceContext.allowed ? null : sourceContext;
34
30
  }
35
- });
31
+
32
+ core.protect.getSourceContext = getSourceContext;
33
+ };
@@ -0,0 +1,20 @@
1
+ /*
2
+ * Copyright: 2022 Contrast Security, Inc
3
+ * Contact: support@contrastsecurity.com
4
+ * License: Commercial
5
+
6
+ * NOTICE: This Software and the patented inventions embodied within may only be
7
+ * used as part of Contrast Security’s commercial offerings. Even though it is
8
+ * made available through public repositories, use of this Software is subject to
9
+ * the applicable End User Licensing Agreement found at
10
+ * https://www.contrastsecurity.com/enduser-terms-0317a or as otherwise agreed
11
+ * between Contrast Security and the End User. The Software may not be reverse
12
+ * engineered, modified, repackaged, sold, redistributed or otherwise used in a
13
+ * way not consistent with the End User License Agreement.
14
+ */
15
+
16
+ 'use strict';
17
+
18
+ module.exports = {
19
+ patchType: 'protect-hardening'
20
+ };
@@ -0,0 +1,65 @@
1
+ /*
2
+ * Copyright: 2022 Contrast Security, Inc
3
+ * Contact: support@contrastsecurity.com
4
+ * License: Commercial
5
+
6
+ * NOTICE: This Software and the patented inventions embodied within may only be
7
+ * used as part of Contrast Security’s commercial offerings. Even though it is
8
+ * made available through public repositories, use of this Software is subject to
9
+ * the applicable End User Licensing Agreement found at
10
+ * https://www.contrastsecurity.com/enduser-terms-0317a or as otherwise agreed
11
+ * between Contrast Security and the End User. The Software may not be reverse
12
+ * engineered, modified, repackaged, sold, redistributed or otherwise used in a
13
+ * way not consistent with the End User License Agreement.
14
+ */
15
+
16
+ 'use strict';
17
+
18
+ const { BLOCKING_MODES, isString } = require('@contrast/common');
19
+
20
+ const NODE_SERIALIZE_RCE_TOKEN = '_$$ND_FUNC$$_';
21
+
22
+ module.exports = function(core) {
23
+ const {
24
+ protect: {
25
+ hardening,
26
+ throwSecurityException,
27
+ }
28
+ } = core;
29
+
30
+ function getResults(sourceContext, ruleId) {
31
+ let results = sourceContext.findings.hardeningResultsMap[ruleId];
32
+ if (!results) {
33
+ results = sourceContext.findings.hardeningResultsMap[ruleId] = [];
34
+ }
35
+ return results;
36
+ }
37
+
38
+ hardening.handleUntrustedDeserialization = function(sourceContext, sinkContext) {
39
+ const ruleId = 'untrusted-deserialization';
40
+ const mode = sourceContext.policy[ruleId];
41
+ const { name, value } = sinkContext;
42
+
43
+ if (mode === 'off') return;
44
+
45
+ if (name === 'node-serialize.unserialize') {
46
+ if (!isString(value) || !value.indexOf(NODE_SERIALIZE_RCE_TOKEN)) return;
47
+
48
+ const blocked = BLOCKING_MODES.includes(mode);
49
+ const results = getResults(sourceContext, ruleId);
50
+
51
+ results.push({
52
+ blocked,
53
+ findings: { deserializer: name, command: false },
54
+ sinkContext,
55
+ });
56
+
57
+ if (blocked) {
58
+ sourceContext.findings.securityException = [mode, ruleId];
59
+ throwSecurityException(sourceContext);
60
+ }
61
+ }
62
+ };
63
+
64
+ return hardening;
65
+ };
@@ -0,0 +1,29 @@
1
+ /*
2
+ * Copyright: 2022 Contrast Security, Inc
3
+ * Contact: support@contrastsecurity.com
4
+ * License: Commercial
5
+
6
+ * NOTICE: This Software and the patented inventions embodied within may only be
7
+ * used as part of Contrast Security’s commercial offerings. Even though it is
8
+ * made available through public repositories, use of this Software is subject to
9
+ * the applicable End User Licensing Agreement found at
10
+ * https://www.contrastsecurity.com/enduser-terms-0317a or as otherwise agreed
11
+ * between Contrast Security and the End User. The Software may not be reverse
12
+ * engineered, modified, repackaged, sold, redistributed or otherwise used in a
13
+ * way not consistent with the End User License Agreement.
14
+ */
15
+
16
+ 'use strict';
17
+
18
+ module.exports = function(core) {
19
+ const hardening = core.protect.hardening = {};
20
+
21
+ require('./handlers')(core);
22
+
23
+ require('./install/node-serialize0')(core);
24
+ hardening.install = function() {
25
+ hardening.nodeSerialize0Instrumentation.install();
26
+ };
27
+
28
+ return hardening;
29
+ };
@@ -0,0 +1,59 @@
1
+ /*
2
+ * Copyright: 2022 Contrast Security, Inc
3
+ * Contact: support@contrastsecurity.com
4
+ * License: Commercial
5
+
6
+ * NOTICE: This Software and the patented inventions embodied within may only be
7
+ * used as part of Contrast Security’s commercial offerings. Even though it is
8
+ * made available through public repositories, use of this Software is subject to
9
+ * the applicable End User Licensing Agreement found at
10
+ * https://www.contrastsecurity.com/enduser-terms-0317a or as otherwise agreed
11
+ * between Contrast Security and the End User. The Software may not be reverse
12
+ * engineered, modified, repackaged, sold, redistributed or otherwise used in a
13
+ * way not consistent with the End User License Agreement.
14
+ */
15
+
16
+ 'use strict';
17
+
18
+ const { patchType } = require('../constants');
19
+
20
+ module.exports = function(core) {
21
+ const {
22
+ depHooks,
23
+ patcher,
24
+ captureStacktrace,
25
+ protect,
26
+ protect: {
27
+ hardening
28
+ }
29
+ } = core;
30
+
31
+ function install() {
32
+ const name = 'node-serialize';
33
+ const method = 'unserialize';
34
+
35
+ depHooks.resolve(
36
+ { name, version: '<1.0.0' },
37
+ (nodeSerialize) => {
38
+ patcher.patch(nodeSerialize, method, {
39
+ name,
40
+ patchType,
41
+ pre({ args: [value], hooked, orig }) {
42
+ const sourceContext = protect.getSourceContext(`${name}.${method}`);
43
+
44
+ if (!sourceContext || !value) return;
45
+
46
+ const sinkContext = captureStacktrace(
47
+ { name: `${name}.${method}`, value },
48
+ { constructorOpt: hooked, prependFrames: [orig] },
49
+ );
50
+ hardening.handleUntrustedDeserialization(sourceContext, sinkContext);
51
+ },
52
+ });
53
+ });
54
+ }
55
+
56
+ return hardening.nodeSerialize0Instrumentation = {
57
+ install
58
+ };
59
+ };
package/lib/index.d.ts CHANGED
@@ -18,10 +18,9 @@ import { Core } from '@contrast/core';
18
18
  import { Logger } from '@contrast/logger';
19
19
  import { Sources } from '@contrast/scopes';
20
20
  import RequireHook from '@contrast/require-hook';
21
- import { RulesConfig, Rule, Messages, Result } from '@contrast/common';
21
+ import { RulesConfig, Messages, ReqData, ProtectMessage, Findings } from '@contrast/common';
22
22
  import { IncomingMessage, ServerResponse } from 'node:http';
23
23
  import { Config } from '@contrast/config';
24
- import { ProtectMessage } from '@contrast/common';
25
24
  import * as http from 'node:http';
26
25
  import * as https from 'node:https';
27
26
 
@@ -50,24 +49,6 @@ export class HttpInstrumentation {
50
49
  initiateRequestHandling(fnContext: { instance: any, method: any, args: any }): void; //TODO
51
50
  removeCookies(headers: string[]): string[];
52
51
  }
53
- export interface ReqData {
54
- method: string;
55
- headers: string[];
56
- uriPath: string;
57
- queries: string;
58
- contentType?: string;
59
- standardUrlParsing: boolean;
60
- ip: string;
61
- httpVersion: string,
62
- headers2: { [key: string]: Array<string> };
63
- }
64
-
65
- export interface Findings {
66
- trackRequest: boolean;
67
- securityException?: [mode: string, ruleId: string];
68
- bodyType?: 'json' | 'urlencoded';
69
- resultsMap: Record<Rule, Result[]>
70
- }
71
52
 
72
53
  export interface ProtectRequestStore {
73
54
  reqData: ReqData;
@@ -140,7 +121,8 @@ export interface Protect {
140
121
  sequelizeInstrumentation: {
141
122
  getQueryFromArgs: ([value]: any[]) => string | undefined,
142
123
  install: () => void
143
- }
124
+ },
125
+ httpInstrumentation: { install: () => void },
144
126
  install: () => void
145
127
  }
146
128
  errorHandlers: {
package/lib/index.js CHANGED
@@ -16,34 +16,29 @@
16
16
  'use strict';
17
17
 
18
18
  const agentLib = require('@contrast/agent-lib');
19
+ const { installChildComponentsSync } = require('@contrast/common');
19
20
 
20
21
  module.exports = function(core) {
21
22
  const protect = core.protect = {
22
23
  agentLib: module.exports.instantiateAgentLib(agentLib),
23
24
  };
24
25
 
25
- const rules = instantiateRulesFromConfig(
26
- core.config.protect.rules,
27
- core.config.protect.disabled_rules,
28
- protect.agentLib,
29
- );
30
-
31
- protect.rules = rules;
32
-
26
+ require('./policy')(core);
33
27
  require('./throw-security-exception')(core);
34
28
  require('./make-response-blocker')(core);
35
29
  require('./make-source-context')(core);
30
+ require('./get-source-context')(core);
36
31
  require('./input-analysis')(core);
37
32
  require('./input-tracing')(core);
33
+ require('./hardening')(core);
34
+ require('./semantic-analysis')(core);
38
35
  require('./error-handlers')(core);
39
36
 
40
37
  const pkj = require('../package.json');
41
38
  protect.version = pkj.version;
42
39
 
43
40
  protect.install = function() {
44
- protect.inputAnalysis.install();
45
- protect.inputTracing.install();
46
- protect.errorHandlers.install();
41
+ installChildComponentsSync(protect)
47
42
  };
48
43
 
49
44
  return protect;
@@ -67,38 +62,3 @@ function instantiateAgentLib(lib) {
67
62
  }
68
63
  return agentLib;
69
64
  }
70
-
71
- /**
72
- * This function instatiates the rules as defined in the configuration into
73
- * some structure. I'm in no way convinced or asserting that this is the right
74
- * structure but it does get a usable definition of rules in place. The final
75
- * structure will change based on what exactly TS sends as well as what the needs
76
- * of the code accessing the rules, exclusions, virtual-patches, etc.
77
- *
78
- * @param {Object} rules the rules object in the config.protect object.
79
- * @param {string[]} disabled array of disabled rules from config.protect
80
- * @param {Object} agentLib the agent-lib instance
81
- * @returns {Object} { agentLibRules, agentLibRulesMask, agentRules }
82
- */
83
- function instantiateRulesFromConfig(rules, disabled, agentLib) {
84
- const agentLibRules = {};
85
- let agentLibRulesMask = 0;
86
- const agentRules = {};
87
-
88
- for (const ruleId in rules) {
89
- if (disabled.indexOf(ruleId) >= 0 || rules[ruleId].mode === 'off') {
90
- continue;
91
- }
92
- // [matt] this is awkward. we should probably make each nosql-injection-x
93
- // rule separate in the config and only convert them to 'nosql-injection'
94
- // for reporting.
95
- if (agentLib.RuleType[ruleId]) {
96
- agentLibRules[ruleId] = rules[ruleId];
97
- agentLibRulesMask = agentLibRulesMask | agentLib.RuleType[ruleId];
98
- } else {
99
- agentRules[ruleId] = rules[ruleId];
100
- }
101
- }
102
-
103
- return { agentLibRules, agentLibRulesMask, agentRules };
104
- }