From da2d6369b83cc41fd239bab6afba15247421e612 Mon Sep 17 00:00:00 2001 From: dnitsch Date: Wed, 24 Sep 2025 08:15:16 +0100 Subject: [PATCH 1/3] fix: add linters --- .github/workflows/ci.yml | 2 +- .golangci.yaml | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 .golangci.yaml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aaff147..5e76179 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -56,7 +56,7 @@ jobs: - name: Run linters run: | - echo 'eirctl run vuln:check' + eirctl run lints - name: Unit Tests run: | diff --git a/.golangci.yaml b/.golangci.yaml new file mode 100644 index 0000000..ec00945 --- /dev/null +++ b/.golangci.yaml @@ -0,0 +1,31 @@ +version: "2" +linters: + # Default set of linters. + # The value can be: `standard`, `all`, `none`, or `fast`. + # Default: standard + default: standard + exclusions: + generated: lax + # Log a warning if an exclusion rule is unused. + # Default: false + warn-unused: true + # Predefined exclusion rules. + # Default: [] + presets: + - comments + - std-error-handling + - common-false-positives + - legacy + # Excluding configuration per-path, per-linter, per-text and per-source. + rules: + # Exclude some linters from running on tests files. + - path: _test\.go + linters: + - gocyclo + - errcheck + - dupl + - gosec + - ineffassign + - staticcheck + - unused + - govet From d57903cb35a482b85f897066571b6b56566a6cbe Mon Sep 17 00:00:00 2001 From: dnitsch Date: Wed, 24 Sep 2025 20:28:54 +0100 Subject: [PATCH 2/3] fix: os process find and kill properly --- internal/web/web.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/web/web.go b/internal/web/web.go index 85946eb..f3ddf33 100755 --- a/internal/web/web.go +++ b/internal/web/web.go @@ -227,6 +227,7 @@ func (web *Web) MustClose() { utils.Sleep(0.5) // remove process just in case // os.Process is cross platform safe way to remove a process - osprocess := os.Process{Pid: web.launcher.PID()} - _ = osprocess.Kill() + if osprocess, err := os.FindProcess(web.launcher.PID()); err != nil { + osprocess.Kill() + } } From f7b4b7ed5aaa15fa48ed20804606a812044a6428 Mon Sep 17 00:00:00 2001 From: dnitsch Date: Fri, 26 Sep 2025 18:19:32 +0100 Subject: [PATCH 3/3] fix: correct condition --- Makefile | 69 --------------------------------------------- cmd/saml.go | 2 +- eirctl.yaml | 2 +- internal/web/web.go | 4 +-- 4 files changed, 4 insertions(+), 73 deletions(-) delete mode 100644 Makefile diff --git a/Makefile b/Makefile deleted file mode 100644 index 02ab5c2..0000000 --- a/Makefile +++ /dev/null @@ -1,69 +0,0 @@ -OWNER := DevLabFoundry -NAME := aws-cli-auth -GIT_TAG := 0.11.11 -VERSION := v$(GIT_TAG) -REVISION := aaaabbbbb1234 - -LDFLAGS := -ldflags="-s -w -X \"github.com/$(OWNER)/$(NAME)/cmd.Version=$(VERSION)\" -X \"github.com/$(OWNER)/$(NAME)/cmd.Revision=$(REVISION)\" -extldflags -static" - -.PHONY: test test_ci tidy install buildprep build buildmac buildwin - -test: test_prereq - go test ./... -v -mod=readonly -coverprofile=.coverage/out -race | tee .coverage/test.out ; \ - cat .coverage/test.out | go-junit-report > .coverage/report-junit.xml ; \ - gocov convert .coverage/out | gocov-xml > .coverage/report-cobertura.xml - -test_ci: - go test ./... -mod=readonly - -test_prereq: - mkdir -p .coverage - go install github.com/jstemmer/go-junit-report@v0.9.1 && \ - go install github.com/axw/gocov/gocov@v1.0.0 && \ - go install github.com/AlekSi/gocov-xml@v1.0.0 - -install: - go mod tidy - -.PHONY: clean -clean: - rm -rf bin/* - rm -rf dist/* - rm -rf vendor/* - -.PHONY: cross-build - -build-win: - for arch in amd64 386; do \ - GOOS=windows GOARCH=$$arch CGO_ENABLED=0 go build -mod=readonly -buildvcs=false $(LDFLAGS) -o dist/$(NAME)-windows-$$arch .; \ - done - -cross-build: build-win - for os in darwin linux; do \ - GOOS=$$os CGO_ENABLED=0 go build -mod=readonly -buildvcs=false $(LDFLAGS) -o dist/$(NAME)-$$os .; \ - done - -release: - OWNER=$(OWNER) NAME=$(NAME) PAT=$(PAT) VERSION=$(VERSION) . hack/release.sh - -tag: - git tag -a $(VERSION) -m "ci tag release" $(REVISION) - git push origin $(VERSION) - -tagbuildrelease: tag cross-build release - -show_coverage: test - go tool cover -html=.coverage/out - -.PHONY: deps -deps: - GO111MODULE=on go mod vendor - -.PHONY: dist -dist: - cd dist && \ - $(DIST_DIRS) cp ../LICENSE {} \; && \ - $(DIST_DIRS) cp ../README.md {} \; && \ - $(DIST_DIRS) tar -zcf $(NAME)-$(VERSION)-{}.tar.gz {} \; && \ - $(DIST_DIRS) zip -r $(NAME)-$(VERSION)-{}.zip {} \; && \ - cd .. diff --git a/cmd/saml.go b/cmd/saml.go index ffe6266..415e2fd 100755 --- a/cmd/saml.go +++ b/cmd/saml.go @@ -67,7 +67,7 @@ func newSamlCmd(r *Root) { return err } - allRoles := credentialexchange.MergeRoleChain(flags.role, r.rootFlags.roleChain, sc.flags.isSso) + allRoles := credentialexchange.MergeRoleChain(flags.role, r.rootFlags.roleChain, flags.isSso) conf := credentialexchange.CredentialConfig{ ProviderUrl: flags.providerUrl, PrincipalArn: flags.principalArn, diff --git a/eirctl.yaml b/eirctl.yaml index ccd45ae..4e3c2d0 100644 --- a/eirctl.yaml +++ b/eirctl.yaml @@ -74,7 +74,7 @@ tasks: - | mkdir -p .deps ldflags="-s -w -X \"github.com/{{.RepoOwner}}/{{.BinName}}/cmd.Version={{.Version}}\" -X \"github.com/{{.RepoOwner}}/{{.BinName}}/cmd.Revision={{.Revision}}\" -extldflags -static" - CGO_ENABLED=0 GOPATH=$PWD/.deps GOOS=${BUILD_GOOS} GOARCH=${BUILD_GOARCH} go build -mod=readonly -buildvcs=false -ldflags="$ldflags" -o dist/{{.BinName}}-${BUILD_GOOS}${BUILD_GOARCH} . + CGO_ENABLED=0 GOPATH=$PWD/.deps GOOS=${BUILD_GOOS} GOARCH=${BUILD_GOARCH} go build -mod=readonly -buildvcs=false -ldflags="$ldflags" -o dist/{{.BinName}}-${BUILD_GOOS}-${BUILD_GOARCH} . variations: - BUILD_GOOS: windows BUILD_GOARCH: amd64 diff --git a/internal/web/web.go b/internal/web/web.go index f3ddf33..cabdfa9 100755 --- a/internal/web/web.go +++ b/internal/web/web.go @@ -227,7 +227,7 @@ func (web *Web) MustClose() { utils.Sleep(0.5) // remove process just in case // os.Process is cross platform safe way to remove a process - if osprocess, err := os.FindProcess(web.launcher.PID()); err != nil { - osprocess.Kill() + if osprocess, err := os.FindProcess(web.launcher.PID()); err == nil && osprocess != nil { + _ = osprocess.Kill() } }