JSPM

  • Created
  • Published
  • Downloads 42
  • Score
    100M100P100Q73361F
  • License MIT

Completely erases files by making recovery impossible.

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

Logo of the project
Completely erases files by making recovery impossible.

Version Downloads/week License

⚠️ 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 --save

Or the command-line version:

$ npm install secure-rm -g

Secure-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/*.js

Usage

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))
  • method <Number> (optional) :
    • By default, method 0 (Pseudorandom data)
    • You can pick another one, they are described below.
  • callback <Function> :
    • returns err <Error> when finished.

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))
  • 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, --version show CLI version.

Example:

$ secure-rm ./folder/*.js ./garbage ./file.js -m 6 -f

You 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|10  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 State Standard GOST R 50739-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 Royal Canadian Mounted Police TSSIT OPS-II 7 Pass 1: Overwriting with zeroes;
Pass 2: Overwriting with ones;
Pass 3-6: Same as 1-2;
Pass 7: Overwriting with a random data as well as review the writing of this character.
8 Bruce Schneier Algorithm 7 Pass 1: Overwriting with zeros;
Pass 2: Overwriting with ones;
Pass 3-7: Overwriting with random data.
9 Bruce Schneier Algorithm 33 Pass 1-33: Overwriting with random data.
10 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* ...).

TODO

  • Release of 1.0.0 (stable API)
  • Implement more tests
  • TypeScript
  • Support of 64bit files

Developing

Contributions are welcome. Fork this repository and issue a pull request with your changes.

Please add new tests for new functionality, adapt the existing ones if needed, and make sure that npm test succeeds.

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 install

To 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

JavaScript Style Guide

This project uses JavaScript Standard Style. Please respect this convention.

We provide an easy installation for you, just run:

$ npm run style-setup

And 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.