npm.io
1.0.3 • Published 8 years ago

require-shield

Licence
MIT
Version
1.0.3
Deps
0
Vulns
0
Weekly
0
Stars
1
var rs = require('require-shield')({mode: 'white-list'});
rs.except('^stream|string_decoder

What this is

  • A simple tool to control which modules can be loaded and by which modules
  • It gives you peace of mind when using third party modules
  • It eases you of the burden of reviewing and understanding the implementation of other modules

Installation

This is a Node.js module available through the npm registry.

Before installing, download and install Node.js. Node.js 9.4 or higher is required.

Installation is done using the npm install command:

$ npm install require-shield

Arguments (configuration)

configuration: mode
  • white-list: Default. All modules are prohibited from loading any module unless explicitly allowed.
  • black-list: All modules are allowed to load any other module unless explicitly denied.
var rs = require('require-shield')({mode: 'black-list'});

Methods

except(toRequire[, fromModules])

This method is used in white-list mode to indicate which modules will be allowed to load other modules. In black-list mode it indicates which modules will be prevented from loading other modules.

Arguments

toRequire: A regular expression to match the names or paths of modules that we want to allow being required in white-list mode, and deny in black-list mode.
fromModules: Optional. A regular expression to match the names or paths of modules that we want to allow requiring the toRequire modules in white-list mode, and deny in black-list mode. If this argument is not provided, the exception is for all modules.

Examples

Allow only the stream and string_decoder modules to be loaded, and only by the sax module:
var rs = require('require-shield')({mode: 'white-list'});
rs.except('^stream|string_decoder
Prevent all modules from loading the stream and string_decoder modules:
var rs = require('require-shield')({mode: 'black-list'});
rs.except('^stream|string_decoder

Testing

The 'mocha' module is used for testing. Run either 'whitelist.js' or 'blacklist.js', but not both in the same run. If you are testing this in Cloud9, you can choose the Mocha runner, and give the path to the test file as argument.
Example:

$ mocha test/blacklist.js

This will enable you to debug the code through the test.
Note: The path must be specified relative to your workspace.

, '^sax

What this is

  • A simple tool to control which modules can be loaded and by which modules
  • It gives you peace of mind when using third party modules
  • It eases you of the burden of reviewing and understanding the implementation of other modules

Installation

This is a Node.js module available through the npm registry.

Before installing, download and install Node.js. Node.js 9.4 or higher is required.

Installation is done using the __INLINE_CODE_0__ command:

__CODE_BLOCK_1__

Arguments (__INLINE_CODE_1__)

configuration: __INLINE_CODE_2__
  • __INLINE_CODE_3__: Default. All modules are prohibited from loading any module unless explicitly allowed.
  • __INLINE_CODE_4__: All modules are allowed to load any other module unless explicitly denied.
__CODE_BLOCK_2__

Methods

__INLINE_CODE_5__

This method is used in __INLINE_CODE_6__ mode to indicate which modules will be allowed to load other modules. In __INLINE_CODE_7__ mode it indicates which modules will be prevented from loading other modules.

Arguments

__INLINE_CODE_8__: A regular expression to match the names or paths of modules that we want to allow being required in __INLINE_CODE_9__ mode, and deny in __INLINE_CODE_10__ mode.
__INLINE_CODE_11__: Optional. A regular expression to match the names or paths of modules that we want to allow requiring the __INLINE_CODE_12__ modules in __INLINE_CODE_13__ mode, and deny in __INLINE_CODE_14__ mode. If this argument is not provided, the exception is for all modules.

Examples

Allow only the __INLINE_CODE_15__ and __INLINE_CODE_16__ modules to be loaded, and only by the __INLINE_CODE_17__ module:
__CODE_BLOCK_3__
Prevent all modules from loading the __INLINE_CODE_18__ and __INLINE_CODE_19__ modules:
__CODE_BLOCK_4__

Testing

The 'mocha' module is used for testing. Run either 'whitelist.js' or 'blacklist.js', but not both in the same run. If you are testing this in Cloud9, you can choose the Mocha runner, and give the path to the test file as argument.
Example:

__CODE_BLOCK_5__

This will enable you to debug the code through the test.
Note: The path must be specified relative to your workspace.

);

What this is

  • A simple tool to control which modules can be loaded and by which modules
  • It gives you peace of mind when using third party modules
  • It eases you of the burden of reviewing and understanding the implementation of other modules

Installation

This is a Node.js module available through the npm registry.

Before installing, download and install Node.js. Node.js 9.4 or higher is required.

Installation is done using the __INLINE_CODE_0__ command:

__CODE_BLOCK_1__

Arguments (__INLINE_CODE_1__)

configuration: __INLINE_CODE_2__
  • __INLINE_CODE_3__: Default. All modules are prohibited from loading any module unless explicitly allowed.
  • __INLINE_CODE_4__: All modules are allowed to load any other module unless explicitly denied.
__CODE_BLOCK_2__

Methods

__INLINE_CODE_5__

This method is used in __INLINE_CODE_6__ mode to indicate which modules will be allowed to load other modules. In __INLINE_CODE_7__ mode it indicates which modules will be prevented from loading other modules.

Arguments

__INLINE_CODE_8__: A regular expression to match the names or paths of modules that we want to allow being required in __INLINE_CODE_9__ mode, and deny in __INLINE_CODE_10__ mode.
__INLINE_CODE_11__: Optional. A regular expression to match the names or paths of modules that we want to allow requiring the __INLINE_CODE_12__ modules in __INLINE_CODE_13__ mode, and deny in __INLINE_CODE_14__ mode. If this argument is not provided, the exception is for all modules.

Examples

Allow only the __INLINE_CODE_15__ and __INLINE_CODE_16__ modules to be loaded, and only by the __INLINE_CODE_17__ module:
__CODE_BLOCK_3__
Prevent all modules from loading the __INLINE_CODE_18__ and __INLINE_CODE_19__ modules:
__CODE_BLOCK_4__

Testing

The 'mocha' module is used for testing. Run either 'whitelist.js' or 'blacklist.js', but not both in the same run. If you are testing this in Cloud9, you can choose the Mocha runner, and give the path to the test file as argument.
Example:

__CODE_BLOCK_5__

This will enable you to debug the code through the test.
Note: The path must be specified relative to your workspace.

, '^sax
Prevent all modules from loading the __INLINE_CODE_18__ and __INLINE_CODE_19__ modules:
__CODE_BLOCK_4__

Testing

The 'mocha' module is used for testing. Run either 'whitelist.js' or 'blacklist.js', but not both in the same run. If you are testing this in Cloud9, you can choose the Mocha runner, and give the path to the test file as argument.
Example:

__CODE_BLOCK_5__

This will enable you to debug the code through the test.
Note: The path must be specified relative to your workspace.

, '^sax

What this is

  • A simple tool to control which modules can be loaded and by which modules
  • It gives you peace of mind when using third party modules
  • It eases you of the burden of reviewing and understanding the implementation of other modules

Installation

This is a Node.js module available through the npm registry.

Before installing, download and install Node.js. Node.js 9.4 or higher is required.

Installation is done using the __INLINE_CODE_0__ command:

__CODE_BLOCK_1__

Arguments (__INLINE_CODE_1__)

configuration: __INLINE_CODE_2__
  • __INLINE_CODE_3__: Default. All modules are prohibited from loading any module unless explicitly allowed.
  • __INLINE_CODE_4__: All modules are allowed to load any other module unless explicitly denied.
__CODE_BLOCK_2__

Methods

__INLINE_CODE_5__

This method is used in __INLINE_CODE_6__ mode to indicate which modules will be allowed to load other modules. In __INLINE_CODE_7__ mode it indicates which modules will be prevented from loading other modules.

Arguments

__INLINE_CODE_8__: A regular expression to match the names or paths of modules that we want to allow being required in __INLINE_CODE_9__ mode, and deny in __INLINE_CODE_10__ mode.
__INLINE_CODE_11__: Optional. A regular expression to match the names or paths of modules that we want to allow requiring the __INLINE_CODE_12__ modules in __INLINE_CODE_13__ mode, and deny in __INLINE_CODE_14__ mode. If this argument is not provided, the exception is for all modules.

Examples

Allow only the __INLINE_CODE_15__ and __INLINE_CODE_16__ modules to be loaded, and only by the __INLINE_CODE_17__ module:
__CODE_BLOCK_3__
Prevent all modules from loading the __INLINE_CODE_18__ and __INLINE_CODE_19__ modules:
__CODE_BLOCK_4__

Testing

The 'mocha' module is used for testing. Run either 'whitelist.js' or 'blacklist.js', but not both in the same run. If you are testing this in Cloud9, you can choose the Mocha runner, and give the path to the test file as argument.
Example:

__CODE_BLOCK_5__

This will enable you to debug the code through the test.
Note: The path must be specified relative to your workspace.

);

What this is

  • A simple tool to control which modules can be loaded and by which modules
  • It gives you peace of mind when using third party modules
  • It eases you of the burden of reviewing and understanding the implementation of other modules

Installation

This is a Node.js module available through the npm registry.

Before installing, download and install Node.js. Node.js 9.4 or higher is required.

Installation is done using the __INLINE_CODE_0__ command:

__CODE_BLOCK_1__

Arguments (__INLINE_CODE_1__)

configuration: __INLINE_CODE_2__
  • __INLINE_CODE_3__: Default. All modules are prohibited from loading any module unless explicitly allowed.
  • __INLINE_CODE_4__: All modules are allowed to load any other module unless explicitly denied.
__CODE_BLOCK_2__

Methods

__INLINE_CODE_5__

This method is used in __INLINE_CODE_6__ mode to indicate which modules will be allowed to load other modules. In __INLINE_CODE_7__ mode it indicates which modules will be prevented from loading other modules.

Arguments

__INLINE_CODE_8__: A regular expression to match the names or paths of modules that we want to allow being required in __INLINE_CODE_9__ mode, and deny in __INLINE_CODE_10__ mode.
__INLINE_CODE_11__: Optional. A regular expression to match the names or paths of modules that we want to allow requiring the __INLINE_CODE_12__ modules in __INLINE_CODE_13__ mode, and deny in __INLINE_CODE_14__ mode. If this argument is not provided, the exception is for all modules.

Examples

Allow only the __INLINE_CODE_15__ and __INLINE_CODE_16__ modules to be loaded, and only by the __INLINE_CODE_17__ module:
__CODE_BLOCK_3__
Prevent all modules from loading the __INLINE_CODE_18__ and __INLINE_CODE_19__ modules:
__CODE_BLOCK_4__

Testing

The 'mocha' module is used for testing. Run either 'whitelist.js' or 'blacklist.js', but not both in the same run. If you are testing this in Cloud9, you can choose the Mocha runner, and give the path to the test file as argument.
Example:

__CODE_BLOCK_5__

This will enable you to debug the code through the test.
Note: The path must be specified relative to your workspace.

);
Prevent all modules from loading the __INLINE_CODE_18__ and __INLINE_CODE_19__ modules:
__CODE_BLOCK_4__

