@contrast/agent 4.19.7 → 4.20.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.
- package/lib/assess/policy/signatures.json +2 -2
- package/lib/assess/sinks/mongodb.js +34 -40
- package/lib/core/arch-components/mongodb.js +87 -29
- package/lib/core/async-storage/hooks/mongodb.js +77 -25
- package/lib/core/async-storage/index.js +1 -1
- package/lib/libraries.js +1 -1
- package/lib/list-installed.js +14 -20
- package/node_modules/moment/CHANGELOG.md +13 -1
- package/node_modules/moment/dist/locale/sr-cyrl.js +3 -2
- package/node_modules/moment/dist/locale/sr.js +3 -2
- package/node_modules/moment/dist/moment.js +3 -3
- package/node_modules/moment/locale/sr-cyrl.js +3 -2
- package/node_modules/moment/locale/sr.js +3 -2
- package/node_modules/moment/min/locales.js +6 -4
- package/node_modules/moment/min/locales.min.js +1 -1
- package/node_modules/moment/min/locales.min.js.map +1 -1
- package/node_modules/moment/min/moment-with-locales.js +8 -6
- package/node_modules/moment/min/moment-with-locales.min.js +1 -1
- package/node_modules/moment/min/moment-with-locales.min.js.map +1 -1
- package/node_modules/moment/min/moment.min.js +1 -1
- package/node_modules/moment/min/moment.min.js.map +1 -1
- package/node_modules/moment/moment.js +3 -3
- package/node_modules/moment/package.json +4 -4
- package/node_modules/moment/src/lib/create/from-string.js +1 -1
- package/node_modules/moment/src/locale/sr-cyrl.js +3 -2
- package/node_modules/moment/src/locale/sr.js +3 -2
- package/node_modules/moment/src/moment.js +2 -2
- package/package.json +1 -1
|
@@ -215,13 +215,13 @@
|
|
|
215
215
|
},
|
|
216
216
|
"mongodb.Db.prototype.eval": {
|
|
217
217
|
"moduleName": "mongodb",
|
|
218
|
-
"version": ">=3.
|
|
218
|
+
"version": ">=3.3.0",
|
|
219
219
|
"methodName": "Db.prototype.eval",
|
|
220
220
|
"isModule": true
|
|
221
221
|
},
|
|
222
222
|
"mongodb.Collection.prototype.rename": {
|
|
223
223
|
"moduleName": "mongodb",
|
|
224
|
-
"version": ">=3.
|
|
224
|
+
"version": ">=3.3.0",
|
|
225
225
|
"methodName": "Collection.prototype.rename",
|
|
226
226
|
"isModule": true
|
|
227
227
|
},
|
|
@@ -48,10 +48,11 @@ module.exports = ({ common }) => {
|
|
|
48
48
|
const mongoSink = {};
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
|
-
* Methods to hook in Collection.prototype
|
|
51
|
+
* Methods to hook in Collection.prototype
|
|
52
52
|
* Collated and pruned from: Object.keys(mongodb.Collection.prototype)
|
|
53
|
+
* Some methods are deprecated in newer DATABASE versions
|
|
53
54
|
*/
|
|
54
|
-
mongoSink.
|
|
55
|
+
mongoSink.collectionMethods = [
|
|
55
56
|
// XXX hooking these results in compilation issues; unsure why
|
|
56
57
|
// 'collectionName',
|
|
57
58
|
// 'namespace',
|
|
@@ -91,45 +92,36 @@ module.exports = ({ common }) => {
|
|
|
91
92
|
// 'initializeOrderedBulkOp'
|
|
92
93
|
|
|
93
94
|
// 'bulkWrite',
|
|
94
|
-
// 'insert',
|
|
95
95
|
|
|
96
|
-
'deleteMany',
|
|
97
|
-
'deleteOne',
|
|
98
96
|
'find',
|
|
99
|
-
'findAndModify',
|
|
100
|
-
'findAndRemove',
|
|
101
97
|
'findOne',
|
|
98
|
+
'findAndModify',
|
|
102
99
|
'findOneAndDelete',
|
|
103
100
|
'findOneAndReplace',
|
|
104
101
|
'findOneAndUpdate',
|
|
102
|
+
'insert',
|
|
105
103
|
'insertMany',
|
|
106
104
|
'insertOne',
|
|
107
105
|
'remove',
|
|
108
|
-
'removeMany',
|
|
109
106
|
'removeOne',
|
|
110
107
|
'replaceOne',
|
|
108
|
+
'removeMany',
|
|
111
109
|
'save',
|
|
112
110
|
'update',
|
|
111
|
+
'updateOne',
|
|
113
112
|
'updateMany',
|
|
114
|
-
'
|
|
113
|
+
'deleteOne',
|
|
114
|
+
'deleteMany',
|
|
115
115
|
];
|
|
116
116
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
'find',
|
|
121
|
-
'findOne',
|
|
122
|
-
'findOneAndDelete',
|
|
117
|
+
// Collection of methods with the syntax: method(filter, doc, options);
|
|
118
|
+
// We should track and report unsafe inputs in both: `filter` and `doc`
|
|
119
|
+
const twoArgsCollectionMethods = [
|
|
123
120
|
'findOneAndReplace',
|
|
124
121
|
'findOneAndUpdate',
|
|
125
|
-
'insert',
|
|
126
|
-
'insertMany',
|
|
127
|
-
'insertOne',
|
|
128
|
-
'remove',
|
|
129
122
|
'replaceOne',
|
|
130
|
-
'
|
|
131
|
-
'updateMany'
|
|
132
|
-
'updateOne'
|
|
123
|
+
'updateOne',
|
|
124
|
+
'updateMany'
|
|
133
125
|
];
|
|
134
126
|
|
|
135
127
|
/**
|
|
@@ -144,6 +136,7 @@ module.exports = ({ common }) => {
|
|
|
144
136
|
...data,
|
|
145
137
|
result: null
|
|
146
138
|
});
|
|
139
|
+
|
|
147
140
|
// events are prefixed with 'protect '
|
|
148
141
|
ctxt.signature = data.name.split(' ')[1];
|
|
149
142
|
Object.defineProperty(doc, '__contrastContext', {
|
|
@@ -169,8 +162,10 @@ module.exports = ({ common }) => {
|
|
|
169
162
|
};
|
|
170
163
|
|
|
171
164
|
mongoSink.collectionMethodPost = (data) => {
|
|
165
|
+
const method = data.hooked && data.hooked.name;
|
|
166
|
+
|
|
172
167
|
try {
|
|
173
|
-
|
|
168
|
+
let doc = data.args[0];
|
|
174
169
|
|
|
175
170
|
if (!doc) {
|
|
176
171
|
return;
|
|
@@ -183,7 +178,14 @@ module.exports = ({ common }) => {
|
|
|
183
178
|
}
|
|
184
179
|
|
|
185
180
|
const ctxt = getCallContext(contrastContext, data);
|
|
181
|
+
|
|
182
|
+
if (twoArgsCollectionMethods.indexOf(method) > -1) {
|
|
183
|
+
// Assess both args at once
|
|
184
|
+
doc = { filter: data.args[0], update: data.args[1] };
|
|
185
|
+
}
|
|
186
|
+
|
|
186
187
|
mongoSink.assess(doc, ctxt);
|
|
188
|
+
|
|
187
189
|
} catch (err) {
|
|
188
190
|
logger.error(`Unable to perform post hook in ${data.name} %o`, err);
|
|
189
191
|
}
|
|
@@ -287,13 +289,6 @@ module.exports = ({ common }) => {
|
|
|
287
289
|
};
|
|
288
290
|
|
|
289
291
|
mongoSink.handleVersion4 = (mongodb, version) => {
|
|
290
|
-
patcher.patch(mongodb.Collection.prototype, mongoSink.collectionMethodsV4, {
|
|
291
|
-
name: 'assess mongodb.Collection.prototype',
|
|
292
|
-
patchType: PATCH_TYPES.ASSESS_SINK,
|
|
293
|
-
pre: mongoSink.collectionMethodHandler,
|
|
294
|
-
post: mongoSink.collectionMethodPost
|
|
295
|
-
});
|
|
296
|
-
|
|
297
292
|
patcher.patch(mongodb.Db.prototype, 'command', {
|
|
298
293
|
name: 'assess mongodb.Db.prototype',
|
|
299
294
|
patchType: PATCH_TYPES.ASSESS_SINK,
|
|
@@ -302,13 +297,6 @@ module.exports = ({ common }) => {
|
|
|
302
297
|
};
|
|
303
298
|
|
|
304
299
|
mongoSink.handleVersion3 = (mongodb, version) => {
|
|
305
|
-
patcher.patch(mongodb.Collection.prototype, mongoSink.collectionMethodsV3, {
|
|
306
|
-
name: 'assess mongodb.Collection.prototype',
|
|
307
|
-
patchType: PATCH_TYPES.ASSESS_SINK,
|
|
308
|
-
pre: mongoSink.collectionMethodHandler,
|
|
309
|
-
post: mongoSink.collectionMethodPost
|
|
310
|
-
});
|
|
311
|
-
|
|
312
300
|
patcher.patch(
|
|
313
301
|
mongodb.CoreServer.prototype,
|
|
314
302
|
mongoSink.coreServerQueryMethods,
|
|
@@ -342,7 +330,15 @@ module.exports = ({ common }) => {
|
|
|
342
330
|
return;
|
|
343
331
|
}
|
|
344
332
|
|
|
333
|
+
// NPM package architectures are different between v3.x.x and v4.x.x
|
|
345
334
|
requireHook.resolve({ name: 'mongodb' }, function(mongodb, { version }) {
|
|
335
|
+
patcher.patch(mongodb.Collection.prototype, mongoSink.collectionMethods, {
|
|
336
|
+
name: 'assess mongodb.Collection.prototype',
|
|
337
|
+
patchType: PATCH_TYPES.ASSESS_SINK,
|
|
338
|
+
pre: mongoSink.collectionMethodHandler,
|
|
339
|
+
post: mongoSink.collectionMethodPost
|
|
340
|
+
});
|
|
341
|
+
|
|
346
342
|
if (semver.gte(version, '4.0.0')) {
|
|
347
343
|
return mongoSink.handleVersion4(mongodb, version);
|
|
348
344
|
}
|
|
@@ -358,9 +354,7 @@ module.exports = ({ common }) => {
|
|
|
358
354
|
* It tries to get the context from the pre handler
|
|
359
355
|
* See: mongoSink.collectionMethodHandler
|
|
360
356
|
*
|
|
361
|
-
* If it does not
|
|
362
|
-
* although it won't be great, it is something
|
|
363
|
-
*
|
|
357
|
+
* If it does not exist, it tries to create a call context
|
|
364
358
|
*/
|
|
365
359
|
function getCallContext(ctxt, data) {
|
|
366
360
|
if (!ctxt) {
|
|
@@ -19,39 +19,97 @@ const { PATCH_TYPES } = require('../../constants');
|
|
|
19
19
|
const ModuleHook = require('../../hooks/require');
|
|
20
20
|
const patcher = require('../../hooks/patcher');
|
|
21
21
|
const logger = require('../logger')('contrast:arch-component');
|
|
22
|
+
const semver = require('semver');
|
|
22
23
|
|
|
23
24
|
ModuleHook.resolve(
|
|
24
|
-
{
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
{
|
|
26
|
+
name: 'mongodb',
|
|
27
|
+
file: 'lib/mongo_client.js',
|
|
28
|
+
version: '>=3.3.0'
|
|
29
|
+
},
|
|
30
|
+
(MongoClient, { version }) => {
|
|
31
|
+
if (semver.lt(version, '4.0.0')) {
|
|
32
|
+
patcher.patch(MongoClient.prototype, 'connect', {
|
|
33
|
+
name: 'MongoClient.connect.arch_component',
|
|
34
|
+
patchType: PATCH_TYPES.ARCH_COMPONENT,
|
|
35
|
+
alwaysRun: true,
|
|
36
|
+
post(ctx) {
|
|
37
|
+
if (!ctx.result || !ctx.result.then) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
34
40
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
// We should report only when connection is successful
|
|
42
|
+
ctx.result.then(function(client) {
|
|
43
|
+
try {
|
|
44
|
+
const { servers = [] } = ctx.obj.s && ctx.obj.s.options;
|
|
45
|
+
for (const server of servers) {
|
|
46
|
+
agentEmitter.emit('architectureComponent', {
|
|
47
|
+
vendor: 'MongoDB',
|
|
48
|
+
url: `mongodb://${server.host}:${server.port}`,
|
|
49
|
+
remoteHost: '',
|
|
50
|
+
remotePort: server.port,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
} catch (err) {
|
|
54
|
+
logger.warn(
|
|
55
|
+
'unable to report MongoDB architecture component, err: %o',
|
|
56
|
+
err,
|
|
57
|
+
);
|
|
46
58
|
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
59
|
+
});
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
/* Architecture component for >= mongodb@4
|
|
67
|
+
* It's not limited in the require hook to >=4.0.0 because
|
|
68
|
+
* that would result in confusing logs for the customer that
|
|
69
|
+
* we don't support older versions (which is not true) */
|
|
70
|
+
ModuleHook.resolve(
|
|
71
|
+
{
|
|
72
|
+
name: 'mongodb',
|
|
73
|
+
version: '>=3.3.0'
|
|
74
|
+
},
|
|
75
|
+
(MongoDB, { version }) => {
|
|
76
|
+
if (semver.gte(version, '4.0.0')) {
|
|
77
|
+
patcher.patch(MongoDB.MongoClient.prototype, 'connect', {
|
|
78
|
+
name: 'MongoClient.connect.arch_component',
|
|
79
|
+
patchType: PATCH_TYPES.ARCH_COMPONENT,
|
|
80
|
+
alwaysRun: true,
|
|
81
|
+
post(ctx) {
|
|
82
|
+
if (!ctx.result || !ctx.result.then) {
|
|
83
|
+
return;
|
|
52
84
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
85
|
+
|
|
86
|
+
// We should report only when connection is successful
|
|
87
|
+
ctx.result.then(function(client) {
|
|
88
|
+
if (client && client.topology && client.topology.s) {
|
|
89
|
+
try {
|
|
90
|
+
const { servers } = client.topology.s;
|
|
91
|
+
for (const [, server] of servers) {
|
|
92
|
+
if (server.s && server.s.state === 'connected') {
|
|
93
|
+
const { srvServiceName } = server.s.options;
|
|
94
|
+
const { address } = server.s.description;
|
|
95
|
+
agentEmitter.emit('architectureComponent', {
|
|
96
|
+
vendor: 'MongoDB',
|
|
97
|
+
url: `${srvServiceName}://${address}`,
|
|
98
|
+
remoteHost: '',
|
|
99
|
+
remotePort: address.split(':').pop()
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
} catch (err) {
|
|
104
|
+
logger.warn(
|
|
105
|
+
'unable to report MongoDB architecture component, err: %o',
|
|
106
|
+
err,
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
}
|
|
56
114
|
},
|
|
57
115
|
);
|
|
@@ -20,6 +20,7 @@ const requireHook = require('../../../hooks/require');
|
|
|
20
20
|
const resolveCallbackIdx = require('../../../util/callback-resolver');
|
|
21
21
|
const patcher = require('../../../hooks/patcher');
|
|
22
22
|
const utils = require('./utils');
|
|
23
|
+
const semver = require('semver');
|
|
23
24
|
|
|
24
25
|
/**
|
|
25
26
|
* Hooks a method to properly bind to AsyncStorage
|
|
@@ -35,10 +36,11 @@ function hookMethod(obj, method, patchName) {
|
|
|
35
36
|
pre: (data) => {
|
|
36
37
|
const { args, funcKey: identifier } = data;
|
|
37
38
|
const idx = resolveCallbackIdx(data.args);
|
|
39
|
+
|
|
38
40
|
if (idx >= 0) {
|
|
39
41
|
utils.bindFnArgAtIndex({ args, idx, identifier });
|
|
40
42
|
}
|
|
41
|
-
}
|
|
43
|
+
},
|
|
42
44
|
});
|
|
43
45
|
}
|
|
44
46
|
|
|
@@ -70,34 +72,84 @@ function init() {
|
|
|
70
72
|
requireHook.resolve(
|
|
71
73
|
{
|
|
72
74
|
name: 'mongodb',
|
|
73
|
-
file: 'lib/topologies/
|
|
74
|
-
version: '>=3.3.0
|
|
75
|
+
file: 'lib/topologies/topology_base.js',
|
|
76
|
+
version: '>=3.3.0',
|
|
75
77
|
},
|
|
76
|
-
(
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
78
|
+
(tpl, { version }) => {
|
|
79
|
+
if (semver.lt(version, '4.0.0')) {
|
|
80
|
+
return patcher.patch(tpl, 'TopologyBase', {
|
|
81
|
+
name: 'mongodb.TopologyBase',
|
|
82
|
+
patchType: ASYNC_CONTEXT,
|
|
83
|
+
alwaysRun: true,
|
|
84
|
+
post: (data) => {
|
|
85
|
+
const methods = ['command', 'insert', 'update', 'remove'];
|
|
86
|
+
for (const method of methods) {
|
|
87
|
+
hookMethod(data.result, method, 'mongodb.TopologyBase');
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
88
93
|
);
|
|
89
94
|
|
|
90
95
|
requireHook.resolve(
|
|
91
|
-
{
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
96
|
+
{
|
|
97
|
+
name: 'mongodb',
|
|
98
|
+
file: 'lib/topologies/native_topology.js',
|
|
99
|
+
version: '>=3.3.0',
|
|
100
|
+
},
|
|
101
|
+
(tpl, { version }) => {
|
|
102
|
+
if (semver.lt(version, '4.0.0')) {
|
|
103
|
+
return patcher.patch(tpl, {
|
|
104
|
+
name: 'mongodb.NativeTopology',
|
|
105
|
+
patchType: ASYNC_CONTEXT,
|
|
106
|
+
alwaysRun: true,
|
|
107
|
+
post: (data) => {
|
|
108
|
+
const methods = ['command', 'insert', 'update', 'remove'];
|
|
109
|
+
for (const method of methods) {
|
|
110
|
+
hookMethod(data.result, method, 'mongodb.NativeTopology');
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
requireHook.resolve(
|
|
119
|
+
{
|
|
120
|
+
name: 'mongodb',
|
|
121
|
+
file: 'lib/operations/command.js',
|
|
122
|
+
version: '>=3.3.0',
|
|
123
|
+
},
|
|
124
|
+
(command, { version }) => {
|
|
125
|
+
if (semver.gte(version, '4.0.0')) {
|
|
126
|
+
return patcher.patch(command, {
|
|
127
|
+
name: 'mongodb.Command',
|
|
128
|
+
patchType: ASYNC_CONTEXT,
|
|
129
|
+
alwaysRun: true,
|
|
130
|
+
post: (data) => {
|
|
131
|
+
hookMethod(data.result, 'executeCommand', 'mongodb.Command');
|
|
132
|
+
hookMethod(data.result, 'execute', 'mongodb.Command');
|
|
133
|
+
},
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
requireHook.resolve(
|
|
140
|
+
{ name: 'mongodb', file: 'lib/cursor.js', version: '>=3.3.0' },
|
|
141
|
+
(cursor, { version }) => {
|
|
142
|
+
if (semver.lt(version, '4.0.0')) {
|
|
143
|
+
return patcher.patch(cursor, {
|
|
144
|
+
name: 'mongodb.Cursor',
|
|
145
|
+
patchType: ASYNC_CONTEXT,
|
|
146
|
+
alwaysRun: true,
|
|
147
|
+
post: (data) => {
|
|
148
|
+
hookMethod(data.result, '_next', 'mongodb.Cursor');
|
|
149
|
+
},
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
}
|
|
101
153
|
);
|
|
102
154
|
}
|
|
103
155
|
|
|
@@ -195,7 +195,7 @@ class AsyncStorage {
|
|
|
195
195
|
}
|
|
196
196
|
|
|
197
197
|
/**
|
|
198
|
-
*
|
|
198
|
+
* Retrieves the active storage context from an error
|
|
199
199
|
* context is added to error when one is thrown
|
|
200
200
|
* see: https://github.com/Jeff-Lewis/cls-hooked/blob/master/context.js#L101
|
|
201
201
|
*
|
package/lib/libraries.js
CHANGED
|
@@ -164,7 +164,7 @@ const getLibInfo = async (agent, eluEnabled) =>
|
|
|
164
164
|
|
|
165
165
|
return libs;
|
|
166
166
|
} catch (err) {
|
|
167
|
-
logger.error('unable to read installed dependencies
|
|
167
|
+
logger.error('unable to read installed dependencies: %o', err);
|
|
168
168
|
return AppUpdate.libraries;
|
|
169
169
|
}
|
|
170
170
|
}, DEADZONE_NAME);
|
package/lib/list-installed.js
CHANGED
|
@@ -18,7 +18,7 @@ const semver = require('semver');
|
|
|
18
18
|
const util = require('util');
|
|
19
19
|
|
|
20
20
|
const {
|
|
21
|
-
AGENT_INFO: { SUPPORTED_NPM_VERSIONS }
|
|
21
|
+
AGENT_INFO: { SUPPORTED_NPM_VERSIONS },
|
|
22
22
|
} = require('./constants');
|
|
23
23
|
|
|
24
24
|
const VERSION_REGEX = /^npm@(\S+)\s+(\S+)$/m;
|
|
@@ -39,19 +39,18 @@ const execFile = util.promisify(require('child_process').execFile);
|
|
|
39
39
|
* @returns {Promise<Result>}
|
|
40
40
|
*/
|
|
41
41
|
module.exports = async function listInstalled(cwd, logger) {
|
|
42
|
-
const
|
|
43
|
-
|
|
42
|
+
const execFileOpts = {
|
|
43
|
+
cwd,
|
|
44
|
+
env: { ...process.env, NODE_OPTIONS: undefined },
|
|
45
|
+
maxBuffer: 1024 * 1024 * 128,
|
|
46
|
+
};
|
|
44
47
|
let stdout;
|
|
45
48
|
|
|
46
49
|
try {
|
|
47
|
-
const result = await execFile('npm', ['help'],
|
|
48
|
-
cwd,
|
|
49
|
-
env,
|
|
50
|
-
shell: true,
|
|
51
|
-
});
|
|
50
|
+
const result = await execFile('npm', ['help'], execFileOpts);
|
|
52
51
|
stdout = result.stdout;
|
|
53
52
|
} catch (err) {
|
|
54
|
-
logger.
|
|
53
|
+
logger.trace('`npm help` returned an error: %o', err);
|
|
55
54
|
// If npm encounters any errors whatsoever it will return with a non-zero
|
|
56
55
|
// exit code but still output the relevant information to stdout.
|
|
57
56
|
// If an even worse error occurs, we may not be able to parse stdout.
|
|
@@ -61,12 +60,13 @@ module.exports = async function listInstalled(cwd, logger) {
|
|
|
61
60
|
const [, version, location] = stdout.match(VERSION_REGEX) || [];
|
|
62
61
|
if (!version)
|
|
63
62
|
throw new Error(
|
|
64
|
-
|
|
63
|
+
"Unable to locate `npm`. `npm` is required for your application's libraries to be reported to Contrast for analysis. Please enable debug level logs for more information."
|
|
65
64
|
);
|
|
66
65
|
|
|
67
66
|
logger.debug('using npm version %s at %s', version, location);
|
|
68
67
|
|
|
69
|
-
|
|
68
|
+
const lsArgs = ['ls', '--json', '--long'];
|
|
69
|
+
if (semver.gte(version, '7.0.0')) lsArgs.push('--all');
|
|
70
70
|
if (!semver.satisfies(version, SUPPORTED_NPM_VERSIONS))
|
|
71
71
|
logger.warn(
|
|
72
72
|
'The installed version of npm (%s at %s) can cause unexpected behavior. Please install a version that satisfies %s',
|
|
@@ -76,16 +76,10 @@ module.exports = async function listInstalled(cwd, logger) {
|
|
|
76
76
|
);
|
|
77
77
|
|
|
78
78
|
try {
|
|
79
|
-
const result = await execFile('npm',
|
|
80
|
-
cwd,
|
|
81
|
-
env,
|
|
82
|
-
shell: true,
|
|
83
|
-
maxBuffer: 1024 * 1024 * 128,
|
|
84
|
-
});
|
|
85
|
-
|
|
79
|
+
const result = await execFile('npm', lsArgs, execFileOpts);
|
|
86
80
|
stdout = result.stdout;
|
|
87
81
|
} catch (err) {
|
|
88
|
-
logger.
|
|
82
|
+
logger.trace('`npm ls` returned an error: %o', err);
|
|
89
83
|
stdout = err.stdout || '';
|
|
90
84
|
}
|
|
91
85
|
|
|
@@ -94,7 +88,7 @@ module.exports = async function listInstalled(cwd, logger) {
|
|
|
94
88
|
} catch (err) {
|
|
95
89
|
logger.trace('parsing the output of `npm ls` failed: %o', err);
|
|
96
90
|
throw new Error(
|
|
97
|
-
'`npm ls` failed to provide a list of installed dependencies. Please enable
|
|
91
|
+
'`npm ls` failed to provide a list of installed dependencies. Please enable trace level logs for more information.'
|
|
98
92
|
);
|
|
99
93
|
}
|
|
100
94
|
};
|
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
Changelog
|
|
2
2
|
=========
|
|
3
3
|
|
|
4
|
+
### 2.29.4
|
|
5
|
+
|
|
6
|
+
* Release Jul 6, 2022
|
|
7
|
+
* [#6015](https://github.com/moment/moment/pull/6015) [bugfix] Fix ReDoS in preprocessRFC2822 regex
|
|
8
|
+
|
|
9
|
+
### 2.29.3 [Full changelog](https://gist.github.com/ichernev/edebd440f49adcaec72e5e77b791d8be)
|
|
10
|
+
|
|
11
|
+
* Release Apr 17, 2022
|
|
12
|
+
* [#5995](https://github.com/moment/moment/pull/5995) [bugfix] Remove const usage
|
|
13
|
+
* [#5990](https://github.com/moment/moment/pull/5990) misc: fix advisory link
|
|
14
|
+
|
|
15
|
+
|
|
4
16
|
### 2.29.2 [See full changelog](https://gist.github.com/ichernev/1904b564f6679d9aac1ae08ce13bc45c)
|
|
5
17
|
|
|
6
18
|
* Release Apr 3 2022
|
|
7
19
|
|
|
8
|
-
Address https://github.com/advisories/GHSA-8hfj-j24r-96c4
|
|
20
|
+
Address https://github.com/moment/moment/security/advisories/GHSA-8hfj-j24r-96c4
|
|
9
21
|
|
|
10
22
|
### 2.29.1 [See full changelog](https://gist.github.com/marwahaha/cc478ba01a1292ab4bd4e861d164d99b)
|
|
11
23
|
|
|
@@ -31,7 +31,8 @@ var translator = {
|
|
|
31
31
|
return wordKey[2];
|
|
32
32
|
},
|
|
33
33
|
translate: function (number, withoutSuffix, key, isFuture) {
|
|
34
|
-
var wordKey = translator.words[key]
|
|
34
|
+
var wordKey = translator.words[key],
|
|
35
|
+
word;
|
|
35
36
|
|
|
36
37
|
if (key.length === 1) {
|
|
37
38
|
// Nominativ
|
|
@@ -39,7 +40,7 @@ var translator = {
|
|
|
39
40
|
return isFuture || withoutSuffix ? wordKey[0] : wordKey[1];
|
|
40
41
|
}
|
|
41
42
|
|
|
42
|
-
|
|
43
|
+
word = translator.correctGrammaticalCase(number, wordKey);
|
|
43
44
|
// Nominativ
|
|
44
45
|
if (key === 'yy' && withoutSuffix && word === 'годину') {
|
|
45
46
|
return number + ' година';
|
|
@@ -31,7 +31,8 @@ var translator = {
|
|
|
31
31
|
return wordKey[2];
|
|
32
32
|
},
|
|
33
33
|
translate: function (number, withoutSuffix, key, isFuture) {
|
|
34
|
-
var wordKey = translator.words[key]
|
|
34
|
+
var wordKey = translator.words[key],
|
|
35
|
+
word;
|
|
35
36
|
|
|
36
37
|
if (key.length === 1) {
|
|
37
38
|
// Nominativ
|
|
@@ -39,7 +40,7 @@ var translator = {
|
|
|
39
40
|
return isFuture || withoutSuffix ? wordKey[0] : wordKey[1];
|
|
40
41
|
}
|
|
41
42
|
|
|
42
|
-
|
|
43
|
+
word = translator.correctGrammaticalCase(number, wordKey);
|
|
43
44
|
// Nominativ
|
|
44
45
|
if (key === 'yy' && withoutSuffix && word === 'godinu') {
|
|
45
46
|
return number + ' godina';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//! moment.js
|
|
2
|
-
//! version : 2.29.
|
|
2
|
+
//! version : 2.29.4
|
|
3
3
|
//! authors : Tim Wood, Iskren Chernev, Moment.js contributors
|
|
4
4
|
//! license : MIT
|
|
5
5
|
//! momentjs.com
|
|
@@ -2448,7 +2448,7 @@ function untruncateYear(yearStr) {
|
|
|
2448
2448
|
function preprocessRFC2822(s) {
|
|
2449
2449
|
// Remove comments and folding whitespace and replace multiple-spaces with a single space
|
|
2450
2450
|
return s
|
|
2451
|
-
.replace(/\([^)]*\)|[\n\t]/g, ' ')
|
|
2451
|
+
.replace(/\([^()]*\)|[\n\t]/g, ' ')
|
|
2452
2452
|
.replace(/(\s\s+)/g, ' ')
|
|
2453
2453
|
.replace(/^\s\s*/, '')
|
|
2454
2454
|
.replace(/\s\s*$/, '');
|
|
@@ -5629,7 +5629,7 @@ addParseToken('x', function (input, array, config) {
|
|
|
5629
5629
|
|
|
5630
5630
|
//! moment.js
|
|
5631
5631
|
|
|
5632
|
-
hooks.version = '2.29.
|
|
5632
|
+
hooks.version = '2.29.4';
|
|
5633
5633
|
|
|
5634
5634
|
setHookCallback(createLocal);
|
|
5635
5635
|
|
|
@@ -38,7 +38,8 @@
|
|
|
38
38
|
return wordKey[2];
|
|
39
39
|
},
|
|
40
40
|
translate: function (number, withoutSuffix, key, isFuture) {
|
|
41
|
-
var wordKey = translator.words[key]
|
|
41
|
+
var wordKey = translator.words[key],
|
|
42
|
+
word;
|
|
42
43
|
|
|
43
44
|
if (key.length === 1) {
|
|
44
45
|
// Nominativ
|
|
@@ -46,7 +47,7 @@
|
|
|
46
47
|
return isFuture || withoutSuffix ? wordKey[0] : wordKey[1];
|
|
47
48
|
}
|
|
48
49
|
|
|
49
|
-
|
|
50
|
+
word = translator.correctGrammaticalCase(number, wordKey);
|
|
50
51
|
// Nominativ
|
|
51
52
|
if (key === 'yy' && withoutSuffix && word === 'годину') {
|
|
52
53
|
return number + ' година';
|
|
@@ -38,7 +38,8 @@
|
|
|
38
38
|
return wordKey[2];
|
|
39
39
|
},
|
|
40
40
|
translate: function (number, withoutSuffix, key, isFuture) {
|
|
41
|
-
var wordKey = translator.words[key]
|
|
41
|
+
var wordKey = translator.words[key],
|
|
42
|
+
word;
|
|
42
43
|
|
|
43
44
|
if (key.length === 1) {
|
|
44
45
|
// Nominativ
|
|
@@ -46,7 +47,7 @@
|
|
|
46
47
|
return isFuture || withoutSuffix ? wordKey[0] : wordKey[1];
|
|
47
48
|
}
|
|
48
49
|
|
|
49
|
-
|
|
50
|
+
word = translator.correctGrammaticalCase(number, wordKey);
|
|
50
51
|
// Nominativ
|
|
51
52
|
if (key === 'yy' && withoutSuffix && word === 'godinu') {
|
|
52
53
|
return number + ' godina';
|