Bug#997847: golang-github-hashicorp-go-slug: autopkgtest regression: testdata/archive-dir: no such file or directory

2022-03-21 Thread Nick Rosbrook
Package: golang-github-hashicorp-go-slug
Version: 0.7.0-1
Followup-For: Bug #997847
User: ubuntu-de...@lists.ubuntu.com
Usertags: origin-ubuntu jammy ubuntu-patch
Control: tags -1 patch

Dear Maintainer,

In Ubuntu, the attached patch was applied to fix autopkgtest
regressions:

  * debian/patches/disable-strange-tests.patch: Refresh the patch to include
new tests that try to access testdata/archive-dir. This fixes an
autopkgtest failure (LP: #1965429).

Thanks,
Nick
diff -Nru 
golang-github-hashicorp-go-slug-0.7.0/debian/patches/disable-strange-tests.patch
 
golang-github-hashicorp-go-slug-0.7.0/debian/patches/disable-strange-tests.patch
--- 
golang-github-hashicorp-go-slug-0.7.0/debian/patches/disable-strange-tests.patch
2021-10-05 14:31:50.0 -0400
+++ 
golang-github-hashicorp-go-slug-0.7.0/debian/patches/disable-strange-tests.patch
2022-03-17 14:36:15.0 -0400
@@ -1,11 +1,20 @@
 Description: some tests require files in paths that are not compatible with 
Debian packaging
  in order to make life easier, these tests are disabled
 Author: Thorsten Alteholz 
-Index: golang-github-hashicorp-go-slug-0.7.0/slug_test.go
-===
 golang-github-hashicorp-go-slug-0.7.0.orig/slug_test.go2021-10-06 
06:10:32.879315260 +
-+++ golang-github-hashicorp-go-slug-0.7.0/slug_test.go 2021-10-06 
06:13:39.728065809 +
-@@ -14,231 +14,231 @@
+--- a/slug_test.go
 b/slug_test.go
+@@ -2,10 +2,8 @@
+ 
+ import (
+   "archive/tar"
+-  "bytes"
+   "compress/gzip"
+   "errors"
+-  "io"
+   "io/ioutil"
+   "os"
+   "path/filepath"
+@@ -14,338 +12,338 @@
"testing"
  )
  
@@ -234,6 +243,113 @@
 -  t.Fatalf("\nexpect:\n%#v\n\nactual:\n%#v", expect, meta)
 -  }
 -}