Testing

The 'mocha' module is used for testing. Run either 'whitelist.js' or 'blacklist.js', but not both in the same run. If you are testing this in Cloud9, you can choose the Mocha runner, and give the path to the test file as argument.
Example:

__CODE_BLOCK_5__

This will enable you to debug the code through the test.
Note: The path must be specified relative to your workspace.

, '^sax

What this is

  • A simple tool to control which modules can be loaded and by which modules
  • It gives you peace of mind when using third party modules
  • It eases you of the burden of reviewing and understanding the implementation of other modules

Installation

This is a Node.js module available through the npm registry.

Before installing, download and install Node.js. Node.js 9.4 or higher is required.

Installation is done using the __INLINE_CODE_0__ command:

__CODE_BLOCK_1__

Arguments (__INLINE_CODE_1__)

configuration: __INLINE_CODE_2__
  • __INLINE_CODE_3__: Default. All modules are prohibited from loading any module unless explicitly allowed.
  • __INLINE_CODE_4__: All modules are allowed to load any other module unless explicitly denied.
__CODE_BLOCK_2__

Methods

__INLINE_CODE_5__

This method is used in __INLINE_CODE_6__ mode to indicate which modules will be allowed to load other modules. In __INLINE_CODE_7__ mode it indicates which modules will be prevented from loading other modules.

