
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
detectionizr
Advanced tools
Detect npm modules and system libraries with the same ease as Modernizr
Detect npm modules and system libraries with the same ease as Modernizr. Never has feature detection in Node.js been so easy!
Install the module with: npm install detectionizr
The one liner:
var d = require('detectionizr').detect(['html-doc', 'html-md']) // that's it!
Now you could do this:
d['html-doc'] ? // is html-doc available?
d['html-doc'].parse(markdown) : // then use it
d['html-md'] ? // if not, is html-md available?
d['html-md'].md(markdown) : // then use it
console.error("No markdown support") // both d['html-doc'] and d['html-md'] are false
var detectionizr = require('detectionizr');
// be sure to attach event handler before you use detect
test.on("detect", function(name, exist) {
if(name === "ls" && test.ls)
console.log("We can use ls on this computer!");
});
// call detect with an array of commands you want to test for
test.detect(["imagemagick", "ls", "punycode"]);
if(test.punycode)
console.log("We can use test.punycode");
if(test.imagemagick)
console.log("We can use test.imagemagick");
I use command, system library and nodejs module interchangeably in this text.
NOT TESTED ON WINDOWS
detectionizr has 4 methods:
detectionizr uses child_process
from native nodejs modules and also checks in the same manner as it will test your library dependecies. That is why, detectionizr will always have a reference to child_process
.
detectionizr will first try and require
the commands. If that fails, it will search for the command as a process with: command -v [command name]
, which
and whereis
and look for a return value. If you experience false positives, please file a bug in the issue tracker. The command command
should be available on all POSIX compliant systems (OS X, Linux, Unix ect.). which
and whereis
should be able to find libraries like g++ ect.
var test = require("detectionizr");
function PackageManager() {
this.available = [];
}
PackageManager.prototype.recieve = function(name, exist) {
if(exist) this.available.push(name)
}
var pm = new PackageManager();
test.on("detect", pm.recieve, pm);
test.on("finally", function() {
console.dir(pm); // { available: [ 'imagemagick', 'rdjpgcom' ] }
console.dir(test); /* { child_process:
{ fork: [Function],
_forkChild: [Function],
exec: [Function],
execFile: [Function],
spawn: [Function] },
require: [Function: r],
detect: [Function],
on: [Function],
overwrite: [Function],
rdjpgcom: true, <- command line libraries can not be referenced
imagemagick: <- but nodejs modules are referenced
{ identify: { [Function] path: 'identify' },
readMetadata: [Function],
convert: { [Function] path: 'convert' },
resize: [Function],
crop: [Function],
resizeArgs: [Function] },
imgcheck: false }*/
});
test.detect(["rdjpgcom", "imagemagick", "imgcheck"]);
// Instead of
var mongodb;
try {
mongodb = require( 'mongodb' );
}
catch( e ) {
if ( e.code === 'MODULE_NOT_FOUND' ) {
// The module hasn't been found
}
}
// write
if( !require('detectionizr').detect(['mongodb']).mongodb) )
// The module hasn't been found
// or
var mongodb = require('detectionizr').detect(['mongodb'].mongodb;
if(!mongodb)
// The module hasn't been found
// if you need to do something with mongodb later
delete
http://nodejs.org/docs/latest/api/globals.html#globals_require_cacheIn lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Test your code using grunt.
NOTE - If you symlink detectionizr into a another folder, e.g. npm link [../path/to/detectionizr]
, detectionizr will not be able to find modules in that folder's node_modules directory. This is because nodejs require function only looks in the symlinked folder and not in the folder you are working in. See issue #4757.
whereis
as a test program. This was what the 0.1.4 release was suppose to do. Sorry..detect
now return a reference to detectionizr. Enabling the one liner.Copyright (c) 2013 dotnetCarpenter Licensed under the WTFPL license.
FAQs
Detect npm modules and system libraries with the same ease as Modernizr
The npm package detectionizr receives a total of 38 weekly downloads. As such, detectionizr popularity was classified as not popular.
We found that detectionizr 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
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.