Minimal pure-ruby support for POSIX tar(1) archives.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
docs Switching from Ruby+GPL to Ruby+2BSD. Dec 22, 2014
lib 0.6.1: Restore exception blocks for great justice Feb 8, 2017
support/hoe 0.6.1: Restore exception blocks for great justice Feb 8, 2017
test 0.6.1: Restore exception blocks for great justice Feb 8, 2017
.autotest Modernize the minitar codebase. Dec 21, 2014
.coveralls.yml Modernize the minitar codebase. Dec 21, 2014
.gemtest Modernize the minitar codebase. Dec 21, 2014
.gitignore Resolve relative path vulnerability Feb 7, 2017
.hoerc Resolve relative path vulnerability Feb 7, 2017
.pullreview.yml Modernize the minitar codebase. Dec 21, 2014
.rubocop.yml Clean up code with Rubocop Feb 7, 2017
.simplecov-prelude.rb Clean up the test coverage calls Nov 4, 2016
.travis.yml Resolve relative path vulnerability Feb 7, 2017
Code-of-Conduct.md Fix the hoerc and gitignore Nov 4, 2016
Contributing.md Fix an off-by-1 error in split_name Feb 7, 2017
Gemfile Prepare release 0.6 Feb 7, 2017
History.md 0.6.1: Restore exception blocks for great justice Feb 8, 2017
Licence.md Resolve relative path vulnerability Feb 7, 2017
Manifest.txt No unnecessary strings on POSIX header creation Nov 8, 2016
README.rdoc Fix the README for email justice. Feb 8, 2017
Rakefile Add post-install message about minitar executable Feb 7, 2017
appveyor.yml Tweak the Gemfile for version testing Nov 4, 2016
archive-tar-minitar.gemspec 0.6.1: Restore exception blocks for great justice Feb 8, 2017
minitar.gemspec 0.6.1: Restore exception blocks for great justice Feb 8, 2017

README.rdoc

minitar

home

github.com/halostatue/minitar/

code

github.com/halostatue/minitar/

bugs

github.com/halostatue/minitar/issues

rdoc

rdoc.info/gems/minitar/

cli

github.com/halostatue/minitar-cli

travis

appveyor

coveralls

Coverage
Status

Description

The minitar library is a pure-Ruby library that provides the ability to deal with POSIX tar(1) archive files.

This is release 0.6, providing a number of bug fixes including a directory traversal vulnerability, CVE-2016-10173. This release starts the migration and modernization of the code:

  • the licence has been changed to match the modern Ruby licensing scheme (Ruby and Simplified BSD instead of Ruby and GNU GPL);

  • the minitar command-line program has been separated into the minitar-cli gem; and

  • the archive-tar-minitar gem now points to the minitar and minitar-cli gems and discourages its installation.

Some of these changes may break existing programs that depend on the internal structure of the minitar library, but every effort has been made to ensure compatibility; inasmuch as is possible, this compatibility will be maintained through the release of minitar 1.0 (which will have strong breaking changes).

minitar (previously called Archive::Tar::Minitar) is based heavily on code originally written by Mauricio Julio Fernández Pradier for the rpa-base project.

Synopsis

Using minitar is easy. The simplest case is:

require 'minitar'

# Packs everything that matches Find.find('tests').
# test.tar will automatically be closed by Minitar.pack.
Minitar.pack('tests', File.open('test.tar', 'wb'))

# Unpacks 'test.tar' to 'x', creating 'x' if necessary.
Minitar.unpack('test.tar', 'x')

A gzipped tar can be written with:

require 'zlib'
# test.tgz will be closed automatically.
Minitar.pack('tests', Zlib::GzipWriter.new(File.open('test.tgz', 'wb'))

# test.tgz will be closed automatically.
Minitar.unpack(Zlib::GzipReader.new(File.open('test.tgz', 'rb')), 'x')

As the case above shows, one need not write to a file. However, it will sometimes require that one dive a little deeper into the API, as in the case of StringIO objects. Note that I'm not providing a block with Minitar::Output, as Minitar::Output#close automatically closes both the Output object and the wrapped data stream object.

begin
  sgz = Zlib::GzipWriter.new(StringIO.new(String.new))
  tar = Output.new(sgz)
  Find.find('tests') do |entry|
    Minitar.pack_file(entry, tar)
  end
ensure
    # Closes both tar and sgz.
  tar.close
end

minitar Semantic Versioning

The minitar library uses a Semantic Versioning scheme with one change:

  • When PATCH is zero (0), it will be omitted from version references.