Arguments

__INLINE_CODE_8__: A regular expression to match the names or paths of modules that we want to allow being required in __INLINE_CODE_9__ mode, and deny in __INLINE_CODE_10__ mode.
__INLINE_CODE_11__: Optional. A regular expression to match the names or paths of modules that we want to allow requiring the __INLINE_CODE_12__ modules in __INLINE_CODE_13__ mode, and deny in __INLINE_CODE_14__ mode. If this argument is not provided, the exception is for all modules.

Examples

Allow only the __INLINE_CODE_15__ and __INLINE_CODE_16__ modules to be loaded, and only by the __INLINE_CODE_17__ module:
__CODE_BLOCK_3__
Prevent all modules from loading the __INLINE_CODE_18__ and __INLINE_CODE_19__ modules:
__CODE_BLOCK_4__

Testing

The 'mocha' module is used for testing. Run either 'whitelist.js' or 'blacklist.js', but not both in the same run. If you are testing this in Cloud9, you can choose the Mocha runner, and give the path to the test file as argument.
Example:

__CODE_BLOCK_5__

This will enable you to debug the code through the test.
Note: The path must be specified relative to your workspace.

);

What this is

  • A simple tool to control which modules can be loaded and by which modules
  • It gives you peace of mind when using third party modules
  • It eases you of the burden of reviewing and understanding the implementation of other modules

