Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
crash-safe-write-file
Advanced tools
Write a file atomically and use fsync to flush its contents.
Node.js file operations, even writeFileSync
, cannot guarantee that the contents of the file were written.
From http://www.daveeddy.com/2013/03/26/synchronous-file-io-in-nodejs/:
fs.writeFileSync
is synchronous in the sense that it blocks the event loop while it executes. It does NOT ask the Kernel to do a synchronous write to the underlying file system.
This is fine for most cases, but if you're trying to write a file that's immune to crashes, you need to get into the fsync
game. This library borrows graciously from the storage methods in nedb
.
npm install crash-safe-write-file --save
const writeFile = require('crash-safe-write-file').writeFile;
writeFile(filename, data, callback);
import {writeFile} from 'crash-safe-write-file';
writeFile(filename, data, callback);
/**
* Fully write or rewrite the datafile, immune to crashes during the write
* operation. Writes to a temporary file like `write-file-atomic`, but flushes
* all buffers using fsync.
*
* Adapted from https://github.com/louischatriot/nedb/blob/master/lib/storage.js.
*
* @param {String} filename The destination file
* @param {String} data The data to write
* @param {Function} callback Optional callback on completion or error
*/
function writeFile(filename, data, callback);
FAQs
Write a file atomically and use fsync to flush contents
The npm package crash-safe-write-file receives a total of 3,526 weekly downloads. As such, crash-safe-write-file popularity was classified as popular.
We found that crash-safe-write-file 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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.