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...
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 -gGetting 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 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 | US Department of Defense DoD 5220.22-M (E) | 3 | Pass 1: Overwriting with zeroes as well as checking the writing; Pass 2: Overwriting with ones and checking the writing; Pass 3: Overwriting with random data as well as verifying the writing. |
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 installYou are ready to develop.
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.