Installation

This is a Node.js module available through the npm registry.

Before installing, download and install Node.js. Node.js 9.4 or higher is required.

Installation is done using the __INLINE_CODE_0__ command:

__CODE_BLOCK_1__

Arguments (__INLINE_CODE_1__)

configuration: __INLINE_CODE_2__
  • __INLINE_CODE_3__: Default. All modules are prohibited from loading any module unless explicitly allowed.
  • __INLINE_CODE_4__: All modules are allowed to load any other module unless explicitly denied.
__CODE_BLOCK_2__

Methods

__INLINE_CODE_5__

This method is used in __INLINE_CODE_6__ mode to indicate which modules will be allowed to load other modules. In __INLINE_CODE_7__ mode it indicates which modules will be prevented from loading other modules.

Arguments

__INLINE_CODE_8__: A regular expression to match the names or paths of modules that we want to allow being required in __INLINE_CODE_9__ mode, and deny in __INLINE_CODE_10__ mode.
__INLINE_CODE_11__: Optional. A regular expression to match the names or paths of modules that we want to allow requiring the __INLINE_CODE_12__ modules in __INLINE_CODE_13__ mode, and deny in __INLINE_CODE_14__ mode. If this argument is not provided, the exception is for all modules.

Examples

Allow only the __INLINE_CODE_15__ and __INLINE_CODE_16__ modules to be loaded, and only by the __INLINE_CODE_17__ module:
__CODE_BLOCK_3__
Prevent all modules from loading the __INLINE_CODE_18__ and __INLINE_CODE_19__ modules:
__CODE_BLOCK_4__

Testing

The 'mocha' module is used for testing. Run either 'whitelist.js' or 'blacklist.js', but not both in the same run. If you are testing this in Cloud9, you can choose the Mocha runner, and give the path to the test file as argument.
Example:

__CODE_BLOCK_5__

This will enable you to debug the code through the test.
Note: The path must be specified relative to your workspace.

);

Testing

The 'mocha' module is used for testing. Run either 'whitelist.js' or 'blacklist.js', but not both in the same run. If you are testing this in Cloud9, you can choose the Mocha runner, and give the path to the test file as argument.
Example:

__CODE_BLOCK_5__

This will enable you to debug the code through the test.
Note: The path must be specified relative to your workspace.

, '^sax

What this is

  • A simple tool to control which modules can be loaded and by which modules
  • It gives you peace of mind when using third party modules
  • It eases you of the burden of reviewing and understanding the implementation of other modules

Installation

This is a Node.js module available through the npm registry.

Before installing, download and install Node.js. Node.js 9.4 or higher is required.

Installation is done using the __INLINE_CODE_0__ command:

__CODE_BLOCK_1__

Arguments (__INLINE_CODE_1__)

configuration: __INLINE_CODE_2__
  • __INLINE_CODE_3__: Default. All modules are prohibited from loading any module unless explicitly allowed.
  • __INLINE_CODE_4__: All modules are allowed to load any other module unless explicitly denied.
__CODE_BLOCK_2__

Methods

__INLINE_CODE_5__

This method is used in __INLINE_CODE_6__ mode to indicate which modules will be allowed to load other modules. In __INLINE_CODE_7__ mode it indicates which modules will be prevented from loading other modules.

