Commit Graph

210 Commits

Author SHA1 Message Date
asellappen 6b914ec7a4
Add poweron architecture ppc64le to travis build
travis build to support
2020-10-28 11:46:55 +05:30
Vincent Batts 4b50e3822d
Merge pull request #52 from vbatts/vendor
go mod and vendoring
2020-10-27 20:19:30 -04:00
Vincent Batts f78d1a4af1
travis: test from go1.10 - go1.15
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2020-10-27 12:10:43 -04:00
Vincent Batts ec6b1ae20e
vendor the dependencies
There is a discrepancy of behavior of `github.com/urfave/cli` between
using go1.12 and go1.15, when the dependency is not present as vendored
source. Now this builds fine with go1.12

There are users of tar-split as a package. It is the hope that by adding
this vendored source it does not impact them depending on tar-split
itself.

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2020-10-27 12:10:40 -04:00
Vincent Batts a62c8017af
go mod
closer coupling to versions of depencies

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2020-10-27 12:10:36 -04:00
Vincent Batts 620714a4c5
Merge pull request #49 from steveb/asm-compress
Add --compress flag to tar-split asm
2018-10-22 15:49:18 +01:00
Steve Baker dbab9ab4fb Add --compress flag to tar-split asm
The Go implementation of gzip is the only known to produce compressed
layers with the expected digest hashes.

This change allows compressed tar layer files to be produced, which is
useful for exporting layers from non-Go tools.
2018-10-18 12:57:54 +13:00
Vincent Batts 61b49a82bb
Merge pull request #48 from kolyshkin/go111
rebase to go-1.11's archive/tar
2018-09-06 08:34:40 -04:00
Kir Kolyshkin 3a386a2750 travis: update golang versions
Now when golang 1.11 is out, 1.9 and older versions are no longer
supported. More to say, since the archive/tar is from go-1.11, it
uses some features from new Go versions (strings.Builder and sync.Map)
not supported by anything older than Go 1.10.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2018-09-05 17:13:21 -07:00
Kir Kolyshkin a555806af9 README.md: update
The fork of archive/tar is now from go-1.11.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2018-09-05 17:13:18 -07:00
Kir Kolyshkin 9a95e02602 archive/tar: port RawHeader() changes
This is a port of commits adding RawHeader() to go-1.11 archive/tar.

In addition:
* simplify the rawBytes.Write() code in readHeader()
* ignore errors from rawBytes.Write(), as (at least for go-1.11)
  it never returns an error, only panics (if the buffer grew too large)

Also, remove the internal/testenv from tar_tar.go to enable go test.
As working symlink detection is non-trivial on Windows, just skip
the test on that platform.

In addition to `go test`, I did some minimal manual testing, and
it seems this code creates tar-data.json.gz which is identical
to the one made by the old version.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2018-09-05 17:12:53 -07:00
Kir Kolyshkin 73fdb78c36 archive/tar: replace with one from go-1.11
The RawAccounting changes are to be ported on top.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2018-09-05 14:04:10 -07:00
Vincent Batts e489928272
Merge pull request #44 from nolith/sirupsen
rename github.com/Sirupsen/logrus -> github.com/sirupsen/logrus
2018-02-23 09:46:38 -05:00
Alessio Caiazza a9de541771
rename github.com/Sirupsen/logrus -> github.com/sirupsen/logrus
Since version 1.0.0 sirupsen changed his github username to downcase.
2018-02-23 14:42:06 +01:00
Vincent Batts 38ec4ddb06
Merge pull request #42 from cyphar/chunked-padding
tar: asm: store padding in chunks to avoid memory exhaustion
2017-11-07 10:39:49 -05:00
Aleksa Sarai 99430a8454
tar: asm: add an excess padding test case
To ensure we don't have regressions in our padding fix, add a test case
that attempts to crash the test by creating 20GB of random junk padding.

Signed-off-by: Aleksa Sarai <asarai@suse.de>
2017-11-08 02:35:01 +11:00
Aleksa Sarai 3d9db48dbe
tar: asm: store padding in chunks to avoid memory exhaustion
Previously, we would read the entire padding in a given archive into
memory in order to store it in the packer. This would cause memory
exhaustion if a malicious archive was crafted with very large amounts of
padding. Since a given SegmentType is reconstructed losslessly, we can
simply chunk up any padding into large segments to avoid this problem.
Use a reasonable default of 1MiB to avoid changing the tar-split.json of
existing archives that are not malformed.

