@contrast/agent 4.4.0-beta.0 → 4.5.2

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 (45) hide show
  1. package/bin/VERSION +1 -1
  2. package/bin/linux/contrast-service +0 -0
  3. package/bin/mac/contrast-service +0 -0
  4. package/bin/windows/contrast-service.exe +0 -0
  5. package/lib/assess/hapi/route-coverage.js +3 -3
  6. package/lib/assess/membrane/index.js +2 -8
  7. package/lib/assess/membrane/source-membrane.js +3 -4
  8. package/lib/assess/models/base-event.js +2 -2
  9. package/lib/assess/models/call-context.js +0 -3
  10. package/lib/assess/models/tag-range/index.js +6 -16
  11. package/lib/assess/policy/signatures.json +95 -0
  12. package/lib/assess/policy/util.js +9 -2
  13. package/lib/assess/propagators/path/common.js +165 -36
  14. package/lib/assess/propagators/path/join.js +5 -1
  15. package/lib/assess/propagators/path/normalize.js +5 -1
  16. package/lib/assess/propagators/path/resolve.js +11 -2
  17. package/lib/assess/response-scanning/autocomplete-missing.js +0 -2
  18. package/lib/assess/response-scanning/parameter-pollution.js +0 -2
  19. package/lib/assess/sinks/mongodb.js +11 -7
  20. package/lib/core/arch-components/dynamodb.js +1 -2
  21. package/lib/core/arch-components/dynamodbv3.js +44 -0
  22. package/lib/core/arch-components/index.js +1 -0
  23. package/lib/core/async-storage/hooks/bluebird.js +20 -0
  24. package/lib/core/express/utils.js +1 -1
  25. package/lib/core/logger/debug-logger.js +15 -17
  26. package/lib/core/stacktrace.js +1 -3
  27. package/lib/feature-set.js +2 -1
  28. package/lib/hooks/encoding.js +1 -1
  29. package/lib/hooks/patcher.js +10 -12
  30. package/lib/protect/analysis/aho-corasick.js +13 -30
  31. package/lib/protect/rules/cmd-injection-command-backdoors/backdoor-detector.js +3 -3
  32. package/lib/protect/rules/signatures/reflected-xss/helpers/function-call.js +1 -1
  33. package/lib/protect/rules/xss/helpers/function-call.js +1 -1
  34. package/lib/util/clean-stack.js +1 -1
  35. package/lib/util/clean-string/brackets.js +3 -3
  36. package/lib/util/clean-string/concatenations.js +1 -1
  37. package/lib/util/clean-string/util.js +1 -2
  38. package/lib/util/ip-analyzer.js +1 -1
  39. package/lib/util/some.js +27 -0
  40. package/lib/util/xml-analyzer/external-entity-finder.js +1 -1
  41. package/node_modules/unix-dgram/build/Makefile +2 -2
  42. package/node_modules/unix-dgram/build/Release/.deps/Release/obj.target/unix_dgram/src/unix_dgram.o.d +35 -35
  43. package/node_modules/unix-dgram/build/config.gypi +8 -8
  44. package/node_modules/unix-dgram/build/unix_dgram.target.mk +14 -14
  45. package/package.json +4 -2
package/bin/VERSION CHANGED
@@ -1 +1 @@
1
- 2.26.0
1
+ 2.27.3
Binary file
Binary file
Binary file
@@ -151,9 +151,9 @@ class RouteCoverage {
151
151
  */
152
152
  createSignature({ method, path }) {
153
153
  let signature = 'server.route({ method: ';
154
- Array.isArray(method)
155
- ? (signature += `["${method.join('", "')}"]`)
156
- : (signature += `"${method}"`);
154
+ signature += Array.isArray(method)
155
+ ? `["${method.join('", "')}"]`
156
+ : `"${method}"`;
157
157
 
158
158
  signature += `, path: "${path}" })`;
159
159
  return signature;
@@ -280,10 +280,6 @@ class Membrane {
280
280
  return this.wrapArray(target, metadata);
281
281
  }
282
282
 
283
- // Object.defineProperty(target, util.inspect.custom, {
284
- // target: typeof target === 'string' ? () => `'${target}'` : () => target
285
- // });
286
-
287
283
  return this.wrapObject(target, metadata);
288
284
  }
289
285
  }
