diff --git a/.github/workflows/golangci-lint.yaml b/.github/workflows/golangci-lint.yaml index 36e66de8..77bd3a40 100644 --- a/.github/workflows/golangci-lint.yaml +++ b/.github/workflows/golangci-lint.yaml @@ -35,10 +35,6 @@ jobs: - name: Check go.mod/go.sum to be consistent run: go mod tidy -v && git diff --exit-code - - name: golangci-lint - uses: golangci/golangci-lint-action@v6 - with: - version: latest - skip-cache: true - only-new-issues: false - args: --verbose + - name: Run linter + run: | + make lint diff --git a/.gitignore b/.gitignore index e1534127..d19e8c54 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ +/build/cache/* test/rigtest test/footloose.yaml test/Library test/.ssh test/*.iid +/.rigbuild.docker-image.k0s diff --git a/Makefile b/Makefile index 6efa1d05..9b40e05d 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,38 @@ GO_TESTS := $(shell find . -type f -name '*_test.go') INT_TESTS := $(shell git ls-files test/) +alpine_version = 3.21 +alpine_patch_version = $(alpine_version).3 +go_version = 1.24.2 +golang_buildimage=docker.io/library/golang:$(go_version)-alpine$(alpine_version) + +GOLANG_IMAGE ?= $(golang_buildimage) + +RIG_GO_BUILD_CACHE ?= build/cache +DOCKER ?= docker +BUILD_UID ?= $(shell id -u) +BUILD_GID ?= $(shell id -g) + +$(RIG_GO_BUILD_CACHE): + mkdir -p -- '$@' + +.rigbuild.docker-image.k0s: build/Dockerfile | $(RIG_GO_BUILD_CACHE) + $(DOCKER) build --progress=plain --iidfile '$@' \ + --build-arg BUILDIMAGE=$(GOLANG_IMAGE) \ + -t rigbuild.docker-image.k0s - uint32" + binary.BigEndian.PutUint32(size[4:], uint32(rows)) // #nosec G115 -- ignore "integer overflow conversion int -> uint32" } return size diff --git a/remotefs/posixfs.go b/remotefs/posixfs.go index 483c9b02..cf5e6a39 100644 --- a/remotefs/posixfs.go +++ b/remotefs/posixfs.go @@ -154,7 +154,8 @@ func posixBitsToFileMode(bits int64) fs.FileMode { } // Mapping permission bits - mode |= fs.FileMode(bits & 0o777) // Owner, group, and other permissions + // Owner, group, and other permissions + mode |= fs.FileMode(bits & 0o777) // #nosec G115 -- ignore "integer overflow conversion int64 -> uint64" // Mapping special permission bits if bits&0o4000 != 0 { // Set-user-ID diff --git a/remotefs/withname.go b/remotefs/withname.go index 33e437ab..7f4b9e65 100644 --- a/remotefs/withname.go +++ b/remotefs/withname.go @@ -3,14 +3,22 @@ package remotefs import "io/fs" const ( - OpClose = "close" // OpClose Close operation - OpOpen = "open" // OpOpen Open operation - OpRead = "read" // OpRead Read operation - OpSeek = "seek" // OpSeek Seek operation - OpStat = "stat" // OpStat Stat operation - OpWrite = "write" // OpWrite Write operation - OpCopyTo = "copy-to" // OpCopyTo CopyTo operation - OpCopyFrom = "copy-from" // OpCopyFrom CopyFrom operation + // OpClose Close operation. + OpClose = "close" + // OpOpen Open operation. + OpOpen = "open" + // OpRead Read operation. + OpRead = "read" + // OpSeek Seek operation. + OpSeek = "seek" + // OpStat Stat operation. + OpStat = "stat" + // OpWrite Write operation. + OpWrite = "write" + // OpCopyTo CopyTo operation. + OpCopyTo = "copy-to" + // OpCopyFrom CopyFrom operation. + OpCopyFrom = "copy-from" ) type withPath struct { diff --git a/sshconfig/printer.go b/sshconfig/printer.go index 7f6cfeae..0d54fde5 100644 --- a/sshconfig/printer.go +++ b/sshconfig/printer.go @@ -128,9 +128,9 @@ func (p *printer) number(key string) (string, bool) { } if field, err := p.get(key, reflect.Uint); err == nil { if key == "StreamLocalBindMask" { - return "0" + strconv.FormatInt(int64(field.Uint()), 8), true + return "0" + strconv.FormatInt(int64(field.Uint()), 8), true // #nosec G115 -- ignore "integer overflow conversion int64 -> uint64" } - return strconv.FormatInt(int64(field.Uint()), 10), true + return strconv.FormatInt(int64(field.Uint()), 10), true // #nosec G115 -- ignore "integer overflow conversion int64 -> uint64" } return "", false } diff --git a/sshconfig/set.go b/sshconfig/set.go index 9e77883d..78c98545 100644 --- a/sshconfig/set.go +++ b/sshconfig/set.go @@ -1125,7 +1125,7 @@ func (s *Setter) expandToken(token string) (string, error) { //nolint:cyclop if f, err := s.get("Port", reflect.Uint); err == nil { if f.Uint() > 0 { - return strconv.Itoa(int(f.Uint())), nil + return strconv.Itoa(int(f.Uint())), nil // #nosec G115 -- ignore "integer overflow conversion uint64 -> int" } } if f, err := s.get("Port", reflect.String); err == nil { @@ -1349,7 +1349,7 @@ func (s *Setter) matchesHost(conditions ...string) (bool, error) { // matchesMatch checks if the Match directive conditions are met. func (s *Setter) matchesMatch(conditions ...string) (bool, error) { //nolint:funlen,cyclop // TODO extract functions log.Trace(context.Background(), "matching Match directive", "conditions", conditions) - for i := range len(conditions) { + for i := range conditions { condition := conditions[i] log.Trace(context.Background(), "matching Match directive", "condition", condition) var negate bool @@ -1607,7 +1607,7 @@ func (s *Setter) canonicalizeMaxDots() int { if md, err := s.get("CanonicalizeMaxDots", reflect.Int); err == nil { return int(md.Int()) } else if md, err := s.get("CanonicalizeMaxDots", reflect.Uint); err == nil { - return int(md.Uint()) + return int(md.Uint()) // #nosec G115 -- ignore "integer overflow conversion int64 -> uint64" } return 1 }