From 0ecfcb5997ab232de311cb385ecf3da7f68edc00 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 18 Jul 2019 11:13:45 +0200 Subject: [PATCH 1/3] Dockerfile: use GO_VERSION build-arg for overriding Go version This allows overriding the version of Go without making modifications in the source code, which can be useful to test against multiple versions. For example: make GO_VERSION=1.13beta1 -f docker.Makefile binary Signed-off-by: Sebastiaan van Stijn (cherry picked from commit 0d3022c6d284e3e742065228fcda89d3275ce682) Signed-off-by: Sebastiaan van Stijn --- docker.Makefile | 12 ++++++------ dockerfiles/Dockerfile.binary-native | 4 +++- dockerfiles/Dockerfile.cross | 4 +++- dockerfiles/Dockerfile.dev | 4 +++- dockerfiles/Dockerfile.lint | 4 +++- 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/docker.Makefile b/docker.Makefile index 3783e8bff6..cf4f406cf9 100644 --- a/docker.Makefile +++ b/docker.Makefile @@ -27,32 +27,32 @@ ENVVARS = -e VERSION=$(VERSION) -e GITCOMMIT -e PLATFORM -e TESTFLAGS -e TESTDIR .PHONY: build_docker_image build_docker_image: # build dockerfile from stdin so that we don't send the build-context; source is bind-mounted in the development environment - cat ./dockerfiles/Dockerfile.dev | docker build ${DOCKER_BUILD_ARGS} -t $(DEV_DOCKER_IMAGE_NAME) - + cat ./dockerfiles/Dockerfile.dev | docker build ${DOCKER_BUILD_ARGS} --build-arg=GO_VERSION -t $(DEV_DOCKER_IMAGE_NAME) - # build docker image having the linting tools (dockerfiles/Dockerfile.lint) .PHONY: build_linter_image build_linter_image: # build dockerfile from stdin so that we don't send the build-context; source is bind-mounted in the development environment - cat ./dockerfiles/Dockerfile.lint | docker build ${DOCKER_BUILD_ARGS} -t $(LINTER_IMAGE_NAME) - + cat ./dockerfiles/Dockerfile.lint | docker build ${DOCKER_BUILD_ARGS} --build-arg=GO_VERSION -t $(LINTER_IMAGE_NAME) - .PHONY: build_cross_image build_cross_image: # build dockerfile from stdin so that we don't send the build-context; source is bind-mounted in the development environment - cat ./dockerfiles/Dockerfile.cross | docker build ${DOCKER_BUILD_ARGS} -t $(CROSS_IMAGE_NAME) - + cat ./dockerfiles/Dockerfile.cross | docker build ${DOCKER_BUILD_ARGS} --build-arg=GO_VERSION -t $(CROSS_IMAGE_NAME) - .PHONY: build_shell_validate_image build_shell_validate_image: # build dockerfile from stdin so that we don't send the build-context; source is bind-mounted in the development environment - cat ./dockerfiles/Dockerfile.shellcheck | docker build -t $(VALIDATE_IMAGE_NAME) - + cat ./dockerfiles/Dockerfile.shellcheck | docker build --build-arg=GO_VERSION -t $(VALIDATE_IMAGE_NAME) - .PHONY: build_binary_native_image build_binary_native_image: # build dockerfile from stdin so that we don't send the build-context; source is bind-mounted in the development environment - cat ./dockerfiles/Dockerfile.binary-native | docker build -t $(BINARY_NATIVE_IMAGE_NAME) - + cat ./dockerfiles/Dockerfile.binary-native | docker build --build-arg=GO_VERSION -t $(BINARY_NATIVE_IMAGE_NAME) - .PHONY: build_e2e_image build_e2e_image: - docker build -t $(E2E_IMAGE_NAME) --build-arg VERSION=$(VERSION) --build-arg GITCOMMIT=$(GITCOMMIT) -f ./dockerfiles/Dockerfile.e2e . + docker build -t $(E2E_IMAGE_NAME) --build-arg=GO_VERSION --build-arg VERSION=$(VERSION) --build-arg GITCOMMIT=$(GITCOMMIT) -f ./dockerfiles/Dockerfile.e2e . DOCKER_RUN_NAME_OPTION := $(if $(DOCKER_CLI_CONTAINER_NAME),--name $(DOCKER_CLI_CONTAINER_NAME),) DOCKER_RUN := docker run --rm $(ENVVARS) $(DOCKER_CLI_MOUNTS) $(DOCKER_RUN_NAME_OPTION) diff --git a/dockerfiles/Dockerfile.binary-native b/dockerfiles/Dockerfile.binary-native index 8193522d12..4e37092c51 100644 --- a/dockerfiles/Dockerfile.binary-native +++ b/dockerfiles/Dockerfile.binary-native @@ -1,4 +1,6 @@ -FROM golang:1.12.7-alpine +ARG GO_VERSION=1.12.7 + +FROM golang:${GO_VERSION}-alpine RUN apk add -U git bash coreutils gcc musl-dev diff --git a/dockerfiles/Dockerfile.cross b/dockerfiles/Dockerfile.cross index 53e3cffca0..6f9103cea7 100644 --- a/dockerfiles/Dockerfile.cross +++ b/dockerfiles/Dockerfile.cross @@ -1,4 +1,6 @@ -FROM dockercore/golang-cross:1.12.7 +ARG GO_VERSION=1.12.7 + +FROM dockercore/golang-cross:${GO_VERSION} ENV DISABLE_WARN_OUTSIDE_CONTAINER=1 WORKDIR /go/src/github.com/docker/cli COPY . . diff --git a/dockerfiles/Dockerfile.dev b/dockerfiles/Dockerfile.dev index ba2d9d9398..c0b041eba0 100644 --- a/dockerfiles/Dockerfile.dev +++ b/dockerfiles/Dockerfile.dev @@ -1,4 +1,6 @@ -FROM golang:1.12.7-alpine +ARG GO_VERSION=1.12.7 + +FROM golang:${GO_VERSION}-alpine RUN apk add -U git make bash coreutils ca-certificates curl diff --git a/dockerfiles/Dockerfile.lint b/dockerfiles/Dockerfile.lint index 9e967232c9..70ace90463 100644 --- a/dockerfiles/Dockerfile.lint +++ b/dockerfiles/Dockerfile.lint @@ -1,4 +1,6 @@ -FROM golang:1.12.7-alpine +ARG GO_VERSION=1.12.7 + +FROM golang:${GO_VERSION}-alpine RUN apk add -U git From b58270ba6984c8f90297f2abe6ac840a1cdad3f3 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 14 Aug 2019 02:55:45 +0200 Subject: [PATCH 2/3] Bump golang 1.12.8 (CVE-2019-9512, CVE-2019-9514) go1.12.8 (released 2019/08/13) includes security fixes to the net/http and net/url packages. See the Go 1.12.8 milestone on our issue tracker for details: https://github.com/golang/go/issues?q=milestone%3AGo1.12.8 - net/http: Denial of Service vulnerabilities in the HTTP/2 implementation net/http and golang.org/x/net/http2 servers that accept direct connections from untrusted clients could be remotely made to allocate an unlimited amount of memory, until the program crashes. Servers will now close connections if the send queue accumulates too many control messages. The issues are CVE-2019-9512 and CVE-2019-9514, and Go issue golang.org/issue/33606. Thanks to Jonathan Looney from Netflix for discovering and reporting these issues. This is also fixed in version v0.0.0-20190813141303-74dc4d7220e7 of golang.org/x/net/http2. net/url: parsing validation issue - url.Parse would accept URLs with malformed hosts, such that the Host field could have arbitrary suffixes that would appear in neither Hostname() nor Port(), allowing authorization bypasses in certain applications. Note that URLs with invalid, not numeric ports will now return an error from url.Parse. The issue is CVE-2019-14809 and Go issue golang.org/issue/29098. Thanks to Julian Hector and Nikolai Krein from Cure53, and Adi Cohen (adico.me) for discovering and reporting this issue. Signed-off-by: Sebastiaan van Stijn (cherry picked from commit bbd179f25b60cd445a975a4138e9edf918931ad8) Signed-off-by: Sebastiaan van Stijn --- appveyor.yml | 2 +- dockerfiles/Dockerfile.binary-native | 2 +- dockerfiles/Dockerfile.cross | 2 +- dockerfiles/Dockerfile.dev | 2 +- dockerfiles/Dockerfile.e2e | 2 +- dockerfiles/Dockerfile.lint | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index c8c9715971..58189d5c56 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -4,7 +4,7 @@ clone_folder: c:\gopath\src\github.com\docker\cli environment: GOPATH: c:\gopath - GOVERSION: 1.12.7 + GOVERSION: 1.12.8 DEPVERSION: v0.4.1 install: diff --git a/dockerfiles/Dockerfile.binary-native b/dockerfiles/Dockerfile.binary-native index 4e37092c51..9d1ee68580 100644 --- a/dockerfiles/Dockerfile.binary-native +++ b/dockerfiles/Dockerfile.binary-native @@ -1,4 +1,4 @@ -ARG GO_VERSION=1.12.7 +ARG GO_VERSION=1.12.8 FROM golang:${GO_VERSION}-alpine diff --git a/dockerfiles/Dockerfile.cross b/dockerfiles/Dockerfile.cross index 6f9103cea7..4c9b32d281 100644 --- a/dockerfiles/Dockerfile.cross +++ b/dockerfiles/Dockerfile.cross @@ -1,4 +1,4 @@ -ARG GO_VERSION=1.12.7 +ARG GO_VERSION=1.12.8 FROM dockercore/golang-cross:${GO_VERSION} ENV DISABLE_WARN_OUTSIDE_CONTAINER=1 diff --git a/dockerfiles/Dockerfile.dev b/dockerfiles/Dockerfile.dev index c0b041eba0..8617449084 100644 --- a/dockerfiles/Dockerfile.dev +++ b/dockerfiles/Dockerfile.dev @@ -1,4 +1,4 @@ -ARG GO_VERSION=1.12.7 +ARG GO_VERSION=1.12.8 FROM golang:${GO_VERSION}-alpine diff --git a/dockerfiles/Dockerfile.e2e b/dockerfiles/Dockerfile.e2e index a4adc12624..22f3ecf74e 100644 --- a/dockerfiles/Dockerfile.e2e +++ b/dockerfiles/Dockerfile.e2e @@ -1,4 +1,4 @@ -ARG GO_VERSION=1.12.7 +ARG GO_VERSION=1.12.8 FROM docker/containerd-shim-process:a4d1531 AS containerd-shim-process diff --git a/dockerfiles/Dockerfile.lint b/dockerfiles/Dockerfile.lint index 70ace90463..280d02a4f0 100644 --- a/dockerfiles/Dockerfile.lint +++ b/dockerfiles/Dockerfile.lint @@ -1,4 +1,4 @@ -ARG GO_VERSION=1.12.7 +ARG GO_VERSION=1.12.8 FROM golang:${GO_VERSION}-alpine From 307befd7e23004f038e0231349ac9fb00f39c91d Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 14 Aug 2019 10:04:43 +0200 Subject: [PATCH 3/3] Adjust tests for changes in Go 1.12.8 / 1.11.13 For now, just verifying that an error is returned, but not checking the error message itself, because those are not under our control, and may change with different Go versions. ``` === Failed === FAIL: opts TestParseDockerDaemonHost (0.00s) hosts_test.go:87: tcp tcp:a.b.c.d address expected error "Invalid bind address format: tcp:a.b.c.d" return, got "parse tcp://tcp:a.b.c.d: invalid port \":a.b.c.d\" after host" and addr hosts_test.go:87: tcp tcp:a.b.c.d/path address expected error "Invalid bind address format: tcp:a.b.c.d/path" return, got "parse tcp://tcp:a.b.c.d/path: invalid port \":a.b.c.d\" after host" and addr === FAIL: opts TestParseTCP (0.00s) hosts_test.go:129: tcp tcp:a.b.c.d address expected error Invalid bind address format: tcp:a.b.c.d return, got parse tcp://tcp:a.b.c.d: invalid port ":a.b.c.d" after host and addr hosts_test.go:129: tcp tcp:a.b.c.d/path address expected error Invalid bind address format: tcp:a.b.c.d/path return, got parse tcp://tcp:a.b.c.d/path: invalid port ":a.b.c.d" after host and addr ``` Signed-off-by: Sebastiaan van Stijn (cherry picked from commit de1523d221d7e719fe470c63c3cd908092e772df) Signed-off-by: Sebastiaan van Stijn --- opts/hosts_test.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/opts/hosts_test.go b/opts/hosts_test.go index a2b03f46d9..3e6e49703f 100644 --- a/opts/hosts_test.go +++ b/opts/hosts_test.go @@ -53,8 +53,8 @@ func TestParseHost(t *testing.T) { func TestParseDockerDaemonHost(t *testing.T) { invalids := map[string]string{ - "tcp:a.b.c.d": "Invalid bind address format: tcp:a.b.c.d", - "tcp:a.b.c.d/path": "Invalid bind address format: tcp:a.b.c.d/path", + "tcp:a.b.c.d": "", + "tcp:a.b.c.d/path": "", "udp://127.0.0.1": "Invalid bind address format: udp://127.0.0.1", "udp://127.0.0.1:2375": "Invalid bind address format: udp://127.0.0.1:2375", "tcp://unix:///run/docker.sock": "Invalid proto, expected tcp: unix:///run/docker.sock", @@ -83,7 +83,7 @@ func TestParseDockerDaemonHost(t *testing.T) { "localhost:5555/path": "tcp://localhost:5555/path", } for invalidAddr, expectedError := range invalids { - if addr, err := parseDockerDaemonHost(invalidAddr); err == nil || err.Error() != expectedError { + if addr, err := parseDockerDaemonHost(invalidAddr); err == nil || expectedError != "" && err.Error() != expectedError { t.Errorf("tcp %v address expected error %q return, got %q and addr %v", invalidAddr, expectedError, err, addr) } } @@ -99,8 +99,8 @@ func TestParseTCP(t *testing.T) { defaultHTTPHost = "tcp://127.0.0.1:2376" ) invalids := map[string]string{ - "tcp:a.b.c.d": "Invalid bind address format: tcp:a.b.c.d", - "tcp:a.b.c.d/path": "Invalid bind address format: tcp:a.b.c.d/path", + "tcp:a.b.c.d": "", + "tcp:a.b.c.d/path": "", "udp://127.0.0.1": "Invalid proto, expected tcp: udp://127.0.0.1", "udp://127.0.0.1:2375": "Invalid proto, expected tcp: udp://127.0.0.1:2375", } @@ -125,7 +125,7 @@ func TestParseTCP(t *testing.T) { "localhost:5555/path": "tcp://localhost:5555/path", } for invalidAddr, expectedError := range invalids { - if addr, err := ParseTCPAddr(invalidAddr, defaultHTTPHost); err == nil || err.Error() != expectedError { + if addr, err := ParseTCPAddr(invalidAddr, defaultHTTPHost); err == nil || expectedError != "" && err.Error() != expectedError { t.Errorf("tcp %v address expected error %v return, got %s and addr %v", invalidAddr, expectedError, err, addr) } }