Fixes: CVE-2017-14992
Signed-off-by: Aleksa Sarai <asarai@suse.de>
2017-11-08 02:34:56 +11:00
Aleksa Sarai b9775006bf
*: move tar_benchmark to cmd/tar-split/
This fixes a new go-vet(1) error which has surfaced in Go HEAD.

  $ go vet ./...
  go build github.com/vbatts/tar-split: no non-test Go files in
  /home/travis/gopath/src/github.com/vbatts/tar-split

Signed-off-by: Aleksa Sarai <asarai@suse.de>
2017-11-08 02:20:30 +11:00
Vincent Batts ed1c08584d Merge pull request #40 from EdwardBetts/spelling
correct spelling mistake
2017-09-01 06:05:25 -04:00
Edward Betts 22999e8f96 correct spelling mistake 2017-09-01 09:45:09 +01:00
Vincent Batts b9127a1393 Merge pull request #38 from vbatts/travis
travis: test more go versions
2017-03-14 11:24:38 -04:00
Vincent Batts c6dd42815a
archive/tar: monotonic clock adjustment
commit 0e3355903d2ebcf5ee9e76096f51ac9a116a9dbb upstream

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2017-03-14 11:04:10 -04:00
Vincent Batts 245403c324
travis: test more go versions
Thanks to @tianon, for pointing to
5e3ef60b0d/lib/travis/build/config.rb (L54-L70)

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2017-03-14 08:38:13 -04:00
Vincent Batts 7560005f21
README: adding a golang report card
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2017-03-13 18:28:54 -04:00
Vincent Batts bd4c5d64c3
main: switch import paths to urfave
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-09-27 02:54:18 +00:00
Vincent Batts d3f1b54304
version: bump to v0.10.1
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-09-26 19:53:52 -04:00
Vincent Batts f28028292a Merge branch 'master' of github.com:vbatts/tar-split 2016-09-26 19:52:55 -04:00
Vincent Batts 416fa5dcfe Merge pull request #36 from dmcgowan/fix-extra-nil-accounting
archive/tar: fix writing too many raw bytes
2016-09-26 18:31:47 -04:00
Derek McGowan 6b59e6942e archive/tar: fix writing too many raw bytes
When an EOF is read, only the part of the header buffer which
was read should be accounted for.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2016-09-26 14:01:48 -07:00
Vincent Batts 7410961e75 tar/asm: failing test for lack of EOF nils
Reported-by: Derek McGowan <derek@mcgstyle.net>
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-09-26 13:39:03 -07:00
Vincent Batts eb3808673d
version: bump to v0.10.0
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-09-23 11:01:58 -04:00
Vincent Batts ae8540dc47 Merge pull request #34 from dmcgowan/fix-panic-issue-33
Fix panic in Next
2016-09-23 09:41:12 -04:00
Derek McGowan e527e70d25 Fix panic in Next
readHeader should never return nil with a tr.err also nil.
To correct this, ensure tr.err never gets reset to nil followed
by a nil return.
2016-09-22 17:38:18 -07:00
Vincent Batts 6810cedb21 benchmark: add a comparison of 'archive/tar'
Since this project has forked logic of upstream 'archive/tar', this does
a brief comparison including the RawBytes usage.

```bash
$ go test -run="XXX" -bench=.
testing: warning: no tests to run
BenchmarkUpstreamTar-4                      2000            700809 ns/op
BenchmarkOurTarNoAccounting-4               2000            692055 ns/op
BenchmarkOurTarYesAccounting-4              2000            723184 ns/op
PASS
ok      vb/tar-split    4.461s
```

From this, the difference is negligible.

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-07-26 09:50:08 -04:00
Vincent Batts 28bc4c32f9 Merge pull request #32 from vbatts/fix-travis
travis: update golang versions
2016-06-26 15:00:37 -04:00
Vincent Batts beaeceb06f travis: update golang versions
This is not saying that tar-split no longer works on go1.3 or go1.4, but
rather that the headache of `go vet` having a version dependent ability
to install it, makes it a headache in travis.

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-06-26 14:56:04 -04:00
Vincent Batts 54e3a92a60 Merge branch 'master' of github.com:vbatts/tar-split 2016-06-26 14:43:38 -04:00
Vincent Batts 354fd6cf34 cmd: add a `disasm --no-stdout` flag
Since sometimes you just need to > /dev/null

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-06-26 10:15:12 -04:00
Vincent Batts 226f7c7490 README: update `archive/tar` version reference
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-03-30 16:38:51 -04:00
Vincent Batts e2a62d6b0d README.md: fix thumbnail
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-02-29 11:40:38 -05:00
Vincent Batts 24fe0a94fe version: bump to v0.9.13
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-02-15 09:44:28 -05:00
Vincent Batts 862ccd05bc Merge pull request #31 from vbatts/tar-go1.6
Tar go1.6
2016-02-15 09:41:56 -05:00
Vincent Batts c32966b9e8 archive/tar: go1.3 and go1.4 compatibility
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-02-15 09:38:46 -05:00
Joe Tsai 10db8408f6 archive/tar: document how Reader.Read handles header-only files
Commit dd5e14a7511465d20c6e95bf54c9b8f999abbbf6 ensured that no data
could be read for header-only files regardless of what the Header.Size
said. We should document this fact in Reader.Read.

