MCPcopy
hub / github.com/klauspost/compress / TestDisableInsecurePathCheck

Function TestDisableInsecurePathCheck

zip/reader_test.go:1705–1726  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1703}
1704
1705func TestDisableInsecurePathCheck(t *testing.T) {
1706 t.Setenv("GODEBUG", "zipinsecurepath=1")
1707 var buf bytes.Buffer
1708 zw := NewWriter(&buf)
1709 const name = "/foo"
1710 _, err := zw.Create(name)
1711 if err != nil {
1712 t.Fatalf("zw.Create(%q) = %v", name, err)
1713 }
1714 zw.Close()
1715 zr, err := NewReader(bytes.NewReader(buf.Bytes()), int64(buf.Len()))
1716 if err != nil {
1717 t.Fatalf("NewReader with zipinsecurepath=1: got err %v, want nil", err)
1718 }
1719 var gotPaths []string
1720 for _, f := range zr.File {
1721 gotPaths = append(gotPaths, f.Name)
1722 }
1723 if want := []string{name}; !reflect.DeepEqual(gotPaths, want) {
1724 t.Errorf("NewReader with zipinsecurepath=1: got files %q, want %q", gotPaths, want)
1725 }
1726}
1727
1728func TestCompressedDirectory(t *testing.T) {
1729 // Empty Java JAR, with a compressed directory with uncompressed size 0

Callers

nothing calls this directly

Calls 6

CreateMethod · 0.95
CloseMethod · 0.95
LenMethod · 0.80
NewWriterFunction · 0.70
NewReaderFunction · 0.70
BytesMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…