Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Simple fs mock with posix and windows file system styles.
Unfortunately I don't have any more time to maintain this repository :-(
Don't you want to save me and this project by taking over it?
$ npm install fs-mock
This module does not change original fs module in any way.
If you want to pass this module into other module, you will have to use for example rewire package.
var FS = require('fs-mock');
var fs = new FS({
'var': {}, // empty directory
'var/www/index.php': '', // empty file in /var/www, so directory var is now not empty
'home/david/documents/school/projects': {},
'home': {
'david': {},
'john': {
'password.txt': 'my super password' // file
}
}
});
var myPassword = fs.readFileSync('/home/john/password.txt', {encoding: 'utf8'}); // my super password
If you write some path like this: home/david/documents/school/projects
, it will be automatically expanded and all its
parent directories will be also added to mocked file system.
var fs = new FS({
'Users': {
'David': {
'password.txt': 'my super password'
}
}
}, {
windows: true
});
This will change delimiter from /
to \
and add root directory to c:
.
new FS({ ... }, {
windows: true,
drives: ['c:', 'd:', 'z:']
});
new FS({ ... }, {
windows: true,
drives: ['c:', 'd:', 'z:'],
root: 'z:'
});
Now every path will be saved into z:
drive.
If you want to save paths to custom drives, you need to disable auto saving into options.root
.
new FS({
'c:': {
'Users': {}
},
'x:': {
'xampp': {
'htdocs': {}
}
}
}, {
windows: true,
root: false
});
I haven't got any machine with Windows so all methods (like chmod) works just like in Unix systems. Please let me know if you want to improve this and how.
There are also all *Sync methods.
Calling unsupported methods will throw an exception.
fs.rename()
: yesfs.ftruncate()
: yesfs.truncate()
: yesfs.chown()
: yesfs.fchown()
: yesfs.lchown()
: yesfs.chmod()
: yesfs.fchmod()
: yesfs.lchmod()
: yesfs.stat()
: yesfs.lstat()
: yesfs.fstat()
: yesfs.link()
: yesfs.symlink()
: yes (type argument is ignored)fs.readlink()
: yesfs.realpath()
: yesfs.unlink()
: yesfs.rmdir()
: yesfs.mkdir()
: yesfs.readdir()
: yesfs.close()
: yesfs.open()
: yesfs.utimes()
: yesfs.futimes()
: yesfs.write()
: yesfs.read()
: yesfs.readFile()
: yesfs.writeFile()
: yesfs.appendFile()
: yesfs.watchFile()
: no (use fs.watch())fs.unwatchFile()
: no (use fs.watch())fs.watch()
: yes (persistent option is ignored)fs.exists()
: yesfs.createReadStream()
: yesfs.createWriteStream()
: yesdev
: noino
: nomode
: yesnlink
: nouid
: yesgid
: yesrdev
: nosize
: yesblksize
: yesblocks
: yesatime
: yesmtime
: yesctime
: yesisFile()
: yesisDirectory()
: yesisBlockDevice()
: noisCharacterDevice()
: noisSymbolicLink()
: yesisFIFO()
: noisSocket()
: no$ npm test
1.2.0 - 1.2.1
1.1.3
1.1.2
1.1.1
fd
in options1.1.0
1.0.1
1.0.0
FAQs
[ABANDONED] Simple fs mock with posix and windows file system styles
We found that fs-mock 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
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.