+-
+-func TestPackWithoutIgnoring(t *testing.T) {
+-  slug := bytes.NewBuffer(nil)
+-
+-  // By default NewPacker() creates a Packer that does not use
+-  // .terraformignore or dereference symlinks.
+-  p, err := NewPacker()
+-  if err != nil {
+-  t.Fatalf("err: %v", err)
+-  }
+-
+-  meta, err := p.Pack("testdata/archive-dir", slug)
+-  if err != nil {
+-  t.Fatalf("err: %v", err)
+-  }
+-
+-  gzipR, err := gzip.NewReader(slug)
+-  if err != nil {
+-  t.Fatalf("err: %v", err)
+-  }
+-
+-  tarR := tar.NewReader(gzipR)
+-  var (
+-  fileList []string
+-  slugSize int64
+-  )
+-
+-  for {
+-  hdr, err := tarR.Next()
+-  if err == io.EOF {
+-  break
+-  }
+-  if err != nil {
+-  t.Fatalf("err: %v", err)
+-  }
+-
+-  fileList = append(fileList, hdr.Name)
+-  if hdr.Typeflag == tar.TypeReg || hdr.Typeflag == tar.TypeRegA {
+-  slugSize += hdr.Size
+-  }
+-  }
+-
+-  // baz.txt would normally be ignored, but should not be
+-  var bazFound bool
+-  for _, file := range fileList {
+-  if file == "baz.txt" {
+-  bazFound = true
+-  }
+-  }
+-  if !bazFound {
+-  t.Fatal("expected file baz.txt to be present, but not found")
+-  }
+-
+-  // .terraform/file.txt would normally be ignored, but should not be
+-  var dotTerraformFileFound bool
+-  for _, file := range fileList {
+-  if file == ".terraform/file.txt" {
+-  dotTerraformFileFound = true
+-  }
+-  }
+-  if !dotTerraformFileFound {
+-  t.Fatal("expected file .terraform/file.txt to be present, but 
not found")
+-  }
+-
+-  // Check the metadata
+-  expect := {
+-  Files: fileList,
+-  Size:  slugSize,
+-  }
+-  if !reflect.DeepEqual(meta, expect) {
+-  t.Fatalf("\nexpect:\n%#v\n\nactual:\n%#v", expect, meta)
+-  }
+-}
+-
+-func TestUnpack(t *testing.T) {
+-  // First create the slug file so we can try to unpack it.
+-  slug := bytes.NewBuffer(nil)
+-
+-  if _, err := Pack("testdata/archive-dir", slug, true); err != nil {
+-  t.Fatalf("err: %v", err)
+-  }
+-
+-  // Create a dir to unpack into.
+-  dst, err := ioutil.TempDir("", "slug")
+-  if err != nil {
+-  t.Fatalf("err: %v", err)
+-  }
+-  defer os.RemoveAll(dst)
+-
+-  // Now try unpacking it.
+-  if err := Unpack(slug, dst); err != nil {
+-  t.Fatalf("err: %v", err)
+-  }
+-
+-  // Verify all the files
+-  verifyFile(t, filepath.Join(dst, "foo.txt"), 0, "foo\n")
+-  verifyFile(t, filepath.Join(dst, "bar.txt"), 0, "bar\n")
+-  verifyFile(t, filepath.Join(dst, "sub", "bar.txt"), os.ModeSymlink, 
"../bar.txt")
+-  verifyFile(t, filepath.Join(dst, "sub", "zip.txt"), 0, "zip\n")
+-
+-  // Check that we can 

Bug#997847: golang-github-hashicorp-go-slug: autopkgtest regression: testdata/archive-dir: no such file or directory

2021-10-25 Thread Paul Gevers
Source: golang-github-hashicorp-go-slug
Version: 0.7.0-1
X-Debbugs-CC: debian...@lists.debian.org
Severity: serious
User: debian...@lists.debian.org
Usertags: regression

Dear maintainer(s),

With a recent upload of golang-github-hashicorp-go-slug the autopkgtest
of golang-github-hashicorp-go-slug fails in testing when that
autopkgtest is run with the binary packages of
golang-github-hashicorp-go-slug from unstable. It passes when run with
only packages from testing. In tabular form:

 passfail
golang-github-hashicorp-go-slug  from testing0.7.0-1
all others   from testingfrom testing

I copied some of the output at the bottom of this report.

Currently this regression is blocking the migration to testing [1]. Can
you please investigate the situation and fix it?

More information about this bug and the reason for filing it can be found on
https://wiki.debian.org/ContinuousIntegration/RegressionEmailInformation

Paul

[1]
https://qa.debian.org/excuses.php?package=golang-github-hashicorp-go-slug

https://ci.debian.net/data/autopkgtest/testing/amd64/g/golang-github-hashicorp-go-slug/16196086/log.gz

[info] Testing github.com/hashicorp/go-slug...
[info] Source code installed by binary package, overriding
dh_auto_configure...
dh build --buildsystem=golang --with=golang
   dh_update_autotools_config -O--buildsystem=golang
   dh_autoreconf -O--buildsystem=golang
   debian/rules override_dh_auto_configure
make[1]: Entering directory
'/tmp/autopkgtest-lxc.3snypp0h/downtmp/autopkgtest_tmp'
mkdir -p "obj-x86_64-linux-gnu"
cp -a /usr/share/gocode/src "obj-x86_64-linux-gnu"
make[1]: Leaving directory
'/tmp/autopkgtest-lxc.3snypp0h/downtmp/autopkgtest_tmp'
   dh_auto_build -O--buildsystem=golang
cd obj-x86_64-linux-gnu && go install -trimpath -v -p 48
github.com/hashicorp/go-slug
internal/unsafeheader
runtime/internal/sys
internal/goexperiment
internal/abi
unicode/utf8
sync/atomic
internal/race
internal/itoa
internal/cpu
math/bits
runtime/internal/atomic
unicode
runtime/internal/math
internal/bytealg
math
runtime
internal/reflectlite
sync
internal/testlog
runtime/cgo
errors
sort
internal/oserror
io
path
strconv
syscall
hash
bytes
strings
hash/crc32
reflect
bufio
regexp/syntax
internal/syscall/execenv
internal/syscall/unix
time
regexp
io/fs
internal/poll
os
internal/fmtsort
encoding/binary
fmt
path/filepath
os/user
text/scanner
compress/flate
compress/gzip
archive/tar
github.com/hashicorp/go-slug
   dh_auto_test -O--buildsystem=golang
cd obj-x86_64-linux-gnu && go test -vet=off -v -p 48
github.com/hashicorp/go-slug
=== RUN   TestPackWithoutIgnoring
slug_test.go:255: err: lstat testdata/archive-dir: no such file or
directory
--- FAIL: TestPackWithoutIgnoring (0.00s)
=== RUN   TestUnpack
slug_test.go:321: err: lstat testdata/archive-dir: no such file or
directory
--- FAIL: TestUnpack (0.00s)
=== RUN   TestUnpackDuplicateNoWritePerm
--- PASS: TestUnpackDuplicateNoWritePerm (0.00s)
=== RUN   TestUnpackErrorOnUnhandledType
--- PASS: TestUnpackErrorOnUnhandledType (0.00s)
=== RUN   TestUnpackMaliciousSymlinks
=== RUN   TestUnpackMaliciousSymlinks/symlink_with_absolute_path
=== RUN   TestUnpackMaliciousSymlinks/symlink_with_external_target
=== RUN   TestUnpackMaliciousSymlinks/symlink_with_nested_external_target
=== RUN   TestUnpackMaliciousSymlinks/zipslip_vulnerability
=== RUN   TestUnpackMaliciousSymlinks/nested_symlinks_within_symlinked_dir
=== RUN   TestUnpackMaliciousSymlinks/regular_file_through_symlink
=== RUN   TestUnpackMaliciousSymlinks/directory_through_symlink
--- PASS: TestUnpackMaliciousSymlinks (0.01s)
--- PASS: TestUnpackMaliciousSymlinks/symlink_with_absolute_path (0.00s)
--- PASS: TestUnpackMaliciousSymlinks/symlink_with_external_target
(0.00s)
--- PASS:
TestUnpackMaliciousSymlinks/symlink_with_nested_external_target (0.00s)
--- PASS: TestUnpackMaliciousSymlinks/zipslip_vulnerability (0.00s)
--- PASS:
TestUnpackMaliciousSymlinks/nested_symlinks_within_symlinked_dir (0.00s)
--- PASS: TestUnpackMaliciousSymlinks/regular_file_through_symlink
(0.00s)
--- PASS: TestUnpackMaliciousSymlinks/directory_through_symlink (0.00s)
=== RUN   TestUnpackMaliciousFiles
=== RUN   TestUnpackMaliciousFiles/filename_containing_path_traversal
=== RUN
TestUnpackMaliciousFiles/should_fail_before_attempting_to_create_directories
--- PASS: TestUnpackMaliciousFiles (0.00s)
--- PASS:
TestUnpackMaliciousFiles/filename_containing_path_traversal (0.00s)
--- PASS:
TestUnpackMaliciousFiles/should_fail_before_attempting_to_create_directories
(0.00s)
=== RUN   TestCheckFileMode
=== RUN   TestCheckFileMode/includes_regular_files
=== RUN   TestCheckFileMode/includes_directories
=== RUN   TestCheckFileMode/includes_symlinks
=== RUN   TestCheckFileMode/excludes_unrecognized_modes
--- PASS: TestCheckFileMode (0.00s)
--- PASS: TestCheckFileMode/includes_regular_files (0.00s)
--- PASS: