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.
dependencies-tree
Advanced tools
Collect dependencies from package.json
npm i dependencies-tree
import getDependencies from 'dependencies-tree'
const { tree, flat } = await getDependencies()
export interface DependenciesOptions {
/** @default process.cwd() */
root?: string
/** `dependencies` in package.json under the default root path */
dependencies?: string[]
}
Assume there is a dependency electron-squirrel-startup
in package.json.
{
"dependencies": {
"electron-squirrel-startup": "^1.0.0"
}
}
We get the dependency tree based on the path where package.json is located.
import getDependencies from 'dependencies-tree'
const root = process.cwd()
const { tree } = await getDependencies({ root })
console.log(tree)
// ↓↓↓↓
[
{
name: 'electron-squirrel-startup',
path: {
src: path.join(fixtureRoot, 'node_modules', 'electron-squirrel-startup'),
dest: path.join('node_modules', 'electron-squirrel-startup'),
name: 'electron-squirrel-startup',
},
dependencies: [
{
name: 'debug',
path: {
src: path.join(fixtureRoot, 'node_modules', 'debug'),
dest: path.join('node_modules', 'debug'),
name: 'debug',
},
dependencies: [
{
name: 'ms',
path: {
src: path.join(fixtureRoot, 'node_modules', 'ms'),
dest: path.join('node_modules', 'ms'),
name: 'ms',
},
dependencies: [],
},
],
},
],
},
]
Get the flat dependency tree
import getDependencies from 'dependencies-tree'
const root = process.cwd()
const { flat } = await getDependencies({ root })
console.log(falg)
// ↓↓↓↓
[
{
src: path.join(fixtureRoot, 'node_modules', 'electron-squirrel-startup'),
dest: path.join('node_modules', 'electron-squirrel-startup'),
name: 'electron-squirrel-startup',
},
{
src: path.join(fixtureRoot, 'node_modules', 'debug'),
dest: path.join('node_modules', 'debug'),
name: 'debug',
},
{
src: path.join(fixtureRoot, 'node_modules', 'ms'),
dest: path.join('node_modules', 'ms'),
name: 'ms',
},
]
2.0.0 (2024-09-25)
FAQs
Collect dependencies from package.json
The npm package dependencies-tree receives a total of 60 weekly downloads. As such, dependencies-tree popularity was classified as not popular.
We found that dependencies-tree demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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
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.