From 397bb9b2543133e7346e5b00edee28de64ddf595 Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Thu, 22 Jun 2023 09:28:48 +0100 Subject: [PATCH 01/80] refresh --- .goreleaser.yml | 6 +++--- .pre-commit-config.yaml | 13 +++++++++++-- README.md | 8 ++++---- go.mod | 2 +- go.sum | 4 ++-- 5 files changed, 21 insertions(+), 12 deletions(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index 1d4ed6e..a86746e 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -10,13 +10,13 @@ builds: - linux - windows goarch: - - 386 + - "386" - amd64 - arm64 goarm: - - 7 + - "7" ignore: - - goarch: 386 + - goarch: "386" goos: darwin archives: - format_overrides: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 01bf506..286b2f9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -29,7 +29,7 @@ repos: hooks: - id: shell-lint - repo: https://github.com/igorshubovych/markdownlint-cli - rev: v0.34.0 + rev: v0.35.0 hooks: - id: markdownlint exclude: src/testdata|testdata @@ -55,8 +55,17 @@ repos: hooks: - id: golangci-lint - repo: https://github.com/bridgecrewio/checkov - rev: 2.3.294 + rev: 2.3.300 hooks: - id: checkov language_version: python3.10 args: ["-d", "."] + - repo: local + hooks: + - id: ghat-go + name: ghat + description: upgrade action dependencies + language: golang + entry: ghat swot -d . + pass_filenames: false + types: [ yaml ] \ No newline at end of file diff --git a/README.md b/README.md index fe0c34d..70b78a0 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ Becomes uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 ``` -Ghat will use your Github creds, if available, from your environment using the environmental variables GITHUB_TOKEN or GITHUB_API, but it can also drop back to anonymous access, the drawback is that this is severely rate limited by gitHub. +Ghat will use your GitHub creds, if available, from your environment using the environmental variables GITHUB_TOKEN or GITHUB_API, but it can also drop back to anonymous access, the drawback is that this is severely rate limited by gitHub. ## Table of Contents @@ -106,11 +106,11 @@ docker run --tty --volume /local/path/to/tf:/tf jameswoolfenden/ghat scan -d /tf ## Usage -To authenticate the GitHub Api you should set-up your GitHub Personal Access Token as the environment variable -*GITHUB_API* or *GITHUB_TOKEN*, it will fall back to using anonymous if you dont but RATE LIMITS. +To authenticate the GitHub Api you should setup your GitHub Personal Access Token as the environment variable +*GITHUB_API* or *GITHUB_TOKEN*, it will fall back to using anonymous if you don't but RATE LIMITS. ### Directory scan -This will look for the .github/worflow folder and update all the files it find there, and display a diff of the changes made to each file: +This will look for the .github/worflow folder and update all the files it finds there, and display a diff of the changes made to each file: ```bash $ghat swot -d . diff --git a/go.mod b/go.mod index 081147d..b3f67db 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.20 require ( github.com/rs/zerolog v1.29.1 github.com/sergi/go-diff v1.3.1 - github.com/urfave/cli/v2 v2.25.6 + github.com/urfave/cli/v2 v2.25.7 ) require ( diff --git a/go.sum b/go.sum index b047071..eb121fe 100644 --- a/go.sum +++ b/go.sum @@ -28,8 +28,8 @@ github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NF github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/urfave/cli/v2 v2.25.6 h1:yuSkgDSZfH3L1CjF2/5fNNg2KbM47pY2EvjBq4ESQnU= -github.com/urfave/cli/v2 v2.25.6/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= +github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs= +github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= From 2cc63d844d819230448ff794c2b17ca94e8ce8e3 Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Thu, 22 Jun 2023 09:37:17 +0100 Subject: [PATCH 02/80] with working hook --- .github/workflows/release.yml | 2 +- .pre-commit-config.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 097c5c1..ddba303 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -50,7 +50,7 @@ jobs: password: ${{ secrets.DOCKERHUB_PASSWORD }} tags: "latest,${{ github.ref_name }}" - name: Update Docker Hub README - uses: peter-evans/dockerhub-description@579f64ca0abced29dbbc44ab4c6a0b9e33ab3588 # v3.4.1 + uses: peter-evans/dockerhub-description@dc67fad7001ef9e8e3c124cb7a64e16d0a63d864 # v3.4.2 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 286b2f9..d8ca05e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -68,4 +68,4 @@ repos: language: golang entry: ghat swot -d . pass_filenames: false - types: [ yaml ] \ No newline at end of file + types: [ yaml ] From c84d0299294918791175d896bdb677fdbe0762ff Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Thu, 22 Jun 2023 16:34:35 +0100 Subject: [PATCH 03/80] update docs with example and pre-commit --- README.md | 62 +++++++++++++++++++++++++++++++----------- src/core/files_test.go | 5 ++++ 2 files changed, 51 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 70b78a0..f17ab76 100644 --- a/README.md +++ b/README.md @@ -110,7 +110,8 @@ To authenticate the GitHub Api you should setup your GitHub Personal Access Toke *GITHUB_API* or *GITHUB_TOKEN*, it will fall back to using anonymous if you don't but RATE LIMITS. ### Directory scan -This will look for the .github/worflow folder and update all the files it finds there, and display a diff of the changes made to each file: + +This will look for the .github/workflow folder and update all the files it finds there, and display a diff of the changes made to each file: ```bash $ghat swot -d . @@ -118,34 +119,61 @@ $ghat swot -d . ### Individual file scan -``` +```bash $ghat swot -f .\.github\workflows\ci.yml ``` +### Stable releases + +If you're concerned that the very latest release might be too fresh, and would rather have the latest from 2 weeks ago? +I got you covered: + +```bash +$ghat swot -d . --stable 14 +``` + ## Help ```bash -./ghat -h + ghat swot -h NAME: - ghat - Update GHA dependencies + ghat swot - updates GHA in a directory USAGE: - ghat [global options] command [command options] [arguments...] + ghat swot -VERSION: - 9.9.9 +OPTIONS: + authentication -AUTHOR: - James Woolfenden + --token value, -t value Github PAT token [$GITHUB_TOKEN, $GITHUB_API] -COMMANDS: - swot, a updates GHA in a directory - version, v Outputs the application version - help, h Shows a list of commands or help for one command + delay -GLOBAL OPTIONS: - --help, -h show help - --version, -v print the version + --stable value, -s value days to wait for stabilisation of release (default: 0) + + files + + --directory value, -d value Destination to update GHAs (default: ".") + --file value, -f value GHA file to parse + +``` + +### pre-commit + +I've added a number of pre-commit hooks to this repo that will update your build configs, +update .pre-commit-config.yaml + +```yaml + - repo: https://github.com/JamesWoolfenden/ghat/actions + rev: v0.0.10 + hooks: + - id: ghat-go + name: ghat + description: upgrade action dependencies + language: golang + entry: ghat swot -d . + pass_filenames: false + types: [ yaml ] ``` @@ -162,3 +190,5 @@ Make build ``` ## Extending + +Log an issue, a pr or send an email to jim.wolf @ duck.com. diff --git a/src/core/files_test.go b/src/core/files_test.go index 38f2845..8475271 100644 --- a/src/core/files_test.go +++ b/src/core/files_test.go @@ -99,10 +99,13 @@ func TestGetGHA(t *testing.T) { } func TestGetBody(t *testing.T) { + t.Parallel() + type args struct { gitHubToken string url string } + tests := []struct { name string args args @@ -112,7 +115,9 @@ func TestGetBody(t *testing.T) { // TODO: Add test cases. } for _, tt := range tests { + tt := tt t.Run(tt.name, func(t *testing.T) { + t.Parallel() got, err := GetBody(tt.args.gitHubToken, tt.args.url) if (err != nil) != tt.wantErr { t.Errorf("GetBody() error = %v, wantErr %v", err, tt.wantErr) From 270430609b886202a4f43c50e0cfa3cc726ab390 Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Fri, 23 Jun 2023 08:23:47 +0100 Subject: [PATCH 04/80] always run --- .pre-commit-config.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d8ca05e..76d5135 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -68,4 +68,5 @@ repos: language: golang entry: ghat swot -d . pass_filenames: false + always_run: true types: [ yaml ] From 4406c66eee0d9501269fe4b41369e51ecc294f67 Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Tue, 27 Jun 2023 15:36:58 -0700 Subject: [PATCH 05/80] stale action --- .github/stale.yml | 18 ------------------ .github/workflows/codeql-analysis.yml | 9 +++++---- .github/workflows/pr.yml | 4 ++-- .github/workflows/release.yml | 4 ++-- .github/workflows/stale.yml | 23 +++++++++++++++++++++++ 5 files changed, 32 insertions(+), 26 deletions(-) delete mode 100644 .github/stale.yml create mode 100644 .github/workflows/stale.yml diff --git a/.github/stale.yml b/.github/stale.yml deleted file mode 100644 index 4687cbc..0000000 --- a/.github/stale.yml +++ /dev/null @@ -1,18 +0,0 @@ -# Number of days of inactivity before an issue becomes stale -daysUntilStale: 30 -# Number of days of inactivity before a stale issue is closed -daysUntilClose: 7 -# Issues with these labels will never be considered stale -exemptLabels: - - pinned - - security - - enhancement -# Label to use when marking an issue as stale -staleLabel: wontfix -# Comment to post when marking an issue as stale. Set to `false` to disable -markComment: > - This issue has been automatically marked as stale because it has not had - recent activity. It will be closed if no further activity occurs. Thank you - for your contributions. -# Comment to post when closing a stale issue. Set to `false` to disable -closeComment: false diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index ffd549a..82d007a 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -19,6 +19,7 @@ on: branches: [ "master" ] schedule: - cron: '36 4 * * 0' +permissions: read-all jobs: analyze: @@ -32,7 +33,7 @@ jobs: strategy: fail-fast: false matrix: - language: [ 'go', 'javascript' ] + language: [ 'go' ] # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support @@ -42,7 +43,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@1245696032ecf7d39f87d54daa406e22ddf769a8 # codeql-bundle-20230524 + uses: github/codeql-action/init@cdcdbb579706841c47f7063dda365e292e5cad7a # codeql-bundle-v2.13.4 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -52,7 +53,7 @@ jobs: # 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@1245696032ecf7d39f87d54daa406e22ddf769a8 # codeql-bundle-20230524 + uses: github/codeql-action/autobuild@cdcdbb579706841c47f7063dda365e292e5cad7a # codeql-bundle-v2.13.4 # â„šī¸ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun @@ -65,4 +66,4 @@ jobs: # ./location_of_script_within_repo/buildscript.sh - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@1245696032ecf7d39f87d54daa406e22ddf769a8 # codeql-bundle-20230524 + uses: github/codeql-action/analyze@cdcdbb579706841c47f7063dda365e292e5cad7a # codeql-bundle-v2.13.4 diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index a47957b..69c3092 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -20,8 +20,8 @@ jobs: key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} restore-keys: | ${{ runner.os }}-go-mod- - - name: Fmt - run: make fmt + - name: gofumpt + uses: iamnotaturtle/auto-gofmt@3934ab53013ffb44d3db33bbd1c271279b5925d5 # v2.1.0 test: strategy: matrix: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ddba303..e96597d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,5 +1,5 @@ --- -name: release +name: Release on: push: tags: @@ -17,7 +17,7 @@ jobs: - name: Set up Go uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1 with: - go-version: 1.19 + go-version: 1.20 - name: Import GPG key id: import_gpg uses: crazy-max/ghaction-import-gpg@72b6676b71ab476b77e676928516f6982eef7a41 # v5.3.0 diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml new file mode 100644 index 0000000..d75d877 --- /dev/null +++ b/.github/workflows/stale.yml @@ -0,0 +1,23 @@ +name: 'Stale' +on: + schedule: + - cron: '30 1 * * *' + workflow_dispatch: +permissions: read-all + +jobs: + stale: + permissions: + contents: write + issues: write + pull-requests: write + runs-on: ubuntu-latest + steps: + - uses: actions/stale@1160a2240286f5da8ec72b1c0816ce2481aabf84 # v8.0.0 + with: + stale-issue-message: 'This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.' + days-before-stale: 30 + days-before-close: 5 + enable-statistics: true + exempt-issue-labels: enhancement + exempt-pr-labels: enhancement From 98888a4e739dbcd94eb6e475357f3a3e557c2343 Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Thu, 29 Jun 2023 12:34:58 -0700 Subject: [PATCH 06/80] add label --- Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index a61a4fa..08142e0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,3 +7,5 @@ COPY entrypoint.sh /entrypoint.sh # Code file to execute when the docker container starts up (`entrypoint.sh`) ENTRYPOINT ["/entrypoint.sh"] + +LABEL layer.0.author="JamesWoolfenden" From 8aeb7359449974e5a9d7fc574637ba0b4a5b90d2 Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Thu, 29 Jun 2023 14:44:44 -0700 Subject: [PATCH 07/80] add label --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 08142e0..e7936c3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ -FROM alpine +FROM alpine:3.18.2 RUN apk --no-cache add build-base git curl jq bash -RUN curl -s -k https://api.github.com/repos/JamesWoolfenden/ghat/releases/latest | jq '.assets[] | select(.name | contains("linux_386")) | select(.content_type | contains("gzip")) | .browser_download_url' -r | awk '{print "curl -L -k " $0 " -o ./ghat.tar.gz"}' | sh +RUN curl -s https://api.github.com/repos/JamesWoolfenden/ghat/releases/latest | jq '.assets[] | select(.name | contains("linux_386")) | select(.content_type | contains("gzip")) | .browser_download_url' -r | awk '{print "curl -L -k " $0 " -o ./ghat.tar.gz"}' | sh RUN tar -xf ./ghat.tar.gz -C /usr/bin/ && rm ./ghat.tar.gz && chmod +x /usr/bin/ghat && echo 'alias ghat="/usr/bin/ghat"' >> ~/.bashrc COPY entrypoint.sh /entrypoint.sh From 3da23acf92012be766b4c910af92939ca61ff266 Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Thu, 29 Jun 2023 14:47:11 -0700 Subject: [PATCH 08/80] drop to 1.19 --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e96597d..a74574f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,7 +17,7 @@ jobs: - name: Set up Go uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1 with: - go-version: 1.20 + go-version: 1.19 - name: Import GPG key id: import_gpg uses: crazy-max/ghaction-import-gpg@72b6676b71ab476b77e676928516f6982eef7a41 # v5.3.0 From a767345a5599f8e227268195e2f4246f1b71041a Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Tue, 4 Jul 2023 10:35:50 +0100 Subject: [PATCH 09/80] cope with uses:file --- src/core/files.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/core/files.go b/src/core/files.go index 41fb842..787a6f3 100644 --- a/src/core/files.go +++ b/src/core/files.go @@ -2,6 +2,7 @@ package core import ( "encoding/json" + "errors" "fmt" "io" "net/http" @@ -84,6 +85,12 @@ func UpdateFile(file *string, gitHubToken string, days *int) error { r := regexp.MustCompile(`uses:(.*)`) matches := r.FindAllStringSubmatch(string(buffer), -1) for _, match := range matches { + + //is path + if strings.Contains(match[1], ".github") { + continue + } + action := strings.Split(match[1], "@") action[0] = strings.TrimSpace(action[0]) @@ -100,7 +107,11 @@ func UpdateFile(file *string, gitHubToken string, days *int) error { } } - msg := body.(map[string]interface{}) + msg, ok := body.(map[string]interface{}) + + if !ok { + return errors.New("failed to assert map[string]interface{}") + } if msg["tag_name"] != nil { tag := msg["tag_name"].(string) From 7a76253abfe0b2f264c9fbca46bc48bf6eaf29ad Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Thu, 3 Aug 2023 14:58:17 +0100 Subject: [PATCH 10/80] object oriented (a bit) now with dry-run --- .github/workflows/codeql-analysis.yml | 6 +- README.md | 11 +- main.go | 29 ++-- src/core/files.go | 43 +++--- src/core/files_test.go | 198 ++++++++++++++------------ src/core/types.go | 9 ++ 6 files changed, 168 insertions(+), 128 deletions(-) create mode 100644 src/core/types.go diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 82d007a..7e6e0b9 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -43,7 +43,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@cdcdbb579706841c47f7063dda365e292e5cad7a # codeql-bundle-v2.13.4 + uses: github/codeql-action/init@7b6664fa89524ee6e3c3e9749402d5afd69b3cd8 # codeql-bundle-v2.14.1 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -53,7 +53,7 @@ jobs: # 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@cdcdbb579706841c47f7063dda365e292e5cad7a # codeql-bundle-v2.13.4 + uses: github/codeql-action/autobuild@7b6664fa89524ee6e3c3e9749402d5afd69b3cd8 # codeql-bundle-v2.14.1 # â„šī¸ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun @@ -66,4 +66,4 @@ jobs: # ./location_of_script_within_repo/buildscript.sh - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@cdcdbb579706841c47f7063dda365e292e5cad7a # codeql-bundle-v2.13.4 + uses: github/codeql-action/analyze@7b6664fa89524ee6e3c3e9749402d5afd69b3cd8 # codeql-bundle-v2.14.1 diff --git a/README.md b/README.md index f17ab76..1777eec 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,10 @@ Ghat will use your GitHub creds, if available, from your environment using the e - [Windows](#windows) - [Docker](#docker) - [Usage](#usage) + - [directory](#directory-scan) + - [file](#file-scan) + - [stable](#stable-releases) + - [pre-commit](#pre-commit) @@ -99,14 +103,14 @@ scoop install ghat ```shell docker pull jameswoolfenden/ghat -docker run --tty --volume /local/path/to/tf:/tf jameswoolfenden/ghat scan -d /tf +docker run --tty --volume /local/path/to/repo:/repo jameswoolfenden/ghat swot -d /repo ``` ## Usage -To authenticate the GitHub Api you should setup your GitHub Personal Access Token as the environment variable +To authenticate the GitHub Api you should set up your GitHub Personal Access Token as the environment variable *GITHUB_API* or *GITHUB_TOKEN*, it will fall back to using anonymous if you don't but RATE LIMITS. ### Directory scan @@ -117,7 +121,7 @@ This will look for the .github/workflow folder and update all the files it finds $ghat swot -d . ``` -### Individual file scan +### File scan ```bash $ghat swot -f .\.github\workflows\ci.yml @@ -173,6 +177,7 @@ update .pre-commit-config.yaml language: golang entry: ghat swot -d . pass_filenames: false + always_run: true types: [ yaml ] ``` diff --git a/main.go b/main.go index 0ee5bb3..17add6e 100644 --- a/main.go +++ b/main.go @@ -16,16 +16,11 @@ import ( func main() { log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr}) - var file string - - var directory string - - var gitHubToken string - - var days int + var myFlags core.Flags app := &cli.App{ EnableBashCompletion: true, + Copyright: "James Woolfenden", Flags: []cli.Flag{}, Commands: []*cli.Command{ { @@ -46,13 +41,13 @@ func main() { UsageText: "ghat swot", Action: func(*cli.Context) error { - if file != "" { - err := core.UpdateFile(&file, gitHubToken, &days) + if myFlags.File != "" { + err := myFlags.UpdateFile() if err != nil { return err } } else { - _, err := core.Files(&directory, gitHubToken, &days) + _, err := myFlags.Files() if err != nil { return err } @@ -65,7 +60,7 @@ func main() { Name: "file", Aliases: []string{"f"}, Usage: "GHA file to parse", - Destination: &file, + Destination: &myFlags.File, Category: "files", }, &cli.StringFlag{ @@ -73,7 +68,7 @@ func main() { Aliases: []string{"d"}, Usage: "Destination to update GHAs", Value: ".", - Destination: &directory, + Destination: &myFlags.Directory, Category: "files", }, &cli.IntFlag{ @@ -81,7 +76,7 @@ func main() { Aliases: []string{"s"}, Usage: "days to wait for stabilisation of release", Value: 0, - Destination: &days, + Destination: &myFlags.Days, DefaultText: "0", Category: "delay", }, @@ -89,10 +84,16 @@ func main() { Name: "token", Aliases: []string{"t"}, Usage: "Github PAT token", - Destination: &gitHubToken, + Destination: &myFlags.GitHubToken, Category: "authentication", EnvVars: []string{"GITHUB_TOKEN", "GITHUB_API"}, }, + &cli.BoolFlag{ + Name: "dry-run", + Usage: "show but don't write changes", + Destination: &myFlags.DryRun, + Value: false, + }, }, }, }, diff --git a/src/core/files.go b/src/core/files.go index 787a6f3..a0e68b5 100644 --- a/src/core/files.go +++ b/src/core/files.go @@ -16,24 +16,24 @@ import ( ) // Files updates all actions in a directory. -func Files(directory *string, gitHubToken string, days *int) ([]os.DirEntry, error) { +func (myFlags *Flags) Files() ([]os.DirEntry, error) { - matches, err := os.ReadDir(*directory) + matches, err := os.ReadDir(myFlags.Directory) if err != nil { - log.Error().Msgf("failed to read %s", *directory) + log.Error().Msgf("failed to read %s", myFlags.Directory) } var ghat []os.DirEntry - entries, directory, err2 := GetGHA(directory, matches, ghat) + entries, err2 := myFlags.GetGHA(matches, ghat) if err2 != nil { return entries, err2 } for _, gha := range entries { - file := filepath.Join(*directory, gha.Name()) - err = UpdateFile(&file, gitHubToken, days) + myFlags.File = filepath.Join(myFlags.Directory, gha.Name()) + err = myFlags.UpdateFile() if err != nil { log.Warn().Msgf("failed to update %s", gha.Name()) @@ -44,21 +44,22 @@ func Files(directory *string, gitHubToken string, days *int) ([]os.DirEntry, err } // GetGHA gets all the actions in a directory -func GetGHA(directory *string, matches []os.DirEntry, ghat []os.DirEntry) ([]os.DirEntry, *string, error) { +func (myFlags *Flags) GetGHA(matches []os.DirEntry, ghat []os.DirEntry) ([]os.DirEntry, error) { for _, match := range matches { if match.IsDir() { if strings.Contains(match.Name(), ".github") { log.Print(match.Name()) - AbsDir, _ := filepath.Abs(*directory) + AbsDir, _ := filepath.Abs(myFlags.Directory) newDirectory := filepath.Join(AbsDir, match.Name(), "workflows") if _, err := os.Stat(newDirectory); err == nil { ghat, err = os.ReadDir(newDirectory) + myFlags.Directory = newDirectory if err != nil { - return nil, &newDirectory, fmt.Errorf("no files found %w", err) + return nil, fmt.Errorf("no files found %w", err) } - return ghat, &newDirectory, nil + return ghat, nil } } } else { @@ -68,12 +69,12 @@ func GetGHA(directory *string, matches []os.DirEntry, ghat []os.DirEntry) ([]os. } } - return ghat, directory, nil + return ghat, nil } // UpdateFile updates am action with latest dependencies -func UpdateFile(file *string, gitHubToken string, days *int) error { - buffer, err := os.ReadFile(*file) +func (myFlags *Flags) UpdateFile() error { + buffer, err := os.ReadFile(myFlags.File) replacement := string(buffer) var newUrl string @@ -94,12 +95,12 @@ func UpdateFile(file *string, gitHubToken string, days *int) error { action := strings.Split(match[1], "@") action[0] = strings.TrimSpace(action[0]) - body, err2 := getPayload(action[0], gitHubToken, days) + body, err2 := getPayload(action[0], myFlags.GitHubToken, &myFlags.Days) if err2 != nil { splitter := strings.SplitN(action[0], "/", 3) newUrl = splitter[0] + "/" + splitter[1] - body, err2 = getPayload(newUrl, gitHubToken, days) + body, err2 = getPayload(newUrl, myFlags.GitHubToken, &myFlags.Days) if err2 != nil { log.Warn().Msgf("failed to retrieve back %s", err2) @@ -122,7 +123,7 @@ func UpdateFile(file *string, gitHubToken string, days *int) error { url = newUrl } - payload, err := getHash(url, tag, gitHubToken) + payload, err := getHash(url, tag, myFlags.GitHubToken) body := payload.(map[string]interface{}) if err != nil { @@ -156,12 +157,14 @@ func UpdateFile(file *string, gitHubToken string, days *int) error { fmt.Println(dmp.DiffPrettyText(diffs)) - newBuffer := []byte(replacement) + if !myFlags.DryRun { + newBuffer := []byte(replacement) - err = os.WriteFile(*file, newBuffer, 0644) + err = os.WriteFile(myFlags.File, newBuffer, 0644) - if err != nil { - return fmt.Errorf("failed to write err %w", err) + if err != nil { + return fmt.Errorf("failed to write err %w", err) + } } return nil diff --git a/src/core/files_test.go b/src/core/files_test.go index 8475271..b44aa80 100644 --- a/src/core/files_test.go +++ b/src/core/files_test.go @@ -8,102 +8,73 @@ import ( var gitHubToken = os.Getenv("GITHUB_TOKEN") -func TestFiles(t *testing.T) { +func TestGetBody(t *testing.T) { t.Parallel() type args struct { - directory *string - days *int + gitHubToken string + url string } - dir := "testdata/files/" - bogus := "testdata/bogus/" - empty := "testdata/empty" - - var zero = 0 - tests := []struct { name string args args - want []os.DirEntry + want interface{} wantErr bool }{ - {"Pass", args{&dir, &zero}, nil, false}, - {"Bogus", args{&bogus, &zero}, nil, false}, - {"Empty", args{&empty, &zero}, nil, false}, + // TODO: Add test cases. } - for _, tt := range tests { tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() - got, err := Files(tt.args.directory, gitHubToken, tt.args.days) + got, err := GetBody(tt.args.gitHubToken, tt.args.url) if (err != nil) != tt.wantErr { - t.Errorf("Files() error = %v, wantErr %v", err, tt.wantErr) + t.Errorf("GetBody() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(got, tt.want) { - t.Errorf("Files() got = %v, want %v", got, tt.want) + t.Errorf("GetBody() got = %v, want %v", got, tt.want) } }) } } -func TestGetGHA(t *testing.T) { - t.Parallel() - +func Test_getHash(t *testing.T) { type args struct { - directory *string - matches []os.DirEntry - ghat []os.DirEntry + action string + tag string + gitHubToken string } - - duffDir := "nothere" - nomatches, _ := os.ReadDir(duffDir) - - noworkflowsdir := "./testdata/noworkflows" - noworkflows, _ := os.ReadDir(noworkflowsdir) - - noworkflowswithdir := "./testdata/noworkflowswithdir" - noworkflowswithdircontents, _ := os.ReadDir(noworkflowswithdir) - tests := []struct { name string args args - want []os.DirEntry - want1 *string + want interface{} wantErr bool }{ - {"no matches", args{&duffDir, nomatches, nil}, nil, &duffDir, false}, - {"no workflows", args{&noworkflowsdir, noworkflows, nil}, nil, &noworkflowsdir, false}, - {"no workflows with dir", args{&noworkflowswithdir, noworkflowswithdircontents, nil}, nil, &noworkflowswithdir, false}, + // TODO: Add test cases. } - for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { - got, got1, err := GetGHA(tt.args.directory, tt.args.matches, tt.args.ghat) - t.Parallel() + got, err := getHash(tt.args.action, tt.args.tag, tt.args.gitHubToken) if (err != nil) != tt.wantErr { - t.Errorf("GetGHA() error = %v, wantErr %v", err, tt.wantErr) + t.Errorf("getHash() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(got, tt.want) { - t.Errorf("GetGHA() got = %v, want %v", got, tt.want) - } - if !reflect.DeepEqual(got1, tt.want1) { - t.Errorf("GetGHA() got1 = %v, want %v", got1, tt.want1) + t.Errorf("getHash() got = %v, want %v", got, tt.want) } }) } } -func TestGetBody(t *testing.T) { +func Test_getPayload(t *testing.T) { t.Parallel() type args struct { + action string gitHubToken string - url string + days *int } tests := []struct { @@ -118,96 +89,147 @@ func TestGetBody(t *testing.T) { tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() - got, err := GetBody(tt.args.gitHubToken, tt.args.url) + got, err := getPayload(tt.args.action, tt.args.gitHubToken, tt.args.days) if (err != nil) != tt.wantErr { - t.Errorf("GetBody() error = %v, wantErr %v", err, tt.wantErr) + t.Errorf("getPayload() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(got, tt.want) { - t.Errorf("GetBody() got = %v, want %v", got, tt.want) + t.Errorf("getPayload() got = %v, want %v", got, tt.want) } }) } } -func TestUpdateFile(t *testing.T) { - type args struct { - file *string - gitHubToken string - days *int +func TestFlags_Files(t *testing.T) { + + type fields struct { + File string + Directory string + GitHubToken string + Days int + DryRun bool } + + dir := fields{"", "testdata/files/", gitHubToken, 0, false} + bogus := fields{"", "testdata/bogus/", gitHubToken, 0, false} + empty := fields{"", "testdata/empty", gitHubToken, 0, false} + dirDry := fields{"", "testdata/files/", gitHubToken, 0, true} + tests := []struct { name string - args args + fields fields + want []os.DirEntry wantErr bool }{ - // TODO: Add test cases. + {"Pass", dir, nil, false}, + {"Bogus", bogus, nil, false}, + {"Empty", empty, nil, false}, + {"dirDry", dirDry, nil, false}, } + for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if err := UpdateFile(tt.args.file, tt.args.gitHubToken, tt.args.days); (err != nil) != tt.wantErr { - t.Errorf("UpdateFile() error = %v, wantErr %v", err, tt.wantErr) + myFlags := &Flags{ + File: tt.fields.File, + Directory: tt.fields.Directory, + GitHubToken: tt.fields.GitHubToken, + Days: tt.fields.Days, + DryRun: tt.fields.DryRun, + } + got, err := myFlags.Files() + if (err != nil) != tt.wantErr { + t.Errorf("Files() error = %v, wantErr %v", err, tt.wantErr) + return + } + if !reflect.DeepEqual(got, tt.want) { + t.Errorf("Files() got = %v, want %v", got, tt.want) } }) } } -func Test_getHash(t *testing.T) { +func TestFlags_GetGHA(t *testing.T) { + type fields struct { + File string + Directory string + GitHubToken string + Days int + DryRun bool + } + type args struct { - action string - tag string - gitHubToken string + matches []os.DirEntry + ghat []os.DirEntry } + + duffDir := fields{"", "nothere", gitHubToken, 0, false} + noMatches, _ := os.ReadDir(duffDir.Directory) + + noWorkflowsDir := fields{"", "./testdata/noworkflows", gitHubToken, 0, false} + noWorkflows, _ := os.ReadDir(noWorkflowsDir.Directory) + + noWorkflowsWithDir := fields{"", "./testdata/noworkflowswithdir", gitHubToken, 0, false} + noWorkflowsWithDirContents, _ := os.ReadDir(noWorkflowsWithDir.Directory) + tests := []struct { name string + fields fields args args - want interface{} + want []os.DirEntry wantErr bool }{ - // TODO: Add test cases. + {"no matches", duffDir, args{noMatches, nil}, nil, false}, + {"no workflows", noWorkflowsDir, args{noWorkflows, nil}, nil, false}, + {"no workflows with dir", noWorkflowsWithDir, args{noWorkflowsWithDirContents, nil}, nil, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - got, err := getHash(tt.args.action, tt.args.tag, tt.args.gitHubToken) + myFlags := &Flags{ + File: tt.fields.File, + Directory: tt.fields.Directory, + GitHubToken: tt.fields.GitHubToken, + Days: tt.fields.Days, + DryRun: tt.fields.DryRun, + } + got, err := myFlags.GetGHA(tt.args.matches, tt.args.ghat) if (err != nil) != tt.wantErr { - t.Errorf("getHash() error = %v, wantErr %v", err, tt.wantErr) + t.Errorf("GetGHA() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(got, tt.want) { - t.Errorf("getHash() got = %v, want %v", got, tt.want) + t.Errorf("GetGHA() got = %v, want %v", got, tt.want) } }) } } -func Test_getPayload(t *testing.T) { - t.Parallel() - - type args struct { - action string - gitHubToken string - days *int +func TestFlags_UpdateFile(t *testing.T) { + type fields struct { + File string + Directory string + GitHubToken string + Days int + DryRun bool } - tests := []struct { name string - args args - want interface{} + fields fields wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { - t.Parallel() - got, err := getPayload(tt.args.action, tt.args.gitHubToken, tt.args.days) - if (err != nil) != tt.wantErr { - t.Errorf("getPayload() error = %v, wantErr %v", err, tt.wantErr) - return + myFlags := &Flags{ + File: tt.fields.File, + Directory: tt.fields.Directory, + GitHubToken: tt.fields.GitHubToken, + Days: tt.fields.Days, + DryRun: tt.fields.DryRun, } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("getPayload() got = %v, want %v", got, tt.want) + if err := myFlags.UpdateFile(); (err != nil) != tt.wantErr { + t.Errorf("UpdateFile() error = %v, wantErr %v", err, tt.wantErr) } }) } diff --git a/src/core/types.go b/src/core/types.go new file mode 100644 index 0000000..4142add --- /dev/null +++ b/src/core/types.go @@ -0,0 +1,9 @@ +package core + +type Flags struct { + File string + Directory string + GitHubToken string + Days int + DryRun bool +} From a3550ead2db60591709c629c46a6d80ef5828740 Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Thu, 3 Aug 2023 15:15:37 +0100 Subject: [PATCH 11/80] fix test --- src/core/filter_test.go | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/src/core/filter_test.go b/src/core/filter_test.go index ff7d01b..6774655 100644 --- a/src/core/filter_test.go +++ b/src/core/filter_test.go @@ -16,7 +16,45 @@ func TestGetReleases(t *testing.T) { delay := 14 zero := 0 var empty map[string]interface{} - var want map[string]interface{} + want := map[string]interface{}{ + "tarball_url": "https: //api.github.com/repos/JamesWoolfenden/test-data-action/tarball/v0.0.1", + "zipball_url": "https: //api.github.com/repos/JamesWoolfenden/test-data-action/zipball/v0.0.1", + "assets_url": "https: //api.github.com/repos/JamesWoolfenden/test-data-action/releases/109328421/assets", + "id": 109328421, + "draft": false, + "created_at": "2023-06-21T06:59:22Z", + "published_at": "2023-06-21T06:59:51Z", + "assets": []interface{}{}, + "html_url": "https: //github.com/JamesWoolfenden/test-data-action/releases/tag/v0.0.1", + "author": map[string]interface{}{ + "avatar_url": "https://avatars.githubusercontent.com/u/1456880?v=4", + "url": "https://api.github.com/users/JamesWoolfenden", + "type": "User", + "followers_url": "https://api.github.com/users/JamesWoolfenden/followers", + "organizations_url": "https://api.github.com/users/JamesWoolfenden/orgs", + "starred_url": "https://api.github.com/users/JamesWoolfenden/starred{/owner}{/repo}", + "events_url": "https://api.github.com/users/JamesWoolfenden/events{/privacy}", + "login": "JamesWoolfenden", + "id": 1456880, + "node_id": "MDQ6VXNlcjE0NTY4ODA=", + "gravatar_id": "", + "html_url": "https://github.com/JamesWoolfenden", + "following_url": "https://api.github.com/users/JamesWoolfenden/following{/other_user}", + "gists_url": "https://api.github.com/users/JamesWoolfenden/gists{/gist_id}", + "subscriptions_url": "https://api.github.com/users/JamesWoolfenden/subscriptions", + "repos_url": "https://api.github.com/users/JamesWoolfenden/repos", + "received_events_url": "https://api.github.com/users/JamesWoolfenden/received_events", + "site_admin": false, + }, + "node_id": "RE_kwDOJyIXLs4GhDgl", + "tag_name": "v0.0.1", + "name": "Test", + "prerelease": false, + "body": "", + "url": "https://api.github.com/repos/JamesWoolfenden/test-data-action/releases/109328421", + "upload_url": "https: //uploads.github.com/repos/JamesWoolfenden/test-data-action/releases/109328421/assets{?name,label}", + "target_commitish": "main", + } result := map[string]interface{}{ "tarball_url": "https: //api.github.com/repos/JamesWoolfenden/test-data-action/tarball/v0.0.1", From 118e9c269beccbf8773fd44ea3557557ebc6e40d Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Thu, 3 Aug 2023 15:17:54 +0100 Subject: [PATCH 12/80] fix test --- .pre-commit-config.yaml | 2 +- go.mod | 4 ++-- go.sum | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 76d5135..f8d4a9d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -55,7 +55,7 @@ repos: hooks: - id: golangci-lint - repo: https://github.com/bridgecrewio/checkov - rev: 2.3.300 + rev: 2.3.356 hooks: - id: checkov language_version: python3.10 diff --git a/go.mod b/go.mod index b3f67db..f73286c 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module ghat go 1.20 require ( - github.com/rs/zerolog v1.29.1 + github.com/rs/zerolog v1.30.0 github.com/sergi/go-diff v1.3.1 github.com/urfave/cli/v2 v2.25.7 ) @@ -14,5 +14,5 @@ require ( github.com/mattn/go-isatty v0.0.19 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect - golang.org/x/sys v0.9.0 // indirect + golang.org/x/sys v0.10.0 // indirect ) diff --git a/go.sum b/go.sum index eb121fe..394acaf 100644 --- a/go.sum +++ b/go.sum @@ -18,9 +18,9 @@ github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= -github.com/rs/zerolog v1.29.1 h1:cO+d60CHkknCbvzEWxP0S9K6KqyTjrCNUy1LdQLCGPc= -github.com/rs/zerolog v1.29.1/go.mod h1:Le6ESbR7hc+DP6Lt1THiV8CQSdkkNrd3R0XbEgp3ZBU= +github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= +github.com/rs/zerolog v1.30.0 h1:SymVODrcRsaRaSInD9yQtKbtWqwsfoPcRff/oRXLj4c= +github.com/rs/zerolog v1.30.0/go.mod h1:/tk+P47gFdPXq4QYjvCmT5/Gsug2nagsFWBWhAiSi1w= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= @@ -36,8 +36,8 @@ golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s= -golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= +golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= From f687b7fb577ac43905e27a479b1d268875afad89 Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Sun, 6 Aug 2023 08:36:32 +0100 Subject: [PATCH 13/80] UPDATED dependencies --- .pre-commit-config.yaml | 2 +- README.md | 4 ++-- go.mod | 3 ++- go.sum | 6 ++++-- main.go | 4 ++++ 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f8d4a9d..fc5914d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,7 +19,7 @@ repos: - id: detect-aws-credentials - id: detect-private-key - repo: https://github.com/Lucas-C/pre-commit-hooks - rev: v1.5.1 + rev: v1.5.3 hooks: - id: forbid-tabs exclude_types: [ python, javascript, dtd, markdown, makefile, xml ] diff --git a/README.md b/README.md index 1777eec..602e416 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ Becomes uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 ``` -Ghat will use your GitHub creds, if available, from your environment using the environmental variables GITHUB_TOKEN or GITHUB_API, but it can also drop back to anonymous access, the drawback is that this is severely rate limited by gitHub. +Ghat will use your GitHub credentials, if available, from your environment using the environmental variables GITHUB_TOKEN or GITHUB_API, but it can also drop back to anonymous access, the drawback is that this is severely rate limited by gitHub. ## Table of Contents @@ -196,4 +196,4 @@ Make build ## Extending -Log an issue, a pr or send an email to jim.wolf @ duck.com. +Log an issue, a pr or an email to jim.wolf @ duck.com. diff --git a/go.mod b/go.mod index f73286c..2f54c26 100644 --- a/go.mod +++ b/go.mod @@ -6,6 +6,7 @@ require ( github.com/rs/zerolog v1.30.0 github.com/sergi/go-diff v1.3.1 github.com/urfave/cli/v2 v2.25.7 + moul.io/banner v1.0.1 ) require ( @@ -14,5 +15,5 @@ require ( github.com/mattn/go-isatty v0.0.19 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect - golang.org/x/sys v0.10.0 // indirect + golang.org/x/sys v0.11.0 // indirect ) diff --git a/go.sum b/go.sum index 394acaf..edf9eec 100644 --- a/go.sum +++ b/go.sum @@ -36,10 +36,12 @@ golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= -golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= +golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +moul.io/banner v1.0.1 h1:+WsemGLhj2pOajw2eR5VYjLhOIqs0XhIRYchzTyMLk0= +moul.io/banner v1.0.1/go.mod h1:XwvIGKkhKRKyN1vIdmR5oaKQLIkMhkMqrsHpS94QzAU= diff --git a/main.go b/main.go index 17add6e..0f2c158 100644 --- a/main.go +++ b/main.go @@ -11,9 +11,13 @@ import ( "github.com/rs/zerolog" "github.com/rs/zerolog/log" "github.com/urfave/cli/v2" + "moul.io/banner" ) func main() { + fmt.Println(banner.Inline("ghat")) + fmt.Println("version:", version.Version) + log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr}) var myFlags core.Flags From 9c36a65ae917cb45ca6d359da6c400432e0d9b6b Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Fri, 11 Aug 2023 08:31:17 +0100 Subject: [PATCH 14/80] skeleton --- .github/workflows/ci.yml | 2 +- .github/workflows/pr.yml | 6 +- .github/workflows/release.yml | 4 +- .pre-commit-config.yaml | 4 +- go.mod | 8 + go.sum | 21 ++- main.go | 66 ++++++-- src/core/action.go | 46 ++++++ src/core/{files.go => gha.go} | 108 ++++++------ src/core/{files_test.go => gha_test.go} | 10 +- src/core/modules.go | 155 ++++++++++++++++++ src/core/testdata/modules/registry/module.tf | 5 + .../modules/registry/nomoduleshere.tfvars | 0 .../testdata/modules/registry/subdir/catch.tf | 3 + src/core/types.go | 1 + 15 files changed, 363 insertions(+), 76 deletions(-) create mode 100644 src/core/action.go rename src/core/{files.go => gha.go} (70%) rename src/core/{files_test.go => gha_test.go} (94%) create mode 100644 src/core/modules.go create mode 100644 src/core/testdata/modules/registry/module.tf create mode 100644 src/core/testdata/modules/registry/nomoduleshere.tfvars create mode 100644 src/core/testdata/modules/registry/subdir/catch.tf diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4afa6a6..257c036 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ jobs: steps: ## sets up go based on the version - name: Install Go - uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1 + uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0 with: go-version: ${{ matrix.go-version }} diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 69c3092..c87a32d 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -10,7 +10,7 @@ jobs: - name: Checkout code uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 - name: Install Go - uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1 + uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0 with: go-version: 1.20.x - name: Restore cache @@ -32,7 +32,7 @@ jobs: - name: Checkout code uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 - name: Install Go - uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1 + uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0 with: go-version: ${{ matrix.go-version }} - name: Restore cache @@ -50,6 +50,6 @@ jobs: - name: Checkout code uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 - name: Install Go - uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1 + uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0 with: go-version: 1.20.x diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a74574f..15bf1bf 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,7 +15,7 @@ jobs: - name: Unshallow run: git fetch --prune --unshallow - name: Set up Go - uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1 + uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0 with: go-version: 1.19 - name: Import GPG key @@ -25,7 +25,7 @@ jobs: gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} passphrase: ${{ secrets.PASSPHRASE }} - name: Run GoReleaser - uses: goreleaser/goreleaser-action@336e29918d653399e599bfca99fadc1d7ffbc9f7 # v4.3.0 + uses: goreleaser/goreleaser-action@3fa32b8bb5620a2c1afe798654bbad59f9da4906 # v4.4.0 with: version: latest args: release --clean diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fc5914d..cd9bd95 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -51,11 +51,11 @@ repos: - id: go-mod-tidy - id: go-generate - repo: https://github.com/golangci/golangci-lint - rev: v1.53.3 + rev: v1.54.0 hooks: - id: golangci-lint - repo: https://github.com/bridgecrewio/checkov - rev: 2.3.356 + rev: 2.3.360 hooks: - id: checkov language_version: python3.10 diff --git a/go.mod b/go.mod index 2f54c26..a12b8fe 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module ghat go 1.20 require ( + github.com/hashicorp/hcl/v2 v2.17.0 github.com/rs/zerolog v1.30.0 github.com/sergi/go-diff v1.3.1 github.com/urfave/cli/v2 v2.25.7 @@ -10,10 +11,17 @@ require ( ) require ( + github.com/agext/levenshtein v1.2.3 // indirect + github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect + github.com/google/go-cmp v0.5.9 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.19 // indirect + github.com/mitchellh/go-wordwrap v1.0.1 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect + github.com/stretchr/testify v1.5.1 // indirect github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect + github.com/zclconf/go-cty v1.13.2 // indirect golang.org/x/sys v0.11.0 // indirect + golang.org/x/text v0.12.0 // indirect ) diff --git a/go.sum b/go.sum index edf9eec..5292ca9 100644 --- a/go.sum +++ b/go.sum @@ -1,13 +1,25 @@ +github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= +github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= +github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw= +github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/hashicorp/hcl/v2 v2.17.0 h1:z1XvSUyXd1HP10U4lrLg5e0JMVz6CPaJvAgxM0KNZVY= +github.com/hashicorp/hcl/v2 v2.17.0/go.mod h1:gJyW2PTShkJqQBKpAmPO3yxMxIuoXkOF2TpqXzrQyx4= +github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348 h1:MtvEpTB6LX3vkb4ax0b5D2DHbNAUsen0Gx5wZoq3lV4= github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= @@ -15,6 +27,8 @@ github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27k github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= +github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= @@ -26,18 +40,23 @@ github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQD github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs= github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= +github.com/zclconf/go-cty v1.13.2 h1:4GvrUxe/QUDYuJKAav4EYqdM47/kZa672LwmXFmEKT0= +github.com/zclconf/go-cty v1.13.2/go.mod h1:YKQzy/7pZ7iq2jNFzy5go57xdxdWoLLpaEp4u238AE0= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= +golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/main.go b/main.go index 0f2c158..e42deef 100644 --- a/main.go +++ b/main.go @@ -41,23 +41,59 @@ func main() { { Name: "swot", Aliases: []string{"a"}, - Usage: "updates GHA in a directory", + Usage: "updates GHA versions for hashes", UsageText: "ghat swot", Action: func(*cli.Context) error { - - if myFlags.File != "" { - err := myFlags.UpdateFile() - if err != nil { - return err - } - } else { - _, err := myFlags.Files() - if err != nil { - return err - } - } - - return nil + return myFlags.Action("swot") + }, + Flags: []cli.Flag{ + &cli.StringFlag{ + Name: "file", + Aliases: []string{"f"}, + Usage: "GHA file to parse", + Destination: &myFlags.File, + Category: "files", + }, + &cli.StringFlag{ + Name: "directory", + Aliases: []string{"d"}, + Usage: "Destination to update GHAs", + Value: ".", + Destination: &myFlags.Directory, + Category: "files", + }, + &cli.IntFlag{ + Name: "stable", + Aliases: []string{"s"}, + Usage: "days to wait for stabilisation of release", + Value: 0, + Destination: &myFlags.Days, + DefaultText: "0", + Category: "delay", + }, + &cli.StringFlag{ + Name: "token", + Aliases: []string{"t"}, + Usage: "Github PAT token", + Destination: &myFlags.GitHubToken, + Category: "authentication", + EnvVars: []string{"GITHUB_TOKEN", "GITHUB_API"}, + }, + &cli.BoolFlag{ + Name: "dry-run", + Usage: "show but don't write changes", + Destination: &myFlags.DryRun, + Value: false, + }, + }, + }, + { + Name: "swipe", + Aliases: []string{"w"}, + Usage: "updates Terraform module versions with versioned hashes", + UsageText: "ghat swipe", + Action: func(*cli.Context) error { + return myFlags.Action("swipe") }, Flags: []cli.Flag{ &cli.StringFlag{ diff --git a/src/core/action.go b/src/core/action.go new file mode 100644 index 0000000..19d8547 --- /dev/null +++ b/src/core/action.go @@ -0,0 +1,46 @@ +package core + +import ( + "os" + "path/filepath" + + "github.com/rs/zerolog/log" +) + +func (myFlags *Flags) Action(Action string) error { + var err error + + if myFlags.File != "" { + if _, err := os.Stat(myFlags.File); err != nil { + pwd, _ := os.Getwd() + myFlags.File = filepath.Join(pwd, myFlags.File) + } + } else { + myFlags.Entries, err = GetFiles(myFlags.Directory) + + if err != nil { + log.Error().Msgf("failed to read %s", myFlags.Directory) + } + } + + switch Action { + case "swipe": + { + if myFlags.File != "" { + return myFlags.UpdateModule(myFlags.File) + } else { + return myFlags.UpdateModules() + } + } + case "swot": + { + if myFlags.File != "" { + return myFlags.UpdateGHA(myFlags.File) + } else { + return myFlags.UpdateGHAS() + } + } + } + + return nil +} diff --git a/src/core/files.go b/src/core/gha.go similarity index 70% rename from src/core/files.go rename to src/core/gha.go index a0e68b5..c9c42de 100644 --- a/src/core/files.go +++ b/src/core/gha.go @@ -15,55 +15,69 @@ import ( "github.com/sergi/go-diff/diffmatchpatch" ) -// Files updates all actions in a directory. -func (myFlags *Flags) Files() ([]os.DirEntry, error) { +func GetFiles(dir string) ([]string, error) { + Entries, err := os.ReadDir(dir) + if err != nil { + return nil, err + } - matches, err := os.ReadDir(myFlags.Directory) + var ParsedEntries []string - if err != nil { - log.Error().Msgf("failed to read %s", myFlags.Directory) + for _, entry := range Entries { + AbsDir, _ := filepath.Abs(dir) + gitDir := filepath.Join(AbsDir, ".git") + + if entry.IsDir() { + + newDir := filepath.Join(AbsDir, entry.Name()) + + if !(strings.Contains(newDir, ".terraform")) && newDir != gitDir { + newEntries, err := GetFiles(newDir) + + if err != nil { + return nil, err + } + + ParsedEntries = append(ParsedEntries, newEntries...) + } + } else { + myFile := filepath.Join(dir, entry.Name()) + if !(strings.Contains(myFile, ".terraform")) { + ParsedEntries = append(ParsedEntries, myFile) + } + } } - var ghat []os.DirEntry + return ParsedEntries, nil +} + +func (myFlags *Flags) UpdateGHAS() error { + var err error + myFlags.Entries, err = myFlags.GetGHA() - entries, err2 := myFlags.GetGHA(matches, ghat) - if err2 != nil { - return entries, err2 + if err != nil { + return err } - for _, gha := range entries { - myFlags.File = filepath.Join(myFlags.Directory, gha.Name()) - err = myFlags.UpdateFile() + for _, gha := range myFlags.Entries { + err = myFlags.UpdateGHA(gha) if err != nil { - log.Warn().Msgf("failed to update %s", gha.Name()) + return fmt.Errorf("failed to update %s", gha) } } - return nil, nil + return nil } // GetGHA gets all the actions in a directory -func (myFlags *Flags) GetGHA(matches []os.DirEntry, ghat []os.DirEntry) ([]os.DirEntry, error) { - for _, match := range matches { - if match.IsDir() { - if strings.Contains(match.Name(), ".github") { - log.Print(match.Name()) - AbsDir, _ := filepath.Abs(myFlags.Directory) - newDirectory := filepath.Join(AbsDir, match.Name(), "workflows") - if _, err := os.Stat(newDirectory); err == nil { - ghat, err = os.ReadDir(newDirectory) - myFlags.Directory = newDirectory - - if err != nil { - return nil, fmt.Errorf("no files found %w", err) - } - - return ghat, nil - } - } - } else { - if strings.Contains(match.Name(), ".yml") || (strings.Contains(match.Name(), ".yaml")) { +func (myFlags *Flags) GetGHA() ([]string, error) { + var ghat []string + + for _, match := range myFlags.Entries { + entry, _ := os.Stat(match) + if strings.Contains(match, ".github/workflows") && !entry.IsDir() { + if strings.Contains(match, ".yml") || (strings.Contains(match, ".yaml")) { ghat = append(ghat, match) } } @@ -72,17 +86,17 @@ func (myFlags *Flags) GetGHA(matches []os.DirEntry, ghat []os.DirEntry) ([]os.Di return ghat, nil } -// UpdateFile updates am action with latest dependencies -func (myFlags *Flags) UpdateFile() error { - buffer, err := os.ReadFile(myFlags.File) - replacement := string(buffer) - - var newUrl string - +// UpdateGHA updates am action with latest dependencies +func (myFlags *Flags) UpdateGHA(file string) error { + buffer, err := os.ReadFile(file) if err != nil { return fmt.Errorf("failed to open file %w", err) } + replacement := string(buffer) + + var newUrl string + r := regexp.MustCompile(`uses:(.*)`) matches := r.FindAllStringSubmatch(string(buffer), -1) for _, match := range matches { @@ -95,14 +109,14 @@ func (myFlags *Flags) UpdateFile() error { action := strings.Split(match[1], "@") action[0] = strings.TrimSpace(action[0]) - body, err2 := getPayload(action[0], myFlags.GitHubToken, &myFlags.Days) + body, err := getPayload(action[0], myFlags.GitHubToken, &myFlags.Days) - if err2 != nil { + if err != nil { splitter := strings.SplitN(action[0], "/", 3) newUrl = splitter[0] + "/" + splitter[1] - body, err2 = getPayload(newUrl, myFlags.GitHubToken, &myFlags.Days) - if err2 != nil { - log.Warn().Msgf("failed to retrieve back %s", err2) + body, err = getPayload(newUrl, myFlags.GitHubToken, &myFlags.Days) + if err != nil { + log.Warn().Msgf("failed to retrieve back %s", err) continue } @@ -160,7 +174,7 @@ func (myFlags *Flags) UpdateFile() error { if !myFlags.DryRun { newBuffer := []byte(replacement) - err = os.WriteFile(myFlags.File, newBuffer, 0644) + err = os.WriteFile(file, newBuffer, 0644) if err != nil { return fmt.Errorf("failed to write err %w", err) diff --git a/src/core/files_test.go b/src/core/gha_test.go similarity index 94% rename from src/core/files_test.go rename to src/core/gha_test.go index b44aa80..0ac674d 100644 --- a/src/core/files_test.go +++ b/src/core/gha_test.go @@ -137,13 +137,13 @@ func TestFlags_Files(t *testing.T) { Days: tt.fields.Days, DryRun: tt.fields.DryRun, } - got, err := myFlags.Files() + got, err := myFlags.Action() if (err != nil) != tt.wantErr { - t.Errorf("Files() error = %v, wantErr %v", err, tt.wantErr) + t.Errorf("Action() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(got, tt.want) { - t.Errorf("Files() got = %v, want %v", got, tt.want) + t.Errorf("Action() got = %v, want %v", got, tt.want) } }) } @@ -228,8 +228,8 @@ func TestFlags_UpdateFile(t *testing.T) { Days: tt.fields.Days, DryRun: tt.fields.DryRun, } - if err := myFlags.UpdateFile(); (err != nil) != tt.wantErr { - t.Errorf("UpdateFile() error = %v, wantErr %v", err, tt.wantErr) + if err := myFlags.UpdateGHA(); (err != nil) != tt.wantErr { + t.Errorf("UpdateGHA() error = %v, wantErr %v", err, tt.wantErr) } }) } diff --git a/src/core/modules.go b/src/core/modules.go new file mode 100644 index 0000000..cc9b37b --- /dev/null +++ b/src/core/modules.go @@ -0,0 +1,155 @@ +package core + +import ( + "fmt" + "os" + "path" + + "github.com/hashicorp/hcl/v2" + "github.com/hashicorp/hcl/v2/hclparse" + "github.com/hashicorp/hcl/v2/hclsyntax" + "github.com/rs/zerolog/log" +) + +func (myFlags *Flags) UpdateModule(file string) error { + parser := hclparse.NewParser() + src, err := os.ReadFile(file) + if err != nil { + return fmt.Errorf("failed to read %s", file) + } + + parsedFile, fileDiags := parser.ParseHCL(src, file) + + if fileDiags.HasErrors() { + return fmt.Errorf("config parse: %w", fileDiags) + } + + content := parsedFile.Body.(*hclsyntax.Body) + + //newContent:=hcl.File{ + // Body: nil, + // Bytes: nil, + // Nav: nil, + //} + + newBody := hclsyntax.Body{} + + for _, block := range content.Blocks { + + if block.Type == "module" { + var source *hclsyntax.Attribute + var version *hclsyntax.Attribute + //version := cty.Value{} + //source := cty.Value{} + + myAttributes := block.Body.Attributes + newAttributes := hclsyntax.Attributes{} + + if myAttributes["source"] != nil { + source = myAttributes["source"] + } + + if myAttributes["version"] != nil { + version = myAttributes["version"] + } + + log.Print(source) + log.Print(version) + for x, attribute := range myAttributes { + + if attribute.Name == "version" { + continue + } + + if attribute.Name == "source" { + ctx := &hcl.EvalContext{} + + var diags hcl.Diagnostics + sourceValue, diags := attribute.Expr.Value(ctx) + + log.Print(sourceValue) + + if diags.HasErrors() { + return fmt.Errorf("version parse: %w", fileDiags) + } + } + + newAttributes[x] = attribute + // ctx := &hcl.EvalContext{} + // var diags hcl.Diagnostics + // version, diags = attribute.Expr.Value(ctx) + // + // if diags.HasErrors() { + // return nil, fmt.Errorf("version parse: %w", fileDiags) + // } + // } + } + + block.Body.Attributes = newAttributes + //log.Info().Msgf("%s", version) + //new tf file + + //terraformBlock, err := p.parseBlock(block, file) + //src, _ := os.ReadFile(file) + // + //hclFile, diags := hclwrite.ParseConfig(src, file, hcl.InitialPos) + // + //if diags.HasErrors() { + // return nil, fmt.Errorf("config parse: %w", diags) + //} + // + //hclSyntaxFile, diags := hclsyntax.ParseConfig(src, file, hcl.InitialPos) + + //f.Body().SetAttributeValue("version", cty.StringVal("999.999.999")) + + //myBlocks := test.Blocks() + //for _, block := range myBlocks { + // log.Print(block.Labels()) + //} + //log.Print(myBlocks) + //result := hclFile.Bytes() + //log.Print(result) + //log.Print(hclSyntaxFile) + newBody.Blocks = append(newBody.Blocks, block) + } else { + newBody.Blocks = append(newBody.Blocks, block) + log.Info().Msgf("%s", newBody) + } + + } + + //write back if modified and if !myFlags.DryRun + return nil +} + +func (myFlags *Flags) UpdateModules() error { + + terraform, err := myFlags.GetTF() + + if err != nil { + return err + } + + // contains a module? + for _, file := range terraform { + err = myFlags.UpdateModule(file) + if err != nil { + return err + } + } + + return nil +} + +func (myFlags *Flags) GetTF() ([]string, error) { + var terraform []string + + for _, match := range myFlags.Entries { + //for each file that is a terraform file + if path.Ext(match) == ".tf" { + terraform = append(terraform, match) + } + } + + return terraform, nil +} diff --git a/src/core/testdata/modules/registry/module.tf b/src/core/testdata/modules/registry/module.tf new file mode 100644 index 0000000..2997d5e --- /dev/null +++ b/src/core/testdata/modules/registry/module.tf @@ -0,0 +1,5 @@ +module "ip" { + source = "JamesWoolfenden/ip/http" + version = "0.3.12" + permissions = "pike" +} diff --git a/src/core/testdata/modules/registry/nomoduleshere.tfvars b/src/core/testdata/modules/registry/nomoduleshere.tfvars new file mode 100644 index 0000000..e69de29 diff --git a/src/core/testdata/modules/registry/subdir/catch.tf b/src/core/testdata/modules/registry/subdir/catch.tf new file mode 100644 index 0000000..2fb0780 --- /dev/null +++ b/src/core/testdata/modules/registry/subdir/catch.tf @@ -0,0 +1,3 @@ +resource "aws_s3_bucket" "ignore" { + bucket = "fake" +} diff --git a/src/core/types.go b/src/core/types.go index 4142add..027c261 100644 --- a/src/core/types.go +++ b/src/core/types.go @@ -6,4 +6,5 @@ type Flags struct { GitHubToken string Days int DryRun bool + Entries []string } From b63bf8cd46315b83eda920b7a720a1202d136554 Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Fri, 11 Aug 2023 09:24:06 +0100 Subject: [PATCH 15/80] get registry item --- src/core/filter.go | 2 +- src/core/gha.go | 8 +- src/core/gha_test.go | 273 +++++++++++++++++++------------------- src/core/modules.go | 2 +- src/core/registry.go | 36 +++++ src/core/registry_test.go | 83 ++++++++++++ 6 files changed, 262 insertions(+), 142 deletions(-) create mode 100644 src/core/registry.go create mode 100644 src/core/registry_test.go diff --git a/src/core/filter.go b/src/core/filter.go index d93d9dd..8742e3a 100644 --- a/src/core/filter.go +++ b/src/core/filter.go @@ -11,7 +11,7 @@ func GetReleases(action string, gitHubToken string, days *int) (map[string]inter limit := now.Add(-interval) url := "https://api.github.com/repos/" + action + "/releases" - temp, err := GetBody(gitHubToken, url) + temp, err := GetGithubBody(gitHubToken, url) if err != nil { return nil, fmt.Errorf("failed to request list of releases %w", err) diff --git a/src/core/gha.go b/src/core/gha.go index c9c42de..a149393 100644 --- a/src/core/gha.go +++ b/src/core/gha.go @@ -187,7 +187,7 @@ func (myFlags *Flags) UpdateGHA(file string) error { func getPayload(action string, gitHubToken string, days *int) (interface{}, error) { if *days == 0 { url := "https://api.github.com/repos/" + action + "/releases/latest" - return GetBody(gitHubToken, url) + return GetGithubBody(gitHubToken, url) } return GetReleases(action, gitHubToken, days) @@ -195,11 +195,11 @@ func getPayload(action string, gitHubToken string, days *int) (interface{}, erro func getHash(action string, tag string, gitHubToken string) (interface{}, error) { url := "https://api.github.com/repos/" + action + "/git/ref/tags/" + tag - return GetBody(gitHubToken, url) + return GetGithubBody(gitHubToken, url) } -// GetBody requests a URL using gitHub PAT for auth -func GetBody(gitHubToken string, url string) (interface{}, error) { +// GetGithubBody requests a URL using gitHub PAT for auth +func GetGithubBody(gitHubToken string, url string) (interface{}, error) { var body []byte if gitHubToken != "" { diff --git a/src/core/gha_test.go b/src/core/gha_test.go index 0ac674d..9bfa416 100644 --- a/src/core/gha_test.go +++ b/src/core/gha_test.go @@ -28,13 +28,13 @@ func TestGetBody(t *testing.T) { tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() - got, err := GetBody(tt.args.gitHubToken, tt.args.url) + got, err := GetGithubBody(tt.args.gitHubToken, tt.args.url) if (err != nil) != tt.wantErr { - t.Errorf("GetBody() error = %v, wantErr %v", err, tt.wantErr) + t.Errorf("GetGithubBody() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(got, tt.want) { - t.Errorf("GetBody() got = %v, want %v", got, tt.want) + t.Errorf("GetGithubBody() got = %v, want %v", got, tt.want) } }) } @@ -101,136 +101,137 @@ func Test_getPayload(t *testing.T) { } } -func TestFlags_Files(t *testing.T) { - - type fields struct { - File string - Directory string - GitHubToken string - Days int - DryRun bool - } - - dir := fields{"", "testdata/files/", gitHubToken, 0, false} - bogus := fields{"", "testdata/bogus/", gitHubToken, 0, false} - empty := fields{"", "testdata/empty", gitHubToken, 0, false} - dirDry := fields{"", "testdata/files/", gitHubToken, 0, true} - - tests := []struct { - name string - fields fields - want []os.DirEntry - wantErr bool - }{ - {"Pass", dir, nil, false}, - {"Bogus", bogus, nil, false}, - {"Empty", empty, nil, false}, - {"dirDry", dirDry, nil, false}, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - myFlags := &Flags{ - File: tt.fields.File, - Directory: tt.fields.Directory, - GitHubToken: tt.fields.GitHubToken, - Days: tt.fields.Days, - DryRun: tt.fields.DryRun, - } - got, err := myFlags.Action() - if (err != nil) != tt.wantErr { - t.Errorf("Action() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("Action() got = %v, want %v", got, tt.want) - } - }) - } -} - -func TestFlags_GetGHA(t *testing.T) { - type fields struct { - File string - Directory string - GitHubToken string - Days int - DryRun bool - } - - type args struct { - matches []os.DirEntry - ghat []os.DirEntry - } - - duffDir := fields{"", "nothere", gitHubToken, 0, false} - noMatches, _ := os.ReadDir(duffDir.Directory) - - noWorkflowsDir := fields{"", "./testdata/noworkflows", gitHubToken, 0, false} - noWorkflows, _ := os.ReadDir(noWorkflowsDir.Directory) - - noWorkflowsWithDir := fields{"", "./testdata/noworkflowswithdir", gitHubToken, 0, false} - noWorkflowsWithDirContents, _ := os.ReadDir(noWorkflowsWithDir.Directory) - - tests := []struct { - name string - fields fields - args args - want []os.DirEntry - wantErr bool - }{ - {"no matches", duffDir, args{noMatches, nil}, nil, false}, - {"no workflows", noWorkflowsDir, args{noWorkflows, nil}, nil, false}, - {"no workflows with dir", noWorkflowsWithDir, args{noWorkflowsWithDirContents, nil}, nil, false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - myFlags := &Flags{ - File: tt.fields.File, - Directory: tt.fields.Directory, - GitHubToken: tt.fields.GitHubToken, - Days: tt.fields.Days, - DryRun: tt.fields.DryRun, - } - got, err := myFlags.GetGHA(tt.args.matches, tt.args.ghat) - if (err != nil) != tt.wantErr { - t.Errorf("GetGHA() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("GetGHA() got = %v, want %v", got, tt.want) - } - }) - } -} - -func TestFlags_UpdateFile(t *testing.T) { - type fields struct { - File string - Directory string - GitHubToken string - Days int - DryRun bool - } - tests := []struct { - name string - fields fields - wantErr bool - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - myFlags := &Flags{ - File: tt.fields.File, - Directory: tt.fields.Directory, - GitHubToken: tt.fields.GitHubToken, - Days: tt.fields.Days, - DryRun: tt.fields.DryRun, - } - if err := myFlags.UpdateGHA(); (err != nil) != tt.wantErr { - t.Errorf("UpdateGHA() error = %v, wantErr %v", err, tt.wantErr) - } - }) - } -} +// +//func TestFlags_Files(t *testing.T) { +// +// type fields struct { +// File string +// Directory string +// GitHubToken string +// Days int +// DryRun bool +// } +// +// dir := fields{"", "testdata/files/", gitHubToken, 0, false} +// bogus := fields{"", "testdata/bogus/", gitHubToken, 0, false} +// empty := fields{"", "testdata/empty", gitHubToken, 0, false} +// dirDry := fields{"", "testdata/files/", gitHubToken, 0, true} +// +// tests := []struct { +// name string +// fields fields +// want []os.DirEntry +// wantErr bool +// }{ +// {"Pass", dir, nil, false}, +// {"Bogus", bogus, nil, false}, +// {"Empty", empty, nil, false}, +// {"dirDry", dirDry, nil, false}, +// } +// +// for _, tt := range tests { +// t.Run(tt.name, func(t *testing.T) { +// myFlags := &Flags{ +// File: tt.fields.File, +// Directory: tt.fields.Directory, +// GitHubToken: tt.fields.GitHubToken, +// Days: tt.fields.Days, +// DryRun: tt.fields.DryRun, +// } +// got, err := myFlags.Action() +// if (err != nil) != tt.wantErr { +// t.Errorf("Action() error = %v, wantErr %v", err, tt.wantErr) +// return +// } +// if !reflect.DeepEqual(got, tt.want) { +// t.Errorf("Action() got = %v, want %v", got, tt.want) +// } +// }) +// } +//} +// +//func TestFlags_GetGHA(t *testing.T) { +// type fields struct { +// File string +// Directory string +// GitHubToken string +// Days int +// DryRun bool +// } +// +// type args struct { +// matches []os.DirEntry +// ghat []os.DirEntry +// } +// +// duffDir := fields{"", "nothere", gitHubToken, 0, false} +// noMatches, _ := os.ReadDir(duffDir.Directory) +// +// noWorkflowsDir := fields{"", "./testdata/noworkflows", gitHubToken, 0, false} +// noWorkflows, _ := os.ReadDir(noWorkflowsDir.Directory) +// +// noWorkflowsWithDir := fields{"", "./testdata/noworkflowswithdir", gitHubToken, 0, false} +// noWorkflowsWithDirContents, _ := os.ReadDir(noWorkflowsWithDir.Directory) +// +// tests := []struct { +// name string +// fields fields +// args args +// want []os.DirEntry +// wantErr bool +// }{ +// {"no matches", duffDir, args{noMatches, nil}, nil, false}, +// {"no workflows", noWorkflowsDir, args{noWorkflows, nil}, nil, false}, +// {"no workflows with dir", noWorkflowsWithDir, args{noWorkflowsWithDirContents, nil}, nil, false}, +// } +// for _, tt := range tests { +// t.Run(tt.name, func(t *testing.T) { +// myFlags := &Flags{ +// File: tt.fields.File, +// Directory: tt.fields.Directory, +// GitHubToken: tt.fields.GitHubToken, +// Days: tt.fields.Days, +// DryRun: tt.fields.DryRun, +// } +// got, err := myFlags.GetGHA(tt.args.matches, tt.args.ghat) +// if (err != nil) != tt.wantErr { +// t.Errorf("GetGHA() error = %v, wantErr %v", err, tt.wantErr) +// return +// } +// if !reflect.DeepEqual(got, tt.want) { +// t.Errorf("GetGHA() got = %v, want %v", got, tt.want) +// } +// }) +// } +//} +// +//func TestFlags_UpdateFile(t *testing.T) { +// type fields struct { +// File string +// Directory string +// GitHubToken string +// Days int +// DryRun bool +// } +// tests := []struct { +// name string +// fields fields +// wantErr bool +// }{ +// // TODO: Add test cases. +// } +// for _, tt := range tests { +// t.Run(tt.name, func(t *testing.T) { +// myFlags := &Flags{ +// File: tt.fields.File, +// Directory: tt.fields.Directory, +// GitHubToken: tt.fields.GitHubToken, +// Days: tt.fields.Days, +// DryRun: tt.fields.DryRun, +// } +// if err := myFlags.UpdateGHA(); (err != nil) != tt.wantErr { +// t.Errorf("UpdateGHA() error = %v, wantErr %v", err, tt.wantErr) +// } +// }) +// } +//} diff --git a/src/core/modules.go b/src/core/modules.go index cc9b37b..33f7557 100644 --- a/src/core/modules.go +++ b/src/core/modules.go @@ -113,7 +113,7 @@ func (myFlags *Flags) UpdateModule(file string) error { newBody.Blocks = append(newBody.Blocks, block) } else { newBody.Blocks = append(newBody.Blocks, block) - log.Info().Msgf("%s", newBody) + log.Print(newBody) } } diff --git a/src/core/registry.go b/src/core/registry.go new file mode 100644 index 0000000..bb3053e --- /dev/null +++ b/src/core/registry.go @@ -0,0 +1,36 @@ +package core + +import ( + "fmt" + "net/http" + + "github.com/rs/zerolog/log" +) + +type Registry struct { + Registry bool +} + +func (myRegistry *Registry) IsRegistryModule(module string) (bool, error) { + url := "https://registry.terraform.io/v1/modules/" + module + "/versions" + result, err := IsOK(url) + + myRegistry.Registry = result + + return result, err +} + +func IsOK(url string) (bool, error) { + resp, err := http.Get(url) + if err != nil { + return false, fmt.Errorf("failed to get url %w", err) + } + + if resp.StatusCode == 200 { + return true, nil + } + + log.Info().Msgf("Received %s for %s", resp.Status, url) + + return false, nil +} diff --git a/src/core/registry_test.go b/src/core/registry_test.go new file mode 100644 index 0000000..4cde256 --- /dev/null +++ b/src/core/registry_test.go @@ -0,0 +1,83 @@ +package core + +import ( + "reflect" + "testing" +) + +func TestIsOK(t *testing.T) { + t.Parallel() + + type args struct { + url string + } + + tests := []struct { + name string + args args + want interface{} + wantErr bool + }{ + {"Pass", args{"https://registry.terraform.io/v1/modules/jameswoolfenden/ip/http/versions"}, true, false}, + {"Fail", args{"https://registry.terraform.io/v1/modules/jameswoolfenden/ip/https/versions"}, false, false}, + {"NotUrl", args{"jameswoolfenden/ip/https"}, nil, true}, + } + + for _, tt := range tests { + tt := tt + t.Run(tt.name, func(t *testing.T) { + t.Parallel() + got, err := IsOK(tt.args.url) + if (err != nil) != tt.wantErr { + t.Errorf("IsOK() error = %v, wantErr %v", err, tt.wantErr) + return + } + if !reflect.DeepEqual(got, tt.want) { + t.Errorf("IsOK() got = %v, want %v", got, tt.want) + } + }) + } +} + +func TestRegistry_IsRegistryModule(t *testing.T) { + t.Parallel() + + type fields struct { + Registry bool + } + + type args struct { + module string + } + + tests := []struct { + name string + fields fields + args args + want bool + wantErr bool + }{ + {"Pass", fields{false}, args{"jameswoolfenden/ip/http"}, true, false}, + {"Fail", fields{false}, args{"jameswoolfenden/ip/https"}, false, false}, + {"NotUrl", fields{false}, args{"https://jameswoolfenden/ip/https"}, false, false}, + } + + for _, tt := range tests { + tt := tt + t.Run(tt.name, func(t *testing.T) { + t.Parallel() + myRegistry := &Registry{ + Registry: tt.fields.Registry, + } + got, err := myRegistry.IsRegistryModule(tt.args.module) + if (err != nil) != tt.wantErr { + t.Errorf("IsRegistryModule() error = %v, wantErr %v", err, tt.wantErr) + + return + } + if got != tt.want { + t.Errorf("IsRegistryModule() got = %v, want %v", got, tt.want) + } + }) + } +} From 25646776d92a630aca752e78d14485f23c8a00c7 Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Fri, 11 Aug 2023 13:35:02 +0100 Subject: [PATCH 16/80] module typing Signed-off-by: James Woolfenden --- src/core/modules_test.go | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/core/modules_test.go diff --git a/src/core/modules_test.go b/src/core/modules_test.go new file mode 100644 index 0000000..9a8bc95 --- /dev/null +++ b/src/core/modules_test.go @@ -0,0 +1 @@ +package core From 9909bb3e308df409703064e13b6a80b016d2c20d Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Fri, 11 Aug 2023 13:35:14 +0100 Subject: [PATCH 17/80] module typing Signed-off-by: James Woolfenden --- .github/workflows/codeql-analysis.yml | 6 +-- main.go | 25 +++------- src/core/action.go | 2 +- src/core/modules.go | 60 +++++++++++++++++++++++- src/core/modules_test.go | 67 +++++++++++++++++++++++++++ src/core/registry.go | 62 ++++++++++++++++++++++++- src/core/registry_test.go | 43 +++++++++++++++++ src/core/types.go | 1 + 8 files changed, 241 insertions(+), 25 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 7e6e0b9..6126fe7 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -43,7 +43,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@7b6664fa89524ee6e3c3e9749402d5afd69b3cd8 # codeql-bundle-v2.14.1 + uses: github/codeql-action/init@f9a7c6738f28efb36e31d49c53a201a9c5d6a476 # codeql-bundle-v2.14.2 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -53,7 +53,7 @@ jobs: # 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@7b6664fa89524ee6e3c3e9749402d5afd69b3cd8 # codeql-bundle-v2.14.1 + uses: github/codeql-action/autobuild@f9a7c6738f28efb36e31d49c53a201a9c5d6a476 # codeql-bundle-v2.14.2 # â„šī¸ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun @@ -66,4 +66,4 @@ jobs: # ./location_of_script_within_repo/buildscript.sh - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@7b6664fa89524ee6e3c3e9749402d5afd69b3cd8 # codeql-bundle-v2.14.1 + uses: github/codeql-action/analyze@f9a7c6738f28efb36e31d49c53a201a9c5d6a476 # codeql-bundle-v2.14.2 diff --git a/main.go b/main.go index e42deef..6f2fee8 100644 --- a/main.go +++ b/main.go @@ -99,34 +99,23 @@ func main() { &cli.StringFlag{ Name: "file", Aliases: []string{"f"}, - Usage: "GHA file to parse", + Usage: "module file to parse", Destination: &myFlags.File, Category: "files", }, &cli.StringFlag{ Name: "directory", Aliases: []string{"d"}, - Usage: "Destination to update GHAs", + Usage: "Destination to update modules", Value: ".", Destination: &myFlags.Directory, Category: "files", }, - &cli.IntFlag{ - Name: "stable", - Aliases: []string{"s"}, - Usage: "days to wait for stabilisation of release", - Value: 0, - Destination: &myFlags.Days, - DefaultText: "0", - Category: "delay", - }, - &cli.StringFlag{ - Name: "token", - Aliases: []string{"t"}, - Usage: "Github PAT token", - Destination: &myFlags.GitHubToken, - Category: "authentication", - EnvVars: []string{"GITHUB_TOKEN", "GITHUB_API"}, + &cli.BoolFlag{ + Name: "update", + Usage: "update to lastest module available", + Destination: &myFlags.Update, + Value: false, }, &cli.BoolFlag{ Name: "dry-run", diff --git a/src/core/action.go b/src/core/action.go index 19d8547..eb54490 100644 --- a/src/core/action.go +++ b/src/core/action.go @@ -19,7 +19,7 @@ func (myFlags *Flags) Action(Action string) error { myFlags.Entries, err = GetFiles(myFlags.Directory) if err != nil { - log.Error().Msgf("failed to read %s", myFlags.Directory) + log.Error().Msgf("action failed to read %s", myFlags.Directory) } } diff --git a/src/core/modules.go b/src/core/modules.go index 33f7557..41a07b3 100644 --- a/src/core/modules.go +++ b/src/core/modules.go @@ -4,6 +4,8 @@ import ( "fmt" "os" "path" + "path/filepath" + "strings" "github.com/hashicorp/hcl/v2" "github.com/hashicorp/hcl/v2/hclparse" @@ -67,8 +69,11 @@ func (myFlags *Flags) UpdateModule(file string) error { var diags hcl.Diagnostics sourceValue, diags := attribute.Expr.Value(ctx) - log.Print(sourceValue) - + myFlags.GetType(sourceValue.AsString()) + // what is the source type + // + // if source type is git update version? + // if source is registry convert to git if diags.HasErrors() { return fmt.Errorf("version parse: %w", fileDiags) } @@ -153,3 +158,54 @@ func (myFlags *Flags) GetTF() ([]string, error) { return terraform, nil } + +func (myFlags *Flags) GetType(module string) (string, string, error) { + var moduleType string + + //handle local path + absPath, _ := filepath.Abs(module) + _, err := os.Stat(absPath) + + if err == nil { + return module, "local", nil + } + + if strings.Contains("?ref=", module) { + moduleType = "url" + + if myFlags.Update { + splitter := strings.Split(module, "?ref=") + base := splitter[0] + log.Print(base) + // get lastest tag from git reference + //trim git: + //trim + } + + return module, moduleType, nil + } + + //split and check if using version then replace with hash or updated version hash + //then it's a good + //Modules in Package Sub-directories + // + //Generic Git, Mercurial repositories + // + // //HTTP URLs + // // // + // //GitHub + + //Local paths + // + //Terraform Registry + + // + //Bitbucket + + //S3 buckets + // + //GCS buckets + // + + return module, moduleType, err +} diff --git a/src/core/modules_test.go b/src/core/modules_test.go index 9a8bc95..54e8743 100644 --- a/src/core/modules_test.go +++ b/src/core/modules_test.go @@ -1 +1,68 @@ package core + +import "testing" + +func TestFlags_GetType(t *testing.T) { + type fields struct { + File string + Directory string + GitHubToken string + Days int + DryRun bool + Entries []string + Update bool + } + type args struct { + module string + } + tests := []struct { + name string + fields fields + args args + want string + want1 string + wantErr bool + }{ + {"Local paths", fields{}, args{"./testdata"}, "./testdata", "local", false}, + {"Local paths not found", fields{}, args{"./somewhere"}, "./somewhere", "", true}, + //{"Terraform Registry",""}, + // + //{"GitHub",""}, + // + //{"Bitbucket"""}, + // + //{"Generic Git, Mercurial repositories",""}, + // + //{"HTTP URLs",""}, + // + //{"S3 buckets",""}, + // + //{"GCS buckets",""}, + // + //{"Modules in Package Sub-directories",""}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + myFlags := &Flags{ + File: tt.fields.File, + Directory: tt.fields.Directory, + GitHubToken: tt.fields.GitHubToken, + Days: tt.fields.Days, + DryRun: tt.fields.DryRun, + Entries: tt.fields.Entries, + Update: tt.fields.Update, + } + got, got1, err := myFlags.GetType(tt.args.module) + if (err != nil) != tt.wantErr { + t.Errorf("GetType() error = %v, wantErr %v", err, tt.wantErr) + return + } + if got != tt.want { + t.Errorf("GetType() got = %v, want %v", got, tt.want) + } + if got1 != tt.want1 { + t.Errorf("GetType() got1 = %v, want %v", got1, tt.want1) + } + }) + } +} diff --git a/src/core/registry.go b/src/core/registry.go index bb3053e..5c47991 100644 --- a/src/core/registry.go +++ b/src/core/registry.go @@ -1,14 +1,17 @@ package core import ( + "encoding/json" "fmt" + "io" "net/http" "github.com/rs/zerolog/log" ) type Registry struct { - Registry bool + Registry bool + LatestVersion string } func (myRegistry *Registry) IsRegistryModule(module string) (bool, error) { @@ -34,3 +37,60 @@ func IsOK(url string) (bool, error) { return false, nil } + +func (myRegistry *Registry) GetLatest(module string) (*string, error) { + found, err := myRegistry.IsRegistryModule(module) + + if err != nil { + return nil, err + } + + if found { + url := "https://registry.terraform.io/v1/modules/" + module + resp, err := http.Get(url) + + if err != nil { + return nil, fmt.Errorf("failed to get url %w", err) + } + + if resp == nil { + return nil, fmt.Errorf("api failed to respond") + } + + if resp.StatusCode != 200 { + return nil, fmt.Errorf("api failed with %d", resp.StatusCode) + } + + defer func(Body io.ReadCloser) { + _ = Body.Close() + }(resp.Body) + + if err != nil { + return nil, fmt.Errorf("client failed %w", err) + } + + body, err := io.ReadAll(resp.Body) + + if err != nil { + return nil, fmt.Errorf("failed to read body %w", err) + } + + var msg map[string]interface{} + + err = json.Unmarshal(body, &msg) + + if err != nil { + return nil, fmt.Errorf("failed to read body %w", err) + } + + var ok bool + + myRegistry.LatestVersion, ok = msg["version"].(string) + + if !ok { + return nil, fmt.Errorf("failed to find version in payload") + } + } + + return &myRegistry.LatestVersion, nil +} diff --git a/src/core/registry_test.go b/src/core/registry_test.go index 4cde256..878523c 100644 --- a/src/core/registry_test.go +++ b/src/core/registry_test.go @@ -81,3 +81,46 @@ func TestRegistry_IsRegistryModule(t *testing.T) { }) } } + +func TestRegistry_GetLatest(t *testing.T) { + t.Parallel() + + type fields struct { + Registry bool + LatestVersion string + } + + type args struct { + module string + } + + want := "0.3.12" + + tests := []struct { + name string + fields fields + args args + want *string + wantErr bool + }{ + {"Pass", fields{false, ""}, args{"jameswoolfenden/ip/http"}, &want, false}, + } + for _, tt := range tests { + tt := tt + t.Run(tt.name, func(t *testing.T) { + t.Parallel() + myRegistry := &Registry{ + Registry: tt.fields.Registry, + LatestVersion: tt.fields.LatestVersion, + } + got, err := myRegistry.GetLatest(tt.args.module) + if (err != nil) != tt.wantErr { + t.Errorf("GetLatest() error = %v, wantErr %v", err, tt.wantErr) + return + } + if !reflect.DeepEqual(got, tt.want) { + t.Errorf("GetLatest() got = %v, want %v", got, tt.want) + } + }) + } +} diff --git a/src/core/types.go b/src/core/types.go index 027c261..e5ed6fd 100644 --- a/src/core/types.go +++ b/src/core/types.go @@ -7,4 +7,5 @@ type Flags struct { Days int DryRun bool Entries []string + Update bool } From bd81d0a3316bca855bb5c963119f33eff6f59b31 Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Sun, 13 Aug 2023 09:02:55 +0100 Subject: [PATCH 18/80] WIP --- src/core/modules.go | 112 ++++++++++++++-------- src/core/modules_test.go | 63 ++++++------ src/core/testdata/modules/depth/module.tf | 3 + 3 files changed, 112 insertions(+), 66 deletions(-) create mode 100644 src/core/testdata/modules/depth/module.tf diff --git a/src/core/modules.go b/src/core/modules.go index 41a07b3..2e42140 100644 --- a/src/core/modules.go +++ b/src/core/modules.go @@ -68,15 +68,21 @@ func (myFlags *Flags) UpdateModule(file string) error { var diags hcl.Diagnostics sourceValue, diags := attribute.Expr.Value(ctx) - - myFlags.GetType(sourceValue.AsString()) - // what is the source type - // - // if source type is git update version? - // if source is registry convert to git if diags.HasErrors() { return fmt.Errorf("version parse: %w", fileDiags) } + + ModuleType, err := myFlags.GetType(sourceValue.AsString()) + + if err != nil { + return err + } + + =myFlags.UpdateSource(sourceValue.AsString(), ModuleType) + switch ModuleType { + case + } + } newAttributes[x] = attribute @@ -159,53 +165,83 @@ func (myFlags *Flags) GetTF() ([]string, error) { return terraform, nil } -func (myFlags *Flags) GetType(module string) (string, string, error) { +func (myFlags *Flags) GetType(module string) (string, error) { var moduleType string - //handle local path + // handle local path absPath, _ := filepath.Abs(module) _, err := os.Stat(absPath) if err == nil { - return module, "local", nil + return "local", nil } - if strings.Contains("?ref=", module) { - moduleType = "url" + if strings.Contains(module, "bitbucket.org") { + return "bitbucket", nil + } - if myFlags.Update { - splitter := strings.Split(module, "?ref=") - base := splitter[0] - log.Print(base) - // get lastest tag from git reference - //trim git: - //trim - } + if strings.Contains(module, "s3::") { + return "s3", nil + } - return module, moduleType, nil + if strings.Contains(module, "gcs::") { + return "gcs", nil } - //split and check if using version then replace with hash or updated version hash - //then it's a good - //Modules in Package Sub-directories - // - //Generic Git, Mercurial repositories - // - // //HTTP URLs - // // // - // //GitHub + if strings.Contains(module, ".zip") || strings.Contains(module, "archive=") { + return "archive", nil + } - //Local paths - // - //Terraform Registry + var splitter []string - // - //Bitbucket + // github registry format and suub dirs + + splitter = strings.Split(module, "/") + + if len(splitter) == 3 && !(strings.Contains(module, "git::") || strings.Contains(module, "https:")) { + return "github", nil + } + + if strings.Contains(module, "depth=") { + return "shallow", nil + } + + if strings.Contains(module, "git::") { + return "git", nil + } + + if strings.Contains(module, "hg::") { + return "mercurial", nil + } + + if strings.Contains(module, "//") { + temp := strings.Split(module, "//")[0] + return myFlags.GetType(temp) + } - //S3 buckets + err = os.MkdirAll(module, 0700) + + if err == nil { + _ = os.Remove(module) + return "local", fmt.Errorf("localpath not found %s", module) + } + + return moduleType, err +} + +func (myFlags *Flags) UpdateSource(module string, moduleType string ) { + //if strings.Contains("?ref=", module) { + // moduleType = "url" // - //GCS buckets + // if myFlags.Update { + // splitter := strings.Split(module, "?ref=") + // base := splitter[0] + // log.Print(base) + // // get lastest tag from git reference + // //trim git: + // //trim + // } // - - return module, moduleType, err + // return moduleType, nil + //} } diff --git a/src/core/modules_test.go b/src/core/modules_test.go index 54e8743..fd1b93f 100644 --- a/src/core/modules_test.go +++ b/src/core/modules_test.go @@ -3,6 +3,7 @@ package core import "testing" func TestFlags_GetType(t *testing.T) { + t.Parallel() type fields struct { File string Directory string @@ -12,37 +13,44 @@ func TestFlags_GetType(t *testing.T) { Entries []string Update bool } + type args struct { module string } + tests := []struct { - name string - fields fields - args args - want string - want1 string - wantErr bool + name string + fields fields + args args + wantType string + wantErr bool }{ - {"Local paths", fields{}, args{"./testdata"}, "./testdata", "local", false}, - {"Local paths not found", fields{}, args{"./somewhere"}, "./somewhere", "", true}, - //{"Terraform Registry",""}, - // - //{"GitHub",""}, - // - //{"Bitbucket"""}, - // - //{"Generic Git, Mercurial repositories",""}, - // - //{"HTTP URLs",""}, - // - //{"S3 buckets",""}, - // - //{"GCS buckets",""}, + {"Local paths", fields{}, args{"./testdata"}, "local", false}, + {"Local paths not found", fields{}, args{"./somewhere"}, "local", true}, + + {"Terraform Registry", fields{}, args{"jameswoolfenden/http/ip"}, "github", false}, + {"Terraform Registry fail", fields{}, args{"jameswoolfenden/http/ip/duff"}, "", true}, + + // I dearly wanted to use that name + {"Bitbucket", fields{}, args{"bitbucket.org/hashicorp/terraform-consul-aws"}, "bitbucket", false}, + + {"Shallow", fields{}, args{"git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?depth=1"}, "shallow", false}, // + + {"Mercurial repositories", fields{}, args{"hg::http://example.com/vpc.hg"}, "mercurial", false}, // - //{"Modules in Package Sub-directories",""}, + {"archive", fields{}, args{"https://example.com/vpc-module.zip"}, "archive", false}, + {"archive", fields{}, args{"https://example.com/vpc-module?archive=zip"}, "archive", false}, + + {"S3 buckets", fields{}, args{"s3::https://s3-eu-west-1.amazonaws.com/examplecorp-terraform-modules/vpc.zip"}, "s3", false}, + {"GCS buckets", fields{}, args{"gcs::https://www.googleapis.com/storage/v1/modules/foomodule.zip"}, "gcs", false}, + + {"Modules in Package Sub-directories", fields{}, args{"hashicorp/consul/aws//modules/consul-cluster"}, "github", false}, + {"Modules 2", fields{}, args{"git::https://example.com/network.git//modules/vpc"}, "git", false}, } for _, tt := range tests { + tt := tt t.Run(tt.name, func(t *testing.T) { + t.Parallel() myFlags := &Flags{ File: tt.fields.File, Directory: tt.fields.Directory, @@ -52,16 +60,15 @@ func TestFlags_GetType(t *testing.T) { Entries: tt.fields.Entries, Update: tt.fields.Update, } - got, got1, err := myFlags.GetType(tt.args.module) + got, err := myFlags.GetType(tt.args.module) if (err != nil) != tt.wantErr { t.Errorf("GetType() error = %v, wantErr %v", err, tt.wantErr) + return } - if got != tt.want { - t.Errorf("GetType() got = %v, want %v", got, tt.want) - } - if got1 != tt.want1 { - t.Errorf("GetType() got1 = %v, want %v", got1, tt.want1) + + if got != tt.wantType { + t.Errorf("GetType() got = %v, want %v", got, tt.wantType) } }) } diff --git a/src/core/testdata/modules/depth/module.tf b/src/core/testdata/modules/depth/module.tf new file mode 100644 index 0000000..b30a0dc --- /dev/null +++ b/src/core/testdata/modules/depth/module.tf @@ -0,0 +1,3 @@ +module "memory" { + source = "git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?depth=1" +} From b5df9c0230c3c98fb32dbdbb7df14b60e9db3031 Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Sun, 13 Aug 2023 15:46:06 +0100 Subject: [PATCH 19/80] editing of hcl --- go.mod | 13 +++- go.sum | 93 ++++++++++++++++++++++-- src/core/modules.go | 152 ++++++++++++--------------------------- src/core/modules_test.go | 1 + 4 files changed, 144 insertions(+), 115 deletions(-) diff --git a/go.mod b/go.mod index a12b8fe..9345336 100644 --- a/go.mod +++ b/go.mod @@ -7,6 +7,8 @@ require ( github.com/rs/zerolog v1.30.0 github.com/sergi/go-diff v1.3.1 github.com/urfave/cli/v2 v2.25.7 + github.com/yudai/gojsondiff v1.0.0 + github.com/zclconf/go-cty v1.13.2 moul.io/banner v1.0.1 ) @@ -14,14 +16,21 @@ require ( github.com/agext/levenshtein v1.2.3 // indirect github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect + github.com/go-test/deep v1.0.7 // indirect github.com/google/go-cmp v0.5.9 // indirect + github.com/kr/pretty v0.2.1 // indirect + github.com/kr/text v0.2.0 // indirect + github.com/kylelemons/godebug v1.1.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.19 // indirect github.com/mitchellh/go-wordwrap v1.0.1 // indirect + github.com/onsi/ginkgo v1.16.5 // indirect + github.com/onsi/gomega v1.27.10 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect - github.com/stretchr/testify v1.5.1 // indirect + github.com/stretchr/testify v1.8.4 // indirect github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect - github.com/zclconf/go-cty v1.13.2 // indirect + github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirect + github.com/yudai/pp v2.0.1+incompatible // indirect golang.org/x/sys v0.11.0 // indirect golang.org/x/text v0.12.0 // indirect ) diff --git a/go.sum b/go.sum index 5292ca9..16c06f0 100644 --- a/go.sum +++ b/go.sum @@ -5,21 +5,41 @@ github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkE github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= +github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= +github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= +github.com/go-test/deep v1.0.7 h1:/VSMRlnY/JSyqxQUzQLKVMAskpY/NZKFA5j2P+0pP2M= +github.com/go-test/deep v1.0.7/go.mod h1:QV8Hv/iy04NyLBxAdO9njL0iVPN1S4d/A3NVv1V36o8= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/hashicorp/hcl/v2 v2.17.0 h1:z1XvSUyXd1HP10U4lrLg5e0JMVz6CPaJvAgxM0KNZVY= github.com/hashicorp/hcl/v2 v2.17.0/go.mod h1:gJyW2PTShkJqQBKpAmPO3yxMxIuoXkOF2TpqXzrQyx4= -github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= +github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348 h1:MtvEpTB6LX3vkb4ax0b5D2DHbNAUsen0Gx5wZoq3lV4= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= @@ -29,6 +49,17 @@ github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APP github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= +github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= +github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= +github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= +github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= +github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= +github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= +github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= +github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= +github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= +github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= @@ -41,26 +72,76 @@ github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs= github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= +github.com/yudai/gojsondiff v1.0.0 h1:27cbfqXLVEJ1o8I6v3y9lg8Ydm53EKqHXAOMxEGlCOA= +github.com/yudai/gojsondiff v1.0.0/go.mod h1:AY32+k2cwILAkW1fbgxQ5mUmMiZFgLIV+FBNExI05xg= +github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 h1:BHyfKlQyqbsFN5p3IfnEUduWvb9is428/nNb5L3U01M= +github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM= +github.com/yudai/pp v2.0.1+incompatible h1:Q4//iY4pNF6yPLZIigmvcl7k/bPgrcTPIFIcmawg5bI= +github.com/yudai/pp v2.0.1+incompatible/go.mod h1:PuxR/8QJ7cyCkFp/aUDS+JY727OFEZkTdatxwunjIkc= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/zclconf/go-cty v1.13.2 h1:4GvrUxe/QUDYuJKAav4EYqdM47/kZa672LwmXFmEKT0= github.com/zclconf/go-cty v1.13.2/go.mod h1:YKQzy/7pZ7iq2jNFzy5go57xdxdWoLLpaEp4u238AE0= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= moul.io/banner v1.0.1 h1:+WsemGLhj2pOajw2eR5VYjLhOIqs0XhIRYchzTyMLk0= moul.io/banner v1.0.1/go.mod h1:XwvIGKkhKRKyN1vIdmR5oaKQLIkMhkMqrsHpS94QzAU= diff --git a/src/core/modules.go b/src/core/modules.go index 2e42140..aedf4b4 100644 --- a/src/core/modules.go +++ b/src/core/modules.go @@ -8,131 +8,71 @@ import ( "strings" "github.com/hashicorp/hcl/v2" - "github.com/hashicorp/hcl/v2/hclparse" - "github.com/hashicorp/hcl/v2/hclsyntax" + "github.com/hashicorp/hcl/v2/hclwrite" "github.com/rs/zerolog/log" + diff "github.com/yudai/gojsondiff" + "github.com/zclconf/go-cty/cty" ) func (myFlags *Flags) UpdateModule(file string) error { - parser := hclparse.NewParser() + src, err := os.ReadFile(file) if err != nil { return fmt.Errorf("failed to read %s", file) } - parsedFile, fileDiags := parser.ParseHCL(src, file) - - if fileDiags.HasErrors() { - return fmt.Errorf("config parse: %w", fileDiags) - } - - content := parsedFile.Body.(*hclsyntax.Body) - - //newContent:=hcl.File{ - // Body: nil, - // Bytes: nil, - // Nav: nil, - //} + inFile, _ := hclwrite.ParseConfig(src, "", hcl.Pos{Line: 1, Column: 1}) + outFile := hclwrite.NewEmptyFile() - newBody := hclsyntax.Body{} + newBody := outFile.Body() + root := inFile.Body() - for _, block := range content.Blocks { + for _, block := range root.Blocks() { + if block.Type() == "module" { + version := GetStringValue(block, "version") + source := GetStringValue(block, "source") - if block.Type == "module" { - var source *hclsyntax.Attribute - var version *hclsyntax.Attribute - //version := cty.Value{} - //source := cty.Value{} + block.Body().RemoveAttribute("version") - myAttributes := block.Body.Attributes - newAttributes := hclsyntax.Attributes{} + myType, err := myFlags.GetType(source) - if myAttributes["source"] != nil { - source = myAttributes["source"] + if err != nil { + log.Info().Msgf("source type failure") + continue } - if myAttributes["version"] != nil { - version = myAttributes["version"] - } + block.Body().SetAttributeValue("source", cty.StringVal(myFlags.UpdateSource(source, myType, version))) + } + newBody.AppendBlock(block) + } - log.Print(source) - log.Print(version) - for x, attribute := range myAttributes { - - if attribute.Name == "version" { - continue - } - - if attribute.Name == "source" { - ctx := &hcl.EvalContext{} - - var diags hcl.Diagnostics - sourceValue, diags := attribute.Expr.Value(ctx) - if diags.HasErrors() { - return fmt.Errorf("version parse: %w", fileDiags) - } - - ModuleType, err := myFlags.GetType(sourceValue.AsString()) - - if err != nil { - return err - } - - =myFlags.UpdateSource(sourceValue.AsString(), ModuleType) - switch ModuleType { - case - } - - } - - newAttributes[x] = attribute - // ctx := &hcl.EvalContext{} - // var diags hcl.Diagnostics - // version, diags = attribute.Expr.Value(ctx) - // - // if diags.HasErrors() { - // return nil, fmt.Errorf("version parse: %w", fileDiags) - // } - // } - } + differ := diff.New() + compare, err := differ.Compare(src, outFile.Bytes()) - block.Body.Attributes = newAttributes - //log.Info().Msgf("%s", version) - //new tf file - - //terraformBlock, err := p.parseBlock(block, file) - //src, _ := os.ReadFile(file) - // - //hclFile, diags := hclwrite.ParseConfig(src, file, hcl.InitialPos) - // - //if diags.HasErrors() { - // return nil, fmt.Errorf("config parse: %w", diags) - //} - // - //hclSyntaxFile, diags := hclsyntax.ParseConfig(src, file, hcl.InitialPos) - - //f.Body().SetAttributeValue("version", cty.StringVal("999.999.999")) - - //myBlocks := test.Blocks() - //for _, block := range myBlocks { - // log.Print(block.Labels()) - //} - //log.Print(myBlocks) - //result := hclFile.Bytes() - //log.Print(result) - //log.Print(hclSyntaxFile) - newBody.Blocks = append(newBody.Blocks, block) - } else { - newBody.Blocks = append(newBody.Blocks, block) - log.Print(newBody) - } + if err != nil { + return err + } + if compare.Modified() && !myFlags.DryRun { + err := os.WriteFile(file, outFile.Bytes(), 0666) + if err != nil { + log.Info().Msgf("failed to write %s", file) + } } - //write back if modified and if !myFlags.DryRun return nil } +func GetStringValue(block *hclwrite.Block, attribute string) string { + var Value string + version := block.Body().GetAttribute(attribute) + + if (version != nil) && (len(version.Expr().BuildTokens(nil)) == 3) { + Value = string(version.Expr().BuildTokens(nil)[1].Bytes) + } + return Value +} + func (myFlags *Flags) UpdateModules() error { terraform, err := myFlags.GetTF() @@ -192,11 +132,8 @@ func (myFlags *Flags) GetType(module string) (string, error) { return "archive", nil } - var splitter []string - - // github registry format and suub dirs - - splitter = strings.Split(module, "/") + // gitHub registry format and sub dirs + splitter := strings.Split(module, "/") if len(splitter) == 3 && !(strings.Contains(module, "git::") || strings.Contains(module, "https:")) { return "github", nil @@ -229,7 +166,7 @@ func (myFlags *Flags) GetType(module string) (string, error) { return moduleType, err } -func (myFlags *Flags) UpdateSource(module string, moduleType string ) { +func (myFlags *Flags) UpdateSource(module string, moduleType string, version string) string { //if strings.Contains("?ref=", module) { // moduleType = "url" // @@ -244,4 +181,5 @@ func (myFlags *Flags) UpdateSource(module string, moduleType string ) { // // return moduleType, nil //} + return "test" } diff --git a/src/core/modules_test.go b/src/core/modules_test.go index fd1b93f..4027f58 100644 --- a/src/core/modules_test.go +++ b/src/core/modules_test.go @@ -18,6 +18,7 @@ func TestFlags_GetType(t *testing.T) { module string } + //goland:noinspection HttpUrlsUsage tests := []struct { name string fields fields From 7173992ac620c25d774af124af2995acb09c5633 Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Mon, 14 Aug 2023 08:17:49 +0100 Subject: [PATCH 20/80] new parsing method --- .pre-commit-config.yaml | 6 +- go.mod | 5 -- go.sum | 76 -------------------- src/core/modules.go | 25 ++++--- src/core/testdata/modules/registry/module.tf | 10 +-- 5 files changed, 24 insertions(+), 98 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cd9bd95..47f89a2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,7 +19,7 @@ repos: - id: detect-aws-credentials - id: detect-private-key - repo: https://github.com/Lucas-C/pre-commit-hooks - rev: v1.5.3 + rev: v1.5.4 hooks: - id: forbid-tabs exclude_types: [ python, javascript, dtd, markdown, makefile, xml ] @@ -51,11 +51,11 @@ repos: - id: go-mod-tidy - id: go-generate - repo: https://github.com/golangci/golangci-lint - rev: v1.54.0 + rev: v1.54.1 hooks: - id: golangci-lint - repo: https://github.com/bridgecrewio/checkov - rev: 2.3.360 + rev: 2.3.364 hooks: - id: checkov language_version: python3.10 diff --git a/go.mod b/go.mod index 9345336..11dd960 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,6 @@ require ( github.com/rs/zerolog v1.30.0 github.com/sergi/go-diff v1.3.1 github.com/urfave/cli/v2 v2.25.7 - github.com/yudai/gojsondiff v1.0.0 github.com/zclconf/go-cty v1.13.2 moul.io/banner v1.0.1 ) @@ -24,13 +23,9 @@ require ( github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.19 // indirect github.com/mitchellh/go-wordwrap v1.0.1 // indirect - github.com/onsi/ginkgo v1.16.5 // indirect - github.com/onsi/gomega v1.27.10 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/stretchr/testify v1.8.4 // indirect github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect - github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirect - github.com/yudai/pp v2.0.1+incompatible // indirect golang.org/x/sys v0.11.0 // indirect golang.org/x/text v0.12.0 // indirect ) diff --git a/go.sum b/go.sum index 16c06f0..db000d4 100644 --- a/go.sum +++ b/go.sum @@ -9,28 +9,13 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= -github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= -github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= github.com/go-test/deep v1.0.7 h1:/VSMRlnY/JSyqxQUzQLKVMAskpY/NZKFA5j2P+0pP2M= github.com/go-test/deep v1.0.7/go.mod h1:QV8Hv/iy04NyLBxAdO9njL0iVPN1S4d/A3NVv1V36o8= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= -github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= -github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= -github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= -github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/hashicorp/hcl/v2 v2.17.0 h1:z1XvSUyXd1HP10U4lrLg5e0JMVz6CPaJvAgxM0KNZVY= github.com/hashicorp/hcl/v2 v2.17.0/go.mod h1:gJyW2PTShkJqQBKpAmPO3yxMxIuoXkOF2TpqXzrQyx4= -github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= @@ -49,17 +34,6 @@ github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APP github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= -github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= -github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= -github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= -github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= -github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= -github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= -github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= -github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= -github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= -github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= @@ -72,75 +46,25 @@ github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs= github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= -github.com/yudai/gojsondiff v1.0.0 h1:27cbfqXLVEJ1o8I6v3y9lg8Ydm53EKqHXAOMxEGlCOA= -github.com/yudai/gojsondiff v1.0.0/go.mod h1:AY32+k2cwILAkW1fbgxQ5mUmMiZFgLIV+FBNExI05xg= -github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 h1:BHyfKlQyqbsFN5p3IfnEUduWvb9is428/nNb5L3U01M= -github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM= -github.com/yudai/pp v2.0.1+incompatible h1:Q4//iY4pNF6yPLZIigmvcl7k/bPgrcTPIFIcmawg5bI= -github.com/yudai/pp v2.0.1+incompatible/go.mod h1:PuxR/8QJ7cyCkFp/aUDS+JY727OFEZkTdatxwunjIkc= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/zclconf/go-cty v1.13.2 h1:4GvrUxe/QUDYuJKAav4EYqdM47/kZa672LwmXFmEKT0= github.com/zclconf/go-cty v1.13.2/go.mod h1:YKQzy/7pZ7iq2jNFzy5go57xdxdWoLLpaEp4u238AE0= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= -google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= -google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= -google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= -google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= moul.io/banner v1.0.1 h1:+WsemGLhj2pOajw2eR5VYjLhOIqs0XhIRYchzTyMLk0= diff --git a/src/core/modules.go b/src/core/modules.go index aedf4b4..0a0c135 100644 --- a/src/core/modules.go +++ b/src/core/modules.go @@ -10,7 +10,7 @@ import ( "github.com/hashicorp/hcl/v2" "github.com/hashicorp/hcl/v2/hclwrite" "github.com/rs/zerolog/log" - diff "github.com/yudai/gojsondiff" + "github.com/sergi/go-diff/diffmatchpatch" "github.com/zclconf/go-cty/cty" ) @@ -28,6 +28,7 @@ func (myFlags *Flags) UpdateModule(file string) error { root := inFile.Body() for _, block := range root.Blocks() { + if block.Type() == "module" { version := GetStringValue(block, "version") source := GetStringValue(block, "source") @@ -38,22 +39,28 @@ func (myFlags *Flags) UpdateModule(file string) error { if err != nil { log.Info().Msgf("source type failure") - continue + } else { + block.Body().SetAttributeValue("source", cty.StringVal(myFlags.UpdateSource(source, myType, version))) } - - block.Body().SetAttributeValue("source", cty.StringVal(myFlags.UpdateSource(source, myType, version))) } newBody.AppendBlock(block) } - differ := diff.New() - compare, err := differ.Compare(src, outFile.Bytes()) + var differ bool + temp := outFile.Bytes() - if err != nil { - return err + if string(src) != string(temp) { + differ = true + } + + dmp := diffmatchpatch.New() + diffs := dmp.DiffMain(string(src), string(temp), false) + + if differ { + fmt.Println(dmp.DiffPrettyText(diffs)) } - if compare.Modified() && !myFlags.DryRun { + if differ && !myFlags.DryRun { err := os.WriteFile(file, outFile.Bytes(), 0666) if err != nil { log.Info().Msgf("failed to write %s", file) diff --git a/src/core/testdata/modules/registry/module.tf b/src/core/testdata/modules/registry/module.tf index 2997d5e..fc4b53c 100644 --- a/src/core/testdata/modules/registry/module.tf +++ b/src/core/testdata/modules/registry/module.tf @@ -1,5 +1,5 @@ -module "ip" { - source = "JamesWoolfenden/ip/http" - version = "0.3.12" - permissions = "pike" -} +module "ip" { + source = "JamesWoolfenden/ip/http" + version = "0.3.12" + permissions = "pike" +} From b06f66d67368cf72c5a22d7c4f47a0b065bd605b Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Mon, 14 Aug 2023 17:47:46 +0100 Subject: [PATCH 21/80] in progress --- .pre-commit-config.yaml | 2 +- go.mod | 22 +++- go.sum | 108 +++++++++++++++++- src/core/gha.go | 8 +- src/core/modules.go | 228 ++++++++++++++++++++++++++++++++++---- src/core/modules_test.go | 117 ++++++++++++++++++- src/core/registry_test.go | 1 + 7 files changed, 459 insertions(+), 27 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 47f89a2..91b1e61 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -55,7 +55,7 @@ repos: hooks: - id: golangci-lint - repo: https://github.com/bridgecrewio/checkov - rev: 2.3.364 + rev: 2.3.365 hooks: - id: checkov language_version: python3.10 diff --git a/go.mod b/go.mod index 11dd960..ffd5c45 100644 --- a/go.mod +++ b/go.mod @@ -3,29 +3,47 @@ module ghat go 1.20 require ( + github.com/go-git/go-git/v5 v5.8.1 github.com/hashicorp/hcl/v2 v2.17.0 github.com/rs/zerolog v1.30.0 github.com/sergi/go-diff v1.3.1 github.com/urfave/cli/v2 v2.25.7 github.com/zclconf/go-cty v1.13.2 + golang.org/x/mod v0.12.0 moul.io/banner v1.0.1 ) require ( + dario.cat/mergo v1.0.0 // indirect + github.com/Microsoft/go-winio v0.6.1 // indirect + github.com/ProtonMail/go-crypto v0.0.0-20230717121422-5aa5874ade95 // indirect + github.com/acomagu/bufpipe v1.0.4 // indirect github.com/agext/levenshtein v1.2.3 // indirect github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect + github.com/cloudflare/circl v1.3.3 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect + github.com/emirpasic/gods v1.18.1 // indirect + github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect + github.com/go-git/go-billy/v5 v5.4.1 // indirect github.com/go-test/deep v1.0.7 // indirect + github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/google/go-cmp v0.5.9 // indirect - github.com/kr/pretty v0.2.1 // indirect - github.com/kr/text v0.2.0 // indirect + github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect + github.com/kevinburke/ssh_config v1.2.0 // indirect github.com/kylelemons/godebug v1.1.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.19 // indirect github.com/mitchellh/go-wordwrap v1.0.1 // indirect + github.com/pjbgf/sha1cd v0.3.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect + github.com/skeema/knownhosts v1.2.0 // indirect github.com/stretchr/testify v1.8.4 // indirect + github.com/xanzy/ssh-agent v0.3.3 // indirect github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect + golang.org/x/crypto v0.12.0 // indirect + golang.org/x/net v0.14.0 // indirect golang.org/x/sys v0.11.0 // indirect golang.org/x/text v0.12.0 // indirect + golang.org/x/tools v0.12.0 // indirect + gopkg.in/warnings.v0 v0.1.2 // indirect ) diff --git a/go.sum b/go.sum index db000d4..fd69275 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,21 @@ +dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= +dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= +github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= +github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= +github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= +github.com/ProtonMail/go-crypto v0.0.0-20230717121422-5aa5874ade95 h1:KLq8BE0KwCL+mmXnjLWEAOYO+2l2AE4YMmqG1ZpZHBs= +github.com/ProtonMail/go-crypto v0.0.0-20230717121422-5aa5874ade95/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= +github.com/acomagu/bufpipe v1.0.4 h1:e3H4WUzM3npvo5uv95QuJM3cQspFNtFBzvJ2oNjKIDQ= +github.com/acomagu/bufpipe v1.0.4/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4= github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= +github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8= github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw= github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo= +github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= +github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= +github.com/cloudflare/circl v1.3.3 h1:fE/Qz0QdIGqeWfnwq0RE0R7MI51s0M2E4Ga9kq5AEMs= +github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= @@ -9,22 +23,41 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/elazarl/goproxy v0.0.0-20221015165544-a0805db90819 h1:RIB4cRk+lBqKK3Oy0r2gRX4ui7tuhiZq2SuTtTCi0/0= +github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= +github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= +github.com/gliderlabs/ssh v0.3.5 h1:OcaySEmAQJgyYcArR+gGGTHCyE7nvhEMTlYY+Dp8CpY= +github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI= +github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic= +github.com/go-git/go-billy/v5 v5.4.1 h1:Uwp5tDRkPr+l/TnbHOQzp+tmJfLceOlbVucgpTz8ix4= +github.com/go-git/go-billy/v5 v5.4.1/go.mod h1:vjbugF6Fz7JIflbVpl1hJsGjSHNltrSw45YK/ukIvQg= +github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20230305113008-0c11038e723f h1:Pz0DHeFij3XFhoBRGUDPzSJ+w2UcK5/0JvF8DRI58r8= +github.com/go-git/go-git/v5 v5.8.1 h1:Zo79E4p7TRk0xoRgMq0RShiTHGKcKI4+DI6BfJc/Q+A= +github.com/go-git/go-git/v5 v5.8.1/go.mod h1:FHFuoD6yGz5OSKEBK+aWN9Oah0q54Jxl0abmj6GnqAo= github.com/go-test/deep v1.0.7 h1:/VSMRlnY/JSyqxQUzQLKVMAskpY/NZKFA5j2P+0pP2M= github.com/go-test/deep v1.0.7/go.mod h1:QV8Hv/iy04NyLBxAdO9njL0iVPN1S4d/A3NVv1V36o8= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/hashicorp/hcl/v2 v2.17.0 h1:z1XvSUyXd1HP10U4lrLg5e0JMVz6CPaJvAgxM0KNZVY= github.com/hashicorp/hcl/v2 v2.17.0/go.mod h1:gJyW2PTShkJqQBKpAmPO3yxMxIuoXkOF2TpqXzrQyx4= +github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= +github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= +github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= +github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/matryer/is v1.2.0 h1:92UTHpy8CDwaJ08GqLDzhhuixiBUUD1p3AU6PHddz4A= +github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA= github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= @@ -34,9 +67,14 @@ github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APP github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= +github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4= +github.com/pjbgf/sha1cd v0.3.0/go.mod h1:nZ1rrWOcGJ5uZgEEVL1VUM9iRQiZvWdbZjkKyFzPPsI= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.30.0 h1:SymVODrcRsaRaSInD9yQtKbtWqwsfoPcRff/oRXLj4c= github.com/rs/zerolog v1.30.0/go.mod h1:/tk+P47gFdPXq4QYjvCmT5/Gsug2nagsFWBWhAiSi1w= @@ -44,28 +82,96 @@ github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= +github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= +github.com/skeema/knownhosts v1.2.0 h1:h9r9cf0+u7wSE+M183ZtMGgOJKiL96brpaz5ekfJCpM= +github.com/skeema/knownhosts v1.2.0/go.mod h1:g4fPeYpque7P0xefxtGzV81ihjC8sX2IqpAoNkjxbMo= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs= github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= +github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= +github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/zclconf/go-cty v1.13.2 h1:4GvrUxe/QUDYuJKAav4EYqdM47/kZa672LwmXFmEKT0= github.com/zclconf/go-cty v1.13.2/go.mod h1:YKQzy/7pZ7iq2jNFzy5go57xdxdWoLLpaEp4u238AE0= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= +golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= +golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= +golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= +golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= +golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= +golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= +golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= +golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= +golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= +golang.org/x/term v0.11.0 h1:F9tnn/DA/Im8nCwm+fX+1/eBwi4qFjRT++MhtVC4ZX0= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= +golang.org/x/tools v0.12.0 h1:YW6HUoUmYBpwSgyaGaZq1fHjrBjX1rlpZ54T6mu2kss= +golang.org/x/tools v0.12.0/go.mod h1:Sc0INKfu04TlqNoRA1hgpFZbhYXHPr4V5DzpSBTPqQM= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= +gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= moul.io/banner v1.0.1 h1:+WsemGLhj2pOajw2eR5VYjLhOIqs0XhIRYchzTyMLk0= moul.io/banner v1.0.1/go.mod h1:XwvIGKkhKRKyN1vIdmR5oaKQLIkMhkMqrsHpS94QzAU= diff --git a/src/core/gha.go b/src/core/gha.go index a149393..b3c4350 100644 --- a/src/core/gha.go +++ b/src/core/gha.go @@ -186,13 +186,17 @@ func (myFlags *Flags) UpdateGHA(file string) error { func getPayload(action string, gitHubToken string, days *int) (interface{}, error) { if *days == 0 { - url := "https://api.github.com/repos/" + action + "/releases/latest" - return GetGithubBody(gitHubToken, url) + return GetLatest(action, gitHubToken) } return GetReleases(action, gitHubToken, days) } +func GetLatest(action string, gitHubToken string) (interface{}, error) { + url := "https://api.github.com/repos/" + action + "/releases/latest" + return GetGithubBody(gitHubToken, url) +} + func getHash(action string, tag string, gitHubToken string) (interface{}, error) { url := "https://api.github.com/repos/" + action + "/git/ref/tags/" + tag return GetGithubBody(gitHubToken, url) diff --git a/src/core/modules.go b/src/core/modules.go index 0a0c135..b02c00c 100644 --- a/src/core/modules.go +++ b/src/core/modules.go @@ -2,16 +2,19 @@ package core import ( "fmt" + "github.com/go-git/go-git/v5/storage/memory" "os" "path" "path/filepath" "strings" + "github.com/go-git/go-git/v5" "github.com/hashicorp/hcl/v2" "github.com/hashicorp/hcl/v2/hclwrite" "github.com/rs/zerolog/log" "github.com/sergi/go-diff/diffmatchpatch" "github.com/zclconf/go-cty/cty" + "golang.org/x/mod/semver" ) func (myFlags *Flags) UpdateModule(file string) error { @@ -28,7 +31,6 @@ func (myFlags *Flags) UpdateModule(file string) error { root := inFile.Body() for _, block := range root.Blocks() { - if block.Type() == "module" { version := GetStringValue(block, "version") source := GetStringValue(block, "source") @@ -40,13 +42,19 @@ func (myFlags *Flags) UpdateModule(file string) error { if err != nil { log.Info().Msgf("source type failure") } else { - block.Body().SetAttributeValue("source", cty.StringVal(myFlags.UpdateSource(source, myType, version))) + newValue, version, err := myFlags.UpdateSource(source, myType, version) + if err != nil { + log.Info().Msgf("failed to update module source %s", err) + } + block.Body().SetAttributeValue("source", cty.StringVal(newValue+"# "+version)) } } + newBody.AppendBlock(block) } var differ bool + temp := outFile.Bytes() if string(src) != string(temp) { @@ -143,7 +151,11 @@ func (myFlags *Flags) GetType(module string) (string, error) { splitter := strings.Split(module, "/") if len(splitter) == 3 && !(strings.Contains(module, "git::") || strings.Contains(module, "https:")) { - return "github", nil + if strings.Contains(module, "github.com") { + return "github", nil + } + + return "registry", nil } if strings.Contains(module, "depth=") { @@ -173,20 +185,198 @@ func (myFlags *Flags) GetType(module string) (string, error) { return moduleType, err } -func (myFlags *Flags) UpdateSource(module string, moduleType string, version string) string { - //if strings.Contains("?ref=", module) { - // moduleType = "url" - // - // if myFlags.Update { - // splitter := strings.Split(module, "?ref=") - // base := splitter[0] - // log.Print(base) - // // get lastest tag from git reference - // //trim git: - // //trim - // } - // - // return moduleType, nil - //} - return "test" +func (myFlags *Flags) UpdateSource(module string, moduleType string, version string) (string, string, error) { + + var newModule string + var hash string + var err error + + switch moduleType { + case "git": + { + //var hash string + newModule := strings.TrimLeft(module, "git::") + + if strings.Contains(newModule, ",") { + commas := strings.Split(newModule, ",") + + if len(commas) > 1 { + log.Info().Msgf("too many urlparams") + //do something + } + } + splitter := strings.Split(newModule, "?ref=") + + root := splitter[0] + + if len(splitter) > 1 { + version = splitter[1] + } + + if myFlags.Update { + if strings.Contains(newModule, "github.com") { + hash, version, err := myFlags.GetGithubLatestHash(newModule) + if err != nil { + return "", "", err + } + + return "git::" + root + "?ref=" + hash, version, nil + } else { + repo, err := git.Clone(memory.NewStorage(), nil, &git.CloneOptions{ + URL: strings.TrimRight(module, ".git"), + }) + + if err != nil { + return "", "", fmt.Errorf("failed to clone %s", newModule) + } + + ref, err := repo.Head() + log.Print(ref) + } + + // get latest hash for root + log.Print(root) + } else { + if strings.Contains(newModule, "github.com") { + if version != "" { + hash, err = myFlags.GetGithubHash(strings.TrimLeft(newModule, "https://"), version) + if err != nil { + return "", "", err + } + } else { + hash, version, err = myFlags.GetGithubLatestHash(newModule) + if err != nil { + return "", "", err + } + } + return "git::" + root + "?ref=" + hash, version, nil + } + + log.Info().Msgf(" git != github") + } + } + + case "registry": + { + splits := strings.Split(module, "/") + if len(splits) != 4 { + return "", "", fmt.Errorf("registry format should split 3 ways") + } + + newModule := splits[0] + "/" + splits[1] + "-" + splits[3] + "-" + splits[2] + + return myFlags.UpdateGithubSource(version, newModule) + } + + case "github": + { + + } + + case "mercurial": + { + + } + + case "local", "shallow", "archive", "s3", "gcs": + { + log.Info().Msgf("module source is %s of type %s and cannot be updated", module, moduleType) + return module, version, nil + } + + default: + { + log.Info().Msgf("unknown module type encountered %s", moduleType) + } + } + + return newModule, version, nil +} + +func (myFlags *Flags) UpdateGithubSource(version string, newModule string) (string, string, error) { + var hash string + var err error + + if myFlags.Update { + hash, version, err = myFlags.GetGithubLatestHash(newModule) + if err != nil { + return "", "", err + } + } else { + if version != "" { + hash, err = myFlags.GetGithubHash(newModule, version) + if err != nil { + return "", "", err + } + } else { + hash, version, err = myFlags.GetGithubLatestHash(newModule) + if err != nil { + return "", "", err + } + } + } + + root := "github.com/" + newModule + return "git::" + root + "?ref=" + hash, version, nil +} + +func (myFlags *Flags) GetGithubLatestHash(newModule string) (string, string, error) { + + name := strings.Split(newModule, "github.com/") + + action := strings.Split(name[1], ".git") + payload, err := GetLatest(action[0], myFlags.GitHubToken) + + if err != nil { + return "", "", err + } + + assertedPayload := payload.(map[string]interface{}) + + version := assertedPayload["tag_name"].(string) + hash, err := myFlags.GetGithubHash(newModule, version) + + if err != nil { + return "", "", err + } + + return hash, version, nil +} + +func (myFlags *Flags) GetGithubHash(newModule string, tag string) (string, error) { + var err error + + var hash string + + var url string + + var payload interface{} + + name := strings.Split(newModule, "github.com/") + action := strings.Split(name[1], ".git") + + valid := semver.IsValid(tag) + + if valid { + url = "https://api.github.com/repos/" + action[0] + "/git/ref/tags/" + tag + payload, err = GetGithubBody(myFlags.GitHubToken, url) + + if err != nil { + return "", err + } + + assertedPayload := payload.(map[string]interface{}) + + object := assertedPayload["object"].(map[string]interface{}) + + hash = object["sha"].(string) + } else { + if len(tag) == 64 || len(tag) == 7 { + hash = tag + } else { + return "", fmt.Errorf("supplied hash is not a short or a long hash") + } + } + + return hash, err } diff --git a/src/core/modules_test.go b/src/core/modules_test.go index 4027f58..c525441 100644 --- a/src/core/modules_test.go +++ b/src/core/modules_test.go @@ -1,6 +1,8 @@ package core -import "testing" +import ( + "testing" +) func TestFlags_GetType(t *testing.T) { t.Parallel() @@ -29,8 +31,13 @@ func TestFlags_GetType(t *testing.T) { {"Local paths", fields{}, args{"./testdata"}, "local", false}, {"Local paths not found", fields{}, args{"./somewhere"}, "local", true}, - {"Terraform Registry", fields{}, args{"jameswoolfenden/http/ip"}, "github", false}, + {"Terraform Registry", fields{}, args{"jameswoolfenden/http/ip"}, "registry", false}, {"Terraform Registry fail", fields{}, args{"jameswoolfenden/http/ip/duff"}, "", true}, + {"github", fields{}, args{"github.com/jameswoolfenden/terraform-http-ip"}, "github", false}, + + {"git", fields{}, args{"git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git"}, "git", false}, + {"git query string", fields{}, args{"git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git"}, "git", false}, + {"git query string", fields{}, args{"git::ssh://github.com/terraform-aws-modules/terraform-aws-memory-db"}, "git", false}, // I dearly wanted to use that name {"Bitbucket", fields{}, args{"bitbucket.org/hashicorp/terraform-consul-aws"}, "bitbucket", false}, @@ -74,3 +81,109 @@ func TestFlags_GetType(t *testing.T) { }) } } + +func TestFlags_UpdateSource(t *testing.T) { + type fields struct { + File string + Directory string + GitHubToken string + Days int + DryRun bool + Entries []string + Update bool + } + type args struct { + module string + moduleType string + version string + } + tests := []struct { + name string + fields fields + args args + want string + want1 string + wantErr bool + }{ + {"Local paths", fields{}, args{"./testdata", "local", ""}, "./testdata", "", false}, + {"Local paths not found", fields{}, args{"./somewhere", "local", ""}, "./somewhere", "", false}, + // + //{"Terraform Registry", fields{}, args{"jameswoolfenden/http/ip"}, "registry", false}, + //{"Terraform Registry fail", fields{}, args{"jameswoolfenden/http/ip/duff"}, "", true}, + //{"github", fields{}, args{"github.com/jameswoolfenden/terraform-http-ip"}, "github", false}, + // + {"git", + fields{"", "", gitHubToken, 0, false, nil, false}, + args{"git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git", "git", ""}, + "git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=c6d56c13e65876d7df7b7a9a21ffc010396120e7", "v2.0.0", false}, + {"git update", + fields{"", "", gitHubToken, 0, false, nil, true}, + args{"git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git", "git", ""}, + "git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=c6d56c13e65876d7df7b7a9a21ffc010396120e7", "v2.0.0", false}, + {"git version", + fields{"", "", gitHubToken, 0, false, nil, false}, + args{"git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=v1.0.0", "git", ""}, + "git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=c1a0698ae1ae4ced03399809ef3e0253b07c44a9", "v1.0.0", false}, + {"git version update", + fields{"", "", gitHubToken, 0, false, nil, true}, + args{"git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=v1.0.0", "git", ""}, + "git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=c6d56c13e65876d7df7b7a9a21ffc010396120e7", "v2.0.0", false}, + {"git version missing", + fields{"", "", gitHubToken, 0, false, nil, false}, + args{"git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=v1.2.0", "git", ""}, + "", "", true}, + {"git hash", + fields{"", "", gitHubToken, 0, false, nil, false}, + args{"git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=c6d56c1", "git", ""}, + "git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=c6d56c1", "c6d56c1", false}, + {name: "git hash update", + fields: fields{"", "", gitHubToken, 0, false, nil, true}, + args: args{"git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=c6d56c13e65876d7df7b7a9a21ffc010396120e7", "git", ""}, + want: "git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=c6d56c13e65876d7df7b7a9a21ffc010396120e7", + want1: "v2.0.0", + wantErr: false}, + + //{"git query string", fields{}, args{"git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git"}, "git", false}, + //{"git query string", fields{}, args{"git::ssh://github.com/terraform-aws-modules/terraform-aws-memory-db.git"}, "git", false}, + // + //// I dearly wanted to use that name + //{"Bitbucket", fields{}, args{"bitbucket.org/hashicorp/terraform-consul-aws"}, "bitbucket", false}, + // + //{"Shallow", fields{}, args{"git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?depth=1"}, "shallow", false}, // + // + //{"Mercurial repositories", fields{}, args{"hg::http://example.com/vpc.hg"}, "mercurial", false}, + //// + //{"archive", fields{}, args{"https://example.com/vpc-module.zip"}, "archive", false}, + //{"archive", fields{}, args{"https://example.com/vpc-module?archive=zip"}, "archive", false}, + // + //{"S3 buckets", fields{}, args{"s3::https://s3-eu-west-1.amazonaws.com/examplecorp-terraform-modules/vpc.zip"}, "s3", false}, + //{"GCS buckets", fields{}, args{"gcs::https://www.googleapis.com/storage/v1/modules/foomodule.zip"}, "gcs", false}, + // + //{"Modules in Package Sub-directories", fields{}, args{"hashicorp/consul/aws//modules/consul-cluster"}, "github", false}, + //{"Modules 2", fields{}, args{"git::https://example.com/network.git//modules/vpc"}, "git", false}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + myFlags := &Flags{ + File: tt.fields.File, + Directory: tt.fields.Directory, + GitHubToken: tt.fields.GitHubToken, + Days: tt.fields.Days, + DryRun: tt.fields.DryRun, + Entries: tt.fields.Entries, + Update: tt.fields.Update, + } + got, got1, err := myFlags.UpdateSource(tt.args.module, tt.args.moduleType, tt.args.version) + if (err != nil) != tt.wantErr { + t.Errorf("UpdateSource() error = %v, wantErr %v", err, tt.wantErr) + return + } + if got != tt.want { + t.Errorf("UpdateSource() got = %v, want %v", got, tt.want) + } + if got1 != tt.want1 { + t.Errorf("UpdateSource() got1 = %v, want %v", got1, tt.want1) + } + }) + } +} diff --git a/src/core/registry_test.go b/src/core/registry_test.go index 878523c..7967200 100644 --- a/src/core/registry_test.go +++ b/src/core/registry_test.go @@ -30,6 +30,7 @@ func TestIsOK(t *testing.T) { got, err := IsOK(tt.args.url) if (err != nil) != tt.wantErr { t.Errorf("IsOK() error = %v, wantErr %v", err, tt.wantErr) + return } if !reflect.DeepEqual(got, tt.want) { From 97c93108789a7865d10388a2c85d73dec3dd1e92 Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Mon, 14 Aug 2023 20:38:31 +0100 Subject: [PATCH 22/80] getting there --- src/core/modules.go | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/core/modules.go b/src/core/modules.go index b02c00c..15c0f35 100644 --- a/src/core/modules.go +++ b/src/core/modules.go @@ -2,13 +2,13 @@ package core import ( "fmt" - "github.com/go-git/go-git/v5/storage/memory" "os" "path" "path/filepath" "strings" "github.com/go-git/go-git/v5" + "github.com/go-git/go-git/v5/storage/memory" "github.com/hashicorp/hcl/v2" "github.com/hashicorp/hcl/v2/hclwrite" "github.com/rs/zerolog/log" @@ -33,6 +33,10 @@ func (myFlags *Flags) UpdateModule(file string) error { for _, block := range root.Blocks() { if block.Type() == "module" { version := GetStringValue(block, "version") + if !strings.Contains(version, "v") { + version = "v" + version + } + source := GetStringValue(block, "source") block.Body().RemoveAttribute("version") @@ -46,7 +50,8 @@ func (myFlags *Flags) UpdateModule(file string) error { if err != nil { log.Info().Msgf("failed to update module source %s", err) } - block.Body().SetAttributeValue("source", cty.StringVal(newValue+"# "+version)) + block.Body().SetAttributeValue("source", cty.StringVal(newValue)) + log.Info().Msgf("updated %s with hash of version %s", newValue, version) } } @@ -220,7 +225,7 @@ func (myFlags *Flags) UpdateSource(module string, moduleType string, version str return "", "", err } - return "git::" + root + "?ref=" + hash, version, nil + return "git::https://" + root + "?ref=" + hash, version, nil } else { repo, err := git.Clone(memory.NewStorage(), nil, &git.CloneOptions{ URL: strings.TrimRight(module, ".git"), @@ -231,6 +236,9 @@ func (myFlags *Flags) UpdateSource(module string, moduleType string, version str } ref, err := repo.Head() + if err != nil { + return "", "", err + } log.Print(ref) } @@ -249,21 +257,22 @@ func (myFlags *Flags) UpdateSource(module string, moduleType string, version str return "", "", err } } - return "git::" + root + "?ref=" + hash, version, nil + return "git::https://" + root + "?ref=" + hash, version, nil + } else { + log.Info().Msgf("git != github") } - - log.Info().Msgf(" git != github") } } case "registry": { splits := strings.Split(module, "/") - if len(splits) != 4 { + if len(splits) != 3 { return "", "", fmt.Errorf("registry format should split 3 ways") } - newModule := splits[0] + "/" + splits[1] + "-" + splits[3] + "-" + splits[2] + //e.g. jameswoolfenden/terraform-http-ip + newModule := "github.com" + "/" + splits[0] + "/" + "terraform" + "-" + splits[2] + "-" + splits[1] + ".git" return myFlags.UpdateGithubSource(version, newModule) } @@ -316,8 +325,7 @@ func (myFlags *Flags) UpdateGithubSource(version string, newModule string) (stri } } - root := "github.com/" + newModule - return "git::" + root + "?ref=" + hash, version, nil + return "git::https://" + newModule + "?ref=" + hash, version, nil } func (myFlags *Flags) GetGithubLatestHash(newModule string) (string, string, error) { From 319cb61e1668e662da0d4fca3de3f84b056a5ba1 Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Tue, 15 Aug 2023 08:20:19 +0100 Subject: [PATCH 23/80] remove dir --- src/core/modules.go | 13 ++++++++++--- src/core/modules_test.go | 4 ++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/core/modules.go b/src/core/modules.go index 15c0f35..d5bfaf6 100644 --- a/src/core/modules.go +++ b/src/core/modules.go @@ -182,11 +182,15 @@ func (myFlags *Flags) GetType(module string) (string, error) { err = os.MkdirAll(module, 0700) + remove := os.RemoveAll(module) + + if remove != nil { + log.Info().Msgf("%s", remove) + } + if err == nil { - _ = os.Remove(module) return "local", fmt.Errorf("localpath not found %s", module) } - return moduleType, err } @@ -247,7 +251,10 @@ func (myFlags *Flags) UpdateSource(module string, moduleType string, version str } else { if strings.Contains(newModule, "github.com") { if version != "" { - hash, err = myFlags.GetGithubHash(strings.TrimLeft(newModule, "https://"), version) + hash, err = myFlags.GetGithubHash( + strings.TrimPrefix(newModule, "https://"), + version, + ) if err != nil { return "", "", err } diff --git a/src/core/modules_test.go b/src/core/modules_test.go index c525441..6b40c88 100644 --- a/src/core/modules_test.go +++ b/src/core/modules_test.go @@ -32,7 +32,7 @@ func TestFlags_GetType(t *testing.T) { {"Local paths not found", fields{}, args{"./somewhere"}, "local", true}, {"Terraform Registry", fields{}, args{"jameswoolfenden/http/ip"}, "registry", false}, - {"Terraform Registry fail", fields{}, args{"jameswoolfenden/http/ip/duff"}, "", true}, + {"Terraform Registry fail", fields{}, args{"jameswoolfenden/http/ip/duff"}, "local", true}, {"github", fields{}, args{"github.com/jameswoolfenden/terraform-http-ip"}, "github", false}, {"git", fields{}, args{"git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git"}, "git", false}, @@ -52,7 +52,7 @@ func TestFlags_GetType(t *testing.T) { {"S3 buckets", fields{}, args{"s3::https://s3-eu-west-1.amazonaws.com/examplecorp-terraform-modules/vpc.zip"}, "s3", false}, {"GCS buckets", fields{}, args{"gcs::https://www.googleapis.com/storage/v1/modules/foomodule.zip"}, "gcs", false}, - {"Modules in Package Sub-directories", fields{}, args{"hashicorp/consul/aws//modules/consul-cluster"}, "github", false}, + {"Modules in Package Sub-directories", fields{}, args{"hashicorp/consul/aws//modules/consul-cluster"}, "registry", false}, {"Modules 2", fields{}, args{"git::https://example.com/network.git//modules/vpc"}, "git", false}, } for _, tt := range tests { From 1066e59897b93e0ddc0e8588c1990875c0d3243b Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Tue, 15 Aug 2023 10:21:04 +0100 Subject: [PATCH 24/80] first draft on updating source field --- src/core/modules.go | 55 ++++++++++----- src/core/modules_test.go | 82 ++++++++++++++++------ src/core/registry_test.go | 4 +- src/core/testdata/modules/subdir/module.tf | 3 + 4 files changed, 106 insertions(+), 38 deletions(-) create mode 100644 src/core/testdata/modules/subdir/module.tf diff --git a/src/core/modules.go b/src/core/modules.go index d5bfaf6..2db978f 100644 --- a/src/core/modules.go +++ b/src/core/modules.go @@ -180,17 +180,10 @@ func (myFlags *Flags) GetType(module string) (string, error) { return myFlags.GetType(temp) } - err = os.MkdirAll(module, 0700) - - remove := os.RemoveAll(module) - - if remove != nil { - log.Info().Msgf("%s", remove) - } - - if err == nil { + if _, err := os.Stat(module); os.IsNotExist(err) { return "local", fmt.Errorf("localpath not found %s", module) } + return moduleType, err } @@ -229,7 +222,7 @@ func (myFlags *Flags) UpdateSource(module string, moduleType string, version str return "", "", err } - return "git::https://" + root + "?ref=" + hash, version, nil + return "git::" + root + "?ref=" + hash, version, nil } else { repo, err := git.Clone(memory.NewStorage(), nil, &git.CloneOptions{ URL: strings.TrimRight(module, ".git"), @@ -264,7 +257,7 @@ func (myFlags *Flags) UpdateSource(module string, moduleType string, version str return "", "", err } } - return "git::https://" + root + "?ref=" + hash, version, nil + return "git::" + root + "?ref=" + hash, version, nil } else { log.Info().Msgf("git != github") } @@ -273,7 +266,17 @@ func (myFlags *Flags) UpdateSource(module string, moduleType string, version str case "registry": { + var subdir string + + subdirs := strings.Split(module, "//") + + if len(subdirs) == 2 { + subdir = subdirs[1] + module = subdirs[0] + } + splits := strings.Split(module, "/") + if len(splits) != 3 { return "", "", fmt.Errorf("registry format should split 3 ways") } @@ -281,20 +284,32 @@ func (myFlags *Flags) UpdateSource(module string, moduleType string, version str //e.g. jameswoolfenden/terraform-http-ip newModule := "github.com" + "/" + splits[0] + "/" + "terraform" + "-" + splits[2] + "-" + splits[1] + ".git" - return myFlags.UpdateGithubSource(version, newModule) + if subdir == "" { + return myFlags.UpdateGithubSource(version, newModule) + } else { + return myFlags.WithSubDir(version, newModule, subdir) + } + } case "github": { + subdirs := strings.Split(module, "//") + if len(subdirs) == 2 { + subdir := subdirs[1] + root := subdirs[0] + //e.g. jameswoolfenden/terraform-http-ip + newModule := root + ".git" - } + return myFlags.WithSubDir(version, newModule, subdir) - case "mercurial": - { + } + newModule = module + ".git" + return myFlags.UpdateGithubSource(version, newModule) } - case "local", "shallow", "archive", "s3", "gcs": + case "local", "shallow", "archive", "s3", "gcs", "mercurial": { log.Info().Msgf("module source is %s of type %s and cannot be updated", module, moduleType) return module, version, nil @@ -309,6 +324,14 @@ func (myFlags *Flags) UpdateSource(module string, moduleType string, version str return newModule, version, nil } +func (myFlags *Flags) WithSubDir(version string, newModule string, subdir string) (string, string, error) { + url, version, err := myFlags.UpdateGithubSource(version, newModule) + + urlsplit := strings.Split(url, ".git") + newUrl := urlsplit[0] + ".git" + "//" + subdir + urlsplit[1] + return newUrl, version, err +} + func (myFlags *Flags) UpdateGithubSource(version string, newModule string) (string, string, error) { var hash string var err error diff --git a/src/core/modules_test.go b/src/core/modules_test.go index 6b40c88..76d82ed 100644 --- a/src/core/modules_test.go +++ b/src/core/modules_test.go @@ -107,11 +107,19 @@ func TestFlags_UpdateSource(t *testing.T) { }{ {"Local paths", fields{}, args{"./testdata", "local", ""}, "./testdata", "", false}, {"Local paths not found", fields{}, args{"./somewhere", "local", ""}, "./somewhere", "", false}, - // - //{"Terraform Registry", fields{}, args{"jameswoolfenden/http/ip"}, "registry", false}, - //{"Terraform Registry fail", fields{}, args{"jameswoolfenden/http/ip/duff"}, "", true}, - //{"github", fields{}, args{"github.com/jameswoolfenden/terraform-http-ip"}, "github", false}, - // + + {"github", + fields{"", "", gitHubToken, 0, false, nil, true}, + args{"github.com/hashicorp/terraform-aws-consul", "github", ""}, + "git::https://github.com/hashicorp/terraform-aws-consul.git?ref=e9ceb573687c3d28516c9e3714caca84db64a766", + "v0.11.0", + false}, + {"Terraform Registry fail", + fields{}, + args{"jameswoolfenden/http/ip/duff", "registry", ""}, + "", + "", + true}, {"git", fields{"", "", gitHubToken, 0, false, nil, false}, args{"git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git", "git", ""}, @@ -146,21 +154,55 @@ func TestFlags_UpdateSource(t *testing.T) { //{"git query string", fields{}, args{"git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git"}, "git", false}, //{"git query string", fields{}, args{"git::ssh://github.com/terraform-aws-modules/terraform-aws-memory-db.git"}, "git", false}, // - //// I dearly wanted to use that name - //{"Bitbucket", fields{}, args{"bitbucket.org/hashicorp/terraform-consul-aws"}, "bitbucket", false}, - // - //{"Shallow", fields{}, args{"git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?depth=1"}, "shallow", false}, // - // - //{"Mercurial repositories", fields{}, args{"hg::http://example.com/vpc.hg"}, "mercurial", false}, - //// - //{"archive", fields{}, args{"https://example.com/vpc-module.zip"}, "archive", false}, - //{"archive", fields{}, args{"https://example.com/vpc-module?archive=zip"}, "archive", false}, - // - //{"S3 buckets", fields{}, args{"s3::https://s3-eu-west-1.amazonaws.com/examplecorp-terraform-modules/vpc.zip"}, "s3", false}, - //{"GCS buckets", fields{}, args{"gcs::https://www.googleapis.com/storage/v1/modules/foomodule.zip"}, "gcs", false}, - // - //{"Modules in Package Sub-directories", fields{}, args{"hashicorp/consul/aws//modules/consul-cluster"}, "github", false}, - //{"Modules 2", fields{}, args{"git::https://example.com/network.git//modules/vpc"}, "git", false}, + // I dearly wanted to use that name + {"Bitbucket", fields{}, args{"bitbucket.org/hashicorp/terraform-consul-aws", "bitbucket", ""}, + "", + "", + false}, + + {"Shallow", fields{}, args{"git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?depth=1", "shallow", ""}, + "git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?depth=1", + "", + false}, // + + {"Mercurial repositories", fields{}, args{"hg::http://example.com/vpc.hg", "mercurial", ""}, + "hg::http://example.com/vpc.hg", + "", + false}, + + {"archive", fields{}, args{"https://example.com/vpc-module.zip", "archive", ""}, + "https://example.com/vpc-module.zip", + "", + false}, + {"archive", fields{}, args{"https://example.com/vpc-module?archive=zip", "archive", ""}, + "https://example.com/vpc-module?archive=zip", + "", + false}, + + {"S3 buckets", fields{}, args{"s3::https://s3-eu-west-1.amazonaws.com/examplecorp-terraform-modules/vpc.zip", "s3", ""}, + "s3::https://s3-eu-west-1.amazonaws.com/examplecorp-terraform-modules/vpc.zip", + "", + false}, + {"GCS buckets", fields{}, args{"gcs::https://www.googleapis.com/storage/v1/modules/foomodule.zip", "gcs", ""}, + "gcs::https://www.googleapis.com/storage/v1/modules/foomodule.zip", + "", + false}, + {"subdir registry", + fields{"", "", gitHubToken, 0, false, nil, true}, + args{"hashicorp/consul/aws//modules/consul-cluster", "registry", ""}, + "git::https://github.com/hashicorp/terraform-aws-consul.git//modules/consul-cluster?ref=e9ceb573687c3d28516c9e3714caca84db64a766", + "v0.11.0", + false}, + {"subdir github", + fields{"", "", gitHubToken, 0, false, nil, true}, + args{"github.com/hashicorp/terraform-aws-consul//modules/consul-cluster", "github", ""}, + "git::https://github.com/hashicorp/terraform-aws-consul.git//modules/consul-cluster?ref=e9ceb573687c3d28516c9e3714caca84db64a766", + "v0.11.0", + false}, + //{"Modules 2", fields{}, args{"git::https://example.com/network.git//modules/vpc", "git", ""}, + // "git::https://example.com/network.git//modules/vpc", + // "", + // false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/src/core/registry_test.go b/src/core/registry_test.go index 7967200..34459bb 100644 --- a/src/core/registry_test.go +++ b/src/core/registry_test.go @@ -20,7 +20,7 @@ func TestIsOK(t *testing.T) { }{ {"Pass", args{"https://registry.terraform.io/v1/modules/jameswoolfenden/ip/http/versions"}, true, false}, {"Fail", args{"https://registry.terraform.io/v1/modules/jameswoolfenden/ip/https/versions"}, false, false}, - {"NotUrl", args{"jameswoolfenden/ip/https"}, nil, true}, + {"NotUrl", args{"jameswoolfenden/ip/https"}, false, true}, } for _, tt := range tests { @@ -95,7 +95,7 @@ func TestRegistry_GetLatest(t *testing.T) { module string } - want := "0.3.12" + want := "0.3.13" tests := []struct { name string diff --git a/src/core/testdata/modules/subdir/module.tf b/src/core/testdata/modules/subdir/module.tf new file mode 100644 index 0000000..2aced76 --- /dev/null +++ b/src/core/testdata/modules/subdir/module.tf @@ -0,0 +1,3 @@ +module "test" { + source = "git::https://github.com/hashicorp/terraform-aws-consul.git//modules/consul-cluster?ref=e9ceb573687c3d28516c9e3714caca84db64a766" +} From 88d804301a86d2d1fb1c69feefdc1aab472a2562 Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Tue, 15 Aug 2023 10:42:54 +0100 Subject: [PATCH 25/80] missing param --- main.go | 8 ++++++++ src/core/testdata/modules/subdir/module.tf | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 6f2fee8..9411d10 100644 --- a/main.go +++ b/main.go @@ -123,6 +123,14 @@ func main() { Destination: &myFlags.DryRun, Value: false, }, + &cli.StringFlag{ + Name: "token", + Aliases: []string{"t"}, + Usage: "Github PAT token", + Destination: &myFlags.GitHubToken, + Category: "authentication", + EnvVars: []string{"GITHUB_TOKEN", "GITHUB_API"}, + }, }, }, }, diff --git a/src/core/testdata/modules/subdir/module.tf b/src/core/testdata/modules/subdir/module.tf index 2aced76..d4b4023 100644 --- a/src/core/testdata/modules/subdir/module.tf +++ b/src/core/testdata/modules/subdir/module.tf @@ -1,3 +1,3 @@ -module "test" { +module "subdir" { source = "git::https://github.com/hashicorp/terraform-aws-consul.git//modules/consul-cluster?ref=e9ceb573687c3d28516c9e3714caca84db64a766" -} +} From 8ded72f155952d323e988a3a0cf4d830404c3928 Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Tue, 15 Aug 2023 10:57:15 +0100 Subject: [PATCH 26/80] missing param --- src/core/modules.go | 4 ++-- src/core/testdata/modules/registry/module.git.tf | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 src/core/testdata/modules/registry/module.git.tf diff --git a/src/core/modules.go b/src/core/modules.go index 2db978f..0784c84 100644 --- a/src/core/modules.go +++ b/src/core/modules.go @@ -33,7 +33,7 @@ func (myFlags *Flags) UpdateModule(file string) error { for _, block := range root.Blocks() { if block.Type() == "module" { version := GetStringValue(block, "version") - if !strings.Contains(version, "v") { + if !strings.Contains(version, "v") && version != "" { version = "v" + version } @@ -197,7 +197,7 @@ func (myFlags *Flags) UpdateSource(module string, moduleType string, version str case "git": { //var hash string - newModule := strings.TrimLeft(module, "git::") + newModule := strings.TrimPrefix(module, "git::") if strings.Contains(newModule, ",") { commas := strings.Split(newModule, ",") diff --git a/src/core/testdata/modules/registry/module.git.tf b/src/core/testdata/modules/registry/module.git.tf new file mode 100644 index 0000000..fb68348 --- /dev/null +++ b/src/core/testdata/modules/registry/module.git.tf @@ -0,0 +1,4 @@ +module "git" { + source = "git::https://github.com/JamesWoolfenden/terraform-http-ip.git?ref=aca5d04513698f2f564913cfcc3534780794c800" + permissions = "pike" +} From d8a72fb0d2e80aff69a4bf809fed4a32f2b7462b Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Tue, 15 Aug 2023 11:00:44 +0100 Subject: [PATCH 27/80] 40 long not 64 --- src/core/modules.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/modules.go b/src/core/modules.go index 0784c84..c5a3f85 100644 --- a/src/core/modules.go +++ b/src/core/modules.go @@ -409,7 +409,7 @@ func (myFlags *Flags) GetGithubHash(newModule string, tag string) (string, error hash = object["sha"].(string) } else { - if len(tag) == 64 || len(tag) == 7 { + if len(tag) == 40 || len(tag) == 7 { hash = tag } else { return "", fmt.Errorf("supplied hash is not a short or a long hash") From 7a4fd6fa8152c814696c2ffa0b46bfabb833a4f4 Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Tue, 15 Aug 2023 11:09:57 +0100 Subject: [PATCH 28/80] no info --- src/core/modules.go | 1 - 1 file changed, 1 deletion(-) diff --git a/src/core/modules.go b/src/core/modules.go index c5a3f85..697d663 100644 --- a/src/core/modules.go +++ b/src/core/modules.go @@ -51,7 +51,6 @@ func (myFlags *Flags) UpdateModule(file string) error { log.Info().Msgf("failed to update module source %s", err) } block.Body().SetAttributeValue("source", cty.StringVal(newValue)) - log.Info().Msgf("updated %s with hash of version %s", newValue, version) } } From b1eaa1afa85c552e2741db7a61430be6b7559a56 Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Tue, 15 Aug 2023 11:14:52 +0100 Subject: [PATCH 29/80] no info --- src/core/modules.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/modules.go b/src/core/modules.go index 697d663..83d7abf 100644 --- a/src/core/modules.go +++ b/src/core/modules.go @@ -46,7 +46,7 @@ func (myFlags *Flags) UpdateModule(file string) error { if err != nil { log.Info().Msgf("source type failure") } else { - newValue, version, err := myFlags.UpdateSource(source, myType, version) + newValue, _, err := myFlags.UpdateSource(source, myType, version) if err != nil { log.Info().Msgf("failed to update module source %s", err) } From 28db91391523e7ab1f617a05caf2b4bf378d3d25 Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Tue, 15 Aug 2023 13:46:26 +0100 Subject: [PATCH 30/80] Update README.md --- README.md | 78 +++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 64 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 602e416..306bf25 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ [![checkov](https://img.shields.io/badge/checkov-verified-brightgreen)](https://www.checkov.io/) [![Github All Releases](https://img.shields.io/github/downloads/jameswoolfenden/ghat/total.svg)](https://github.com/JamesWoolfenden/ghat/releases) -Ghat is a tool (GHAT) for updating dependencies in a GHA - GitHub Action. It replaces insecure mutable tags with immutable commit hashes as well as using the latest released version: +Ghat is a tool (GHAT) for updating dependencies in a GHA - GitHub Action, and now also for updating and **managing Terraform Dependencies**. It replaces insecure mutable tags with immutable commit hashes as well as using the latest released version: ```yml ## sets up go based on the version @@ -41,6 +41,25 @@ Becomes Ghat will use your GitHub credentials, if available, from your environment using the environmental variables GITHUB_TOKEN or GITHUB_API, but it can also drop back to anonymous access, the drawback is that this is severely rate limited by gitHub. +Ghat also manages Terraform modules, to give you the most secure reference, so: + +```terraform +module "ip" { + source = "JamesWoolfenden/ip/http" + version = "0.3.12" + permissions = "pike" +} +``` +Becomes: + +```terraform +module "ip" { + source = "git::https://github.com/JamesWoolfenden/terraform-http-ip.git?ref=a6cf071d14365133f48ed161812c14b00ad3c692" + permissions = "pike" +} + +``` + ## Table of Contents @@ -136,30 +155,61 @@ I got you covered: $ghat swot -d . --stable 14 ``` +### Swipe +Updates Terraform modules to use secure module references, and displays a file diff: + +```bash + ghat swipe -f .\registry\module.git.tf -update + _ _ + __ _ | |_ __ _ | |_ +/ _` || ' \ / _` || _| +\__, ||_||_|\__,_| \__| +|___/ +version: 9.9.9 +1:42PM INF module source is git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?depth=1 of type shallow and cannot be updated +module "ip" { + source = "git::https://github.com/JamesWoolfenden/ip/terraform-http" + v-ip.git?rersion f= "aca5d0.4513.1698f2f564913cfcc3534780794c800" + permissions = "pike" +} +``` +The update flag can be used to update the reference, the default behaviour is just to change the reference to a git bashed hash. + + ## Help ```bash - ghat swot -h + ghat --help + _ _ + __ _ | |_ __ _ | |_ +/ _` || ' \ / _` || _| +\__, ||_||_|\__,_| \__| +|___/ +version: v0.0.19 NAME: - ghat swot - updates GHA in a directory + ghat - Update GHA dependencies USAGE: - ghat swot - -OPTIONS: - authentication - - --token value, -t value Github PAT token [$GITHUB_TOKEN, $GITHUB_API] + ghat [global options] command [command options] [arguments...] - delay +VERSION: + v0.0.19 - --stable value, -s value days to wait for stabilisation of release (default: 0) +AUTHOR: + James Woolfenden - files +COMMANDS: + swipe, w updates Terraform module versions with versioned hashes + swot, a updates GHA versions for hashes + version, v Outputs the application version + help, h Shows a list of commands or help for one command - --directory value, -d value Destination to update GHAs (default: ".") - --file value, -f value GHA file to parse +GLOBAL OPTIONS: + --help, -h show help + --version, -v print the version +COPYRIGHT: + James Woolfenden ``` ### pre-commit From b00b7eb1870437638693da87e88adf284bd23fa1 Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Wed, 16 Aug 2023 15:37:54 +0100 Subject: [PATCH 31/80] want tags not releases for tf modules --- src/core/gha.go | 16 ++++++++++++++-- src/core/gha_test.go | 36 ++++++++++++++++++++++++++++++++++++ src/core/modules.go | 10 ++++++++-- src/core/registry_test.go | 4 ++-- 4 files changed, 60 insertions(+), 6 deletions(-) diff --git a/src/core/gha.go b/src/core/gha.go index b3c4350..0394b2d 100644 --- a/src/core/gha.go +++ b/src/core/gha.go @@ -186,17 +186,29 @@ func (myFlags *Flags) UpdateGHA(file string) error { func getPayload(action string, gitHubToken string, days *int) (interface{}, error) { if *days == 0 { - return GetLatest(action, gitHubToken) + return GetLatestRelease(action, gitHubToken) } return GetReleases(action, gitHubToken, days) } -func GetLatest(action string, gitHubToken string) (interface{}, error) { +func GetLatestRelease(action string, gitHubToken string) (interface{}, error) { url := "https://api.github.com/repos/" + action + "/releases/latest" return GetGithubBody(gitHubToken, url) } +func GetLatestTag(action string, gitHubToken string) (interface{}, error) { + url := "https://api.github.com/repos/" + action + "/tags" + tags, err := GetGithubBody(gitHubToken, url) + tagged, ok := tags.([]interface{}) + + if !ok { + return nil, fmt.Errorf("failed to assert slice %s", tags) + } + + return tagged[0].(map[string]interface{}), err +} + func getHash(action string, tag string, gitHubToken string) (interface{}, error) { url := "https://api.github.com/repos/" + action + "/git/ref/tags/" + tag return GetGithubBody(gitHubToken, url) diff --git a/src/core/gha_test.go b/src/core/gha_test.go index 9bfa416..22ccc70 100644 --- a/src/core/gha_test.go +++ b/src/core/gha_test.go @@ -235,3 +235,39 @@ func Test_getPayload(t *testing.T) { // }) // } //} + +func TestGetLatestTag(t *testing.T) { + t.Parallel() + type args struct { + action string + gitHubToken string + } + + latest := "4232d5fcb1b2a98d741258b8329742f63f7a598b" + + tests := []struct { + name string + args args + want string + wantErr bool + }{ + {"Pass", args{"jameswoolfenden/terraform-azurerm-diskencryptionset", gitHubToken}, latest, false}, + } + for _, tt := range tests { + tt := tt + t.Run(tt.name, func(t *testing.T) { + t.Parallel() + got, err := GetLatestTag(tt.args.action, tt.args.gitHubToken) + if (err != nil) != tt.wantErr { + t.Errorf("GetLatestTag() error = %v, wantErr %v", err, tt.wantErr) + return + } + returned := got.(map[string]interface{}) + commit := returned["commit"].(map[string]interface{}) + hash := commit["sha"].(string) + if hash != tt.want { + t.Errorf("GetLatestTag() got = %v, want %v", hash, tt.want) + } + }) + } +} diff --git a/src/core/modules.go b/src/core/modules.go index 83d7abf..cc9ee1f 100644 --- a/src/core/modules.go +++ b/src/core/modules.go @@ -189,7 +189,9 @@ func (myFlags *Flags) GetType(module string) (string, error) { func (myFlags *Flags) UpdateSource(module string, moduleType string, version string) (string, string, error) { var newModule string + var hash string + var err error switch moduleType { @@ -362,13 +364,17 @@ func (myFlags *Flags) GetGithubLatestHash(newModule string) (string, string, err name := strings.Split(newModule, "github.com/") action := strings.Split(name[1], ".git") - payload, err := GetLatest(action[0], myFlags.GitHubToken) + payload, err := GetLatestTag(action[0], myFlags.GitHubToken) if err != nil { return "", "", err } - assertedPayload := payload.(map[string]interface{}) + assertedPayload, ok := payload.(map[string]interface{}) + + if !ok { + return "", "", fmt.Errorf("type assertion failed") + } version := assertedPayload["tag_name"].(string) hash, err := myFlags.GetGithubHash(newModule, version) diff --git a/src/core/registry_test.go b/src/core/registry_test.go index 34459bb..96f415f 100644 --- a/src/core/registry_test.go +++ b/src/core/registry_test.go @@ -116,11 +116,11 @@ func TestRegistry_GetLatest(t *testing.T) { } got, err := myRegistry.GetLatest(tt.args.module) if (err != nil) != tt.wantErr { - t.Errorf("GetLatest() error = %v, wantErr %v", err, tt.wantErr) + t.Errorf("GetLatestRelease() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(got, tt.want) { - t.Errorf("GetLatest() got = %v, want %v", got, tt.want) + t.Errorf("GetLatestRelease() got = %v, want %v", got, tt.want) } }) } From 1869d48b7d7e68c6e782b66c60db09f012bfde10 Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Thu, 17 Aug 2023 10:09:56 +0100 Subject: [PATCH 32/80] fix hash lookup --- src/core/modules.go | 43 ++++++++++--------- .../testdata/modules/github-git/module.tf | 6 +++ 2 files changed, 29 insertions(+), 20 deletions(-) create mode 100644 src/core/testdata/modules/github-git/module.tf diff --git a/src/core/modules.go b/src/core/modules.go index cc9ee1f..dd7ac0d 100644 --- a/src/core/modules.go +++ b/src/core/modules.go @@ -267,13 +267,13 @@ func (myFlags *Flags) UpdateSource(module string, moduleType string, version str case "registry": { - var subdir string + var subDir string - subdirs := strings.Split(module, "//") + subDirs := strings.Split(module, "//") - if len(subdirs) == 2 { - subdir = subdirs[1] - module = subdirs[0] + if len(subDirs) == 2 { + subDir = subDirs[1] + module = subDirs[0] } splits := strings.Split(module, "/") @@ -285,25 +285,24 @@ func (myFlags *Flags) UpdateSource(module string, moduleType string, version str //e.g. jameswoolfenden/terraform-http-ip newModule := "github.com" + "/" + splits[0] + "/" + "terraform" + "-" + splits[2] + "-" + splits[1] + ".git" - if subdir == "" { + if subDir == "" { return myFlags.UpdateGithubSource(version, newModule) } else { - return myFlags.WithSubDir(version, newModule, subdir) + return myFlags.WithSubDir(version, newModule, subDir) } - } case "github": { - subdirs := strings.Split(module, "//") - if len(subdirs) == 2 { - subdir := subdirs[1] - root := subdirs[0] - //e.g. jameswoolfenden/terraform-http-ip - newModule := root + ".git" + subDirs := strings.Split(module, "//") + if len(subDirs) == 2 { + subDir := subDirs[1] + root := subDirs[0] - return myFlags.WithSubDir(version, newModule, subdir) + // e.g. jameswoolfenden/terraform-http-ip + newModule := root + ".git" + return myFlags.WithSubDir(version, newModule, subDir) } newModule = module + ".git" @@ -330,11 +329,13 @@ func (myFlags *Flags) WithSubDir(version string, newModule string, subdir string urlsplit := strings.Split(url, ".git") newUrl := urlsplit[0] + ".git" + "//" + subdir + urlsplit[1] + return newUrl, version, err } func (myFlags *Flags) UpdateGithubSource(version string, newModule string) (string, string, error) { var hash string + var err error if myFlags.Update { @@ -360,7 +361,6 @@ func (myFlags *Flags) UpdateGithubSource(version string, newModule string) (stri } func (myFlags *Flags) GetGithubLatestHash(newModule string) (string, string, error) { - name := strings.Split(newModule, "github.com/") action := strings.Split(name[1], ".git") @@ -376,13 +376,16 @@ func (myFlags *Flags) GetGithubLatestHash(newModule string) (string, string, err return "", "", fmt.Errorf("type assertion failed") } - version := assertedPayload["tag_name"].(string) - hash, err := myFlags.GetGithubHash(newModule, version) + version, ok := assertedPayload["name"].(string) - if err != nil { - return "", "", err + if !ok { + return "", "", fmt.Errorf("type assertion failed") } + commit := assertedPayload["commit"].(map[string]interface{}) + + hash := commit["sha"].(string) + return hash, version, nil } diff --git a/src/core/testdata/modules/github-git/module.tf b/src/core/testdata/modules/github-git/module.tf new file mode 100644 index 0000000..a0ef667 --- /dev/null +++ b/src/core/testdata/modules/github-git/module.tf @@ -0,0 +1,6 @@ +module "diskencryptionset" { + source = "git::https://github.com/JamesWoolfenden/terraform-azurerm-diskencryptionset.git?ref=fc0b830997dd820476a7ad5e4b6ef2dcbdc766d7" + common_tags = var.common_tags + location = var.location + rg_name = var.resource_group_name +} From b41ca1b403016da5c76e7967ca0fbea814cc1375 Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Thu, 17 Aug 2023 10:13:03 +0100 Subject: [PATCH 33/80] fix hash lookup --- src/core/gha_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/gha_test.go b/src/core/gha_test.go index 22ccc70..0cf2217 100644 --- a/src/core/gha_test.go +++ b/src/core/gha_test.go @@ -243,7 +243,7 @@ func TestGetLatestTag(t *testing.T) { gitHubToken string } - latest := "4232d5fcb1b2a98d741258b8329742f63f7a598b" + latest := "fc0b830997dd820476a7ad5e4b6ef2dcbdc766d7" tests := []struct { name string From 889adc8ffd146689d6b9599f11c52a611934cbc1 Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Sun, 20 Aug 2023 13:26:51 +0100 Subject: [PATCH 34/80] find ghsa if using windows --- src/core/gha.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/core/gha.go b/src/core/gha.go index 0394b2d..657e878 100644 --- a/src/core/gha.go +++ b/src/core/gha.go @@ -74,9 +74,11 @@ func (myFlags *Flags) UpdateGHAS() error { func (myFlags *Flags) GetGHA() ([]string, error) { var ghat []string + gitHubPath := filepath.Join(".github", "workflows") + for _, match := range myFlags.Entries { entry, _ := os.Stat(match) - if strings.Contains(match, ".github/workflows") && !entry.IsDir() { + if strings.Contains(match, gitHubPath) && !entry.IsDir() { if strings.Contains(match, ".yml") || (strings.Contains(match, ".yaml")) { ghat = append(ghat, match) } From fe0025423c135cfffdb93218830b8538a0bd99d4 Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Mon, 21 Aug 2023 21:50:41 +0100 Subject: [PATCH 35/80] update tests --- src/core/gha_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/gha_test.go b/src/core/gha_test.go index 0cf2217..ec1dc51 100644 --- a/src/core/gha_test.go +++ b/src/core/gha_test.go @@ -243,7 +243,7 @@ func TestGetLatestTag(t *testing.T) { gitHubToken string } - latest := "fc0b830997dd820476a7ad5e4b6ef2dcbdc766d7" + latest := "8f12c5f88e2a1306c6b7c3764027bcb731c3f829" tests := []struct { name string From a563e7d03ad256f5349739eb43567e999450c6d6 Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Sat, 16 Sep 2023 16:01:46 +0100 Subject: [PATCH 36/80] version constraint handling --- .github/workflows/ci.yml | 2 +- .github/workflows/codeql-analysis.yml | 8 ++-- .github/workflows/pr.yml | 10 ++--- .github/workflows/release.yml | 10 ++--- src/core/modules.go | 45 ++++++++++++++++--- .../testdata/modules/version/gt/module.tf | 5 +++ .../modules/version/range/module.range.tf | 5 +++ 7 files changed, 64 insertions(+), 21 deletions(-) create mode 100644 src/core/testdata/modules/version/gt/module.tf create mode 100644 src/core/testdata/modules/version/range/module.range.tf diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 257c036..6551664 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,7 +31,7 @@ jobs: ## checks out our code locally, so we can work with the files - name: Checkout code - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 ## runs go test ./... - name: Build diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 6126fe7..92db1c4 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -39,11 +39,11 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@f9a7c6738f28efb36e31d49c53a201a9c5d6a476 # codeql-bundle-v2.14.2 + uses: github/codeql-action/init@c6c77c8c2d62cfd5b2e8d548817fd3d1582ac744 # codeql-bundle-v2.14.5 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -53,7 +53,7 @@ jobs: # 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@f9a7c6738f28efb36e31d49c53a201a9c5d6a476 # codeql-bundle-v2.14.2 + uses: github/codeql-action/autobuild@c6c77c8c2d62cfd5b2e8d548817fd3d1582ac744 # codeql-bundle-v2.14.5 # â„šī¸ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun @@ -66,4 +66,4 @@ jobs: # ./location_of_script_within_repo/buildscript.sh - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@f9a7c6738f28efb36e31d49c53a201a9c5d6a476 # codeql-bundle-v2.14.2 + uses: github/codeql-action/analyze@c6c77c8c2d62cfd5b2e8d548817fd3d1582ac744 # codeql-bundle-v2.14.5 diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index c87a32d..d648e2e 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -8,13 +8,13 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 - name: Install Go uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0 with: go-version: 1.20.x - name: Restore cache - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1 + uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2 with: path: ~/go/pkg/mod key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} @@ -30,13 +30,13 @@ jobs: runs-on: ${{ matrix.platform }} steps: - name: Checkout code - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 - name: Install Go uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0 with: go-version: ${{ matrix.go-version }} - name: Restore cache - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1 + uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2 with: path: ~/go/pkg/mod key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} @@ -48,7 +48,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 - name: Install Go uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 15bf1bf..eb19105 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 - name: Unshallow run: git fetch --prune --unshallow - name: Set up Go @@ -20,12 +20,12 @@ jobs: go-version: 1.19 - name: Import GPG key id: import_gpg - uses: crazy-max/ghaction-import-gpg@72b6676b71ab476b77e676928516f6982eef7a41 # v5.3.0 + uses: crazy-max/ghaction-import-gpg@82a020f1f7f605c65dd2449b392a52c3fcfef7ef # v6.0.0 with: gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} passphrase: ${{ secrets.PASSPHRASE }} - name: Run GoReleaser - uses: goreleaser/goreleaser-action@3fa32b8bb5620a2c1afe798654bbad59f9da4906 # v4.4.0 + uses: goreleaser/goreleaser-action@7ec5c2b0c6cdda6e8bbb49444bc797dd33d74dd8 # v5.0.0 with: version: latest args: release --clean @@ -41,7 +41,7 @@ jobs: needs: - goreleaser steps: - - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 - name: Publish to Registry uses: elgohr/Publish-Docker-Github-Action@219613003b08f4d049f34cb56c92e84345e1bb3f # v5 with: @@ -64,7 +64,7 @@ jobs: - goreleaser steps: - name: Repository Dispatch - uses: peter-evans/repository-dispatch@26b39ed245ab8f31526069329e112ab2fb224588 # v2.1.1 + uses: peter-evans/repository-dispatch@bf47d102fdb849e755b0b0023ea3e81a44b6f570 # v2.1.2 with: token: ${{ secrets.PAT }} repository: jameswoolfenden/scoop diff --git a/src/core/modules.go b/src/core/modules.go index dd7ac0d..36eb5d6 100644 --- a/src/core/modules.go +++ b/src/core/modules.go @@ -32,10 +32,7 @@ func (myFlags *Flags) UpdateModule(file string) error { for _, block := range root.Blocks() { if block.Type() == "module" { - version := GetStringValue(block, "version") - if !strings.Contains(version, "v") && version != "" { - version = "v" + version - } + version := GetVersion(block) source := GetStringValue(block, "source") @@ -44,7 +41,7 @@ func (myFlags *Flags) UpdateModule(file string) error { myType, err := myFlags.GetType(source) if err != nil { - log.Info().Msgf("source type failure") + log.Info().Msgf("source type failure %s", source) } else { newValue, _, err := myFlags.UpdateSource(source, myType, version) if err != nil { @@ -82,6 +79,29 @@ func (myFlags *Flags) UpdateModule(file string) error { return nil } +func GetVersion(block *hclwrite.Block) string { + version := GetStringValue(block, "version") + if version == "" { + return "" + } + + constraints := []string{"=", "!", ">", ">", "~"} + + for _, constraint := range constraints { + if strings.Contains(version, constraint) { + version = "" + log.Info().Msg("constraints not valid, using latest") + continue + } + } + + if !strings.Contains(version, "v") && version != "" { + version = "v" + version + } + + return version +} + func GetStringValue(block *hclwrite.Block, attribute string) string { var Value string version := block.Body().GetAttribute(attribute) @@ -408,7 +428,20 @@ func (myFlags *Flags) GetGithubHash(newModule string, tag string) (string, error payload, err = GetGithubBody(myFlags.GitHubToken, url) if err != nil { - return "", err + // retry as version is truncated + if strings.Count(tag, ".") == 1 { + tag = tag + ".0" + url = "https://api.github.com/repos/" + action[0] + "/git/ref/tags/" + tag + payload, err = GetGithubBody(myFlags.GitHubToken, url) + if err != nil { + log.Info().Msgf("failed to find tag %s", tag) + return "", err + } + } else { + return "", err + } + } else { + log.Info().Msgf("failed to understand %s", tag) } assertedPayload := payload.(map[string]interface{}) diff --git a/src/core/testdata/modules/version/gt/module.tf b/src/core/testdata/modules/version/gt/module.tf new file mode 100644 index 0000000..4db64f7 --- /dev/null +++ b/src/core/testdata/modules/version/gt/module.tf @@ -0,0 +1,5 @@ +module "ip" { + source = "JamesWoolfenden/ip/http" + version = ">=0.3.12" + permissions = "pike" +} diff --git a/src/core/testdata/modules/version/range/module.range.tf b/src/core/testdata/modules/version/range/module.range.tf new file mode 100644 index 0000000..4db64f7 --- /dev/null +++ b/src/core/testdata/modules/version/range/module.range.tf @@ -0,0 +1,5 @@ +module "ip" { + source = "JamesWoolfenden/ip/http" + version = ">=0.3.12" + permissions = "pike" +} From 5d6e3a2e6ad5ed30eab3a53b3b9c3e3860781ddb Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Sat, 16 Sep 2023 17:24:32 +0100 Subject: [PATCH 37/80] version constraint handling --- src/core/gha_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/gha_test.go b/src/core/gha_test.go index ec1dc51..370d869 100644 --- a/src/core/gha_test.go +++ b/src/core/gha_test.go @@ -243,7 +243,7 @@ func TestGetLatestTag(t *testing.T) { gitHubToken string } - latest := "8f12c5f88e2a1306c6b7c3764027bcb731c3f829" + latest := "34bf44973c4f415bd3e791728b630e5d110a2244" tests := []struct { name string From 096b78d9e78ddd7119204546357f5a64b11c6e50 Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Sat, 16 Sep 2023 23:32:30 +0100 Subject: [PATCH 38/80] more tests --- src/core/action.go | 5 +- src/core/action_test.go | 60 ++++++++++ src/core/gha_test.go | 189 +++++++++--------------------- src/core/testdata/files/module.tf | 5 + 4 files changed, 122 insertions(+), 137 deletions(-) create mode 100644 src/core/action_test.go create mode 100644 src/core/testdata/files/module.tf diff --git a/src/core/action.go b/src/core/action.go index eb54490..eb4dc51 100644 --- a/src/core/action.go +++ b/src/core/action.go @@ -1,10 +1,9 @@ package core import ( + "fmt" "os" "path/filepath" - - "github.com/rs/zerolog/log" ) func (myFlags *Flags) Action(Action string) error { @@ -19,7 +18,7 @@ func (myFlags *Flags) Action(Action string) error { myFlags.Entries, err = GetFiles(myFlags.Directory) if err != nil { - log.Error().Msgf("action failed to read %s", myFlags.Directory) + return fmt.Errorf("action failed to read %s", myFlags.Directory) } } diff --git a/src/core/action_test.go b/src/core/action_test.go new file mode 100644 index 0000000..f3011fe --- /dev/null +++ b/src/core/action_test.go @@ -0,0 +1,60 @@ +package core + +import ( + "testing" +) + +func TestFlags_Action(t *testing.T) { + + type fields struct { + File string + Directory string + GitHubToken string + Days int + DryRun bool + Entries []string + Update bool + } + + type args struct { + Action string + } + + dir := fields{"", "testdata/files/", gitHubToken, 0, false, nil, true} + bogus := fields{"", "testdata/bogus/", gitHubToken, 0, false, nil, true} + empty := fields{"", "testdata/empty", gitHubToken, 0, false, nil, true} + dirDry := fields{"", "testdata/files/", gitHubToken, 0, true, nil, true} + fileGHA := fields{"testdata/files/ci.yml", "testdata/files/", gitHubToken, 0, true, nil, true} + file := fields{"testdata/files/module.tf", "testdata/files/", gitHubToken, 0, true, nil, true} + + tests := []struct { + name string + fields fields + args args + wantErr bool + }{ + {"Pass", dir, args{}, false}, + {"Bogus", bogus, args{}, true}, + {"Empty swot", empty, args{"swot"}, true}, + {"Empty swipe", empty, args{"swipe"}, true}, + {"dirDry", dirDry, args{}, false}, + {"file swipe", file, args{"swipe"}, false}, + {"file swot", fileGHA, args{"swot"}, false}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + myFlags := &Flags{ + File: tt.fields.File, + Directory: tt.fields.Directory, + GitHubToken: tt.fields.GitHubToken, + Days: tt.fields.Days, + DryRun: tt.fields.DryRun, + Entries: tt.fields.Entries, + Update: tt.fields.Update, + } + if err := myFlags.Action(tt.args.Action); (err != nil) != tt.wantErr { + t.Errorf("Action() error = %v, wantErr %v", err, tt.wantErr) + } + }) + } +} diff --git a/src/core/gha_test.go b/src/core/gha_test.go index 370d869..8ef247d 100644 --- a/src/core/gha_test.go +++ b/src/core/gha_test.go @@ -101,140 +101,61 @@ func Test_getPayload(t *testing.T) { } } -// -//func TestFlags_Files(t *testing.T) { -// -// type fields struct { -// File string -// Directory string -// GitHubToken string -// Days int -// DryRun bool -// } -// -// dir := fields{"", "testdata/files/", gitHubToken, 0, false} -// bogus := fields{"", "testdata/bogus/", gitHubToken, 0, false} -// empty := fields{"", "testdata/empty", gitHubToken, 0, false} -// dirDry := fields{"", "testdata/files/", gitHubToken, 0, true} -// -// tests := []struct { -// name string -// fields fields -// want []os.DirEntry -// wantErr bool -// }{ -// {"Pass", dir, nil, false}, -// {"Bogus", bogus, nil, false}, -// {"Empty", empty, nil, false}, -// {"dirDry", dirDry, nil, false}, -// } -// -// for _, tt := range tests { -// t.Run(tt.name, func(t *testing.T) { -// myFlags := &Flags{ -// File: tt.fields.File, -// Directory: tt.fields.Directory, -// GitHubToken: tt.fields.GitHubToken, -// Days: tt.fields.Days, -// DryRun: tt.fields.DryRun, -// } -// got, err := myFlags.Action() -// if (err != nil) != tt.wantErr { -// t.Errorf("Action() error = %v, wantErr %v", err, tt.wantErr) -// return -// } -// if !reflect.DeepEqual(got, tt.want) { -// t.Errorf("Action() got = %v, want %v", got, tt.want) -// } -// }) -// } -//} -// -//func TestFlags_GetGHA(t *testing.T) { -// type fields struct { -// File string -// Directory string -// GitHubToken string -// Days int -// DryRun bool -// } -// -// type args struct { -// matches []os.DirEntry -// ghat []os.DirEntry -// } -// -// duffDir := fields{"", "nothere", gitHubToken, 0, false} -// noMatches, _ := os.ReadDir(duffDir.Directory) -// -// noWorkflowsDir := fields{"", "./testdata/noworkflows", gitHubToken, 0, false} -// noWorkflows, _ := os.ReadDir(noWorkflowsDir.Directory) -// -// noWorkflowsWithDir := fields{"", "./testdata/noworkflowswithdir", gitHubToken, 0, false} -// noWorkflowsWithDirContents, _ := os.ReadDir(noWorkflowsWithDir.Directory) -// -// tests := []struct { -// name string -// fields fields -// args args -// want []os.DirEntry -// wantErr bool -// }{ -// {"no matches", duffDir, args{noMatches, nil}, nil, false}, -// {"no workflows", noWorkflowsDir, args{noWorkflows, nil}, nil, false}, -// {"no workflows with dir", noWorkflowsWithDir, args{noWorkflowsWithDirContents, nil}, nil, false}, -// } -// for _, tt := range tests { -// t.Run(tt.name, func(t *testing.T) { -// myFlags := &Flags{ -// File: tt.fields.File, -// Directory: tt.fields.Directory, -// GitHubToken: tt.fields.GitHubToken, -// Days: tt.fields.Days, -// DryRun: tt.fields.DryRun, -// } -// got, err := myFlags.GetGHA(tt.args.matches, tt.args.ghat) -// if (err != nil) != tt.wantErr { -// t.Errorf("GetGHA() error = %v, wantErr %v", err, tt.wantErr) -// return -// } -// if !reflect.DeepEqual(got, tt.want) { -// t.Errorf("GetGHA() got = %v, want %v", got, tt.want) -// } -// }) -// } -//} -// -//func TestFlags_UpdateFile(t *testing.T) { -// type fields struct { -// File string -// Directory string -// GitHubToken string -// Days int -// DryRun bool -// } -// tests := []struct { -// name string -// fields fields -// wantErr bool -// }{ -// // TODO: Add test cases. -// } -// for _, tt := range tests { -// t.Run(tt.name, func(t *testing.T) { -// myFlags := &Flags{ -// File: tt.fields.File, -// Directory: tt.fields.Directory, -// GitHubToken: tt.fields.GitHubToken, -// Days: tt.fields.Days, -// DryRun: tt.fields.DryRun, -// } -// if err := myFlags.UpdateGHA(); (err != nil) != tt.wantErr { -// t.Errorf("UpdateGHA() error = %v, wantErr %v", err, tt.wantErr) -// } -// }) -// } -//} +func TestFlags_GetGHA(t *testing.T) { + type fields struct { + File string + Directory string + GitHubToken string + Days int + DryRun bool + } + + type args struct { + matches []os.DirEntry + ghat []os.DirEntry + } + + duffDir := fields{"", "nothere", gitHubToken, 0, false} + noMatches, _ := os.ReadDir(duffDir.Directory) + + noWorkflowsDir := fields{"", "./testdata/noworkflows", gitHubToken, 0, false} + noWorkflows, _ := os.ReadDir(noWorkflowsDir.Directory) + + noWorkflowsWithDir := fields{"", "./testdata/noworkflowswithdir", gitHubToken, 0, false} + noWorkflowsWithDirContents, _ := os.ReadDir(noWorkflowsWithDir.Directory) + + var nothing []string + tests := []struct { + name string + fields fields + args args + want []string + wantErr bool + }{ + {"no matches", duffDir, args{noMatches, nil}, nothing, false}, + {"no workflows", noWorkflowsDir, args{noWorkflows, nil}, nil, false}, + {"no workflows with dir", noWorkflowsWithDir, args{noWorkflowsWithDirContents, nil}, nil, false}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + myFlags := &Flags{ + File: tt.fields.File, + Directory: tt.fields.Directory, + GitHubToken: tt.fields.GitHubToken, + Days: tt.fields.Days, + DryRun: tt.fields.DryRun, + } + got, err := myFlags.GetGHA() + if (err != nil) != tt.wantErr { + t.Errorf("GetGHA() error = %v, wantErr %v", err, tt.wantErr) + return + } + if !reflect.DeepEqual(got, tt.want) { + t.Errorf("GetGHA() got = %v, want %v", got, tt.want) + } + }) + } +} func TestGetLatestTag(t *testing.T) { t.Parallel() diff --git a/src/core/testdata/files/module.tf b/src/core/testdata/files/module.tf new file mode 100644 index 0000000..fc4b53c --- /dev/null +++ b/src/core/testdata/files/module.tf @@ -0,0 +1,5 @@ +module "ip" { + source = "JamesWoolfenden/ip/http" + version = "0.3.12" + permissions = "pike" +} From 2ebcba1885df1aceb97215bf6c34081c4f3e52ff Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Sun, 17 Sep 2023 16:16:40 +0100 Subject: [PATCH 39/80] more test coverage --- .github/workflows/ci.yml | 2 +- .github/workflows/pr.yml | 6 ++-- .github/workflows/release.yml | 2 +- .pre-commit-config.yaml | 6 ++-- README.md | 6 ++-- go.mod | 25 ++++++------- go.sum | 66 +++++++++++++++++++--------------- src/core/action_test.go | 2 ++ src/core/gha_test.go | 34 ++++++++++++++++-- src/core/testdata/files/ci.yml | 2 +- 10 files changed, 98 insertions(+), 53 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6551664..520824a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,7 @@ jobs: ## this will contain a matrix of all the combinations ## we wish to test again: matrix: - go-version: [ 1.20.x ] + go-version: [ 1.21.x ] platform: [ ubuntu-latest, macos-latest, windows-latest ] ## Defines the platform for each test run diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index d648e2e..409dc5a 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -12,7 +12,7 @@ jobs: - name: Install Go uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0 with: - go-version: 1.20.x + go-version: 1.21.x - name: Restore cache uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2 with: @@ -25,7 +25,7 @@ jobs: test: strategy: matrix: - go-version: [ 1.20.x ] + go-version: [ 1.21.x ] platform: [ ubuntu-latest, macos-latest, windows-latest ] runs-on: ${{ matrix.platform }} steps: @@ -52,4 +52,4 @@ jobs: - name: Install Go uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0 with: - go-version: 1.20.x + go-version: 1.21.x diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index eb19105..6d711dd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,7 +17,7 @@ jobs: - name: Set up Go uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0 with: - go-version: 1.19 + go-version: 1.21 - name: Import GPG key id: import_gpg uses: crazy-max/ghaction-import-gpg@82a020f1f7f605c65dd2449b392a52c3fcfef7ef # v6.0.0 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 91b1e61..22f606b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -29,7 +29,7 @@ repos: hooks: - id: shell-lint - repo: https://github.com/igorshubovych/markdownlint-cli - rev: v0.35.0 + rev: v0.36.0 hooks: - id: markdownlint exclude: src/testdata|testdata @@ -51,11 +51,11 @@ repos: - id: go-mod-tidy - id: go-generate - repo: https://github.com/golangci/golangci-lint - rev: v1.54.1 + rev: v1.54.2 hooks: - id: golangci-lint - repo: https://github.com/bridgecrewio/checkov - rev: 2.3.365 + rev: 2.4.39 hooks: - id: checkov language_version: python3.10 diff --git a/README.md b/README.md index 306bf25..eafad3e 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,7 @@ module "ip" { permissions = "pike" } ``` + Becomes: ```terraform @@ -156,6 +157,7 @@ $ghat swot -d . --stable 14 ``` ### Swipe + Updates Terraform modules to use secure module references, and displays a file diff: ```bash @@ -173,8 +175,8 @@ module "ip" { permissions = "pike" } ``` -The update flag can be used to update the reference, the default behaviour is just to change the reference to a git bashed hash. +The update flag can be used to update the reference, the default behaviour is just to change the reference to a git bashed hash. ## Help @@ -234,7 +236,7 @@ update .pre-commit-config.yaml ## Building -```go +```shell go build ``` diff --git a/go.mod b/go.mod index ffd5c45..21f7178 100644 --- a/go.mod +++ b/go.mod @@ -1,14 +1,14 @@ module ghat -go 1.20 +go 1.21 require ( - github.com/go-git/go-git/v5 v5.8.1 - github.com/hashicorp/hcl/v2 v2.17.0 + github.com/go-git/go-git/v5 v5.9.0 + github.com/hashicorp/hcl/v2 v2.18.0 github.com/rs/zerolog v1.30.0 github.com/sergi/go-diff v1.3.1 github.com/urfave/cli/v2 v2.25.7 - github.com/zclconf/go-cty v1.13.2 + github.com/zclconf/go-cty v1.14.0 golang.org/x/mod v0.12.0 moul.io/banner v1.0.1 ) @@ -16,15 +16,16 @@ require ( require ( dario.cat/mergo v1.0.0 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect - github.com/ProtonMail/go-crypto v0.0.0-20230717121422-5aa5874ade95 // indirect + github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect github.com/acomagu/bufpipe v1.0.4 // indirect github.com/agext/levenshtein v1.2.3 // indirect - github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect + github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect github.com/cloudflare/circl v1.3.3 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect + github.com/cyphar/filepath-securejoin v0.2.4 // indirect github.com/emirpasic/gods v1.18.1 // indirect github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect - github.com/go-git/go-billy/v5 v5.4.1 // indirect + github.com/go-git/go-billy/v5 v5.5.0 // indirect github.com/go-test/deep v1.0.7 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/google/go-cmp v0.5.9 // indirect @@ -40,10 +41,10 @@ require ( github.com/stretchr/testify v1.8.4 // indirect github.com/xanzy/ssh-agent v0.3.3 // indirect github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect - golang.org/x/crypto v0.12.0 // indirect - golang.org/x/net v0.14.0 // indirect - golang.org/x/sys v0.11.0 // indirect - golang.org/x/text v0.12.0 // indirect - golang.org/x/tools v0.12.0 // indirect + golang.org/x/crypto v0.13.0 // indirect + golang.org/x/net v0.15.0 // indirect + golang.org/x/sys v0.12.0 // indirect + golang.org/x/text v0.13.0 // indirect + golang.org/x/tools v0.13.0 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect ) diff --git a/go.sum b/go.sum index fd69275..d425b80 100644 --- a/go.sum +++ b/go.sum @@ -3,37 +3,43 @@ dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= -github.com/ProtonMail/go-crypto v0.0.0-20230717121422-5aa5874ade95 h1:KLq8BE0KwCL+mmXnjLWEAOYO+2l2AE4YMmqG1ZpZHBs= -github.com/ProtonMail/go-crypto v0.0.0-20230717121422-5aa5874ade95/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= +github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 h1:kkhsdkhsCvIsutKu5zLMgWtgh9YxGCNAw8Ad8hjwfYg= +github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= github.com/acomagu/bufpipe v1.0.4 h1:e3H4WUzM3npvo5uv95QuJM3cQspFNtFBzvJ2oNjKIDQ= github.com/acomagu/bufpipe v1.0.4/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4= github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8= -github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw= -github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo= +github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4= +github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew1u1fNQOlOtuGxQY= +github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= +github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= github.com/cloudflare/circl v1.3.3 h1:fE/Qz0QdIGqeWfnwq0RE0R7MI51s0M2E4Ga9kq5AEMs= github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= -github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg= +github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/elazarl/goproxy v0.0.0-20221015165544-a0805db90819 h1:RIB4cRk+lBqKK3Oy0r2gRX4ui7tuhiZq2SuTtTCi0/0= +github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a h1:mATvB/9r/3gvcejNsXKSkQ6lcIaNec2nyfOdlTBR2lU= +github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a/go.mod h1:Ro8st/ElPeALwNFlcTpWmkr6IoMFfkjXAvTHpevnDsM= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= github.com/gliderlabs/ssh v0.3.5 h1:OcaySEmAQJgyYcArR+gGGTHCyE7nvhEMTlYY+Dp8CpY= +github.com/gliderlabs/ssh v0.3.5/go.mod h1:8XB4KraRrX39qHhT6yxPsHedjA08I/uBVwj4xC+/+z4= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic= -github.com/go-git/go-billy/v5 v5.4.1 h1:Uwp5tDRkPr+l/TnbHOQzp+tmJfLceOlbVucgpTz8ix4= -github.com/go-git/go-billy/v5 v5.4.1/go.mod h1:vjbugF6Fz7JIflbVpl1hJsGjSHNltrSw45YK/ukIvQg= +github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+mTU= +github.com/go-git/go-billy/v5 v5.5.0/go.mod h1:hmexnoNsr2SJU1Ju67OaNz5ASJY3+sHgFRpCtpDCKow= github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20230305113008-0c11038e723f h1:Pz0DHeFij3XFhoBRGUDPzSJ+w2UcK5/0JvF8DRI58r8= -github.com/go-git/go-git/v5 v5.8.1 h1:Zo79E4p7TRk0xoRgMq0RShiTHGKcKI4+DI6BfJc/Q+A= -github.com/go-git/go-git/v5 v5.8.1/go.mod h1:FHFuoD6yGz5OSKEBK+aWN9Oah0q54Jxl0abmj6GnqAo= +github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20230305113008-0c11038e723f/go.mod h1:8LHG1a3SRW71ettAD/jW13h8c6AqjVSeL11RAdgaqpo= +github.com/go-git/go-git/v5 v5.9.0 h1:cD9SFA7sHVRdJ7AYck1ZaAa/yeuBvGPxwXDL8cxrObY= +github.com/go-git/go-git/v5 v5.9.0/go.mod h1:RKIqga24sWdMGZF+1Ekv9kylsDz6LzdTSI2s/OsZWE0= github.com/go-test/deep v1.0.7 h1:/VSMRlnY/JSyqxQUzQLKVMAskpY/NZKFA5j2P+0pP2M= github.com/go-test/deep v1.0.7/go.mod h1:QV8Hv/iy04NyLBxAdO9njL0iVPN1S4d/A3NVv1V36o8= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= @@ -41,15 +47,15 @@ github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/hashicorp/hcl/v2 v2.17.0 h1:z1XvSUyXd1HP10U4lrLg5e0JMVz6CPaJvAgxM0KNZVY= -github.com/hashicorp/hcl/v2 v2.17.0/go.mod h1:gJyW2PTShkJqQBKpAmPO3yxMxIuoXkOF2TpqXzrQyx4= +github.com/hashicorp/hcl/v2 v2.18.0 h1:wYnG7Lt31t2zYkcquwgKo6MWXzRUDIeIVU5naZwHLl8= +github.com/hashicorp/hcl/v2 v2.18.0/go.mod h1:ThLC89FV4p9MPW804KVbe/cEXoQ8NZEh+JtMeeGErHE= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -67,14 +73,16 @@ github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APP github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= -github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= +github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= +github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M= github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4= github.com/pjbgf/sha1cd v0.3.0/go.mod h1:nZ1rrWOcGJ5uZgEEVL1VUM9iRQiZvWdbZjkKyFzPPsI= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= +github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= +github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.30.0 h1:SymVODrcRsaRaSInD9yQtKbtWqwsfoPcRff/oRXLj4c= github.com/rs/zerolog v1.30.0/go.mod h1:/tk+P47gFdPXq4QYjvCmT5/Gsug2nagsFWBWhAiSi1w= @@ -97,15 +105,15 @@ github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -github.com/zclconf/go-cty v1.13.2 h1:4GvrUxe/QUDYuJKAav4EYqdM47/kZa672LwmXFmEKT0= -github.com/zclconf/go-cty v1.13.2/go.mod h1:YKQzy/7pZ7iq2jNFzy5go57xdxdWoLLpaEp4u238AE0= +github.com/zclconf/go-cty v1.14.0 h1:/Xrd39K7DXbHzlisFP9c4pHao4yyf+/Ug9LEz+Y/yhc= +github.com/zclconf/go-cty v1.14.0/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= -golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= +golang.org/x/crypto v0.13.0 h1:mvySKfSWJ+UKUii46M40LOvyWfN0s2U+46/jDd0e6Ck= +golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= @@ -117,12 +125,13 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= -golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= -golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= +golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8= +golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= +golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -139,14 +148,15 @@ golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= -golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o= +golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= -golang.org/x/term v0.11.0 h1:F9tnn/DA/Im8nCwm+fX+1/eBwi4qFjRT++MhtVC4ZX0= +golang.org/x/term v0.12.0 h1:/ZfYdc3zq+q02Rv9vGqTeSItdzZTSNDmfTi0mBAuidU= +golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= @@ -154,14 +164,14 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= -golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.12.0 h1:YW6HUoUmYBpwSgyaGaZq1fHjrBjX1rlpZ54T6mu2kss= -golang.org/x/tools v0.12.0/go.mod h1:Sc0INKfu04TlqNoRA1hgpFZbhYXHPr4V5DzpSBTPqQM= +golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ= +golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/src/core/action_test.go b/src/core/action_test.go index f3011fe..f0c1096 100644 --- a/src/core/action_test.go +++ b/src/core/action_test.go @@ -40,6 +40,8 @@ func TestFlags_Action(t *testing.T) { {"dirDry", dirDry, args{}, false}, {"file swipe", file, args{"swipe"}, false}, {"file swot", fileGHA, args{"swot"}, false}, + {"file swot empty", dirDry, args{"swot"}, false}, + {"file swipe empty", dirDry, args{"swipe"}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/src/core/gha_test.go b/src/core/gha_test.go index 8ef247d..8264038 100644 --- a/src/core/gha_test.go +++ b/src/core/gha_test.go @@ -11,6 +11,23 @@ var gitHubToken = os.Getenv("GITHUB_TOKEN") func TestGetBody(t *testing.T) { t.Parallel() + url := "https://api.github.com/users/JamesWoolfenden/orgs" + + result := map[string]interface{}{ + "login": "teamvulkan", + "id": 46164047, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjQ2MTY0MDQ3", + "url": "https://api.github.com/orgs/teamvulkan", + "repos_url": "https://api.github.com/orgs/teamvulkan/repos", + "events_url": "https://api.github.com/orgs/teamvulkan/events", + "hooks_url": "https://api.github.com/orgs/teamvulkan/hooks", + "issues_url": "https://api.github.com/orgs/teamvulkan/issues", + "members_url": "https://api.github.com/orgs/teamvulkan/members{/member}", + "public_members_url": "https://api.github.com/orgs/teamvulkan/public_members{/member}", + "avatar_url": "https://avatars.githubusercontent.com/u/46164047?v=4", + "description": "", + } + type args struct { gitHubToken string url string @@ -22,7 +39,7 @@ func TestGetBody(t *testing.T) { want interface{} wantErr bool }{ - // TODO: Add test cases. + {"Pass", args{gitHubToken: gitHubToken, url: url}, result, false}, } for _, tt := range tests { tt := tt @@ -33,7 +50,9 @@ func TestGetBody(t *testing.T) { t.Errorf("GetGithubBody() error = %v, wantErr %v", err, tt.wantErr) return } - if !reflect.DeepEqual(got, tt.want) { + gotMap := got.([]interface{})[0].(map[string]interface{}) + wanted := tt.want.(map[string]interface{}) + if !reflect.DeepEqual(gotMap["node_id"], wanted["node_id"]) { t.Errorf("GetGithubBody() got = %v, want %v", got, tt.want) } }) @@ -173,6 +192,7 @@ func TestGetLatestTag(t *testing.T) { wantErr bool }{ {"Pass", args{"jameswoolfenden/terraform-azurerm-diskencryptionset", gitHubToken}, latest, false}, + {"Fail", args{"jameswoolfenden/terraform-azurerm-guff", gitHubToken}, "", true}, } for _, tt := range tests { tt := tt @@ -183,6 +203,16 @@ func TestGetLatestTag(t *testing.T) { t.Errorf("GetLatestTag() error = %v, wantErr %v", err, tt.wantErr) return } + + if got == nil && tt.want != "" { + t.Errorf("GetLatestTag() got = nil, want %v", tt.want) + return + } + + if (got == nil) == (tt.want == "") { + return + } + returned := got.(map[string]interface{}) commit := returned["commit"].(map[string]interface{}) hash := commit["sha"].(string) diff --git a/src/core/testdata/files/ci.yml b/src/core/testdata/files/ci.yml index 67b99be..ed677c6 100644 --- a/src/core/testdata/files/ci.yml +++ b/src/core/testdata/files/ci.yml @@ -13,7 +13,7 @@ jobs: ## this will contain a matrix of all the combinations ## we wish to test again: matrix: - go-version: [ 1.20.x ] + go-version: [ 1.21.x ] platform: [ ubuntu-latest, macos-latest, windows-latest ] ## Defines the platform for each test run From 218eb96edafcb6d01c7b408f3f6dd83370437773 Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Mon, 18 Sep 2023 09:40:00 +0100 Subject: [PATCH 40/80] coverage fixes --- main.go | 2 +- src/core/action.go | 2 + src/core/gha.go | 1 + src/core/gha_test.go | 93 ++++++++++++++++++- src/core/modules.go | 2 +- src/core/modules_test.go | 1 + src/core/registry.go | 6 +- src/core/registry_test.go | 7 +- .../testdata/gha/.github/workflows/test.yml | 42 +++++++++ .../testdata/modules/github-git/module.tf | 2 +- 10 files changed, 144 insertions(+), 14 deletions(-) create mode 100644 src/core/testdata/gha/.github/workflows/test.yml diff --git a/main.go b/main.go index 9411d10..8eea6a8 100644 --- a/main.go +++ b/main.go @@ -113,7 +113,7 @@ func main() { }, &cli.BoolFlag{ Name: "update", - Usage: "update to lastest module available", + Usage: "update to latest module available", Destination: &myFlags.Update, Value: false, }, diff --git a/src/core/action.go b/src/core/action.go index eb4dc51..4118542 100644 --- a/src/core/action.go +++ b/src/core/action.go @@ -14,6 +14,8 @@ func (myFlags *Flags) Action(Action string) error { pwd, _ := os.Getwd() myFlags.File = filepath.Join(pwd, myFlags.File) } + + myFlags.Entries = append(myFlags.Entries, myFlags.File) } else { myFlags.Entries, err = GetFiles(myFlags.Directory) diff --git a/src/core/gha.go b/src/core/gha.go index 657e878..87c2285 100644 --- a/src/core/gha.go +++ b/src/core/gha.go @@ -77,6 +77,7 @@ func (myFlags *Flags) GetGHA() ([]string, error) { gitHubPath := filepath.Join(".github", "workflows") for _, match := range myFlags.Entries { + match, _ = filepath.Abs(match) entry, _ := os.Stat(match) if strings.Contains(match, gitHubPath) && !entry.IsDir() { if strings.Contains(match, ".yml") || (strings.Contains(match, ".yaml")) { diff --git a/src/core/gha_test.go b/src/core/gha_test.go index 8264038..f94b119 100644 --- a/src/core/gha_test.go +++ b/src/core/gha_test.go @@ -40,6 +40,7 @@ func TestGetBody(t *testing.T) { wantErr bool }{ {"Pass", args{gitHubToken: gitHubToken, url: url}, result, false}, + {"Pass no token", args{url: url}, result, false}, } for _, tt := range tests { tt := tt @@ -60,18 +61,33 @@ func TestGetBody(t *testing.T) { } func Test_getHash(t *testing.T) { + t.Parallel() + type args struct { action string tag string gitHubToken string } + + want := map[string]interface{}{ + "node_id": "MDM6UmVmMTk3ODE0NjI5OnJlZnMvdGFncy92NC4wLjA=", + "object": map[string]interface{}{ + "sha": "3df4ab11eba7bda6032a0b82a6bb43b11571feac", + "type": "commit", + "url": "https://api.github.com/repos/actions/checkout/git/commits/3df4ab11eba7bda6032a0b82a6bb43b11571feac", + }, + "ref": "refs/tags/v4.0.0", + "url": "https://api.github.com/repos/actions/checkout/git/refs/tags/v4.0.0", + } + tests := []struct { name string args args want interface{} wantErr bool }{ - // TODO: Add test cases. + {"pass", args{"actions/checkout", "v4.0.0", gitHubToken}, want, false}, + {"pass", args{"actions/checkout", "v4.0.999", gitHubToken}, nil, true}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -96,14 +112,37 @@ func Test_getPayload(t *testing.T) { days *int } + days := 0 + ninety := 90 + + daysMap := map[string]interface{}{ + "html_url": "https://github.com/JamesWoolfenden/action-pike/releases/tag/v0.1.3", + "id": 81460196, + "created_at": "2022-10-29T11:25:25Z", + "url": "https://api.github.com/repos/JamesWoolfenden/action-pike/releases/81460196", + "node_id": "RE_kwDOIVF07c4E2vvk", + "prerelease": "false", + "tarball_url": "https://api.github.com/repos/JamesWoolfenden/action-pike/tarball/v0.1.3", + "target_commitish": "master", + "name": "Initial Release", + "zipball_url": "https://api.github.com/repos/JamesWoolfenden/action-pike/zipball/v0.1.3", + "assets_url": "https://api.github.com/repos/JamesWoolfenden/action-pike/releases/81460196/assets", + "upload_url": "https://uploads.github.com/repos/JamesWoolfenden/action-pike/releases/81460196/assets{?name,label}", + "tag_name": "v0.1.3", + "draft": "false", + "published_at": "2022-10-29T15:17:57Z", + } + tests := []struct { name string args args want interface{} wantErr bool }{ - // TODO: Add test cases. + {"pass", args{"JamesWoolfenden/action-pike", gitHubToken, &days}, daysMap, false}, + {"pass", args{"JamesWoolfenden/action-pike", gitHubToken, &ninety}, daysMap, false}, } + for _, tt := range tests { tt := tt t.Run(tt.name, func(t *testing.T) { @@ -113,7 +152,11 @@ func Test_getPayload(t *testing.T) { t.Errorf("getPayload() error = %v, wantErr %v", err, tt.wantErr) return } - if !reflect.DeepEqual(got, tt.want) { + + gotMap := got.(map[string]interface{}) + wantMap := tt.want.(map[string]interface{}) + + if !reflect.DeepEqual(gotMap["created_at"], wantMap["created_at"]) { t.Errorf("getPayload() got = %v, want %v", got, tt.want) } }) @@ -222,3 +265,47 @@ func TestGetLatestTag(t *testing.T) { }) } } + +func TestFlags_UpdateGHAS(t *testing.T) { + t.Parallel() + + type fields struct { + File string + Directory string + GitHubToken string + Days int + DryRun bool + Entries []string + Update bool + } + + tests := []struct { + name string + fields fields + wantErr bool + }{ + {"Pass file", + fields{"./testdata/gha/.github/workflows/test.yml", "", gitHubToken, 0, true, []string{"./testdata/gha/.github/workflows/test.yml"}, true}, false}, + {"Pass dir", + fields{"", "./testdata/gha/.github/workflows", gitHubToken, 0, true, []string{"./testdata/gha/.github/workflows/test.yml"}, true}, false}, + } + + for _, tt := range tests { + tt := tt + t.Run(tt.name, func(t *testing.T) { + t.Parallel() + myFlags := &Flags{ + File: tt.fields.File, + Directory: tt.fields.Directory, + GitHubToken: tt.fields.GitHubToken, + Days: tt.fields.Days, + DryRun: tt.fields.DryRun, + Entries: tt.fields.Entries, + Update: tt.fields.Update, + } + if err := myFlags.UpdateGHAS(); (err != nil) != tt.wantErr { + t.Errorf("UpdateGHAS() error = %v, wantErr %v", err, tt.wantErr) + } + }) + } +} diff --git a/src/core/modules.go b/src/core/modules.go index 36eb5d6..6ee332e 100644 --- a/src/core/modules.go +++ b/src/core/modules.go @@ -224,7 +224,7 @@ func (myFlags *Flags) UpdateSource(module string, moduleType string, version str commas := strings.Split(newModule, ",") if len(commas) > 1 { - log.Info().Msgf("too many urlparams") + log.Info().Msgf("too many URL params") //do something } } diff --git a/src/core/modules_test.go b/src/core/modules_test.go index 76d82ed..555d11a 100644 --- a/src/core/modules_test.go +++ b/src/core/modules_test.go @@ -97,6 +97,7 @@ func TestFlags_UpdateSource(t *testing.T) { moduleType string version string } + //goland:noinspection HttpUrlsUsage tests := []struct { name string fields fields diff --git a/src/core/registry.go b/src/core/registry.go index 5c47991..7af04d9 100644 --- a/src/core/registry.go +++ b/src/core/registry.go @@ -5,8 +5,6 @@ import ( "fmt" "io" "net/http" - - "github.com/rs/zerolog/log" ) type Registry struct { @@ -33,9 +31,7 @@ func IsOK(url string) (bool, error) { return true, nil } - log.Info().Msgf("Received %s for %s", resp.Status, url) - - return false, nil + return false, fmt.Errorf("Received %s for %s", resp.Status, url) } func (myRegistry *Registry) GetLatest(module string) (*string, error) { diff --git a/src/core/registry_test.go b/src/core/registry_test.go index 96f415f..79f7b75 100644 --- a/src/core/registry_test.go +++ b/src/core/registry_test.go @@ -19,7 +19,7 @@ func TestIsOK(t *testing.T) { wantErr bool }{ {"Pass", args{"https://registry.terraform.io/v1/modules/jameswoolfenden/ip/http/versions"}, true, false}, - {"Fail", args{"https://registry.terraform.io/v1/modules/jameswoolfenden/ip/https/versions"}, false, false}, + {"Fail", args{"https://registry.terraform.io/v1/modules/jameswoolfenden/ip/https/versions"}, false, true}, {"NotUrl", args{"jameswoolfenden/ip/https"}, false, true}, } @@ -59,8 +59,8 @@ func TestRegistry_IsRegistryModule(t *testing.T) { wantErr bool }{ {"Pass", fields{false}, args{"jameswoolfenden/ip/http"}, true, false}, - {"Fail", fields{false}, args{"jameswoolfenden/ip/https"}, false, false}, - {"NotUrl", fields{false}, args{"https://jameswoolfenden/ip/https"}, false, false}, + {"Fail", fields{false}, args{"jameswoolfenden/ip/https"}, false, true}, + {"NotUrl", fields{false}, args{"https://jameswoolfenden/ip/https"}, false, true}, } for _, tt := range tests { @@ -105,6 +105,7 @@ func TestRegistry_GetLatest(t *testing.T) { wantErr bool }{ {"Pass", fields{false, ""}, args{"jameswoolfenden/ip/http"}, &want, false}, + {"Fail", fields{false, ""}, args{"jameswoolfenden/ip/guff"}, nil, true}, } for _, tt := range tests { tt := tt diff --git a/src/core/testdata/gha/.github/workflows/test.yml b/src/core/testdata/gha/.github/workflows/test.yml new file mode 100644 index 0000000..2a18f69 --- /dev/null +++ b/src/core/testdata/gha/.github/workflows/test.yml @@ -0,0 +1,42 @@ +on: + push: + branches: + - master + +name: CI +permissions: read-all +env: + GITHUB_TOKEN: ${{ github.token }} +jobs: + test: + ## We want to define a strategy for our job + strategy: + ## this will contain a matrix of all the combinations + ## we wish to test again: + matrix: + go-version: [ 1.21.x ] + platform: [ ubuntu-latest, macos-latest, windows-latest ] + + ## Defines the platform for each test run + runs-on: ${{ matrix.platform }} + + ## the steps that will be run through for each version and platform + ## combination + steps: + ## sets up go based on the version + - name: Install Go + uses: actions/setup-go@v1.0 + with: + go-version: ${{ matrix.go-version }} + + ## checks out our code locally, so we can work with the files + - name: Checkout code + uses: actions/checkout@v1.0 + + ## runs go test ./... + - name: Build + run: go build ./... + + ## runs go test ./... + - name: Test + run: go test ./... diff --git a/src/core/testdata/modules/github-git/module.tf b/src/core/testdata/modules/github-git/module.tf index a0ef667..7697a32 100644 --- a/src/core/testdata/modules/github-git/module.tf +++ b/src/core/testdata/modules/github-git/module.tf @@ -1,4 +1,4 @@ -module "diskencryptionset" { +module "disk_encryption_set" { source = "git::https://github.com/JamesWoolfenden/terraform-azurerm-diskencryptionset.git?ref=fc0b830997dd820476a7ad5e4b6ef2dcbdc766d7" common_tags = var.common_tags location = var.location From e0f94bd902ff140d0c0e2ebc6188e461b040c9e2 Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Wed, 20 Sep 2023 06:55:07 +0100 Subject: [PATCH 41/80] Update ci.yml --- .github/workflows/ci.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 520824a..6ea360b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,3 +40,8 @@ jobs: ## runs go test ./... - name: Test run: go test ./... + + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v3 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} From b3cfaab95610e7ff45744aca3dbc2ddd49e4c2fd Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Wed, 20 Sep 2023 07:07:23 +0100 Subject: [PATCH 42/80] Update ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6ea360b..061629a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,7 +39,7 @@ jobs: ## runs go test ./... - name: Test - run: go test ./... + run: go test ./... -coverprofile=./cover.out - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v3 From 3e1ef24d848cfa32f265c75b99d6020b44cb3834 Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Wed, 20 Sep 2023 08:26:05 +0100 Subject: [PATCH 43/80] add coverage and stability --- .github/workflows/ci.yml | 2 +- .pre-commit-config.yaml | 5 +- README.md | 1 + go.mod | 4 +- go.sum | 8 +- main.go | 6 ++ src/core/gha.go | 16 ++-- src/core/gha_test.go | 78 ++++++++++++++++++- src/core/registry.go | 2 +- .../faulty/.github/workflows/test.yml | 42 ++++++++++ .../testdata/gha/.github/workflows/test.yml | 4 +- src/core/types.go | 15 ++-- 12 files changed, 155 insertions(+), 28 deletions(-) create mode 100644 src/core/testdata/faulty/.github/workflows/test.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 061629a..b02254d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,6 +42,6 @@ jobs: run: go test ./... -coverprofile=./cover.out - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@3444e47d45411c1e34e39245eb914e9d557d2305 # v3.1.4 env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 22f606b..b96e51c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -55,7 +55,7 @@ repos: hooks: - id: golangci-lint - repo: https://github.com/bridgecrewio/checkov - rev: 2.4.39 + rev: 2.4.42 hooks: - id: checkov language_version: python3.10 @@ -66,7 +66,8 @@ repos: name: ghat description: upgrade action dependencies language: golang - entry: ghat swot -d . + entry: ghat swot -d . --continue-on-error true + exclude: test.yml pass_filenames: false always_run: true types: [ yaml ] diff --git a/README.md b/README.md index eafad3e..d9ac23e 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ [![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit) [![checkov](https://img.shields.io/badge/checkov-verified-brightgreen)](https://www.checkov.io/) [![Github All Releases](https://img.shields.io/github/downloads/jameswoolfenden/ghat/total.svg)](https://github.com/JamesWoolfenden/ghat/releases) +[![codecov](https://codecov.io/gh/JamesWoolfenden/ghat/graph/badge.svg?token=P9V791WMRE)](https://codecov.io/gh/JamesWoolfenden/ghat) Ghat is a tool (GHAT) for updating dependencies in a GHA - GitHub Action, and now also for updating and **managing Terraform Dependencies**. It replaces insecure mutable tags with immutable commit hashes as well as using the latest released version: diff --git a/go.mod b/go.mod index 21f7178..0220d9d 100644 --- a/go.mod +++ b/go.mod @@ -26,7 +26,7 @@ require ( github.com/emirpasic/gods v1.18.1 // indirect github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect github.com/go-git/go-billy/v5 v5.5.0 // indirect - github.com/go-test/deep v1.0.7 // indirect + github.com/go-test/deep v1.1.0 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/google/go-cmp v0.5.9 // indirect github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect @@ -37,7 +37,7 @@ require ( github.com/mitchellh/go-wordwrap v1.0.1 // indirect github.com/pjbgf/sha1cd v0.3.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect - github.com/skeema/knownhosts v1.2.0 // indirect + github.com/skeema/knownhosts v1.2.1 // indirect github.com/stretchr/testify v1.8.4 // indirect github.com/xanzy/ssh-agent v0.3.3 // indirect github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect diff --git a/go.sum b/go.sum index d425b80..8058340 100644 --- a/go.sum +++ b/go.sum @@ -40,8 +40,8 @@ github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20230305113008-0c11038e723f h1:Pz0 github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20230305113008-0c11038e723f/go.mod h1:8LHG1a3SRW71ettAD/jW13h8c6AqjVSeL11RAdgaqpo= github.com/go-git/go-git/v5 v5.9.0 h1:cD9SFA7sHVRdJ7AYck1ZaAa/yeuBvGPxwXDL8cxrObY= github.com/go-git/go-git/v5 v5.9.0/go.mod h1:RKIqga24sWdMGZF+1Ekv9kylsDz6LzdTSI2s/OsZWE0= -github.com/go-test/deep v1.0.7 h1:/VSMRlnY/JSyqxQUzQLKVMAskpY/NZKFA5j2P+0pP2M= -github.com/go-test/deep v1.0.7/go.mod h1:QV8Hv/iy04NyLBxAdO9njL0iVPN1S4d/A3NVv1V36o8= +github.com/go-test/deep v1.1.0 h1:WOcxcdHcvdgThNXjw0t76K42FXTU7HpNQWHpA2HHNlg= +github.com/go-test/deep v1.1.0/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -91,8 +91,8 @@ github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQD github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= -github.com/skeema/knownhosts v1.2.0 h1:h9r9cf0+u7wSE+M183ZtMGgOJKiL96brpaz5ekfJCpM= -github.com/skeema/knownhosts v1.2.0/go.mod h1:g4fPeYpque7P0xefxtGzV81ihjC8sX2IqpAoNkjxbMo= +github.com/skeema/knownhosts v1.2.1 h1:SHWdIUa82uGZz+F+47k8SY4QhhI291cXCpopT1lK2AQ= +github.com/skeema/knownhosts v1.2.1/go.mod h1:xYbVRSPxqBZFrdmDyMmsOs+uX1UZC3nTN3ThzgDxUwo= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= diff --git a/main.go b/main.go index 8eea6a8..a43d077 100644 --- a/main.go +++ b/main.go @@ -85,6 +85,12 @@ func main() { Destination: &myFlags.DryRun, Value: false, }, + &cli.BoolFlag{ + Name: "continue-on-error", + Usage: "just keep going", + Destination: &myFlags.ContinueOnError, + Value: false, + }, }, }, { diff --git a/src/core/gha.go b/src/core/gha.go index 87c2285..da65e8d 100644 --- a/src/core/gha.go +++ b/src/core/gha.go @@ -119,9 +119,11 @@ func (myFlags *Flags) UpdateGHA(file string) error { newUrl = splitter[0] + "/" + splitter[1] body, err = getPayload(newUrl, myFlags.GitHubToken, &myFlags.Days) if err != nil { - log.Warn().Msgf("failed to retrieve back %s", err) - - continue + if myFlags.ContinueOnError { + log.Info().Err(err) + continue + } + return fmt.Errorf("failed to retrieve data for action %s with %s", action[0], err) } } @@ -141,13 +143,17 @@ func (myFlags *Flags) UpdateGHA(file string) error { } payload, err := getHash(url, tag, myFlags.GitHubToken) - body := payload.(map[string]interface{}) - if err != nil { log.Warn().Msgf("failed to retrieve commit hash %s for %s", err, action[0]) continue } + body, ok := payload.(map[string]interface{}) + if !ok { + log.Warn().Msgf("Payload is not expected map %s", body) + continue + } + object, ok := body["object"].(map[string]interface{}) if !ok { log.Warn().Msgf("failed to assert map of string %s", err) diff --git a/src/core/gha_test.go b/src/core/gha_test.go index f94b119..470001f 100644 --- a/src/core/gha_test.go +++ b/src/core/gha_test.go @@ -11,6 +11,8 @@ var gitHubToken = os.Getenv("GITHUB_TOKEN") func TestGetBody(t *testing.T) { t.Parallel() + garbage := "guffinhere" + fail_url := "https://api.github.com/users/JamesWoolfenden2/orgs" url := "https://api.github.com/users/JamesWoolfenden/orgs" result := map[string]interface{}{ @@ -41,6 +43,8 @@ func TestGetBody(t *testing.T) { }{ {"Pass", args{gitHubToken: gitHubToken, url: url}, result, false}, {"Pass no token", args{url: url}, result, false}, + {"Fail 404", args{gitHubToken: gitHubToken, url: fail_url}, nil, true}, + {"Garbage", args{gitHubToken: gitHubToken, url: garbage}, nil, true}, } for _, tt := range tests { tt := tt @@ -51,11 +55,18 @@ func TestGetBody(t *testing.T) { t.Errorf("GetGithubBody() error = %v, wantErr %v", err, tt.wantErr) return } - gotMap := got.([]interface{})[0].(map[string]interface{}) - wanted := tt.want.(map[string]interface{}) - if !reflect.DeepEqual(gotMap["node_id"], wanted["node_id"]) { - t.Errorf("GetGithubBody() got = %v, want %v", got, tt.want) + if tt.want != nil { + gotMap := got.([]interface{})[0].(map[string]interface{}) + wanted := tt.want.(map[string]interface{}) + if !reflect.DeepEqual(gotMap["node_id"], wanted["node_id"]) { + t.Errorf("GetGithubBody() got = %v, want %v", got, tt.want) + } + return + } + if got != nil { + t.Errorf("GetGithubBody() nillness got = %v, want %v", got, tt.want) } + }) } } @@ -309,3 +320,62 @@ func TestFlags_UpdateGHAS(t *testing.T) { }) } } + +func TestFlags_UpdateGHA(t *testing.T) { + t.Parallel() + type fields struct { + File string + Directory string + GitHubToken string + Days int + DryRun bool + Entries []string + Update bool + ContinueOnError bool + } + + type args struct { + file string + } + + tests := []struct { + name string + fields fields + args args + wantErr bool + }{ + {name: "Pass file", + fields: fields{File: "./testdata/gha/.github/workflows/test.yml", GitHubToken: gitHubToken, DryRun: true, Entries: []string{"./testdata/gha/.github/workflows/test.yml"}, Update: true}, + args: args{"./testdata/gha/.github/workflows/test.yml"}}, + {name: "No such file", + fields: fields{File: "./testdata/gha/.github/workflows/guff.yml", GitHubToken: gitHubToken, DryRun: true, Entries: []string{"./testdata/gha/.github/workflows/test.yml"}, Update: true}, + args: args{"./testdata/gha/.github/workflows/guff.yml"}, + wantErr: true}, + {name: "Faulty GHA", + fields: fields{File: "./testdata/faulty/.github/workflows/test.yml", GitHubToken: gitHubToken, DryRun: true, Entries: []string{"./testdata/faulty/.github/workflows/test.yml"}, Update: true}, + args: args{file: "./testdata/faulty/.github/workflows/test.yml"}, + wantErr: true}, + {name: "Faulty GHA continue", + fields: fields{File: "./testdata/faulty/.github/workflows/test.yml", GitHubToken: gitHubToken, DryRun: true, Entries: []string{"./testdata/faulty/.github/workflows/test.yml"}, Update: true, ContinueOnError: true}, + args: args{file: "./testdata/faulty/.github/workflows/test.yml"}}, + } + for _, tt := range tests { + tt := tt + t.Run(tt.name, func(t *testing.T) { + t.Parallel() + myFlags := &Flags{ + File: tt.fields.File, + Directory: tt.fields.Directory, + GitHubToken: tt.fields.GitHubToken, + Days: tt.fields.Days, + DryRun: tt.fields.DryRun, + Entries: tt.fields.Entries, + Update: tt.fields.Update, + ContinueOnError: tt.fields.ContinueOnError, + } + if err := myFlags.UpdateGHA(tt.args.file); (err != nil) != tt.wantErr { + t.Errorf("UpdateGHA() error = %v, wantErr %v", err, tt.wantErr) + } + }) + } +} diff --git a/src/core/registry.go b/src/core/registry.go index 7af04d9..62785db 100644 --- a/src/core/registry.go +++ b/src/core/registry.go @@ -31,7 +31,7 @@ func IsOK(url string) (bool, error) { return true, nil } - return false, fmt.Errorf("Received %s for %s", resp.Status, url) + return false, fmt.Errorf("received %s for %s", resp.Status, url) } func (myRegistry *Registry) GetLatest(module string) (*string, error) { diff --git a/src/core/testdata/faulty/.github/workflows/test.yml b/src/core/testdata/faulty/.github/workflows/test.yml new file mode 100644 index 0000000..c374aad --- /dev/null +++ b/src/core/testdata/faulty/.github/workflows/test.yml @@ -0,0 +1,42 @@ +on: + push: + branches: + - master + +name: CI +permissions: read-all +env: + GITHUB_TOKEN: ${{ github.token }} +jobs: + test: + ## We want to define a strategy for our job + strategy: + ## this will contain a matrix of all the combinations + ## we wish to test again: + matrix: + go-version: [ 1.21.x ] + platform: [ ubuntu-latest, macos-latest, windows-latest ] + + ## Defines the platform for each test run + runs-on: ${{ matrix.platform }} + + ## the steps that will be run through for each version and platform + ## combination + steps: + ## sets up go based on the version + - name: Install Go + uses: notactions/setup-go@v1.0 + with: + go-version: ${{ matrix.go-version }} + + ## checks out our code locally, so we can work with the files + - name: Checkout code + uses: actions/checkout@v1.0 + + ## runs go test ./... + - name: Build + run: go build ./... + + ## runs go test ./... + - name: Test + run: go test ./... diff --git a/src/core/testdata/gha/.github/workflows/test.yml b/src/core/testdata/gha/.github/workflows/test.yml index 2a18f69..520824a 100644 --- a/src/core/testdata/gha/.github/workflows/test.yml +++ b/src/core/testdata/gha/.github/workflows/test.yml @@ -25,13 +25,13 @@ jobs: steps: ## sets up go based on the version - name: Install Go - uses: actions/setup-go@v1.0 + uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0 with: go-version: ${{ matrix.go-version }} ## checks out our code locally, so we can work with the files - name: Checkout code - uses: actions/checkout@v1.0 + uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 ## runs go test ./... - name: Build diff --git a/src/core/types.go b/src/core/types.go index e5ed6fd..9e9d4d1 100644 --- a/src/core/types.go +++ b/src/core/types.go @@ -1,11 +1,12 @@ package core type Flags struct { - File string - Directory string - GitHubToken string - Days int - DryRun bool - Entries []string - Update bool + File string + Directory string + GitHubToken string + Days int + DryRun bool + Entries []string + Update bool + ContinueOnError bool } From de9976ad4a102bd0db67eb59c2b170dba236f8de Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Wed, 20 Sep 2023 08:30:10 +0100 Subject: [PATCH 44/80] add coverage and stability --- .pre-commit-config.yaml | 1 - src/core/testdata/gha/.github/workflows/test.yml | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b96e51c..6d437e2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -67,7 +67,6 @@ repos: description: upgrade action dependencies language: golang entry: ghat swot -d . --continue-on-error true - exclude: test.yml pass_filenames: false always_run: true types: [ yaml ] diff --git a/src/core/testdata/gha/.github/workflows/test.yml b/src/core/testdata/gha/.github/workflows/test.yml index 520824a..1f2d67a 100644 --- a/src/core/testdata/gha/.github/workflows/test.yml +++ b/src/core/testdata/gha/.github/workflows/test.yml @@ -25,13 +25,13 @@ jobs: steps: ## sets up go based on the version - name: Install Go - uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0 + uses: actions/setup-go@v1.0 with: go-version: ${{ matrix.go-version }} ## checks out our code locally, so we can work with the files - name: Checkout code - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 + uses: actions/checkout@v1.0 # v4.0.0 ## runs go test ./... - name: Build From bf54ea5fe19cb9a5074767db5fac87708745a5da Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Wed, 20 Sep 2023 08:38:17 +0100 Subject: [PATCH 45/80] add coverage and stability --- src/core/gha_test.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/core/gha_test.go b/src/core/gha_test.go index 470001f..fde8373 100644 --- a/src/core/gha_test.go +++ b/src/core/gha_test.go @@ -4,6 +4,8 @@ import ( "os" "reflect" "testing" + + "github.com/rs/zerolog/log" ) var gitHubToken = os.Getenv("GITHUB_TOKEN") @@ -56,7 +58,11 @@ func TestGetBody(t *testing.T) { return } if tt.want != nil { - gotMap := got.([]interface{})[0].(map[string]interface{}) + gotMap, ok := got.([]interface{})[0].(map[string]interface{}) + if !ok { + log.Info().Msgf("assertion error %s", err) + return + } wanted := tt.want.(map[string]interface{}) if !reflect.DeepEqual(gotMap["node_id"], wanted["node_id"]) { t.Errorf("GetGithubBody() got = %v, want %v", got, tt.want) From 703e8f6bfbd301ea06da39dbc1d89ce50a13e6c4 Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Wed, 20 Sep 2023 09:09:42 +0100 Subject: [PATCH 46/80] check type in test --- src/core/gha_test.go | 5 ++++- src/core/testdata/gha/.github/workflows/test.yml | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/core/gha_test.go b/src/core/gha_test.go index fde8373..db54dc9 100644 --- a/src/core/gha_test.go +++ b/src/core/gha_test.go @@ -58,12 +58,15 @@ func TestGetBody(t *testing.T) { return } if tt.want != nil { - gotMap, ok := got.([]interface{})[0].(map[string]interface{}) + _, ok := got.([]interface{}) if !ok { log.Info().Msgf("assertion error %s", err) return } + + gotMap := got.([]interface{})[0].(map[string]interface{}) wanted := tt.want.(map[string]interface{}) + if !reflect.DeepEqual(gotMap["node_id"], wanted["node_id"]) { t.Errorf("GetGithubBody() got = %v, want %v", got, tt.want) } diff --git a/src/core/testdata/gha/.github/workflows/test.yml b/src/core/testdata/gha/.github/workflows/test.yml index 1f2d67a..520824a 100644 --- a/src/core/testdata/gha/.github/workflows/test.yml +++ b/src/core/testdata/gha/.github/workflows/test.yml @@ -25,13 +25,13 @@ jobs: steps: ## sets up go based on the version - name: Install Go - uses: actions/setup-go@v1.0 + uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0 with: go-version: ${{ matrix.go-version }} ## checks out our code locally, so we can work with the files - name: Checkout code - uses: actions/checkout@v1.0 # v4.0.0 + uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 ## runs go test ./... - name: Build From 0245f07a5d432b4c322cc2d516f06f7bd777bad2 Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Wed, 20 Sep 2023 15:57:51 +0100 Subject: [PATCH 47/80] new hooks --- .checkov.yaml | 22 ++++++++++++++++++++++ .pre-commit-config.yaml | 6 ++++++ 2 files changed, 28 insertions(+) create mode 100644 .checkov.yaml diff --git a/.checkov.yaml b/.checkov.yaml new file mode 100644 index 0000000..af0c4a4 --- /dev/null +++ b/.checkov.yaml @@ -0,0 +1,22 @@ +block-list-secret-scan: [ ] +branch: master +directory: + - . +download-external-modules: false +evaluate-variables: true +external-modules-download-path: .external_modules +framework: + - secrets + - github_configuration + - github_actions + - json + - yaml + - sca_package + - sca_image +mask: [ ] +secrets-history-timeout: 12h +secrets-scan-file-type: [ ] +skip-path: + - terraform + - venv +summary-position: top diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6d437e2..62b2f7b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -70,3 +70,9 @@ repos: pass_filenames: false always_run: true types: [ yaml ] + - repo: https://github.com/dnephin/pre-commit-golang + rev: v0.5.1 + hooks: + - id: validate-toml + - id: no-go-testing + - id: go-mod-tidy From 902ae4b2c60b2bb724ccbc37f2561c0354554632 Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Sun, 24 Sep 2023 09:04:28 +0100 Subject: [PATCH 48/80] increase coverage --- .pre-commit-config.yaml | 4 ++-- go.mod | 2 +- go.sum | 4 ++-- src/core/action_test.go | 2 ++ src/core/gha.go | 10 +++------- src/core/gha_test.go | 28 ++++++++++++---------------- src/core/modules.go | 16 ++++++++-------- 7 files changed, 30 insertions(+), 36 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 62b2f7b..9c0eb02 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -29,7 +29,7 @@ repos: hooks: - id: shell-lint - repo: https://github.com/igorshubovych/markdownlint-cli - rev: v0.36.0 + rev: v0.37.0 hooks: - id: markdownlint exclude: src/testdata|testdata @@ -55,7 +55,7 @@ repos: hooks: - id: golangci-lint - repo: https://github.com/bridgecrewio/checkov - rev: 2.4.42 + rev: 2.4.48 hooks: - id: checkov language_version: python3.10 diff --git a/go.mod b/go.mod index 0220d9d..5934dfa 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( require ( dario.cat/mergo v1.0.0 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect - github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect + github.com/ProtonMail/go-crypto v0.0.0-20230923063757-afb1ddc0824c // indirect github.com/acomagu/bufpipe v1.0.4 // indirect github.com/agext/levenshtein v1.2.3 // indirect github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect diff --git a/go.sum b/go.sum index 8058340..a05a663 100644 --- a/go.sum +++ b/go.sum @@ -3,8 +3,8 @@ dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= -github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 h1:kkhsdkhsCvIsutKu5zLMgWtgh9YxGCNAw8Ad8hjwfYg= -github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= +github.com/ProtonMail/go-crypto v0.0.0-20230923063757-afb1ddc0824c h1:kMFnB0vCcX7IL/m9Y5LO+KQYv+t1CQOiFe6+SV2J7bE= +github.com/ProtonMail/go-crypto v0.0.0-20230923063757-afb1ddc0824c/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= github.com/acomagu/bufpipe v1.0.4 h1:e3H4WUzM3npvo5uv95QuJM3cQspFNtFBzvJ2oNjKIDQ= github.com/acomagu/bufpipe v1.0.4/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4= github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= diff --git a/src/core/action_test.go b/src/core/action_test.go index f0c1096..740efe9 100644 --- a/src/core/action_test.go +++ b/src/core/action_test.go @@ -26,6 +26,7 @@ func TestFlags_Action(t *testing.T) { dirDry := fields{"", "testdata/files/", gitHubToken, 0, true, nil, true} fileGHA := fields{"testdata/files/ci.yml", "testdata/files/", gitHubToken, 0, true, nil, true} file := fields{"testdata/files/module.tf", "testdata/files/", gitHubToken, 0, true, nil, true} + noFile := fields{"testdata/files/guff.tf", "testdata/files/", gitHubToken, 0, true, nil, true} tests := []struct { name string @@ -42,6 +43,7 @@ func TestFlags_Action(t *testing.T) { {"file swot", fileGHA, args{"swot"}, false}, {"file swot empty", dirDry, args{"swot"}, false}, {"file swipe empty", dirDry, args{"swipe"}, false}, + {"no file", noFile, args{"swipe"}, true}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/src/core/gha.go b/src/core/gha.go index da65e8d..391b605 100644 --- a/src/core/gha.go +++ b/src/core/gha.go @@ -53,11 +53,7 @@ func GetFiles(dir string) ([]string, error) { func (myFlags *Flags) UpdateGHAS() error { var err error - myFlags.Entries, err = myFlags.GetGHA() - - if err != nil { - return err - } + myFlags.Entries = myFlags.GetGHA() for _, gha := range myFlags.Entries { err = myFlags.UpdateGHA(gha) @@ -71,7 +67,7 @@ func (myFlags *Flags) UpdateGHAS() error { } // GetGHA gets all the actions in a directory -func (myFlags *Flags) GetGHA() ([]string, error) { +func (myFlags *Flags) GetGHA() []string { var ghat []string gitHubPath := filepath.Join(".github", "workflows") @@ -86,7 +82,7 @@ func (myFlags *Flags) GetGHA() ([]string, error) { } } - return ghat, nil + return ghat } // UpdateGHA updates am action with latest dependencies diff --git a/src/core/gha_test.go b/src/core/gha_test.go index db54dc9..dc0d9ec 100644 --- a/src/core/gha_test.go +++ b/src/core/gha_test.go @@ -13,8 +13,8 @@ var gitHubToken = os.Getenv("GITHUB_TOKEN") func TestGetBody(t *testing.T) { t.Parallel() - garbage := "guffinhere" - fail_url := "https://api.github.com/users/JamesWoolfenden2/orgs" + garbage := "guff-inhere" + failUrl := "https://api.github.com/users/JamesWoolfenden2/orgs" url := "https://api.github.com/users/JamesWoolfenden/orgs" result := map[string]interface{}{ @@ -45,7 +45,7 @@ func TestGetBody(t *testing.T) { }{ {"Pass", args{gitHubToken: gitHubToken, url: url}, result, false}, {"Pass no token", args{url: url}, result, false}, - {"Fail 404", args{gitHubToken: gitHubToken, url: fail_url}, nil, true}, + {"Fail 404", args{gitHubToken: gitHubToken, url: failUrl}, nil, true}, {"Garbage", args{gitHubToken: gitHubToken, url: garbage}, nil, true}, } for _, tt := range tests { @@ -208,15 +208,14 @@ func TestFlags_GetGHA(t *testing.T) { var nothing []string tests := []struct { - name string - fields fields - args args - want []string - wantErr bool + name string + fields fields + args args + want []string }{ - {"no matches", duffDir, args{noMatches, nil}, nothing, false}, - {"no workflows", noWorkflowsDir, args{noWorkflows, nil}, nil, false}, - {"no workflows with dir", noWorkflowsWithDir, args{noWorkflowsWithDirContents, nil}, nil, false}, + {"no matches", duffDir, args{noMatches, nil}, nothing}, + {"no workflows", noWorkflowsDir, args{noWorkflows, nil}, nil}, + {"no workflows with dir", noWorkflowsWithDir, args{noWorkflowsWithDirContents, nil}, nil}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -227,11 +226,8 @@ func TestFlags_GetGHA(t *testing.T) { Days: tt.fields.Days, DryRun: tt.fields.DryRun, } - got, err := myFlags.GetGHA() - if (err != nil) != tt.wantErr { - t.Errorf("GetGHA() error = %v, wantErr %v", err, tt.wantErr) - return - } + got := myFlags.GetGHA() + if !reflect.DeepEqual(got, tt.want) { t.Errorf("GetGHA() got = %v, want %v", got, tt.want) } diff --git a/src/core/modules.go b/src/core/modules.go index 6ee332e..0f50f83 100644 --- a/src/core/modules.go +++ b/src/core/modules.go @@ -220,14 +220,14 @@ func (myFlags *Flags) UpdateSource(module string, moduleType string, version str //var hash string newModule := strings.TrimPrefix(module, "git::") - if strings.Contains(newModule, ",") { - commas := strings.Split(newModule, ",") - - if len(commas) > 1 { - log.Info().Msgf("too many URL params") - //do something - } - } + //if strings.Contains(newModule, ",") { + // commas := strings.Split(newModule, ",") + // + // if len(commas) > 1 { + // log.Info().Msgf("too many URL params") + // //do something + // } + //} splitter := strings.Split(newModule, "?ref=") root := splitter[0] From 2eb2cc581eb21afe50697cac8bbaec8e6019d84e Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Wed, 27 Sep 2023 07:26:26 +0100 Subject: [PATCH 49/80] coverage --- .github/workflows/ci.yml | 2 +- .github/workflows/codeql-analysis.yml | 8 ++++---- .github/workflows/pr.yml | 6 +++--- .github/workflows/release.yml | 4 ++-- src/core/registry.go | 6 +----- src/core/registry_test.go | 1 + src/core/testdata/gha/.github/workflows/test.yml | 2 +- 7 files changed, 13 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b02254d..d4bacb1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,7 +31,7 @@ jobs: ## checks out our code locally, so we can work with the files - name: Checkout code - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 ## runs go test ./... - name: Build diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 92db1c4..915c896 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -39,11 +39,11 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@c6c77c8c2d62cfd5b2e8d548817fd3d1582ac744 # codeql-bundle-v2.14.5 + uses: github/codeql-action/init@8e0b1c74b1d5a0077b04d064c76ee714d3da7637 # codeql-bundle-v2.14.6 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -53,7 +53,7 @@ jobs: # 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@c6c77c8c2d62cfd5b2e8d548817fd3d1582ac744 # codeql-bundle-v2.14.5 + uses: github/codeql-action/autobuild@8e0b1c74b1d5a0077b04d064c76ee714d3da7637 # codeql-bundle-v2.14.6 # â„šī¸ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun @@ -66,4 +66,4 @@ jobs: # ./location_of_script_within_repo/buildscript.sh - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@c6c77c8c2d62cfd5b2e8d548817fd3d1582ac744 # codeql-bundle-v2.14.5 + uses: github/codeql-action/analyze@8e0b1c74b1d5a0077b04d064c76ee714d3da7637 # codeql-bundle-v2.14.6 diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 409dc5a..33d0d43 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - name: Install Go uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0 with: @@ -30,7 +30,7 @@ jobs: runs-on: ${{ matrix.platform }} steps: - name: Checkout code - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - name: Install Go uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0 with: @@ -48,7 +48,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - name: Install Go uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6d711dd..4f10773 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - name: Unshallow run: git fetch --prune --unshallow - name: Set up Go @@ -41,7 +41,7 @@ jobs: needs: - goreleaser steps: - - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 + - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - name: Publish to Registry uses: elgohr/Publish-Docker-Github-Action@219613003b08f4d049f34cb56c92e84345e1bb3f # v5 with: diff --git a/src/core/registry.go b/src/core/registry.go index 62785db..edace80 100644 --- a/src/core/registry.go +++ b/src/core/registry.go @@ -43,11 +43,7 @@ func (myRegistry *Registry) GetLatest(module string) (*string, error) { if found { url := "https://registry.terraform.io/v1/modules/" + module - resp, err := http.Get(url) - - if err != nil { - return nil, fmt.Errorf("failed to get url %w", err) - } + resp, _ := http.Get(url) if resp == nil { return nil, fmt.Errorf("api failed to respond") diff --git a/src/core/registry_test.go b/src/core/registry_test.go index 79f7b75..e4851a9 100644 --- a/src/core/registry_test.go +++ b/src/core/registry_test.go @@ -106,6 +106,7 @@ func TestRegistry_GetLatest(t *testing.T) { }{ {"Pass", fields{false, ""}, args{"jameswoolfenden/ip/http"}, &want, false}, {"Fail", fields{false, ""}, args{"jameswoolfenden/ip/guff"}, nil, true}, + {"norepo", fields{false, ""}, args{"jameswoolfenden/ip/guff"}, nil, true}, } for _, tt := range tests { tt := tt diff --git a/src/core/testdata/gha/.github/workflows/test.yml b/src/core/testdata/gha/.github/workflows/test.yml index 520824a..d835054 100644 --- a/src/core/testdata/gha/.github/workflows/test.yml +++ b/src/core/testdata/gha/.github/workflows/test.yml @@ -31,7 +31,7 @@ jobs: ## checks out our code locally, so we can work with the files - name: Checkout code - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 ## runs go test ./... - name: Build From e79bc004310776cd9a66ecbbe1670a238d642d3f Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Thu, 28 Sep 2023 09:34:19 +0100 Subject: [PATCH 50/80] sift --- .pre-commit-config.yaml | 169 ++++++++++++++++++++---------------- .pre-commit-hooks.yaml | 24 +++++ Makefile | 1 - go.mod | 3 +- go.sum | 8 +- main.go | 32 +++++++ src/core/action.go | 4 + src/core/pre-commit.go | 77 ++++++++++++++++ src/core/pre-commit_test.go | 49 +++++++++++ 9 files changed, 283 insertions(+), 84 deletions(-) create mode 100644 src/core/pre-commit.go create mode 100644 src/core/pre-commit_test.go diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9c0eb02..c0bf71f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,78 +1,95 @@ ---- -# yamllint disable rule:line-length default_language_version: - python: python3.10 + python: python3.11 repos: - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 - hooks: - - id: check-json - - id: check-merge-conflict - - id: trailing-whitespace - - id: end-of-file-fixer - - id: check-yaml - exclude: examples/ - - id: check-added-large-files - - id: pretty-format-json - args: - - --autofix - - id: detect-aws-credentials - - id: detect-private-key - - repo: https://github.com/Lucas-C/pre-commit-hooks - rev: v1.5.4 - hooks: - - id: forbid-tabs - exclude_types: [ python, javascript, dtd, markdown, makefile, xml ] - exclude: binary|\.bin$|rego|\.rego$|go|\.go$ - - repo: https://github.com/jameswoolfenden/pre-commit-shell - rev: 0.0.2 - hooks: - - id: shell-lint - - repo: https://github.com/igorshubovych/markdownlint-cli - rev: v0.37.0 - hooks: - - id: markdownlint - exclude: src/testdata|testdata - - repo: https://github.com/jameswoolfenden/pre-commit - rev: v0.1.50 - hooks: - - id: terraform-fmt - language_version: python3.10 - - repo: https://github.com/gruntwork-io/pre-commit - rev: v0.1.22 - hooks: - - id: gofmt - - id: goimports - - repo: https://github.com/syntaqx/git-hooks - rev: v0.0.18 - hooks: - - id: go-test - args: [ "./..." ] - - id: go-mod-tidy - - id: go-generate - - repo: https://github.com/golangci/golangci-lint - rev: v1.54.2 - hooks: - - id: golangci-lint - - repo: https://github.com/bridgecrewio/checkov - rev: 2.4.48 - hooks: - - id: checkov - language_version: python3.10 - args: ["-d", "."] - - repo: local - hooks: - - id: ghat-go - name: ghat - description: upgrade action dependencies - language: golang - entry: ghat swot -d . --continue-on-error true - pass_filenames: false - always_run: true - types: [ yaml ] - - repo: https://github.com/dnephin/pre-commit-golang - rev: v0.5.1 - hooks: - - id: validate-toml - - id: no-go-testing - - id: go-mod-tidy + - hooks: + - id: check-json + - id: check-merge-conflict + - id: trailing-whitespace + - id: end-of-file-fixer + - exclude: examples/ + id: check-yaml + - id: check-added-large-files + - args: + - --autofix + id: pretty-format-json + - id: detect-aws-credentials + - id: detect-private-key + repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + - hooks: + - exclude: binary|\.bin$|rego|\.rego$|go|\.go$ + exclude_types: + - python + - javascript + - dtd + - markdown + - makefile + - xml + id: forbid-tabs + repo: https://github.com/Lucas-C/pre-commit-hooks + rev: v1.5.4 + - hooks: + - id: shell-lint + repo: https://github.com/jameswoolfenden/pre-commit-shell + rev: 0.0.2 + - hooks: + - exclude: src/testdata|testdata + id: markdownlint + repo: https://github.com/igorshubovych/markdownlint-cli + rev: v0.37.0 + - hooks: + - id: terraform-fmt + language_version: python3.11 + repo: https://github.com/jameswoolfenden/pre-commit + rev: v0.1.50 + - hooks: + - id: gofmt + - id: goimports + repo: https://github.com/gruntwork-io/pre-commit + rev: v0.1.22 + - hooks: + - args: + - ./... + id: go-test + - id: go-mod-tidy + - id: go-generate + repo: https://github.com/syntaqx/git-hooks + rev: v0.0.18 + - hooks: + - id: golangci-lint + repo: https://github.com/golangci/golangci-lint + rev: v1.54.2 + - hooks: + - args: + - -d + - . + id: checkov + language_version: python3.11 + repo: https://github.com/bridgecrewio/checkov + rev: 2.4.52 + - hooks: + - always_run: true + description: upgrade action dependencies + entry: ghat swot -d . --continue-on-error true + id: ghat-go + language: golang + name: ghat + pass_filenames: false + types: + - yaml + - always_run: true + description: upgrade action dependencies + entry: ghat sift -d . + id: ghat-go-sift + language: golang + name: sift + pass_filenames: false + types: + - yaml + repo: local + - hooks: + - id: validate-toml + - id: no-go-testing + - id: go-mod-tidy + repo: https://github.com/dnephin/pre-commit-golang + rev: v0.5.1 diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index 23bbc05..4dd6120 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -9,6 +9,14 @@ pass_filenames: false types: [ yaml ] +- id: ghat-go-sift + name: sift + description: upgrade precommit dependencies + language: golang + entry: ghat sift -d . + pass_filenames: false + types: [ yaml ] + # Build and run `ghat-docs` assuming it was installed manually # or via package manager # REQUIRES: ghat-docs to be installed and on the $PATH @@ -20,6 +28,14 @@ pass_filenames: false types: [ yaml ] +- id: ghat-system-sift + name: sift + description: upgrade pre-commit dependencies + language: system + entry: ghat sift -d . + pass_filenames: false + types: [ yaml ] + # Builds and runs the Docker image from the repo # REQUIRES: Docker installed - id: ghat-docker @@ -29,3 +45,11 @@ entry: ghat swot -d . pass_filenames: false types: [ yaml ] + +- id: ghat-docker-sift + name: sift + description: upgrade pre-commit dependencies (via Docker build) + language: docker + entry: ghat sift -d . + pass_filenames: false + types: [ yaml ] diff --git a/Makefile b/Makefile index bca9783..9aacff2 100644 --- a/Makefile +++ b/Makefile @@ -67,7 +67,6 @@ psbump: update: go get -u go mod tidy - pre-commit autoupdate lint: golangci-lint run --fix diff --git a/go.mod b/go.mod index 5934dfa..e9b3287 100644 --- a/go.mod +++ b/go.mod @@ -5,11 +5,12 @@ go 1.21 require ( github.com/go-git/go-git/v5 v5.9.0 github.com/hashicorp/hcl/v2 v2.18.0 - github.com/rs/zerolog v1.30.0 + github.com/rs/zerolog v1.31.0 github.com/sergi/go-diff v1.3.1 github.com/urfave/cli/v2 v2.25.7 github.com/zclconf/go-cty v1.14.0 golang.org/x/mod v0.12.0 + gopkg.in/yaml.v3 v3.0.1 moul.io/banner v1.0.1 ) diff --git a/go.sum b/go.sum index a05a663..5538dad 100644 --- a/go.sum +++ b/go.sum @@ -64,10 +64,8 @@ github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0 github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/matryer/is v1.2.0 h1:92UTHpy8CDwaJ08GqLDzhhuixiBUUD1p3AU6PHddz4A= github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA= -github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= -github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= @@ -84,8 +82,8 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= -github.com/rs/zerolog v1.30.0 h1:SymVODrcRsaRaSInD9yQtKbtWqwsfoPcRff/oRXLj4c= -github.com/rs/zerolog v1.30.0/go.mod h1:/tk+P47gFdPXq4QYjvCmT5/Gsug2nagsFWBWhAiSi1w= +github.com/rs/zerolog v1.31.0 h1:FcTR3NnLWW+NnTwwhFWiJSZr4ECLpqCm6QsEnyvbV4A= +github.com/rs/zerolog v1.31.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= @@ -138,8 +136,6 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= diff --git a/main.go b/main.go index a43d077..ddeb5c5 100644 --- a/main.go +++ b/main.go @@ -139,6 +139,38 @@ func main() { }, }, }, + { + Name: "sift", + Aliases: []string{"p"}, + Usage: "updates pre-commit version with hashes", + UsageText: "ghat sift", + Action: func(*cli.Context) error { + return myFlags.Action("sift") + }, + Flags: []cli.Flag{ + &cli.StringFlag{ + Name: "directory", + Aliases: []string{"d"}, + Usage: "Destination to update modules", + Destination: &myFlags.Directory, + Category: "files", + }, + &cli.BoolFlag{ + Name: "dry-run", + Usage: "show but don't write changes", + Destination: &myFlags.DryRun, + Value: false, + }, + &cli.StringFlag{ + Name: "token", + Aliases: []string{"t"}, + Usage: "Github PAT token", + Destination: &myFlags.GitHubToken, + Category: "authentication", + EnvVars: []string{"GITHUB_TOKEN", "GITHUB_API"}, + }, + }, + }, }, Name: "ghat", Usage: "Update GHA dependencies", diff --git a/src/core/action.go b/src/core/action.go index 4118542..7ff8dfc 100644 --- a/src/core/action.go +++ b/src/core/action.go @@ -41,6 +41,10 @@ func (myFlags *Flags) Action(Action string) error { return myFlags.UpdateGHAS() } } + case "sift": + { + return myFlags.UpdateHooks() + } } return nil diff --git a/src/core/pre-commit.go b/src/core/pre-commit.go new file mode 100644 index 0000000..82c1348 --- /dev/null +++ b/src/core/pre-commit.go @@ -0,0 +1,77 @@ +package core + +import ( + "fmt" + "os" + "path/filepath" + "strings" + + "github.com/rs/zerolog/log" + "gopkg.in/yaml.v3" +) + +func (myFlags *Flags) UpdateHooks() error { + var config *string + var err error + + if config, err = myFlags.GetHook(); err != nil { + return err + } + + data, _ := os.ReadFile(*config) + m := make(map[string]interface{}) + + err = yaml.Unmarshal(data, &m) + var newRepos []interface{} + + for _, item := range m["repos"].([]interface{}) { + newItem := item.(map[string]interface{}) + action := strings.Replace(newItem["repo"].(string), "https://github.com/", "", 1) + tag, err := GetLatestTag(action, myFlags.GitHubToken) + + if err != nil { + log.Info().Msgf("failed to find %s", newItem["repo"].(string)) + //i dont want to delete hook + newRepos = append(newRepos, item) + continue + } + + myTag := tag.(map[string]interface{}) + commit := myTag["commit"].(map[string]interface{}) + newItem["rev"] = commit["sha"].(string) //+ " #" + myTag["name"].(string) + + newRepos = append(newRepos, newItem) + } + + m["repos"] = newRepos + data, err = yaml.Marshal(&m) + err = os.WriteFile(*config, data, 0666) + if err != nil { + log.Info().Msgf("failed to write %s", *config) + return err + } + + fmt.Printf("updated %s", *config) + return nil +} + +func (myFlags *Flags) GetHook() (*string, error) { + var err error + myFlags.Directory, err = filepath.Abs(myFlags.Directory) + + fileInfo, err := os.Stat(myFlags.Directory) + if err != nil { + return nil, fmt.Errorf("please specify a valid directory: %s", myFlags.Directory) + } + + if !fileInfo.IsDir() { + return nil, fmt.Errorf("please specify a directory") + } + + config := filepath.Join(myFlags.Directory, ".pre-commit-config.yaml") + if _, err = os.Stat(config); err != nil { + return nil, fmt.Errorf("pre-commit config not found %s", config) + } + + return &config, nil +} diff --git a/src/core/pre-commit_test.go b/src/core/pre-commit_test.go new file mode 100644 index 0000000..66b24e4 --- /dev/null +++ b/src/core/pre-commit_test.go @@ -0,0 +1,49 @@ +package core + +import "testing" + +func TestFlags_UpdateHooks(t *testing.T) { + t.Parallel() + type fields struct { + File string + Directory string + GitHubToken string + Days int + DryRun bool + Entries []string + Update bool + ContinueOnError bool + } + + tests := []struct { + name string + fields fields + wantErr bool + }{ + {name: "Empty", fields: fields{GitHubToken: gitHubToken}, wantErr: true}, + {name: "guff", fields: fields{Directory: "guff", GitHubToken: gitHubToken}, wantErr: true}, + {name: "Pass relative", fields: fields{Directory: "../../", GitHubToken: gitHubToken}, wantErr: false}, + //{name: "Pass absolute", fields: fields{Directory: "E:/Code/pike", GitHubToken: gitHubToken}, wantErr: false}, + {name: "Pass absolute", fields: fields{Directory: "E:/Code/pike", GitHubToken: gitHubToken}, wantErr: false}, + } + + for _, tt := range tests { + tt := tt + t.Run(tt.name, func(t *testing.T) { + t.Parallel() + myFlags := &Flags{ + File: tt.fields.File, + Directory: tt.fields.Directory, + GitHubToken: tt.fields.GitHubToken, + Days: tt.fields.Days, + DryRun: tt.fields.DryRun, + Entries: tt.fields.Entries, + Update: tt.fields.Update, + ContinueOnError: tt.fields.ContinueOnError, + } + if err := myFlags.UpdateHooks(); (err != nil) != tt.wantErr { + t.Errorf("UpdateHooks() error = %v, wantErr %v", err, tt.wantErr) + } + }) + } +} From 901045b73e704af4b4188005619ffc0f9b669154 Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Thu, 28 Sep 2023 09:34:19 +0100 Subject: [PATCH 51/80] introducting sift --- .pre-commit-config.yaml | 62 ++++++++++++++-------------- src/core/action_test.go | 8 +++- src/core/pre-commit.go | 82 ++++++++++++++++++++++++++++++------- src/core/pre-commit_test.go | 1 - 4 files changed, 104 insertions(+), 49 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c0bf71f..d2defdc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,18 +6,19 @@ repos: - id: check-merge-conflict - id: trailing-whitespace - id: end-of-file-fixer - - exclude: examples/ - id: check-yaml + - id: check-yaml + exclude: examples/ - id: check-added-large-files - - args: + - id: pretty-format-json + args: - --autofix - id: pretty-format-json - id: detect-aws-credentials - id: detect-private-key repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: f71fa2c1f9cf5cb705f73dffe4b21f7c61470ba9 - hooks: - - exclude: binary|\.bin$|rego|\.rego$|go|\.go$ + - id: forbid-tabs + exclude: binary|\.bin$|rego|\.rego$|go|\.go$ exclude_types: - python - javascript @@ -25,71 +26,68 @@ repos: - markdown - makefile - xml - id: forbid-tabs repo: https://github.com/Lucas-C/pre-commit-hooks - rev: v1.5.4 + rev: 762c66ea96843b54b936fc680162ea67f85ec2d7 - hooks: - id: shell-lint repo: https://github.com/jameswoolfenden/pre-commit-shell - rev: 0.0.2 + rev: 062f0b028ae65827e04f91c1e6738cfcbe9b337f - hooks: - - exclude: src/testdata|testdata - id: markdownlint + - id: markdownlint + exclude: src/testdata|testdata repo: https://github.com/igorshubovych/markdownlint-cli - rev: v0.37.0 + rev: 3f18b949d53ffddafc6d98373366533d61e00da8 - hooks: - id: terraform-fmt language_version: python3.11 repo: https://github.com/jameswoolfenden/pre-commit - rev: v0.1.50 + rev: b00d945c0dce54f230a5d1cfb7d24e285396e1f2 - hooks: - id: gofmt - id: goimports repo: https://github.com/gruntwork-io/pre-commit - rev: v0.1.22 + rev: 62acdd0e6aaf398eb04af4a6fcd97a9f3f538668 - hooks: - - args: + - id: go-test + args: - ./... - id: go-test - id: go-mod-tidy - id: go-generate repo: https://github.com/syntaqx/git-hooks - rev: v0.0.18 + rev: a3b888f92cd5b40b270c9a9752181fdc1717cbe5 - hooks: - id: golangci-lint repo: https://github.com/golangci/golangci-lint - rev: v1.54.2 + rev: 411e0bbbd3096aa0ee2b924160629bdf2bc81d40 - hooks: - - args: + - id: checkov + language_version: python3.11 + args: - -d - . - id: checkov - language_version: python3.11 repo: https://github.com/bridgecrewio/checkov - rev: 2.4.52 + rev: 59cd4d3232b12be549cd7910ea6e3dee5b3b1e73 - hooks: - - always_run: true - description: upgrade action dependencies + - id: ghat-go + name: ghat entry: ghat swot -d . --continue-on-error true - id: ghat-go language: golang - name: ghat - pass_filenames: false types: - yaml - - always_run: true + always_run: true description: upgrade action dependencies + - id: ghat-go-sift + name: sift entry: ghat sift -d . - id: ghat-go-sift language: golang - name: sift - pass_filenames: false types: - yaml + always_run: true + description: upgrade action dependencies repo: local - hooks: - id: validate-toml - id: no-go-testing - id: go-mod-tidy repo: https://github.com/dnephin/pre-commit-golang - rev: v0.5.1 + rev: fb24a639f7c938759fe56eeebbb7713b69d60494 diff --git a/src/core/action_test.go b/src/core/action_test.go index 740efe9..374a7eb 100644 --- a/src/core/action_test.go +++ b/src/core/action_test.go @@ -1,11 +1,12 @@ package core import ( + "os" "testing" ) func TestFlags_Action(t *testing.T) { - + t.Parallel() type fields struct { File string Directory string @@ -28,6 +29,8 @@ func TestFlags_Action(t *testing.T) { file := fields{"testdata/files/module.tf", "testdata/files/", gitHubToken, 0, true, nil, true} noFile := fields{"testdata/files/guff.tf", "testdata/files/", gitHubToken, 0, true, nil, true} + os.Remove("testdata/empty") + tests := []struct { name string fields fields @@ -45,8 +48,11 @@ func TestFlags_Action(t *testing.T) { {"file swipe empty", dirDry, args{"swipe"}, false}, {"no file", noFile, args{"swipe"}, true}, } + for _, tt := range tests { + tt := tt t.Run(tt.name, func(t *testing.T) { + t.Parallel() myFlags := &Flags{ File: tt.fields.File, Directory: tt.fields.Directory, diff --git a/src/core/pre-commit.go b/src/core/pre-commit.go index 82c1348..be62a77 100644 --- a/src/core/pre-commit.go +++ b/src/core/pre-commit.go @@ -7,9 +7,45 @@ import ( "strings" "github.com/rs/zerolog/log" + "github.com/sergi/go-diff/diffmatchpatch" "gopkg.in/yaml.v3" ) +type Hook struct { + ID string `yaml:"id"` + Name string `yaml:"name,omitempty"` + Entry string `yaml:"entry,omitempty"` + Language string `yaml:"language,omitempty"` + Files string `yaml:"files,omitempty"` + Exclude string `yaml:"exclude,omitempty"` + Types []string `yaml:"types,omitempty"` + TypesOr []string `yaml:"types_or,omitempty"` + ExcludeTypes []string `yaml:"exclude_types,omitempty"` + AlwaysRun *bool `yaml:"always_run,omitempty"` + FailFast *bool `yaml:"fail_fast,omitempty"` + Verbose *bool `yaml:"verbose,omitempty"` + PassFilenames *bool `yaml:"pass_filenames,omitempty"` + RequireSerial *bool `yaml:"require_serial,omitempty"` + Description string `yaml:"description,omitempty"` + LanguageVersion string `yaml:"language_version,omitempty"` + MinimumPrecommitVersion string `yaml:"minimum_pre_commit_version,omitempty"` + Args []string `yaml:"args,omitempty"` + Stages []string `yaml:"stages,omitempty"` +} + +type Repo struct { + Hooks []Hook `yaml:"hooks"` + Repo string `yaml:"repo"` + Rev string `yaml:"rev,omitempty"` +} + +type ConfigFile struct { + DefaultLanguageVersion struct { + Python string `yaml:"python"` + } `yaml:"default_language_version"` + Repos []Repo `yaml:"repos"` +} + func (myFlags *Flags) UpdateHooks() error { var config *string var err error @@ -19,39 +55,55 @@ func (myFlags *Flags) UpdateHooks() error { } data, _ := os.ReadFile(*config) - m := make(map[string]interface{}) + + var m ConfigFile err = yaml.Unmarshal(data, &m) - var newRepos []interface{} - for _, item := range m["repos"].([]interface{}) { - newItem := item.(map[string]interface{}) - action := strings.Replace(newItem["repo"].(string), "https://github.com/", "", 1) + var newRepos []Repo + + for _, item := range m.Repos { + action := strings.Replace(item.Repo, "https://github.com/", "", 1) tag, err := GetLatestTag(action, myFlags.GitHubToken) if err != nil { - log.Info().Msgf("failed to find %s", newItem["repo"].(string)) - //i dont want to delete hook + log.Info().Msgf("failed to find %s", item.Repo) + // i dont want to delete hook newRepos = append(newRepos, item) continue } myTag := tag.(map[string]interface{}) + commit := myTag["commit"].(map[string]interface{}) - newItem["rev"] = commit["sha"].(string) //+ " #" + myTag["name"].(string) - newRepos = append(newRepos, newItem) + item.Rev = commit["sha"].(string) //+ " #" + myTag["name"].(string) + + newRepos = append(newRepos, item) } - m["repos"] = newRepos - data, err = yaml.Marshal(&m) - err = os.WriteFile(*config, data, 0666) + newConfigFile := m + newConfigFile.Repos = newRepos + + newData, err := yaml.Marshal(&newConfigFile) if err != nil { - log.Info().Msgf("failed to write %s", *config) - return err + return fmt.Errorf("failed to marshal mew config") + } + + dmp := diffmatchpatch.New() + diffs := dmp.DiffMain(string(data), string(newData), false) + + fmt.Println(dmp.DiffPrettyText(diffs)) + + if !myFlags.DryRun { + err = os.WriteFile(*config, newData, 0666) + if err != nil { + log.Info().Msgf("failed to write %s", *config) + + return err + } } - fmt.Printf("updated %s", *config) return nil } diff --git a/src/core/pre-commit_test.go b/src/core/pre-commit_test.go index 66b24e4..402f004 100644 --- a/src/core/pre-commit_test.go +++ b/src/core/pre-commit_test.go @@ -24,7 +24,6 @@ func TestFlags_UpdateHooks(t *testing.T) { {name: "guff", fields: fields{Directory: "guff", GitHubToken: gitHubToken}, wantErr: true}, {name: "Pass relative", fields: fields{Directory: "../../", GitHubToken: gitHubToken}, wantErr: false}, //{name: "Pass absolute", fields: fields{Directory: "E:/Code/pike", GitHubToken: gitHubToken}, wantErr: false}, - {name: "Pass absolute", fields: fields{Directory: "E:/Code/pike", GitHubToken: gitHubToken}, wantErr: false}, } for _, tt := range tests { From cc34f0d601df6ef2328f27fa83579b0054ddca3b Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Thu, 28 Sep 2023 17:41:15 +0100 Subject: [PATCH 52/80] sift --- README.md | 52 ++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index d9ac23e..2cb0903 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ [![Github All Releases](https://img.shields.io/github/downloads/jameswoolfenden/ghat/total.svg)](https://github.com/JamesWoolfenden/ghat/releases) [![codecov](https://codecov.io/gh/JamesWoolfenden/ghat/graph/badge.svg?token=P9V791WMRE)](https://codecov.io/gh/JamesWoolfenden/ghat) -Ghat is a tool (GHAT) for updating dependencies in a GHA - GitHub Action, and now also for updating and **managing Terraform Dependencies**. It replaces insecure mutable tags with immutable commit hashes as well as using the latest released version: +Ghat is a tool (GHAT) for updating dependencies in a GHA - GitHub Action, **managing Terraform Dependencies** and pre-commit configs. It replaces insecure mutable tags with immutable commit hashes as well as using the latest released version: ```yml ## sets up go based on the version @@ -72,10 +72,13 @@ module "ip" { - [Windows](#windows) - [Docker](#docker) - [Usage](#usage) - - [directory](#directory-scan) - - [file](#file-scan) - - [stable](#stable-releases) - - [pre-commit](#pre-commit) + - [swot](#swot) + - [directory](#directory-scan) + - [file](#file-scan) + - [stable](#stable-releases) + - [pre-commit](#pre-commit) + - [swipe](#swipe) + - [sift](#sift) @@ -134,7 +137,9 @@ docker run --tty --volume /local/path/to/repo:/repo jameswoolfenden/ghat swot -d To authenticate the GitHub Api you should set up your GitHub Personal Access Token as the environment variable *GITHUB_API* or *GITHUB_TOKEN*, it will fall back to using anonymous if you don't but RATE LIMITS. -### Directory scan +### swot + +#### Directory scan This will look for the .github/workflow folder and update all the files it finds there, and display a diff of the changes made to each file: @@ -142,13 +147,13 @@ This will look for the .github/workflow folder and update all the files it finds $ghat swot -d . ``` -### File scan +#### File scan ```bash $ghat swot -f .\.github\workflows\ci.yml ``` -### Stable releases +#### Stable releases If you're concerned that the very latest release might be too fresh, and would rather have the latest from 2 weeks ago? I got you covered: @@ -179,6 +184,32 @@ module "ip" { The update flag can be used to update the reference, the default behaviour is just to change the reference to a git bashed hash. +### sift + +Sift updates pre-commit configs with the latest hooks using hashes. +Commands are similar, but only the directory is needed: + +```shell +ghat sift -d . +``` + +The flag dryrun is also supported. Example outcome display: + +```yaml + - hooks: + - id: forbid-tabs + exclude: binary|\.bin$|rego|\.rego$|go|\.go$ + exclude_types: + - python + - javascript + - dtd + - markdown + - makefile + - xml + repo: https://github.com/Lucas-C/pre-commit-hooks + rev: 762c66ea96843b54b936fc680162ea67f85ec2d7 +``` + ## Help ```bash @@ -188,7 +219,7 @@ The update flag can be used to update the reference, the default behaviour is ju / _` || ' \ / _` || _| \__, ||_||_|\__,_| \__| |___/ -version: v0.0.19 +version: v0.1.1 NAME: ghat - Update GHA dependencies @@ -196,12 +227,13 @@ USAGE: ghat [global options] command [command options] [arguments...] VERSION: - v0.0.19 + v0.1.1 AUTHOR: James Woolfenden COMMANDS: + sift, p updates pre-commit version with hashes swipe, w updates Terraform module versions with versioned hashes swot, a updates GHA versions for hashes version, v Outputs the application version From 574e2dfad98841ea8a17521c1278ae550003e9f9 Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Sat, 30 Sep 2023 09:45:27 +0100 Subject: [PATCH 53/80] increase coverage --- .pre-commit-config.yaml | 2 +- .pre-commit-hooks.yaml | 2 +- src/core/action_test.go | 3 +- src/core/gha_test.go | 2 ++ src/core/modules.go | 17 +++++----- src/core/modules_test.go | 69 +++++++++++++++++++++++++++++++++++++++ src/core/pre-commit.go | 10 +++++- src/core/registry_test.go | 2 +- 8 files changed, 93 insertions(+), 14 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d2defdc..31ad341 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -66,7 +66,7 @@ repos: - -d - . repo: https://github.com/bridgecrewio/checkov - rev: 59cd4d3232b12be549cd7910ea6e3dee5b3b1e73 + rev: f93a812a46e8ef699409facf4370d5d6401ae587 - hooks: - id: ghat-go name: ghat diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index 4dd6120..8c871b9 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -11,7 +11,7 @@ - id: ghat-go-sift name: sift - description: upgrade precommit dependencies + description: upgrade pre-commit dependencies language: golang entry: ghat sift -d . pass_filenames: false diff --git a/src/core/action_test.go b/src/core/action_test.go index 374a7eb..4a73307 100644 --- a/src/core/action_test.go +++ b/src/core/action_test.go @@ -29,7 +29,7 @@ func TestFlags_Action(t *testing.T) { file := fields{"testdata/files/module.tf", "testdata/files/", gitHubToken, 0, true, nil, true} noFile := fields{"testdata/files/guff.tf", "testdata/files/", gitHubToken, 0, true, nil, true} - os.Remove("testdata/empty") + _ = os.Remove("testdata/empty") tests := []struct { name string @@ -47,6 +47,7 @@ func TestFlags_Action(t *testing.T) { {"file swot empty", dirDry, args{"swot"}, false}, {"file swipe empty", dirDry, args{"swipe"}, false}, {"no file", noFile, args{"swipe"}, true}, + {"sift", fields{Directory: "../../"}, args{"sift"}, false}, } for _, tt := range tests { diff --git a/src/core/gha_test.go b/src/core/gha_test.go index dc0d9ec..2a01d7a 100644 --- a/src/core/gha_test.go +++ b/src/core/gha_test.go @@ -302,6 +302,8 @@ func TestFlags_UpdateGHAS(t *testing.T) { }{ {"Pass file", fields{"./testdata/gha/.github/workflows/test.yml", "", gitHubToken, 0, true, []string{"./testdata/gha/.github/workflows/test.yml"}, true}, false}, + {"Pass file not dry", + fields{"./testdata/gha/.github/workflows/test.yml", "", gitHubToken, 0, false, []string{"./testdata/gha/.github/workflows/test.yml"}, true}, false}, {"Pass dir", fields{"", "./testdata/gha/.github/workflows", gitHubToken, 0, true, []string{"./testdata/gha/.github/workflows/test.yml"}, true}, false}, } diff --git a/src/core/modules.go b/src/core/modules.go index 0f50f83..598a46f 100644 --- a/src/core/modules.go +++ b/src/core/modules.go @@ -217,17 +217,8 @@ func (myFlags *Flags) UpdateSource(module string, moduleType string, version str switch moduleType { case "git": { - //var hash string newModule := strings.TrimPrefix(module, "git::") - //if strings.Contains(newModule, ",") { - // commas := strings.Split(newModule, ",") - // - // if len(commas) > 1 { - // log.Info().Msgf("too many URL params") - // //do something - // } - //} splitter := strings.Split(newModule, "?ref=") root := splitter[0] @@ -383,7 +374,15 @@ func (myFlags *Flags) UpdateGithubSource(version string, newModule string) (stri func (myFlags *Flags) GetGithubLatestHash(newModule string) (string, string, error) { name := strings.Split(newModule, "github.com/") + if len(name) < 2 { + return "", "", fmt.Errorf("modules string doesnt contain github.com") + } + action := strings.Split(name[1], ".git") + if len(action) < 2 { + return "", "", fmt.Errorf("modules string doesnt end in .git") + } + payload, err := GetLatestTag(action[0], myFlags.GitHubToken) if err != nil { diff --git a/src/core/modules_test.go b/src/core/modules_test.go index 555d11a..7d34e7b 100644 --- a/src/core/modules_test.go +++ b/src/core/modules_test.go @@ -230,3 +230,72 @@ func TestFlags_UpdateSource(t *testing.T) { }) } } + +func TestFlags_UpdateGithubSource(t *testing.T) { + t.Parallel() + type fields struct { + File string + Directory string + GitHubToken string + Days int + DryRun bool + Entries []string + Update bool + ContinueOnError bool + } + + type args struct { + version string + newModule string + } + + tests := []struct { + name string + fields fields + args args + want string + want1 string + wantErr bool + }{ + {"Pass update", fields{Update: true, GitHubToken: gitHubToken}, args{newModule: "github.com/jameswoolfenden/terraform-http-ip.git"}, + "git::https://github.com/jameswoolfenden/terraform-http-ip.git?ref=6e651695dc636de858961f36bc54ffe9e744e946", + "v0.3.13", false}, + {"Not action", fields{Update: true}, args{newModule: "github.com/jameswoolfenden/ip.git"}, "", "", true}, + {"Fail no .git", fields{Update: true}, args{newModule: "jameswoolfenden/ip"}, "", "", true}, + {"Fail too short", fields{Update: true}, args{newModule: "jameswoolfenden/ip"}, "", "", true}, + {"Pass", fields{Update: false, GitHubToken: gitHubToken}, args{newModule: "github.com/jameswoolfenden/terraform-http-ip.git"}, + "git::https://github.com/jameswoolfenden/terraform-http-ip.git?ref=6e651695dc636de858961f36bc54ffe9e744e946", + "v0.3.13", false}, + {"Pass with version", + fields{Update: false, GitHubToken: gitHubToken}, args{version: "81a0a7c", newModule: "github.com/jameswoolfenden/terraform-http-ip.git"}, + "git::https://github.com/jameswoolfenden/terraform-http-ip.git?ref=81a0a7c", + "81a0a7c", false}, + } + for _, tt := range tests { + tt := tt + t.Run(tt.name, func(t *testing.T) { + t.Parallel() + myFlags := &Flags{ + File: tt.fields.File, + Directory: tt.fields.Directory, + GitHubToken: tt.fields.GitHubToken, + Days: tt.fields.Days, + DryRun: tt.fields.DryRun, + Entries: tt.fields.Entries, + Update: tt.fields.Update, + ContinueOnError: tt.fields.ContinueOnError, + } + got, got1, err := myFlags.UpdateGithubSource(tt.args.version, tt.args.newModule) + if (err != nil) != tt.wantErr { + t.Errorf("UpdateGithubSource() error = %v, wantErr %v", err, tt.wantErr) + return + } + if got != tt.want { + t.Errorf("UpdateGithubSource() got = %v, want %v", got, tt.want) + } + if got1 != tt.want1 { + t.Errorf("UpdateGithubSource() got1 = %v, want %v", got1, tt.want1) + } + }) + } +} diff --git a/src/core/pre-commit.go b/src/core/pre-commit.go index be62a77..14c631c 100644 --- a/src/core/pre-commit.go +++ b/src/core/pre-commit.go @@ -60,6 +60,10 @@ func (myFlags *Flags) UpdateHooks() error { err = yaml.Unmarshal(data, &m) + if err != nil { + return fmt.Errorf("failed to unmarshall %s", *config) + } + var newRepos []Repo for _, item := range m.Repos { @@ -77,7 +81,7 @@ func (myFlags *Flags) UpdateHooks() error { commit := myTag["commit"].(map[string]interface{}) - item.Rev = commit["sha"].(string) //+ " #" + myTag["name"].(string) + item.Rev = commit["sha"].(string) // myTag["name"].(string) newRepos = append(newRepos, item) } @@ -111,6 +115,10 @@ func (myFlags *Flags) GetHook() (*string, error) { var err error myFlags.Directory, err = filepath.Abs(myFlags.Directory) + if err != nil { + return nil, fmt.Errorf("failed to make sense of directory %s", myFlags.Directory) + } + fileInfo, err := os.Stat(myFlags.Directory) if err != nil { return nil, fmt.Errorf("please specify a valid directory: %s", myFlags.Directory) diff --git a/src/core/registry_test.go b/src/core/registry_test.go index e4851a9..9eadce5 100644 --- a/src/core/registry_test.go +++ b/src/core/registry_test.go @@ -106,7 +106,7 @@ func TestRegistry_GetLatest(t *testing.T) { }{ {"Pass", fields{false, ""}, args{"jameswoolfenden/ip/http"}, &want, false}, {"Fail", fields{false, ""}, args{"jameswoolfenden/ip/guff"}, nil, true}, - {"norepo", fields{false, ""}, args{"jameswoolfenden/ip/guff"}, nil, true}, + {"No Repo", fields{false, ""}, args{"jameswoolfenden/ip/guff"}, nil, true}, } for _, tt := range tests { tt := tt From bd333cd9478e6da733c4ca4b7eb4713962fc01c8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 13 Oct 2023 22:52:56 +0000 Subject: [PATCH 54/80] Bump golang.org/x/net from 0.15.0 to 0.17.0 Bumps [golang.org/x/net](https://github.com/golang/net) from 0.15.0 to 0.17.0. - [Commits](https://github.com/golang/net/compare/v0.15.0...v0.17.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: indirect ... Signed-off-by: dependabot[bot] --- go.mod | 6 +++--- go.sum | 15 ++++++++------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/go.mod b/go.mod index e9b3287..3661a94 100644 --- a/go.mod +++ b/go.mod @@ -42,9 +42,9 @@ require ( github.com/stretchr/testify v1.8.4 // indirect github.com/xanzy/ssh-agent v0.3.3 // indirect github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect - golang.org/x/crypto v0.13.0 // indirect - golang.org/x/net v0.15.0 // indirect - golang.org/x/sys v0.12.0 // indirect + golang.org/x/crypto v0.14.0 // indirect + golang.org/x/net v0.17.0 // indirect + golang.org/x/sys v0.13.0 // indirect golang.org/x/text v0.13.0 // indirect golang.org/x/tools v0.13.0 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect diff --git a/go.sum b/go.sum index 5538dad..7d564bb 100644 --- a/go.sum +++ b/go.sum @@ -110,8 +110,8 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -golang.org/x/crypto v0.13.0 h1:mvySKfSWJ+UKUii46M40LOvyWfN0s2U+46/jDd0e6Ck= -golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= +golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= +golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= @@ -123,8 +123,8 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= -golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8= -golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= +golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= +golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -144,15 +144,16 @@ golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= +golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= -golang.org/x/term v0.12.0 h1:/ZfYdc3zq+q02Rv9vGqTeSItdzZTSNDmfTi0mBAuidU= -golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= +golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek= +golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= From 8f3ec57a74249fd1bcf397a089abb98b9cf2d010 Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Wed, 25 Oct 2023 09:20:09 +0100 Subject: [PATCH 55/80] refresh --- .github/workflows/ci.yml | 2 +- .github/workflows/codeql-analysis.yml | 8 ++--- .github/workflows/pr.yml | 6 ++-- .github/workflows/release.yml | 6 ++-- .pre-commit-config.yaml | 6 ++-- Makefile | 1 + go.mod | 16 ++++----- go.sum | 34 ++++++++++--------- src/core/gha_test.go | 4 +-- src/core/modules_test.go | 9 ++--- src/core/registry_test.go | 2 +- .../testdata/gha/.github/workflows/test.yml | 2 +- 12 files changed, 50 insertions(+), 46 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d4bacb1..f4a10ed 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,7 +31,7 @@ jobs: ## checks out our code locally, so we can work with the files - name: Checkout code - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 ## runs go test ./... - name: Build diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 915c896..9f3e259 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -39,11 +39,11 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@8e0b1c74b1d5a0077b04d064c76ee714d3da7637 # codeql-bundle-v2.14.6 + uses: github/codeql-action/init@bad341350a2f5616f9e048e51360cedc49181ce8 # codeql-bundle-v2.15.1 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -53,7 +53,7 @@ jobs: # 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@8e0b1c74b1d5a0077b04d064c76ee714d3da7637 # codeql-bundle-v2.14.6 + uses: github/codeql-action/autobuild@bad341350a2f5616f9e048e51360cedc49181ce8 # codeql-bundle-v2.15.1 # â„šī¸ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun @@ -66,4 +66,4 @@ jobs: # ./location_of_script_within_repo/buildscript.sh - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@8e0b1c74b1d5a0077b04d064c76ee714d3da7637 # codeql-bundle-v2.14.6 + uses: github/codeql-action/analyze@bad341350a2f5616f9e048e51360cedc49181ce8 # codeql-bundle-v2.15.1 diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 33d0d43..bac8572 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - name: Install Go uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0 with: @@ -30,7 +30,7 @@ jobs: runs-on: ${{ matrix.platform }} steps: - name: Checkout code - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - name: Install Go uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0 with: @@ -48,7 +48,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - name: Install Go uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4f10773..d8e286a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - name: Unshallow run: git fetch --prune --unshallow - name: Set up Go @@ -41,9 +41,9 @@ jobs: needs: - goreleaser steps: - - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - name: Publish to Registry - uses: elgohr/Publish-Docker-Github-Action@219613003b08f4d049f34cb56c92e84345e1bb3f # v5 + uses: elgohr/Publish-Docker-Github-Action@82556589c08f584cb95411629a94e6c2b68b9b80 # v5 with: name: jameswoolfenden/ghat username: ${{ secrets.DOCKERHUB_USERNAME }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 31ad341..01b32d1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,7 +15,7 @@ repos: - id: detect-aws-credentials - id: detect-private-key repo: https://github.com/pre-commit/pre-commit-hooks - rev: f71fa2c1f9cf5cb705f73dffe4b21f7c61470ba9 + rev: c4a0b883114b00d8d76b479c820ce7950211c99b - hooks: - id: forbid-tabs exclude: binary|\.bin$|rego|\.rego$|go|\.go$ @@ -58,7 +58,7 @@ repos: - hooks: - id: golangci-lint repo: https://github.com/golangci/golangci-lint - rev: 411e0bbbd3096aa0ee2b924160629bdf2bc81d40 + rev: de1c391922f0e3792c862f7e8c653bbf3f198d16 - hooks: - id: checkov language_version: python3.11 @@ -66,7 +66,7 @@ repos: - -d - . repo: https://github.com/bridgecrewio/checkov - rev: f93a812a46e8ef699409facf4370d5d6401ae587 + rev: 3.0.4 - hooks: - id: ghat-go name: ghat diff --git a/Makefile b/Makefile index 9aacff2..bca9783 100644 --- a/Makefile +++ b/Makefile @@ -67,6 +67,7 @@ psbump: update: go get -u go mod tidy + pre-commit autoupdate lint: golangci-lint run --fix diff --git a/go.mod b/go.mod index 3661a94..5755a3c 100644 --- a/go.mod +++ b/go.mod @@ -4,12 +4,12 @@ go 1.21 require ( github.com/go-git/go-git/v5 v5.9.0 - github.com/hashicorp/hcl/v2 v2.18.0 + github.com/hashicorp/hcl/v2 v2.19.1 github.com/rs/zerolog v1.31.0 github.com/sergi/go-diff v1.3.1 github.com/urfave/cli/v2 v2.25.7 - github.com/zclconf/go-cty v1.14.0 - golang.org/x/mod v0.12.0 + github.com/zclconf/go-cty v1.14.1 + golang.org/x/mod v0.13.0 gopkg.in/yaml.v3 v3.0.1 moul.io/banner v1.0.1 ) @@ -21,20 +21,20 @@ require ( github.com/acomagu/bufpipe v1.0.4 // indirect github.com/agext/levenshtein v1.2.3 // indirect github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect - github.com/cloudflare/circl v1.3.3 // indirect - github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect + github.com/cloudflare/circl v1.3.5 // indirect + github.com/cpuguy83/go-md2man/v2 v2.0.3 // indirect github.com/cyphar/filepath-securejoin v0.2.4 // indirect github.com/emirpasic/gods v1.18.1 // indirect github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect github.com/go-git/go-billy/v5 v5.5.0 // indirect github.com/go-test/deep v1.1.0 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect - github.com/google/go-cmp v0.5.9 // indirect + github.com/google/go-cmp v0.6.0 // indirect github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect github.com/kevinburke/ssh_config v1.2.0 // indirect github.com/kylelemons/godebug v1.1.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.19 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect github.com/mitchellh/go-wordwrap v1.0.1 // indirect github.com/pjbgf/sha1cd v0.3.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect @@ -46,6 +46,6 @@ require ( golang.org/x/net v0.17.0 // indirect golang.org/x/sys v0.13.0 // indirect golang.org/x/text v0.13.0 // indirect - golang.org/x/tools v0.13.0 // indirect + golang.org/x/tools v0.14.0 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect ) diff --git a/go.sum b/go.sum index 7d564bb..f5b85c0 100644 --- a/go.sum +++ b/go.sum @@ -16,11 +16,12 @@ github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmms github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= -github.com/cloudflare/circl v1.3.3 h1:fE/Qz0QdIGqeWfnwq0RE0R7MI51s0M2E4Ga9kq5AEMs= github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= +github.com/cloudflare/circl v1.3.5 h1:g+wWynZqVALYAlpSQFAa7TscDnUK8mKYtrxMpw6AUKo= +github.com/cloudflare/circl v1.3.5/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= -github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= -github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/cpuguy83/go-md2man/v2 v2.0.3 h1:qMCsGGgs+MAzDFyp9LpAe1Lqy/fY/qCovCm0qnXZOBM= +github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg= github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -45,10 +46,10 @@ github.com/go-test/deep v1.1.0/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncV github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/hashicorp/hcl/v2 v2.18.0 h1:wYnG7Lt31t2zYkcquwgKo6MWXzRUDIeIVU5naZwHLl8= -github.com/hashicorp/hcl/v2 v2.18.0/go.mod h1:ThLC89FV4p9MPW804KVbe/cEXoQ8NZEh+JtMeeGErHE= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/hashicorp/hcl/v2 v2.19.1 h1://i05Jqznmb2EXqa39Nsvyan2o5XyMowW5fnCKW5RPI= +github.com/hashicorp/hcl/v2 v2.19.1/go.mod h1:ThLC89FV4p9MPW804KVbe/cEXoQ8NZEh+JtMeeGErHE= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= @@ -67,8 +68,9 @@ github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlW github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= @@ -103,8 +105,8 @@ github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -github.com/zclconf/go-cty v1.14.0 h1:/Xrd39K7DXbHzlisFP9c4pHao4yyf+/Ug9LEz+Y/yhc= -github.com/zclconf/go-cty v1.14.0/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= +github.com/zclconf/go-cty v1.14.1 h1:t9fyA35fwjjUMcmL5hLER+e/rEPqrbCK1/OSE4SI9KA= +github.com/zclconf/go-cty v1.14.1/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= @@ -114,8 +116,8 @@ golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= -golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.13.0 h1:I/DsJXRlw/8l/0c24sM9yb0T4z9liZTduXvdAWYiysY= +golang.org/x/mod v0.13.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= @@ -128,8 +130,8 @@ golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= -golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= +golang.org/x/sync v0.4.0 h1:zxkM55ReGkDlKSM+Fu41A+zmbZuaPVbGMzvvdUPznYQ= +golang.org/x/sync v0.4.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -167,8 +169,8 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ= -golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= +golang.org/x/tools v0.14.0 h1:jvNa2pY0M4r62jkRQ6RwEZZyPcymeL9XZMLBbV7U2nc= +golang.org/x/tools v0.14.0/go.mod h1:uYBEerGOWcJyEORxN+Ek8+TT266gXkNlHdJBwexUsBg= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/src/core/gha_test.go b/src/core/gha_test.go index 2a01d7a..58035af 100644 --- a/src/core/gha_test.go +++ b/src/core/gha_test.go @@ -92,9 +92,9 @@ func Test_getHash(t *testing.T) { want := map[string]interface{}{ "node_id": "MDM6UmVmMTk3ODE0NjI5OnJlZnMvdGFncy92NC4wLjA=", "object": map[string]interface{}{ - "sha": "3df4ab11eba7bda6032a0b82a6bb43b11571feac", + "sha": "1e31de5234b9f8995739874a8ce0492dc87873e2", "type": "commit", - "url": "https://api.github.com/repos/actions/checkout/git/commits/3df4ab11eba7bda6032a0b82a6bb43b11571feac", + "url": "https://api.github.com/repos/actions/checkout/git/commits/1e31de5234b9f8995739874a8ce0492dc87873e2", }, "ref": "refs/tags/v4.0.0", "url": "https://api.github.com/repos/actions/checkout/git/refs/tags/v4.0.0", diff --git a/src/core/modules_test.go b/src/core/modules_test.go index 7d34e7b..7a3c1ed 100644 --- a/src/core/modules_test.go +++ b/src/core/modules_test.go @@ -258,19 +258,20 @@ func TestFlags_UpdateGithubSource(t *testing.T) { wantErr bool }{ {"Pass update", fields{Update: true, GitHubToken: gitHubToken}, args{newModule: "github.com/jameswoolfenden/terraform-http-ip.git"}, - "git::https://github.com/jameswoolfenden/terraform-http-ip.git?ref=6e651695dc636de858961f36bc54ffe9e744e946", - "v0.3.13", false}, + "git::https://github.com/jameswoolfenden/terraform-http-ip.git?ref=2f3cef24e667fb840a3d3481f5a1aaa5a1ac7d28", + "v0.3.14", false}, {"Not action", fields{Update: true}, args{newModule: "github.com/jameswoolfenden/ip.git"}, "", "", true}, {"Fail no .git", fields{Update: true}, args{newModule: "jameswoolfenden/ip"}, "", "", true}, {"Fail too short", fields{Update: true}, args{newModule: "jameswoolfenden/ip"}, "", "", true}, {"Pass", fields{Update: false, GitHubToken: gitHubToken}, args{newModule: "github.com/jameswoolfenden/terraform-http-ip.git"}, - "git::https://github.com/jameswoolfenden/terraform-http-ip.git?ref=6e651695dc636de858961f36bc54ffe9e744e946", - "v0.3.13", false}, + "git::https://github.com/jameswoolfenden/terraform-http-ip.git?ref=2f3cef24e667fb840a3d3481f5a1aaa5a1ac7d28", + "v0.3.14", false}, {"Pass with version", fields{Update: false, GitHubToken: gitHubToken}, args{version: "81a0a7c", newModule: "github.com/jameswoolfenden/terraform-http-ip.git"}, "git::https://github.com/jameswoolfenden/terraform-http-ip.git?ref=81a0a7c", "81a0a7c", false}, } + for _, tt := range tests { tt := tt t.Run(tt.name, func(t *testing.T) { diff --git a/src/core/registry_test.go b/src/core/registry_test.go index 9eadce5..3b66e83 100644 --- a/src/core/registry_test.go +++ b/src/core/registry_test.go @@ -95,7 +95,7 @@ func TestRegistry_GetLatest(t *testing.T) { module string } - want := "0.3.13" + want := "0.3.14" tests := []struct { name string diff --git a/src/core/testdata/gha/.github/workflows/test.yml b/src/core/testdata/gha/.github/workflows/test.yml index d835054..5b03d0e 100644 --- a/src/core/testdata/gha/.github/workflows/test.yml +++ b/src/core/testdata/gha/.github/workflows/test.yml @@ -31,7 +31,7 @@ jobs: ## checks out our code locally, so we can work with the files - name: Checkout code - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 ## runs go test ./... - name: Build From 6a106d4151eceebb65019a7b1166df994e91cd20 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 31 Dec 2023 11:55:50 +0000 Subject: [PATCH 56/80] Bump golang.org/x/crypto from 0.14.0 to 0.17.0 Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.14.0 to 0.17.0. - [Commits](https://github.com/golang/crypto/compare/v0.14.0...v0.17.0) --- updated-dependencies: - dependency-name: golang.org/x/crypto dependency-type: indirect ... Signed-off-by: dependabot[bot] --- go.mod | 6 +++--- go.sum | 16 ++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/go.mod b/go.mod index 5755a3c..f1717a4 100644 --- a/go.mod +++ b/go.mod @@ -42,10 +42,10 @@ require ( github.com/stretchr/testify v1.8.4 // indirect github.com/xanzy/ssh-agent v0.3.3 // indirect github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect - golang.org/x/crypto v0.14.0 // indirect + golang.org/x/crypto v0.17.0 // indirect golang.org/x/net v0.17.0 // indirect - golang.org/x/sys v0.13.0 // indirect - golang.org/x/text v0.13.0 // indirect + golang.org/x/sys v0.15.0 // indirect + golang.org/x/text v0.14.0 // indirect golang.org/x/tools v0.14.0 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect ) diff --git a/go.sum b/go.sum index f5b85c0..ba881be 100644 --- a/go.sum +++ b/go.sum @@ -112,8 +112,8 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= -golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.13.0 h1:I/DsJXRlw/8l/0c24sM9yb0T4z9liZTduXvdAWYiysY= @@ -147,15 +147,15 @@ golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= -golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= +golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= -golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek= -golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= +golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4= +golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= @@ -163,8 +163,8 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= -golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= From 7764a9dc1cd6cb34c9992cd82cd1ffdb55caf1f1 Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Tue, 9 Jan 2024 16:53:46 +0000 Subject: [PATCH 57/80] refreshed --- .github/workflows/ci.yml | 2 +- .github/workflows/codeql-analysis.yml | 6 +-- .github/workflows/pr.yml | 6 +-- .github/workflows/release.yml | 4 +- .github/workflows/stale.yml | 2 +- .pre-commit-config.yaml | 8 +-- go.mod | 20 ++++--- go.sum | 52 +++++++++---------- .../testdata/gha/.github/workflows/test.yml | 2 +- 9 files changed, 48 insertions(+), 54 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f4a10ed..3252ba8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ jobs: steps: ## sets up go based on the version - name: Install Go - uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0 + uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 with: go-version: ${{ matrix.go-version }} diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 9f3e259..22a1bea 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -43,7 +43,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@bad341350a2f5616f9e048e51360cedc49181ce8 # codeql-bundle-v2.15.1 + uses: github/codeql-action/init@7e187e1c529d80bac7b87a16e7a792427f65cf02 # codeql-bundle-v2.15.5 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -53,7 +53,7 @@ jobs: # 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@bad341350a2f5616f9e048e51360cedc49181ce8 # codeql-bundle-v2.15.1 + uses: github/codeql-action/autobuild@7e187e1c529d80bac7b87a16e7a792427f65cf02 # codeql-bundle-v2.15.5 # â„šī¸ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun @@ -66,4 +66,4 @@ jobs: # ./location_of_script_within_repo/buildscript.sh - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@bad341350a2f5616f9e048e51360cedc49181ce8 # codeql-bundle-v2.15.1 + uses: github/codeql-action/analyze@7e187e1c529d80bac7b87a16e7a792427f65cf02 # codeql-bundle-v2.15.5 diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index bac8572..aa74ac1 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -10,7 +10,7 @@ jobs: - name: Checkout code uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - name: Install Go - uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0 + uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 with: go-version: 1.21.x - name: Restore cache @@ -32,7 +32,7 @@ jobs: - name: Checkout code uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - name: Install Go - uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0 + uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 with: go-version: ${{ matrix.go-version }} - name: Restore cache @@ -50,6 +50,6 @@ jobs: - name: Checkout code uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - name: Install Go - uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0 + uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 with: go-version: 1.21.x diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d8e286a..85a167f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,12 +15,12 @@ jobs: - name: Unshallow run: git fetch --prune --unshallow - name: Set up Go - uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0 + uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 with: go-version: 1.21 - name: Import GPG key id: import_gpg - uses: crazy-max/ghaction-import-gpg@82a020f1f7f605c65dd2449b392a52c3fcfef7ef # v6.0.0 + uses: crazy-max/ghaction-import-gpg@01dd5d3ca463c7f10f7f4f7b4f177225ac661ee4 # v6.1.0 with: gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} passphrase: ${{ secrets.PASSPHRASE }} diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index d75d877..1481a9d 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -13,7 +13,7 @@ jobs: pull-requests: write runs-on: ubuntu-latest steps: - - uses: actions/stale@1160a2240286f5da8ec72b1c0816ce2481aabf84 # v8.0.0 + - uses: actions/stale@28ca1036281a5e5922ead5184a1bbf96e5fc984e # v9.0.0 with: stale-issue-message: 'This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.' days-before-stale: 30 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 01b32d1..a968380 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -36,7 +36,7 @@ repos: - id: markdownlint exclude: src/testdata|testdata repo: https://github.com/igorshubovych/markdownlint-cli - rev: 3f18b949d53ffddafc6d98373366533d61e00da8 + rev: 1d2f2483dbca436b5e89d208f1ff56688ba4af9e - hooks: - id: terraform-fmt language_version: python3.11 @@ -46,7 +46,7 @@ repos: - id: gofmt - id: goimports repo: https://github.com/gruntwork-io/pre-commit - rev: 62acdd0e6aaf398eb04af4a6fcd97a9f3f538668 + rev: d0bcdb35c6999a4a120b528f050d2b11778fd3d0 - hooks: - id: go-test args: @@ -58,7 +58,7 @@ repos: - hooks: - id: golangci-lint repo: https://github.com/golangci/golangci-lint - rev: de1c391922f0e3792c862f7e8c653bbf3f198d16 + rev: e3c2265f4939976874989e159386b3bb7dcf8e1f - hooks: - id: checkov language_version: python3.11 @@ -66,7 +66,7 @@ repos: - -d - . repo: https://github.com/bridgecrewio/checkov - rev: 3.0.4 + rev: 4f6c8f08e2b5395c37738d89ef6e099fa8667648 - hooks: - id: ghat-go name: ghat diff --git a/go.mod b/go.mod index f1717a4..81150ae 100644 --- a/go.mod +++ b/go.mod @@ -3,13 +3,13 @@ module ghat go 1.21 require ( - github.com/go-git/go-git/v5 v5.9.0 + github.com/go-git/go-git/v5 v5.11.0 github.com/hashicorp/hcl/v2 v2.19.1 github.com/rs/zerolog v1.31.0 github.com/sergi/go-diff v1.3.1 - github.com/urfave/cli/v2 v2.25.7 + github.com/urfave/cli/v2 v2.27.1 github.com/zclconf/go-cty v1.14.1 - golang.org/x/mod v0.13.0 + golang.org/x/mod v0.14.0 gopkg.in/yaml.v3 v3.0.1 moul.io/banner v1.0.1 ) @@ -18,10 +18,9 @@ require ( dario.cat/mergo v1.0.0 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect github.com/ProtonMail/go-crypto v0.0.0-20230923063757-afb1ddc0824c // indirect - github.com/acomagu/bufpipe v1.0.4 // indirect github.com/agext/levenshtein v1.2.3 // indirect github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect - github.com/cloudflare/circl v1.3.5 // indirect + github.com/cloudflare/circl v1.3.7 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.3 // indirect github.com/cyphar/filepath-securejoin v0.2.4 // indirect github.com/emirpasic/gods v1.18.1 // indirect @@ -39,13 +38,12 @@ require ( github.com/pjbgf/sha1cd v0.3.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/skeema/knownhosts v1.2.1 // indirect - github.com/stretchr/testify v1.8.4 // indirect github.com/xanzy/ssh-agent v0.3.3 // indirect - github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect - golang.org/x/crypto v0.17.0 // indirect - golang.org/x/net v0.17.0 // indirect - golang.org/x/sys v0.15.0 // indirect + github.com/xrash/smetrics v0.0.0-20231213231151-1d8dd44e695e // indirect + golang.org/x/crypto v0.18.0 // indirect + golang.org/x/net v0.20.0 // indirect + golang.org/x/sys v0.16.0 // indirect golang.org/x/text v0.14.0 // indirect - golang.org/x/tools v0.14.0 // indirect + golang.org/x/tools v0.16.1 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect ) diff --git a/go.sum b/go.sum index ba881be..43d5f49 100644 --- a/go.sum +++ b/go.sum @@ -5,8 +5,6 @@ github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migc github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= github.com/ProtonMail/go-crypto v0.0.0-20230923063757-afb1ddc0824c h1:kMFnB0vCcX7IL/m9Y5LO+KQYv+t1CQOiFe6+SV2J7bE= github.com/ProtonMail/go-crypto v0.0.0-20230923063757-afb1ddc0824c/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= -github.com/acomagu/bufpipe v1.0.4 h1:e3H4WUzM3npvo5uv95QuJM3cQspFNtFBzvJ2oNjKIDQ= -github.com/acomagu/bufpipe v1.0.4/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4= github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8= @@ -17,8 +15,8 @@ github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPd github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= -github.com/cloudflare/circl v1.3.5 h1:g+wWynZqVALYAlpSQFAa7TscDnUK8mKYtrxMpw6AUKo= -github.com/cloudflare/circl v1.3.5/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= +github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU= +github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/cpuguy83/go-md2man/v2 v2.0.3 h1:qMCsGGgs+MAzDFyp9LpAe1Lqy/fY/qCovCm0qnXZOBM= github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= @@ -37,10 +35,10 @@ github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66D github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic= github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+mTU= github.com/go-git/go-billy/v5 v5.5.0/go.mod h1:hmexnoNsr2SJU1Ju67OaNz5ASJY3+sHgFRpCtpDCKow= -github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20230305113008-0c11038e723f h1:Pz0DHeFij3XFhoBRGUDPzSJ+w2UcK5/0JvF8DRI58r8= -github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20230305113008-0c11038e723f/go.mod h1:8LHG1a3SRW71ettAD/jW13h8c6AqjVSeL11RAdgaqpo= -github.com/go-git/go-git/v5 v5.9.0 h1:cD9SFA7sHVRdJ7AYck1ZaAa/yeuBvGPxwXDL8cxrObY= -github.com/go-git/go-git/v5 v5.9.0/go.mod h1:RKIqga24sWdMGZF+1Ekv9kylsDz6LzdTSI2s/OsZWE0= +github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399 h1:eMje31YglSBqCdIqdhKBW8lokaMrL3uTkpGYlE2OOT4= +github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399/go.mod h1:1OCfN199q1Jm3HZlxleg+Dw/mwps2Wbk9frAWm+4FII= +github.com/go-git/go-git/v5 v5.11.0 h1:XIZc1p+8YzypNr34itUfSvYJcv+eYdTnTvOZ2vD3cA4= +github.com/go-git/go-git/v5 v5.11.0/go.mod h1:6GFcX2P3NM7FPBfpePbpLd21XxsgdAt+lKqXmCUiUCY= github.com/go-test/deep v1.1.0 h1:WOcxcdHcvdgThNXjw0t76K42FXTU7HpNQWHpA2HHNlg= github.com/go-test/deep v1.1.0/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= @@ -63,8 +61,6 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/matryer/is v1.2.0 h1:92UTHpy8CDwaJ08GqLDzhhuixiBUUD1p3AU6PHddz4A= -github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= @@ -98,12 +94,12 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs= -github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= +github.com/urfave/cli/v2 v2.27.1 h1:8xSQ6szndafKVRmfyeUMxkNUJQMjL1F2zmsZ+qHpfho= +github.com/urfave/cli/v2 v2.27.1/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= -github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= -github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= +github.com/xrash/smetrics v0.0.0-20231213231151-1d8dd44e695e h1:+SOyEddqYF09QP7vr7CgJ1eti3pY9Fn3LHO1M1r/0sI= +github.com/xrash/smetrics v0.0.0-20231213231151-1d8dd44e695e/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/zclconf/go-cty v1.14.1 h1:t9fyA35fwjjUMcmL5hLER+e/rEPqrbCK1/OSE4SI9KA= github.com/zclconf/go-cty v1.14.1/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= @@ -112,12 +108,12 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= -golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc= +golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.13.0 h1:I/DsJXRlw/8l/0c24sM9yb0T4z9liZTduXvdAWYiysY= -golang.org/x/mod v0.13.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= +golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= @@ -125,13 +121,13 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= -golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= -golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= +golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= +golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.4.0 h1:zxkM55ReGkDlKSM+Fu41A+zmbZuaPVbGMzvvdUPznYQ= -golang.org/x/sync v0.4.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= +golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE= +golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -147,15 +143,15 @@ golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= -golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= +golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= -golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4= -golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0= +golang.org/x/term v0.16.0 h1:m+B6fahuftsE9qjo0VWp2FW0mB3MTJvR0BaMQrq0pmE= +golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= @@ -169,8 +165,8 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.14.0 h1:jvNa2pY0M4r62jkRQ6RwEZZyPcymeL9XZMLBbV7U2nc= -golang.org/x/tools v0.14.0/go.mod h1:uYBEerGOWcJyEORxN+Ek8+TT266gXkNlHdJBwexUsBg= +golang.org/x/tools v0.16.1 h1:TLyB3WofjdOEepBHAU20JdNC1Zbg87elYofWYAY5oZA= +golang.org/x/tools v0.16.1/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/src/core/testdata/gha/.github/workflows/test.yml b/src/core/testdata/gha/.github/workflows/test.yml index 5b03d0e..5307014 100644 --- a/src/core/testdata/gha/.github/workflows/test.yml +++ b/src/core/testdata/gha/.github/workflows/test.yml @@ -25,7 +25,7 @@ jobs: steps: ## sets up go based on the version - name: Install Go - uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0 + uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 with: go-version: ${{ matrix.go-version }} From 1f78426b7bbd0aca1107f186e13f1ed19d1db4f4 Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Thu, 11 Apr 2024 16:25:04 +0100 Subject: [PATCH 58/80] refresh --- .github/workflows/ci.yml | 2 +- .github/workflows/codeql-analysis.yml | 6 +-- .github/workflows/pr.yml | 4 +- .github/workflows/release.yml | 4 +- .pre-commit-config.yaml | 10 ++-- go.mod | 30 +++++------ go.sum | 76 +++++++++++++-------------- 7 files changed, 66 insertions(+), 66 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3252ba8..aeaae17 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,6 +42,6 @@ jobs: run: go test ./... -coverprofile=./cover.out - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@3444e47d45411c1e34e39245eb914e9d557d2305 # v3.1.4 + uses: codecov/codecov-action@fa9a6909dc02281d24b410b6ee3dd8c5675a2e76 # v4.3.0 env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 22a1bea..005a031 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -43,7 +43,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@7e187e1c529d80bac7b87a16e7a792427f65cf02 # codeql-bundle-v2.15.5 + uses: github/codeql-action/init@99c9897648dded3fe63d6f328c46089dd57735ca # codeql-bundle-v2.17.0 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -53,7 +53,7 @@ jobs: # 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@7e187e1c529d80bac7b87a16e7a792427f65cf02 # codeql-bundle-v2.15.5 + uses: github/codeql-action/autobuild@99c9897648dded3fe63d6f328c46089dd57735ca # codeql-bundle-v2.17.0 # â„šī¸ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun @@ -66,4 +66,4 @@ jobs: # ./location_of_script_within_repo/buildscript.sh - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@7e187e1c529d80bac7b87a16e7a792427f65cf02 # codeql-bundle-v2.15.5 + uses: github/codeql-action/analyze@99c9897648dded3fe63d6f328c46089dd57735ca # codeql-bundle-v2.17.0 diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index aa74ac1..1610a7a 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -14,7 +14,7 @@ jobs: with: go-version: 1.21.x - name: Restore cache - uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2 + uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 with: path: ~/go/pkg/mod key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} @@ -36,7 +36,7 @@ jobs: with: go-version: ${{ matrix.go-version }} - name: Restore cache - uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2 + uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 with: path: ~/go/pkg/mod key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 85a167f..69040b4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -50,7 +50,7 @@ jobs: password: ${{ secrets.DOCKERHUB_PASSWORD }} tags: "latest,${{ github.ref_name }}" - name: Update Docker Hub README - uses: peter-evans/dockerhub-description@dc67fad7001ef9e8e3c124cb7a64e16d0a63d864 # v3.4.2 + uses: peter-evans/dockerhub-description@e98e4d1628a5f3be2be7c231e50981aee98723ae # v4.0.0 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} @@ -64,7 +64,7 @@ jobs: - goreleaser steps: - name: Repository Dispatch - uses: peter-evans/repository-dispatch@bf47d102fdb849e755b0b0023ea3e81a44b6f570 # v2.1.2 + uses: peter-evans/repository-dispatch@ff45666b9427631e3450c54a1bcbee4d9ff4d7c0 # v3.0.0 with: token: ${{ secrets.PAT }} repository: jameswoolfenden/scoop diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a968380..0d6e235 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,7 +15,7 @@ repos: - id: detect-aws-credentials - id: detect-private-key repo: https://github.com/pre-commit/pre-commit-hooks - rev: c4a0b883114b00d8d76b479c820ce7950211c99b + rev: 2c9f875913ee60ca25ce70243dc24d5b6415598c - hooks: - id: forbid-tabs exclude: binary|\.bin$|rego|\.rego$|go|\.go$ @@ -27,7 +27,7 @@ repos: - makefile - xml repo: https://github.com/Lucas-C/pre-commit-hooks - rev: 762c66ea96843b54b936fc680162ea67f85ec2d7 + rev: a30f0d816e5062a67d87c8de753cfe499672b959 - hooks: - id: shell-lint repo: https://github.com/jameswoolfenden/pre-commit-shell @@ -36,7 +36,7 @@ repos: - id: markdownlint exclude: src/testdata|testdata repo: https://github.com/igorshubovych/markdownlint-cli - rev: 1d2f2483dbca436b5e89d208f1ff56688ba4af9e + rev: c9ea83146232fb263effdfe6f222d87f5395b27a - hooks: - id: terraform-fmt language_version: python3.11 @@ -58,7 +58,7 @@ repos: - hooks: - id: golangci-lint repo: https://github.com/golangci/golangci-lint - rev: e3c2265f4939976874989e159386b3bb7dcf8e1f + rev: 77a8601aa372eaab3ad2d7fa1dffa71f28005393 - hooks: - id: checkov language_version: python3.11 @@ -66,7 +66,7 @@ repos: - -d - . repo: https://github.com/bridgecrewio/checkov - rev: 4f6c8f08e2b5395c37738d89ef6e099fa8667648 + rev: 2b1db34a99faed3910588dacfa1cdd35863aa5bb - hooks: - id: ghat-go name: ghat diff --git a/go.mod b/go.mod index 81150ae..7ad29ac 100644 --- a/go.mod +++ b/go.mod @@ -3,13 +3,13 @@ module ghat go 1.21 require ( - github.com/go-git/go-git/v5 v5.11.0 - github.com/hashicorp/hcl/v2 v2.19.1 - github.com/rs/zerolog v1.31.0 - github.com/sergi/go-diff v1.3.1 + github.com/go-git/go-git/v5 v5.12.0 + github.com/hashicorp/hcl/v2 v2.20.1 + github.com/rs/zerolog v1.32.0 + github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 github.com/urfave/cli/v2 v2.27.1 - github.com/zclconf/go-cty v1.14.1 - golang.org/x/mod v0.14.0 + github.com/zclconf/go-cty v1.14.4 + golang.org/x/mod v0.17.0 gopkg.in/yaml.v3 v3.0.1 moul.io/banner v1.0.1 ) @@ -17,11 +17,11 @@ require ( require ( dario.cat/mergo v1.0.0 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect - github.com/ProtonMail/go-crypto v0.0.0-20230923063757-afb1ddc0824c // indirect + github.com/ProtonMail/go-crypto v1.0.0 // indirect github.com/agext/levenshtein v1.2.3 // indirect github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect github.com/cloudflare/circl v1.3.7 // indirect - github.com/cpuguy83/go-md2man/v2 v2.0.3 // indirect + github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect github.com/cyphar/filepath-securejoin v0.2.4 // indirect github.com/emirpasic/gods v1.18.1 // indirect github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect @@ -31,19 +31,19 @@ require ( github.com/google/go-cmp v0.6.0 // indirect github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect github.com/kevinburke/ssh_config v1.2.0 // indirect - github.com/kylelemons/godebug v1.1.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mitchellh/go-wordwrap v1.0.1 // indirect github.com/pjbgf/sha1cd v0.3.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect - github.com/skeema/knownhosts v1.2.1 // indirect + github.com/skeema/knownhosts v1.2.2 // indirect github.com/xanzy/ssh-agent v0.3.3 // indirect - github.com/xrash/smetrics v0.0.0-20231213231151-1d8dd44e695e // indirect - golang.org/x/crypto v0.18.0 // indirect - golang.org/x/net v0.20.0 // indirect - golang.org/x/sys v0.16.0 // indirect + github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 // indirect + golang.org/x/crypto v0.22.0 // indirect + golang.org/x/net v0.24.0 // indirect + golang.org/x/sync v0.7.0 // indirect + golang.org/x/sys v0.19.0 // indirect golang.org/x/text v0.14.0 // indirect - golang.org/x/tools v0.16.1 // indirect + golang.org/x/tools v0.20.0 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect ) diff --git a/go.sum b/go.sum index 43d5f49..13dc9f3 100644 --- a/go.sum +++ b/go.sum @@ -3,8 +3,8 @@ dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= -github.com/ProtonMail/go-crypto v0.0.0-20230923063757-afb1ddc0824c h1:kMFnB0vCcX7IL/m9Y5LO+KQYv+t1CQOiFe6+SV2J7bE= -github.com/ProtonMail/go-crypto v0.0.0-20230923063757-afb1ddc0824c/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= +github.com/ProtonMail/go-crypto v1.0.0 h1:LRuvITjQWX+WIfr930YHG2HNfjR1uOfyf5vE0kC2U78= +github.com/ProtonMail/go-crypto v1.0.0/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8= @@ -18,8 +18,8 @@ github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUK github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU= github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= -github.com/cpuguy83/go-md2man/v2 v2.0.3 h1:qMCsGGgs+MAzDFyp9LpAe1Lqy/fY/qCovCm0qnXZOBM= -github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4= +github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg= github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -29,16 +29,16 @@ github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a h1:mATvB/9r/3gvcej github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a/go.mod h1:Ro8st/ElPeALwNFlcTpWmkr6IoMFfkjXAvTHpevnDsM= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= -github.com/gliderlabs/ssh v0.3.5 h1:OcaySEmAQJgyYcArR+gGGTHCyE7nvhEMTlYY+Dp8CpY= -github.com/gliderlabs/ssh v0.3.5/go.mod h1:8XB4KraRrX39qHhT6yxPsHedjA08I/uBVwj4xC+/+z4= +github.com/gliderlabs/ssh v0.3.7 h1:iV3Bqi942d9huXnzEF2Mt+CY9gLu8DNM4Obd+8bODRE= +github.com/gliderlabs/ssh v0.3.7/go.mod h1:zpHEXBstFnQYtGnB8k8kQLol82umzn/2/snG7alWVD8= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic= github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+mTU= github.com/go-git/go-billy/v5 v5.5.0/go.mod h1:hmexnoNsr2SJU1Ju67OaNz5ASJY3+sHgFRpCtpDCKow= github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399 h1:eMje31YglSBqCdIqdhKBW8lokaMrL3uTkpGYlE2OOT4= github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399/go.mod h1:1OCfN199q1Jm3HZlxleg+Dw/mwps2Wbk9frAWm+4FII= -github.com/go-git/go-git/v5 v5.11.0 h1:XIZc1p+8YzypNr34itUfSvYJcv+eYdTnTvOZ2vD3cA4= -github.com/go-git/go-git/v5 v5.11.0/go.mod h1:6GFcX2P3NM7FPBfpePbpLd21XxsgdAt+lKqXmCUiUCY= +github.com/go-git/go-git/v5 v5.12.0 h1:7Md+ndsjrzZxbddRDZjF14qK+NN56sy6wkqaVrjZtys= +github.com/go-git/go-git/v5 v5.12.0/go.mod h1:FTM9VKtnI2m65hNI/TenDDDnUf2Q9FHnXYjuz9i5OEY= github.com/go-test/deep v1.1.0 h1:WOcxcdHcvdgThNXjw0t76K42FXTU7HpNQWHpA2HHNlg= github.com/go-test/deep v1.1.0/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= @@ -46,8 +46,8 @@ github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/hashicorp/hcl/v2 v2.19.1 h1://i05Jqznmb2EXqa39Nsvyan2o5XyMowW5fnCKW5RPI= -github.com/hashicorp/hcl/v2 v2.19.1/go.mod h1:ThLC89FV4p9MPW804KVbe/cEXoQ8NZEh+JtMeeGErHE= +github.com/hashicorp/hcl/v2 v2.20.1 h1:M6hgdyz7HYt1UN9e61j+qKJBqR3orTWbI1HKBJEdxtc= +github.com/hashicorp/hcl/v2 v2.20.1/go.mod h1:TZDqQ4kNKCbh1iJp99FdPiUaVDDUPivbqxZulxDYqL4= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= @@ -59,8 +59,6 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= -github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= @@ -80,40 +78,42 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= -github.com/rs/zerolog v1.31.0 h1:FcTR3NnLWW+NnTwwhFWiJSZr4ECLpqCm6QsEnyvbV4A= -github.com/rs/zerolog v1.31.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= +github.com/rs/zerolog v1.32.0 h1:keLypqrlIjaFsbmJOBdB/qvyF8KEtCWHwobLp5l/mQ0= +github.com/rs/zerolog v1.32.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= -github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= +github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8= +github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4= github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= -github.com/skeema/knownhosts v1.2.1 h1:SHWdIUa82uGZz+F+47k8SY4QhhI291cXCpopT1lK2AQ= -github.com/skeema/knownhosts v1.2.1/go.mod h1:xYbVRSPxqBZFrdmDyMmsOs+uX1UZC3nTN3ThzgDxUwo= +github.com/skeema/knownhosts v1.2.2 h1:Iug2P4fLmDw9f41PB6thxUkNUkJzB5i+1/exaj40L3A= +github.com/skeema/knownhosts v1.2.2/go.mod h1:xYbVRSPxqBZFrdmDyMmsOs+uX1UZC3nTN3ThzgDxUwo= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/urfave/cli/v2 v2.27.1 h1:8xSQ6szndafKVRmfyeUMxkNUJQMjL1F2zmsZ+qHpfho= github.com/urfave/cli/v2 v2.27.1/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= -github.com/xrash/smetrics v0.0.0-20231213231151-1d8dd44e695e h1:+SOyEddqYF09QP7vr7CgJ1eti3pY9Fn3LHO1M1r/0sI= -github.com/xrash/smetrics v0.0.0-20231213231151-1d8dd44e695e/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= +github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 h1:+qGGcbkzsfDQNPPe9UDgpxAWQrhbbBXOYJFQDq/dtJw= +github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913/go.mod h1:4aEEwZQutDLsQv2Deui4iYQ6DWTxR14g6m8Wv88+Xqk= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -github.com/zclconf/go-cty v1.14.1 h1:t9fyA35fwjjUMcmL5hLER+e/rEPqrbCK1/OSE4SI9KA= -github.com/zclconf/go-cty v1.14.1/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= +github.com/zclconf/go-cty v1.14.4 h1:uXXczd9QDGsgu0i/QFR/hzI5NYCHLf6NQw/atrbnhq8= +github.com/zclconf/go-cty v1.14.4/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= +github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b h1:FosyBZYxY34Wul7O/MSKey3txpPYyCqVO5ZyceuQJEI= +github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc= -golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= +golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= +golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= -golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= +golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= @@ -121,13 +121,13 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= -golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= -golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= +golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= +golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE= -golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= +golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -143,15 +143,15 @@ golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= -golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= +golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= -golang.org/x/term v0.16.0 h1:m+B6fahuftsE9qjo0VWp2FW0mB3MTJvR0BaMQrq0pmE= -golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY= +golang.org/x/term v0.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q= +golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= @@ -165,8 +165,8 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.16.1 h1:TLyB3WofjdOEepBHAU20JdNC1Zbg87elYofWYAY5oZA= -golang.org/x/tools v0.16.1/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0= +golang.org/x/tools v0.20.0 h1:hz/CVckiOxybQvFw6h7b/q80NTr9IUQb4s1IIzW7KNY= +golang.org/x/tools v0.20.0/go.mod h1:WvitBU7JJf6A4jOdg4S1tviW9bhUxkgeCui/0JHctQg= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= From 76563762c09c6cccf933766bf4a897f683a20848 Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Thu, 11 Apr 2024 16:35:41 +0100 Subject: [PATCH 59/80] fix test versions --- src/core/modules_test.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/core/modules_test.go b/src/core/modules_test.go index 7a3c1ed..0e64769 100644 --- a/src/core/modules_test.go +++ b/src/core/modules_test.go @@ -124,11 +124,11 @@ func TestFlags_UpdateSource(t *testing.T) { {"git", fields{"", "", gitHubToken, 0, false, nil, false}, args{"git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git", "git", ""}, - "git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=c6d56c13e65876d7df7b7a9a21ffc010396120e7", "v2.0.0", false}, + "git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=93facd14e9e3a66704d84a0236a8a3b813f047be", "v2.0.1", false}, {"git update", fields{"", "", gitHubToken, 0, false, nil, true}, args{"git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git", "git", ""}, - "git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=c6d56c13e65876d7df7b7a9a21ffc010396120e7", "v2.0.0", false}, + "git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=93facd14e9e3a66704d84a0236a8a3b813f047be", "v2.0.1", false}, {"git version", fields{"", "", gitHubToken, 0, false, nil, false}, args{"git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=v1.0.0", "git", ""}, @@ -136,7 +136,7 @@ func TestFlags_UpdateSource(t *testing.T) { {"git version update", fields{"", "", gitHubToken, 0, false, nil, true}, args{"git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=v1.0.0", "git", ""}, - "git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=c6d56c13e65876d7df7b7a9a21ffc010396120e7", "v2.0.0", false}, + "git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=93facd14e9e3a66704d84a0236a8a3b813f047be", "v2.0.1", false}, {"git version missing", fields{"", "", gitHubToken, 0, false, nil, false}, args{"git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=v1.2.0", "git", ""}, @@ -147,9 +147,9 @@ func TestFlags_UpdateSource(t *testing.T) { "git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=c6d56c1", "c6d56c1", false}, {name: "git hash update", fields: fields{"", "", gitHubToken, 0, false, nil, true}, - args: args{"git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=c6d56c13e65876d7df7b7a9a21ffc010396120e7", "git", ""}, - want: "git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=c6d56c13e65876d7df7b7a9a21ffc010396120e7", - want1: "v2.0.0", + args: args{"git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=93facd14e9e3a66704d84a0236a8a3b813f047be", "git", ""}, + want: "git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=93facd14e9e3a66704d84a0236a8a3b813f047be", + want1: "v2.0.1", wantErr: false}, //{"git query string", fields{}, args{"git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git"}, "git", false}, From 7519e122c59022980c0fab21b594937b7d503344 Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Thu, 18 Jul 2024 09:19:27 +0100 Subject: [PATCH 60/80] update deps --- .gitignore | 8 +++++ .goreleaser.yml | 8 ++++- .pre-commit-config.yaml | 20 ++++++------ go.mod | 32 +++++++++---------- go.sum | 68 ++++++++++++++++++++--------------------- 5 files changed, 75 insertions(+), 61 deletions(-) diff --git a/.gitignore b/.gitignore index e806b1e..11531ff 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,11 @@ __debug_bin.exe .ghat provider.azure.tf provider.azurerm.tf +terraform-provider-* +*.pem +*.csr +.destination +tf.plan +tf.json + +dist/ diff --git a/.goreleaser.yml b/.goreleaser.yml index a86746e..77cf9fc 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,5 +1,11 @@ # .goreleaser.yml +# The lines below are called `modelines`. See `:help modeline` +# Feel free to remove those if you don't want/need to use them. +# yaml-language-server: $schema=https://goreleaser.com/static/schema.json +# vim: set ts=2 sw=2 tw=0 fo=cnqoj + +version: 2 before: hooks: - ./set-version.sh @@ -26,7 +32,7 @@ archives: brews: - name: ghat - tap: + repository: owner: JamesWoolfenden name: homebrew-tap token: "{{ .Env.HOMEBREW_TAP_GITHUB_TOKEN }}" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0d6e235..157c713 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,7 +15,7 @@ repos: - id: detect-aws-credentials - id: detect-private-key repo: https://github.com/pre-commit/pre-commit-hooks - rev: 2c9f875913ee60ca25ce70243dc24d5b6415598c + rev: v4.6.0 - hooks: - id: forbid-tabs exclude: binary|\.bin$|rego|\.rego$|go|\.go$ @@ -27,26 +27,26 @@ repos: - makefile - xml repo: https://github.com/Lucas-C/pre-commit-hooks - rev: a30f0d816e5062a67d87c8de753cfe499672b959 + rev: v1.5.5 - hooks: - id: shell-lint repo: https://github.com/jameswoolfenden/pre-commit-shell - rev: 062f0b028ae65827e04f91c1e6738cfcbe9b337f + rev: 0.0.2 - hooks: - id: markdownlint exclude: src/testdata|testdata repo: https://github.com/igorshubovych/markdownlint-cli - rev: c9ea83146232fb263effdfe6f222d87f5395b27a + rev: v0.41.0 - hooks: - id: terraform-fmt language_version: python3.11 repo: https://github.com/jameswoolfenden/pre-commit - rev: b00d945c0dce54f230a5d1cfb7d24e285396e1f2 + rev: v0.1.50 - hooks: - id: gofmt - id: goimports repo: https://github.com/gruntwork-io/pre-commit - rev: d0bcdb35c6999a4a120b528f050d2b11778fd3d0 + rev: v0.1.23 - hooks: - id: go-test args: @@ -54,11 +54,11 @@ repos: - id: go-mod-tidy - id: go-generate repo: https://github.com/syntaqx/git-hooks - rev: a3b888f92cd5b40b270c9a9752181fdc1717cbe5 + rev: v0.0.18 - hooks: - id: golangci-lint repo: https://github.com/golangci/golangci-lint - rev: 77a8601aa372eaab3ad2d7fa1dffa71f28005393 + rev: v1.59.1 - hooks: - id: checkov language_version: python3.11 @@ -66,7 +66,7 @@ repos: - -d - . repo: https://github.com/bridgecrewio/checkov - rev: 2b1db34a99faed3910588dacfa1cdd35863aa5bb + rev: 3.2.193 - hooks: - id: ghat-go name: ghat @@ -90,4 +90,4 @@ repos: - id: no-go-testing - id: go-mod-tidy repo: https://github.com/dnephin/pre-commit-golang - rev: fb24a639f7c938759fe56eeebbb7713b69d60494 + rev: v0.5.1 diff --git a/go.mod b/go.mod index 7ad29ac..0c04e05 100644 --- a/go.mod +++ b/go.mod @@ -1,28 +1,28 @@ module ghat -go 1.21 +go 1.22.2 require ( github.com/go-git/go-git/v5 v5.12.0 - github.com/hashicorp/hcl/v2 v2.20.1 - github.com/rs/zerolog v1.32.0 + github.com/hashicorp/hcl/v2 v2.21.0 + github.com/rs/zerolog v1.33.0 github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 - github.com/urfave/cli/v2 v2.27.1 - github.com/zclconf/go-cty v1.14.4 - golang.org/x/mod v0.17.0 + github.com/urfave/cli/v2 v2.27.2 + github.com/zclconf/go-cty v1.15.0 + golang.org/x/mod v0.19.0 gopkg.in/yaml.v3 v3.0.1 moul.io/banner v1.0.1 ) require ( dario.cat/mergo v1.0.0 // indirect - github.com/Microsoft/go-winio v0.6.1 // indirect + github.com/Microsoft/go-winio v0.6.2 // indirect github.com/ProtonMail/go-crypto v1.0.0 // indirect github.com/agext/levenshtein v1.2.3 // indirect github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect - github.com/cloudflare/circl v1.3.7 // indirect + github.com/cloudflare/circl v1.3.9 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect - github.com/cyphar/filepath-securejoin v0.2.4 // indirect + github.com/cyphar/filepath-securejoin v0.3.0 // indirect github.com/emirpasic/gods v1.18.1 // indirect github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect github.com/go-git/go-billy/v5 v5.5.0 // indirect @@ -36,14 +36,14 @@ require ( github.com/mitchellh/go-wordwrap v1.0.1 // indirect github.com/pjbgf/sha1cd v0.3.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect - github.com/skeema/knownhosts v1.2.2 // indirect + github.com/skeema/knownhosts v1.3.0 // indirect github.com/xanzy/ssh-agent v0.3.3 // indirect - github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 // indirect - golang.org/x/crypto v0.22.0 // indirect - golang.org/x/net v0.24.0 // indirect + github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect + golang.org/x/crypto v0.25.0 // indirect + golang.org/x/net v0.27.0 // indirect golang.org/x/sync v0.7.0 // indirect - golang.org/x/sys v0.19.0 // indirect - golang.org/x/text v0.14.0 // indirect - golang.org/x/tools v0.20.0 // indirect + golang.org/x/sys v0.22.0 // indirect + golang.org/x/text v0.16.0 // indirect + golang.org/x/tools v0.23.0 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect ) diff --git a/go.sum b/go.sum index 13dc9f3..2444374 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,8 @@ dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= -github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= -github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= +github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= +github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= github.com/ProtonMail/go-crypto v1.0.0 h1:LRuvITjQWX+WIfr930YHG2HNfjR1uOfyf5vE0kC2U78= github.com/ProtonMail/go-crypto v1.0.0/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= @@ -15,13 +15,13 @@ github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPd github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= -github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU= -github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA= +github.com/cloudflare/circl v1.3.9 h1:QFrlgFYf2Qpi8bSpVPK1HBvWpx16v/1TZivyo7pGuBE= +github.com/cloudflare/circl v1.3.9/go.mod h1:PDRU+oXvdD7KCtgKxW95M5Z8BpSCJXQORiZFnBQS5QU= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4= github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= -github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg= -github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= +github.com/cyphar/filepath-securejoin v0.3.0 h1:tXpmbiaeBrS/K2US8nhgwdKYnfAOnVfkcLPKFgFHeA0= +github.com/cyphar/filepath-securejoin v0.3.0/go.mod h1:F7i41x/9cBF7lzCrVsYs9fuzwRZm4NQsGTBdpp6mETc= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -46,8 +46,8 @@ github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/hashicorp/hcl/v2 v2.20.1 h1:M6hgdyz7HYt1UN9e61j+qKJBqR3orTWbI1HKBJEdxtc= -github.com/hashicorp/hcl/v2 v2.20.1/go.mod h1:TZDqQ4kNKCbh1iJp99FdPiUaVDDUPivbqxZulxDYqL4= +github.com/hashicorp/hcl/v2 v2.21.0 h1:lve4q/o/2rqwYOgUg3y3V2YPyD1/zkCLGjIV74Jit14= +github.com/hashicorp/hcl/v2 v2.21.0/go.mod h1:62ZYHrXgPoX8xBnzl8QzbWq4dyDsDtfCRgIq1rbJEvA= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= @@ -78,42 +78,42 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= -github.com/rs/zerolog v1.32.0 h1:keLypqrlIjaFsbmJOBdB/qvyF8KEtCWHwobLp5l/mQ0= -github.com/rs/zerolog v1.32.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= +github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8= +github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8= github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4= github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= -github.com/skeema/knownhosts v1.2.2 h1:Iug2P4fLmDw9f41PB6thxUkNUkJzB5i+1/exaj40L3A= -github.com/skeema/knownhosts v1.2.2/go.mod h1:xYbVRSPxqBZFrdmDyMmsOs+uX1UZC3nTN3ThzgDxUwo= +github.com/skeema/knownhosts v1.3.0 h1:AM+y0rI04VksttfwjkSTNQorvGqmwATnvnAHpSgc0LY= +github.com/skeema/knownhosts v1.3.0/go.mod h1:sPINvnADmT/qYH1kfv+ePMmOBTH6Tbl7b5LvTDjFK7M= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/urfave/cli/v2 v2.27.1 h1:8xSQ6szndafKVRmfyeUMxkNUJQMjL1F2zmsZ+qHpfho= -github.com/urfave/cli/v2 v2.27.1/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= +github.com/urfave/cli/v2 v2.27.2 h1:6e0H+AkS+zDckwPCUrZkKX38mRaau4nL2uipkJpbkcI= +github.com/urfave/cli/v2 v2.27.2/go.mod h1:g0+79LmHHATl7DAcHO99smiR/T7uGLw84w8Y42x+4eM= github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= -github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 h1:+qGGcbkzsfDQNPPe9UDgpxAWQrhbbBXOYJFQDq/dtJw= -github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913/go.mod h1:4aEEwZQutDLsQv2Deui4iYQ6DWTxR14g6m8Wv88+Xqk= +github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4= +github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -github.com/zclconf/go-cty v1.14.4 h1:uXXczd9QDGsgu0i/QFR/hzI5NYCHLf6NQw/atrbnhq8= -github.com/zclconf/go-cty v1.14.4/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= -github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b h1:FosyBZYxY34Wul7O/MSKey3txpPYyCqVO5ZyceuQJEI= -github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8= +github.com/zclconf/go-cty v1.15.0 h1:tTCRWxsexYUmtt/wVxgDClUe+uQusuI443uL6e+5sXQ= +github.com/zclconf/go-cty v1.15.0/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= +github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940 h1:4r45xpDWB6ZMSMNJFMOjqrGHynW3DIBuR2H9j0ug+Mo= +github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940/go.mod h1:CmBdvvj3nqzfzJ6nTCIwDTPZ56aVGvDrmztiO5g3qrM= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= -golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= +golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= +golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= -golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.19.0 h1:fEdghXQSo20giMthA7cd28ZC+jts4amQ3YMXiP5oMQ8= +golang.org/x/mod v0.19.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= @@ -121,8 +121,8 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= -golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= -golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= +golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= +golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -143,15 +143,15 @@ golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= -golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= +golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= -golang.org/x/term v0.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q= -golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk= +golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk= +golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= @@ -159,14 +159,14 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= +golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.20.0 h1:hz/CVckiOxybQvFw6h7b/q80NTr9IUQb4s1IIzW7KNY= -golang.org/x/tools v0.20.0/go.mod h1:WvitBU7JJf6A4jOdg4S1tviW9bhUxkgeCui/0JHctQg= +golang.org/x/tools v0.23.0 h1:SGsXPZ+2l4JsgaCKkx+FQ9YZ5XEtA1GZYuoDjenLjvg= +golang.org/x/tools v0.23.0/go.mod h1:pnu6ufv6vQkll6szChhK3C3L/ruaIv5eBeztNG8wtsI= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= From 39affddbd2aac804070b440de111bcb4e3e63e98 Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Thu, 18 Jul 2024 09:38:27 +0100 Subject: [PATCH 61/80] update deps --- .github/workflows/ci.yml | 6 ++--- .github/workflows/codeql-analysis.yml | 8 +++---- .github/workflows/pr.yml | 12 +++++----- .github/workflows/release.yml | 8 +++---- .pre-commit-config.yaml | 24 +++++++++---------- .../testdata/gha/.github/workflows/test.yml | 4 ++-- 6 files changed, 31 insertions(+), 31 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aeaae17..0506fbf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,13 +25,13 @@ jobs: steps: ## sets up go based on the version - name: Install Go - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 + uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 with: go-version: ${{ matrix.go-version }} ## checks out our code locally, so we can work with the files - name: Checkout code - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 ## runs go test ./... - name: Build @@ -42,6 +42,6 @@ jobs: run: go test ./... -coverprofile=./cover.out - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@fa9a6909dc02281d24b410b6ee3dd8c5675a2e76 # v4.3.0 + uses: codecov/codecov-action@79066c46f8dcdf8d7355f820dbac958c5b4cb9d3 # v4.5.0 env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 005a031..65bca24 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -39,11 +39,11 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@99c9897648dded3fe63d6f328c46089dd57735ca # codeql-bundle-v2.17.0 + uses: github/codeql-action/init@064a406de026ea27990a5b507b56911401ca2f95 # codeql-bundle-v2.18.0 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -53,7 +53,7 @@ jobs: # 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@99c9897648dded3fe63d6f328c46089dd57735ca # codeql-bundle-v2.17.0 + uses: github/codeql-action/autobuild@064a406de026ea27990a5b507b56911401ca2f95 # codeql-bundle-v2.18.0 # â„šī¸ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun @@ -66,4 +66,4 @@ jobs: # ./location_of_script_within_repo/buildscript.sh - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@99c9897648dded3fe63d6f328c46089dd57735ca # codeql-bundle-v2.17.0 + uses: github/codeql-action/analyze@064a406de026ea27990a5b507b56911401ca2f95 # codeql-bundle-v2.18.0 diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 1610a7a..23d7557 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -8,9 +8,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Install Go - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 + uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 with: go-version: 1.21.x - name: Restore cache @@ -30,9 +30,9 @@ jobs: runs-on: ${{ matrix.platform }} steps: - name: Checkout code - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Install Go - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 + uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 with: go-version: ${{ matrix.go-version }} - name: Restore cache @@ -48,8 +48,8 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Install Go - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 + uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 with: go-version: 1.21.x diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 69040b4..aad42e5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,11 +11,11 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Unshallow run: git fetch --prune --unshallow - name: Set up Go - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 + uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 with: go-version: 1.21 - name: Import GPG key @@ -25,7 +25,7 @@ jobs: gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} passphrase: ${{ secrets.PASSPHRASE }} - name: Run GoReleaser - uses: goreleaser/goreleaser-action@7ec5c2b0c6cdda6e8bbb49444bc797dd33d74dd8 # v5.0.0 + uses: goreleaser/goreleaser-action@286f3b13b1b49da4ac219696163fb8c1c93e1200 # v6.0.0 with: version: latest args: release --clean @@ -41,7 +41,7 @@ jobs: needs: - goreleaser steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Publish to Registry uses: elgohr/Publish-Docker-Github-Action@82556589c08f584cb95411629a94e6c2b68b9b80 # v5 with: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 157c713..2ef92b5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,5 +1,5 @@ default_language_version: - python: python3.11 + python: python3.12 repos: - hooks: - id: check-json @@ -15,7 +15,7 @@ repos: - id: detect-aws-credentials - id: detect-private-key repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: 2c9f875913ee60ca25ce70243dc24d5b6415598c - hooks: - id: forbid-tabs exclude: binary|\.bin$|rego|\.rego$|go|\.go$ @@ -27,26 +27,26 @@ repos: - makefile - xml repo: https://github.com/Lucas-C/pre-commit-hooks - rev: v1.5.5 + rev: a30f0d816e5062a67d87c8de753cfe499672b959 - hooks: - id: shell-lint repo: https://github.com/jameswoolfenden/pre-commit-shell - rev: 0.0.2 + rev: 062f0b028ae65827e04f91c1e6738cfcbe9b337f - hooks: - id: markdownlint exclude: src/testdata|testdata repo: https://github.com/igorshubovych/markdownlint-cli - rev: v0.41.0 + rev: f295829140d25717bc79368d3f966fc1f67a824f - hooks: - id: terraform-fmt language_version: python3.11 repo: https://github.com/jameswoolfenden/pre-commit - rev: v0.1.50 + rev: b00d945c0dce54f230a5d1cfb7d24e285396e1f2 - hooks: - id: gofmt - id: goimports repo: https://github.com/gruntwork-io/pre-commit - rev: v0.1.23 + rev: d0bcdb35c6999a4a120b528f050d2b11778fd3d0 - hooks: - id: go-test args: @@ -54,19 +54,19 @@ repos: - id: go-mod-tidy - id: go-generate repo: https://github.com/syntaqx/git-hooks - rev: v0.0.18 + rev: a3b888f92cd5b40b270c9a9752181fdc1717cbe5 - hooks: - id: golangci-lint repo: https://github.com/golangci/golangci-lint - rev: v1.59.1 + rev: 1a55854aff4ef60cd8c4e709b650b281303ca7aa - hooks: - id: checkov - language_version: python3.11 + language_version: python3.12 args: - -d - . repo: https://github.com/bridgecrewio/checkov - rev: 3.2.193 + rev: 49a467606b4777f75c7f53ecda4e03d32f0c2002 - hooks: - id: ghat-go name: ghat @@ -90,4 +90,4 @@ repos: - id: no-go-testing - id: go-mod-tidy repo: https://github.com/dnephin/pre-commit-golang - rev: v0.5.1 + rev: fb24a639f7c938759fe56eeebbb7713b69d60494 diff --git a/src/core/testdata/gha/.github/workflows/test.yml b/src/core/testdata/gha/.github/workflows/test.yml index 5307014..48402c8 100644 --- a/src/core/testdata/gha/.github/workflows/test.yml +++ b/src/core/testdata/gha/.github/workflows/test.yml @@ -25,13 +25,13 @@ jobs: steps: ## sets up go based on the version - name: Install Go - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 + uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 with: go-version: ${{ matrix.go-version }} ## checks out our code locally, so we can work with the files - name: Checkout code - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 ## runs go test ./... - name: Build From 0104ce359bf25262a8fc032f2376a56fdcf1f48e Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Thu, 18 Jul 2024 09:55:52 +0100 Subject: [PATCH 62/80] update tests --- src/core/modules_test.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/core/modules_test.go b/src/core/modules_test.go index 0e64769..02650a4 100644 --- a/src/core/modules_test.go +++ b/src/core/modules_test.go @@ -124,19 +124,23 @@ func TestFlags_UpdateSource(t *testing.T) { {"git", fields{"", "", gitHubToken, 0, false, nil, false}, args{"git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git", "git", ""}, - "git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=93facd14e9e3a66704d84a0236a8a3b813f047be", "v2.0.1", false}, + "git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=7490e771c58f2d4a233b5c62b4fb1c4a368245c1", + "v2.1.0", false}, {"git update", fields{"", "", gitHubToken, 0, false, nil, true}, args{"git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git", "git", ""}, - "git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=93facd14e9e3a66704d84a0236a8a3b813f047be", "v2.0.1", false}, + "git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=7490e771c58f2d4a233b5c62b4fb1c4a368245c1", + "v2.1.0", false}, {"git version", fields{"", "", gitHubToken, 0, false, nil, false}, args{"git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=v1.0.0", "git", ""}, - "git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=c1a0698ae1ae4ced03399809ef3e0253b07c44a9", "v1.0.0", false}, + "git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=c1a0698ae1ae4ced03399809ef3e0253b07c44a9", + "v1.0.0", false}, {"git version update", fields{"", "", gitHubToken, 0, false, nil, true}, args{"git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=v1.0.0", "git", ""}, - "git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=93facd14e9e3a66704d84a0236a8a3b813f047be", "v2.0.1", false}, + "git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=7490e771c58f2d4a233b5c62b4fb1c4a368245c1", + "v2.1.0", false}, {"git version missing", fields{"", "", gitHubToken, 0, false, nil, false}, args{"git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=v1.2.0", "git", ""}, @@ -148,8 +152,8 @@ func TestFlags_UpdateSource(t *testing.T) { {name: "git hash update", fields: fields{"", "", gitHubToken, 0, false, nil, true}, args: args{"git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=93facd14e9e3a66704d84a0236a8a3b813f047be", "git", ""}, - want: "git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=93facd14e9e3a66704d84a0236a8a3b813f047be", - want1: "v2.0.1", + want: "git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=7490e771c58f2d4a233b5c62b4fb1c4a368245c1", + want1: "v2.1.0", wantErr: false}, //{"git query string", fields{}, args{"git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git"}, "git", false}, From 3f9346626daf8da7edd502f728b7c7e4bbb37167 Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Thu, 18 Jul 2024 15:02:07 +0100 Subject: [PATCH 63/80] fix flow --- .pre-commit-config.yaml | 2 +- src/core/gha.go | 2 +- src/core/registry.go | 4 ---- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2ef92b5..2a37b6d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -66,7 +66,7 @@ repos: - -d - . repo: https://github.com/bridgecrewio/checkov - rev: 49a467606b4777f75c7f53ecda4e03d32f0c2002 + rev: 76041d8579b178af16e0db9c69b1f7448211626e - hooks: - id: ghat-go name: ghat diff --git a/src/core/gha.go b/src/core/gha.go index 391b605..3d9ae95 100644 --- a/src/core/gha.go +++ b/src/core/gha.go @@ -156,7 +156,7 @@ func (myFlags *Flags) UpdateGHA(file string) error { continue } - sha := object["sha"].(string) + sha, ok := object["sha"].(string) if !ok { log.Warn().Msgf("failed to assert string %s", err) continue diff --git a/src/core/registry.go b/src/core/registry.go index edace80..4e6b08c 100644 --- a/src/core/registry.go +++ b/src/core/registry.go @@ -57,10 +57,6 @@ func (myRegistry *Registry) GetLatest(module string) (*string, error) { _ = Body.Close() }(resp.Body) - if err != nil { - return nil, fmt.Errorf("client failed %w", err) - } - body, err := io.ReadAll(resp.Body) if err != nil { From 8b04de19b2a923b54e56668fec3c99d24655ca81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Fri, 9 Aug 2024 09:49:58 +0200 Subject: [PATCH 64/80] Fix module path in go.mod Installing it via `go install` now gets: ``` go install github.com/jameswoolfenden/ghat@latest go: downloading github.com/jameswoolfenden/ghat v0.1.5 go: github.com/jameswoolfenden/ghat@latest: version constraints conflict: github.com/jameswoolfenden/ghat@v0.1.5: parsing go.mod: module declares its path as: ghat but was required as: github.com/jameswoolfenden/ghat ``` --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 0c04e05..a09fb0d 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module ghat +module github.com/jameswoolfenden/ghat go 1.22.2 From faa569948ce6744cf5e41c31e82541b83cb6fd6c Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Fri, 9 Aug 2024 18:40:20 +0100 Subject: [PATCH 65/80] fix reference --- .github/workflows/codeql-analysis.yml | 6 ++-- .pre-commit-config.yaml | 6 ++-- go.mod | 18 ++++++------ go.sum | 40 +++++++++++++-------------- main.go | 4 +-- 5 files changed, 37 insertions(+), 37 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 65bca24..78aab0f 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -43,7 +43,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@064a406de026ea27990a5b507b56911401ca2f95 # codeql-bundle-v2.18.0 + uses: github/codeql-action/init@0e346f2c4a1b999b44f1ef93fe08bdb83dae63ab # codeql-bundle-v2.18.1 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -53,7 +53,7 @@ jobs: # 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@064a406de026ea27990a5b507b56911401ca2f95 # codeql-bundle-v2.18.0 + uses: github/codeql-action/autobuild@0e346f2c4a1b999b44f1ef93fe08bdb83dae63ab # codeql-bundle-v2.18.1 # â„šī¸ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun @@ -66,4 +66,4 @@ jobs: # ./location_of_script_within_repo/buildscript.sh - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@064a406de026ea27990a5b507b56911401ca2f95 # codeql-bundle-v2.18.0 + uses: github/codeql-action/analyze@0e346f2c4a1b999b44f1ef93fe08bdb83dae63ab # codeql-bundle-v2.18.1 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2a37b6d..9e5ba7d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,5 +1,5 @@ default_language_version: - python: python3.12 + python: python3.11 repos: - hooks: - id: check-json @@ -61,12 +61,12 @@ repos: rev: 1a55854aff4ef60cd8c4e709b650b281303ca7aa - hooks: - id: checkov - language_version: python3.12 + language_version: python3.11 args: - -d - . repo: https://github.com/bridgecrewio/checkov - rev: 76041d8579b178af16e0db9c69b1f7448211626e + rev: c81e0929317cba5cec1712168445c021b4ec4f4d - hooks: - id: ghat-go name: ghat diff --git a/go.mod b/go.mod index a09fb0d..5ef222c 100644 --- a/go.mod +++ b/go.mod @@ -7,9 +7,9 @@ require ( github.com/hashicorp/hcl/v2 v2.21.0 github.com/rs/zerolog v1.33.0 github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 - github.com/urfave/cli/v2 v2.27.2 + github.com/urfave/cli/v2 v2.27.3 github.com/zclconf/go-cty v1.15.0 - golang.org/x/mod v0.19.0 + golang.org/x/mod v0.20.0 gopkg.in/yaml.v3 v3.0.1 moul.io/banner v1.0.1 ) @@ -22,7 +22,7 @@ require ( github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect github.com/cloudflare/circl v1.3.9 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect - github.com/cyphar/filepath-securejoin v0.3.0 // indirect + github.com/cyphar/filepath-securejoin v0.3.1 // indirect github.com/emirpasic/gods v1.18.1 // indirect github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect github.com/go-git/go-billy/v5 v5.5.0 // indirect @@ -39,11 +39,11 @@ require ( github.com/skeema/knownhosts v1.3.0 // indirect github.com/xanzy/ssh-agent v0.3.3 // indirect github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect - golang.org/x/crypto v0.25.0 // indirect - golang.org/x/net v0.27.0 // indirect - golang.org/x/sync v0.7.0 // indirect - golang.org/x/sys v0.22.0 // indirect - golang.org/x/text v0.16.0 // indirect - golang.org/x/tools v0.23.0 // indirect + golang.org/x/crypto v0.26.0 // indirect + golang.org/x/net v0.28.0 // indirect + golang.org/x/sync v0.8.0 // indirect + golang.org/x/sys v0.24.0 // indirect + golang.org/x/text v0.17.0 // indirect + golang.org/x/tools v0.24.0 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect ) diff --git a/go.sum b/go.sum index 2444374..acf3633 100644 --- a/go.sum +++ b/go.sum @@ -20,8 +20,8 @@ github.com/cloudflare/circl v1.3.9/go.mod h1:PDRU+oXvdD7KCtgKxW95M5Z8BpSCJXQORiZ github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4= github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= -github.com/cyphar/filepath-securejoin v0.3.0 h1:tXpmbiaeBrS/K2US8nhgwdKYnfAOnVfkcLPKFgFHeA0= -github.com/cyphar/filepath-securejoin v0.3.0/go.mod h1:F7i41x/9cBF7lzCrVsYs9fuzwRZm4NQsGTBdpp6mETc= +github.com/cyphar/filepath-securejoin v0.3.1 h1:1V7cHiaW+C+39wEfpH6XlLBQo3j/PciWFrgfCLS8XrE= +github.com/cyphar/filepath-securejoin v0.3.1/go.mod h1:F7i41x/9cBF7lzCrVsYs9fuzwRZm4NQsGTBdpp6mETc= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -92,8 +92,8 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/urfave/cli/v2 v2.27.2 h1:6e0H+AkS+zDckwPCUrZkKX38mRaau4nL2uipkJpbkcI= -github.com/urfave/cli/v2 v2.27.2/go.mod h1:g0+79LmHHATl7DAcHO99smiR/T7uGLw84w8Y42x+4eM= +github.com/urfave/cli/v2 v2.27.3 h1:/POWahRmdh7uztQ3CYnaDddk0Rm90PyOgIxgW2rr41M= +github.com/urfave/cli/v2 v2.27.3/go.mod h1:m4QzxcD2qpra4z7WhzEGn74WZLViBnMpb1ToCAKdGRQ= github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4= @@ -108,12 +108,12 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= -golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= +golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw= +golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.19.0 h1:fEdghXQSo20giMthA7cd28ZC+jts4amQ3YMXiP5oMQ8= -golang.org/x/mod v0.19.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0= +golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= @@ -121,13 +121,13 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= -golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= -golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= +golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= +golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= -golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= +golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -143,15 +143,15 @@ golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= -golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= +golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= -golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk= -golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4= +golang.org/x/term v0.23.0 h1:F6D4vR+EHoL9/sWAWgAR1H2DcHr4PareCbAaCo1RpuU= +golang.org/x/term v0.23.0/go.mod h1:DgV24QBUrK6jhZXl+20l6UWznPlwAHm1Q1mGHtydmSk= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= @@ -159,14 +159,14 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= +golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.23.0 h1:SGsXPZ+2l4JsgaCKkx+FQ9YZ5XEtA1GZYuoDjenLjvg= -golang.org/x/tools v0.23.0/go.mod h1:pnu6ufv6vQkll6szChhK3C3L/ruaIv5eBeztNG8wtsI= +golang.org/x/tools v0.24.0 h1:J1shsA93PJUEVaUSaay7UXAyE8aimq3GW0pjlolpa24= +golang.org/x/tools v0.24.0/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/main.go b/main.go index ddeb5c5..b9bba96 100644 --- a/main.go +++ b/main.go @@ -2,12 +2,12 @@ package main import ( "fmt" - "ghat/src/core" - "ghat/src/version" "os" "sort" "time" + "github.com/jameswoolfenden/ghat/src/core" + "github.com/jameswoolfenden/ghat/src/version" "github.com/rs/zerolog" "github.com/rs/zerolog/log" "github.com/urfave/cli/v2" From b0c160e4b5a131f29d87d12f90a402250f8cafc0 Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Wed, 16 Oct 2024 09:51:45 +0100 Subject: [PATCH 66/80] update mod --- .github/workflows/ci.yml | 4 +- .github/workflows/codeql-analysis.yml | 8 +-- .github/workflows/pr.yml | 10 ++-- .github/workflows/release.yml | 4 +- .pre-commit-config.yaml | 8 +-- go.mod | 26 ++++----- go.sum | 56 +++++++++---------- .../testdata/gha/.github/workflows/test.yml | 2 +- 8 files changed, 59 insertions(+), 59 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0506fbf..8908561 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,7 +31,7 @@ jobs: ## checks out our code locally, so we can work with the files - name: Checkout code - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 ## runs go test ./... - name: Build @@ -42,6 +42,6 @@ jobs: run: go test ./... -coverprofile=./cover.out - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@79066c46f8dcdf8d7355f820dbac958c5b4cb9d3 # v4.5.0 + uses: codecov/codecov-action@0f8570b1a125f4937846a11fcfa3bcd548bd8c97 # v4.6.0 env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 65bca24..cea506d 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -39,11 +39,11 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@064a406de026ea27990a5b507b56911401ca2f95 # codeql-bundle-v2.18.0 + uses: github/codeql-action/init@cf5b0a9041d3c1d336516f1944c96d96598193cc # codeql-bundle-v2.19.1 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -53,7 +53,7 @@ jobs: # 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@064a406de026ea27990a5b507b56911401ca2f95 # codeql-bundle-v2.18.0 + uses: github/codeql-action/autobuild@cf5b0a9041d3c1d336516f1944c96d96598193cc # codeql-bundle-v2.19.1 # â„šī¸ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun @@ -66,4 +66,4 @@ jobs: # ./location_of_script_within_repo/buildscript.sh - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@064a406de026ea27990a5b507b56911401ca2f95 # codeql-bundle-v2.18.0 + uses: github/codeql-action/analyze@cf5b0a9041d3c1d336516f1944c96d96598193cc # codeql-bundle-v2.19.1 diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 23d7557..cbc9b2d 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -8,13 +8,13 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 - name: Install Go uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 with: go-version: 1.21.x - name: Restore cache - uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 + uses: actions/cache@3624ceb22c1c5a301c8db4169662070a689d9ea8 # v4.1.1 with: path: ~/go/pkg/mod key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} @@ -30,13 +30,13 @@ jobs: runs-on: ${{ matrix.platform }} steps: - name: Checkout code - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 - name: Install Go uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 with: go-version: ${{ matrix.go-version }} - name: Restore cache - uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 + uses: actions/cache@3624ceb22c1c5a301c8db4169662070a689d9ea8 # v4.1.1 with: path: ~/go/pkg/mod key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} @@ -48,7 +48,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 - name: Install Go uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index aad42e5..f0b39d1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 - name: Unshallow run: git fetch --prune --unshallow - name: Set up Go @@ -41,7 +41,7 @@ jobs: needs: - goreleaser steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 - name: Publish to Registry uses: elgohr/Publish-Docker-Github-Action@82556589c08f584cb95411629a94e6c2b68b9b80 # v5 with: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2a37b6d..3c823ea 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,7 +15,7 @@ repos: - id: detect-aws-credentials - id: detect-private-key repo: https://github.com/pre-commit/pre-commit-hooks - rev: 2c9f875913ee60ca25ce70243dc24d5b6415598c + rev: cef0300fd0fc4d2a87a85fa2093c6b283ea36f4b - hooks: - id: forbid-tabs exclude: binary|\.bin$|rego|\.rego$|go|\.go$ @@ -36,7 +36,7 @@ repos: - id: markdownlint exclude: src/testdata|testdata repo: https://github.com/igorshubovych/markdownlint-cli - rev: f295829140d25717bc79368d3f966fc1f67a824f + rev: aa975a18c9a869648007d33864034dbc7481fe5e - hooks: - id: terraform-fmt language_version: python3.11 @@ -58,7 +58,7 @@ repos: - hooks: - id: golangci-lint repo: https://github.com/golangci/golangci-lint - rev: 1a55854aff4ef60cd8c4e709b650b281303ca7aa + rev: a1d6c560de1a193a0c68ffed68cd5928ef39e884 - hooks: - id: checkov language_version: python3.12 @@ -66,7 +66,7 @@ repos: - -d - . repo: https://github.com/bridgecrewio/checkov - rev: 76041d8579b178af16e0db9c69b1f7448211626e + rev: f177b202e32c2bf7d28ff00b34bc5d4062a7f13f - hooks: - id: ghat-go name: ghat diff --git a/go.mod b/go.mod index 0c04e05..fb2215b 100644 --- a/go.mod +++ b/go.mod @@ -4,25 +4,25 @@ go 1.22.2 require ( github.com/go-git/go-git/v5 v5.12.0 - github.com/hashicorp/hcl/v2 v2.21.0 + github.com/hashicorp/hcl/v2 v2.22.0 github.com/rs/zerolog v1.33.0 github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 - github.com/urfave/cli/v2 v2.27.2 + github.com/urfave/cli/v2 v2.27.5 github.com/zclconf/go-cty v1.15.0 - golang.org/x/mod v0.19.0 + golang.org/x/mod v0.21.0 gopkg.in/yaml.v3 v3.0.1 moul.io/banner v1.0.1 ) require ( - dario.cat/mergo v1.0.0 // indirect + dario.cat/mergo v1.0.1 // indirect github.com/Microsoft/go-winio v0.6.2 // indirect github.com/ProtonMail/go-crypto v1.0.0 // indirect github.com/agext/levenshtein v1.2.3 // indirect github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect - github.com/cloudflare/circl v1.3.9 // indirect - github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect - github.com/cyphar/filepath-securejoin v0.3.0 // indirect + github.com/cloudflare/circl v1.5.0 // indirect + github.com/cpuguy83/go-md2man/v2 v2.0.5 // indirect + github.com/cyphar/filepath-securejoin v0.3.4 // indirect github.com/emirpasic/gods v1.18.1 // indirect github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect github.com/go-git/go-billy/v5 v5.5.0 // indirect @@ -39,11 +39,11 @@ require ( github.com/skeema/knownhosts v1.3.0 // indirect github.com/xanzy/ssh-agent v0.3.3 // indirect github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect - golang.org/x/crypto v0.25.0 // indirect - golang.org/x/net v0.27.0 // indirect - golang.org/x/sync v0.7.0 // indirect - golang.org/x/sys v0.22.0 // indirect - golang.org/x/text v0.16.0 // indirect - golang.org/x/tools v0.23.0 // indirect + golang.org/x/crypto v0.28.0 // indirect + golang.org/x/net v0.30.0 // indirect + golang.org/x/sync v0.8.0 // indirect + golang.org/x/sys v0.26.0 // indirect + golang.org/x/text v0.19.0 // indirect + golang.org/x/tools v0.26.0 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect ) diff --git a/go.sum b/go.sum index 2444374..91f1ef9 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= -dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= +dario.cat/mergo v1.0.1 h1:Ra4+bf83h2ztPIQYNP99R6m+Y7KfnARDfID+a+vLl4s= +dario.cat/mergo v1.0.1/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= @@ -15,13 +15,13 @@ github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPd github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= -github.com/cloudflare/circl v1.3.9 h1:QFrlgFYf2Qpi8bSpVPK1HBvWpx16v/1TZivyo7pGuBE= -github.com/cloudflare/circl v1.3.9/go.mod h1:PDRU+oXvdD7KCtgKxW95M5Z8BpSCJXQORiZFnBQS5QU= +github.com/cloudflare/circl v1.5.0 h1:hxIWksrX6XN5a1L2TI/h53AGPhNHoUBo+TD1ms9+pys= +github.com/cloudflare/circl v1.5.0/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZh3pJrofs= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= -github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4= -github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= -github.com/cyphar/filepath-securejoin v0.3.0 h1:tXpmbiaeBrS/K2US8nhgwdKYnfAOnVfkcLPKFgFHeA0= -github.com/cyphar/filepath-securejoin v0.3.0/go.mod h1:F7i41x/9cBF7lzCrVsYs9fuzwRZm4NQsGTBdpp6mETc= +github.com/cpuguy83/go-md2man/v2 v2.0.5 h1:ZtcqGrnekaHpVLArFSe4HK5DoKx1T0rq2DwVB0alcyc= +github.com/cpuguy83/go-md2man/v2 v2.0.5/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/cyphar/filepath-securejoin v0.3.4 h1:VBWugsJh2ZxJmLFSM06/0qzQyiQX2Qs0ViKrUAcqdZ8= +github.com/cyphar/filepath-securejoin v0.3.4/go.mod h1:8s/MCNJREmFK0H02MF6Ihv1nakJe4L/w3WZLHNkvlYM= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -46,8 +46,8 @@ github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/hashicorp/hcl/v2 v2.21.0 h1:lve4q/o/2rqwYOgUg3y3V2YPyD1/zkCLGjIV74Jit14= -github.com/hashicorp/hcl/v2 v2.21.0/go.mod h1:62ZYHrXgPoX8xBnzl8QzbWq4dyDsDtfCRgIq1rbJEvA= +github.com/hashicorp/hcl/v2 v2.22.0 h1:hkZ3nCtqeJsDhPRFz5EA9iwcG1hNWGePOTw6oyul12M= +github.com/hashicorp/hcl/v2 v2.22.0/go.mod h1:62ZYHrXgPoX8xBnzl8QzbWq4dyDsDtfCRgIq1rbJEvA= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= @@ -92,8 +92,8 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/urfave/cli/v2 v2.27.2 h1:6e0H+AkS+zDckwPCUrZkKX38mRaau4nL2uipkJpbkcI= -github.com/urfave/cli/v2 v2.27.2/go.mod h1:g0+79LmHHATl7DAcHO99smiR/T7uGLw84w8Y42x+4eM= +github.com/urfave/cli/v2 v2.27.5 h1:WoHEJLdsXr6dDWoJgMq/CboDmyY/8HMMH1fTECbih+w= +github.com/urfave/cli/v2 v2.27.5/go.mod h1:3Sevf16NykTbInEnD0yKkjDAeZDS0A6bzhBH5hrMvTQ= github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4= @@ -108,12 +108,12 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= -golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= +golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw= +golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.19.0 h1:fEdghXQSo20giMthA7cd28ZC+jts4amQ3YMXiP5oMQ8= -golang.org/x/mod v0.19.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0= +golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= @@ -121,13 +121,13 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= -golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= -golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= +golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4= +golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= -golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= +golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -143,15 +143,15 @@ golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= -golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= +golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= -golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk= -golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4= +golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24= +golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= @@ -159,14 +159,14 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= +golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.23.0 h1:SGsXPZ+2l4JsgaCKkx+FQ9YZ5XEtA1GZYuoDjenLjvg= -golang.org/x/tools v0.23.0/go.mod h1:pnu6ufv6vQkll6szChhK3C3L/ruaIv5eBeztNG8wtsI= +golang.org/x/tools v0.26.0 h1:v/60pFQmzmT9ExmjDv2gGIfi3OqfKoEP6I5+umXlbnQ= +golang.org/x/tools v0.26.0/go.mod h1:TPVVj70c7JJ3WCazhD8OdXcZg/og+b9+tH/KxylGwH0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/src/core/testdata/gha/.github/workflows/test.yml b/src/core/testdata/gha/.github/workflows/test.yml index 48402c8..5032826 100644 --- a/src/core/testdata/gha/.github/workflows/test.yml +++ b/src/core/testdata/gha/.github/workflows/test.yml @@ -31,7 +31,7 @@ jobs: ## checks out our code locally, so we can work with the files - name: Checkout code - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 ## runs go test ./... - name: Build From 299aeb5ec546aadd676f53e773ec3c084ef30935 Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Thu, 31 Oct 2024 10:28:12 +0000 Subject: [PATCH 67/80] add version comments to module references --- .github/workflows/ci.yml | 6 +- .github/workflows/codeql-analysis.yml | 8 +-- .github/workflows/pr.yml | 16 ++--- .github/workflows/release.yml | 8 +-- .pre-commit-config.yaml | 10 +-- go.mod | 26 ++++---- go.sum | 62 ++++++++++--------- src/core/modules.go | 31 ++++++++-- src/core/modules_test.go | 41 ++++++++++++ .../testdata/gha/.github/workflows/test.yml | 4 +- 10 files changed, 137 insertions(+), 75 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0506fbf..9be11d1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,13 +25,13 @@ jobs: steps: ## sets up go based on the version - name: Install Go - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 + uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 with: go-version: ${{ matrix.go-version }} ## checks out our code locally, so we can work with the files - name: Checkout code - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 ## runs go test ./... - name: Build @@ -42,6 +42,6 @@ jobs: run: go test ./... -coverprofile=./cover.out - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@79066c46f8dcdf8d7355f820dbac958c5b4cb9d3 # v4.5.0 + uses: codecov/codecov-action@0f8570b1a125f4937846a11fcfa3bcd548bd8c97 # v4.6.0 env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 78aab0f..372f407 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -39,11 +39,11 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@0e346f2c4a1b999b44f1ef93fe08bdb83dae63ab # codeql-bundle-v2.18.1 + uses: github/codeql-action/init@af56b044b5d41c317aef5d19920b3183cb4fbbec # codeql-bundle-v2.19.2 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -53,7 +53,7 @@ jobs: # 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@0e346f2c4a1b999b44f1ef93fe08bdb83dae63ab # codeql-bundle-v2.18.1 + uses: github/codeql-action/autobuild@af56b044b5d41c317aef5d19920b3183cb4fbbec # codeql-bundle-v2.19.2 # â„šī¸ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun @@ -66,4 +66,4 @@ jobs: # ./location_of_script_within_repo/buildscript.sh - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@0e346f2c4a1b999b44f1ef93fe08bdb83dae63ab # codeql-bundle-v2.18.1 + uses: github/codeql-action/analyze@af56b044b5d41c317aef5d19920b3183cb4fbbec # codeql-bundle-v2.19.2 diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 23d7557..209eb53 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -8,13 +8,13 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Install Go - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 + uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 with: go-version: 1.21.x - name: Restore cache - uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 + uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 with: path: ~/go/pkg/mod key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} @@ -30,13 +30,13 @@ jobs: runs-on: ${{ matrix.platform }} steps: - name: Checkout code - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Install Go - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 + uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 with: go-version: ${{ matrix.go-version }} - name: Restore cache - uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 + uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 with: path: ~/go/pkg/mod key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} @@ -48,8 +48,8 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Install Go - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 + uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 with: go-version: 1.21.x diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index aad42e5..c748c87 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,16 +11,16 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Unshallow run: git fetch --prune --unshallow - name: Set up Go - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 + uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 with: go-version: 1.21 - name: Import GPG key id: import_gpg - uses: crazy-max/ghaction-import-gpg@01dd5d3ca463c7f10f7f4f7b4f177225ac661ee4 # v6.1.0 + uses: crazy-max/ghaction-import-gpg@cb9bde2e2525e640591a934b1fd28eef1dcaf5e5 # v6.2.0 with: gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} passphrase: ${{ secrets.PASSPHRASE }} @@ -41,7 +41,7 @@ jobs: needs: - goreleaser steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Publish to Registry uses: elgohr/Publish-Docker-Github-Action@82556589c08f584cb95411629a94e6c2b68b9b80 # v5 with: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9e5ba7d..25dc043 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,7 +15,7 @@ repos: - id: detect-aws-credentials - id: detect-private-key repo: https://github.com/pre-commit/pre-commit-hooks - rev: 2c9f875913ee60ca25ce70243dc24d5b6415598c + rev: cef0300fd0fc4d2a87a85fa2093c6b283ea36f4b - hooks: - id: forbid-tabs exclude: binary|\.bin$|rego|\.rego$|go|\.go$ @@ -36,7 +36,7 @@ repos: - id: markdownlint exclude: src/testdata|testdata repo: https://github.com/igorshubovych/markdownlint-cli - rev: f295829140d25717bc79368d3f966fc1f67a824f + rev: aa975a18c9a869648007d33864034dbc7481fe5e - hooks: - id: terraform-fmt language_version: python3.11 @@ -46,7 +46,7 @@ repos: - id: gofmt - id: goimports repo: https://github.com/gruntwork-io/pre-commit - rev: d0bcdb35c6999a4a120b528f050d2b11778fd3d0 + rev: a2d20160412a9bd26a11ff45987c0e178d7e10c3 - hooks: - id: go-test args: @@ -58,7 +58,7 @@ repos: - hooks: - id: golangci-lint repo: https://github.com/golangci/golangci-lint - rev: 1a55854aff4ef60cd8c4e709b650b281303ca7aa + rev: a1d6c560de1a193a0c68ffed68cd5928ef39e884 - hooks: - id: checkov language_version: python3.11 @@ -66,7 +66,7 @@ repos: - -d - . repo: https://github.com/bridgecrewio/checkov - rev: c81e0929317cba5cec1712168445c021b4ec4f4d + rev: 30c3e8ef39e17ae515875fd83273444a00f6c412 - hooks: - id: ghat-go name: ghat diff --git a/go.mod b/go.mod index 5ef222c..5902701 100644 --- a/go.mod +++ b/go.mod @@ -4,28 +4,28 @@ go 1.22.2 require ( github.com/go-git/go-git/v5 v5.12.0 - github.com/hashicorp/hcl/v2 v2.21.0 + github.com/hashicorp/hcl/v2 v2.22.0 github.com/rs/zerolog v1.33.0 github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 - github.com/urfave/cli/v2 v2.27.3 + github.com/urfave/cli/v2 v2.27.5 github.com/zclconf/go-cty v1.15.0 - golang.org/x/mod v0.20.0 + golang.org/x/mod v0.21.0 gopkg.in/yaml.v3 v3.0.1 moul.io/banner v1.0.1 ) require ( - dario.cat/mergo v1.0.0 // indirect + dario.cat/mergo v1.0.1 // indirect github.com/Microsoft/go-winio v0.6.2 // indirect github.com/ProtonMail/go-crypto v1.0.0 // indirect github.com/agext/levenshtein v1.2.3 // indirect github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect - github.com/cloudflare/circl v1.3.9 // indirect - github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect - github.com/cyphar/filepath-securejoin v0.3.1 // indirect + github.com/cloudflare/circl v1.5.0 // indirect + github.com/cpuguy83/go-md2man/v2 v2.0.5 // indirect + github.com/cyphar/filepath-securejoin v0.3.4 // indirect github.com/emirpasic/gods v1.18.1 // indirect github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect - github.com/go-git/go-billy/v5 v5.5.0 // indirect + github.com/go-git/go-billy/v5 v5.6.0 // indirect github.com/go-test/deep v1.1.0 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/google/go-cmp v0.6.0 // indirect @@ -39,11 +39,11 @@ require ( github.com/skeema/knownhosts v1.3.0 // indirect github.com/xanzy/ssh-agent v0.3.3 // indirect github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect - golang.org/x/crypto v0.26.0 // indirect - golang.org/x/net v0.28.0 // indirect + golang.org/x/crypto v0.28.0 // indirect + golang.org/x/net v0.30.0 // indirect golang.org/x/sync v0.8.0 // indirect - golang.org/x/sys v0.24.0 // indirect - golang.org/x/text v0.17.0 // indirect - golang.org/x/tools v0.24.0 // indirect + golang.org/x/sys v0.26.0 // indirect + golang.org/x/text v0.19.0 // indirect + golang.org/x/tools v0.26.0 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect ) diff --git a/go.sum b/go.sum index acf3633..7891fa3 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= -dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= +dario.cat/mergo v1.0.1 h1:Ra4+bf83h2ztPIQYNP99R6m+Y7KfnARDfID+a+vLl4s= +dario.cat/mergo v1.0.1/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= @@ -15,13 +15,13 @@ github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPd github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= -github.com/cloudflare/circl v1.3.9 h1:QFrlgFYf2Qpi8bSpVPK1HBvWpx16v/1TZivyo7pGuBE= -github.com/cloudflare/circl v1.3.9/go.mod h1:PDRU+oXvdD7KCtgKxW95M5Z8BpSCJXQORiZFnBQS5QU= +github.com/cloudflare/circl v1.5.0 h1:hxIWksrX6XN5a1L2TI/h53AGPhNHoUBo+TD1ms9+pys= +github.com/cloudflare/circl v1.5.0/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZh3pJrofs= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= -github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4= -github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= -github.com/cyphar/filepath-securejoin v0.3.1 h1:1V7cHiaW+C+39wEfpH6XlLBQo3j/PciWFrgfCLS8XrE= -github.com/cyphar/filepath-securejoin v0.3.1/go.mod h1:F7i41x/9cBF7lzCrVsYs9fuzwRZm4NQsGTBdpp6mETc= +github.com/cpuguy83/go-md2man/v2 v2.0.5 h1:ZtcqGrnekaHpVLArFSe4HK5DoKx1T0rq2DwVB0alcyc= +github.com/cpuguy83/go-md2man/v2 v2.0.5/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/cyphar/filepath-securejoin v0.3.4 h1:VBWugsJh2ZxJmLFSM06/0qzQyiQX2Qs0ViKrUAcqdZ8= +github.com/cyphar/filepath-securejoin v0.3.4/go.mod h1:8s/MCNJREmFK0H02MF6Ihv1nakJe4L/w3WZLHNkvlYM= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -33,8 +33,8 @@ github.com/gliderlabs/ssh v0.3.7 h1:iV3Bqi942d9huXnzEF2Mt+CY9gLu8DNM4Obd+8bODRE= github.com/gliderlabs/ssh v0.3.7/go.mod h1:zpHEXBstFnQYtGnB8k8kQLol82umzn/2/snG7alWVD8= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic= -github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+mTU= -github.com/go-git/go-billy/v5 v5.5.0/go.mod h1:hmexnoNsr2SJU1Ju67OaNz5ASJY3+sHgFRpCtpDCKow= +github.com/go-git/go-billy/v5 v5.6.0 h1:w2hPNtoehvJIxR00Vb4xX94qHQi/ApZfX+nBE2Cjio8= +github.com/go-git/go-billy/v5 v5.6.0/go.mod h1:sFDq7xD3fn3E0GOwUSZqHo9lrkmx8xJhA0ZrfvjBRGM= github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399 h1:eMje31YglSBqCdIqdhKBW8lokaMrL3uTkpGYlE2OOT4= github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399/go.mod h1:1OCfN199q1Jm3HZlxleg+Dw/mwps2Wbk9frAWm+4FII= github.com/go-git/go-git/v5 v5.12.0 h1:7Md+ndsjrzZxbddRDZjF14qK+NN56sy6wkqaVrjZtys= @@ -46,8 +46,8 @@ github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/hashicorp/hcl/v2 v2.21.0 h1:lve4q/o/2rqwYOgUg3y3V2YPyD1/zkCLGjIV74Jit14= -github.com/hashicorp/hcl/v2 v2.21.0/go.mod h1:62ZYHrXgPoX8xBnzl8QzbWq4dyDsDtfCRgIq1rbJEvA= +github.com/hashicorp/hcl/v2 v2.22.0 h1:hkZ3nCtqeJsDhPRFz5EA9iwcG1hNWGePOTw6oyul12M= +github.com/hashicorp/hcl/v2 v2.22.0/go.mod h1:62ZYHrXgPoX8xBnzl8QzbWq4dyDsDtfCRgIq1rbJEvA= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= @@ -67,8 +67,8 @@ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWE github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= -github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= -github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M= +github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k= +github.com/onsi/gomega v1.34.1/go.mod h1:kU1QgUvBDLXBJq618Xvm2LUX6rSAfRaFRTcdOeDLwwY= github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4= github.com/pjbgf/sha1cd v0.3.0/go.mod h1:nZ1rrWOcGJ5uZgEEVL1VUM9iRQiZvWdbZjkKyFzPPsI= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -92,8 +92,8 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/urfave/cli/v2 v2.27.3 h1:/POWahRmdh7uztQ3CYnaDddk0Rm90PyOgIxgW2rr41M= -github.com/urfave/cli/v2 v2.27.3/go.mod h1:m4QzxcD2qpra4z7WhzEGn74WZLViBnMpb1ToCAKdGRQ= +github.com/urfave/cli/v2 v2.27.5 h1:WoHEJLdsXr6dDWoJgMq/CboDmyY/8HMMH1fTECbih+w= +github.com/urfave/cli/v2 v2.27.5/go.mod h1:3Sevf16NykTbInEnD0yKkjDAeZDS0A6bzhBH5hrMvTQ= github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4= @@ -108,12 +108,14 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw= -golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= +golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw= +golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U= +golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8= +golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0= -golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0= +golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= @@ -121,8 +123,8 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= -golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= -golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= +golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4= +golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -143,15 +145,15 @@ golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= -golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= +golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= -golang.org/x/term v0.23.0 h1:F6D4vR+EHoL9/sWAWgAR1H2DcHr4PareCbAaCo1RpuU= -golang.org/x/term v0.23.0/go.mod h1:DgV24QBUrK6jhZXl+20l6UWznPlwAHm1Q1mGHtydmSk= +golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24= +golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= @@ -159,14 +161,14 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= -golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= +golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.24.0 h1:J1shsA93PJUEVaUSaay7UXAyE8aimq3GW0pjlolpa24= -golang.org/x/tools v0.24.0/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ= +golang.org/x/tools v0.26.0 h1:v/60pFQmzmT9ExmjDv2gGIfi3OqfKoEP6I5+umXlbnQ= +golang.org/x/tools v0.26.0/go.mod h1:TPVVj70c7JJ3WCazhD8OdXcZg/og+b9+tH/KxylGwH0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/src/core/modules.go b/src/core/modules.go index 598a46f..3237ae6 100644 --- a/src/core/modules.go +++ b/src/core/modules.go @@ -19,6 +19,9 @@ import ( func (myFlags *Flags) UpdateModule(file string) error { + var version string + var newValue string + src, err := os.ReadFile(file) if err != nil { return fmt.Errorf("failed to read %s", file) @@ -32,7 +35,7 @@ func (myFlags *Flags) UpdateModule(file string) error { for _, block := range root.Blocks() { if block.Type() == "module" { - version := GetVersion(block) + version = GetVersion(block) source := GetStringValue(block, "source") @@ -43,7 +46,7 @@ func (myFlags *Flags) UpdateModule(file string) error { if err != nil { log.Info().Msgf("source type failure %s", source) } else { - newValue, _, err := myFlags.UpdateSource(source, myType, version) + newValue, version, err = myFlags.UpdateSource(source, myType, version) if err != nil { log.Info().Msgf("failed to update module source %s", err) } @@ -56,21 +59,37 @@ func (myFlags *Flags) UpdateModule(file string) error { var differ bool - temp := outFile.Bytes() + temp := string(outFile.Bytes()) + + if version != "" { + find := "\"" + newValue + "\"" + replacement := " source = " + find + " #" + version + + lines := strings.Split(temp, "\n") + + for i, line := range lines { + if strings.Contains(line, find) { + lines[i] = replacement + break + } + } + + temp = strings.Join(lines, "\n") + } - if string(src) != string(temp) { + if string(src) != temp { differ = true } dmp := diffmatchpatch.New() - diffs := dmp.DiffMain(string(src), string(temp), false) + diffs := dmp.DiffMain(string(src), temp, false) if differ { fmt.Println(dmp.DiffPrettyText(diffs)) } if differ && !myFlags.DryRun { - err := os.WriteFile(file, outFile.Bytes(), 0666) + err := os.WriteFile(file, []byte(temp), 0666) if err != nil { log.Info().Msgf("failed to write %s", file) } diff --git a/src/core/modules_test.go b/src/core/modules_test.go index 02650a4..c021a94 100644 --- a/src/core/modules_test.go +++ b/src/core/modules_test.go @@ -304,3 +304,44 @@ func TestFlags_UpdateGithubSource(t *testing.T) { }) } } + +func TestFlags_UpdateModule(t *testing.T) { + type fields struct { + File string + Directory string + GitHubToken string + Days int + DryRun bool + Entries []string + Update bool + ContinueOnError bool + } + type args struct { + file string + } + tests := []struct { + name string + fields fields + args args + wantErr bool + }{ + {"add version", fields{Update: true}, args{"testdata/modules/github-git/module.tf"}, false}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + myFlags := &Flags{ + File: tt.fields.File, + Directory: tt.fields.Directory, + GitHubToken: tt.fields.GitHubToken, + Days: tt.fields.Days, + DryRun: tt.fields.DryRun, + Entries: tt.fields.Entries, + Update: tt.fields.Update, + ContinueOnError: tt.fields.ContinueOnError, + } + if err := myFlags.UpdateModule(tt.args.file); (err != nil) != tt.wantErr { + t.Errorf("UpdateModule() error = %v, wantErr %v", err, tt.wantErr) + } + }) + } +} diff --git a/src/core/testdata/gha/.github/workflows/test.yml b/src/core/testdata/gha/.github/workflows/test.yml index 48402c8..7704a4f 100644 --- a/src/core/testdata/gha/.github/workflows/test.yml +++ b/src/core/testdata/gha/.github/workflows/test.yml @@ -25,13 +25,13 @@ jobs: steps: ## sets up go based on the version - name: Install Go - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 + uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 with: go-version: ${{ matrix.go-version }} ## checks out our code locally, so we can work with the files - name: Checkout code - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 ## runs go test ./... - name: Build From f95f97426f51705bb5999df6cff99f7770157836 Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Mon, 18 Nov 2024 09:35:36 +0000 Subject: [PATCH 68/80] ghatted workflows --- .github/workflows/ci.yml | 2 +- .github/workflows/codeql-analysis.yml | 6 +- .github/workflows/release.yml | 2 +- .pre-commit-config.yaml | 4 +- go.mod | 16 +- go.sum | 74 ++----- src/core/action.go | 55 +++-- src/core/action_test.go | 85 +++++++- src/core/error.go | 73 +++++++ src/core/error_test.go | 191 ++++++++++++++++++ src/core/filter.go | 23 ++- src/core/gha.go | 36 ++-- src/core/pre-commit.go | 18 +- src/core/registry.go | 40 +++- .../testdata/modules/github-git/module.tf | 2 +- 15 files changed, 513 insertions(+), 114 deletions(-) create mode 100644 src/core/error.go create mode 100644 src/core/error_test.go diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9be11d1..c0e30a5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,6 +42,6 @@ jobs: run: go test ./... -coverprofile=./cover.out - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@0f8570b1a125f4937846a11fcfa3bcd548bd8c97 # v4.6.0 + uses: codecov/codecov-action@a2f73fb6db51fcd2e0aa085dfb36dea90c5e3689 # v5.0.2 env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 372f407..1563b48 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -43,7 +43,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@af56b044b5d41c317aef5d19920b3183cb4fbbec # codeql-bundle-v2.19.2 + uses: github/codeql-action/init@cbe18979603527f12c7871a6eb04833ecf1548c7 # codeql-bundle-v2.19.3 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -53,7 +53,7 @@ jobs: # 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@af56b044b5d41c317aef5d19920b3183cb4fbbec # codeql-bundle-v2.19.2 + uses: github/codeql-action/autobuild@cbe18979603527f12c7871a6eb04833ecf1548c7 # codeql-bundle-v2.19.3 # â„šī¸ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun @@ -66,4 +66,4 @@ jobs: # ./location_of_script_within_repo/buildscript.sh - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@af56b044b5d41c317aef5d19920b3183cb4fbbec # codeql-bundle-v2.19.2 + uses: github/codeql-action/analyze@cbe18979603527f12c7871a6eb04833ecf1548c7 # codeql-bundle-v2.19.3 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c748c87..11b8991 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,7 +25,7 @@ jobs: gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} passphrase: ${{ secrets.PASSPHRASE }} - name: Run GoReleaser - uses: goreleaser/goreleaser-action@286f3b13b1b49da4ac219696163fb8c1c93e1200 # v6.0.0 + uses: goreleaser/goreleaser-action@9ed2f89a662bf1735a48bc8557fd212fa902bebf # v6.1.0 with: version: latest args: release --clean diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 25dc043..80a5bb8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -58,7 +58,7 @@ repos: - hooks: - id: golangci-lint repo: https://github.com/golangci/golangci-lint - rev: a1d6c560de1a193a0c68ffed68cd5928ef39e884 + rev: 22b58c9b648f027d699f305c069a2a97ed0c5b06 - hooks: - id: checkov language_version: python3.11 @@ -66,7 +66,7 @@ repos: - -d - . repo: https://github.com/bridgecrewio/checkov - rev: 30c3e8ef39e17ae515875fd83273444a00f6c412 + rev: e66e08456de4c7f0c2d8ad2b3f2ab9df0999073f - hooks: - id: ghat-go name: ghat diff --git a/go.mod b/go.mod index 5902701..3a019c4 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 github.com/urfave/cli/v2 v2.27.5 github.com/zclconf/go-cty v1.15.0 - golang.org/x/mod v0.21.0 + golang.org/x/mod v0.22.0 gopkg.in/yaml.v3 v3.0.1 moul.io/banner v1.0.1 ) @@ -17,7 +17,7 @@ require ( require ( dario.cat/mergo v1.0.1 // indirect github.com/Microsoft/go-winio v0.6.2 // indirect - github.com/ProtonMail/go-crypto v1.0.0 // indirect + github.com/ProtonMail/go-crypto v1.1.2 // indirect github.com/agext/levenshtein v1.2.3 // indirect github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect github.com/cloudflare/circl v1.5.0 // indirect @@ -39,11 +39,11 @@ require ( github.com/skeema/knownhosts v1.3.0 // indirect github.com/xanzy/ssh-agent v0.3.3 // indirect github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect - golang.org/x/crypto v0.28.0 // indirect - golang.org/x/net v0.30.0 // indirect - golang.org/x/sync v0.8.0 // indirect - golang.org/x/sys v0.26.0 // indirect - golang.org/x/text v0.19.0 // indirect - golang.org/x/tools v0.26.0 // indirect + golang.org/x/crypto v0.29.0 // indirect + golang.org/x/net v0.31.0 // indirect + golang.org/x/sync v0.9.0 // indirect + golang.org/x/sys v0.27.0 // indirect + golang.org/x/text v0.20.0 // indirect + golang.org/x/tools v0.27.0 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect ) diff --git a/go.sum b/go.sum index 7891fa3..2cd8788 100644 --- a/go.sum +++ b/go.sum @@ -3,8 +3,8 @@ dario.cat/mergo v1.0.1/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= -github.com/ProtonMail/go-crypto v1.0.0 h1:LRuvITjQWX+WIfr930YHG2HNfjR1uOfyf5vE0kC2U78= -github.com/ProtonMail/go-crypto v1.0.0/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= +github.com/ProtonMail/go-crypto v1.1.2 h1:A7JbD57ThNqh7XjmHE+PXpQ3Dqt3BrSAC0AL0Go3KS0= +github.com/ProtonMail/go-crypto v1.1.2/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE= github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8= @@ -13,8 +13,6 @@ github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= -github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= -github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= github.com/cloudflare/circl v1.5.0 h1:hxIWksrX6XN5a1L2TI/h53AGPhNHoUBo+TD1ms9+pys= github.com/cloudflare/circl v1.5.0/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZh3pJrofs= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= @@ -98,78 +96,42 @@ github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4= github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/zclconf/go-cty v1.15.0 h1:tTCRWxsexYUmtt/wVxgDClUe+uQusuI443uL6e+5sXQ= github.com/zclconf/go-cty v1.15.0/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940 h1:4r45xpDWB6ZMSMNJFMOjqrGHynW3DIBuR2H9j0ug+Mo= github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940/go.mod h1:CmBdvvj3nqzfzJ6nTCIwDTPZ56aVGvDrmztiO5g3qrM= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= -golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw= -golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U= +golang.org/x/crypto v0.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ= +golang.org/x/crypto v0.29.0/go.mod h1:+F4F4N5hv6v38hfeYwTdx20oUvLLc+QfrE9Ax9HtgRg= golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8= golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0= -golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4= +golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= -golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= -golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4= -golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= -golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo= +golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM= +golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ= +golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= -golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s= +golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= -golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= -golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24= -golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/term v0.26.0 h1:WEQa6V3Gja/BhNxg540hBip/kkaYtRg3cxg4oXSw4AU= +golang.org/x/term v0.26.0/go.mod h1:Si5m1o57C5nBNQo5z1iq+XDijt21BDBDp2bK0QI8e3E= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= -golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug= +golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.26.0 h1:v/60pFQmzmT9ExmjDv2gGIfi3OqfKoEP6I5+umXlbnQ= -golang.org/x/tools v0.26.0/go.mod h1:TPVVj70c7JJ3WCazhD8OdXcZg/og+b9+tH/KxylGwH0= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/tools v0.27.0 h1:qEKojBykQkQ4EynWy4S8Weg69NumxKdn40Fce3uc/8o= +golang.org/x/tools v0.27.0/go.mod h1:sUi0ZgbwW9ZPAq26Ekut+weQPR5eIM6GQLQ1Yjm1H0Q= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= diff --git a/src/core/action.go b/src/core/action.go index 7ff8dfc..72c9f11 100644 --- a/src/core/action.go +++ b/src/core/action.go @@ -1,17 +1,29 @@ package core import ( - "fmt" "os" "path/filepath" ) -func (myFlags *Flags) Action(Action string) error { +const ( + ActionSwipe = "swipe" + ActionSwot = "swot" + ActionSift = "sift" +) + +func (myFlags *Flags) Action(action string) error { var err error + if action == "" { + return &actionIsEmptyError{} + } + if myFlags.File != "" { if _, err := os.Stat(myFlags.File); err != nil { - pwd, _ := os.Getwd() + pwd, err := os.Getwd() + if err != nil { + return &workingDirectoryError{pwd} + } myFlags.File = filepath.Join(pwd, myFlags.File) } @@ -20,20 +32,35 @@ func (myFlags *Flags) Action(Action string) error { myFlags.Entries, err = GetFiles(myFlags.Directory) if err != nil { - return fmt.Errorf("action failed to read %s", myFlags.Directory) + return &directoryReadError{myFlags.Directory} } } - switch Action { - case "swipe": - { - if myFlags.File != "" { - return myFlags.UpdateModule(myFlags.File) - } else { - return myFlags.UpdateModules() - } + err = executeAction(action, myFlags) + if err != nil { + return &executeActionError{action} + } + + return nil +} + +func executeAction(action string, myFlags *Flags) error { + if myFlags == nil { + return &actionIsEmptyError{} + } + + if myFlags.File == "" && myFlags.Directory == "" { + return &dirAndFileEmptyError{} + } + + switch action { + case ActionSwipe: + if myFlags.File != "" { + return myFlags.UpdateModule(myFlags.File) + } else { + return myFlags.UpdateModules() } - case "swot": + case ActionSwot: { if myFlags.File != "" { return myFlags.UpdateGHA(myFlags.File) @@ -41,7 +68,7 @@ func (myFlags *Flags) Action(Action string) error { return myFlags.UpdateGHAS() } } - case "sift": + case ActionSift: { return myFlags.UpdateHooks() } diff --git a/src/core/action_test.go b/src/core/action_test.go index 4a73307..c4fab34 100644 --- a/src/core/action_test.go +++ b/src/core/action_test.go @@ -37,11 +37,11 @@ func TestFlags_Action(t *testing.T) { args args wantErr bool }{ - {"Pass", dir, args{}, false}, + {"Pass", dir, args{}, true}, {"Bogus", bogus, args{}, true}, {"Empty swot", empty, args{"swot"}, true}, {"Empty swipe", empty, args{"swipe"}, true}, - {"dirDry", dirDry, args{}, false}, + {"dirDry", dirDry, args{}, true}, {"file swipe", file, args{"swipe"}, false}, {"file swot", fileGHA, args{"swot"}, false}, {"file swot empty", dirDry, args{"swot"}, false}, @@ -69,3 +69,84 @@ func TestFlags_Action(t *testing.T) { }) } } + +func TestExecuteAction(t *testing.T) { + t.Parallel() + type args struct { + action string + myFlags *Flags + } + + tests := []struct { + name string + args args + wantErr bool + }{ + { + name: "Unknown action type", + args: args{ + action: "unknown", + myFlags: &Flags{ + File: "", + Directory: "testdata/files/", + GitHubToken: gitHubToken, + }, + }, + wantErr: false, + }, + { + name: "Swipe with nil flags", + args: args{ + action: ActionSwipe, + myFlags: nil, + }, + wantErr: true, + }, + { + name: "Swot with empty file and directory", + args: args{ + action: ActionSwot, + myFlags: &Flags{ + File: "", + Directory: "", + GitHubToken: "", + }, + }, + wantErr: true, + }, + { + name: "Sift with missing GitHub token", + args: args{ + action: ActionSift, + myFlags: &Flags{ + File: "", + Directory: "testdata/files/", + GitHubToken: "", + }, + }, + wantErr: true, + }, + { + name: "Swipe with invalid file path format", + args: args{ + action: ActionSwipe, + myFlags: &Flags{ + File: "///", + Directory: "testdata/files/", + GitHubToken: gitHubToken, + }, + }, + wantErr: true, + }, + } + + for _, tt := range tests { + tt := tt + t.Run(tt.name, func(t *testing.T) { + t.Parallel() + if err := executeAction(tt.args.action, tt.args.myFlags); (err != nil) != tt.wantErr { + t.Errorf("executeAction() error = %v, wantErr %v", err, tt.wantErr) + } + }) + } +} diff --git a/src/core/error.go b/src/core/error.go new file mode 100644 index 0000000..6f282d3 --- /dev/null +++ b/src/core/error.go @@ -0,0 +1,73 @@ +package core + +import "fmt" + +type actionIsEmptyError struct { +} + +func (m *actionIsEmptyError) Error() string { + return "action is empty" +} + +type directoryReadError struct { + directory string +} + +func (m *directoryReadError) Error() string { + return fmt.Sprintf("action failed to read %s", m.directory) +} + +type workingDirectoryError struct { + directory string +} + +func (m *workingDirectoryError) Error() string { + return fmt.Sprintf("failed to get working directory: %s", m.directory) +} + +type executeActionError struct { + action string +} + +func (m *executeActionError) Error() string { + return fmt.Sprintf("failed to execute action: %s", m.action) +} + +type dirAndFileEmptyError struct { +} + +func (m *dirAndFileEmptyError) Error() string { + return "file and directory are empty" +} + +type ghaUpdateError struct { + gha string +} + +func (m *ghaUpdateError) Error() string { + return fmt.Sprintf("GHA update error %s", m.gha) +} + +type ghaFileError struct { + file string +} + +func (m *ghaFileError) Error() string { + return fmt.Sprintf("GHA file error %s", m.file) +} + +type castToMapError struct { + object string +} + +func (m *castToMapError) Error() string { + return fmt.Sprintf("failed to cast %s to map[string]interface{}", m.object) +} + +type writeGHAError struct { + gha string +} + +func (m *writeGHAError) Error() string { + return fmt.Sprintf("failed to write GHA %s", m.gha) +} diff --git a/src/core/error_test.go b/src/core/error_test.go new file mode 100644 index 0000000..bd3e24f --- /dev/null +++ b/src/core/error_test.go @@ -0,0 +1,191 @@ +package core + +import ( + "testing" +) + +func TestActionIsEmptyError(t *testing.T) { + t.Parallel() + err := &actionIsEmptyError{} + expected := "action is empty" + if err.Error() != expected { + t.Errorf("Expected error message '%s', got '%s'", expected, err.Error()) + } +} + +func TestDirectoryReadError(t *testing.T) { + t.Parallel() + testCases := []struct { + name string + directory string + expected string + }{ + {"Empty directory", "", "action failed to read "}, + {"Valid directory", "/test/dir", "action failed to read /test/dir"}, + {"Relative path", "./relative", "action failed to read ./relative"}, + } + + for _, tc := range testCases { + tc := tc + t.Run(tc.name, func(t *testing.T) { + t.Parallel() + err := &directoryReadError{directory: tc.directory} + if err.Error() != tc.expected { + t.Errorf("Expected error message '%s', got '%s'", tc.expected, err.Error()) + } + }) + } +} + +func TestWorkingDirectoryError(t *testing.T) { + t.Parallel() + testCases := []struct { + name string + directory string + expected string + }{ + {"Empty directory", "", "failed to get working directory: "}, + {"Valid directory", "/home/user", "failed to get working directory: /home/user"}, + {"Windows path", "C:\\Users\\test", "failed to get working directory: C:\\Users\\test"}, + } + + for _, tc := range testCases { + tc := tc + t.Run(tc.name, func(t *testing.T) { + t.Parallel() + err := &workingDirectoryError{directory: tc.directory} + if err.Error() != tc.expected { + t.Errorf("Expected error message '%s', got '%s'", tc.expected, err.Error()) + } + }) + } +} + +func TestExecuteActionError(t *testing.T) { + t.Parallel() + testCases := []struct { + name string + action string + expected string + }{ + {"Empty action", "", "failed to execute action: "}, + {"Simple action", "build", "failed to execute action: build"}, + {"Complex action", "deploy --force --env=prod", "failed to execute action: deploy --force --env=prod"}, + } + + for _, tc := range testCases { + tc := tc + t.Run(tc.name, func(t *testing.T) { + t.Parallel() + err := &executeActionError{action: tc.action} + if err.Error() != tc.expected { + t.Errorf("Expected error message '%s', got '%s'", tc.expected, err.Error()) + } + }) + } +} + +func TestDirAndFileEmptyError(t *testing.T) { + t.Parallel() + err := &dirAndFileEmptyError{} + expected := "file and directory are empty" + if err.Error() != expected { + t.Errorf("Expected error message '%s', got '%s'", expected, err.Error()) + } +} + +func TestGHAUpdateError(t *testing.T) { + t.Parallel() + testCases := []struct { + name string + gha string + expected string + }{ + {"Empty GHA", "", "GHA update error "}, + {"Valid GHA", "workflow.yml", "GHA update error workflow.yml"}, + {"Path GHA", ".github/workflows/test.yml", "GHA update error .github/workflows/test.yml"}, + } + + for _, tc := range testCases { + tc := tc + t.Run(tc.name, func(t *testing.T) { + t.Parallel() + err := &ghaUpdateError{gha: tc.gha} + if err.Error() != tc.expected { + t.Errorf("Expected error message '%s', got '%s'", tc.expected, err.Error()) + } + }) + } +} + +func TestGHAFileError(t *testing.T) { + t.Parallel() + testCases := []struct { + name string + file string + expected string + }{ + {"Empty file", "", "GHA file error "}, + {"Simple file", "main.yml", "GHA file error main.yml"}, + {"Nested file", "workflows/deploy.yml", "GHA file error workflows/deploy.yml"}, + } + + for _, tc := range testCases { + tc := tc + t.Run(tc.name, func(t *testing.T) { + t.Parallel() + err := &ghaFileError{file: tc.file} + if err.Error() != tc.expected { + t.Errorf("Expected error message '%s', got '%s'", tc.expected, err.Error()) + } + }) + } +} + +func TestCastToMapError(t *testing.T) { + t.Parallel() + testCases := []struct { + name string + object string + expected string + }{ + {"Empty object", "", "failed to cast to map[string]interface{}"}, + {"Simple object", "config", "failed to cast config to map[string]interface{}"}, + {"Complex object", "workflow.settings", "failed to cast workflow.settings to map[string]interface{}"}, + } + + for _, tc := range testCases { + tc := tc + t.Run(tc.name, func(t *testing.T) { + t.Parallel() + err := &castToMapError{object: tc.object} + if err.Error() != tc.expected { + t.Errorf("Expected error message '%s', got '%s'", tc.expected, err.Error()) + } + }) + } +} + +func TestWriteGHAError(t *testing.T) { + t.Parallel() + testCases := []struct { + name string + gha string + expected string + }{ + {"Empty GHA", "", "failed to write GHA "}, + {"Simple GHA", "ci.yml", "failed to write GHA ci.yml"}, + {"Full path GHA", ".github/workflows/release.yml", "failed to write GHA .github/workflows/release.yml"}, + } + + for _, tc := range testCases { + tc := tc + t.Run(tc.name, func(t *testing.T) { + t.Parallel() + err := &writeGHAError{gha: tc.gha} + if err.Error() != tc.expected { + t.Errorf("Expected error message '%s', got '%s'", tc.expected, err.Error()) + } + }) + } +} diff --git a/src/core/filter.go b/src/core/filter.go index 8742e3a..f7a2e05 100644 --- a/src/core/filter.go +++ b/src/core/filter.go @@ -1,11 +1,21 @@ package core import ( + "errors" "fmt" "time" ) func GetReleases(action string, gitHubToken string, days *int) (map[string]interface{}, error) { + + if gitHubToken == "" { + return nil, fmt.Errorf("github token is empty") + } + + if action == "" { + return nil, fmt.Errorf("action is empty") + } + now := time.Now() interval := time.Duration(*days * 24 * 60 * 60 * 1000 * 1000 * 1000) limit := now.Add(-interval) @@ -25,9 +35,18 @@ func GetReleases(action string, gitHubToken string, days *int) (map[string]inter for _, body := range bodies { release := body.(map[string]interface{}) - temp := release["published_at"].(string) + temp, ok := release["published_at"].(string) + + if !ok { + return nil, errors.New("failed to assert published_at as a string") + } + + released, err := time.Parse(time.RFC3339, temp) + + if err != nil { + return nil, fmt.Errorf("failed to parse time %w", err) + } - released, _ := time.Parse(time.RFC3339, temp) if released.Before(limit) { return release, nil } diff --git a/src/core/gha.go b/src/core/gha.go index 3d9ae95..e7da7fb 100644 --- a/src/core/gha.go +++ b/src/core/gha.go @@ -2,7 +2,6 @@ package core import ( "encoding/json" - "errors" "fmt" "io" "net/http" @@ -10,11 +9,19 @@ import ( "path/filepath" "regexp" "strings" + "time" "github.com/rs/zerolog/log" "github.com/sergi/go-diff/diffmatchpatch" ) +const ( + githubWorkflowPath = ".github/workflows" + terraformDir = ".terraform" + yamlExtension = ".yml" + yamlAltExtension = ".yaml" +) + func GetFiles(dir string) ([]string, error) { Entries, err := os.ReadDir(dir) if err != nil { @@ -24,14 +31,17 @@ func GetFiles(dir string) ([]string, error) { var ParsedEntries []string for _, entry := range Entries { - AbsDir, _ := filepath.Abs(dir) + AbsDir, err := filepath.Abs(dir) + if err != nil { + return nil, fmt.Errorf("failed to get absolute path: %w", err) + } gitDir := filepath.Join(AbsDir, ".git") if entry.IsDir() { newDir := filepath.Join(AbsDir, entry.Name()) - if !(strings.Contains(newDir, ".terraform")) && newDir != gitDir { + if !(strings.Contains(newDir, terraformDir)) && newDir != gitDir { newEntries, err := GetFiles(newDir) if err != nil { @@ -42,7 +52,7 @@ func GetFiles(dir string) ([]string, error) { } } else { myFile := filepath.Join(dir, entry.Name()) - if !(strings.Contains(myFile, ".terraform")) { + if !(strings.Contains(myFile, terraformDir)) { ParsedEntries = append(ParsedEntries, myFile) } } @@ -59,7 +69,7 @@ func (myFlags *Flags) UpdateGHAS() error { err = myFlags.UpdateGHA(gha) if err != nil { - return fmt.Errorf("failed to update %s", gha) + return &ghaUpdateError{gha} } } @@ -70,13 +80,11 @@ func (myFlags *Flags) UpdateGHAS() error { func (myFlags *Flags) GetGHA() []string { var ghat []string - gitHubPath := filepath.Join(".github", "workflows") - for _, match := range myFlags.Entries { match, _ = filepath.Abs(match) entry, _ := os.Stat(match) - if strings.Contains(match, gitHubPath) && !entry.IsDir() { - if strings.Contains(match, ".yml") || (strings.Contains(match, ".yaml")) { + if strings.Contains(match, githubWorkflowPath) && !entry.IsDir() { + if strings.Contains(match, yamlExtension) || (strings.Contains(match, yamlAltExtension)) { ghat = append(ghat, match) } } @@ -89,7 +97,7 @@ func (myFlags *Flags) GetGHA() []string { func (myFlags *Flags) UpdateGHA(file string) error { buffer, err := os.ReadFile(file) if err != nil { - return fmt.Errorf("failed to open file %w", err) + return &ghaFileError{file} } replacement := string(buffer) @@ -126,7 +134,7 @@ func (myFlags *Flags) UpdateGHA(file string) error { msg, ok := body.(map[string]interface{}) if !ok { - return errors.New("failed to assert map[string]interface{}") + return &castToMapError{"body"} } if msg["tag_name"] != nil { @@ -182,7 +190,7 @@ func (myFlags *Flags) UpdateGHA(file string) error { err = os.WriteFile(file, newBuffer, 0644) if err != nil { - return fmt.Errorf("failed to write err %w", err) + return &writeGHAError{file} } } @@ -230,7 +238,9 @@ func GetGithubBody(gitHubToken string, url string) (interface{}, error) { } req.Header.Add("Authorization", "Bearer "+gitHubToken) - client := &http.Client{} + client := &http.Client{ + Timeout: time.Second * 30} + resp, err := client.Do(req) if resp == nil { diff --git a/src/core/pre-commit.go b/src/core/pre-commit.go index 14c631c..da57621 100644 --- a/src/core/pre-commit.go +++ b/src/core/pre-commit.go @@ -46,6 +46,13 @@ type ConfigFile struct { Repos []Repo `yaml:"repos"` } +// Add constants for repeated values +const ( + PreCommitConfigFile = ".pre-commit-config.yaml" + GitHubPrefix = "https://github.com/" + FilePermissions = 0666 +) + func (myFlags *Flags) UpdateHooks() error { var config *string var err error @@ -54,7 +61,10 @@ func (myFlags *Flags) UpdateHooks() error { return err } - data, _ := os.ReadFile(*config) + data, err := os.ReadFile(*config) + if err != nil { + return fmt.Errorf("failed to read config file: %w", err) + } var m ConfigFile @@ -67,7 +77,7 @@ func (myFlags *Flags) UpdateHooks() error { var newRepos []Repo for _, item := range m.Repos { - action := strings.Replace(item.Repo, "https://github.com/", "", 1) + action := strings.Replace(item.Repo, GitHubPrefix, "", 1) tag, err := GetLatestTag(action, myFlags.GitHubToken) if err != nil { @@ -100,7 +110,7 @@ func (myFlags *Flags) UpdateHooks() error { fmt.Println(dmp.DiffPrettyText(diffs)) if !myFlags.DryRun { - err = os.WriteFile(*config, newData, 0666) + err = os.WriteFile(*config, newData, FilePermissions) if err != nil { log.Info().Msgf("failed to write %s", *config) @@ -128,7 +138,7 @@ func (myFlags *Flags) GetHook() (*string, error) { return nil, fmt.Errorf("please specify a directory") } - config := filepath.Join(myFlags.Directory, ".pre-commit-config.yaml") + config := filepath.Join(myFlags.Directory, PreCommitConfigFile) if _, err = os.Stat(config); err != nil { return nil, fmt.Errorf("pre-commit config not found %s", config) } diff --git a/src/core/registry.go b/src/core/registry.go index 4e6b08c..3641bf9 100644 --- a/src/core/registry.go +++ b/src/core/registry.go @@ -1,10 +1,13 @@ package core import ( + "context" "encoding/json" "fmt" "io" "net/http" + "net/url" + "time" ) type Registry struct { @@ -12,9 +15,15 @@ type Registry struct { LatestVersion string } +const ( + registryBaseURL = "https://registry.terraform.io/v1/modules/" + successStatus = 200 +) + func (myRegistry *Registry) IsRegistryModule(module string) (bool, error) { - url := "https://registry.terraform.io/v1/modules/" + module + "/versions" - result, err := IsOK(url) + module = url.PathEscape(module) + urlBuilt := registryBaseURL + module + "/versions" + result, err := IsOK(urlBuilt) myRegistry.Registry = result @@ -22,12 +31,21 @@ func (myRegistry *Registry) IsRegistryModule(module string) (bool, error) { } func IsOK(url string) (bool, error) { - resp, err := http.Get(url) + ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) + defer cancel() + req, err := http.NewRequestWithContext(ctx, "GET", url, nil) + + if err != nil { + return false, fmt.Errorf("failed to make request with context: %w", err) + } + + resp, err := http.DefaultClient.Do(req) + if err != nil { return false, fmt.Errorf("failed to get url %w", err) } - if resp.StatusCode == 200 { + if resp.StatusCode == successStatus { return true, nil } @@ -35,6 +53,11 @@ func IsOK(url string) (bool, error) { } func (myRegistry *Registry) GetLatest(module string) (*string, error) { + // Add module name validation + if module == "" { + return nil, fmt.Errorf("module name cannot be empty") + } + found, err := myRegistry.IsRegistryModule(module) if err != nil { @@ -42,14 +65,17 @@ func (myRegistry *Registry) GetLatest(module string) (*string, error) { } if found { - url := "https://registry.terraform.io/v1/modules/" + module - resp, _ := http.Get(url) + urlBuilt := registryBaseURL + module + resp, err := http.Get(urlBuilt) + if err != nil { + return nil, fmt.Errorf("failed to make HTTP request: %w", err) + } if resp == nil { return nil, fmt.Errorf("api failed to respond") } - if resp.StatusCode != 200 { + if resp.StatusCode != successStatus { return nil, fmt.Errorf("api failed with %d", resp.StatusCode) } diff --git a/src/core/testdata/modules/github-git/module.tf b/src/core/testdata/modules/github-git/module.tf index 7697a32..0942ab6 100644 --- a/src/core/testdata/modules/github-git/module.tf +++ b/src/core/testdata/modules/github-git/module.tf @@ -1,5 +1,5 @@ module "disk_encryption_set" { - source = "git::https://github.com/JamesWoolfenden/terraform-azurerm-diskencryptionset.git?ref=fc0b830997dd820476a7ad5e4b6ef2dcbdc766d7" + source = "" #v0.0.7 common_tags = var.common_tags location = var.location rg_name = var.resource_group_name From 91409bf4be3de7d858839786904dc95ce6de259b Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Mon, 9 Dec 2024 10:55:22 +0000 Subject: [PATCH 69/80] error handling --- .github/workflows/ci.yml | 2 +- .github/workflows/codeql-analysis.yml | 6 +- .github/workflows/pr.yml | 4 +- .pre-commit-config.yaml | 6 +- bump.ps1 | 48 +++++-- bump.sh | 35 +++++ go.mod | 22 +-- go.sum | 48 +++---- main.go | 2 +- src/core/action_test.go | 2 +- src/core/error.go | 103 ++++++++++++++ src/core/error_test.go | 142 +++++++++++++++++++ src/core/filter.go | 51 +++++-- src/core/filter_test.go | 74 +++++++++- src/core/gha.go | 28 +++- src/core/gha_test.go | 195 +++++++++++++++++++++++++- src/core/modules_test.go | 113 +++++++++++++-- src/core/pre-commit.go | 8 +- src/core/pre-commit_test.go | 2 +- src/core/registry.go | 72 ++++++++-- src/core/types.go | 2 +- 21 files changed, 856 insertions(+), 109 deletions(-) create mode 100644 bump.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c0e30a5..02ffc17 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,6 +42,6 @@ jobs: run: go test ./... -coverprofile=./cover.out - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@a2f73fb6db51fcd2e0aa085dfb36dea90c5e3689 # v5.0.2 + uses: codecov/codecov-action@b21b58fad3ac66e668f9b08d01599ffff6f2cada # v5.1.1 env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 1563b48..0f69e85 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -43,7 +43,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@cbe18979603527f12c7871a6eb04833ecf1548c7 # codeql-bundle-v2.19.3 + uses: github/codeql-action/init@cba5fb58d4f85affaf03eb9da32f5b6c9d76838b # codeql-bundle-v2.19.4 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -53,7 +53,7 @@ jobs: # 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@cbe18979603527f12c7871a6eb04833ecf1548c7 # codeql-bundle-v2.19.3 + uses: github/codeql-action/autobuild@cba5fb58d4f85affaf03eb9da32f5b6c9d76838b # codeql-bundle-v2.19.4 # â„šī¸ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun @@ -66,4 +66,4 @@ jobs: # ./location_of_script_within_repo/buildscript.sh - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@cbe18979603527f12c7871a6eb04833ecf1548c7 # codeql-bundle-v2.19.3 + uses: github/codeql-action/analyze@cba5fb58d4f85affaf03eb9da32f5b6c9d76838b # codeql-bundle-v2.19.4 diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 209eb53..7a47a2a 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -14,7 +14,7 @@ jobs: with: go-version: 1.21.x - name: Restore cache - uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 + uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 with: path: ~/go/pkg/mod key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} @@ -36,7 +36,7 @@ jobs: with: go-version: ${{ matrix.go-version }} - name: Restore cache - uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 + uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 with: path: ~/go/pkg/mod key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 80a5bb8..8560213 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -36,7 +36,7 @@ repos: - id: markdownlint exclude: src/testdata|testdata repo: https://github.com/igorshubovych/markdownlint-cli - rev: aa975a18c9a869648007d33864034dbc7481fe5e + rev: 0d9fcb51a54f3b750b911c054b4bd1a590f1b592 - hooks: - id: terraform-fmt language_version: python3.11 @@ -58,7 +58,7 @@ repos: - hooks: - id: golangci-lint repo: https://github.com/golangci/golangci-lint - rev: 22b58c9b648f027d699f305c069a2a97ed0c5b06 + rev: 89476e7a1eaa0a8a06c17343af960a5fd9e7edb7 - hooks: - id: checkov language_version: python3.11 @@ -66,7 +66,7 @@ repos: - -d - . repo: https://github.com/bridgecrewio/checkov - rev: e66e08456de4c7f0c2d8ad2b3f2ab9df0999073f + rev: 28d642c33cee90f21d7d9dea13f14860878ce27d - hooks: - id: ghat-go name: ghat diff --git a/bump.ps1 b/bump.ps1 index b7eb557..7c9ba9c 100644 --- a/bump.ps1 +++ b/bump.ps1 @@ -1,8 +1,40 @@ -$version = $( git describe --tags --abbrev = 0 ) -$splitter = $version.split(".") -$build = [int]($splitter[2]) + 1 -$newVersion = $splitter[0] + "." + $splitter[1] + "." + $build - -write-host $newVersion -git tag -a $newVersion -m "new release" -git push origin $newVersion +param( + [Parameter(Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [string]$message = "new release" +) + +$versionPattern = '^\d+\.\d+\.\d+$' +$version = $null + +try +{ + $version = $( git describe --tags --abbrev=0 ) -replace "v" + if ($version -notmatch $versionPattern) + { + Write-Error "Invalid version format $version. Expected: x.y.z" + exit 1 + } + + $splitter = $version.split(".") + $build = [int]($splitter[2]) + 1 + [string]$newVersion = $splitter[0] + "." + $splitter[1] + "." + $build.ToString() + + if ([version]$newVersion -le [version]$version) + { + Write-Error "New version must be greater than current version" + exit 1 + } + + Write-Host "Current version: $version" + Write-Host "New version: $newVersion" + Write-Host "Creating new tag..." + + git tag -a v$newVersion -m "$message" + git push origin v$newVersion +} +catch +{ + Write-Error "An error occurred: $_" + exit 1 +} diff --git a/bump.sh b/bump.sh new file mode 100644 index 0000000..38aa268 --- /dev/null +++ b/bump.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +# Parameters +message="${1:-new release}" + +# Version pattern +versionPattern='^[0-9]+\.[0-9]+\.[0-9]+$' +version='' + +# Get the current version +version=$(git describe --tags --abbrev=0 2>/dev/null) +version=${version//v} +if [[ ! $version =~ $versionPattern ]]; then + echo "Invalid version format. Expected: x.y.z" + exit 1 +fi + +# Split the version and increment the build number +IFS='.' read -r major minor build <<< "$version" +newBuild=$((build + 1)) +newVersion="$major.$minor.$newBuild" + +if [[ ! "$newVersion" > "$version" ]]; then + echo "New version must be greater than current version" + exit 1 +fi + +# Output the current and new version +echo "Current version: $version" +echo "New version: $newVersion" +echo "Creating new tag..." + +# Create a new tag and push it +git tag -a "v$newVersion" -m "$message" +git push origin "v$newVersion" diff --git a/go.mod b/go.mod index 3a019c4..d90c7bb 100644 --- a/go.mod +++ b/go.mod @@ -4,11 +4,11 @@ go 1.22.2 require ( github.com/go-git/go-git/v5 v5.12.0 - github.com/hashicorp/hcl/v2 v2.22.0 + github.com/hashicorp/hcl/v2 v2.23.0 github.com/rs/zerolog v1.33.0 github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 github.com/urfave/cli/v2 v2.27.5 - github.com/zclconf/go-cty v1.15.0 + github.com/zclconf/go-cty v1.15.1 golang.org/x/mod v0.22.0 gopkg.in/yaml.v3 v3.0.1 moul.io/banner v1.0.1 @@ -17,17 +17,17 @@ require ( require ( dario.cat/mergo v1.0.1 // indirect github.com/Microsoft/go-winio v0.6.2 // indirect - github.com/ProtonMail/go-crypto v1.1.2 // indirect + github.com/ProtonMail/go-crypto v1.1.3 // indirect github.com/agext/levenshtein v1.2.3 // indirect github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect github.com/cloudflare/circl v1.5.0 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.5 // indirect - github.com/cyphar/filepath-securejoin v0.3.4 // indirect + github.com/cyphar/filepath-securejoin v0.3.5 // indirect github.com/emirpasic/gods v1.18.1 // indirect github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect github.com/go-git/go-billy/v5 v5.6.0 // indirect github.com/go-test/deep v1.1.0 // indirect - github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect + github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect github.com/google/go-cmp v0.6.0 // indirect github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect github.com/kevinburke/ssh_config v1.2.0 // indirect @@ -39,11 +39,11 @@ require ( github.com/skeema/knownhosts v1.3.0 // indirect github.com/xanzy/ssh-agent v0.3.3 // indirect github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect - golang.org/x/crypto v0.29.0 // indirect - golang.org/x/net v0.31.0 // indirect - golang.org/x/sync v0.9.0 // indirect - golang.org/x/sys v0.27.0 // indirect - golang.org/x/text v0.20.0 // indirect - golang.org/x/tools v0.27.0 // indirect + golang.org/x/crypto v0.30.0 // indirect + golang.org/x/net v0.32.0 // indirect + golang.org/x/sync v0.10.0 // indirect + golang.org/x/sys v0.28.0 // indirect + golang.org/x/text v0.21.0 // indirect + golang.org/x/tools v0.28.0 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect ) diff --git a/go.sum b/go.sum index 2cd8788..1784bcb 100644 --- a/go.sum +++ b/go.sum @@ -3,8 +3,8 @@ dario.cat/mergo v1.0.1/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= -github.com/ProtonMail/go-crypto v1.1.2 h1:A7JbD57ThNqh7XjmHE+PXpQ3Dqt3BrSAC0AL0Go3KS0= -github.com/ProtonMail/go-crypto v1.1.2/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE= +github.com/ProtonMail/go-crypto v1.1.3 h1:nRBOetoydLeUb4nHajyO2bKqMLfWQ/ZPwkXqXxPxCFk= +github.com/ProtonMail/go-crypto v1.1.3/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE= github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8= @@ -18,8 +18,8 @@ github.com/cloudflare/circl v1.5.0/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZ github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/cpuguy83/go-md2man/v2 v2.0.5 h1:ZtcqGrnekaHpVLArFSe4HK5DoKx1T0rq2DwVB0alcyc= github.com/cpuguy83/go-md2man/v2 v2.0.5/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= -github.com/cyphar/filepath-securejoin v0.3.4 h1:VBWugsJh2ZxJmLFSM06/0qzQyiQX2Qs0ViKrUAcqdZ8= -github.com/cyphar/filepath-securejoin v0.3.4/go.mod h1:8s/MCNJREmFK0H02MF6Ihv1nakJe4L/w3WZLHNkvlYM= +github.com/cyphar/filepath-securejoin v0.3.5 h1:L81NHjquoQmcPgXcttUS9qTSR/+bXry6pbSINQGpjj4= +github.com/cyphar/filepath-securejoin v0.3.5/go.mod h1:edhVd3c6OXKjUmSrVa/tGJRS9joFTxlslFCAyaxigkE= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -40,12 +40,12 @@ github.com/go-git/go-git/v5 v5.12.0/go.mod h1:FTM9VKtnI2m65hNI/TenDDDnUf2Q9FHnXY github.com/go-test/deep v1.1.0 h1:WOcxcdHcvdgThNXjw0t76K42FXTU7HpNQWHpA2HHNlg= github.com/go-test/deep v1.1.0/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= -github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= -github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 h1:f+oWsMOmNPc8JmEHVZIycC7hBoQxHH9pNKQORJNozsQ= +github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8/go.mod h1:wcDNUvekVysuuOpQKo3191zZyTpiI6se1N1ULghS0sw= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/hashicorp/hcl/v2 v2.22.0 h1:hkZ3nCtqeJsDhPRFz5EA9iwcG1hNWGePOTw6oyul12M= -github.com/hashicorp/hcl/v2 v2.22.0/go.mod h1:62ZYHrXgPoX8xBnzl8QzbWq4dyDsDtfCRgIq1rbJEvA= +github.com/hashicorp/hcl/v2 v2.23.0 h1:Fphj1/gCylPxHutVSEOf2fBOh1VE4AuLV7+kbJf3qos= +github.com/hashicorp/hcl/v2 v2.23.0/go.mod h1:62ZYHrXgPoX8xBnzl8QzbWq4dyDsDtfCRgIq1rbJEvA= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= @@ -96,22 +96,22 @@ github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4= github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM= -github.com/zclconf/go-cty v1.15.0 h1:tTCRWxsexYUmtt/wVxgDClUe+uQusuI443uL6e+5sXQ= -github.com/zclconf/go-cty v1.15.0/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= +github.com/zclconf/go-cty v1.15.1 h1:RgQYm4j2EvoBRXOPxhUvxPzRrGDo1eCOhHXuGfrj5S0= +github.com/zclconf/go-cty v1.15.1/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940 h1:4r45xpDWB6ZMSMNJFMOjqrGHynW3DIBuR2H9j0ug+Mo= github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940/go.mod h1:CmBdvvj3nqzfzJ6nTCIwDTPZ56aVGvDrmztiO5g3qrM= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ= -golang.org/x/crypto v0.29.0/go.mod h1:+F4F4N5hv6v38hfeYwTdx20oUvLLc+QfrE9Ax9HtgRg= +golang.org/x/crypto v0.30.0 h1:RwoQn3GkWiMkzlX562cLB7OxWvjH1L8xutO2WoJcRoY= +golang.org/x/crypto v0.30.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8= golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY= golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4= golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo= -golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM= -golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ= -golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= +golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= +golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= +golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -121,17 +121,17 @@ golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s= -golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= +golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.26.0 h1:WEQa6V3Gja/BhNxg540hBip/kkaYtRg3cxg4oXSw4AU= -golang.org/x/term v0.26.0/go.mod h1:Si5m1o57C5nBNQo5z1iq+XDijt21BDBDp2bK0QI8e3E= +golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q= +golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug= -golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4= +golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= +golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.27.0 h1:qEKojBykQkQ4EynWy4S8Weg69NumxKdn40Fce3uc/8o= -golang.org/x/tools v0.27.0/go.mod h1:sUi0ZgbwW9ZPAq26Ekut+weQPR5eIM6GQLQ1Yjm1H0Q= +golang.org/x/tools v0.28.0 h1:WuB6qZ4RPCQo5aP3WdKZS7i595EdWqWR8vqJTlwTVK8= +golang.org/x/tools v0.28.0/go.mod h1:dcIOrVd3mfQKTgrDVQHqCPMWy6lnhfhtX3hLXYVLfRw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= diff --git a/main.go b/main.go index b9bba96..aff7bf1 100644 --- a/main.go +++ b/main.go @@ -62,7 +62,7 @@ func main() { Destination: &myFlags.Directory, Category: "files", }, - &cli.IntFlag{ + &cli.UintFlag{ Name: "stable", Aliases: []string{"s"}, Usage: "days to wait for stabilisation of release", diff --git a/src/core/action_test.go b/src/core/action_test.go index c4fab34..1125064 100644 --- a/src/core/action_test.go +++ b/src/core/action_test.go @@ -11,7 +11,7 @@ func TestFlags_Action(t *testing.T) { File string Directory string GitHubToken string - Days int + Days uint DryRun bool Entries []string Update bool diff --git a/src/core/error.go b/src/core/error.go index 6f282d3..e6b4203 100644 --- a/src/core/error.go +++ b/src/core/error.go @@ -71,3 +71,106 @@ type writeGHAError struct { func (m *writeGHAError) Error() string { return fmt.Sprintf("failed to write GHA %s", m.gha) } + +type readConfigError struct { + config *string + err error +} + +func (m *readConfigError) Error() string { + return fmt.Sprintf("failed to read %s: %v", *m.config, m.err) +} + +type marshalJSONError struct { + err error +} + +func (m *marshalJSONError) Error() string { + return fmt.Sprintf("failed to marshal JSON: %v", m.err) +} + +type getHookError struct { + err error +} + +func (m *getHookError) Error() string { + return fmt.Sprintf("failed to get hook: %v", m.err) +} + +type castToStringError struct { + object string +} + +func (m *castToStringError) Error() string { + return fmt.Sprintf("failed to cast %s to string", m.object) +} + +type requestFailedError struct { + err error +} + +func (m *requestFailedError) Error() string { + return fmt.Sprintf("request failed: %v", m.err) +} + +type httpClientError struct { + err error +} + +func (m *httpClientError) Error() string { + return fmt.Sprintf("http client error: %v", m.err) +} + +type emptyURL struct { +} + +func (m *emptyURL) Error() string { + return "URL is empty" +} + +type registryModuleError struct { + module string + err error +} + +func (m *registryModuleError) Error() string { + return fmt.Sprintf("failed to get module %s: %v", m.module, m.err) +} + +type httpGetError struct { + err error +} + +func (m *httpGetError) Error() string { + return fmt.Sprintf("http get error: %v", m.err) +} + +type unmarshalJSONError struct { + err error +} + +func (m *unmarshalJSONError) Error() string { + return fmt.Sprintf("failed to unmarshal: %v", m.err) +} + +type moduleEmptyError struct { +} + +func (m *moduleEmptyError) Error() string { + return "module name cannot be empty" +} + +type responseReadError struct { + err error +} + +func (m *responseReadError) Error() string { + return fmt.Sprintf("failed to read response: %v", m.err) +} + +type responseNilError struct { +} + +func (m *responseNilError) Error() string { + return "api response is nil" +} diff --git a/src/core/error_test.go b/src/core/error_test.go index bd3e24f..b2a33a4 100644 --- a/src/core/error_test.go +++ b/src/core/error_test.go @@ -1,6 +1,7 @@ package core import ( + "fmt" "testing" ) @@ -189,3 +190,144 @@ func TestWriteGHAError(t *testing.T) { }) } } + +func TestReadConfigError(t *testing.T) { + t.Parallel() + config := "config.yaml" + testErr := fmt.Errorf("test error") + err := &readConfigError{config: &config, err: testErr} + expected := "failed to read config.yaml: test error" + if err.Error() != expected { + t.Errorf("Expected error message '%s', got '%s'", expected, err.Error()) + } +} + +func TestMarshalJSONError(t *testing.T) { + t.Parallel() + testErr := fmt.Errorf("marshal error") + err := &marshalJSONError{err: testErr} + expected := "failed to marshal JSON: marshal error" + if err.Error() != expected { + t.Errorf("Expected error message '%s', got '%s'", expected, err.Error()) + } +} + +func TestGetHookError(t *testing.T) { + t.Parallel() + testErr := fmt.Errorf("hook error") + err := &getHookError{err: testErr} + expected := "failed to get hook: hook error" + if err.Error() != expected { + t.Errorf("Expected error message '%s', got '%s'", expected, err.Error()) + } +} + +func TestCastToStringError(t *testing.T) { + t.Parallel() + testCases := []struct { + name string + object string + expected string + }{ + {"Empty object", "", "failed to cast to string"}, + {"Valid object", "testObject", "failed to cast testObject to string"}, + } + + for _, tc := range testCases { + tc := tc + t.Run(tc.name, func(t *testing.T) { + t.Parallel() + err := &castToStringError{object: tc.object} + if err.Error() != tc.expected { + t.Errorf("Expected error message '%s', got '%s'", tc.expected, err.Error()) + } + }) + } +} + +func TestRequestFailedError(t *testing.T) { + t.Parallel() + testErr := fmt.Errorf("request error") + err := &requestFailedError{err: testErr} + expected := "request failed: request error" + if err.Error() != expected { + t.Errorf("Expected error message '%s', got '%s'", expected, err.Error()) + } +} + +func TestHTTPClientError(t *testing.T) { + t.Parallel() + testErr := fmt.Errorf("client error") + err := &httpClientError{err: testErr} + expected := "http client error: client error" + if err.Error() != expected { + t.Errorf("Expected error message '%s', got '%s'", expected, err.Error()) + } +} + +func TestEmptyURL(t *testing.T) { + t.Parallel() + err := &emptyURL{} + expected := "URL is empty" + if err.Error() != expected { + t.Errorf("Expected error message '%s', got '%s'", expected, err.Error()) + } +} + +func TestRegistryModuleError(t *testing.T) { + t.Parallel() + testErr := fmt.Errorf("module error") + err := ®istryModuleError{module: "test-module", err: testErr} + expected := "failed to get module test-module: module error" + if err.Error() != expected { + t.Errorf("Expected error message '%s', got '%s'", expected, err.Error()) + } +} + +func TestHTTPGetError(t *testing.T) { + t.Parallel() + testErr := fmt.Errorf("get error") + err := &httpGetError{err: testErr} + expected := "http get error: get error" + if err.Error() != expected { + t.Errorf("Expected error message '%s', got '%s'", expected, err.Error()) + } +} + +func TestUnmarshalJSONError(t *testing.T) { + t.Parallel() + testErr := fmt.Errorf("unmarshal error") + err := &unmarshalJSONError{err: testErr} + expected := "failed to unmarshal: unmarshal error" + if err.Error() != expected { + t.Errorf("Expected error message '%s', got '%s'", expected, err.Error()) + } +} + +func TestModuleEmptyError(t *testing.T) { + t.Parallel() + err := &moduleEmptyError{} + expected := "module name cannot be empty" + if err.Error() != expected { + t.Errorf("Expected error message '%s', got '%s'", expected, err.Error()) + } +} + +func TestResponseReadError(t *testing.T) { + t.Parallel() + testErr := fmt.Errorf("read error") + err := &responseReadError{err: testErr} + expected := "failed to read response: read error" + if err.Error() != expected { + t.Errorf("Expected error message '%s', got '%s'", expected, err.Error()) + } +} + +func TestResponseNilError(t *testing.T) { + t.Parallel() + err := &responseNilError{} + expected := "api response is nil" + if err.Error() != expected { + t.Errorf("Expected error message '%s', got '%s'", expected, err.Error()) + } +} diff --git a/src/core/filter.go b/src/core/filter.go index f7a2e05..7118a95 100644 --- a/src/core/filter.go +++ b/src/core/filter.go @@ -1,26 +1,53 @@ package core import ( - "errors" "fmt" "time" ) -func GetReleases(action string, gitHubToken string, days *int) (map[string]interface{}, error) { +const ( + dayInNanos = 24 * 60 * 60 * 1000 * 1000 * 1000 + apiBaseURL = "https://api.github.com/repos/" +) + +type githubTokenIsEmptyError struct{} + +func (e githubTokenIsEmptyError) Error() string { + return "github token is empty" +} + +type timeParsingError struct { + err error +} + +func (e timeParsingError) Error() string { + return fmt.Sprintf("failed to parse time %v", e.err) +} + +type daysParameterError struct{} + +func (e daysParameterError) Error() string { + return "days parameter must be positive" +} + +func GetReleases(action string, gitHubToken string, days *uint) (map[string]interface{}, error) { + if days == nil { + return nil, &daysParameterError{} + } if gitHubToken == "" { - return nil, fmt.Errorf("github token is empty") + return nil, &githubTokenIsEmptyError{} } if action == "" { - return nil, fmt.Errorf("action is empty") + return nil, &actionIsEmptyError{} } now := time.Now() - interval := time.Duration(*days * 24 * 60 * 60 * 1000 * 1000 * 1000) + interval := time.Duration(*days * dayInNanos) limit := now.Add(-interval) - url := "https://api.github.com/repos/" + action + "/releases" + url := apiBaseURL + action + "/releases" temp, err := GetGithubBody(gitHubToken, url) if err != nil { @@ -34,17 +61,21 @@ func GetReleases(action string, gitHubToken string, days *int) (map[string]inter } for _, body := range bodies { - release := body.(map[string]interface{}) + release, ok := body.(map[string]interface{}) + if !ok { + return nil, fmt.Errorf("invalid release format in response") + } + temp, ok := release["published_at"].(string) if !ok { - return nil, errors.New("failed to assert published_at as a string") + return nil, &castToStringError{"published_at"} } released, err := time.Parse(time.RFC3339, temp) if err != nil { - return nil, fmt.Errorf("failed to parse time %w", err) + return nil, &timeParsingError{err: err} } if released.Before(limit) { @@ -52,5 +83,5 @@ func GetReleases(action string, gitHubToken string, days *int) (map[string]inter } } - return nil, err + return nil, nil } diff --git a/src/core/filter_test.go b/src/core/filter_test.go index 6774655..58afa0a 100644 --- a/src/core/filter_test.go +++ b/src/core/filter_test.go @@ -10,11 +10,11 @@ func TestGetReleases(t *testing.T) { type args struct { action string gitHubToken string - delay *int + delay *uint } - delay := 14 - zero := 0 + var delay uint = 14 + var zero uint = 0 var empty map[string]interface{} want := map[string]interface{}{ "tarball_url": "https: //api.github.com/repos/JamesWoolfenden/test-data-action/tarball/v0.0.1", @@ -106,6 +106,7 @@ func TestGetReleases(t *testing.T) { {"Has release", args{"jameswoolfenden/test-data-action", gitHubToken, &delay}, want, false}, {"Has released", args{"jameswoolfenden/test-data-action", gitHubToken, &zero}, result, false}, {"Fake", args{"jameswoolfenden/god", gitHubToken, &zero}, nil, true}, + {"no token", args{"actions/checkout", "", &zero}, nil, true}, } for _, tt := range tests { @@ -123,3 +124,70 @@ func TestGetReleases(t *testing.T) { }) } } + +func TestGetReleasesEdgeCases(t *testing.T) { + t.Parallel() + + var days uint = 14 + var zero uint = 0 + + tests := []struct { + name string + action string + gitHubToken string + days *uint + wantErr bool + errMsg string + }{ + { + name: "Empty GitHub token", + action: "JamesWoolfenden/test-data-action", + gitHubToken: "", + days: &days, + wantErr: true, + errMsg: "github token is empty", + }, + { + name: "Empty action name", + action: "", + gitHubToken: "dummy-token", + days: &days, + wantErr: true, + errMsg: "action is empty", + }, + { + name: "Zero days filter", + action: "JamesWoolfenden/test-data-action", + gitHubToken: "dummy-token", + days: &zero, + wantErr: true, + errMsg: "failed to request list of releases api failed with 401", + }, + { + name: "Valid days filter", + action: "JamesWoolfenden/test-data-action", + gitHubToken: "dummy-token", + days: &days, + wantErr: true, + errMsg: "failed to request list of releases api failed with 401", + }, + } + + for _, tt := range tests { + tt := tt + t.Run(tt.name, func(t *testing.T) { + t.Parallel() + got, err := GetReleases(tt.action, tt.gitHubToken, tt.days) + if (err != nil) != tt.wantErr { + t.Errorf("GetReleases() error = %v, wantErr %v", err, tt.wantErr) + return + } + if err != nil && err.Error() != tt.errMsg { + t.Errorf("GetReleases() error message = %v, want %v", err.Error(), tt.errMsg) + } + if !tt.wantErr && got == nil { + t.Error("GetReleases() returned nil result when error not expected") + } + }) + } +} diff --git a/src/core/gha.go b/src/core/gha.go index e7da7fb..577e6ea 100644 --- a/src/core/gha.go +++ b/src/core/gha.go @@ -22,10 +22,27 @@ const ( yamlAltExtension = ".yaml" ) +type readFilesError struct { + err error +} + +func (m *readFilesError) Error() string { + return fmt.Sprintf("failed to read files: %s", m.err) +} + +type absolutePathError struct { + directory string + err error +} + +func (m *absolutePathError) Error() string { + return fmt.Sprintf("failed to get absolute path: %v %s ", m.err, m.directory) +} + func GetFiles(dir string) ([]string, error) { Entries, err := os.ReadDir(dir) if err != nil { - return nil, err + return nil, &readFilesError{err} } var ParsedEntries []string @@ -33,7 +50,7 @@ func GetFiles(dir string) ([]string, error) { for _, entry := range Entries { AbsDir, err := filepath.Abs(dir) if err != nil { - return nil, fmt.Errorf("failed to get absolute path: %w", err) + return nil, &absolutePathError{dir, err} } gitDir := filepath.Join(AbsDir, ".git") @@ -197,7 +214,12 @@ func (myFlags *Flags) UpdateGHA(file string) error { return nil } -func getPayload(action string, gitHubToken string, days *int) (interface{}, error) { +func getPayload(action string, gitHubToken string, days *uint) (interface{}, error) { + + if days == nil { + return nil, &daysParameterError{} + } + if *days == 0 { return GetLatestRelease(action, gitHubToken) } diff --git a/src/core/gha_test.go b/src/core/gha_test.go index 58035af..949bb29 100644 --- a/src/core/gha_test.go +++ b/src/core/gha_test.go @@ -1,7 +1,9 @@ package core import ( + "fmt" "os" + "path/filepath" "reflect" "testing" @@ -129,11 +131,11 @@ func Test_getPayload(t *testing.T) { type args struct { action string gitHubToken string - days *int + days *uint } - days := 0 - ninety := 90 + var days uint = 0 + var ninety uint = 90 daysMap := map[string]interface{}{ "html_url": "https://github.com/JamesWoolfenden/action-pike/releases/tag/v0.1.3", @@ -188,7 +190,7 @@ func TestFlags_GetGHA(t *testing.T) { File string Directory string GitHubToken string - Days int + Days uint DryRun bool } @@ -289,7 +291,7 @@ func TestFlags_UpdateGHAS(t *testing.T) { File string Directory string GitHubToken string - Days int + Days uint DryRun bool Entries []string Update bool @@ -334,7 +336,7 @@ func TestFlags_UpdateGHA(t *testing.T) { File string Directory string GitHubToken string - Days int + Days uint DryRun bool Entries []string Update bool @@ -365,6 +367,22 @@ func TestFlags_UpdateGHA(t *testing.T) { {name: "Faulty GHA continue", fields: fields{File: "./testdata/faulty/.github/workflows/test.yml", GitHubToken: gitHubToken, DryRun: true, Entries: []string{"./testdata/faulty/.github/workflows/test.yml"}, Update: true, ContinueOnError: true}, args: args{file: "./testdata/faulty/.github/workflows/test.yml"}}, + { + name: "Empty entries", + fields: fields{ + Entries: []string{}, + GitHubToken: gitHubToken, + }, + wantErr: true, + }, + { + name: "Invalid file path", + fields: fields{ + Entries: []string{"./testdata/nonexistent/workflow.yml"}, + GitHubToken: gitHubToken, + }, + wantErr: true, + }, } for _, tt := range tests { tt := tt @@ -386,3 +404,168 @@ func TestFlags_UpdateGHA(t *testing.T) { }) } } + +func setupSuite(tb testing.TB) func(tb testing.TB) { + log.Info().Msgf("setup suite %s", tb.Name()) + testPath, _ := filepath.Abs("./testdata/empty") + _ = os.Mkdir(testPath, os.ModePerm) + _ = os.Mkdir("./testdata/.terraform/", os.ModePerm) + _ = os.Mkdir("./testdata/.git/", os.ModePerm) + + return func(tb testing.TB) { + log.Info().Msg("teardown suite") + _ = os.RemoveAll(testPath) + _ = os.RemoveAll("./testdata/.terraform/") + _ = os.RemoveAll("./testdata/.git/") + + } +} + +func TestGetFiles(t *testing.T) { + t.Parallel() + + //teardownSuite := setupSuite(t) + //defer teardownSuite(t) + + tests := []struct { + name string + dir string + want int + wantErr bool + }{ + {"Valid directory", "./testdata/gha", 1, false}, + {"Empty directory", "./testdata/empty", 0, false}, + {"Non-existent directory", "./testdata/nonexistent", 0, true}, + {"Directory with .terraform", "./testdata/.terraform", 0, false}, + {"Directory with .git", "./testdata/.git", 0, false}, + } + + for _, tt := range tests { + tt := tt + t.Run(tt.name, func(t *testing.T) { + t.Parallel() + teardownSuite := setupSuite(t) + defer teardownSuite(t) + got, err := GetFiles(tt.dir) + if (err != nil) != tt.wantErr { + t.Errorf("GetFiles() error = %v, wantErr %v", err, tt.wantErr) + return + } + if !tt.wantErr && len(got) != tt.want { + t.Errorf("GetFiles() got = %v files, want %v", len(got), tt.want) + } + }) + } +} + +func TestReadFilesError(t *testing.T) { + t.Parallel() + + testErr := fmt.Errorf("test error") + err := &readFilesError{err: testErr} + expected := "failed to read files: test error" + + if err.Error() != expected { + t.Errorf("readFilesError.Error() = %v, want %v", err.Error(), expected) + } +} + +func TestAbsolutePathError(t *testing.T) { + t.Parallel() + + testErr := fmt.Errorf("test error") + testDir := "/test/dir" + err := &absolutePathError{directory: testDir, err: testErr} + expected := "failed to get absolute path: test error /test/dir " + + if err.Error() != expected { + t.Errorf("absolutePathError.Error() = %v, want %v", err.Error(), expected) + } +} + +func TestGetGithubBody_EdgeCases(t *testing.T) { + t.Parallel() + + tests := []struct { + name string + gitHubToken string + url string + wantErr bool + }{ + { + name: "Invalid URL format", + gitHubToken: gitHubToken, + url: "not-a-url", + wantErr: true, + }, + { + name: "Empty URL", + gitHubToken: gitHubToken, + url: "", + wantErr: true, + }, + { + name: "Invalid JSON response", + gitHubToken: gitHubToken, + url: "https://api.github.com/invalid-endpoint", + wantErr: true, + }, + } + + for _, tt := range tests { + tt := tt + t.Run(tt.name, func(t *testing.T) { + t.Parallel() + _, err := GetGithubBody(tt.gitHubToken, tt.url) + if (err != nil) != tt.wantErr { + t.Errorf("GetGithubBody() error = %v, wantErr %v", err, tt.wantErr) + } + }) + } +} + +func TestGetPayload_ErrorCases(t *testing.T) { + t.Parallel() + + var days uint = 30 + tests := []struct { + name string + action string + gitHubToken string + days *uint + wantErr bool + }{ + { + name: "Empty action", + action: "", + gitHubToken: gitHubToken, + days: &days, + wantErr: true, + }, + { + name: "Invalid action format", + action: "invalid-format", + gitHubToken: gitHubToken, + days: &days, + wantErr: true, + }, + { + name: "Nil days pointer", + action: "actions/checkout", + gitHubToken: gitHubToken, + days: nil, + wantErr: true, + }, + } + + for _, tt := range tests { + tt := tt + t.Run(tt.name, func(t *testing.T) { + t.Parallel() + _, err := getPayload(tt.action, tt.gitHubToken, tt.days) + if (err != nil) != tt.wantErr { + t.Errorf("getPayload() error = %v, wantErr %v", err, tt.wantErr) + } + }) + } +} diff --git a/src/core/modules_test.go b/src/core/modules_test.go index c021a94..0761a59 100644 --- a/src/core/modules_test.go +++ b/src/core/modules_test.go @@ -1,6 +1,8 @@ package core import ( + "fmt" + "reflect" "testing" ) @@ -10,7 +12,7 @@ func TestFlags_GetType(t *testing.T) { File string Directory string GitHubToken string - Days int + Days uint DryRun bool Entries []string Update bool @@ -87,7 +89,7 @@ func TestFlags_UpdateSource(t *testing.T) { File string Directory string GitHubToken string - Days int + Days uint DryRun bool Entries []string Update bool @@ -124,13 +126,13 @@ func TestFlags_UpdateSource(t *testing.T) { {"git", fields{"", "", gitHubToken, 0, false, nil, false}, args{"git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git", "git", ""}, - "git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=7490e771c58f2d4a233b5c62b4fb1c4a368245c1", - "v2.1.0", false}, + "git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=42be407604c9ec4452f1f5bcc32a142ce9ab75a5", + "v2.2.0", false}, {"git update", fields{"", "", gitHubToken, 0, false, nil, true}, args{"git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git", "git", ""}, - "git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=7490e771c58f2d4a233b5c62b4fb1c4a368245c1", - "v2.1.0", false}, + "git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=42be407604c9ec4452f1f5bcc32a142ce9ab75a5", + "v2.2.0", false}, {"git version", fields{"", "", gitHubToken, 0, false, nil, false}, args{"git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=v1.0.0", "git", ""}, @@ -139,8 +141,8 @@ func TestFlags_UpdateSource(t *testing.T) { {"git version update", fields{"", "", gitHubToken, 0, false, nil, true}, args{"git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=v1.0.0", "git", ""}, - "git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=7490e771c58f2d4a233b5c62b4fb1c4a368245c1", - "v2.1.0", false}, + "git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=42be407604c9ec4452f1f5bcc32a142ce9ab75a5", + "v2.2.0", false}, {"git version missing", fields{"", "", gitHubToken, 0, false, nil, false}, args{"git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=v1.2.0", "git", ""}, @@ -152,8 +154,8 @@ func TestFlags_UpdateSource(t *testing.T) { {name: "git hash update", fields: fields{"", "", gitHubToken, 0, false, nil, true}, args: args{"git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=93facd14e9e3a66704d84a0236a8a3b813f047be", "git", ""}, - want: "git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=7490e771c58f2d4a233b5c62b4fb1c4a368245c1", - want1: "v2.1.0", + want: "git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=42be407604c9ec4452f1f5bcc32a142ce9ab75a5", + want1: "v2.2.0", wantErr: false}, //{"git query string", fields{}, args{"git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git"}, "git", false}, @@ -241,7 +243,7 @@ func TestFlags_UpdateGithubSource(t *testing.T) { File string Directory string GitHubToken string - Days int + Days uint DryRun bool Entries []string Update bool @@ -310,7 +312,7 @@ func TestFlags_UpdateModule(t *testing.T) { File string Directory string GitHubToken string - Days int + Days uint DryRun bool Entries []string Update bool @@ -345,3 +347,90 @@ func TestFlags_UpdateModule(t *testing.T) { }) } } + +func TestCustomErrors(t *testing.T) { + t.Parallel() + + tests := []struct { + name string + err error + expected string + }{ + { + name: "URL Join Error", + err: &urlJoinError{fmt.Errorf("invalid path")}, + expected: "failed to join url: invalid path", + }, + { + name: "Empty Module Error", + err: &moduleEmptyError{}, + expected: "module name cannot be empty", + }, + { + name: "Empty URL Error", + err: &emptyURL{}, + expected: "URL is empty", + }, + } + + for _, tt := range tests { + tt := tt + t.Run(tt.name, func(t *testing.T) { + t.Parallel() + if tt.err.Error() != tt.expected { + t.Errorf("Error() = %v, want %v", tt.err.Error(), tt.expected) + } + }) + } +} + +func TestRegistry_GetLatest_EdgeCases(t *testing.T) { + t.Parallel() + + type fields struct { + Registry bool + LatestVersion string + } + + tests := []struct { + name string + fields fields + module string + want *string + wantErr bool + }{ + { + name: "Empty Module", + fields: fields{false, ""}, + module: "", + want: nil, + wantErr: true, + }, + { + name: "Module With Special Characters", + fields: fields{false, ""}, + module: "test/module/with spaces/and#special@chars", + want: nil, + wantErr: true, + }, + } + + for _, tt := range tests { + tt := tt + t.Run(tt.name, func(t *testing.T) { + t.Parallel() + myRegistry := &Registry{ + Registry: tt.fields.Registry, + LatestVersion: tt.fields.LatestVersion, + } + got, err := myRegistry.GetLatest(tt.module) + if (err != nil) != tt.wantErr { + t.Errorf("GetLatest() error = %v, wantErr %v", err, tt.wantErr) + return + } + if !reflect.DeepEqual(got, tt.want) { + t.Errorf("GetLatest() got = %v, want %v", got, tt.want) + } + }) + } +} diff --git a/src/core/pre-commit.go b/src/core/pre-commit.go index da57621..6d4da4a 100644 --- a/src/core/pre-commit.go +++ b/src/core/pre-commit.go @@ -58,12 +58,12 @@ func (myFlags *Flags) UpdateHooks() error { var err error if config, err = myFlags.GetHook(); err != nil { - return err + return &getHookError{err: err} } data, err := os.ReadFile(*config) if err != nil { - return fmt.Errorf("failed to read config file: %w", err) + return &readConfigError{config, err} } var m ConfigFile @@ -71,7 +71,7 @@ func (myFlags *Flags) UpdateHooks() error { err = yaml.Unmarshal(data, &m) if err != nil { - return fmt.Errorf("failed to unmarshall %s", *config) + return &unmarshalJSONError{err} } var newRepos []Repo @@ -101,7 +101,7 @@ func (myFlags *Flags) UpdateHooks() error { newData, err := yaml.Marshal(&newConfigFile) if err != nil { - return fmt.Errorf("failed to marshal mew config") + return &marshalJSONError{err: err} } dmp := diffmatchpatch.New() diff --git a/src/core/pre-commit_test.go b/src/core/pre-commit_test.go index 402f004..0ea19bb 100644 --- a/src/core/pre-commit_test.go +++ b/src/core/pre-commit_test.go @@ -8,7 +8,7 @@ func TestFlags_UpdateHooks(t *testing.T) { File string Directory string GitHubToken string - Days int + Days uint DryRun bool Entries []string Update bool diff --git a/src/core/registry.go b/src/core/registry.go index 3641bf9..5dfbae4 100644 --- a/src/core/registry.go +++ b/src/core/registry.go @@ -18,6 +18,7 @@ type Registry struct { const ( registryBaseURL = "https://registry.terraform.io/v1/modules/" successStatus = 200 + defaultTimeout = 30 * time.Second ) func (myRegistry *Registry) IsRegistryModule(module string) (bool, error) { @@ -30,49 +31,90 @@ func (myRegistry *Registry) IsRegistryModule(module string) (bool, error) { return result, err } -func IsOK(url string) (bool, error) { - ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) +type URLFormatError struct { + err error +} + +func (e URLFormatError) Error() string { + return fmt.Sprintf("failed to format url: %v", e.err) +} + +func IsOK(rawURL string) (bool, error) { + + if rawURL == "" { + return false, &emptyURL{} + } + + // Add URL format validation + if _, err := url.Parse(rawURL); err != nil { + return false, &URLFormatError{err: err} + } + + ctx, cancel := context.WithTimeout(context.Background(), defaultTimeout) defer cancel() - req, err := http.NewRequestWithContext(ctx, "GET", url, nil) + req, err := http.NewRequestWithContext(ctx, "GET", rawURL, nil) if err != nil { - return false, fmt.Errorf("failed to make request with context: %w", err) + return false, &requestFailedError{err: err} } resp, err := http.DefaultClient.Do(req) if err != nil { - return false, fmt.Errorf("failed to get url %w", err) + return false, &httpClientError{err: err} } + // Add resp.Body.Close() to prevent resource leaks + defer resp.Body.Close() + if resp.StatusCode == successStatus { return true, nil } - return false, fmt.Errorf("received %s for %s", resp.Status, url) + return false, fmt.Errorf("received %s for %s", resp.Status, rawURL) +} + +type urlJoinError struct { + err error +} + +func (m *urlJoinError) Error() string { + return fmt.Sprintf("failed to join url: %v", m.err) } func (myRegistry *Registry) GetLatest(module string) (*string, error) { // Add module name validation if module == "" { - return nil, fmt.Errorf("module name cannot be empty") + return nil, &moduleEmptyError{} } found, err := myRegistry.IsRegistryModule(module) if err != nil { - return nil, err + return nil, ®istryModuleError{module, err} } if found { - urlBuilt := registryBaseURL + module - resp, err := http.Get(urlBuilt) + // Add URL sanitization + urlBuilt, err := url.JoinPath(registryBaseURL, url.PathEscape(module)) + + if err != nil { + return nil, &urlJoinError{err: err} + } + + // Add timeout to prevent hanging requests + client := &http.Client{ + Timeout: defaultTimeout, + } + + resp, err := client.Get(urlBuilt) + if err != nil { - return nil, fmt.Errorf("failed to make HTTP request: %w", err) + return nil, &httpGetError{err: err} } if resp == nil { - return nil, fmt.Errorf("api failed to respond") + return nil, &responseNilError{} } if resp.StatusCode != successStatus { @@ -86,7 +128,7 @@ func (myRegistry *Registry) GetLatest(module string) (*string, error) { body, err := io.ReadAll(resp.Body) if err != nil { - return nil, fmt.Errorf("failed to read body %w", err) + return nil, &responseReadError{err: err} } var msg map[string]interface{} @@ -94,7 +136,7 @@ func (myRegistry *Registry) GetLatest(module string) (*string, error) { err = json.Unmarshal(body, &msg) if err != nil { - return nil, fmt.Errorf("failed to read body %w", err) + return nil, &unmarshalJSONError{err: err} } var ok bool @@ -102,7 +144,7 @@ func (myRegistry *Registry) GetLatest(module string) (*string, error) { myRegistry.LatestVersion, ok = msg["version"].(string) if !ok { - return nil, fmt.Errorf("failed to find version in payload") + return nil, &castToStringError{"version"} } } diff --git a/src/core/types.go b/src/core/types.go index 9e9d4d1..bd1f97e 100644 --- a/src/core/types.go +++ b/src/core/types.go @@ -4,7 +4,7 @@ type Flags struct { File string Directory string GitHubToken string - Days int + Days uint DryRun bool Entries []string Update bool From f3d98562029a9b680fc584db5ea10db2090e2d93 Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Mon, 9 Dec 2024 11:13:35 +0000 Subject: [PATCH 70/80] handling uint to int --- src/core/filter.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/filter.go b/src/core/filter.go index 7118a95..500b267 100644 --- a/src/core/filter.go +++ b/src/core/filter.go @@ -44,7 +44,7 @@ func GetReleases(action string, gitHubToken string, days *uint) (map[string]inte } now := time.Now() - interval := time.Duration(*days * dayInNanos) + interval := time.Duration(*days * uint(dayInNanos)) limit := now.Add(-interval) url := apiBaseURL + action + "/releases" From 749e70da04b323beabc7de1d28dd042a36eecf0e Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Mon, 9 Dec 2024 11:43:13 +0000 Subject: [PATCH 71/80] handling uint to int --- src/core/filter.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/filter.go b/src/core/filter.go index 500b267..c282cf1 100644 --- a/src/core/filter.go +++ b/src/core/filter.go @@ -44,7 +44,7 @@ func GetReleases(action string, gitHubToken string, days *uint) (map[string]inte } now := time.Now() - interval := time.Duration(*days * uint(dayInNanos)) + interval := time.Duration(int(*days) * dayInNanos) limit := now.Add(-interval) url := apiBaseURL + action + "/releases" From 231d2713ee71f010105fbc81eb29f235fa613559 Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Mon, 9 Dec 2024 12:07:38 +0000 Subject: [PATCH 72/80] handling uint to int --- src/core/filter.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/filter.go b/src/core/filter.go index c282cf1..861a8b8 100644 --- a/src/core/filter.go +++ b/src/core/filter.go @@ -6,8 +6,8 @@ import ( ) const ( - dayInNanos = 24 * 60 * 60 * 1000 * 1000 * 1000 - apiBaseURL = "https://api.github.com/repos/" + dayInNanos int64 = 24 * 60 * 60 * 1000 * 1000 * 1000 + apiBaseURL = "https://api.github.com/repos/" ) type githubTokenIsEmptyError struct{} @@ -44,7 +44,7 @@ func GetReleases(action string, gitHubToken string, days *uint) (map[string]inte } now := time.Now() - interval := time.Duration(int(*days) * dayInNanos) + interval := time.Duration(int64(*days) * dayInNanos) limit := now.Add(-interval) url := apiBaseURL + action + "/releases" From 111c1f4d829cff490dec68edcfa63ab194e7aefa Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Fri, 13 Dec 2024 09:36:08 +0000 Subject: [PATCH 73/80] unit test coverrage --- .github/workflows/ci.yml | 2 +- .github/workflows/codeql-analysis.yml | 6 ++--- .github/workflows/pr.yml | 6 ++--- .github/workflows/release.yml | 2 +- src/core/error.go | 20 ++++++++++++++ src/core/error_test.go | 26 +++++++++++++++++++ src/core/filter.go | 20 -------------- .../testdata/gha/.github/workflows/test.yml | 2 +- 8 files changed, 55 insertions(+), 29 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 02ffc17..bbd642d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ jobs: steps: ## sets up go based on the version - name: Install Go - uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 + uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0 with: go-version: ${{ matrix.go-version }} diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 0f69e85..fb7d584 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -43,7 +43,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@cba5fb58d4f85affaf03eb9da32f5b6c9d76838b # codeql-bundle-v2.19.4 + uses: github/codeql-action/init@3096afedf9873361b2b2f65e1445b13272c83eb8 # codeql-bundle-v2.20.0 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -53,7 +53,7 @@ jobs: # 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@cba5fb58d4f85affaf03eb9da32f5b6c9d76838b # codeql-bundle-v2.19.4 + uses: github/codeql-action/autobuild@3096afedf9873361b2b2f65e1445b13272c83eb8 # codeql-bundle-v2.20.0 # â„šī¸ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun @@ -66,4 +66,4 @@ jobs: # ./location_of_script_within_repo/buildscript.sh - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@cba5fb58d4f85affaf03eb9da32f5b6c9d76838b # codeql-bundle-v2.19.4 + uses: github/codeql-action/analyze@3096afedf9873361b2b2f65e1445b13272c83eb8 # codeql-bundle-v2.20.0 diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 7a47a2a..09c36ca 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -10,7 +10,7 @@ jobs: - name: Checkout code uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Install Go - uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 + uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0 with: go-version: 1.21.x - name: Restore cache @@ -32,7 +32,7 @@ jobs: - name: Checkout code uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Install Go - uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 + uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0 with: go-version: ${{ matrix.go-version }} - name: Restore cache @@ -50,6 +50,6 @@ jobs: - name: Checkout code uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Install Go - uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 + uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0 with: go-version: 1.21.x diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 11b8991..9782689 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,7 +15,7 @@ jobs: - name: Unshallow run: git fetch --prune --unshallow - name: Set up Go - uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 + uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0 with: go-version: 1.21 - name: Import GPG key diff --git a/src/core/error.go b/src/core/error.go index e6b4203..7f8f510 100644 --- a/src/core/error.go +++ b/src/core/error.go @@ -174,3 +174,23 @@ type responseNilError struct { func (m *responseNilError) Error() string { return "api response is nil" } + +type githubTokenIsEmptyError struct{} + +func (e githubTokenIsEmptyError) Error() string { + return "github token is empty" +} + +type timeParsingError struct { + err error +} + +func (e timeParsingError) Error() string { + return fmt.Sprintf("failed to parse time %v", e.err) +} + +type daysParameterError struct{} + +func (e daysParameterError) Error() string { + return "days parameter must be positive" +} diff --git a/src/core/error_test.go b/src/core/error_test.go index b2a33a4..2935cf1 100644 --- a/src/core/error_test.go +++ b/src/core/error_test.go @@ -1,6 +1,7 @@ package core import ( + "errors" "fmt" "testing" ) @@ -331,3 +332,28 @@ func TestResponseNilError(t *testing.T) { t.Errorf("Expected error message '%s', got '%s'", expected, err.Error()) } } + +func TestTimeParsingError(t *testing.T) { + testErr := errors.New("test error") + err := timeParsingError{err: testErr} + + expected := "failed to parse time test error" + if got := err.Error(); got != expected { + t.Errorf("timeParsingError.Error() = %v, want %v", got, expected) + } +} + +func TestDaysParameterError(t *testing.T) { + err := daysParameterError{} + + expected := "days parameter must be positive" + if got := err.Error(); got != expected { + t.Errorf("daysParameterError.Error() = %v, want %v", got, expected) + } +} + +func TestErrorInterfaces(t *testing.T) { + // Verify types implement error interface + var _ error = timeParsingError{} + var _ error = daysParameterError{} +} diff --git a/src/core/filter.go b/src/core/filter.go index 861a8b8..a449619 100644 --- a/src/core/filter.go +++ b/src/core/filter.go @@ -10,26 +10,6 @@ const ( apiBaseURL = "https://api.github.com/repos/" ) -type githubTokenIsEmptyError struct{} - -func (e githubTokenIsEmptyError) Error() string { - return "github token is empty" -} - -type timeParsingError struct { - err error -} - -func (e timeParsingError) Error() string { - return fmt.Sprintf("failed to parse time %v", e.err) -} - -type daysParameterError struct{} - -func (e daysParameterError) Error() string { - return "days parameter must be positive" -} - func GetReleases(action string, gitHubToken string, days *uint) (map[string]interface{}, error) { if days == nil { return nil, &daysParameterError{} diff --git a/src/core/testdata/gha/.github/workflows/test.yml b/src/core/testdata/gha/.github/workflows/test.yml index 7704a4f..62a0552 100644 --- a/src/core/testdata/gha/.github/workflows/test.yml +++ b/src/core/testdata/gha/.github/workflows/test.yml @@ -25,7 +25,7 @@ jobs: steps: ## sets up go based on the version - name: Install Go - uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 + uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0 with: go-version: ${{ matrix.go-version }} From 9c93b4041904d329ee4039a97225ede8d7100134 Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Fri, 13 Dec 2024 09:47:38 +0000 Subject: [PATCH 74/80] unit test coverrage --- .pre-commit-config.yaml | 2 +- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8560213..63750c2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -66,7 +66,7 @@ repos: - -d - . repo: https://github.com/bridgecrewio/checkov - rev: 28d642c33cee90f21d7d9dea13f14860878ce27d + rev: 3.2.334 - hooks: - id: ghat-go name: ghat diff --git a/go.mod b/go.mod index d90c7bb..db988a8 100644 --- a/go.mod +++ b/go.mod @@ -39,7 +39,7 @@ require ( github.com/skeema/knownhosts v1.3.0 // indirect github.com/xanzy/ssh-agent v0.3.3 // indirect github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect - golang.org/x/crypto v0.30.0 // indirect + golang.org/x/crypto v0.31.0 // indirect golang.org/x/net v0.32.0 // indirect golang.org/x/sync v0.10.0 // indirect golang.org/x/sys v0.28.0 // indirect diff --git a/go.sum b/go.sum index 1784bcb..d87d9ea 100644 --- a/go.sum +++ b/go.sum @@ -101,8 +101,8 @@ github.com/zclconf/go-cty v1.15.1/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgr github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940 h1:4r45xpDWB6ZMSMNJFMOjqrGHynW3DIBuR2H9j0ug+Mo= github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940/go.mod h1:CmBdvvj3nqzfzJ6nTCIwDTPZ56aVGvDrmztiO5g3qrM= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.30.0 h1:RwoQn3GkWiMkzlX562cLB7OxWvjH1L8xutO2WoJcRoY= -golang.org/x/crypto v0.30.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= +golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U= +golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8= golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY= golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4= From 398a0df33f4c66a60bff3cc3f489b81543fcce01 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 6 Feb 2025 14:09:53 +0000 Subject: [PATCH 75/80] Bump github.com/go-git/go-git/v5 from 5.12.0 to 5.13.0 Bumps [github.com/go-git/go-git/v5](https://github.com/go-git/go-git) from 5.12.0 to 5.13.0. - [Release notes](https://github.com/go-git/go-git/releases) - [Commits](https://github.com/go-git/go-git/compare/v5.12.0...v5.13.0) --- updated-dependencies: - dependency-name: github.com/go-git/go-git/v5 dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- go.mod | 4 ++-- go.sum | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/go.mod b/go.mod index db988a8..1398ee2 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/jameswoolfenden/ghat go 1.22.2 require ( - github.com/go-git/go-git/v5 v5.12.0 + github.com/go-git/go-git/v5 v5.13.0 github.com/hashicorp/hcl/v2 v2.23.0 github.com/rs/zerolog v1.33.0 github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 @@ -40,7 +40,7 @@ require ( github.com/xanzy/ssh-agent v0.3.3 // indirect github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect golang.org/x/crypto v0.31.0 // indirect - golang.org/x/net v0.32.0 // indirect + golang.org/x/net v0.33.0 // indirect golang.org/x/sync v0.10.0 // indirect golang.org/x/sys v0.28.0 // indirect golang.org/x/text v0.21.0 // indirect diff --git a/go.sum b/go.sum index d87d9ea..b0117a1 100644 --- a/go.sum +++ b/go.sum @@ -23,20 +23,20 @@ github.com/cyphar/filepath-securejoin v0.3.5/go.mod h1:edhVd3c6OXKjUmSrVa/tGJRS9 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a h1:mATvB/9r/3gvcejNsXKSkQ6lcIaNec2nyfOdlTBR2lU= -github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a/go.mod h1:Ro8st/ElPeALwNFlcTpWmkr6IoMFfkjXAvTHpevnDsM= +github.com/elazarl/goproxy v1.2.1 h1:njjgvO6cRG9rIqN2ebkqy6cQz2Njkx7Fsfv/zIZqgug= +github.com/elazarl/goproxy v1.2.1/go.mod h1:YfEbZtqP4AetfO6d40vWchF3znWX7C7Vd6ZMfdL8z64= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= -github.com/gliderlabs/ssh v0.3.7 h1:iV3Bqi942d9huXnzEF2Mt+CY9gLu8DNM4Obd+8bODRE= -github.com/gliderlabs/ssh v0.3.7/go.mod h1:zpHEXBstFnQYtGnB8k8kQLol82umzn/2/snG7alWVD8= +github.com/gliderlabs/ssh v0.3.8 h1:a4YXD1V7xMF9g5nTkdfnja3Sxy1PVDCj1Zg4Wb8vY6c= +github.com/gliderlabs/ssh v0.3.8/go.mod h1:xYoytBv1sV0aL3CavoDuJIQNURXkkfPA/wxQ1pL1fAU= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic= github.com/go-git/go-billy/v5 v5.6.0 h1:w2hPNtoehvJIxR00Vb4xX94qHQi/ApZfX+nBE2Cjio8= github.com/go-git/go-billy/v5 v5.6.0/go.mod h1:sFDq7xD3fn3E0GOwUSZqHo9lrkmx8xJhA0ZrfvjBRGM= github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399 h1:eMje31YglSBqCdIqdhKBW8lokaMrL3uTkpGYlE2OOT4= github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399/go.mod h1:1OCfN199q1Jm3HZlxleg+Dw/mwps2Wbk9frAWm+4FII= -github.com/go-git/go-git/v5 v5.12.0 h1:7Md+ndsjrzZxbddRDZjF14qK+NN56sy6wkqaVrjZtys= -github.com/go-git/go-git/v5 v5.12.0/go.mod h1:FTM9VKtnI2m65hNI/TenDDDnUf2Q9FHnXYjuz9i5OEY= +github.com/go-git/go-git/v5 v5.13.0 h1:vLn5wlGIh/X78El6r3Jr+30W16Blk0CTcxTYcYPWi5E= +github.com/go-git/go-git/v5 v5.13.0/go.mod h1:Wjo7/JyVKtQgUNdXYXIepzWfJQkUEIGvkvVkiXRR/zw= github.com/go-test/deep v1.1.0 h1:WOcxcdHcvdgThNXjw0t76K42FXTU7HpNQWHpA2HHNlg= github.com/go-test/deep v1.1.0/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= @@ -88,8 +88,8 @@ github.com/skeema/knownhosts v1.3.0/go.mod h1:sPINvnADmT/qYH1kfv+ePMmOBTH6Tbl7b5 github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/urfave/cli/v2 v2.27.5 h1:WoHEJLdsXr6dDWoJgMq/CboDmyY/8HMMH1fTECbih+w= github.com/urfave/cli/v2 v2.27.5/go.mod h1:3Sevf16NykTbInEnD0yKkjDAeZDS0A6bzhBH5hrMvTQ= github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= @@ -108,8 +108,8 @@ golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbR golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4= golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= -golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= +golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= +golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= From 40835a8ddca922a089f682f1eed7cc4a5b772b7f Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Mon, 17 Mar 2025 17:06:57 +0000 Subject: [PATCH 76/80] upgrade go --- .github/workflows/ci.yml | 6 +-- .github/workflows/codeql-analysis.yml | 6 +-- .github/workflows/pr.yml | 23 +++++---- .github/workflows/release.yml | 6 +-- .github/workflows/stale.yml | 2 +- .pre-commit-config.yaml | 6 +-- go.mod | 40 +++++++-------- go.sum | 50 +++++++++++++++++++ .../faulty/.github/workflows/test.yml | 2 +- src/core/testdata/files/ci.yml | 2 +- .../testdata/gha/.github/workflows/test.yml | 4 +- 11 files changed, 101 insertions(+), 46 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bbd642d..ecba30b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,7 @@ jobs: ## this will contain a matrix of all the combinations ## we wish to test again: matrix: - go-version: [ 1.21.x ] + go-version: [ 1.24.x ] platform: [ ubuntu-latest, macos-latest, windows-latest ] ## Defines the platform for each test run @@ -25,7 +25,7 @@ jobs: steps: ## sets up go based on the version - name: Install Go - uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0 + uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0 with: go-version: ${{ matrix.go-version }} @@ -42,6 +42,6 @@ jobs: run: go test ./... -coverprofile=./cover.out - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@b21b58fad3ac66e668f9b08d01599ffff6f2cada # v5.1.1 + uses: codecov/codecov-action@e96185f4044c2f0cedf0f022454acf9811cf8057 # v5.4.0 env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index fb7d584..f998e34 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -43,7 +43,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@3096afedf9873361b2b2f65e1445b13272c83eb8 # codeql-bundle-v2.20.0 + uses: github/codeql-action/init@80f993039571a6de66594ecaa432875a6942e8e0 # codeql-bundle-v2.20.6 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -53,7 +53,7 @@ jobs: # 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@3096afedf9873361b2b2f65e1445b13272c83eb8 # codeql-bundle-v2.20.0 + uses: github/codeql-action/autobuild@80f993039571a6de66594ecaa432875a6942e8e0 # codeql-bundle-v2.20.6 # â„šī¸ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun @@ -66,4 +66,4 @@ jobs: # ./location_of_script_within_repo/buildscript.sh - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@3096afedf9873361b2b2f65e1445b13272c83eb8 # codeql-bundle-v2.20.0 + uses: github/codeql-action/analyze@80f993039571a6de66594ecaa432875a6942e8e0 # codeql-bundle-v2.20.6 diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 09c36ca..219acbf 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -10,11 +10,11 @@ jobs: - name: Checkout code uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Install Go - uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0 + uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0 with: - go-version: 1.21.x + go-version: 1.24.x - name: Restore cache - uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 + uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2 with: path: ~/go/pkg/mod key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} @@ -25,31 +25,36 @@ jobs: test: strategy: matrix: - go-version: [ 1.21.x ] + go-version: [ 1.24.x ] platform: [ ubuntu-latest, macos-latest, windows-latest ] runs-on: ${{ matrix.platform }} steps: - name: Checkout code uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Install Go - uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0 + uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0 with: go-version: ${{ matrix.go-version }} - name: Restore cache - uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 + uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2 with: path: ~/go/pkg/mod key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} restore-keys: | ${{ runner.os }}-go-mod- + ## runs go test ./... + - name: Build + run: go build ./... + + ## runs go test ./... - name: Test - run: make test + run: go test ./... -coverprofile=./cover.out docs: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Install Go - uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0 + uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0 with: - go-version: 1.21.x + go-version: 1.24.x diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9782689..861891f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,9 +15,9 @@ jobs: - name: Unshallow run: git fetch --prune --unshallow - name: Set up Go - uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0 + uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0 with: - go-version: 1.21 + go-version: 1.24 - name: Import GPG key id: import_gpg uses: crazy-max/ghaction-import-gpg@cb9bde2e2525e640591a934b1fd28eef1dcaf5e5 # v6.2.0 @@ -25,7 +25,7 @@ jobs: gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} passphrase: ${{ secrets.PASSPHRASE }} - name: Run GoReleaser - uses: goreleaser/goreleaser-action@9ed2f89a662bf1735a48bc8557fd212fa902bebf # v6.1.0 + uses: goreleaser/goreleaser-action@90a3faa9d0182683851fbfa97ca1a2cb983bfca3 # v6.2.1 with: version: latest args: release --clean diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 1481a9d..663f980 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -13,7 +13,7 @@ jobs: pull-requests: write runs-on: ubuntu-latest steps: - - uses: actions/stale@28ca1036281a5e5922ead5184a1bbf96e5fc984e # v9.0.0 + - uses: actions/stale@5bef64f19d7facfb25b37b414482c7164d639639 # v9.1.0 with: stale-issue-message: 'This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.' days-before-stale: 30 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 63750c2..2c21be4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -36,7 +36,7 @@ repos: - id: markdownlint exclude: src/testdata|testdata repo: https://github.com/igorshubovych/markdownlint-cli - rev: 0d9fcb51a54f3b750b911c054b4bd1a590f1b592 + rev: 586c3ea3f51230da42bab657c6a32e9e66c364f0 - hooks: - id: terraform-fmt language_version: python3.11 @@ -46,7 +46,7 @@ repos: - id: gofmt - id: goimports repo: https://github.com/gruntwork-io/pre-commit - rev: a2d20160412a9bd26a11ff45987c0e178d7e10c3 + rev: 8481dc99cc5502ae867e66c339732d9ad7f2e1da - hooks: - id: go-test args: @@ -58,7 +58,7 @@ repos: - hooks: - id: golangci-lint repo: https://github.com/golangci/golangci-lint - rev: 89476e7a1eaa0a8a06c17343af960a5fd9e7edb7 + rev: 8cffdb7d21e5b2b89f163f70c60ac9686c9d6180 - hooks: - id: checkov language_version: python3.11 diff --git a/go.mod b/go.mod index 1398ee2..14762ab 100644 --- a/go.mod +++ b/go.mod @@ -1,15 +1,15 @@ module github.com/jameswoolfenden/ghat -go 1.22.2 +go 1.24.1 require ( - github.com/go-git/go-git/v5 v5.13.0 + github.com/go-git/go-git/v5 v5.14.0 github.com/hashicorp/hcl/v2 v2.23.0 github.com/rs/zerolog v1.33.0 github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 - github.com/urfave/cli/v2 v2.27.5 - github.com/zclconf/go-cty v1.15.1 - golang.org/x/mod v0.22.0 + github.com/urfave/cli/v2 v2.27.6 + github.com/zclconf/go-cty v1.16.2 + golang.org/x/mod v0.24.0 gopkg.in/yaml.v3 v3.0.1 moul.io/banner v1.0.1 ) @@ -17,33 +17,33 @@ require ( require ( dario.cat/mergo v1.0.1 // indirect github.com/Microsoft/go-winio v0.6.2 // indirect - github.com/ProtonMail/go-crypto v1.1.3 // indirect + github.com/ProtonMail/go-crypto v1.1.6 // indirect github.com/agext/levenshtein v1.2.3 // indirect github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect - github.com/cloudflare/circl v1.5.0 // indirect + github.com/cloudflare/circl v1.6.0 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.5 // indirect - github.com/cyphar/filepath-securejoin v0.3.5 // indirect + github.com/cyphar/filepath-securejoin v0.4.1 // indirect github.com/emirpasic/gods v1.18.1 // indirect github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect - github.com/go-git/go-billy/v5 v5.6.0 // indirect - github.com/go-test/deep v1.1.0 // indirect + github.com/go-git/go-billy/v5 v5.6.2 // indirect + github.com/go-test/deep v1.1.1 // indirect github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect - github.com/google/go-cmp v0.6.0 // indirect + github.com/google/go-cmp v0.7.0 // indirect github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect github.com/kevinburke/ssh_config v1.2.0 // indirect - github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-colorable v0.1.14 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mitchellh/go-wordwrap v1.0.1 // indirect - github.com/pjbgf/sha1cd v0.3.0 // indirect + github.com/pjbgf/sha1cd v0.3.2 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect - github.com/skeema/knownhosts v1.3.0 // indirect + github.com/skeema/knownhosts v1.3.1 // indirect github.com/xanzy/ssh-agent v0.3.3 // indirect github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect - golang.org/x/crypto v0.31.0 // indirect - golang.org/x/net v0.33.0 // indirect - golang.org/x/sync v0.10.0 // indirect - golang.org/x/sys v0.28.0 // indirect - golang.org/x/text v0.21.0 // indirect - golang.org/x/tools v0.28.0 // indirect + golang.org/x/crypto v0.36.0 // indirect + golang.org/x/net v0.37.0 // indirect + golang.org/x/sync v0.12.0 // indirect + golang.org/x/sys v0.31.0 // indirect + golang.org/x/text v0.23.0 // indirect + golang.org/x/tools v0.31.0 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect ) diff --git a/go.sum b/go.sum index b0117a1..eca1034 100644 --- a/go.sum +++ b/go.sum @@ -5,6 +5,10 @@ github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERo github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= github.com/ProtonMail/go-crypto v1.1.3 h1:nRBOetoydLeUb4nHajyO2bKqMLfWQ/ZPwkXqXxPxCFk= github.com/ProtonMail/go-crypto v1.1.3/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE= +github.com/ProtonMail/go-crypto v1.1.5 h1:eoAQfK2dwL+tFSFpr7TbOaPNUbPiJj4fLYwwGE1FQO4= +github.com/ProtonMail/go-crypto v1.1.5/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE= +github.com/ProtonMail/go-crypto v1.1.6 h1:ZcV+Ropw6Qn0AX9brlQLAUXfqLBc7Bl+f/DmNxpLfdw= +github.com/ProtonMail/go-crypto v1.1.6/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE= github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8= @@ -15,16 +19,21 @@ github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPd github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/cloudflare/circl v1.5.0 h1:hxIWksrX6XN5a1L2TI/h53AGPhNHoUBo+TD1ms9+pys= github.com/cloudflare/circl v1.5.0/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZh3pJrofs= +github.com/cloudflare/circl v1.6.0 h1:cr5JKic4HI+LkINy2lg3W2jF8sHCVTBncJr5gIIq7qk= +github.com/cloudflare/circl v1.6.0/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZh3pJrofs= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/cpuguy83/go-md2man/v2 v2.0.5 h1:ZtcqGrnekaHpVLArFSe4HK5DoKx1T0rq2DwVB0alcyc= github.com/cpuguy83/go-md2man/v2 v2.0.5/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/cyphar/filepath-securejoin v0.3.5 h1:L81NHjquoQmcPgXcttUS9qTSR/+bXry6pbSINQGpjj4= github.com/cyphar/filepath-securejoin v0.3.5/go.mod h1:edhVd3c6OXKjUmSrVa/tGJRS9joFTxlslFCAyaxigkE= +github.com/cyphar/filepath-securejoin v0.4.1 h1:JyxxyPEaktOD+GAnqIqTf9A8tHyAG22rowi7HkoSU1s= +github.com/cyphar/filepath-securejoin v0.4.1/go.mod h1:Sdj7gXlvMcPZsbhwhQ33GguGLDGQL7h7bg04C/+u9jI= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/elazarl/goproxy v1.2.1 h1:njjgvO6cRG9rIqN2ebkqy6cQz2Njkx7Fsfv/zIZqgug= github.com/elazarl/goproxy v1.2.1/go.mod h1:YfEbZtqP4AetfO6d40vWchF3znWX7C7Vd6ZMfdL8z64= +github.com/elazarl/goproxy v1.7.2 h1:Y2o6urb7Eule09PjlhQRGNsqRfPmYI3KKQLFpCAV3+o= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= github.com/gliderlabs/ssh v0.3.8 h1:a4YXD1V7xMF9g5nTkdfnja3Sxy1PVDCj1Zg4Wb8vY6c= @@ -33,17 +42,25 @@ github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66D github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic= github.com/go-git/go-billy/v5 v5.6.0 h1:w2hPNtoehvJIxR00Vb4xX94qHQi/ApZfX+nBE2Cjio8= github.com/go-git/go-billy/v5 v5.6.0/go.mod h1:sFDq7xD3fn3E0GOwUSZqHo9lrkmx8xJhA0ZrfvjBRGM= +github.com/go-git/go-billy/v5 v5.6.2 h1:6Q86EsPXMa7c3YZ3aLAQsMA0VlWmy43r6FHqa/UNbRM= +github.com/go-git/go-billy/v5 v5.6.2/go.mod h1:rcFC2rAsp/erv7CMz9GczHcuD0D32fWzH+MJAU+jaUU= github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399 h1:eMje31YglSBqCdIqdhKBW8lokaMrL3uTkpGYlE2OOT4= github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399/go.mod h1:1OCfN199q1Jm3HZlxleg+Dw/mwps2Wbk9frAWm+4FII= github.com/go-git/go-git/v5 v5.13.0 h1:vLn5wlGIh/X78El6r3Jr+30W16Blk0CTcxTYcYPWi5E= github.com/go-git/go-git/v5 v5.13.0/go.mod h1:Wjo7/JyVKtQgUNdXYXIepzWfJQkUEIGvkvVkiXRR/zw= +github.com/go-git/go-git/v5 v5.14.0 h1:/MD3lCrGjCen5WfEAzKg00MJJffKhC8gzS80ycmCi60= +github.com/go-git/go-git/v5 v5.14.0/go.mod h1:Z5Xhoia5PcWA3NF8vRLURn9E5FRhSl7dGj9ItW3Wk5k= github.com/go-test/deep v1.1.0 h1:WOcxcdHcvdgThNXjw0t76K42FXTU7HpNQWHpA2HHNlg= github.com/go-test/deep v1.1.0/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE= +github.com/go-test/deep v1.1.1 h1:0r/53hagsehfO4bzD2Pgr/+RgHqhmf+k1Bpse2cTu1U= +github.com/go-test/deep v1.1.1/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 h1:f+oWsMOmNPc8JmEHVZIycC7hBoQxHH9pNKQORJNozsQ= github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8/go.mod h1:wcDNUvekVysuuOpQKo3191zZyTpiI6se1N1ULghS0sw= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/hashicorp/hcl/v2 v2.23.0 h1:Fphj1/gCylPxHutVSEOf2fBOh1VE4AuLV7+kbJf3qos= github.com/hashicorp/hcl/v2 v2.23.0/go.mod h1:62ZYHrXgPoX8xBnzl8QzbWq4dyDsDtfCRgIq1rbJEvA= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= @@ -59,6 +76,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= +github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= @@ -69,12 +88,15 @@ github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k= github.com/onsi/gomega v1.34.1/go.mod h1:kU1QgUvBDLXBJq618Xvm2LUX6rSAfRaFRTcdOeDLwwY= github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4= github.com/pjbgf/sha1cd v0.3.0/go.mod h1:nZ1rrWOcGJ5uZgEEVL1VUM9iRQiZvWdbZjkKyFzPPsI= +github.com/pjbgf/sha1cd v0.3.2 h1:a9wb0bp1oC2TGwStyn0Umc/IGKQnEgF0vVaZ8QF8eo4= +github.com/pjbgf/sha1cd v0.3.2/go.mod h1:zQWigSxVmsHEZow5qaLtPYxpcKMMQpa09ixqBxuCS6A= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= +github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ= github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8= github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= @@ -85,6 +107,8 @@ github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/skeema/knownhosts v1.3.0 h1:AM+y0rI04VksttfwjkSTNQorvGqmwATnvnAHpSgc0LY= github.com/skeema/knownhosts v1.3.0/go.mod h1:sPINvnADmT/qYH1kfv+ePMmOBTH6Tbl7b5LvTDjFK7M= +github.com/skeema/knownhosts v1.3.1 h1:X2osQ+RAjK76shCbvhHHHVl3ZlgDm8apHEHFqRjnBY8= +github.com/skeema/knownhosts v1.3.1/go.mod h1:r7KTdC8l4uxWRyK2TpQZ/1o5HaSzh06ePQNxPwTcfiY= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= @@ -92,26 +116,43 @@ github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOf github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/urfave/cli/v2 v2.27.5 h1:WoHEJLdsXr6dDWoJgMq/CboDmyY/8HMMH1fTECbih+w= github.com/urfave/cli/v2 v2.27.5/go.mod h1:3Sevf16NykTbInEnD0yKkjDAeZDS0A6bzhBH5hrMvTQ= +github.com/urfave/cli/v2 v2.27.6 h1:VdRdS98FNhKZ8/Az8B7MTyGQmpIr36O1EHybx/LaZ4g= +github.com/urfave/cli/v2 v2.27.6/go.mod h1:3Sevf16NykTbInEnD0yKkjDAeZDS0A6bzhBH5hrMvTQ= github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4= github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM= github.com/zclconf/go-cty v1.15.1 h1:RgQYm4j2EvoBRXOPxhUvxPzRrGDo1eCOhHXuGfrj5S0= github.com/zclconf/go-cty v1.15.1/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= +github.com/zclconf/go-cty v1.16.2 h1:LAJSwc3v81IRBZyUVQDUdZ7hs3SYs9jv0eZJDWHD/70= +github.com/zclconf/go-cty v1.16.2/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940 h1:4r45xpDWB6ZMSMNJFMOjqrGHynW3DIBuR2H9j0ug+Mo= github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940/go.mod h1:CmBdvvj3nqzfzJ6nTCIwDTPZ56aVGvDrmztiO5g3qrM= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U= golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= +golang.org/x/crypto v0.35.0 h1:b15kiHdrGCHrP6LvwaQ3c03kgNhhiMgvlhxHQhmg2Xs= +golang.org/x/crypto v0.35.0/go.mod h1:dy7dXNW32cAb/6/PRuTNsix8T+vJAqvuIy5Bli/x0YQ= +golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34= +golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc= golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8= golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY= golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4= golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= +golang.org/x/mod v0.24.0 h1:ZfthKaKaT4NrhGVZHO1/WDTwGES4De8KtWO0SIbNJMU= +golang.org/x/mod v0.24.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= +golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8= +golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk= +golang.org/x/net v0.37.0 h1:1zLorHbz+LYj7MQlSf1+2tPIIgibq2eL5xkrGk6f+2c= +golang.org/x/net v0.37.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw= +golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -123,15 +164,24 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc= +golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik= +golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q= golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= +golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY= +golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= +golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.28.0 h1:WuB6qZ4RPCQo5aP3WdKZS7i595EdWqWR8vqJTlwTVK8= golang.org/x/tools v0.28.0/go.mod h1:dcIOrVd3mfQKTgrDVQHqCPMWy6lnhfhtX3hLXYVLfRw= +golang.org/x/tools v0.31.0 h1:0EedkvKDbh+qistFTd0Bcwe/YLh4vHwWEkiI0toFIBU= +golang.org/x/tools v0.31.0/go.mod h1:naFTU+Cev749tSJRXJlna0T3WxKvb1kWEx15xA4SdmQ= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= diff --git a/src/core/testdata/faulty/.github/workflows/test.yml b/src/core/testdata/faulty/.github/workflows/test.yml index c374aad..ed0df1a 100644 --- a/src/core/testdata/faulty/.github/workflows/test.yml +++ b/src/core/testdata/faulty/.github/workflows/test.yml @@ -14,7 +14,7 @@ jobs: ## this will contain a matrix of all the combinations ## we wish to test again: matrix: - go-version: [ 1.21.x ] + go-version: [ 1.24.x ] platform: [ ubuntu-latest, macos-latest, windows-latest ] ## Defines the platform for each test run diff --git a/src/core/testdata/files/ci.yml b/src/core/testdata/files/ci.yml index ed677c6..bf5bb85 100644 --- a/src/core/testdata/files/ci.yml +++ b/src/core/testdata/files/ci.yml @@ -13,7 +13,7 @@ jobs: ## this will contain a matrix of all the combinations ## we wish to test again: matrix: - go-version: [ 1.21.x ] + go-version: [ 1.24.x ] platform: [ ubuntu-latest, macos-latest, windows-latest ] ## Defines the platform for each test run diff --git a/src/core/testdata/gha/.github/workflows/test.yml b/src/core/testdata/gha/.github/workflows/test.yml index 62a0552..28c8fe2 100644 --- a/src/core/testdata/gha/.github/workflows/test.yml +++ b/src/core/testdata/gha/.github/workflows/test.yml @@ -14,7 +14,7 @@ jobs: ## this will contain a matrix of all the combinations ## we wish to test again: matrix: - go-version: [ 1.21.x ] + go-version: [ 1.24.x ] platform: [ ubuntu-latest, macos-latest, windows-latest ] ## Defines the platform for each test run @@ -25,7 +25,7 @@ jobs: steps: ## sets up go based on the version - name: Install Go - uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0 + uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0 with: go-version: ${{ matrix.go-version }} From 11c568d6cb9bcb95efcddfc1c3e32bfba558e766 Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Mon, 17 Mar 2025 17:07:38 +0000 Subject: [PATCH 77/80] upgrade go --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 14762ab..79af94f 100644 --- a/go.mod +++ b/go.mod @@ -21,7 +21,7 @@ require ( github.com/agext/levenshtein v1.2.3 // indirect github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect github.com/cloudflare/circl v1.6.0 // indirect - github.com/cpuguy83/go-md2man/v2 v2.0.5 // indirect + github.com/cpuguy83/go-md2man/v2 v2.0.6 // indirect github.com/cyphar/filepath-securejoin v0.4.1 // indirect github.com/emirpasic/gods v1.18.1 // indirect github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect diff --git a/go.sum b/go.sum index eca1034..df252b0 100644 --- a/go.sum +++ b/go.sum @@ -24,6 +24,8 @@ github.com/cloudflare/circl v1.6.0/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZ github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/cpuguy83/go-md2man/v2 v2.0.5 h1:ZtcqGrnekaHpVLArFSe4HK5DoKx1T0rq2DwVB0alcyc= github.com/cpuguy83/go-md2man/v2 v2.0.5/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/cpuguy83/go-md2man/v2 v2.0.6 h1:XJtiaUW6dEEqVuZiMTn1ldk455QWwEIsMIJlo5vtkx0= +github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= github.com/cyphar/filepath-securejoin v0.3.5 h1:L81NHjquoQmcPgXcttUS9qTSR/+bXry6pbSINQGpjj4= github.com/cyphar/filepath-securejoin v0.3.5/go.mod h1:edhVd3c6OXKjUmSrVa/tGJRS9joFTxlslFCAyaxigkE= github.com/cyphar/filepath-securejoin v0.4.1 h1:JyxxyPEaktOD+GAnqIqTf9A8tHyAG22rowi7HkoSU1s= From f5c7b1db6d5c53c6d99ecf3e1edb340b4d4ce0fc Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Mon, 17 Mar 2025 17:17:41 +0000 Subject: [PATCH 78/80] version changes --- go.sum | 59 +++------------------------------------- src/core/modules_test.go | 16 +++++------ 2 files changed, 12 insertions(+), 63 deletions(-) diff --git a/go.sum b/go.sum index df252b0..ce63baa 100644 --- a/go.sum +++ b/go.sum @@ -3,10 +3,6 @@ dario.cat/mergo v1.0.1/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= -github.com/ProtonMail/go-crypto v1.1.3 h1:nRBOetoydLeUb4nHajyO2bKqMLfWQ/ZPwkXqXxPxCFk= -github.com/ProtonMail/go-crypto v1.1.3/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE= -github.com/ProtonMail/go-crypto v1.1.5 h1:eoAQfK2dwL+tFSFpr7TbOaPNUbPiJj4fLYwwGE1FQO4= -github.com/ProtonMail/go-crypto v1.1.5/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE= github.com/ProtonMail/go-crypto v1.1.6 h1:ZcV+Ropw6Qn0AX9brlQLAUXfqLBc7Bl+f/DmNxpLfdw= github.com/ProtonMail/go-crypto v1.1.6/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE= github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= @@ -17,50 +13,35 @@ github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= -github.com/cloudflare/circl v1.5.0 h1:hxIWksrX6XN5a1L2TI/h53AGPhNHoUBo+TD1ms9+pys= -github.com/cloudflare/circl v1.5.0/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZh3pJrofs= github.com/cloudflare/circl v1.6.0 h1:cr5JKic4HI+LkINy2lg3W2jF8sHCVTBncJr5gIIq7qk= github.com/cloudflare/circl v1.6.0/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZh3pJrofs= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= -github.com/cpuguy83/go-md2man/v2 v2.0.5 h1:ZtcqGrnekaHpVLArFSe4HK5DoKx1T0rq2DwVB0alcyc= -github.com/cpuguy83/go-md2man/v2 v2.0.5/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/cpuguy83/go-md2man/v2 v2.0.6 h1:XJtiaUW6dEEqVuZiMTn1ldk455QWwEIsMIJlo5vtkx0= github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= -github.com/cyphar/filepath-securejoin v0.3.5 h1:L81NHjquoQmcPgXcttUS9qTSR/+bXry6pbSINQGpjj4= -github.com/cyphar/filepath-securejoin v0.3.5/go.mod h1:edhVd3c6OXKjUmSrVa/tGJRS9joFTxlslFCAyaxigkE= github.com/cyphar/filepath-securejoin v0.4.1 h1:JyxxyPEaktOD+GAnqIqTf9A8tHyAG22rowi7HkoSU1s= github.com/cyphar/filepath-securejoin v0.4.1/go.mod h1:Sdj7gXlvMcPZsbhwhQ33GguGLDGQL7h7bg04C/+u9jI= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/elazarl/goproxy v1.2.1 h1:njjgvO6cRG9rIqN2ebkqy6cQz2Njkx7Fsfv/zIZqgug= -github.com/elazarl/goproxy v1.2.1/go.mod h1:YfEbZtqP4AetfO6d40vWchF3znWX7C7Vd6ZMfdL8z64= github.com/elazarl/goproxy v1.7.2 h1:Y2o6urb7Eule09PjlhQRGNsqRfPmYI3KKQLFpCAV3+o= +github.com/elazarl/goproxy v1.7.2/go.mod h1:82vkLNir0ALaW14Rc399OTTjyNREgmdL2cVoIbS6XaE= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= github.com/gliderlabs/ssh v0.3.8 h1:a4YXD1V7xMF9g5nTkdfnja3Sxy1PVDCj1Zg4Wb8vY6c= github.com/gliderlabs/ssh v0.3.8/go.mod h1:xYoytBv1sV0aL3CavoDuJIQNURXkkfPA/wxQ1pL1fAU= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic= -github.com/go-git/go-billy/v5 v5.6.0 h1:w2hPNtoehvJIxR00Vb4xX94qHQi/ApZfX+nBE2Cjio8= -github.com/go-git/go-billy/v5 v5.6.0/go.mod h1:sFDq7xD3fn3E0GOwUSZqHo9lrkmx8xJhA0ZrfvjBRGM= github.com/go-git/go-billy/v5 v5.6.2 h1:6Q86EsPXMa7c3YZ3aLAQsMA0VlWmy43r6FHqa/UNbRM= github.com/go-git/go-billy/v5 v5.6.2/go.mod h1:rcFC2rAsp/erv7CMz9GczHcuD0D32fWzH+MJAU+jaUU= github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399 h1:eMje31YglSBqCdIqdhKBW8lokaMrL3uTkpGYlE2OOT4= github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399/go.mod h1:1OCfN199q1Jm3HZlxleg+Dw/mwps2Wbk9frAWm+4FII= -github.com/go-git/go-git/v5 v5.13.0 h1:vLn5wlGIh/X78El6r3Jr+30W16Blk0CTcxTYcYPWi5E= -github.com/go-git/go-git/v5 v5.13.0/go.mod h1:Wjo7/JyVKtQgUNdXYXIepzWfJQkUEIGvkvVkiXRR/zw= github.com/go-git/go-git/v5 v5.14.0 h1:/MD3lCrGjCen5WfEAzKg00MJJffKhC8gzS80ycmCi60= github.com/go-git/go-git/v5 v5.14.0/go.mod h1:Z5Xhoia5PcWA3NF8vRLURn9E5FRhSl7dGj9ItW3Wk5k= -github.com/go-test/deep v1.1.0 h1:WOcxcdHcvdgThNXjw0t76K42FXTU7HpNQWHpA2HHNlg= -github.com/go-test/deep v1.1.0/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE= github.com/go-test/deep v1.1.1 h1:0r/53hagsehfO4bzD2Pgr/+RgHqhmf+k1Bpse2cTu1U= github.com/go-test/deep v1.1.1/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 h1:f+oWsMOmNPc8JmEHVZIycC7hBoQxHH9pNKQORJNozsQ= github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8/go.mod h1:wcDNUvekVysuuOpQKo3191zZyTpiI6se1N1ULghS0sw= -github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= -github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/hashicorp/hcl/v2 v2.23.0 h1:Fphj1/gCylPxHutVSEOf2fBOh1VE4AuLV7+kbJf3qos= @@ -76,7 +57,6 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= @@ -88,17 +68,14 @@ github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQ github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k= github.com/onsi/gomega v1.34.1/go.mod h1:kU1QgUvBDLXBJq618Xvm2LUX6rSAfRaFRTcdOeDLwwY= -github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4= -github.com/pjbgf/sha1cd v0.3.0/go.mod h1:nZ1rrWOcGJ5uZgEEVL1VUM9iRQiZvWdbZjkKyFzPPsI= github.com/pjbgf/sha1cd v0.3.2 h1:a9wb0bp1oC2TGwStyn0Umc/IGKQnEgF0vVaZ8QF8eo4= github.com/pjbgf/sha1cd v0.3.2/go.mod h1:zQWigSxVmsHEZow5qaLtPYxpcKMMQpa09ixqBxuCS6A= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= -github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ= +github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc= github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8= github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= @@ -107,8 +84,6 @@ github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQD github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8= github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4= github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= -github.com/skeema/knownhosts v1.3.0 h1:AM+y0rI04VksttfwjkSTNQorvGqmwATnvnAHpSgc0LY= -github.com/skeema/knownhosts v1.3.0/go.mod h1:sPINvnADmT/qYH1kfv+ePMmOBTH6Tbl7b5LvTDjFK7M= github.com/skeema/knownhosts v1.3.1 h1:X2osQ+RAjK76shCbvhHHHVl3ZlgDm8apHEHFqRjnBY8= github.com/skeema/knownhosts v1.3.1/go.mod h1:r7KTdC8l4uxWRyK2TpQZ/1o5HaSzh06ePQNxPwTcfiY= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -116,43 +91,26 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/urfave/cli/v2 v2.27.5 h1:WoHEJLdsXr6dDWoJgMq/CboDmyY/8HMMH1fTECbih+w= -github.com/urfave/cli/v2 v2.27.5/go.mod h1:3Sevf16NykTbInEnD0yKkjDAeZDS0A6bzhBH5hrMvTQ= github.com/urfave/cli/v2 v2.27.6 h1:VdRdS98FNhKZ8/Az8B7MTyGQmpIr36O1EHybx/LaZ4g= github.com/urfave/cli/v2 v2.27.6/go.mod h1:3Sevf16NykTbInEnD0yKkjDAeZDS0A6bzhBH5hrMvTQ= github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4= github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM= -github.com/zclconf/go-cty v1.15.1 h1:RgQYm4j2EvoBRXOPxhUvxPzRrGDo1eCOhHXuGfrj5S0= -github.com/zclconf/go-cty v1.15.1/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= github.com/zclconf/go-cty v1.16.2 h1:LAJSwc3v81IRBZyUVQDUdZ7hs3SYs9jv0eZJDWHD/70= github.com/zclconf/go-cty v1.16.2/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940 h1:4r45xpDWB6ZMSMNJFMOjqrGHynW3DIBuR2H9j0ug+Mo= github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940/go.mod h1:CmBdvvj3nqzfzJ6nTCIwDTPZ56aVGvDrmztiO5g3qrM= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U= -golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= -golang.org/x/crypto v0.35.0 h1:b15kiHdrGCHrP6LvwaQ3c03kgNhhiMgvlhxHQhmg2Xs= -golang.org/x/crypto v0.35.0/go.mod h1:dy7dXNW32cAb/6/PRuTNsix8T+vJAqvuIy5Bli/x0YQ= golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34= golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc= golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8= golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY= -golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4= -golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= golang.org/x/mod v0.24.0 h1:ZfthKaKaT4NrhGVZHO1/WDTwGES4De8KtWO0SIbNJMU= golang.org/x/mod v0.24.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= -golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= -golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8= -golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk= golang.org/x/net v0.37.0 h1:1zLorHbz+LYj7MQlSf1+2tPIIgibq2eL5xkrGk6f+2c= golang.org/x/net v0.37.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= -golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= -golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw= golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -164,24 +122,15 @@ golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= -golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc= -golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik= golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q= -golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM= +golang.org/x/term v0.30.0 h1:PQ39fJZ+mfadBm0y5WlL4vlM7Sx1Hgf13sMIY2+QS9Y= +golang.org/x/term v0.30.0/go.mod h1:NYYFdzHoI5wRh/h5tDMdMqCqPJZEuNqVR5xJLd/n67g= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= -golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= -golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY= golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.28.0 h1:WuB6qZ4RPCQo5aP3WdKZS7i595EdWqWR8vqJTlwTVK8= -golang.org/x/tools v0.28.0/go.mod h1:dcIOrVd3mfQKTgrDVQHqCPMWy6lnhfhtX3hLXYVLfRw= golang.org/x/tools v0.31.0 h1:0EedkvKDbh+qistFTd0Bcwe/YLh4vHwWEkiI0toFIBU= golang.org/x/tools v0.31.0/go.mod h1:naFTU+Cev749tSJRXJlna0T3WxKvb1kWEx15xA4SdmQ= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/src/core/modules_test.go b/src/core/modules_test.go index 0761a59..c63788e 100644 --- a/src/core/modules_test.go +++ b/src/core/modules_test.go @@ -126,13 +126,13 @@ func TestFlags_UpdateSource(t *testing.T) { {"git", fields{"", "", gitHubToken, 0, false, nil, false}, args{"git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git", "git", ""}, - "git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=42be407604c9ec4452f1f5bcc32a142ce9ab75a5", - "v2.2.0", false}, + "git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=2c24bd2b005d804cddaa4a09aa39a5a82d0ee9fb", + "v2.3.0", false}, {"git update", fields{"", "", gitHubToken, 0, false, nil, true}, args{"git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git", "git", ""}, - "git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=42be407604c9ec4452f1f5bcc32a142ce9ab75a5", - "v2.2.0", false}, + "git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=2c24bd2b005d804cddaa4a09aa39a5a82d0ee9fb", + "v2.3.0", false}, {"git version", fields{"", "", gitHubToken, 0, false, nil, false}, args{"git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=v1.0.0", "git", ""}, @@ -141,8 +141,8 @@ func TestFlags_UpdateSource(t *testing.T) { {"git version update", fields{"", "", gitHubToken, 0, false, nil, true}, args{"git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=v1.0.0", "git", ""}, - "git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=42be407604c9ec4452f1f5bcc32a142ce9ab75a5", - "v2.2.0", false}, + "git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=2c24bd2b005d804cddaa4a09aa39a5a82d0ee9fb", + "v2.3.0", false}, {"git version missing", fields{"", "", gitHubToken, 0, false, nil, false}, args{"git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=v1.2.0", "git", ""}, @@ -154,8 +154,8 @@ func TestFlags_UpdateSource(t *testing.T) { {name: "git hash update", fields: fields{"", "", gitHubToken, 0, false, nil, true}, args: args{"git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=93facd14e9e3a66704d84a0236a8a3b813f047be", "git", ""}, - want: "git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=42be407604c9ec4452f1f5bcc32a142ce9ab75a5", - want1: "v2.2.0", + want: "git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git?ref=2c24bd2b005d804cddaa4a09aa39a5a82d0ee9fb", + want1: "v2.3.0", wantErr: false}, //{"git query string", fields{}, args{"git::https://github.com/terraform-aws-modules/terraform-aws-memory-db.git"}, "git", false}, From b5e8a8b9a15eb5f734418226bc41ae220c08f40f Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Mon, 17 Mar 2025 17:31:41 +0000 Subject: [PATCH 79/80] version changes --- .github/workflows/pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 219acbf..e810364 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -21,7 +21,7 @@ jobs: restore-keys: | ${{ runner.os }}-go-mod- - name: gofumpt - uses: iamnotaturtle/auto-gofmt@3934ab53013ffb44d3db33bbd1c271279b5925d5 # v2.1.0 + uses: jameswoolfenden/auto-gofmt@99a3ed2b78b6c01d70db1740ba16d3dff60003df # v0.0.3 test: strategy: matrix: From 4a0e6114a4d1437cc7b8493694020944a098280d Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Fri, 25 Apr 2025 14:28:51 +0100 Subject: [PATCH 80/80] update --- .github/workflows/ci.yml | 4 +- .github/workflows/codeql-analysis.yml | 6 +-- .github/workflows/pr.yml | 10 ++-- .github/workflows/release.yml | 8 +-- .pre-commit-config.yaml | 6 +-- go.mod | 22 ++++---- go.sum | 50 +++++++++---------- .../testdata/gha/.github/workflows/test.yml | 2 +- 8 files changed, 54 insertions(+), 54 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ecba30b..afd2d38 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ jobs: steps: ## sets up go based on the version - name: Install Go - uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0 + uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5.4.0 with: go-version: ${{ matrix.go-version }} @@ -42,6 +42,6 @@ jobs: run: go test ./... -coverprofile=./cover.out - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@e96185f4044c2f0cedf0f022454acf9811cf8057 # v5.4.0 + uses: codecov/codecov-action@1f60566a86da84c4b4b64c17662a90de97fbb8d7 # v5.4.2 env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index f998e34..2aaf6b7 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -43,7 +43,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@80f993039571a6de66594ecaa432875a6942e8e0 # codeql-bundle-v2.20.6 + uses: github/codeql-action/init@4c3e5362829f0b0bb62ff5f6c938d7f95574c306 # codeql-bundle-v2.21.1 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -53,7 +53,7 @@ jobs: # 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@80f993039571a6de66594ecaa432875a6942e8e0 # codeql-bundle-v2.20.6 + uses: github/codeql-action/autobuild@4c3e5362829f0b0bb62ff5f6c938d7f95574c306 # codeql-bundle-v2.21.1 # â„šī¸ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun @@ -66,4 +66,4 @@ jobs: # ./location_of_script_within_repo/buildscript.sh - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@80f993039571a6de66594ecaa432875a6942e8e0 # codeql-bundle-v2.20.6 + uses: github/codeql-action/analyze@4c3e5362829f0b0bb62ff5f6c938d7f95574c306 # codeql-bundle-v2.21.1 diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index e810364..027c8f1 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -10,11 +10,11 @@ jobs: - name: Checkout code uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Install Go - uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0 + uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5.4.0 with: go-version: 1.24.x - name: Restore cache - uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2 + uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 with: path: ~/go/pkg/mod key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} @@ -32,11 +32,11 @@ jobs: - name: Checkout code uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Install Go - uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0 + uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5.4.0 with: go-version: ${{ matrix.go-version }} - name: Restore cache - uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2 + uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 with: path: ~/go/pkg/mod key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} @@ -55,6 +55,6 @@ jobs: - name: Checkout code uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Install Go - uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0 + uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5.4.0 with: go-version: 1.24.x diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 861891f..2e00b5f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,17 +15,17 @@ jobs: - name: Unshallow run: git fetch --prune --unshallow - name: Set up Go - uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0 + uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5.4.0 with: go-version: 1.24 - name: Import GPG key id: import_gpg - uses: crazy-max/ghaction-import-gpg@cb9bde2e2525e640591a934b1fd28eef1dcaf5e5 # v6.2.0 + uses: crazy-max/ghaction-import-gpg@e89d40939c28e39f97cf32126055eeae86ba74ec # v6.3.0 with: gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} passphrase: ${{ secrets.PASSPHRASE }} - name: Run GoReleaser - uses: goreleaser/goreleaser-action@90a3faa9d0182683851fbfa97ca1a2cb983bfca3 # v6.2.1 + uses: goreleaser/goreleaser-action@9c156ee8a17a598857849441385a2041ef570552 # v6.3.0 with: version: latest args: release --clean @@ -50,7 +50,7 @@ jobs: password: ${{ secrets.DOCKERHUB_PASSWORD }} tags: "latest,${{ github.ref_name }}" - name: Update Docker Hub README - uses: peter-evans/dockerhub-description@e98e4d1628a5f3be2be7c231e50981aee98723ae # v4.0.0 + uses: peter-evans/dockerhub-description@432a30c9e07499fd01da9f8a49f0faf9e0ca5b77 # v4.0.2 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2c21be4..3f064ce 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -46,7 +46,7 @@ repos: - id: gofmt - id: goimports repo: https://github.com/gruntwork-io/pre-commit - rev: 8481dc99cc5502ae867e66c339732d9ad7f2e1da + rev: 59fd8610ae21aaf8234f1ef17d43c3ccdee84d16 - hooks: - id: go-test args: @@ -58,7 +58,7 @@ repos: - hooks: - id: golangci-lint repo: https://github.com/golangci/golangci-lint - rev: 8cffdb7d21e5b2b89f163f70c60ac9686c9d6180 + rev: 8c14421d29bd005dee63044d07aa897b7d1bf8b0 - hooks: - id: checkov language_version: python3.11 @@ -66,7 +66,7 @@ repos: - -d - . repo: https://github.com/bridgecrewio/checkov - rev: 3.2.334 + rev: 3.2.408 - hooks: - id: ghat-go name: ghat diff --git a/go.mod b/go.mod index 79af94f..91c4e49 100644 --- a/go.mod +++ b/go.mod @@ -3,9 +3,9 @@ module github.com/jameswoolfenden/ghat go 1.24.1 require ( - github.com/go-git/go-git/v5 v5.14.0 + github.com/go-git/go-git/v5 v5.16.0 github.com/hashicorp/hcl/v2 v2.23.0 - github.com/rs/zerolog v1.33.0 + github.com/rs/zerolog v1.34.0 github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 github.com/urfave/cli/v2 v2.27.6 github.com/zclconf/go-cty v1.16.2 @@ -17,11 +17,11 @@ require ( require ( dario.cat/mergo v1.0.1 // indirect github.com/Microsoft/go-winio v0.6.2 // indirect - github.com/ProtonMail/go-crypto v1.1.6 // indirect + github.com/ProtonMail/go-crypto v1.2.0 // indirect github.com/agext/levenshtein v1.2.3 // indirect github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect - github.com/cloudflare/circl v1.6.0 // indirect - github.com/cpuguy83/go-md2man/v2 v2.0.6 // indirect + github.com/cloudflare/circl v1.6.1 // indirect + github.com/cpuguy83/go-md2man/v2 v2.0.7 // indirect github.com/cyphar/filepath-securejoin v0.4.1 // indirect github.com/emirpasic/gods v1.18.1 // indirect github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect @@ -39,11 +39,11 @@ require ( github.com/skeema/knownhosts v1.3.1 // indirect github.com/xanzy/ssh-agent v0.3.3 // indirect github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect - golang.org/x/crypto v0.36.0 // indirect - golang.org/x/net v0.37.0 // indirect - golang.org/x/sync v0.12.0 // indirect - golang.org/x/sys v0.31.0 // indirect - golang.org/x/text v0.23.0 // indirect - golang.org/x/tools v0.31.0 // indirect + golang.org/x/crypto v0.37.0 // indirect + golang.org/x/net v0.39.0 // indirect + golang.org/x/sync v0.13.0 // indirect + golang.org/x/sys v0.32.0 // indirect + golang.org/x/text v0.24.0 // indirect + golang.org/x/tools v0.32.0 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect ) diff --git a/go.sum b/go.sum index ce63baa..4ecfce6 100644 --- a/go.sum +++ b/go.sum @@ -3,8 +3,8 @@ dario.cat/mergo v1.0.1/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= -github.com/ProtonMail/go-crypto v1.1.6 h1:ZcV+Ropw6Qn0AX9brlQLAUXfqLBc7Bl+f/DmNxpLfdw= -github.com/ProtonMail/go-crypto v1.1.6/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE= +github.com/ProtonMail/go-crypto v1.2.0 h1:+PhXXn4SPGd+qk76TlEePBfOfivE0zkWFenhGhFLzWs= +github.com/ProtonMail/go-crypto v1.2.0/go.mod h1:9whxjD8Rbs29b4XWbB8irEcE8KHMqaR2e7GWU1R+/PE= github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8= @@ -13,11 +13,11 @@ github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= -github.com/cloudflare/circl v1.6.0 h1:cr5JKic4HI+LkINy2lg3W2jF8sHCVTBncJr5gIIq7qk= -github.com/cloudflare/circl v1.6.0/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZh3pJrofs= +github.com/cloudflare/circl v1.6.1 h1:zqIqSPIndyBh1bjLVVDHMPpVKqp8Su/V+6MeDzzQBQ0= +github.com/cloudflare/circl v1.6.1/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZh3pJrofs= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= -github.com/cpuguy83/go-md2man/v2 v2.0.6 h1:XJtiaUW6dEEqVuZiMTn1ldk455QWwEIsMIJlo5vtkx0= -github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= +github.com/cpuguy83/go-md2man/v2 v2.0.7 h1:zbFlGlXEAKlwXpmvle3d8Oe3YnkKIK4xSRTd3sHPnBo= +github.com/cpuguy83/go-md2man/v2 v2.0.7/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= github.com/cyphar/filepath-securejoin v0.4.1 h1:JyxxyPEaktOD+GAnqIqTf9A8tHyAG22rowi7HkoSU1s= github.com/cyphar/filepath-securejoin v0.4.1/go.mod h1:Sdj7gXlvMcPZsbhwhQ33GguGLDGQL7h7bg04C/+u9jI= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -35,8 +35,8 @@ github.com/go-git/go-billy/v5 v5.6.2 h1:6Q86EsPXMa7c3YZ3aLAQsMA0VlWmy43r6FHqa/UN github.com/go-git/go-billy/v5 v5.6.2/go.mod h1:rcFC2rAsp/erv7CMz9GczHcuD0D32fWzH+MJAU+jaUU= github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399 h1:eMje31YglSBqCdIqdhKBW8lokaMrL3uTkpGYlE2OOT4= github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399/go.mod h1:1OCfN199q1Jm3HZlxleg+Dw/mwps2Wbk9frAWm+4FII= -github.com/go-git/go-git/v5 v5.14.0 h1:/MD3lCrGjCen5WfEAzKg00MJJffKhC8gzS80ycmCi60= -github.com/go-git/go-git/v5 v5.14.0/go.mod h1:Z5Xhoia5PcWA3NF8vRLURn9E5FRhSl7dGj9ItW3Wk5k= +github.com/go-git/go-git/v5 v5.16.0 h1:k3kuOEpkc0DeY7xlL6NaaNg39xdgQbtH5mwCafHO9AQ= +github.com/go-git/go-git/v5 v5.16.0/go.mod h1:4Ge4alE/5gPs30F2H1esi2gPd69R0C39lolkucHBOp8= github.com/go-test/deep v1.1.1 h1:0r/53hagsehfO4bzD2Pgr/+RgHqhmf+k1Bpse2cTu1U= github.com/go-test/deep v1.1.1/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= @@ -76,9 +76,9 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ= github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc= -github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= -github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8= -github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= +github.com/rs/xid v1.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8ySMSjJKDIan90Nz0= +github.com/rs/zerolog v1.34.0 h1:k43nTLIwcTVQAncfCw4KZ2VY6ukYoZaBPNOE8txlOeY= +github.com/rs/zerolog v1.34.0/go.mod h1:bJsvje4Z08ROH4Nhs5iH600c3IkWhwp44iRc54W6wYQ= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8= @@ -102,17 +102,17 @@ github.com/zclconf/go-cty v1.16.2/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgr github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940 h1:4r45xpDWB6ZMSMNJFMOjqrGHynW3DIBuR2H9j0ug+Mo= github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940/go.mod h1:CmBdvvj3nqzfzJ6nTCIwDTPZ56aVGvDrmztiO5g3qrM= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34= -golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc= +golang.org/x/crypto v0.37.0 h1:kJNSjF/Xp7kU0iB2Z+9viTPMW4EqqsrywMXLJOOsXSE= +golang.org/x/crypto v0.37.0/go.mod h1:vg+k43peMZ0pUMhYmVAWysMK35e6ioLh3wB8ZCAfbVc= golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8= golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY= golang.org/x/mod v0.24.0 h1:ZfthKaKaT4NrhGVZHO1/WDTwGES4De8KtWO0SIbNJMU= golang.org/x/mod v0.24.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.37.0 h1:1zLorHbz+LYj7MQlSf1+2tPIIgibq2eL5xkrGk6f+2c= -golang.org/x/net v0.37.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= -golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw= -golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= +golang.org/x/net v0.39.0 h1:ZCu7HMWDxpXpaiKdhzIfaltL9Lp31x/3fCP11bc6/fY= +golang.org/x/net v0.39.0/go.mod h1:X7NRbYVEA+ewNkCNyJ513WmMdQ3BineSwVtN2zD/d+E= +golang.org/x/sync v0.13.0 h1:AauUjRAJ9OSnvULf/ARrrVywoJDy0YS2AwQ98I37610= +golang.org/x/sync v0.13.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -122,17 +122,17 @@ golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik= -golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20= +golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.30.0 h1:PQ39fJZ+mfadBm0y5WlL4vlM7Sx1Hgf13sMIY2+QS9Y= -golang.org/x/term v0.30.0/go.mod h1:NYYFdzHoI5wRh/h5tDMdMqCqPJZEuNqVR5xJLd/n67g= +golang.org/x/term v0.31.0 h1:erwDkOK1Msy6offm1mOgvspSkslFnIGsFnxOKoufg3o= +golang.org/x/term v0.31.0/go.mod h1:R4BeIy7D95HzImkxGkTW1UQTtP54tio2RyHz7PwK0aw= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= -golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= +golang.org/x/text v0.24.0 h1:dd5Bzh4yt5KYA8f9CJHCP4FB4D51c2c6JvN37xJJkJ0= +golang.org/x/text v0.24.0/go.mod h1:L8rBsPeo2pSS+xqN0d5u2ikmjtmoJbDBT1b7nHvFCdU= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.31.0 h1:0EedkvKDbh+qistFTd0Bcwe/YLh4vHwWEkiI0toFIBU= -golang.org/x/tools v0.31.0/go.mod h1:naFTU+Cev749tSJRXJlna0T3WxKvb1kWEx15xA4SdmQ= +golang.org/x/tools v0.32.0 h1:Q7N1vhpkQv7ybVzLFtTjvQya2ewbwNDZzUgfXGqtMWU= +golang.org/x/tools v0.32.0/go.mod h1:ZxrU41P/wAbZD8EDa6dDCa6XfpkhJ7HFMjHJXfBDu8s= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= diff --git a/src/core/testdata/gha/.github/workflows/test.yml b/src/core/testdata/gha/.github/workflows/test.yml index 28c8fe2..a983b58 100644 --- a/src/core/testdata/gha/.github/workflows/test.yml +++ b/src/core/testdata/gha/.github/workflows/test.yml @@ -25,7 +25,7 @@ jobs: steps: ## sets up go based on the version - name: Install Go - uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0 + uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5.4.0 with: go-version: ${{ matrix.go-version }}