Package Exports
- secure-rm
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (secure-rm) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Completely erases files by making recovery impossible.
⚠️ WARNING ⚠️ THIS TOOL IS STILL IN DEVELOPEMENT, USE IT AT YOUR OWN RISKS! But it will be ready soon...
Choose one of the multiple methods provided (8 to date), it's up to you!
Install
You can use this package in two different ways, the npm module version:
$ npm install secure-rm --saveOr the command-line version:
$ npm install secure-rm -gSecure-rm will retry 3 times if an error occur to ensure the task succeeded.
Getting started
If you want your application to delete specific files with a pass of cryptographically strong pseudo-random data, use this code snippet:
const rm = require('secure-rm')
rm('./folder/*.js', (err) => {
if (err) throw err
console.log('Success!')
})If you want to delete files on the fly, just use the command line tool:
$ secure-rm ./folder/*.jsUsage
npm module
rm(path[, method], callback)
path<String>:- an absolute path (e.g.
D:\data,/d/data) - a relative path (e.g.
./data/file.js,../../data) - a glob pattern (e.g.
./*.js,./**/*,@(pattern|pat*|pat?erN))
- an absolute path (e.g.
method<String> (optional):- By default, method 0 (Pseudorandom data)
- You can pick another one, they are described below.
callback<Function>- returns
err<Error> when finished.
- returns
Example:
rm('./data/file.js', '7' (err) => {
if (err) throw err
console.log('Success!')
})Events
When running, secure-rm emits events to let you know the progression of the deletion.
You can indeed intercept error and ending events for each file.
rm.event.on('start', (file) => console.log('Starting ' + file))
rm.event.on('unlink', (file) => console.log('Unlinking ' + file))
rm.event.on('done', (file) => console.log('Done ' + file))
rm.event.on('info', (file, info) => console.log('Info ' + info + file))
rm.event.on('warn', (file, err) => console.log('Warning ' + err + file))
rm.event.on('error', (file, err) => console.log('Error ' + err + file))Command line tool
$ secure-rm <PATHS> [OPTIONS]PATHS:- one or multiple paths (e.g.
D:\data /d/data ./data/file.js ../../data) - supports glob patterns (e.g.
./*.js ./**/* @(pattern|pat*|pat?erN))
- one or multiple paths (e.g.
OPTIONS(flags):-f, --force: avoid checks if you want to use it in a shell or bash file;-h, --help: show CLI help, see below;-m, --method: numerical ID of the method, default is 0. See them detailed below;-t, --table: show the methods table. See them detailed below;-v, --versionshow CLI version.
Example:
$ secure-rm ./folder/*.js ./garbage ./file.js -m 6 -fYou can invoke the built-in help with secure-rm -h:
CLI help:
USAGE
$ secure-rm PATH
OPTIONS
-f, --force avoid checks
-h, --help show CLI help
-m, --method=0|1|2|3|4|5|6|7|8|9 select the erasure method
-t, --table show the methods table
-v, --version show CLI version
DESCRIPTION
Completely erases files by making recovery impossible.
For extra documentation, go to https://www.npmjs.com/package/secure-rm
Methods
| ID | Name | Passes | Description |
|---|---|---|---|
| 0 | Pseudorandom data | 1 | Your data is overwritten with cryptographically strong pseudo-random data. (The data is indistinguishable from random noise.) |
| 1 | Pseudorandom byte | 1 | Overwriting with a random byte. |
| 2 | Zeroes | 1 | Overwriting with zeroes. |
| 3 | Ones | 1 | Overwriting with ones. |
| 4 | Russian GOST P50739-95 | 2 | Pass 1: Overwriting with zeroes; Pass 2: Overwriting with random data. |
| 5 | British HMG Infosec Standard 5 | 3 | Pass 1: Overwriting with zeroes; Pass 2: Overwriting with ones; Pass 3: Overwriting with random data as well as verifying the writing of this data. |
| 6 | US Army AR380-19 | 3 | Pass 1: Overwriting with random data; Pass 2: Overwriting with a random byte; Pass 3: Overwriting with the complement of the 2nd pass, and verifying the writing. |
| 7 | Bruce Schneier Algorithm | 7 | Pass 1: Overwriting with zeros; Pass 2: Overwriting with ones; Pass 3-7: Overwriting with random data. |
| 8 | Bruce Schneier Algorithm | 33 | Pass 1-33: Overwriting with random data. |
| 9 | Peter Gutmann Algorithm | 35 | Pass 1-4: Overwriting with random data; Pass 5: Overwriting with 0x55; Pass 6: Overwriting with 0xAA; Pass 7-9: Overwriting with 0x92 0x49 0x24, then cycling through the bytes; Pass 10-25: Overwriting with 0x00, incremented by 1 at each pass, until 0xFF; Pass 26-28: Same as 7-9; Pass 29-31: Overwriting with 0x6D 0xB6 0xDB, then cycling through the bytes; Pass 32-35: Overwriting with random data. |
Troubleshooting / Common issues
"WARN Too many open files, cannot ...:"
Don't worry, you've just submited too much file for Node. The tool will retry 3 times to ensure the task succeeded. While you don't get an error, the tool can handle this issue.
If you really need to delete millions of file in one time, split the task (e.g. ./your_folder/a* then ./your_folder/b* ...).
Developing
Prerequisites
You need to have Git and npm installed on your system.
Setting up Dev
You'll need to clone the repository and install the required packages. Just execute these commands:
git clone https://github.com/oganexon/secure-rm.git
cd ./secure-rm/
npm installTo invoke the command line tool, run:
npm start -- [ARGS]Versioning
We use SemVer for versioning. For the versions available, see the link to tags on this repository.
Tests
Soon
Style guide
This project uses JavaScript Standard Style. Please respect this convention.
We provide an easy installation for you, just run:
$ npm run style-setupAnd then npm run style each time you want to check style.
Or install a plugin for your favorite editor and ignore the recommandations above.
Licensing
This project is under MIT License.