Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
export-context
Advanced tools
Get the methods that are not exports as context. these methods becomes possible operations, such as unit testing
A method that has not been export can be run via the context. It will be able to unit test of unexport methods. Further, if necessary of dom can test by creating a document in global. Esnext code is transpile using the babel.
npm install export-context --save-dev
# or if using yarn
yarn
import ExportContext from 'export-context';
// configure option
const options = {
basePath: './',
babel: {
presets: ['latest'],
plugins: ['transform-runtime']
},
dom: true,
html: '<div class="box">example</div>',
vm: {
filename: <string>,
lineOffset: <number>,
columnOffset: <number>,
displayErrors: <boolean>,
timeout: <number>,
breakOnSigint: <boolean>
}
};
const modules = {
'_': 'lodash',
'$': 'jquery'
};
const html = '<span class="comment">example commnet</span>';
const exportContext = new ExportContext;
// add dependent modules setting
exportContext.addModules(modules);
// add html code
exportContext.addHtml(html);
// get context
const ctx = exportContext.run('TARGET/FILE/PATH.js', options);
// ctx has unexported method
// ... some code ...
// clear sandbox dom settings
exportContext.clear()
If the environment variable NODE_ENV
is specified,
it is reflected in the global variable and window object
// set process.env.NODE_ENV = 'test'
global.NODE_ENV // => test
window.NODE_ENV // => test
Set default load file path
Add the module to require at the time of context run.
Add the html to the context that you want to run.
Remove the dom in the global from the execution context.
Run the contents of the passed file path. You can have the option, if necessary. Executed context will be returned. The options are as follows.
If already in the path has been set (using the setfilePath()
), run(options)
method can be performed only in the only option.
Specify the directory to be a base to load the file to be executed. (default: Projectroot).
Code using esnext will run transformer pile in the babel. You can set the options to be passed to the babel. (default: null)
If you run the code using DOM, please be true to this option. To provide the necessary properties to global, you will be able to use the dom api. (default: null)
If you want to set a pre-html adds html. (default: null)
see at below.
FAQs
Get the methods that are not exports as context. these methods becomes possible operations, such as unit testing
The npm package export-context receives a total of 0 weekly downloads. As such, export-context popularity was classified as not popular.
We found that export-context demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.