Arguments

__INLINE_CODE_8__: A regular expression to match the names or paths of modules that we want to allow being required in __INLINE_CODE_9__ mode, and deny in __INLINE_CODE_10__ mode.
__INLINE_CODE_11__: Optional. A regular expression to match the names or paths of modules that we want to allow requiring the __INLINE_CODE_12__ modules in __INLINE_CODE_13__ mode, and deny in __INLINE_CODE_14__ mode. If this argument is not provided, the exception is for all modules.

Examples

Allow only the __INLINE_CODE_15__ and __INLINE_CODE_16__ modules to be loaded, and only by the __INLINE_CODE_17__ module:
__CODE_BLOCK_3__
Prevent all modules from loading the __INLINE_CODE_18__ and __INLINE_CODE_19__ modules:
__CODE_BLOCK_4__

Testing

The 'mocha' module is used for testing. Run either 'whitelist.js' or 'blacklist.js', but not both in the same run. If you are testing this in Cloud9, you can choose the Mocha runner, and give the path to the test file as argument.
Example:

__CODE_BLOCK_5__

This will enable you to debug the code through the test.
Note: The path must be specified relative to your workspace.

);

What this is

  • A simple tool to control which modules can be loaded and by which modules
  • It gives you peace of mind when using third party modules
  • It eases you of the burden of reviewing and understanding the implementation of other modules

Installation

This is a Node.js module available through the npm registry.

Before installing, download and install Node.js. Node.js 9.4 or higher is required.

Installation is done using the __INLINE_CODE_0__ command:

__CODE_BLOCK_1__

Arguments (__INLINE_CODE_1__)

configuration: __INLINE_CODE_2__
  • __INLINE_CODE_3__: Default. All modules are prohibited from loading any module unless explicitly allowed.
  • __INLINE_CODE_4__: All modules are allowed to load any other module unless explicitly denied.
__CODE_BLOCK_2__

Methods

__INLINE_CODE_5__

This method is used in __INLINE_CODE_6__ mode to indicate which modules will be allowed to load other modules. In __INLINE_CODE_7__ mode it indicates which modules will be prevented from loading other modules.

Arguments

__INLINE_CODE_8__: A regular expression to match the names or paths of modules that we want to allow being required in __INLINE_CODE_9__ mode, and deny in __INLINE_CODE_10__ mode.
__INLINE_CODE_11__: Optional. A regular expression to match the names or paths of modules that we want to allow requiring the __INLINE_CODE_12__ modules in __INLINE_CODE_13__ mode, and deny in __INLINE_CODE_14__ mode. If this argument is not provided, the exception is for all modules.

Examples

Allow only the __INLINE_CODE_15__ and __INLINE_CODE_16__ modules to be loaded, and only by the __INLINE_CODE_17__ module:
__CODE_BLOCK_3__
Prevent all modules from loading the __INLINE_CODE_18__ and __INLINE_CODE_19__ modules:
__CODE_BLOCK_4__

Testing

The 'mocha' module is used for testing. Run either 'whitelist.js' or 'blacklist.js', but not both in the same run. If you are testing this in Cloud9, you can choose the Mocha runner, and give the path to the test file as argument.
Example:

__CODE_BLOCK_5__

This will enable you to debug the code through the test.
Note: The path must be specified relative to your workspace.

, '^sax
Prevent all modules from loading the __INLINE_CODE_18__ and __INLINE_CODE_19__ modules:
__CODE_BLOCK_4__

Testing

The 'mocha' module is used for testing. Run either 'whitelist.js' or 'blacklist.js', but not both in the same run. If you are testing this in Cloud9, you can choose the Mocha runner, and give the path to the test file as argument.
Example:

__CODE_BLOCK_5__

This will enable you to debug the code through the test.
Note: The path must be specified relative to your workspace.

, '^sax

What this is

  • A simple tool to control which modules can be loaded and by which modules
  • It gives you peace of mind when using third party modules
  • It eases you of the burden of reviewing and understanding the implementation of other modules

Installation

This is a Node.js module available through the npm registry.

Before installing, download and install Node.js. Node.js 9.4 or higher is required.

Installation is done using the __INLINE_CODE_0__ command:

__CODE_BLOCK_1__

Arguments (__INLINE_CODE_1__)

configuration: __INLINE_CODE_2__
  • __INLINE_CODE_3__: Default. All modules are prohibited from loading any module unless explicitly allowed.
  • __INLINE_CODE_4__: All modules are allowed to load any other module unless explicitly denied.
__CODE_BLOCK_2__

Methods

__INLINE_CODE_5__

This method is used in __INLINE_CODE_6__ mode to indicate which modules will be allowed to load other modules. In __INLINE_CODE_7__ mode it indicates which modules will be prevented from loading other modules.

Arguments

__INLINE_CODE_8__: A regular expression to match the names or paths of modules that we want to allow being required in __INLINE_CODE_9__ mode, and deny in __INLINE_CODE_10__ mode.
__INLINE_CODE_11__: Optional. A regular expression to match the names or paths of modules that we want to allow requiring the __INLINE_CODE_12__ modules in __INLINE_CODE_13__ mode, and deny in __INLINE_CODE_14__ mode. If this argument is not provided, the exception is for all modules.

Examples

Allow only the __INLINE_CODE_15__ and __INLINE_CODE_16__ modules to be loaded, and only by the __INLINE_CODE_17__ module:
__CODE_BLOCK_3__
Prevent all modules from loading the __INLINE_CODE_18__ and __INLINE_CODE_19__ modules:
__CODE_BLOCK_4__

Testing

The 'mocha' module is used for testing. Run either 'whitelist.js' or 'blacklist.js', but not both in the same run. If you are testing this in Cloud9, you can choose the Mocha runner, and give the path to the test file as argument.
Example:

__CODE_BLOCK_5__

This will enable you to debug the code through the test.
Note: The path must be specified relative to your workspace.

);

What this is

  • A simple tool to control which modules can be loaded and by which modules
  • It gives you peace of mind when using third party modules
  • It eases you of the burden of reviewing and understanding the implementation of other modules

Installation

This is a Node.js module available through the npm registry.

Before installing, download and install Node.js. Node.js 9.4 or higher is required.

Installation is done using the __INLINE_CODE_0__ command:

__CODE_BLOCK_1__

Arguments (__INLINE_CODE_1__)

configuration: __INLINE_CODE_2__
  • __INLINE_CODE_3__: Default. All modules are prohibited from loading any module unless explicitly allowed.
  • __INLINE_CODE_4__: All modules are allowed to load any other module unless explicitly denied.
__CODE_BLOCK_2__

Methods

__INLINE_CODE_5__

This method is used in __INLINE_CODE_6__ mode to indicate which modules will be allowed to load other modules. In __INLINE_CODE_7__ mode it indicates which modules will be prevented from loading other modules.

Arguments

__INLINE_CODE_8__: A regular expression to match the names or paths of modules that we want to allow being required in __INLINE_CODE_9__ mode, and deny in __INLINE_CODE_10__ mode.
__INLINE_CODE_11__: Optional. A regular expression to match the names or paths of modules that we want to allow requiring the __INLINE_CODE_12__ modules in __INLINE_CODE_13__ mode, and deny in __INLINE_CODE_14__ mode. If this argument is not provided, the exception is for all modules.

Examples

Allow only the __INLINE_CODE_15__ and __INLINE_CODE_16__ modules to be loaded, and only by the __INLINE_CODE_17__ module:
__CODE_BLOCK_3__
Prevent all modules from loading the __INLINE_CODE_18__ and __INLINE_CODE_19__ modules:
__CODE_BLOCK_4__

Testing

The 'mocha' module is used for testing. Run either 'whitelist.js' or 'blacklist.js', but not both in the same run. If you are testing this in Cloud9, you can choose the Mocha runner, and give the path to the test file as argument.
Example:

__CODE_BLOCK_5__

This will enable you to debug the code through the test.
Note: The path must be specified relative to your workspace.

);
Prevent all modules from loading the __INLINE_CODE_18__ and __INLINE_CODE_19__ modules:
__CODE_BLOCK_4__

Testing

The 'mocha' module is used for testing. Run either 'whitelist.js' or 'blacklist.js', but not both in the same run. If you are testing this in Cloud9, you can choose the Mocha runner, and give the path to the test file as argument.
Example:

__CODE_BLOCK_5__

This will enable you to debug the code through the test.
Note: The path must be specified relative to your workspace.

