@contrast/agent 4.32.19 → 4.32.20

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.
@@ -16,6 +16,8 @@ Copyright: 2023 Contrast Security, Inc
16
16
 
17
17
  const agentEmitter = require('../../agent-emitter');
18
18
  const httpCommon = require('./common');
19
+ const logger = require('../../core/logger')('contrast:response-scanning');
20
+
19
21
  let setup = false;
20
22
 
21
23
  module.exports = {
@@ -25,16 +27,20 @@ module.exports = {
25
27
  }
26
28
  // TODO add generic res.end hook
27
29
  agentEmitter.on('send', function({ request, responseHeaders, body }) {
28
- // not setting default value in arg because null does not evaluate to false
29
- body = body || '';
30
+ if (typeof body !== 'object' || body === null) {
31
+ // not setting default value in arg because null does not evaluate to false
32
+ body = body || '';
30
33
 
31
- if (httpCommon.isParseableResponse(responseHeaders)) {
32
- agentEmitter.emit('parseableResponse', {
33
- request,
34
- responseHeaders,
35
- body,
36
- bodyLC: body.toLowerCase()
37
- });
34
+ if (httpCommon.isParseableResponse(responseHeaders)) {
35
+ agentEmitter.emit('parseableResponse', {
36
+ request,
37
+ responseHeaders,
38
+ body,
39
+ bodyLC: body.toLowerCase()
40
+ });
41
+ }
42
+ } else {
43
+ logger.warn('The contrast agent expects the response body to be a string or null.');
38
44
  }
39
45
  });
40
46
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrast/agent",
3
- "version": "4.32.19",
3
+ "version": "4.32.20",
4
4
  "description": "Node.js security instrumentation by Contrast Security",
5
5
  "keywords": [
6
6
  "security",