Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

machine

Package Overview
Dependencies
Maintainers
5
Versions
132
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

machine - npm Package Compare versions

Comparing version 4.0.4 to 4.0.5

18

lib/Machine.constructor.js

@@ -90,2 +90,6 @@ /**

// unsafe mode completely disables input validation, and sets _runTimeTypeCheck, _inputCoercion
// and _exitCoercion to `false` (they can be reactivated if chained after the call to `.unsafe()`)
this._unsafeMode = false;
this._runningSynchronously = false;

@@ -167,2 +171,16 @@

*/
Machine.prototype.unsafe = function(flag) {
this._unsafeMode = flag;
if (flag === true) {
this._runTimeTypeCheck = false;
this._inputCoercion = false;
this._exitCoercion = false;
}
return this;
};
/**
* @param {Boolean} flag
* @chainable
*/
Machine.prototype.inputCoercion = function(flag) {

@@ -169,0 +187,0 @@ this._inputCoercion = flag;

54

lib/Machine.prototype.exec.js

@@ -34,30 +34,32 @@ /**

var validationResults = validateConfiguredInputValues(self);
var coercedInputValues = validationResults.values;
var errors = validationResults.errors;
if (!self._unsafeMode) {
var validationResults = validateConfiguredInputValues(self);
var coercedInputValues = validationResults.values;
var errors = validationResults.errors;
// Strip E_INVALID_TYPE errors if inputCoercion is enabled.
if (self._inputCoercion) {
// Strip out minor "E_INVALID_TYPE" errors- they are ok if we're just coercing.
_.remove(errors, {code: 'E_INVALID_TYPE', minor: true});
}
// Strip E_INVALID_TYPE errors if inputCoercion is enabled.
if (self._inputCoercion) {
// Strip out minor "E_INVALID_TYPE" errors- they are ok if we're just coercing.
_.remove(errors, {code: 'E_INVALID_TYPE', minor: true});
}
// If there are (still) `e.errors`, then we've got to call the error callback.
if (errors.length > 0) {
// If runtime type checking is enabled, trigger the error exit
// if any inputs are invalid.
// TODO: call a special 'failedInputValidation' exit here
if(self._runTimeTypeCheck) {
// Fourth argument (`true`) tells switchback to run synchronously
return switchback(self._configuredExits, undefined, undefined, true)((function (){
// var err = new Error(util.format('`%s` machine: %d error(s) encountered validating inputs:\n', self.identity, errors.length, util.inspect(errors)));
var err = new Error(util.format('`%s` machine encountered %d error(s) while validating runtime input values.', self.identity, errors.length));
// err.code = errors[0].code;
err.code = 'E_MACHINE_RUNTIME_VALIDATION';
err.machine = self.identity;
err.reason = err.message;
err.status = 400;
err.errors = errors;
return err;
})());
// If there are (still) `e.errors`, then we've got to call the error callback.
if (errors.length > 0) {
// If runtime type checking is enabled, trigger the error exit
// if any inputs are invalid.
// TODO: call a special 'failedInputValidation' exit here
if(self._runTimeTypeCheck) {
// Fourth argument (`true`) tells switchback to run synchronously
return switchback(self._configuredExits, undefined, undefined, true)((function (){
// var err = new Error(util.format('`%s` machine: %d error(s) encountered validating inputs:\n', self.identity, errors.length, util.inspect(errors)));
var err = new Error(util.format('`%s` machine encountered %d error(s) while validating runtime input values.', self.identity, errors.length));
// err.code = errors[0].code;
err.code = 'E_MACHINE_RUNTIME_VALIDATION';
err.machine = self.identity;
err.reason = err.message;
err.status = 400;
err.errors = errors;
return err;
})());
}
}

@@ -64,0 +66,0 @@ }

{
"name": "machine",
"version": "4.0.4",
"version": "4.0.5",
"description": "Configure and execute machines",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc