Find, verify, and analyze leaked credentials
Go credentialsdevsecopsdynamic-analysisprecommitscanningsecretsecret-managementsecretssecuritysecurity-toolstrufflehogverification
Upgrade golangci-lint in CI runner and Makefile (#4861)
Amaan Ullah4673a75b80ab
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.ymlindex c6675888f..c8e13f4f5 100644--- a/.github/workflows/lint.yml+++ b/.github/workflows/lint.yml@@ -20,21 +20,11 @@ jobs:with:go-version: "1.24"- name: golangci-lint- uses: golangci/golangci-lint-action@v6+ uses: golangci/golangci-lint-action@v7with:- # Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version- version: latest- # Optional: working directory, useful for monorepos- # working-directory: somedir-- # Optional: golangci-lint command line arguments.- args: --enable bodyclose --enable copyloopvar --enable misspell --timeout 10m-- # Optional: if set to true then the action don't cache or restore ~/go/pkg.- # skip-pkg-cache: true-- # Optional: if set to true then the action don't cache or restore ~/.cache/go-build.- # skip-build-cache: true+ # NOTE: Version and args must match scripts/lint.sh+ version: v2.11.4+ args: --disable errcheck,staticcheck --enable bodyclose,copyloopvar,misspell --timeout 10msemgrep:name: semgrepruns-on: ubuntu-latestdiff --git a/Makefile b/Makefileindex b0c875900..140e6fc1c 100644--- a/Makefile+++ b/Makefile@@ -22,7 +22,7 @@ check:go vet $(shell go list ./... | grep -v /vendor/)lint:- golangci-lint run --enable bodyclose --enable copyloopvar --enable misspell --out-format=colored-line-number --timeout 10m+ ./scripts/lint.shtest-failing:CGO_ENABLED=0 go test -timeout=5m $(shell go list ./... | grep -v /vendor/) | grep FAILdiff --git a/scripts/lint.sh b/scripts/lint.shnew file mode 100755index 000000000..9e889b2e3--- /dev/null+++ b/scripts/lint.sh@@ -0,0 +1,33 @@+#!/usr/bin/env bash+set -euo pipefail++# NOTE: Version and args must match .github/workflows/lint.yml+GOLANGCI_LINT_VERSION="v2.11.4"++# TODO: Re-enable errcheck and staticcheck once pre-existing issues are resolved.+LINT_ARGS="--disable errcheck,staticcheck --enable bodyclose,copyloopvar,misspell --timeout 10m"++GOBIN="$(go env GOPATH)/bin"+GOLANGCI_LINT="${GOBIN}/golangci-lint"++# Extract and compare the exact version to avoid substring matches (e.g. 2.11.4 matching 2.11.40).+check_version() {+ local bin="$1"+ local installed+ installed=$("${bin}" version 2>&1 | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1)+ [[ "${installed}" == "${GOLANGCI_LINT_VERSION#v}" ]]+}++# Check PATH first, then fall back to GOPATH/bin, otherwise install.+if command -v golangci-lint &>/dev/null && check_version "$(command -v golangci-lint)"; then+ GOLANGCI_LINT="$(command -v golangci-lint)"+ echo "golangci-lint ${GOLANGCI_LINT_VERSION} found at ${GOLANGCI_LINT}"+elif [[ -x "${GOLANGCI_LINT}" ]] && check_version "${GOLANGCI_LINT}"; then+ echo "golangci-lint ${GOLANGCI_LINT_VERSION} found at ${GOLANGCI_LINT}"+else+ echo "Installing golangci-lint ${GOLANGCI_LINT_VERSION}..."+ curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh | sh -s -- -b "${GOBIN}" "${GOLANGCI_LINT_VERSION}"+fi++# shellcheck disable=SC2086+"${GOLANGCI_LINT}" run ${LINT_ARGS}