deps: update golangci/golangci-lint to v1.62.2 (#3511)

* deps: update golangci/golangci-lint to v1.62.2

* deps: tidy all modules

* chore: align with new golangci-lint rules

golangci-lint added some linters in this version upgrade that require fixes on our side. These are done in this commit.

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: edgelessci <edgelessci@users.noreply.github.com>
Co-authored-by: Moritz Sanft <58110325+msanft@users.noreply.github.com>
This commit is contained in:
renovate[bot] 2024-12-02 13:24:34 +01:00 committed by GitHub
parent b652baa9c2
commit 53ae065329
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 47 additions and 45 deletions

View File

@ -24,7 +24,7 @@ linters:
# Additional linters # Additional linters
- bodyclose - bodyclose
- errname - errname
- exportloopref - copyloopvar
- godot - godot
- gofmt - gofmt
- gofumpt - gofumpt

View File

@ -223,45 +223,45 @@ def _golangci_lint_deps():
name = "com_github_golangci_golangci_lint_linux_amd64", name = "com_github_golangci_golangci_lint_linux_amd64",
build_file = "//bazel/toolchains:BUILD.golangci.bazel", build_file = "//bazel/toolchains:BUILD.golangci.bazel",
urls = [ urls = [
"https://cdn.confidential.cloud/constellation/cas/sha256/77cb0af99379d9a21d5dc8c38364d060e864a01bd2f3e30b5e8cc550c3a54111", "https://cdn.confidential.cloud/constellation/cas/sha256/5101292b7925a6a14b49c5c3d845c5021399698ffd2f41bcfab8a111b5669939",
"https://github.com/golangci/golangci-lint/releases/download/v1.61.0/golangci-lint-1.61.0-linux-amd64.tar.gz", "https://github.com/golangci/golangci-lint/releases/download/v1.62.2/golangci-lint-1.62.2-linux-amd64.tar.gz",
], ],
strip_prefix = "golangci-lint-1.61.0-linux-amd64", strip_prefix = "golangci-lint-1.62.2-linux-amd64",
type = "tar.gz", type = "tar.gz",
sha256 = "77cb0af99379d9a21d5dc8c38364d060e864a01bd2f3e30b5e8cc550c3a54111", sha256 = "5101292b7925a6a14b49c5c3d845c5021399698ffd2f41bcfab8a111b5669939",
) )
http_archive( http_archive(
name = "com_github_golangci_golangci_lint_linux_arm64", name = "com_github_golangci_golangci_lint_linux_arm64",
build_file = "//bazel/toolchains:BUILD.golangci.bazel", build_file = "//bazel/toolchains:BUILD.golangci.bazel",
urls = [ urls = [
"https://cdn.confidential.cloud/constellation/cas/sha256/af60ac05566d9351615cb31b4cc070185c25bf8cbd9b09c1873aa5ec6f3cc17e", "https://cdn.confidential.cloud/constellation/cas/sha256/10b6f5bd8483bd9e85a82f6119ed08f95609f42b86dc344b5dc15703c74d5b85",
"https://github.com/golangci/golangci-lint/releases/download/v1.61.0/golangci-lint-1.61.0-linux-arm64.tar.gz", "https://github.com/golangci/golangci-lint/releases/download/v1.62.2/golangci-lint-1.62.2-linux-arm64.tar.gz",
], ],
strip_prefix = "golangci-lint-1.61.0-linux-arm64", strip_prefix = "golangci-lint-1.62.2-linux-arm64",
type = "tar.gz", type = "tar.gz",
sha256 = "af60ac05566d9351615cb31b4cc070185c25bf8cbd9b09c1873aa5ec6f3cc17e", sha256 = "10b6f5bd8483bd9e85a82f6119ed08f95609f42b86dc344b5dc15703c74d5b85",
) )
http_archive( http_archive(
name = "com_github_golangci_golangci_lint_darwin_amd64", name = "com_github_golangci_golangci_lint_darwin_amd64",
build_file = "//bazel/toolchains:BUILD.golangci.bazel", build_file = "//bazel/toolchains:BUILD.golangci.bazel",
urls = [ urls = [
"https://cdn.confidential.cloud/constellation/cas/sha256/5c280ef3284f80c54fd90d73dc39ca276953949da1db03eb9dd0fbf868cc6e55", "https://cdn.confidential.cloud/constellation/cas/sha256/6c9ffd05896f0638d5c37152ac4ae337c2d301ba6c9dadf49c04e6d639f10f91",
"https://github.com/golangci/golangci-lint/releases/download/v1.61.0/golangci-lint-1.61.0-darwin-amd64.tar.gz", "https://github.com/golangci/golangci-lint/releases/download/v1.62.2/golangci-lint-1.62.2-darwin-amd64.tar.gz",
], ],
strip_prefix = "golangci-lint-1.61.0-darwin-amd64", strip_prefix = "golangci-lint-1.62.2-darwin-amd64",
type = "tar.gz", type = "tar.gz",
sha256 = "5c280ef3284f80c54fd90d73dc39ca276953949da1db03eb9dd0fbf868cc6e55", sha256 = "6c9ffd05896f0638d5c37152ac4ae337c2d301ba6c9dadf49c04e6d639f10f91",
) )
http_archive( http_archive(
name = "com_github_golangci_golangci_lint_darwin_arm64", name = "com_github_golangci_golangci_lint_darwin_arm64",
build_file = "//bazel/toolchains:BUILD.golangci.bazel", build_file = "//bazel/toolchains:BUILD.golangci.bazel",
urls = [ urls = [
"https://cdn.confidential.cloud/constellation/cas/sha256/544334890701e4e04a6e574bc010bea8945205c08c44cced73745a6378012d36", "https://cdn.confidential.cloud/constellation/cas/sha256/6c76f54467ba471f7bdcd5df0f27c3fa3dbe530b771a10d384c3d8c7178f5e89",
"https://github.com/golangci/golangci-lint/releases/download/v1.61.0/golangci-lint-1.61.0-darwin-arm64.tar.gz", "https://github.com/golangci/golangci-lint/releases/download/v1.62.2/golangci-lint-1.62.2-darwin-arm64.tar.gz",
], ],
strip_prefix = "golangci-lint-1.61.0-darwin-arm64", strip_prefix = "golangci-lint-1.62.2-darwin-arm64",
type = "tar.gz", type = "tar.gz",
sha256 = "544334890701e4e04a6e574bc010bea8945205c08c44cced73745a6378012d36", sha256 = "6c76f54467ba471f7bdcd5df0f27c3fa3dbe530b771a10d384c3d8c7178f5e89",
) )
def _buf_deps(): def _buf_deps():

