1.1.0 • Published 8 years ago

node-shred v1.1.0

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

node-shred

Travis branch npm npm

node-shred is a thin wrapper around the shred shell utility.

Usage

const Shred = require('node-shred');
var shred   = Shred({ files : [ '/tmp/foo', '/tmp/bar' ]});

shred
  .on('data', function(data) {
    // Only output from `help` and `version` should appear here. You likely
    // won't need this.
  }
  .on('end', function(success) {
    // `success` will be `true` if shredding was successful, and `false`
    // otherwise.
  })
  .on('error', function(err) {
    // `err` will contain the error message. See the note below regarding
    // `verbose`.
  });

Options

node-shred exposes almost exactly the same options as shred itself:

ParameterTypeDescription
forceBooleanChange permissions to allow writing if necessary
iterationsNumberOverwrite N times instead of the default (3)
randomSourceStringGet random bytes from FILE
sizeString or NumberShred this many bytes (suffixes like K, M, G, accepted)
removeBooleanTruncate and remove files after overwriting
verboseBooleanShow progress. (NB: progress information will be written to stderr rather than stdout, and thus must be read from the .on('err') event rather than .on(data). While perhaps counterintuitive, this behavior mirrors that of shred itself.
exactBooleanDo not round file sizes up to the next full block; this is the default for non-regular files
zeroBooleanAdd a final overwrite with zeros to hide shredding
filesArray or StringThe file or files to shred
fileArray or String(Alias for files)
helpBooleanDisplay shred help and exit
versionBooleanOutput version information and exit
shredPathStringThe path to shred on your system. (Defaults to /usr/bin/shred.)

Notes

  • shred must be installed on your system for this wrapper to work.

  • Defenses against command-injection attacks have been put in place, except with regards to the shredPath parameter, which cannot be defended. Regardless, it is unwise to allow users to set initialization parameter values.

  • The unit-tests only assert that the expected options are being sent to shred. They do not assert that shred behaves as expected. While it is probably reasonable to assume that it does, be aware that this assumption is being made.

  • Be certain to read man shred, and to understand the security implications of using shred on modern filesystems.

    1: https://www.owasp.org/index.php/Command_Injection