@contrast/agent 4.32.19 → 4.33.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.
|
@@ -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
|
-
|
|
29
|
-
|
|
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
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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/lib/core/config/util.js
CHANGED
|
@@ -194,7 +194,7 @@ function readConfig(cliOptions, logger) {
|
|
|
194
194
|
|
|
195
195
|
if (configPath) {
|
|
196
196
|
try {
|
|
197
|
-
fileContents = fs.readFileSync(path.resolve(configPath)
|
|
197
|
+
fileContents = fs.readFileSync(path.resolve(configPath)).toString('utf-8');
|
|
198
198
|
} catch (e) {
|
|
199
199
|
logger.error(`Unable to read config file. ${e.message}`);
|
|
200
200
|
}
|
package/lib/library-usage.js
CHANGED
|
@@ -15,12 +15,14 @@ Copyright: 2023 Contrast Security, Inc
|
|
|
15
15
|
'use strict';
|
|
16
16
|
|
|
17
17
|
const path = require('path');
|
|
18
|
+
const semver = require('semver');
|
|
18
19
|
const { setCodeEventListener } = require('@contrast/fn-inspect');
|
|
19
20
|
const agentEmitter = require('./agent-emitter');
|
|
20
21
|
const logger = require('./core/logger')('contrast:library-usage');
|
|
21
22
|
const LibraryUsage = require('./reporter/models/app-update/library-usage');
|
|
22
23
|
|
|
23
24
|
const reportedFiles = new Set();
|
|
25
|
+
const type = semver.gte(process.version, '20.0.0') ? 'Function' : 'LazyCompile';
|
|
24
26
|
|
|
25
27
|
/**
|
|
26
28
|
* start listening for v8 code events
|
|
@@ -30,7 +32,7 @@ module.exports.listen = function(evalInterval = 1) {
|
|
|
30
32
|
const handler = (codeEvent) => {
|
|
31
33
|
try {
|
|
32
34
|
if (
|
|
33
|
-
codeEvent.type !==
|
|
35
|
+
codeEvent.type !== type ||
|
|
34
36
|
codeEvent.script.indexOf(`node_modules${path.sep}`) === -1 ||
|
|
35
37
|
reportedFiles.has(codeEvent.script)
|
|
36
38
|
) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contrast/agent",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.33.0",
|
|
4
4
|
"description": "Node.js security instrumentation by Contrast Security",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"security",
|
|
@@ -81,9 +81,9 @@
|
|
|
81
81
|
"@babel/types": "^7.12.1",
|
|
82
82
|
"@contrast/agent-lib": "^4.3.0",
|
|
83
83
|
"@contrast/cls-hooked": "^4.3.1",
|
|
84
|
-
"@contrast/distringuish": "^4.
|
|
84
|
+
"@contrast/distringuish": "^4.4.0",
|
|
85
85
|
"@contrast/flat": "^4.1.1",
|
|
86
|
-
"@contrast/fn-inspect": "^3.
|
|
86
|
+
"@contrast/fn-inspect": "^3.4.0",
|
|
87
87
|
"@contrast/protobuf-api": "^3.2.5",
|
|
88
88
|
"@contrast/require-hook": "^3.2.3",
|
|
89
89
|
"@contrast/synchronous-source-maps": "^1.1.0",
|
|
@@ -199,7 +199,7 @@
|
|
|
199
199
|
"test": "test"
|
|
200
200
|
},
|
|
201
201
|
"engines": {
|
|
202
|
-
"node": ">=12.13.0 <13 || >=14.15.0 <15 || >=16.9.1 <17 || >=18.7.0 <19",
|
|
202
|
+
"node": ">=12.13.0 <13 || >=14.15.0 <15 || >=16.9.1 <17 || >=18.7.0 <19 || >=20.5.0 <21",
|
|
203
203
|
"npm": ">=6.13.7 <7 || >=7.11.0"
|
|
204
204
|
},
|
|
205
205
|
"bundleDependencies": [
|