@@ -310,12 +306,10 @@ function makeHandler(membrane, metadata) {
310
306
  // https://www.ecma-international.org/ecma-262/7.0/#sec-proxy-object-internal-methods-and-internal-slots-get-p-receiver
311
307
  // satisfy invariant
312
308
  const desc = Object.getOwnPropertyDescriptor(tar, prop);
313
- // if (desc && (desc.writable || desc.set || desc.configurable)) {
314
309
  if (desc && desc.configurable) {
315
310
  r = membrane.wrap(r, copyMetadata(tar, prop, metadata));
316
- } else {
317
- // invariant case; can't wrap
318
- }
311
+ } // else: invariant case; can't wrap
312
+
319
313
  return r;
320
314
  },
321
315
 
@@ -294,10 +294,9 @@ module.exports = class SourceMembrane extends Membrane {
294
294
  if (!(metadata.sourceType && metadata.path)) {
295
295
  return false;
296
296
  }
297
- const koaQueryString = metadata.path.match(/(\w+)=/);
298
- if (koaQueryString) {
299
- // get 1st capture group, fall back to `metadata.path` if for some reason this does not exist
300
- metadata.path = koaQueryString[1] || metadata.path;
297
+ const koaQueryString = metadata.path.split('=');
298
+ if (koaQueryString[1]) {
299
+ metadata.path = koaQueryString[0];
301
300
  }
302
301
  return true;
303
302
  }
@@ -166,7 +166,7 @@ class BaseEvent {
166
166
  * @return {BaseEvent[]} sorted list of events
167
167
  */
168
168
  function sortEvents(events) {
169
- const sorted = events.sort((a, b) => {
169
+ events.sort((a, b) => {
170
170
  let parentsfactor = 0;
171
171
  if (a.parents.length > b.parents.length) {
172
172
  parentsfactor = -1;
@@ -184,7 +184,7 @@ function sortEvents(events) {
184
184
  return parentsfactor + timefactor;
185
185
  });
186
186
 
187
- return sorted;
187
+ return events;
188
188
  }
189
189
 
190
190
  module.exports = BaseEvent;
@@ -153,9 +153,6 @@ module.exports = class CallContext {
153
153
  return value.toString();
154
154
  }
155
155
 
156
- // FIXME
157
- // if value === JSON, if value === Buffer, etc to put proper constructor name for static methods?
158
-
159
156
  const constructorName = _.get(value, 'constructor.name', 'null');
160
157
 
161
158
  if (constructorName === 'Object' && value) {
@@ -14,7 +14,6 @@ Copyright: 2021 Contrast Security, Inc
14
14
  */
15
15
  'use strict';
16
16
 
17
- const _ = require('lodash');
18
17
  const logger = require('../../../core/logger')('contrast:tagRange');
19
18
 
20
19
  const Relationships = require('./relationships');
@@ -27,14 +26,13 @@ const DEFAULT_TAG = 'untrusted';
27
26
  */
28
27
  class TagRange {
29
28
  /**
30
- * Validates the arguments to the contructor call.
31
- * @param {number} start The starting index to track.
32
- * @param {number} stop The stopping index to track.
33
- * @param {string} tag The name of the tag.
29
+ * @param {number} start The starting index of string tracking on the data having the tag.
30
+ * @param {number} stop The stopping index of string tracking on the data having the tag.
31
+ * @param {string?} tag The name of the tag (default is "untrusted").
34
32
  */
35
- static validate(start, stop, tag = DEFAULT_TAG) {
36
- const bothFinite = _.isFinite(start) && _.isFinite(stop);
37
- if (start > stop || !bothFinite) {
33
+ constructor(start, stop, tag = DEFAULT_TAG) {
34
+ // Validates the arguments to the contructor call.
35
+ if (!(start <= stop && start >= 0)) {
38
36
  logger.debug(
39
37
  'could not create tag %s with invalid range start: %s, stop %s.',
40
38
  tag,
@@ -42,15 +40,7 @@ class TagRange {
42
40
  stop
43
41
  );
44
42
  }
45
- }
46
43
 
47
- /**
48
- * @param {number} start The starting index of string tracking on the data having the tag.
49
- * @param {number} stop The stopping index of string tracking on the data having the tag.
50
- * @param {string?} tag The name of the tag (default is "untrusted").
51
- */
52
- constructor(start, stop, tag = DEFAULT_TAG) {
53
- TagRange.validate(start, stop, tag);
54
44
  /** @type {string} */
55
45
  this.tag = tag;
56
46
  /** @type {number} */