diff --git a/pkg/kubectl/cmd/cp/cp.go b/pkg/kubectl/cmd/cp/cp.go index 1f43cbf6403..36ac59bcb83 100644 --- a/pkg/kubectl/cmd/cp/cp.go +++ b/pkg/kubectl/cmd/cp/cp.go @@ -122,8 +122,8 @@ type fileSpec struct { } var ( - errFileSpecDoesntMatchFormat = errors.New("Filespec must match the canonical format: [[namespace/]pod:]file/path") - errFileCannotBeEmpty = errors.New("Filepath can not be empty") + errFileSpecDoesntMatchFormat = errors.New("filespec must match the canonical format: [[namespace/]pod:]file/path") + errFileCannotBeEmpty = errors.New("filepath can not be empty") ) func extractFileSpec(arg string) (fileSpec, error) { diff --git a/pkg/kubectl/cmd/cp/cp_test.go b/pkg/kubectl/cmd/cp/cp_test.go index eb75a0e18b8..5ead99135e5 100644 --- a/pkg/kubectl/cmd/cp/cp_test.go +++ b/pkg/kubectl/cmd/cp/cp_test.go @@ -549,35 +549,6 @@ func TestBadTar(t *testing.T) { } } -// clean prevents path traversals by stripping them out. -// This is adapted from https://golang.org/src/net/http/fs.go#L74 -func clean(fileName string) string { - return path.Clean(string(os.PathSeparator) + fileName) -} - -func TestClean(t *testing.T) { - tests := []struct { - input string - cleaned string - }{ - { - "../../../tmp/foo", - "/tmp/foo", - }, - { - "/../../../tmp/foo", - "/tmp/foo", - }, - } - - for _, test := range tests { - out := clean(test.input) - if out != test.cleaned { - t.Errorf("Expected: %s, saw %s", test.cleaned, out) - } - } -} - func TestCopyToPod(t *testing.T) { tf := cmdtesting.NewTestFactory().WithNamespace("test") ns := scheme.Codecs