@contrast/agent 4.10.2 → 4.10.3
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.
- package/bin/VERSION +1 -1
- package/bin/linux/contrast-service +0 -0
- package/bin/mac/contrast-service +0 -0
- package/bin/windows/contrast-service.exe +0 -0
- package/bootstrap.js +2 -2
- package/lib/core/logger/debug-logger.js +4 -3
- package/lib/core/rewrite/binary-expression.js +1 -2
- package/lib/core/rewrite/callees.js +3 -2
- package/lib/core/rewrite/catch-clause.js +4 -2
- package/lib/core/rewrite/import-declaration.js +2 -2
- package/lib/core/rewrite/index.js +1 -0
- package/lib/core/rewrite/injections.js +1 -3
- package/lib/core/rewrite/rewrite-log.js +5 -8
- package/package.json +9 -7
package/bin/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.28.
|
|
1
|
+
2.28.12
|
|
Binary file
|
package/bin/mac/contrast-service
CHANGED
|
Binary file
|
|
Binary file
|
package/bootstrap.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
1
|
/**
|
|
3
2
|
Copyright: 2022 Contrast Security, Inc
|
|
4
3
|
Contact: support@contrastsecurity.com
|
|
@@ -13,6 +12,7 @@ Copyright: 2022 Contrast Security, Inc
|
|
|
13
12
|
engineered, modified, repackaged, sold, redistributed or otherwise used in a
|
|
14
13
|
way not consistent with the End User License Agreement.
|
|
15
14
|
*/
|
|
15
|
+
'use strict';
|
|
16
16
|
|
|
17
17
|
const startTime = process.hrtime();
|
|
18
18
|
|
|
@@ -25,7 +25,7 @@ const orig = Module.runMain;
|
|
|
25
25
|
* process before invoking the main
|
|
26
26
|
* script from cli
|
|
27
27
|
*/
|
|
28
|
-
Module.runMain = async function(...args) {
|
|
28
|
+
Module.runMain = async function (...args) {
|
|
29
29
|
const { isMainThread } = require('worker_threads');
|
|
30
30
|
|
|
31
31
|
try {
|
|
@@ -108,9 +108,10 @@ class DebugLogFactory {
|
|
|
108
108
|
|
|
109
109
|
// We always log to a file, but check whether we should log to stdout
|
|
110
110
|
if (
|
|
111
|
-
|
|
112
|
-
!
|
|
113
|
-
|
|
111
|
+
this.loggerPath &&
|
|
112
|
+
(!this.stdout ||
|
|
113
|
+
!process.env.DEBUG ||
|
|
114
|
+
!/(^|,\s*)contrast:.+/.test(process.env.DEBUG))
|
|
114
115
|
) {
|
|
115
116
|
this.mute = true;
|
|
116
117
|
}
|
|
@@ -15,7 +15,6 @@ Copyright: 2022 Contrast Security, Inc
|
|
|
15
15
|
'use strict';
|
|
16
16
|
|
|
17
17
|
const t = require('@babel/types');
|
|
18
|
-
const _ = require('lodash');
|
|
19
18
|
|
|
20
19
|
/**
|
|
21
20
|
* Wraps binary expressions in one of the following: `ContrastMethods.__add`,
|
|
@@ -30,7 +29,7 @@ const _ = require('lodash');
|
|
|
30
29
|
* @param {import('.').State} state
|
|
31
30
|
*/
|
|
32
31
|
module.exports = function BinaryExpression(path, state) {
|
|
33
|
-
const spec =
|
|
32
|
+
const spec = state.specs.find(({ token }) => token === path.node.operator);
|
|
34
33
|
if (
|
|
35
34
|
!spec ||
|
|
36
35
|
!state.callees[spec.name] ||
|
|
@@ -15,7 +15,6 @@ Copyright: 2022 Contrast Security, Inc
|
|
|
15
15
|
'use strict';
|
|
16
16
|
|
|
17
17
|
const { expression } = require('@babel/template');
|
|
18
|
-
const _ = require('lodash');
|
|
19
18
|
|
|
20
19
|
/**
|
|
21
20
|
* @typedef {Object} Spec
|
|
@@ -132,7 +131,9 @@ module.exports = function createCallees(agent) {
|
|
|
132
131
|
const callees = specs.reduce(
|
|
133
132
|
(memo, spec) =>
|
|
134
133
|
(assessMode && spec.modes.assess) || (protectMode && spec.modes.protect)
|
|
135
|
-
?
|
|
134
|
+
? Object.assign(memo, {
|
|
135
|
+
[spec.name]: calleeBuilder({ name: spec.name })
|
|
136
|
+
})
|
|
136
137
|
: memo,
|
|
137
138
|
{}
|
|
138
139
|
);
|
|
@@ -13,7 +13,6 @@ Copyright: 2022 Contrast Security, Inc
|
|
|
13
13
|
way not consistent with the End User License Agreement.
|
|
14
14
|
*/
|
|
15
15
|
const { statement } = require('@babel/template');
|
|
16
|
-
const _ = require('lodash');
|
|
17
16
|
|
|
18
17
|
const logStatementBuilder = statement(
|
|
19
18
|
`if (global.CONTRAST_LOG) {
|
|
@@ -38,7 +37,10 @@ const logStatementBuilder = statement(
|
|
|
38
37
|
* @param {import('.').State} state
|
|
39
38
|
*/
|
|
40
39
|
module.exports = function CatchClause(path, state) {
|
|
41
|
-
|
|
40
|
+
const { config } = state.agent;
|
|
41
|
+
if (!config || !config.agent.node.enable_catch_log) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
42
44
|
|
|
43
45
|
path.node.param = path.node.param || path.scope.generateUidIdentifier('err');
|
|
44
46
|
path
|
|
@@ -15,7 +15,6 @@ Copyright: 2022 Contrast Security, Inc
|
|
|
15
15
|
'use strict';
|
|
16
16
|
|
|
17
17
|
const t = require('@babel/types');
|
|
18
|
-
const _ = require('lodash');
|
|
19
18
|
|
|
20
19
|
const IMPORT_META_URL_MEMBER_EXPRESSION = t.memberExpression(
|
|
21
20
|
t.memberExpression(t.identifier('import'), t.identifier('meta')),
|
|
@@ -49,7 +48,8 @@ module.exports = function ImportDeclaration(path, state) {
|
|
|
49
48
|
|
|
50
49
|
path.insertAfter(
|
|
51
50
|
specifiers.map((importSpec) => {
|
|
52
|
-
const spec =
|
|
51
|
+
const spec = state.specs.find(({ type }) => type === importSpec.type);
|
|
52
|
+
|
|
53
53
|
if (!spec || !state.callees[spec.name]) return;
|
|
54
54
|
|
|
55
55
|
const args = [importSpec.local];
|
|
@@ -14,7 +14,6 @@ Copyright: 2022 Contrast Security, Inc
|
|
|
14
14
|
*/
|
|
15
15
|
'use strict';
|
|
16
16
|
|
|
17
|
-
const _ = require('lodash');
|
|
18
17
|
const logger = require('../logger')('contrast:rewrite:injections');
|
|
19
18
|
const patcher = require('../../hooks/patcher');
|
|
20
19
|
const { PATCH_TYPES } = require('../../constants');
|
|
@@ -161,8 +160,7 @@ module.exports = {
|
|
|
161
160
|
* @returns {Injection[]}
|
|
162
161
|
*/
|
|
163
162
|
getEnabled() {
|
|
164
|
-
return
|
|
165
|
-
injections,
|
|
163
|
+
return Object.values(injections).reduce(
|
|
166
164
|
(enabled, injection) =>
|
|
167
165
|
injection.enabled() ? [...enabled, injection] : enabled,
|
|
168
166
|
[]
|
|
@@ -13,7 +13,6 @@ Copyright: 2022 Contrast Security, Inc
|
|
|
13
13
|
way not consistent with the End User License Agreement.
|
|
14
14
|
*/
|
|
15
15
|
'use strict';
|
|
16
|
-
const _ = require('lodash');
|
|
17
16
|
|
|
18
17
|
/**
|
|
19
18
|
* Helper class that provides some means of optimizing the rewrite process.
|
|
@@ -32,11 +31,9 @@ module.exports = class RewriteLog {
|
|
|
32
31
|
this._tokenMatches = specs.reduce(
|
|
33
32
|
(matches, spec) =>
|
|
34
33
|
callees[spec.name]
|
|
35
|
-
?
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
!spec.token || 0 <= codeString.indexOf(spec.token)
|
|
39
|
-
)
|
|
34
|
+
? Object.assign(matches, {
|
|
35
|
+
[spec.name]: !spec.token || 0 <= codeString.indexOf(spec.token)
|
|
36
|
+
})
|
|
40
37
|
: matches,
|
|
41
38
|
{}
|
|
42
39
|
);
|
|
@@ -60,7 +57,7 @@ module.exports = class RewriteLog {
|
|
|
60
57
|
* if we need to even rewrite the code at all.
|
|
61
58
|
*/
|
|
62
59
|
foundTokens() {
|
|
63
|
-
return
|
|
60
|
+
return Object.values(this._tokenMatches).some(Boolean);
|
|
64
61
|
}
|
|
65
62
|
|
|
66
63
|
/**
|
|
@@ -72,6 +69,6 @@ module.exports = class RewriteLog {
|
|
|
72
69
|
* make changes, we can just return original code.
|
|
73
70
|
*/
|
|
74
71
|
rewritesOccurred() {
|
|
75
|
-
return !this.aborted &&
|
|
72
|
+
return !this.aborted && Object.values(this._tokensRewritten).some(Boolean);
|
|
76
73
|
}
|
|
77
74
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contrast/agent",
|
|
3
|
-
"version": "4.10.
|
|
3
|
+
"version": "4.10.3",
|
|
4
4
|
"description": "Node.js security instrumentation by Contrast Security",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"security",
|
|
@@ -113,12 +113,14 @@
|
|
|
113
113
|
"devDependencies": {
|
|
114
114
|
"@aws-sdk/client-dynamodb": "^3.39.0",
|
|
115
115
|
"@bmacnaughton/string-generator": "^1.0.0",
|
|
116
|
-
"@contrast/eslint-config": "^2.0
|
|
116
|
+
"@contrast/eslint-config": "^2.2.0",
|
|
117
117
|
"@contrast/fake-module": "file:test/mock/contrast-fake",
|
|
118
118
|
"@contrast/screener-service": "^1.12.9",
|
|
119
119
|
"@hapi/boom": "file:test/mock/boom",
|
|
120
120
|
"@hapi/hapi": "file:test/mock/hapi",
|
|
121
121
|
"@ls-lint/ls-lint": "^1.8.1",
|
|
122
|
+
"@typescript-eslint/eslint-plugin": "^5.10.2",
|
|
123
|
+
"@typescript-eslint/parser": "^5.10.2",
|
|
122
124
|
"ajv": "^8.5.0",
|
|
123
125
|
"ast-types": "^0.12.4",
|
|
124
126
|
"aws-sdk": "file:test/mock/aws-sdk",
|
|
@@ -135,11 +137,11 @@
|
|
|
135
137
|
"dustjs-linkedin": "^3.0.1",
|
|
136
138
|
"ejs": "^3.1.6",
|
|
137
139
|
"escape-html": "^1.0.3",
|
|
138
|
-
"eslint": "^8.
|
|
139
|
-
"eslint-config-prettier": "^
|
|
140
|
-
"eslint-plugin-mocha": "^
|
|
140
|
+
"eslint": "^8.8.0",
|
|
141
|
+
"eslint-config-prettier": "^8.3.0",
|
|
142
|
+
"eslint-plugin-mocha": "^10.0.3",
|
|
141
143
|
"eslint-plugin-node": "^11.1.0",
|
|
142
|
-
"eslint-plugin-prettier": "^
|
|
144
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
143
145
|
"express": "file:test/mock/express",
|
|
144
146
|
"fetch-cookie": "^0.11.0",
|
|
145
147
|
"form-data": "^3.0.0",
|
|
@@ -168,7 +170,7 @@
|
|
|
168
170
|
"nyc": "^15.1.0",
|
|
169
171
|
"pg": "file:test/mock/pg",
|
|
170
172
|
"pino": "^6.7.0",
|
|
171
|
-
"prettier": "^
|
|
173
|
+
"prettier": "^2.5.1",
|
|
172
174
|
"proxyquire": "^2.1.0",
|
|
173
175
|
"qs": "^6.9.4",
|
|
174
176
|
"rethinkdb": "file:test/mock/rethinkdb",
|