From 607d607b516bf301996678c68dc371a0dba9a938 Mon Sep 17 00:00:00 2001 From: Cosmin Cojocar Date: Mon, 21 Mar 2022 16:53:22 +0100 Subject: [PATCH] Enable Go 1.18 in the ci and release workflows * Enable Go 1.18 in the ci and release workflows * Fix lint warning * Add golangci as a make target --- .github/workflows/ci.yml | 3 +- .github/workflows/release.yml | 6 ++-- Makefile | 8 +++-- .../{tls_version_go14.go => tls_version.go} | 4 --- cmd/tlsconfig/tls_version_go12_go13.go | 34 ------------------- cmd/tlsconfig/tlsconfig.go | 9 +++-- 6 files changed, 15 insertions(+), 49 deletions(-) rename cmd/tlsconfig/{tls_version_go14.go => tls_version.go} (89%) delete mode 100644 cmd/tlsconfig/tls_version_go12_go13.go diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f11b020..55a0ccc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,6 +13,7 @@ jobs: go_version: - '1.16' - '1.17' + - '1.18' runs-on: ubuntu-latest env: GO111MODULE: on @@ -44,7 +45,7 @@ jobs: - name: Setup go uses: actions/setup-go@v3 with: - go-version: '1.17' + go-version: '1.18' - name: Checkout Source uses: actions/checkout@v3 - uses: actions/cache@v2 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 073d426..3a1bfc2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,11 +17,11 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: 1.17 + go-version: 1.18 - name: Install Cosign uses: sigstore/cosign-installer@main with: - cosign-release: 'v1.5.2' + cosign-release: 'v1.6.0' - name: Store Cosign private key in a file run: 'echo "$COSIGN_KEY" > /tmp/cosign.key' shell: bash @@ -66,7 +66,7 @@ jobs: tags: ${{steps.meta.outputs.tags}} labels: ${{steps.meta.outputs.labels}} push: true - build-args: GO_VERSION=1.17 + build-args: GO_VERSION=1.18 - name: Sign Docker Image run: cosign sign -key /tmp/cosign.key ${TAGS} env: diff --git a/Makefile b/Makefile index 4cb90c0..5dbfd77 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ GOBIN ?= $(GOPATH)/bin GOLINT ?= $(GOBIN)/golint GOSEC ?= $(GOBIN)/gosec GINKGO ?= $(GOBIN)/ginkgo -GO_VERSION = 1.17 +GO_VERSION = 1.18 default: $(MAKE) build @@ -31,12 +31,16 @@ fmt: @([ ! -z "$(FORMATTED)" ] && printf "Fixed unformatted files:\n$(FORMATTED)") || true lint: - @echo "LINTING" + @echo "LINTING: golint" $(GO_NOMOD) get -u golang.org/x/lint/golint $(GOLINT) -set_exit_status ./... @echo "VETTING" $(GO) vet ./... +golangci: + @echo "LINTING: golangci-lint" + golangci-lint run + sec: @echo "SECURITY SCANNING" ./$(BIN) ./... diff --git a/cmd/tlsconfig/tls_version_go14.go b/cmd/tlsconfig/tls_version.go similarity index 89% rename from cmd/tlsconfig/tls_version_go14.go rename to cmd/tlsconfig/tls_version.go index e0a6a04..9c238c6 100644 --- a/cmd/tlsconfig/tls_version_go14.go +++ b/cmd/tlsconfig/tls_version.go @@ -1,7 +1,3 @@ -//go:build go1.14 || !go1.11 -// +build go1.14 !go1.11 - -// main package main import ( diff --git a/cmd/tlsconfig/tls_version_go12_go13.go b/cmd/tlsconfig/tls_version_go12_go13.go deleted file mode 100644 index 005d53a..0000000 --- a/cmd/tlsconfig/tls_version_go12_go13.go +++ /dev/null @@ -1,34 +0,0 @@ -//go:build go1.12 && !go1.14 -// +build go1.12,!go1.14 - -// This file can be removed once go1.13 is no longer supported - -package main - -import ( - "crypto/tls" - "sort" -) - -func mapTLSVersions(tlsVersions []string) []int { - var versions []int - for _, tlsVersion := range tlsVersions { - switch tlsVersion { - case "TLSv1.3": - versions = append(versions, tls.VersionTLS13) - case "TLSv1.2": - versions = append(versions, tls.VersionTLS12) - case "TLSv1.1": - versions = append(versions, tls.VersionTLS11) - case "TLSv1": - versions = append(versions, tls.VersionTLS10) - case "SSLv3": - // unsupported from go1.14 - versions = append(versions, tls.VersionSSL30) - default: - continue - } - } - sort.Ints(versions) - return versions -} diff --git a/cmd/tlsconfig/tlsconfig.go b/cmd/tlsconfig/tlsconfig.go index 155cf43..5d1b9aa 100644 --- a/cmd/tlsconfig/tlsconfig.go +++ b/cmd/tlsconfig/tlsconfig.go @@ -1,6 +1,3 @@ -//go:build go1.12 -// +build go1.12 - package main import ( @@ -14,9 +11,10 @@ import ( "log" "net/http" "path/filepath" - "strings" "github.com/mozilla/tls-observatory/constants" + "golang.org/x/text/cases" + "golang.org/x/text/language" ) var ( @@ -82,7 +80,8 @@ func getTLSConfFromURL(url string) (*ServerSideTLSJson, error) { } func getGoCipherConfig(name string, sstls ServerSideTLSJson) (goCipherConfiguration, error) { - cipherConf := goCipherConfiguration{Name: strings.Title(name)} + caser := cases.Title(language.English) + cipherConf := goCipherConfiguration{Name: caser.String(name)} conf, ok := sstls.Configurations[name] if !ok { return cipherConf, fmt.Errorf("TLS configuration '%s' not found", name)