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.
require-inject
Advanced tools
A simple mock injector compatible needing no instrumentation in the libraries being tested
A simple mock injector compatible needing no instrumentation in the libraries being tested
var requireInject = require('require-inject');
var mymod = requireInject('mymod', {
'fs' => {
stat: function (file,cb) {
switch (file) {
case 'testfile1': return cb(null,{})
case 'testfile2': return cb(new Error('ENOENT'))
}
}
}
})
var mymod = requireInject( module, mocks )
module is the name of the module you want to require.
mocks is an object with keys that are the names of the modules you want *to mock and values of the mock version of the objects.
requireInject makes it so that when module is required, any of its calls to require for modules inclued in mocks will return the mocked version. It takes care to not impact any other uses of module, any calls to require for it will get a version without mocks.
FAQs
A simple mock injector compatible needing no instrumentation in the libraries being tested
The npm package require-inject receives a total of 17,859 weekly downloads. As such, require-inject popularity was classified as popular.
We found that require-inject 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.