diff --git a/cmd/utils_test.go b/cmd/utils_test.go index e2255e6b..c87af958 100644 --- a/cmd/utils_test.go +++ b/cmd/utils_test.go @@ -911,7 +911,7 @@ func stringsEqual(a, b []string) bool { return false } for i := range a { - if a[i] != b[i] { + if a[i] != b[i] { //nolint:gosec // G602 false positive: b length equality is checked above return false } } diff --git a/pkg/yqlib/candidate_node.go b/pkg/yqlib/candidate_node.go index 02168515..974898dc 100644 --- a/pkg/yqlib/candidate_node.go +++ b/pkg/yqlib/candidate_node.go @@ -280,7 +280,7 @@ func (n *CandidateNode) AddChild(rawChild *CandidateNode) { func (n *CandidateNode) AddChildren(children []*CandidateNode) { if n.Kind == MappingNode { - for i := 0; i < len(children); i += 2 { + for i := 0; i < len(children)-1; i += 2 { key := children[i] value := children[i+1] n.AddKeyValueChild(key, value) diff --git a/pkg/yqlib/lib.go b/pkg/yqlib/lib.go index 5a32665e..95dae458 100644 --- a/pkg/yqlib/lib.go +++ b/pkg/yqlib/lib.go @@ -29,7 +29,7 @@ func GetLogger() *logging.Logger { } func getContentValueByKey(content []*CandidateNode, key string) *CandidateNode { - for index := 0; index < len(content); index = index + 2 { + for index := 0; index < len(content)-1; index = index + 2 { keyNode := content[index] valueNode := content[index+1] if keyNode.Value == key { diff --git a/scripts/check.sh b/scripts/check.sh index dad8120f..a1ad0605 100755 --- a/scripts/check.sh +++ b/scripts/check.sh @@ -3,8 +3,6 @@ set -o errexit set -o pipefail -# TODO: Check if the found golangci-lint version matches the expected version (e.g., v1.62.0), especially if falling back to PATH version. - GOPATH_LINT="$(go env GOPATH)/bin/golangci-lint" BIN_LINT="./bin/golangci-lint" LINT_CMD="" diff --git a/scripts/devtools.sh b/scripts/devtools.sh index f157ec8e..0eafc4f9 100755 --- a/scripts/devtools.sh +++ b/scripts/devtools.sh @@ -1,5 +1,5 @@ #!/bin/sh set -ex go mod download golang.org/x/tools@latest -curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.1.5 +curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.11.3 curl -sSfL https://raw.githubusercontent.com/securego/gosec/master/install.sh | sh -s v2.22.11 \ No newline at end of file