postman-runtime 7.41.1 → 7.42.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.
@@ -456,6 +456,7 @@ module.exports = {
456
456
  options.agents = defaultOpts.agents;
457
457
  options.extraCA = defaultOpts.extendedRootCA;
458
458
  options.ignoreProxyEnvironmentVariables = defaultOpts.ignoreProxyEnvironmentVariables;
459
+ options.agentIdleTimeout = defaultOpts.agentIdleTimeout;
459
460
 
460
461
  // Disable encoding of URL in postman-request in order to use pre-encoded URL object returned from
461
462
  // toNodeUrl() function of postman-url-encoder
@@ -25,6 +25,7 @@ RequesterPool = function (options, callback) {
25
25
  strictSSL: _.get(options, 'requester.strictSSL'),
26
26
  maxResponseSize: _.get(options, 'requester.maxResponseSize'),
27
27
  protocolVersion: _.get(options, 'requester.protocolVersion'),
28
+ agentIdleTimeout: _.get(options, 'requester.agentIdleTimeout', 60 * 1000), // 60 seconds
28
29
  // @todo drop support in v8
29
30
  useWhatWGUrlParser: _.get(options, 'requester.useWhatWGUrlParser', false),
30
31
  insecureHTTPParser: _.get(options, 'requester.insecureHTTPParser'),
@@ -21,6 +21,8 @@ var _ = require('lodash'),
21
21
  EXECUTION_COOKIES_EVENT_BASE = 'execution.cookies.',
22
22
  EXECUTION_SKIP_REQUEST_EVENT_BASE = 'execution.skipRequest.',
23
23
 
24
+ EXECUTION_VAULT_BASE = 'execution.vault.',
25
+
24
26
  COOKIES_EVENT_STORE_ACTION = 'store',
25
27
  COOKIE_STORE_PUT_METHOD = 'putCookie',
26
28
  COOKIE_STORE_UPDATE_METHOD = 'updateCookie',
@@ -240,8 +242,17 @@ module.exports = {
240
242
 
241
243
  packageResolver = _.get(this, 'options.script.packageResolver'),
242
244
 
245
+ vaultSecrets = payload.context.vaultSecrets,
246
+ allowVaultAccess = _.get(vaultSecrets, '_.allowScriptAccess'),
247
+
243
248
  events;
244
249
 
250
+ // Explicitly enable tracking for vault secrets here as this will
251
+ // not be sent to sandbox who otherwise takes care of mutation tracking
252
+ if (allowVaultAccess) {
253
+ vaultSecrets.enableTracking({ autoCompact: true });
254
+ }
255
+
245
256
  // @todo: find a better place to code this so that event is not aware of such options
246
257
  if (abortOnFailure) {
247
258
  abortOnError = true;
@@ -387,6 +398,22 @@ module.exports = {
387
398
  }
388
399
  }.bind(this));
389
400
 
401
+ this.host.on(EXECUTION_VAULT_BASE + executionId, function (id, cmd, ...args) {
402
+ // Ensure error is string
403
+ // TODO identify why error objects are not being serialized correctly
404
+ const dispatch = (e, r) => { this.host.dispatch(EXECUTION_VAULT_BASE + executionId, id, e, r); };
405
+
406
+ if (!allowVaultAccess) {
407
+ return dispatch('Vault access denied');
408
+ }
409
+
410
+ if (!['get', 'set', 'unset'].includes(cmd)) {
411
+ return dispatch(`Invalid vault command: ${cmd}`);
412
+ }
413
+
414
+ dispatch(null, vaultSecrets[cmd](...args));
415
+ }.bind(this));
416
+
390
417
  this.host.on(EXECUTION_REQUEST_EVENT_BASE + executionId,
391
418
  function (scriptCursor, id, requestId, request) {
392
419
  // remove files in request body if any
@@ -458,11 +485,7 @@ module.exports = {
458
485
  // @todo: Expose this as a property in Collection SDK's Script
459
486
  timeout: payload.scriptTimeout,
460
487
  cursor: scriptCursor,
461
- context: {
462
- ..._.pick(payload.context, SAFE_CONTEXT_VARIABLES),
463
- vaultSecrets: _.get(payload.context.vaultSecrets, '_.allowScriptAccess') ?
464
- payload.context.vaultSecrets : undefined
465
- },
488
+ context: _.pick(payload.context, SAFE_CONTEXT_VARIABLES),
466
489
  resolvedPackages: resolvedPackages,
467
490
 
468
491
  // legacy options
@@ -479,6 +502,7 @@ module.exports = {
479
502
  this.host.removeAllListeners(EXECUTION_COOKIES_EVENT_BASE + executionId);
480
503
  this.host.removeAllListeners(EXECUTION_ERROR_EVENT_BASE + executionId);
481
504
  this.host.removeAllListeners(EXECUTION_SKIP_REQUEST_EVENT_BASE + executionId);
505
+ this.host.removeAllListeners(EXECUTION_VAULT_BASE + executionId);
482
506
 
483
507
  // Handle async errors as well.
484
508
  // If there was an error running the script itself, that takes precedence
@@ -529,10 +553,16 @@ module.exports = {
529
553
  result && result.globals && (result.globals = new sdk.VariableScope(result.globals));
530
554
  result && result.collectionVariables &&
531
555
  (result.collectionVariables = new sdk.VariableScope(result.collectionVariables));
532
- result && result.vaultSecrets &&
533
- (result.vaultSecrets = new sdk.VariableScope(result.vaultSecrets));
534
556
  result && result.request && (result.request = new sdk.Request(result.request));
535
557
 
558
+ // vault secrets are not sent to sandbox, thus using the scope from run context.
559
+ if (allowVaultAccess && vaultSecrets) {
560
+ result.vaultSecrets = vaultSecrets;
561
+
562
+ // Prevent mutations from being carry-forwarded to subsequent events
563
+ vaultSecrets.disableTracking();
564
+ }
565
+
536
566
  // @note Since postman-sandbox@3.5.2, response object is not included in the execution
537
567
  // result.
538
568
  // Refer: https://github.com/postmanlabs/postman-sandbox/pull/512
@@ -152,7 +152,8 @@ module.exports = {
152
152
  item: item,
153
153
  coords: coords,
154
154
  context: ctxTemplate,
155
- trackContext: ['globals', 'environment', 'collectionVariables', 'vaultSecrets'],
155
+ // No need to include vaultSecrets here as runtime takes care of tracking internally
156
+ trackContext: ['globals', 'environment', 'collectionVariables'],
156
157
  stopOnScriptError: stopOnError,
157
158
  stopOnFailure: stopOnFailure
158
159
  }).done(function (prereqExecutions, prereqExecutionError, shouldSkipExecution) {
@@ -234,7 +235,8 @@ module.exports = {
234
235
  item: item,
235
236
  coords: coords,
236
237
  context: ctxTemplate,
237
- trackContext: ['tests', 'globals', 'environment', 'collectionVariables', 'vaultSecrets'],
238
+ // No need to include vaultSecrets here as runtime takes care of tracking internally
239
+ trackContext: ['tests', 'globals', 'environment', 'collectionVariables'],
238
240
  stopOnScriptError: stopOnError,
239
241
  abortOnFailure: abortOnFailure,
240
242
  stopOnFailure: stopOnFailure
@@ -80,7 +80,8 @@ module.exports = {
80
80
  new VariableScope(state.vaultSecrets);
81
81
  state.collectionVariables = VariableScope.isVariableScope(state.collectionVariables) ?
82
82
  state.collectionVariables : new VariableScope(state.collectionVariables);
83
- state._variables = new VariableScope();
83
+ state._variables = VariableScope.isVariableScope(state.localVariables) ?
84
+ state.localVariables : new VariableScope(state.localVariables);
84
85
 
85
86
  // prepare the vault variable scope
86
87
  prepareVaultVariableScope(state.vaultSecrets);
@@ -121,6 +121,7 @@ _.assign(Runner.prototype, {
121
121
  vaultSecrets: options.vaultSecrets,
122
122
  // @todo Move to item level to support Item and ItemGroup variables
123
123
  collectionVariables: collection.variables,
124
+ localVariables: options.localVariables,
124
125
  certificates: options.certificates,
125
126
  proxies: options.proxies
126
127
  }, runOptions)));
package/lib/runner/run.js CHANGED
@@ -157,6 +157,9 @@ _.assign(Run.prototype, {
157
157
 
158
158
  // if there is nothing to process, exit
159
159
  if (!instruction) {
160
+ // dispose the host before ending the run
161
+ this.host && this.host.dispose();
162
+
160
163
  callback(null, this.state.cursor.current());
161
164
 
162
165
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "postman-runtime",
3
- "version": "7.41.1",
3
+ "version": "7.42.0",
4
4
  "description": "Underlying library of executing Postman Collections",
5
5
  "author": "Postman Inc.",
6
6
  "license": "Apache-2.0",
@@ -55,8 +55,8 @@
55
55
  "node-oauth1": "1.3.0",
56
56
  "performance-now": "2.1.0",
57
57
  "postman-collection": "4.5.0",
58
- "postman-request": "2.88.1-postman.38",
59
- "postman-sandbox": "5.1.1",
58
+ "postman-request": "2.88.1-postman.40",
59
+ "postman-sandbox": "5.1.2",
60
60
  "postman-url-encoder": "3.0.5",
61
61
  "serialised-error": "1.1.3",
62
62
  "strip-json-comments": "3.1.1",