
Research
/Security News
Toptal’s GitHub Organization Hijacked: 10 Malicious Packages Published
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
The cmd-shim npm package is designed to create command shims (or symbolic links) on Windows and Unix-like systems for node.js scripts. This allows node.js scripts to be executed as if they were native commands in the user's shell, making it easier to use node.js tools across different platforms without worrying about the underlying differences in how executable scripts are handled.
Creating command shims
This feature allows the creation of a command shim for a node.js script. The code sample demonstrates how to create a shim for a node.js script located at 'path/to/node-script.js' and place the resulting shim at 'path/to/shim'. This makes the script executable as if it were a native command.
const cmdShim = require('cmd-shim');
cmdShim('path/to/node-script.js', 'path/to/shim', function (err) {
if (err) throw err;
});
npx is a package runner tool that comes with npm. It allows you to execute any package from the npm registry without having to install it globally. While npx does not create shims, it provides a similar convenience by allowing direct execution of node.js scripts and commands. Unlike cmd-shim, npx is focused on temporary or one-off execution rather than creating a persistent executable shim.
ShellJS is a portable (Windows/Linux/OS X) implementation of Unix shell commands on top of the Node.js API. While it primarily offers a way to script shell commands within Node.js, it shares the cross-platform scripting goal with cmd-shim. However, ShellJS does not specifically focus on creating command shims but rather on providing a wide range of shell commands within Node.js scripts.
The cmd-shim used in npm to create executable scripts on Windows, since symlinks are not suitable for this purpose there.
On Unix systems, you should use a symbolic link instead.
npm install cmd-shim
Create a cmd shim at to
for the command line program at from
.
e.g.
var cmdShim = require('cmd-shim');
cmdShim(__dirname + '/cli.js', '/usr/bin/command-name').then(() => {
// shims are created!
})
The same as above, but will just continue if the file does not exist.
7.0.0 (2024-08-26)
cmd-shim
now supports node ^18.17.0 || >=20.5.0
FAQs
Used in npm for command line application support
We found that cmd-shim demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 6 open source maintainers 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
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
Research
/Security News
Socket researchers investigate 4 malicious npm and PyPI packages with 56,000+ downloads that install surveillance malware.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.