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.
build-file-tree-from-object
Advanced tools
Asynchronously build directories and write files from an object
Asynchronously build directories and write files from an object.
npm install build-file-tree-from-object
const build = require('build-file-tree-from-object')
const tree = {
'some.file': 'string value means:\n file content\n',
'file.dat' : Buffer.from('Buffer value also means:\n file content\n'),
'some_dir' : { // Object value means directory.
'sub.file': 'another file\ninside the new dir\n',
'dirdir': {
'itty.bitty.file': 'itty bitty'
},
'dir2': { // can have as many directories in a directory as you want...
// even if there's no keys inside `dir2` will still be created.
},
'empty.file': '', // use empty string to get an empty file.
},
}
// build the tree starting at `process.cwd()`:
build({
tree,
done: error => { // callback required.
// called when all async processes are completed. tree built.
// called when mkdir() errors (other than 'EEXIST').
// called with error from writeFile() or invalid value
// when there's no error callback (which quits the processing).
},
})
// specify where to build the tree by providing `root`:
build({
tree,
root: 'some/dir', // optional; defaults to process.cwd()
done: error => { }
})
// if you want writeFile() errors and invalid `value` errors
// reported without quitting the processing,
// then provide an `error` callback:
build({
tree,
error: error => { // optional.
// receives:
// 1. invalid value errors
// 2. writeFile() errors
// Does NOT receive mkdir() errors. those go to done().
},
done: error => { }
})
// NOTE: errors from mkdir() always cause it to quit processing.
FAQs
Asynchronously build directories and write files from an object
We found that build-file-tree-from-object 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
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.