Find, verify, and analyze leaked credentials
Go credentialsdevsecopsdynamic-analysisprecommitscanningsecretsecret-managementsecretssecuritysecurity-toolstrufflehogverification
Use go 1.22 (#2599)
Dustin Decker41d58739bd32
diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.ymlindex 40077dc16..ab6c60738 100644--- a/.github/workflows/codeql-analysis.yml+++ b/.github/workflows/codeql-analysis.yml@@ -13,12 +13,12 @@ name: "CodeQL"on:push:- branches: [ main ]+ branches: [main]pull_request:# The branches below must be a subset of the branches above- branches: [ main ]+ branches: [main]schedule:- - cron: '35 11 * * 2'+ - cron: "35 11 * * 2"jobs:analyze:@@ -32,39 +32,29 @@ jobs:strategy:fail-fast: falsematrix:- language: [ 'go' ]+ language: ["go"]# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]# Learn more about CodeQL language support at https://git.io/codeql-language-supportsteps:- - name: Checkout repository- uses: actions/checkout@v4-- # Initializes the CodeQL tools for scanning.- - name: Initialize CodeQL- uses: github/codeql-action/init@v3- with:- languages: ${{ matrix.language }}- # If you wish to specify custom queries, you can do so here or in a config file.- # By default, queries listed here will override any specified in a config file.- # Prefix the list here with "+" to use these queries and those in the config file.- # queries: ./path/to/local/query, your-org/your-repo/queries@main-- # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).- # If this step fails, then you should remove it and run the build manually (see below)- - name: Autobuild- uses: github/codeql-action/autobuild@v3-- # ℹ️ Command-line programs to run using the OS shell.- # 📚 https://git.io/JvXDl-- # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines- # and modify them (or add more) to build your code if your project- # uses a compiled language-- #- run: |- # make bootstrap- # make release-- - name: Perform CodeQL Analysis- uses: github/codeql-action/analyze@v3+ - name: Checkout repository+ uses: actions/checkout@v4++ # Initializes the CodeQL tools for scanning.+ - name: Initialize CodeQL+ uses: github/codeql-action/init@v3+ with:+ languages: ${{ matrix.language }}+ # If you wish to specify custom queries, you can do so here or in a config file.+ # By default, queries listed here will override any specified in a config file.+ # Prefix the list here with "+" to use these queries and those in the config file.+ # queries: ./path/to/local/query, your-org/your-repo/queries@main+ - name: Install Go+ uses: actions/setup-go@v5+ with:+ go-version: "1.22"+ - name: Smoke+ run: |+ go build .+ - name: Perform CodeQL Analysis+ uses: github/codeql-action/analyze@v3diff --git a/.github/workflows/detector-tests.yml b/.github/workflows/detector-tests.ymlindex 11e95dd07..361737f66 100644--- a/.github/workflows/detector-tests.yml+++ b/.github/workflows/detector-tests.yml@@ -17,7 +17,7 @@ jobs:- name: Install Gouses: actions/setup-go@v5with:- go-version: "1.21"+ go-version: "1.22"- name: Checkout codeuses: actions/checkout@v4- id: "auth"diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.ymlindex 8f6aa6fd0..bb82778b9 100644--- a/.github/workflows/lint.yml+++ b/.github/workflows/lint.yml@@ -17,7 +17,7 @@ jobs:steps:- uses: actions/setup-go@v5with:- go-version: "1.21"+ go-version: "1.22"- uses: actions/checkout@v4- name: golangci-lintuses: golangci/golangci-lint-action@v4diff --git a/.github/workflows/performance.yml b/.github/workflows/performance.ymlindex 0aae0605d..76fef6288 100644--- a/.github/workflows/performance.yml+++ b/.github/workflows/performance.yml@@ -10,83 +10,83 @@ jobs:runs-on: ubuntu-lateststeps:- - name: Install Go- uses: actions/setup-go@v5- with:- go-version: '1.21'-- - name: Checkout code- uses: actions/checkout@v4- with:- fetch-depth: 0- ref: ${{ github.head_ref }}-- - name: Run Head- run: |- go build -o current .- repo_tmp=$(mktemp -d)- git clone https://github.com/trufflesecurity/trufflehog.git $repo_tmp-- user_time_sum=0-- for i in {1..5}- do- tmpfile=$(mktemp)- /usr/bin/time -o $tmpfile $GITHUB_WORKSPACE/current git "file://$repo_tmp" --no-verification --no-update > out.txt- cat $tmpfile- time_output=$(cat $tmpfile)- rm $tmpfile- user_time=$(echo $time_output | awk '{print $1}' | sed 's/user//')-- # Add the user time to the sum- user_time_sum=$(echo "$user_time_sum + $user_time" | bc)- done-- average_user_time=$(echo "scale=3; $user_time_sum / 5" | bc)- echo HEAD_TIME=$average_user_time >> $GITHUB_ENV-- - name: Figure out previous tag- run: |- git fetch --tags- git tag -l --sort=-v:refname | head -n 1 > previous_tag.txt- echo PREVIOUS_TAG=$(cat previous_tag.txt) >> $GITHUB_ENV-- - name: Checkout code- uses: actions/checkout@v4- with:- fetch-depth: 0- ref: ${{ env.PREVIOUS_TAG }}-- - name: Run Previous- run: |- go build -o previous .- repo_tmp=$(mktemp -d)- git clone https://github.com/trufflesecurity/trufflehog.git $repo_tmp-- user_time_sum=0-- for i in {1..5}- do- tmpfile=$(mktemp)- /usr/bin/time -o $tmpfile $GITHUB_WORKSPACE/previous git "file://$repo_tmp" --no-verification --no-update > out.txt- cat $tmpfile- time_output=$(cat $tmpfile)- rm $tmpfile- user_time=$(echo $time_output | awk '{print $1}' | sed 's/user//')-- # Add the user time to the sum- user_time_sum=$(echo "$user_time_sum + $user_time" | bc)- done-- average_user_time=$(echo "scale=3; $user_time_sum / 5" | bc)- echo PREVIOUS_TIME=$average_user_time >> $GITHUB_ENV-- - name: Compare Results- run: |- echo "head ($GITHUB_SHA) avg time (n=5): $HEAD_TIME"- echo "$PREVIOUS_TAG avg time (n=5): $PREVIOUS_TIME"- if [ $(echo "$HEAD_TIME > $PREVIOUS_TIME * 1.1" | bc) -eq 1 ]- then- echo "HEAD run time is at least 10% slower than PREVIOUS run time"- exit 1- fi+ - name: Install Go+ uses: actions/setup-go@v5+ with:+ go-version: "1.22"++ - name: Checkout code+ uses: actions/checkout@v4+ with:+ fetch-depth: 0+ ref: ${{ github.head_ref }}++ - name: Run Head+ run: |+ go build -o current .+ repo_tmp=$(mktemp -d)+ git clone https://github.com/trufflesecurity/trufflehog.git $repo_tmp++ user_time_sum=0++ for i in {1..5}+ do+ tmpfile=$(mktemp)+ /usr/bin/time -o $tmpfile $GITHUB_WORKSPACE/current git "file://$repo_tmp" --no-verification --no-update > out.txt+ cat $tmpfile+ time_output=$(cat $tmpfile)+ rm $tmpfile+ user_time=$(echo $time_output | awk '{print $1}' | sed 's/user//')++ # Add the user time to the sum+ user_time_sum=$(echo "$user_time_sum + $user_time" | bc)+ done++ average_user_time=$(echo "scale=3; $user_time_sum / 5" | bc)+ echo HEAD_TIME=$average_user_time >> $GITHUB_ENV++ - name: Figure out previous tag+ run: |+ git fetch --tags+ git tag -l --sort=-v:refname | head -n 1 > previous_tag.txt+ echo PREVIOUS_TAG=$(cat previous_tag.txt) >> $GITHUB_ENV++ - name: Checkout code+ uses: actions/checkout@v4+ with:+ fetch-depth: 0+ ref: ${{ env.PREVIOUS_TAG }}++ - name: Run Previous+ run: |+ go build -o previous .+ repo_tmp=$(mktemp -d)+ git clone https://github.com/trufflesecurity/trufflehog.git $repo_tmp++ user_time_sum=0++ for i in {1..5}+ do+ tmpfile=$(mktemp)+ /usr/bin/time -o $tmpfile $GITHUB_WORKSPACE/previous git "file://$repo_tmp" --no-verification --no-update > out.txt+ cat $tmpfile+ time_output=$(cat $tmpfile)+ rm $tmpfile+ user_time=$(echo $time_output | awk '{print $1}' | sed 's/user//')++ # Add the user time to the sum+ user_time_sum=$(echo "$user_time_sum + $user_time" | bc)+ done++ average_user_time=$(echo "scale=3; $user_time_sum / 5" | bc)+ echo PREVIOUS_TIME=$average_user_time >> $GITHUB_ENV++ - name: Compare Results+ run: |+ echo "head ($GITHUB_SHA) avg time (n=5): $HEAD_TIME"+ echo "$PREVIOUS_TAG avg time (n=5): $PREVIOUS_TIME"+ if [ $(echo "$HEAD_TIME > $PREVIOUS_TIME * 1.1" | bc) -eq 1 ]+ then+ echo "HEAD run time is at least 10% slower than PREVIOUS run time"+ exit 1+ fidiff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlindex f6d833c4e..b94e5a0c3 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release.yml@@ -36,7 +36,7 @@ jobs:- name: Set up Gouses: actions/setup-go@v5with:- go-version: '1.21'+ go-version: "1.22"- name: Cosign installuses: sigstore/cosign-installer@e1523de7571e31dbe865fd2e80c5c7c23ae71eb4 # v3.4.0- name: Run GoReleaserdiff --git a/.github/workflows/smoke.yml b/.github/workflows/smoke.ymlindex d96e8d8f4..df89612fb 100644--- a/.github/workflows/smoke.yml+++ b/.github/workflows/smoke.yml@@ -1,4 +1,3 @@-name: Smokeon:@@ -8,14 +7,14 @@ jobs:smoke:runs-on: ubuntu-lateststeps:- - name: Install Go- uses: actions/setup-go@v5- with:- go-version: '1.21'- - name: Checkout code- uses: actions/checkout@v4- - name: Smoke- run: |- set -e- go run . git https://github.com/dustin-decker/secretsandstuff.git- go run . github --repo https://github.com/dustin-decker/secretsandstuff.git+ - name: Install Go+ uses: actions/setup-go@v5+ with:+ go-version: "1.22"+ - name: Checkout code+ uses: actions/checkout@v4+ - name: Smoke+ run: |+ set -e+ go run . git https://github.com/dustin-decker/secretsandstuff.git+ go run . github --repo https://github.com/dustin-decker/secretsandstuff.gitdiff --git a/.github/workflows/snifftest.yml b/.github/workflows/snifftest.ymlindex afa25aca5..a3dddb4b6 100644--- a/.github/workflows/snifftest.yml+++ b/.github/workflows/snifftest.yml@@ -18,7 +18,7 @@ jobs:steps:- uses: actions/setup-go@v5with:- go-version: '1.21'+ go-version: "1.22"- uses: actions/checkout@v4- name: Run Snifftestrun: make snifftestdiff --git a/.github/workflows/test.yml b/.github/workflows/test.ymlindex d2501d611..83edb8d94 100644--- a/.github/workflows/test.yml+++ b/.github/workflows/test.yml@@ -20,7 +20,7 @@ jobs:- name: Install Gouses: actions/setup-go@v5with:- go-version: "1.21"+ go-version: "1.22"- name: Checkout codeuses: actions/checkout@v4- id: "auth"@@ -62,7 +62,7 @@ jobs:- name: Install Gouses: actions/setup-go@v5with:- go-version: "1.21"+ go-version: "1.22"- name: Checkout codeuses: actions/checkout@v4- name: Testdiff --git a/Makefile b/Makefileindex 08faf6be9..917881c47 100644--- a/Makefile+++ b/Makefile@@ -1,4 +1,4 @@-PROTOS_IMAGE ?= trufflesecurity/protos:1.21-1+PROTOS_IMAGE ?= trufflesecurity/protos:1.22.PHONY: check.PHONY: lint@@ -59,7 +59,7 @@ protos-windows:release-protos-image:docker buildx build --push --platform=linux/amd64,linux/arm64 \- -t trufflesecurity/protos:1.21-1 -f hack/Dockerfile.protos .+ -t ${PROTOS_IMAGE} -f hack/Dockerfile.protos .snifftest:./hack/snifftest/snifftest.shdiff --git a/go.mod b/go.modindex eaeea9266..910ed324d 100644--- a/go.mod+++ b/go.mod@@ -1,6 +1,6 @@module github.com/trufflesecurity/trufflehog/v3-go 1.21+go 1.22replace github.com/jpillora/overseer => github.com/trufflesecurity/overseer v1.2.7diff --git a/hack/Dockerfile.protos b/hack/Dockerfile.protosindex f854ac12e..0a42c5f2a 100644--- a/hack/Dockerfile.protos+++ b/hack/Dockerfile.protos@@ -1,24 +1,35 @@-# trufflesecurity/protos:1.18-0+# trufflesecurity/protos:1.22FROM golang:1.22-bullseyeARG TARGETARCHARG TARGETOS-ENV PROTOC_VER=3.20.0-ENV GORELEASER_VER=v1.7.0-ENV SQLBOILER_VER=v4.9.0-ENV PROTOC_GEN_GO_VER=v1.5.2++ENV PROTOC_VER=25.3+ENV PROTOC_GEN_GO_VER=v1.5.4+ENV PROTOC_GEN_VALIDATE_VER=v1.0.4+ENV GORELEASER_VERSION=1.19.2RUN echo "building $TARGETARCH"-RUN apt-get update; apt-get install -y --no-install-recommends git unzip && rm -rf /var/lib/apt/lists/*+RUN go install github.com/dustin-decker/quill/cmd/[email protected]+RUN apt-get update; apt-get install apt-transport-https ca-certificates curl gnupg lsb-release -y; \+ curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg; \+ echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian \+ $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null; \+ apt-get update; apt-get install -y --no-install-recommends python3-pip docker-ce-cli docker-buildx-plugin docker-compose-plugin \+ git netbase wget upx unzip && rm -rf /var/lib/apt/lists/*+RUN pip3 install --upgrade setuptools pipRUN set -e; \arch=$(echo $TARGETARCH | sed -e s/amd64/x86_64/ -e s/arm64/aarch_64/); \wget -q https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VER}/protoc-${PROTOC_VER}-${TARGETOS}-${arch}.zip && unzip protoc-${PROTOC_VER}-${TARGETOS}-${arch}.zip -d /usr/local+RUN curl -fsSL https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -; echo "deb https://packages.cloud.google.com/apt cloud-sdk main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list; apt-get update; apt-get install -y google-cloud-cli+RUN echo 'deb [trusted=yes] https://repo.goreleaser.com/apt/ /' | tee /etc/apt/sources.list.d/goreleaser.list; \+ apt-get update; apt-get install -y goreleaser=${GORELEASER_VERSION} && rm -rf /var/lib/apt/lists/*RUN go install "github.com/golang/protobuf/protoc-gen-go@${PROTOC_GEN_GO_VER}"-RUN GO111MODULE=off go get -d "github.com/envoyproxy/protoc-gen-validate" && \+RUN go install gotest.tools/gotestsum@latest+RUN git clone https://github.com/envoyproxy/protoc-gen-validate $GOPATH/src/github.com/envoyproxy/protoc-gen-validate && \cd $GOPATH/src/github.com/envoyproxy/protoc-gen-validate && \- git checkout v0.6.7 && \+ git checkout ${PROTOC_GEN_VALIDATE_VER} && \ln -s /usr/local/protoc/include/google google && \make build-RUN go install github.com/chrusty/protoc-gen-jsonschema/cmd/protoc-gen-jsonschema@latestCMD ["bash"]