Research
Recent Trends in Malicious Packages Targeting Discord
The Socket research team breaks down a sampling of malicious packages that download and execute files, among other suspicious behaviors, targeting the popular Discord platform.
find-root
Advanced tools
Package description
The find-root npm package is used to find the root directory of a Node.js project or module. This is typically the location where the 'package.json' file is located. It is useful when you have a deeply nested file structure and need to programmatically find the path to the project root.
Find project root
This feature allows you to find the nearest directory containing a package.json file, which is considered the project's root directory.
const findRoot = require('find-root');
const root = findRoot('/path/to/some/deeply/nested/file');
console.log(root); // prints the path to the nearest directory containing a package.json
The 'pkg-dir' package provides similar functionality to 'find-root' by finding the closest package.json file in the directory tree. It is a more popular package with additional options and a promise-based API.
The 'app-root-path' package is used to determine the root path of the node application. Unlike 'find-root', which looks for the nearest package.json, 'app-root-path' uses a different heuristic that might be more suitable for certain applications.
The 'root-require' package allows you to require modules relative to the root of your Node.js project. It is similar to 'find-root' in that it helps with resolving paths in a project, but it is specifically tailored for requiring modules.
Readme
recursively find the closest package.json
Say you want to check if the directory name of a project matches its module name in package.json:
var path = require('path')
var findRoot = require('find-root')
// from a starting directory, recursively search for the nearest
// directory containing package.json
var root = findRoot('/Users/jden/dev/find-root/tests')
// => '/Users/jden/dev/find-root'
var dirname = path.basename(root)
console.log('is it the same?')
console.log(dirname === require(path.join(root, 'package.json')).name)
findRoot: (startingPath : String) => String
Returns the path for the nearest directory to startingPath
containing
a package.json
file, eg /foo/module
.
Throws an error if no package.json
is found at any level in the
startingPath
.
$ npm install find-root
From package root:
$ npm install
$ npm test
MIT. (c) MMXIII AgileMD http://agilemd.com
FAQs
find the closest package.json
We found that find-root 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
The Socket research team breaks down a sampling of malicious packages that download and execute files, among other suspicious behaviors, targeting the popular Discord platform.
Security News
Socket CEO Feross Aboukhadijeh joins a16z partners to discuss how modern, sophisticated supply chain attacks require AI-driven defenses and explore the challenges and solutions in leveraging AI for threat detection early in the development life cycle.
Security News
NIST's new AI Risk Management Framework aims to enhance the security and reliability of generative AI systems and address the unique challenges of malicious AI exploits.