View File

@ -76,7 +76,7 @@ func New(log *slog.Logger, csp string, diskPath string, fs afero.Afero,
// PrepareExistingDisk requests and waits for a decryption key to remap the encrypted state disk. // PrepareExistingDisk requests and waits for a decryption key to remap the encrypted state disk.
// Once the disk is mapped, the function taints the node as initialized by updating it's PCRs. // Once the disk is mapped, the function taints the node as initialized by updating it's PCRs.
func (s *Manager) PrepareExistingDisk(recover RecoveryDoer) error { func (s *Manager) PrepareExistingDisk(recoverer RecoveryDoer) error {
uuid, err := s.mapper.DiskUUID() uuid, err := s.mapper.DiskUUID()
if err != nil { if err != nil {
return err return err
@ -84,7 +84,7 @@ func (s *Manager) PrepareExistingDisk(recover RecoveryDoer) error {
s.log.With(slog.String("uuid", uuid)).Info("Preparing existing state disk") s.log.With(slog.String("uuid", uuid)).Info("Preparing existing state disk")
endpoint := net.JoinHostPort("0.0.0.0", strconv.Itoa(constants.RecoveryPort)) endpoint := net.JoinHostPort("0.0.0.0", strconv.Itoa(constants.RecoveryPort))
passphrase, measurementSecret, err := recover.Do(uuid, endpoint) passphrase, measurementSecret, err := recoverer.Do(uuid, endpoint)
if err != nil { if err != nil {
return fmt.Errorf("failed to perform recovery: %w", err) return fmt.Errorf("failed to perform recovery: %w", err)
} }

View File

@ -150,8 +150,10 @@ type BazelFile struct {
type BazelFileType int type BazelFileType int
const ( const (
BazelFileTypeBzl = iota // BazelFileTypeBzl is a .bzl file // BazelFileTypeBzl is a .bzl file.
BazelFileTypeWorkspace // BazelFileTypeWorkspace is a WORKSPACE or WORKSPACE.bzlmod file BazelFileTypeBzl = iota
// BazelFileTypeWorkspace is a WORKSPACE or WORKSPACE.bzlmod file.
BazelFileTypeWorkspace
) )
// LookupEnv can be the real os.LookupEnv or a mock for testing. // LookupEnv can be the real os.LookupEnv or a mock for testing.

View File

@ -139,25 +139,25 @@ func parseTestLine(line string) (string, packageCoverage, error) {
return pkg, coverage, nil return pkg, coverage, nil
} }
func diff(old, new, touched string) error { func diff(a, b, touched string) error {
oldf, err := os.Open(old) af, err := os.Open(a)
if err != nil { if err != nil {
return err return err
} }
defer oldf.Close() defer af.Close()
var oldRep, newReport report var aReport, bReport report
if err := json.NewDecoder(oldf).Decode(&oldRep); err != nil { if err := json.NewDecoder(af).Decode(&aReport); err != nil {
return err return err
} }
newf, err := os.Open(new) bf, err := os.Open(b)
if err != nil { if err != nil {
return err return err
} }
defer newf.Close() defer bf.Close()
if err := json.NewDecoder(newf).Decode(&newReport); err != nil { if err := json.NewDecoder(bf).Decode(&bReport); err != nil {
return err return err
} }
diffs, err := diffCoverage(oldRep, newReport) diffs, err := diffCoverage(aReport, bReport)
if err != nil { if err != nil {
return err return err
} }
@ -170,17 +170,17 @@ type coverageDiff struct {
new *packageCoverage new *packageCoverage
} }
func diffCoverage(old, new report) (map[string]coverageDiff, error) { func diffCoverage(a, b report) (map[string]coverageDiff, error) {
allPkgs := make(map[string]struct{}) allPkgs := make(map[string]struct{})
for pkg := range old.Coverage { for pkg := range a.Coverage {
allPkgs[pkg] = struct{}{} allPkgs[pkg] = struct{}{}
} }
for pkg := range new.Coverage { for pkg := range b.Coverage {
allPkgs[pkg] = struct{}{} allPkgs[pkg] = struct{}{}
} }
diffs := make(map[string]coverageDiff) diffs := make(map[string]coverageDiff)
for pkg := range allPkgs { for pkg := range allPkgs {
diffs[pkg] = coverageDiff{old: old.Coverage[pkg], new: new.Coverage[pkg]} diffs[pkg] = coverageDiff{old: a.Coverage[pkg], new: b.Coverage[pkg]}
if diffs[pkg].old == nil && diffs[pkg].new == nil { if diffs[pkg].old == nil && diffs[pkg].new == nil {
return nil, fmt.Errorf("both old and new coverage are nil for pkg %s", pkg) return nil, fmt.Errorf("both old and new coverage are nil for pkg %s", pkg)
} }

View File

@ -111,8 +111,8 @@ func (i *List) SortReverse() {
} }
// AddVersion adds new to i's list and sorts the element in descending order. // AddVersion adds new to i's list and sorts the element in descending order.
func (i *List) AddVersion(new string) { func (i *List) AddVersion(ver string) {
i.List = append(i.List, new) i.List = append(i.List, ver)
i.List = variant.RemoveDuplicate(i.List) i.List = variant.RemoveDuplicate(i.List)
i.SortReverse() i.SortReverse()

View File

@ -480,17 +480,17 @@ func (m *Measurement) unmarshal(eM encodedMeasurement) error {
// WithAllBytes returns a measurement value where all bytes are set to b. Takes a dynamic length as input. // WithAllBytes returns a measurement value where all bytes are set to b. Takes a dynamic length as input.
// Expected are either 32 bytes (PCRMeasurementLength) or 48 bytes (TDXMeasurementLength). // Expected are either 32 bytes (PCRMeasurementLength) or 48 bytes (TDXMeasurementLength).
// Over inputs are possible in this function, but potentially rejected elsewhere. // Over inputs are possible in this function, but potentially rejected elsewhere.
func WithAllBytes(b byte, validationOpt MeasurementValidationOption, len int) Measurement { func WithAllBytes(b byte, validationOpt MeasurementValidationOption, length int) Measurement {
return Measurement{ return Measurement{
Expected: bytes.Repeat([]byte{b}, len), Expected: bytes.Repeat([]byte{b}, length),
ValidationOpt: validationOpt, ValidationOpt: validationOpt,
} }
} }
// PlaceHolderMeasurement returns a measurement with placeholder values for Expected. // PlaceHolderMeasurement returns a measurement with placeholder values for Expected.
func PlaceHolderMeasurement(len int) Measurement { func PlaceHolderMeasurement(length int) Measurement {
return Measurement{ return Measurement{
Expected: bytes.Repeat([]byte{0x12, 0x34}, len/2), Expected: bytes.Repeat([]byte{0x12, 0x34}, length/2),
ValidationOpt: Enforce, ValidationOpt: Enforce,
} }
} }

View File

@ -233,8 +233,8 @@ func (h *Handler) CopyFile(src, dst string, opts ...Option) error {
} }
// RenameFile renames a file, overwriting any existing file at the destination. // RenameFile renames a file, overwriting any existing file at the destination.
func (h *Handler) RenameFile(old, new string) error { func (h *Handler) RenameFile(a, b string) error {
return h.fs.Rename(old, new) return h.fs.Rename(a, b)
} }
// IsEmpty returns true if the given directory is empty. // IsEmpty returns true if the given directory is empty.

View File

@ -274,7 +274,7 @@ func (s *stubRateLimiter) When(_ any) time.Duration {
func (s *stubRateLimiter) Forget(_ any) {} func (s *stubRateLimiter) Forget(_ any) {}
func assertBetween(assert *assert.Assertions, min, max, actual int) { func assertBetween(assert *assert.Assertions, minimum, maximum, actual int) {
assert.GreaterOrEqual(actual, min) assert.GreaterOrEqual(actual, minimum)
assert.LessOrEqual(actual, max) assert.LessOrEqual(actual, maximum)
} }