
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
depgraph returns a dependency graph for a javascript module. It resolves ESM, CommonJS and Typescript modules using resolvewithplus.
depgraph is similar to module-deps and uses some of the same dependencies.
A sample graph, tree and dependency-ordered array are seen using example calls below found in the unit tests.
For each graph node, "inarr" references dependent nodes and "outarr" references depedency nodes.
const graph = await depgraph.graph.getfromseedfile('./test/files/root.js')
console.log(JSON.stringify(graph, null, '\t'))
result
{
"depgraph-0.0.6:~/test/files/root.js": {
"content": "...",
"filepath": "./test/files/root.js",
"uid": "depgraph-0.0.6:~/test/files/root.js",
"inarr": [],
"outarr": [{
"refname": "./fileb",
"uid": "depgraph-0.0.6:~/test/files/fileb.js"
},{
"refname": "./filea",
"uid": "depgraph-0.0.6:~/test/files/filea.js"
},{
"refname": "./filec",
"uid": "depgraph-0.0.6:~/test/files/filec/index.js"
},{
"refname": "resolveuid",
"uid": "resolveuid-0.0.2:~/index.js"
},{
"refname": "./dir/filed.js",
"uid": "depgraph-0.0.6:~/test/files/dir/filed.js"
}]
},
"depgraph-0.0.6:~/test/files/fileb.js": {
"content": "...",
"filepath": "./test/files/fileb.js",
"uid": "depgraph-0.0.6:~/test/files/fileb.js",
"inarr": [{
"refname": "./fileb",
"uid": "depgraph-0.0.6:~/test/files/root.js"
},{
"refname": "./fileb",
"uid": "depgraph-0.0.6:~/test/files/filea.js"
}],
"outarr": []
},
"depgraph-0.0.6:~/test/files/filea.js": {
"content": "...",
"filepath": "./test/files/filea.js",
"uid": "depgraph-0.0.6:~/test/files/filea.js",
"inarr": [{
"refname": "./filea",
"uid": "depgraph-0.0.6:~/test/files/root.js"
}],
"outarr": [{
"refname": "./fileb",
"uid": "depgraph-0.0.6:~/test/files/fileb.js"
}]
},
"depgraph-0.0.6:~/test/files/filec/index.js": {
"content": "...",
"filepath": "./test/files/filec/index.js",
"uid": "depgraph-0.0.6:~/test/files/filec/index.js",
"inarr": [{
"refname": "./filec",
"uid": "depgraph-0.0.6:~/test/files/root.js"
},{
"refname": "./../filec",
"uid": "depgraph-0.0.6:~/test/files/dir/filed.js"
}],
"outarr": []
},
"resolveuid-0.0.2:~/index.js": {
"content": "...",
"filepath": "./node_modules/resolveuid/index.js",
"uid": "resolveuid-0.0.2:~/index.js",
"inarr": [{
"refname": "resolveuid",
"uid": "depgraph-0.0.6:~/test/files/root.js"
}],
"outarr": [{
"refname": "./src/resolveuid",
"uid": "resolveuid-0.0.2:~/src/resolveuid.js"
}]
},
"resolveuid-0.0.2:~/src/resolveuid.js": {
"content": "...",
"filepath": "./node_modules/resolveuid/src/resolveuid.js",
"uid": "resolveuid-0.0.2:~/src/resolveuid.js",
"inarr": [{
"refname": "./src/resolveuid",
"uid": "resolveuid-0.0.2:~/index.js"
}],
"outarr": []
},
"depgraph-0.0.6:~/test/files/dir/filed.js": {
"content": "...",
"filepath": "./test/files/dir/filed.js",
"uid": "depgraph-0.0.6:~/test/files/dir/filed.js",
"inarr": [{
"refname": "./dir/filed.js",
"uid": "depgraph-0.0.6:~/test/files/root.js"
}],
"outarr": [{
"refname": "./../filec",
"uid": "depgraph-0.0.6:~/test/files/filec/index.js"
}]
}
}
The graph is used to construct a dependency-ordered array.
const graph = await depgraph.graph.getfromseedfile('./test/files/root.js')
console.log(JSON.stringify(depgraph.graph.getdeparr(graph), null, '\t'))
result
[{
"content": "...",
"filepath": "./test/files/fileb.js",
"uid": "depgraph-0.0.6:~/test/files/fileb.js",
"inarr": [{
"refname": "./fileb",
"uid": "depgraph-0.0.6:~/test/files/root.js"
},{
"refname": "./fileb",
"uid": "depgraph-0.0.6:~/test/files/filea.js"
}],
"outarr": []
},{
"content": "...",
"filepath": "./test/files/filea.js",
"uid": "depgraph-0.0.6:~/test/files/filea.js",
"inarr": [{
"refname": "./filea",
"uid": "depgraph-0.0.6:~/test/files/root.js"
}],
"outarr": [{
"refname": "./fileb",
"uid": "depgraph-0.0.6:~/test/files/fileb.js"
}]
},{
"content": "...",
"filepath": "./test/files/filec/index.js",
"uid": "depgraph-0.0.6:~/test/files/filec/index.js",
"inarr": [{
"refname": "./filec",
"uid": "depgraph-0.0.6:~/test/files/root.js"
},{
"refname": "./../filec",
"uid": "depgraph-0.0.6:~/test/files/dir/filed.js"
}],
"outarr": []
},{
"content": "...",
"filepath": "./node_modules/resolveuid/src/resolveuid.js",
"uid": "resolveuid-0.0.2:~/src/resolveuid.js",
"inarr": [{
"refname": "./src/resolveuid",
"uid": "resolveuid-0.0.2:~/index.js"
}],
"outarr": []
},{
"content": "...",
"filepath": "./node_modules/resolveuid/index.js",
"uid": "resolveuid-0.0.2:~/index.js",
"inarr": [{
"refname": "resolveuid",
"uid": "depgraph-0.0.6:~/test/files/root.js"
}],
"outarr": [{
"refname": "./src/resolveuid",
"uid": "resolveuid-0.0.2:~/src/resolveuid.js"
}]
},{
"content": "...",
"filepath": "./test/files/dir/filed.js",
"uid": "depgraph-0.0.6:~/test/files/dir/filed.js",
"inarr": [{
"refname": "./dir/filed.js",
"uid": "depgraph-0.0.6:~/test/files/root.js"
}],
"outarr": [{
"refname": "./../filec",
"uid": "depgraph-0.0.6:~/test/files/filec/index.js"
}]
},{
"content": "...",
"filepath": "./test/files/root.js",
"uid": "depgraph-0.0.6:~/test/files/root.js",
"inarr": [],
"outarr": [{
"refname": "./fileb",
"uid": "depgraph-0.0.6:~/test/files/fileb.js"
},{
"refname": "./filea",
"uid": "depgraph-0.0.6:~/test/files/filea.js"
},{
"refname": "./filec",
"uid": "depgraph-0.0.6:~/test/files/filec/index.js"
},{
"refname": "resolveuid",
"uid": "resolveuid-0.0.2:~/index.js"
},{
"refname": "./dir/filed.js",
"uid": "depgraph-0.0.6:~/test/files/dir/filed.js"
}]
}]
Trees are generated from the graph usi the archy format. Full tree construction may be prohibited by circular cjs dependencies.
The default tree may render a leaf multiple times, but will render the children once only.
const tree = await depgraph.tree.getfromseedfile('./test/files/root.js')
console.log(archy(tree));
result
depgraph-0.0.6:~/test/files/root.js
├── depgraph-0.0.6:~/test/files/fileb.js
├─┬ depgraph-0.0.6:~/test/files/filea.js
│ └── depgraph-0.0.6:~/test/files/fileb.js
├── depgraph-0.0.6:~/test/files/filec/index.js
├─┬ resolveuid-0.0.2:~/index.js
│ └── resolveuid-0.0.2:~/src/resolveuid.js
└─┬ depgraph-0.0.6:~/test/files/dir/filed.js
└── depgraph-0.0.6:~/test/files/filec/index.js
The 'small' tree renders each leaf once only.
const tree = await depgraph.tree.getfromseedfilesmall('./test/files/root.js')
console.log(archy(tree))
result
depgraph-0.0.6:~/test/files/root.js
├── depgraph-0.0.6:~/test/files/fileb.js
├── depgraph-0.0.6:~/test/files/filea.js
├── depgraph-0.0.6:~/test/files/filec/index.js
├─┬ resolveuid-0.0.2:~/index.js
│ └── resolveuid-0.0.2:~/src/resolveuid.js
└── depgraph-0.0.6:~/test/files/dir/filed.js
When { iscircular: false }
is passed to getdeparr
an error will be thrown when circular dependencies are found. All options are passed directly to the resolver, resolvewithplus, and so it is possible to specify preferred resolutions using options like { isbrowser: true }
and { priority: ['browser', 'import', ':spectype', 'default'] }
FAQs
generate a dependency graph or tree of nodes from a given moduleid
The npm package depgraph receives a total of 7 weekly downloads. As such, depgraph popularity was classified as not popular.
We found that depgraph 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
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.