From ec160b5e5650ed8d648a0e364ad03121a8c73afa Mon Sep 17 00:00:00 2001 From: Ivan Krutov Date: Thu, 17 Nov 2022 12:30:43 +0300 Subject: [PATCH 1/6] Bump Golang to 1.19 --- .github/workflows/build.yml | 2 +- .github/workflows/release.yml | 2 +- .github/workflows/test.yml | 2 +- go.mod | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ff22c10..dbdb102 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,7 +14,7 @@ jobs: - name: Setup Golang uses: actions/setup-go@v2 with: - go-version: 1.18.x + go-version: ~1.19.3 - uses: actions/cache@v1 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 84b8ac7..5182e4f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,7 +13,7 @@ jobs: - name: Setup Golang uses: actions/setup-go@v2 with: - go-version: 1.18.x + go-version: ~1.19.3 - uses: actions/cache@v1 with: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2d59054..1af7178 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,7 +12,7 @@ jobs: - name: Setup Golang uses: actions/setup-go@v2 with: - go-version: 1.18.x + go-version: ~1.19.3 - uses: actions/cache@v1 with: diff --git a/go.mod b/go.mod index e1b3277..8bcf94b 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/aerokube/cm -go 1.18 +go 1.19 require ( github.com/Masterminds/semver/v3 v3.0.1 From 0c9766d8dbeff4c1ac5975da8992cec25a21616c Mon Sep 17 00:00:00 2001 From: Ivan Krutov Date: Thu, 17 Nov 2022 12:33:35 +0300 Subject: [PATCH 2/6] Removed deprecated function calls --- selenoid/docker.go | 9 ++++----- selenoid/docker_test.go | 3 +-- selenoid/drivers.go | 5 ++--- selenoid/drivers_test.go | 9 ++++----- 4 files changed, 11 insertions(+), 15 deletions(-) diff --git a/selenoid/docker.go b/selenoid/docker.go index aa11eae..5eaac53 100644 --- a/selenoid/docker.go +++ b/selenoid/docker.go @@ -7,7 +7,6 @@ import ( "fmt" "github.com/docker/docker/api" "github.com/docker/go-units" - "io/ioutil" "log" "sort" @@ -114,7 +113,7 @@ func NewDockerConfigurator(config *LifecycleConfig) (*DockerConfigurator, error) } if c.Quiet { log.SetFlags(0) - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) } err := c.initDockerClient() if err != nil { @@ -389,12 +388,12 @@ func (c *DockerConfigurator) Configure() (*SelenoidConfig, error) { if err != nil { return nil, fmt.Errorf("failed to marshal json: %v", err) } - return &cfg, ioutil.WriteFile(getSelenoidConfigPath(c.ConfigDir), data, 0644) + return &cfg, os.WriteFile(getSelenoidConfigPath(c.ConfigDir), data, 0644) } func (c *DockerConfigurator) syncWithConfig() (*SelenoidConfig, error) { c.Titlef(`Requested to sync configuration from "%v"...`, color.GreenString(c.BrowsersJson)) - data, err := ioutil.ReadFile(c.BrowsersJson) + data, err := os.ReadFile(c.BrowsersJson) if err != nil { return nil, fmt.Errorf("failed to read browsers.json from %s: %v", c.BrowsersJson, err) } @@ -418,7 +417,7 @@ func (c *DockerConfigurator) syncWithConfig() (*SelenoidConfig, error) { } c.pullVideoRecorderImage() } - return &cfg, ioutil.WriteFile(getSelenoidConfigPath(c.ConfigDir), data, 0644) + return &cfg, os.WriteFile(getSelenoidConfigPath(c.ConfigDir), data, 0644) } func (c *DockerConfigurator) createConfig() SelenoidConfig { diff --git a/selenoid/docker_test.go b/selenoid/docker_test.go index a2385c0..e4cfdd5 100644 --- a/selenoid/docker_test.go +++ b/selenoid/docker_test.go @@ -6,7 +6,6 @@ import ( . "github.com/aandryashin/matchers" "github.com/aerokube/selenoid/config" "github.com/docker/docker/api/types" - "io/ioutil" "net/http" "net/http/httptest" "os" @@ -431,7 +430,7 @@ func TestSyncWithConfig(t *testing.T) { initialCfgFile := filepath.Join(dir, "initial-browsers.json") data, _ := json.Marshal(initialCfg) - ioutil.WriteFile(initialCfgFile, data, 0644) + os.WriteFile(initialCfgFile, data, 0644) lcConfig := LifecycleConfig{ ConfigDir: dir, diff --git a/selenoid/drivers.go b/selenoid/drivers.go index e8663a9..a46e289 100644 --- a/selenoid/drivers.go +++ b/selenoid/drivers.go @@ -16,7 +16,6 @@ import ( "github.com/mitchellh/go-ps" "gopkg.in/cheggaaa/pb.v1" "io" - "io/ioutil" "net/http" "net/url" "os" @@ -285,7 +284,7 @@ func (d *DriversConfigurator) Configure() (*SelenoidConfig, error) { if err != nil { return &cfg, fmt.Errorf("failed to marshal json: %v", err) } - return &cfg, ioutil.WriteFile(getSelenoidConfigPath(d.ConfigDir), data, 0644) + return &cfg, os.WriteFile(getSelenoidConfigPath(d.ConfigDir), data, 0644) } func (d *DriversConfigurator) generateConfig(downloadedDrivers []downloadedDriver) SelenoidConfig { @@ -406,7 +405,7 @@ func extractFile(data []byte, filename string, outputDir string) (string, error) return untar(data, filename, outputDir) } else { outputPath := filepath.Join(outputDir, filename) - err := ioutil.WriteFile(outputPath, data, os.ModePerm) + err := os.WriteFile(outputPath, data, os.ModePerm) if err != nil { return "", fmt.Errorf("failed to save file %s: %v", outputPath, err) } diff --git a/selenoid/drivers_test.go b/selenoid/drivers_test.go index 9559c78..e142c45 100644 --- a/selenoid/drivers_test.go +++ b/selenoid/drivers_test.go @@ -6,7 +6,6 @@ import ( . "github.com/aandryashin/matchers" "github.com/aerokube/selenoid/config" "github.com/google/go-github/github" - "io/ioutil" "net/http" "net/http/httptest" "net/url" @@ -276,7 +275,7 @@ func testUnpack(t *testing.T, data []byte, fileName string, fn func([]byte, stri } func readFile(t *testing.T, fileName string) []byte { - data, err := ioutil.ReadFile(fileName) + data, err := os.ReadFile(fileName) if err != nil { t.Fatal(err) } @@ -299,7 +298,7 @@ func mockServerUrl(mockServer *httptest.Server, relativeUrl string) string { } func withTmpDir(t *testing.T, prefix string, fn func(*testing.T, string)) { - dir, err := ioutil.TempDir("", prefix) + dir, err := os.MkdirTemp("", prefix) if err != nil { t.Fatal(err) } @@ -365,7 +364,7 @@ func checkContentsEqual(t *testing.T, outputPath string, expectedFileContents st if !fileExists(outputPath) { t.Fatalf("release was not downloaded to %s: file does not exist\n", outputPath) } - data, err := ioutil.ReadFile(outputPath) + data, err := os.ReadFile(outputPath) AssertThat(t, err, Is{nil}) AssertThat(t, string(data), EqualTo{expectedFileContents}) @@ -418,7 +417,7 @@ func TestWrongBaseUrl(t *testing.T) { }) } -//Based on https://npf.io/2015/06/testing-exec-command/ +// Based on https://npf.io/2015/06/testing-exec-command/ func TestStartStopProcess(t *testing.T) { execCommand = fakeExecCommand defer func() { From f5158f4b3e610498c6a199672129abca6ac3b82e Mon Sep 17 00:00:00 2001 From: Ivan Krutov Date: Thu, 17 Nov 2022 12:33:54 +0300 Subject: [PATCH 3/6] Using latest alpine base image --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 347c5a9..bae9ee1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM alpine:3.12 +FROM alpine:3 RUN apk add -U ca-certificates tzdata && rm -Rf /var/cache/apk/* COPY cm / From 858fa34996c45fa7a91c379db10382fe7e853f9a Mon Sep 17 00:00:00 2001 From: Ivan Krutov Date: Thu, 17 Nov 2022 12:34:22 +0300 Subject: [PATCH 4/6] Building Docker image with --pull --- ci/docker-push.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/docker-push.sh b/ci/docker-push.sh index 5a658b5..5bbbffb 100755 --- a/ci/docker-push.sh +++ b/ci/docker-push.sh @@ -2,7 +2,7 @@ set -e -docker build -t "$GITHUB_REPOSITORY" -t "$GITHUB_REPOSITORY:$1" . docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD" +docker build --pull -t "$GITHUB_REPOSITORY" -t "$GITHUB_REPOSITORY:$1" . docker push "$GITHUB_REPOSITORY" docker push "$GITHUB_REPOSITORY:$1" From d7b75750932b6517c14533c976a59b0086f6a482 Mon Sep 17 00:00:00 2001 From: Ivan Krutov Date: Thu, 17 Nov 2022 12:35:54 +0300 Subject: [PATCH 5/6] Checking source code for vulnerabilities --- ci/test.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ci/test.sh b/ci/test.sh index f9d4c4f..ba886ec 100755 --- a/ci/test.sh +++ b/ci/test.sh @@ -2,3 +2,6 @@ export GO111MODULE="on" go test -race -v github.com/aerokube/cm/selenoid -coverprofile=coverage.txt -covermode=atomic -coverpkg github.com/aerokube/cm/selenoid + +go install golang.org/x/vuln/cmd/govulncheck@latest +"$(go env GOPATH)"/bin/govulncheck ./... From 294cc7adf705f7d8bd7f8256752838b56b15b18d Mon Sep 17 00:00:00 2001 From: Ivan Krutov Date: Thu, 17 Nov 2022 12:57:32 +0300 Subject: [PATCH 6/6] Bump driver versions --- browsers.json | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/browsers.json b/browsers.json index 153d521..76639ec 100644 --- a/browsers.json +++ b/browsers.json @@ -4,23 +4,23 @@ "files": { "linux": { "amd64": { - "url": "https://chromedriver.storage.googleapis.com/104.0.5112.29/chromedriver_linux64.zip", + "url": "https://chromedriver.storage.googleapis.com/107.0.5304.62/chromedriver_linux64.zip", "filename": "chromedriver" } }, "darwin": { "amd64": { - "url": "https://chromedriver.storage.googleapis.com/104.0.5112.29/chromedriver_mac64.zip", + "url": "https://chromedriver.storage.googleapis.com/107.0.5304.62/chromedriver_mac64.zip", "filename": "chromedriver" } }, "windows": { "386": { - "url": "https://chromedriver.storage.googleapis.com/104.0.5112.29/chromedriver_win32.zip", + "url": "https://chromedriver.storage.googleapis.com/107.0.5304.62/chromedriver_win32.zip", "filename": "chromedriver.exe" }, "amd64": { - "url": "https://chromedriver.storage.googleapis.com/104.0.5112.29/chromedriver_win32.zip", + "url": "https://chromedriver.storage.googleapis.com/107.0.5304.62/chromedriver_win32.zip", "filename": "chromedriver.exe" } } @@ -32,27 +32,27 @@ "files": { "linux": { "386": { - "url": "https://github.com/mozilla/geckodriver/releases/download/v0.31.0/geckodriver-v0.31.0-linux32.tar.gz", + "url": "https://github.com/mozilla/geckodriver/releases/download/v0.32.0/geckodriver-v0.32.0-linux32.tar.gz", "filename": "geckodriver" }, "amd64": { - "url": "https://github.com/mozilla/geckodriver/releases/download/v0.31.0/geckodriver-v0.31.0-linux64.tar.gz", + "url": "https://github.com/mozilla/geckodriver/releases/download/v0.32.0/geckodriver-v0.32.0-linux64.tar.gz", "filename": "geckodriver" } }, "darwin": { "amd64": { - "url": "https://github.com/mozilla/geckodriver/releases/download/v0.31.0/geckodriver-v0.31.0-macos.tar.gz", + "url": "https://github.com/mozilla/geckodriver/releases/download/v0.32.0/geckodriver-v0.32.0-macos.tar.gz", "filename": "geckodriver" } }, "windows": { "386": { - "url": "https://github.com/mozilla/geckodriver/releases/download/v0.31.0/geckodriver-v0.31.0-win32.zip", + "url": "https://github.com/mozilla/geckodriver/releases/download/v0.32.0/geckodriver-v0.32.0-win32.zip", "filename": "geckodriver.exe" }, "amd64": { - "url": "https://github.com/mozilla/geckodriver/releases/download/v0.31.0/geckodriver-v0.31.0-win64.zip", + "url": "https://github.com/mozilla/geckodriver/releases/download/v0.32.0/geckodriver-v0.32.0-win64.zip", "filename": "geckodriver.exe" } } @@ -64,23 +64,23 @@ "files": { "linux": { "amd64": { - "url": "https://github.com/operasoftware/operachromiumdriver/releases/download/v.103.0.5060.66/operadriver_linux64.zip", + "url": "https://github.com/operasoftware/operachromiumdriver/releases/download/v.106.0.5249.119 /operadriver_linux64.zip", "filename": "operadriver_linux64/operadriver" } }, "darwin": { "amd64": { - "url": "https://github.com/operasoftware/operachromiumdriver/releases/download/v.103.0.5060.66/operadriver_mac64.zip", + "url": "https://github.com/operasoftware/operachromiumdriver/releases/download/v.106.0.5249.119 /operadriver_mac64.zip", "filename": "operadriver_mac64/operadriver" } }, "windows": { "386": { - "url": "https://github.com/operasoftware/operachromiumdriver/releases/download/v.103.0.5060.66/operadriver_win32.zip", + "url": "https://github.com/operasoftware/operachromiumdriver/releases/download/v.106.0.5249.119 /operadriver_win32.zip", "filename": "operadriver_win32/operadriver.exe" }, "amd64": { - "url": "https://github.com/operasoftware/operachromiumdriver/releases/download/v.103.0.5060.66/operadriver_win64.zip", + "url": "https://github.com/operasoftware/operachromiumdriver/releases/download/v.106.0.5249.119 /operadriver_win64.zip", "filename": "operadriver_win64/operadriver.exe" } } @@ -121,27 +121,27 @@ "files": { "linux": { "amd64": { - "url": "https://msedgewebdriverstorage.blob.core.windows.net/edgewebdriver/105.0.1321.0/edgedriver_linux64.zip", + "url": "https://msedgewebdriverstorage.blob.core.windows.net/edgewebdriver/107.0.1418.42/edgedriver_linux64.zip", "filename": "msedgedriver" } }, "darwin": { "amd64": { - "url": "https://msedgewebdriverstorage.blob.core.windows.net/edgewebdriver/105.0.1321.0/edgedriver_mac64.zip", + "url": "https://msedgewebdriverstorage.blob.core.windows.net/edgewebdriver/107.0.1418.42/edgedriver_mac64.zip", "filename": "msedgedriver" }, "arm64": { - "url": "https://msedgewebdriverstorage.blob.core.windows.net/edgewebdriver/105.0.1321.0/edgedriver_arm64.zip", + "url": "https://msedgewebdriverstorage.blob.core.windows.net/edgewebdriver/107.0.1418.42/edgedriver_arm64.zip", "filename": "msedgedriver" } }, "windows": { "386": { - "url": "https://msedgewebdriverstorage.blob.core.windows.net/edgewebdriver/105.0.1321.0/edgedriver_win32.zip", + "url": "https://msedgewebdriverstorage.blob.core.windows.net/edgewebdriver/107.0.1418.42/edgedriver_win32.zip", "filename": "msedgedriver.exe" }, "amd64": { - "url": "https://msedgewebdriverstorage.blob.core.windows.net/edgewebdriver/105.0.1321.0/edgedriver_win64.zip", + "url": "https://msedgewebdriverstorage.blob.core.windows.net/edgewebdriver/107.0.1418.42/edgedriver_win64.zip", "filename": "msedgedriver.exe" } }