Updates #13647

Change-Id: I4df9a2892bc66b49e0279693d08454bf696cfa31
Reviewed-on: https://go-review.googlesource.com/17913
Reviewed-by: Russ Cox <rsc@golang.org>
2016-02-03 07:01:09 -05:00
Joe Tsai 962540fec3 archive/tar: spell license correctly in example
Change-Id: Ice85d161f026a991953bd63ecc6ec80f8d06dfbd
Reviewed-on: https://go-review.googlesource.com/17901
Run-TryBot: Joe Tsai <joetsai@digital-static.net>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-03 07:01:09 -05:00
Joe Tsai a04b4ddba4 archive/tar: properly parse GNU base-256 encoding
Motivation:
* Previous implementation did not detect integer overflow when
parsing a base-256 encoded field.
* Previous implementation did not treat the integer as a two's
complement value as specified by GNU.

The relevant GNU specification says:
<<<
GNU format uses two's-complement base-256 notation to store values
that do not fit into standard ustar range.
>>>

Fixes #12435

Change-Id: I4639bcffac8d12e1cb040b76bd05c9d7bc6c23a8
Reviewed-on: https://go-review.googlesource.com/17424
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-03 07:01:09 -05:00
Joe Tsai ce5aac17f9 archive/tar: properly format GNU base-256 encoding
Motivation:
* Previous implementation silently failed when an integer overflow
occurred. Now, we report an ErrFieldTooLong.
* Previous implementation did not encode in two's complement format and was
unable to encode negative numbers.

The relevant GNU specification says:
<<<
GNU format uses two's-complement base-256 notation to store values
that do not fit into standard ustar range.
>>>

Fixes #12436

Change-Id: I09c20602eabf8ae3a7e0db35b79440a64bfaf807
Reviewed-on: https://go-review.googlesource.com/17425
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-03 06:58:30 -05:00
Joe Tsai be9ac88117 archive/tar: convert Reader.Next to be loop based
Motivation for change:
* Recursive logic is hard to follow, since it tends to apply
things in reverse. On the other hand, the tar formats tend to
describe meta headers as affecting the next entry.
* Recursion also applies changes in the wrong order. Two test
files are attached that use multiple headers. The previous Go
behavior differs from what GNU and BSD tar do.

Change-Id: Ic1557256fc1363c5cb26570e5d0b9f65a9e57341
Reviewed-on: https://go-review.googlesource.com/14624
Run-TryBot: Joe Tsai <joetsai@digital-static.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-03 06:58:30 -05:00
Joe Tsai 64935a5f0f archive/tar: move parse/format methods to standalone receiver
Motivations for this change:
* It allows these functions to be used outside of Reader/Writer.
* It allows these functions to be more easily unit tested.

Change-Id: Iebe2b70bdb8744371c9ffa87c24316cbbf025b59
Reviewed-on: https://go-review.googlesource.com/15113
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Joe Tsai <joetsai@digital-static.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-02 14:32:27 -05:00
Joe Tsai b598ba3ee7 archive/tar: fix issues with readGNUSparseMap1x0
Motivations:
* Use of strconv.ParseInt does not properly treat integers as 64bit,
preventing this function from working properly on 32bit machines.
* Use of io.ReadFull does not properly detect truncated streams
when the file suddenly ends on a block boundary.
* The function blindly trusts user input for numEntries and allocates
memory accordingly.
* The function does not validate that numEntries is not negative,
allowing a malicious sparse file to cause a panic during make.

In general, this function was overly complicated for what it was
accomplishing and it was hard to reason that it was free from
bounds errors. Instead, it has been rewritten and relies on
bytes.Buffer.ReadString to do the main work. So long as invariants
about the number of '\n' in the buffer are maintained, it is much
easier to see why this approach is correct.

Change-Id: Ibb12c4126c26e0ea460ea063cd17af68e3cf609e
Reviewed-on: https://go-review.googlesource.com/15174
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-02 14:17:35 -05:00