Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
The commondir npm package is a simple utility that helps you find the common parent directory among an array of file paths. This can be particularly useful in file system operations where you need to determine the shared base directory for a group of files.
Finding common directory
This feature allows you to find the common parent directory from an array of file paths. In the provided code, the common directory for '/usr/lib/node_modules' and '/usr/lib/node' is calculated, which results in '/usr/lib'.
const commondir = require('commondir');
const paths = ['/usr/lib/node_modules', '/usr/lib/node'];
const commonPath = commondir(paths);
console.log(commonPath); // Outputs: '/usr/lib'
path-common is another npm package that provides functionality to find the common path among multiple paths. It is similar to commondir but might offer different methods or additional features for handling edge cases or specific path operations.
find-root is a package that helps in finding the root directory of a project by traversing up the current directory until a specific marker file (like 'package.json') is found. While it serves a different purpose, it is related in terms of navigating and determining directory structures, which can be somewhat similar to what commondir does.
compute the closest common parent directory among an array of directories
var commondir = require('commondir');
var dir = commondir(process.argv.slice(2))
console.log(dir);
output:
$ node dir.js /x/y/z /x/y /x/y/w/q
/x/y
$ node ../baz ../../foo/quux ./bizzy
/foo
var commondir = require('commondir');
Compute the closest common parent directory for an array absolutePaths
.
Compute the closest common parent directory for an array relativePaths
which
will be resolved for each dir
in relativePaths
according to:
path.resolve(basedir, dir)
.
With npm do:
npm install commondir
MIT
FAQs
compute the closest common parent for file paths
The npm package commondir receives a total of 17,409,261 weekly downloads. As such, commondir popularity was classified as popular.
We found that commondir 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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.