, '^sax

What this is

  • A simple tool to control which modules can be loaded and by which modules
  • It gives you peace of mind when using third party modules
  • It eases you of the burden of reviewing and understanding the implementation of other modules

Installation

This is a Node.js module available through the npm registry.

Before installing, download and install Node.js. Node.js 9.4 or higher is required.

Installation is done using the __INLINE_CODE_0__ command:

__CODE_BLOCK_1__

Arguments (__INLINE_CODE_1__)

configuration: __INLINE_CODE_2__
  • __INLINE_CODE_3__: Default. All modules are prohibited from loading any module unless explicitly allowed.
  • __INLINE_CODE_4__: All modules are allowed to load any other module unless explicitly denied.
__CODE_BLOCK_2__

Methods

__INLINE_CODE_5__

This method is used in __INLINE_CODE_6__ mode to indicate which modules will be allowed to load other modules. In __INLINE_CODE_7__ mode it indicates which modules will be prevented from loading other modules.

Arguments

__INLINE_CODE_8__: A regular expression to match the names or paths of modules that we want to allow being required in __INLINE_CODE_9__ mode, and deny in __INLINE_CODE_10__ mode.
__INLINE_CODE_11__: Optional. A regular expression to match the names or paths of modules that we want to allow requiring the __INLINE_CODE_12__ modules in __INLINE_CODE_13__ mode, and deny in __INLINE_CODE_14__ mode. If this argument is not provided, the exception is for all modules.

Examples

Allow only the __INLINE_CODE_15__ and __INLINE_CODE_16__ modules to be loaded, and only by the __INLINE_CODE_17__ module:
__CODE_BLOCK_3__
Prevent all modules from loading the __INLINE_CODE_18__ and __INLINE_CODE_19__ modules:
__CODE_BLOCK_4__

Testing

The 'mocha' module is used for testing. Run either 'whitelist.js' or 'blacklist.js', but not both in the same run. If you are testing this in Cloud9, you can choose the Mocha runner, and give the path to the test file as argument.
Example:

__CODE_BLOCK_5__

This will enable you to debug the code through the test.
Note: The path must be specified relative to your workspace.

);

What this is

  • A simple tool to control which modules can be loaded and by which modules
  • It gives you peace of mind when using third party modules
  • It eases you of the burden of reviewing and understanding the implementation of other modules

Installation

This is a Node.js module available through the npm registry.

Before installing, download and install Node.js. Node.js 9.4 or higher is required.

Installation is done using the __INLINE_CODE_0__ command:

__CODE_BLOCK_1__

Arguments (__INLINE_CODE_1__)

configuration: __INLINE_CODE_2__
  • __INLINE_CODE_3__: Default. All modules are prohibited from loading any module unless explicitly allowed.
  • __INLINE_CODE_4__: All modules are allowed to load any other module unless explicitly denied.
__CODE_BLOCK_2__

Methods

__INLINE_CODE_5__

This method is used in __INLINE_CODE_6__ mode to indicate which modules will be allowed to load other modules. In __INLINE_CODE_7__ mode it indicates which modules will be prevented from loading other modules.

Arguments

__INLINE_CODE_8__: A regular expression to match the names or paths of modules that we want to allow being required in __INLINE_CODE_9__ mode, and deny in __INLINE_CODE_10__ mode.
__INLINE_CODE_11__: Optional. A regular expression to match the names or paths of modules that we want to allow requiring the __INLINE_CODE_12__ modules in __INLINE_CODE_13__ mode, and deny in __INLINE_CODE_14__ mode. If this argument is not provided, the exception is for all modules.

Examples

Allow only the __INLINE_CODE_15__ and __INLINE_CODE_16__ modules to be loaded, and only by the __INLINE_CODE_17__ module:
__CODE_BLOCK_3__
Prevent all modules from loading the __INLINE_CODE_18__ and __INLINE_CODE_19__ modules:
__CODE_BLOCK_4__

Testing

The 'mocha' module is used for testing. Run either 'whitelist.js' or 'blacklist.js', but not both in the same run. If you are testing this in Cloud9, you can choose the Mocha runner, and give the path to the test file as argument.
Example:

__CODE_BLOCK_5__

This will enable you to debug the code through the test.
Note: The path must be specified relative to your workspace.