Skip to content

Commit 770899f

Browse files
author
Bryan C. Mills
committed
cmd/go: add a regression test for 'go mod vendor' path traversal
For #46867 Change-Id: I1547ebf7b91e9ddd7b67fd2f20e91391d79fa35d Reviewed-on: https://go-review.googlesource.com/c/go/+/332250 Trust: Bryan C. Mills <bcmills@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com>
1 parent 835d86a commit 770899f

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Regression test for golang.org/issue/46867:
2+
# 'go mod vendor' on Windows attempted to open and copy
3+
# files from directories outside of the module.
4+
5+
cd subdir
6+
go mod vendor
7+
! exists vendor/example.net/NOTICE
8+
exists vendor/example.net/m/NOTICE
9+
10+
-- subdir/go.mod --
11+
module golang.org/issue46867
12+
13+
go 1.17
14+
15+
replace example.net/m v0.1.0 => ./m
16+
17+
require example.net/m v0.1.0
18+
-- subdir/issue.go --
19+
package issue
20+
21+
import _ "example.net/m/n"
22+
-- subdir/m/go.mod --
23+
module example.net/m
24+
25+
go 1.17
26+
-- subdir/m/n/n.go --
27+
package n
28+
-- subdir/m/NOTICE --
29+
This notice is in module m and SHOULD be vendored.
30+
-- subdir/NOTICE --
31+
This notice is outside of module m and SHOULD NOT be vendored.

0 commit comments

Comments
 (0)