From d4a7b644b6ebba9c4a1d193d49f685aee5e6e3a4 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 22 Aug 2026 03:53:37 +0000 Subject: [PATCH] Update code.cloudfoundry.org/credhub-cli digest to 803f496 --- go.mod | 20 +- go.sum | 40 +-- vendor/github.com/onsi/ginkgo/v2/CHANGELOG.md | 5 + .../onsi/ginkgo/v2/internal/group.go | 20 +- .../onsi/ginkgo/v2/types/version.go | 2 +- .../x/crypto/internal/poly1305/mac_noasm.go | 2 +- .../x/crypto/internal/poly1305/sum_asm.go | 2 +- .../x/crypto/internal/poly1305/sum_riscv64.s | 158 ++++++++++ vendor/golang.org/x/crypto/ssh/certs.go | 15 +- vendor/golang.org/x/crypto/ssh/channel.go | 69 +++-- vendor/golang.org/x/crypto/ssh/client_auth.go | 2 +- vendor/golang.org/x/crypto/ssh/common.go | 8 +- vendor/golang.org/x/crypto/ssh/connection.go | 2 +- vendor/golang.org/x/crypto/ssh/handshake.go | 2 +- vendor/golang.org/x/crypto/ssh/keys.go | 17 +- vendor/golang.org/x/crypto/ssh/messages.go | 11 +- vendor/golang.org/x/crypto/ssh/mux.go | 13 +- vendor/golang.org/x/crypto/ssh/server.go | 79 +++-- vendor/golang.org/x/crypto/ssh/ssh_gss.go | 16 +- vendor/golang.org/x/crypto/ssh/streamlocal.go | 2 + vendor/golang.org/x/crypto/ssh/tcpip.go | 2 + .../passes/fieldalignment/fieldalignment.go | 141 +++++---- .../tools/go/analysis/passes/modernize/any.go | 2 +- .../analysis/passes/modernize/atomictypes.go | 2 +- .../go/analysis/passes/modernize/bloop.go | 2 +- .../tools/go/analysis/passes/modernize/doc.go | 44 ++- .../go/analysis/passes/modernize/embedlit.go | 33 ++- .../analysis/passes/modernize/errorsastype.go | 7 +- .../analysis/passes/modernize/fmtappendf.go | 2 +- .../go/analysis/passes/modernize/forvar.go | 2 +- .../passes/modernize/importcomment.go | 2 +- .../go/analysis/passes/modernize/maps.go | 2 +- .../go/analysis/passes/modernize/minmax.go | 17 +- .../go/analysis/passes/modernize/modernize.go | 18 +- .../go/analysis/passes/modernize/newexpr.go | 2 +- .../go/analysis/passes/modernize/omitzero.go | 2 +- .../go/analysis/passes/modernize/plusbuild.go | 2 +- .../go/analysis/passes/modernize/rangeint.go | 45 +-- .../go/analysis/passes/modernize/reflect.go | 2 +- .../passes/modernize/reflecttypeassert.go | 118 ++++++++ .../go/analysis/passes/modernize/slices.go | 2 +- .../passes/modernize/slicesbackward.go | 20 +- .../analysis/passes/modernize/slicesclip.go | 81 ++++++ .../passes/modernize/slicescontains.go | 2 +- .../analysis/passes/modernize/slicesdelete.go | 2 +- .../go/analysis/passes/modernize/sortslice.go | 2 +- .../analysis/passes/modernize/stditerators.go | 2 +- .../passes/modernize/stringsbuilder.go | 2 +- .../analysis/passes/modernize/stringscut.go | 35 +-- .../passes/modernize/stringscutprefix.go | 2 +- .../analysis/passes/modernize/stringsseq.go | 4 +- .../passes/modernize/testingcontext.go | 2 +- .../analysis/passes/modernize/unsafefuncs.go | 2 +- .../analysis/passes/modernize/waitgroupgo.go | 46 ++- .../tools/go/analysis/passes/printf/printf.go | 9 - .../analysis/passes/stdversion/stdversion.go | 31 +- .../passes/unusedresult/unusedresult.go | 4 +- .../x/tools/go/ast/inspector/cursor.go | 41 +++ vendor/golang.org/x/tools/go/loader/loader.go | 2 + .../golang.org/x/tools/go/packages/visit.go | 33 +-- vendor/golang.org/x/tools/go/ssa/builder.go | 5 +- vendor/golang.org/x/tools/go/ssa/methods.go | 12 +- vendor/golang.org/x/tools/go/ssa/util.go | 10 +- vendor/golang.org/x/tools/go/ssa/wrappers.go | 5 +- .../x/tools/go/types/typeutil/callee.go | 61 +--- .../internal/analysis/analyzerutil/version.go | 2 +- .../x/tools/internal/moremaps/maps.go | 116 ++++++++ .../tools/internal/packagepath/packagepath.go | 16 +- .../x/tools/internal/refactor/imports.go | 4 +- .../tools/internal/refactor/inline/callee.go | 30 ++ .../internal/refactor/inline/calleefx.go | 17 +- .../tools/internal/refactor/inline/falcon.go | 14 +- .../internal/typesinternal/assignedaddress.go | 128 +++++++++ .../internal/typesinternal/classify_call.go | 77 ++++- .../x/tools/internal/typesinternal/element.go | 65 ++--- .../x/tools/internal/typesinternal/toonew.go | 44 ++- .../x/tools/internal/typesinternal/types.go | 8 + .../x/tools/refactor/satisfy/find.go | 19 +- .../encoding/protodelim/protodelim.go | 9 +- .../protobuf/encoding/prototext/decode.go | 18 ++ .../protobuf/internal/descfmt/stringer.go | 269 +++++++++--------- .../editiondefaults/editions_defaults.binpb | Bin 154 -> 191 bytes .../internal/encoding/defval/default.go | 8 +- .../protobuf/internal/genid/descriptor_gen.go | 5 + .../protobuf/internal/version/version.go | 2 +- .../reflect/protoreflect/source_gen.go | 2 + .../protobuf/types/known/anypb/any.pb.go | 160 ++++------- .../types/known/timestamppb/timestamp.pb.go | 6 +- vendor/modules.txt | 23 +- 89 files changed, 1626 insertions(+), 765 deletions(-) create mode 100644 vendor/golang.org/x/crypto/internal/poly1305/sum_riscv64.s create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/modernize/reflecttypeassert.go create mode 100644 vendor/golang.org/x/tools/go/analysis/passes/modernize/slicesclip.go create mode 100644 vendor/golang.org/x/tools/internal/moremaps/maps.go create mode 100644 vendor/golang.org/x/tools/internal/typesinternal/assignedaddress.go diff --git a/go.mod b/go.mod index 2d5c7b7d..4d702de9 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.26.5 tool github.com/golangci/golangci-lint/v2/cmd/golangci-lint require ( - code.cloudfoundry.org/credhub-cli v0.0.0-20260727130059-9e78db728bcf + code.cloudfoundry.org/credhub-cli v0.0.0-20260817130202-803f4962b541 github.com/BurntSushi/toml v1.6.0 github.com/apex/log v1.9.0 github.com/buildpacks/lifecycle v0.21.14 @@ -14,7 +14,7 @@ require ( github.com/google/go-containerregistry v0.21.8 github.com/jarcoal/httpmock v1.4.2 github.com/moby/moby/api v1.55.0 - github.com/onsi/ginkgo/v2 v2.32.0 + github.com/onsi/ginkgo/v2 v2.32.1 github.com/onsi/gomega v1.42.1 github.com/spf13/cobra v1.10.2 github.com/testcontainers/testcontainers-go v0.43.0 @@ -104,7 +104,7 @@ require ( github.com/clipperhouse/displaywidth v0.11.0 // indirect github.com/clipperhouse/uax29/v2 v2.7.0 // indirect github.com/cloudfoundry/go-socks5 v0.0.0-20250423223041-4ad5fea42851 // indirect - github.com/cloudfoundry/socks5-proxy v0.2.183 // indirect + github.com/cloudfoundry/socks5-proxy v0.2.185 // indirect github.com/containerd/errdefs v1.0.0 // indirect github.com/containerd/errdefs/pkg v0.3.0 // indirect github.com/containerd/log v0.1.0 // indirect @@ -167,7 +167,7 @@ require ( github.com/golangci/swaggoswag v0.0.0-20250504205917-77f2aca3143e // indirect github.com/golangci/unconvert v0.0.0-20250410112200-a129a6e6413e // indirect github.com/google/go-cmp v0.7.0 // indirect - github.com/google/pprof v0.0.0-20260709232956-b9395ee17fa0 // indirect + github.com/google/pprof v0.0.0-20260802141513-ef3492d7dac3 // indirect github.com/google/uuid v1.6.0 // indirect github.com/gordonklaus/ineffassign v0.2.0 // indirect github.com/gorilla/mux v1.8.1 // indirect @@ -308,17 +308,17 @@ require ( go.uber.org/zap v1.27.0 // indirect go.yaml.in/yaml/v2 v2.4.3 // indirect go.yaml.in/yaml/v3 v3.0.5 // indirect - golang.org/x/crypto v0.54.0 // indirect + golang.org/x/crypto v0.55.0 // indirect golang.org/x/exp v0.0.0-20260410095643-746e56fc9e2f // indirect golang.org/x/exp/typeparams v0.0.0-20260209203927-2842357ff358 // indirect - golang.org/x/mod v0.38.0 // indirect - golang.org/x/net v0.57.0 // indirect + golang.org/x/mod v0.40.0 // indirect + golang.org/x/net v0.58.0 // indirect golang.org/x/sync v0.22.0 // indirect golang.org/x/sys v0.47.0 // indirect golang.org/x/term v0.45.0 // indirect - golang.org/x/text v0.40.0 // indirect - golang.org/x/tools v0.48.0 // indirect - google.golang.org/protobuf v1.36.11 // indirect + golang.org/x/text v0.41.0 // indirect + golang.org/x/tools v0.49.0 // indirect + google.golang.org/protobuf v1.36.12 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect honnef.co/go/tools v0.7.0 // indirect diff --git a/go.sum b/go.sum index 761aa0ec..08396c0f 100644 --- a/go.sum +++ b/go.sum @@ -4,8 +4,8 @@ 4d63.com/gochecknoglobals v0.2.2/go.mod h1:lLxwTQjL5eIesRbvnzIP3jZtG140FnTdz+AlMa+ogt0= charm.land/lipgloss/v2 v2.0.3 h1:yM2zJ4Cf5Y51b7RHIwioil4ApI/aypFXXVHSwlM6RzU= charm.land/lipgloss/v2 v2.0.3/go.mod h1:7myLU9iG/3xluAWzpY/fSxYYHCgoKTie7laxk6ATwXA= -code.cloudfoundry.org/credhub-cli v0.0.0-20260727130059-9e78db728bcf h1:pHjgXWLqCCJpQvA7Cxo/TLILuoPfgrlUYxNLKXYV4IY= -code.cloudfoundry.org/credhub-cli v0.0.0-20260727130059-9e78db728bcf/go.mod h1:v2Ksqa8pjAMN+2sDjuv0Dn649weA85Ge9i9Rgn6ICAI= +code.cloudfoundry.org/credhub-cli v0.0.0-20260817130202-803f4962b541 h1:wzA2OC13AJ1mJxWbZfGdzy4yyzP1WHTiJx36R6/uH4w= +code.cloudfoundry.org/credhub-cli v0.0.0-20260817130202-803f4962b541/go.mod h1:uiFsy3zPEebceGf+XIZI1W7JbCjkPJK4xAKQm6DIviE= codeberg.org/chavacava/garif v0.2.0 h1:F0tVjhYbuOCnvNcU3YSpO6b3Waw6Bimy4K0mM8y6MfY= codeberg.org/chavacava/garif v0.2.0/go.mod h1:P2BPbVbT4QcvLZrORc2T29szK3xEOlnl0GiPTJmEqBQ= codeberg.org/polyfloyd/go-errorlint v1.9.0 h1:VkdEEmA1VBpH6ecQoMR4LdphVI3fA4RrCh2an7YmodI= @@ -211,8 +211,8 @@ github.com/cloudflare/circl v1.6.3 h1:9GPOhQGF9MCYUeXyMYlqTR6a5gTrgR/fBLXvUgtVcg github.com/cloudflare/circl v1.6.3/go.mod h1:2eXP6Qfat4O/Yhh8BznvKnJ+uzEoTQ6jVKJRn81BiS4= github.com/cloudfoundry/go-socks5 v0.0.0-20250423223041-4ad5fea42851 h1:oy59UYcspoP44ggE8DM3kjxl1+sTFd802bbZlBBhBMk= github.com/cloudfoundry/go-socks5 v0.0.0-20250423223041-4ad5fea42851/go.mod h1:72EEm1oq5oXqGfu9XGtaRPWEcAFYd/P10cMNln0QhA8= -github.com/cloudfoundry/socks5-proxy v0.2.183 h1:QgkOB5Od0pzRtyZPQotD6USsxuo13GyhmrAiA0nzjkg= -github.com/cloudfoundry/socks5-proxy v0.2.183/go.mod h1:tnJUhAsMqnBPAt+p+SsNsaAo4lrqxYlpDHD+uURZX4s= +github.com/cloudfoundry/socks5-proxy v0.2.185 h1:AHVSpPpTwxLmoqrur+caZiA07vD5e+hT3fJTWsqV3K4= +github.com/cloudfoundry/socks5-proxy v0.2.185/go.mod h1:8DOQbJLew3uyr8XUImuf9f0w8x0Dlpzij9NJOBfEuX0= github.com/containerd/errdefs v1.0.0 h1:tg5yIfIlQIrxYtu9ajqY42W3lpS19XqdxRQeEwYG8PI= github.com/containerd/errdefs v1.0.0/go.mod h1:+YBYIdtsnF4Iw6nWZhJcqGSg/dwvV7tyJ/kCkyJ2k+M= github.com/containerd/errdefs/pkg v0.3.0 h1:9IKJ06FvyNlexW690DXuQNx2KA2cUJXx151Xdx3ZPPE= @@ -405,8 +405,8 @@ github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX github.com/google/go-containerregistry v0.21.8 h1:Ig/zIsnztdCUNaiNNczE+MoP5xcyUMfvpvfOr1xyMLE= github.com/google/go-containerregistry v0.21.8/go.mod h1:dP5XNKcL7kMFF/TB3LfvWmVhAcv7iqkHb3oDK8aauTo= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/pprof v0.0.0-20260709232956-b9395ee17fa0 h1:du0WGc8xSKq/++e0cglxhS/mXVqsR7+c7jLEi5Vqduw= -github.com/google/pprof v0.0.0-20260709232956-b9395ee17fa0/go.mod h1:MxpfABSjhmINe3F1It9d+8exIHFvUqtLIRCdOGNXqiI= +github.com/google/pprof v0.0.0-20260802141513-ef3492d7dac3 h1:LMLX+LgTNWpfvCBdFebv6EsYotImrt/Ppc5cXIriCSo= +github.com/google/pprof v0.0.0-20260802141513-ef3492d7dac3/go.mod h1:jl5iWTm0/hd5PjEYEOuwAJ57L/CibdZfrqZ5XA5GrCk= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -596,8 +596,8 @@ github.com/nishanths/predeclared v0.2.2/go.mod h1:RROzoN6TnGQupbC+lqggsOlcgysk3L github.com/nunnatsa/ginkgolinter v0.23.0 h1:x3o4DGYOWbBMP/VdNQKgSj+25aJKx2Pe6lHr8gBcgf8= github.com/nunnatsa/ginkgolinter v0.23.0/go.mod h1:9qN1+0akwXEccwV1CAcCDfcoBlWXHB+ML9884pL4SZ4= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo/v2 v2.32.0 h1:Hw7s2pVrQo/8Yz5N77qdnpHaoc+c6cC9WIV1Jce+J6E= -github.com/onsi/ginkgo/v2 v2.32.0/go.mod h1:+aXOY+vzZ5mu2iI2HpTZUPmM//oQfsNFX6gU9kNcA44= +github.com/onsi/ginkgo/v2 v2.32.1 h1:6tlvcDm/3sE8lGJbZ4+d4mO3RLy24/tQWOFzVSQNIfw= +github.com/onsi/ginkgo/v2 v2.32.1/go.mod h1:+aXOY+vzZ5mu2iI2HpTZUPmM//oQfsNFX6gU9kNcA44= github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.42.1 h1:iN1rCUX+44NZ1Dc97MPoeFYbFR0vh8zxoxMFwKdyZ6I= github.com/onsi/gomega v1.42.1/go.mod h1:REff/hsDsodHoKlWsP2mAPhu1+5/6hVYNf9rIEBpeSg= @@ -865,8 +865,8 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= -golang.org/x/crypto v0.54.0 h1:YLIA59K4fiNzHzjnZt2tUJQjQtUWfWbeHBqKtk3eScw= -golang.org/x/crypto v0.54.0/go.mod h1:KWL8ny2AZdGR2cWmzeHrp2azQPGogOv+HeQaVEXC2dk= +golang.org/x/crypto v0.55.0 h1:+KWHjbgOaAQ66dh/YlkZKHlz9ZUlq61AFirAR9ntP8M= +golang.org/x/crypto v0.55.0/go.mod h1:uq0V9dE/fzQuJtbnL+2EhWOE63vo164FY8xqEnV9xis= golang.org/x/exp v0.0.0-20260410095643-746e56fc9e2f h1:W3F4c+6OLc6H2lb//N1q4WpJkhzJCK5J6kUi1NTVXfM= golang.org/x/exp v0.0.0-20260410095643-746e56fc9e2f/go.mod h1:J1xhfL/vlindoeF/aINzNzt2Bket5bjo9sdOYzOsU80= golang.org/x/exp/typeparams v0.0.0-20220428152302-39d4317da171/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= @@ -879,8 +879,8 @@ golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= 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.38.0 h1:MECBjubtXD7yj4HrhIUcywNaGeNVUdfVnxmPajOk4yk= -golang.org/x/mod v0.38.0/go.mod h1:V6Xz0pq8TQ3dGqVQ1FVHuelZpAL0uNhSkk9ogYP3c40= +golang.org/x/mod v0.40.0 h1:hUv+3cXcdRHz08UmSiOob7sadHig73uo5bkXxQ/tvUs= +golang.org/x/mod v0.40.0/go.mod h1:0/weTWkPWGBikyTWAX3dkjVztMmBA5hM0DH6BElSupE= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= @@ -895,8 +895,8 @@ golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qx golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= -golang.org/x/net v0.57.0 h1:K5+3DljvIuDG9/Jv9rvyMywYNFCQ9RSUY6OOTTkT+tE= -golang.org/x/net v0.57.0/go.mod h1:KpXc8iv+r3XplLAG/f7Jsf9RPszJzdR0f58q9vGOuEU= +golang.org/x/net v0.58.0 h1:ynWG7rqYi4ccpTEuPZ2QGWHktVEM9DMCj9yzDE0Q7To= +golang.org/x/net v0.58.0/go.mod h1:YwCddHnFlT7eLQqVprV19OnhLGtc5xOKgE0RyqgfWAU= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -949,8 +949,8 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/text v0.40.0 h1:Ub2Z6/xjgF1WrYQz2nuITOEegKFtiIy+rieRJ5lHZKs= -golang.org/x/text v0.40.0/go.mod h1:hpnzDAfGV753zIKo+wk3u1bVKCGPbrnF7+7LBF/UHVY= +golang.org/x/text v0.41.0 h1:vz/seA0lnX87Othu2f/0L24RcgrXD9/YFTSuGjj3rH8= +golang.org/x/text v0.41.0/go.mod h1:jvf1O8ajNzZqhSrQBPbutR/EB83Cc0CFrezNQIwbb5M= 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-20200329025819-fd4102a86c65/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= @@ -962,8 +962,8 @@ golang.org/x/tools v0.1.1-0.20210302220138-2ac05c832e1a/go.mod h1:9bzcO0MWcOuT0t golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E= 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.48.0 h1:3+hClM1aLL5mjMKm5ovokw9epgRXPuu2tILgismM6RE= -golang.org/x/tools v0.48.0/go.mod h1:08xX0orndb/F7jJxGDicx061tyd5pcMto75YMAXr6lk= +golang.org/x/tools v0.49.0 h1:3NI7VXzL9+1WZD52Dx2ttoPwD5DWrFGpl9mFZDlmisI= +golang.org/x/tools v0.49.0/go.mod h1:SJNXV9DBKT0UbdttsQjbfJlAE/q+y36++zo3uL3N0Oo= golang.org/x/tools/go/expect v0.1.1-deprecated h1:jpBZDwmgPhXsKZC6WhL20P4b/wmnpsEAGHaNy0n/rJM= golang.org/x/tools/go/expect v0.1.1-deprecated/go.mod h1:eihoPOH+FgIqa3FpoTwguz/bVUSGBlGQU67vpBeOrBY= golang.org/x/tools/go/packages/packagestest v0.1.1-deprecated h1:1h2MnaIAIXISqTFKdENegdpAgUXz6NrPEsbIeWaBRvM= @@ -972,8 +972,8 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T 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 v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE= -google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= +google.golang.org/protobuf v1.36.12 h1:pJOKDDOyeXErUroCihFAd5LQuwXBSpVnKGrj5o/fwxc= +google.golang.org/protobuf v1.36.12/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= 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/vendor/github.com/onsi/ginkgo/v2/CHANGELOG.md b/vendor/github.com/onsi/ginkgo/v2/CHANGELOG.md index 10e60856..4d1ed952 100644 --- a/vendor/github.com/onsi/ginkgo/v2/CHANGELOG.md +++ b/vendor/github.com/onsi/ginkgo/v2/CHANGELOG.md @@ -1,3 +1,8 @@ +## 2.32.1 + +### Fixes +- Defer AfterAll until repeated spec completes [e647b3b] + ## 2.32.0 `-fd` generate RSpec-style documentation output. Thank @woodie ! diff --git a/vendor/github.com/onsi/ginkgo/v2/internal/group.go b/vendor/github.com/onsi/ginkgo/v2/internal/group.go index 5e661133..781adf6f 100644 --- a/vendor/github.com/onsi/ginkgo/v2/internal/group.go +++ b/vendor/github.com/onsi/ginkgo/v2/internal/group.go @@ -211,6 +211,21 @@ func (g *group) isLastSpecWithPair(specID uint, pair runOncePair) bool { return lastSpecID == specID } +func (g *group) willRunAnotherAttempt(isFinalAttempt bool) bool { + if isFinalAttempt { + return false + } + + if g.suite.currentSpecReport.MaxMustPassRepeatedly > 0 { + return g.suite.currentSpecReport.State.Is(types.SpecStatePassed) + } + if g.suite.currentSpecReport.MaxFlakeAttempts > 0 { + return g.suite.currentSpecReport.State.Is(types.SpecStateFailureStates) + } + + return false +} + func (g *group) attemptSpec(isFinalAttempt bool, spec Spec) bool { failedInARunOnceBefore := false pairs := g.runOncePairs[spec.SubjectID()] @@ -280,10 +295,11 @@ func (g *group) attemptSpec(isFinalAttempt bool, spec Spec) bool { } // it's our last chance to run if we're the last spec for our oncePair isLastSpecWithPair := g.isLastSpecWithPair(spec.SubjectID(), pair) + willRunAnotherAttempt := g.willRunAnotherAttempt(isFinalAttempt) switch g.suite.currentSpecReport.State { case types.SpecStatePassed: //this attempt is passing... - return isLastSpecWithPair //...we should run-once if we'this is our last chance + return isLastSpecWithPair && !willRunAnotherAttempt //...we should run-once if this is our last chance case types.SpecStateSkipped: //the spec was skipped by the user... if isLastSpecWithPair { return true //...we're the last spec, so we should run the AfterNode @@ -292,7 +308,7 @@ func (g *group) attemptSpec(isFinalAttempt bool, spec Spec) bool { return true //...or, a run-once node at our nesting level was skipped which means this is our last chance to run } case types.SpecStateFailed, types.SpecStatePanicked, types.SpecStateTimedout: // the spec has failed... - if isFinalAttempt { + if !willRunAnotherAttempt { if g.continueOnFailure { return isLastSpecWithPair || failedInARunOnceBefore //...we're configured to continue on failures - so we should only run if we're the last spec for this pair or if we failed in a runOnceBefore (which means we _are_ the last spec to run) } else { diff --git a/vendor/github.com/onsi/ginkgo/v2/types/version.go b/vendor/github.com/onsi/ginkgo/v2/types/version.go index dc28324c..177baed9 100644 --- a/vendor/github.com/onsi/ginkgo/v2/types/version.go +++ b/vendor/github.com/onsi/ginkgo/v2/types/version.go @@ -1,3 +1,3 @@ package types -const VERSION = "2.32.0" +const VERSION = "2.32.1" diff --git a/vendor/golang.org/x/crypto/internal/poly1305/mac_noasm.go b/vendor/golang.org/x/crypto/internal/poly1305/mac_noasm.go index 8d99551f..b1da4568 100644 --- a/vendor/golang.org/x/crypto/internal/poly1305/mac_noasm.go +++ b/vendor/golang.org/x/crypto/internal/poly1305/mac_noasm.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build (!amd64 && !loong64 && !ppc64le && !ppc64 && !s390x) || !gc || purego +//go:build (!amd64 && !loong64 && !ppc64le && !ppc64 && !riscv64 && !s390x) || !gc || purego package poly1305 diff --git a/vendor/golang.org/x/crypto/internal/poly1305/sum_asm.go b/vendor/golang.org/x/crypto/internal/poly1305/sum_asm.go index 315b84ac..55041bf5 100644 --- a/vendor/golang.org/x/crypto/internal/poly1305/sum_asm.go +++ b/vendor/golang.org/x/crypto/internal/poly1305/sum_asm.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build gc && !purego && (amd64 || loong64 || ppc64 || ppc64le) +//go:build gc && !purego && (amd64 || loong64 || ppc64 || ppc64le || riscv64) package poly1305 diff --git a/vendor/golang.org/x/crypto/internal/poly1305/sum_riscv64.s b/vendor/golang.org/x/crypto/internal/poly1305/sum_riscv64.s new file mode 100644 index 00000000..ce5eb3d4 --- /dev/null +++ b/vendor/golang.org/x/crypto/internal/poly1305/sum_riscv64.s @@ -0,0 +1,158 @@ +// Copyright 2026 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build gc && !purego + +#define LOAD64U(base, offset, t0, t1, t2, t3, dst) \ + MOVBU (offset+0*1)(base), t0; \ + MOVBU (offset+1*1)(base), t1; \ + MOVBU (offset+2*1)(base), t2; \ + MOVBU (offset+3*1)(base), t3; \ + SLL $8, t1; \ + SLL $16, t2; \ + SLL $24, t3; \ + OR t1, t0; \ + OR t3, t2; \ + OR t2, t0, dst; \ + MOVBU (offset+4*1)(base), t0; \ + MOVBU (offset+5*1)(base), t1; \ + MOVBU (offset+6*1)(base), t2; \ + MOVBU (offset+7*1)(base), t3; \ + SLL $32, t0; \ + SLL $40, t1; \ + SLL $48, t2; \ + SLL $56, t3; \ + OR t1, t0; \ + OR t3, t2; \ + OR t2, t0; \ + OR t0, dst + +// func update(state *macState, msg []byte) +TEXT ·update(SB), $0-32 + MOV state+0(FP), X5 + MOV msg_base+8(FP), X6 + MOV msg_len+16(FP), X7 + + MOV $16, X8 + + AND $7, X6, X28 + + MOV (0*8)(X5), X9 // h0 + MOV (1*8)(X5), X10 // h1 + MOV (2*8)(X5), X11 // h2 + MOV (3*8)(X5), X12 // r0 + MOV (4*8)(X5), X13 // r1 + + BLT X7, X8, tail + +loop: + BEQZ X28, aligned_load + + LOAD64U(X6, 0*8, X16, X18, X19, X20, X15) // msg[0:8] + LOAD64U(X6, 1*8, X16, X18, X19, X20, X17) // msg[8:16] + JMP block + +aligned_load: + MOV (0*8)(X6), X15 // msg[0:8] + MOV (1*8)(X6), X17 // msg[8:16] + +block: + ADD X15, X9 // h0 (x1 + y1 = z1', if z1' < x1 then z1' overflow) + SLTU X15, X9, X19 // h0.carry + ADD X17, X10, X22 + SLTU X17, X22, X23 + ADD X22, X19, X10 // h1 + SLTU X22, X10, X19 + OR X23, X19 // h1.carry + ADD $1, X19 + ADD X19, X11 // h2 + + ADD $16, X6 // msg = msg[16:] + +multiply: + MULHU X9, X12, X16 // h0r0.hi + MUL X9, X12, X15 // h0r0.lo + MULHU X10, X12, X17 // h1r0.hi + MUL X10, X12, X14 // h1r0.lo + ADD X14, X16 + SLTU X14, X16, X19 + ADD X19, X17 + MUL X11, X12, X20 + ADD X17, X20 + MULHU X9, X13, X17 // h0r1.hi + MUL X9, X13, X14 // h0r1.lo + ADD X14, X16 + SLTU X14, X16, X19 + ADD X19, X17 + MOV X17, X9 + MUL X11, X13, X21 // h2r1 + MULHU X10, X13, X17 // h1r1.hi + MUL X10, X13, X14 // h1r1.lo + ADD X14, X20 + ADD X17, X21, X22 + SLTU X14, X20, X19 + ADD X22, X19, X21 + ADD X9, X20 + SLTU X9, X20, X19 + ADD X19, X21 + AND $3, X20, X11 + AND $-4, X20, X18 + ADD X18, X15, X9 + ADD X21, X16, X22 + SLTU X18, X9, X19 + SLTU X21, X22, X23 + ADD X22, X19, X10 + SLTU X22, X10, X19 + OR X19, X23, X19 + ADD X19, X11 + SLL $62, X21, X22 + SRL $2, X20, X23 + SRL $2, X21, X21 + OR X22, X23, X20 + ADD X20, X9, X9 + ADD X21, X10, X22 + SLTU X20, X9, X19 + SLTU X21, X22, X23 + ADD X22, X19, X10 + SLTU X22, X10, X19 + OR X19, X23, X19 + ADD X19, X11, X11 + + SUB $16, X7, X7 + BGE X7, X8, loop + +tail: + BEQ X7, X0, done + MOV $1, X15 + MOV $0, X16 + ADD X7, X6, X6 + +flush_buffer: + MOVBU -1(X6), X20 + SRL $56, X15, X19 + SLL $8, X16, X23 + SLL $8, X15, X15 + OR X19, X23, X16 + XOR X20, X15 + SUB $1, X7, X7 + SUB $1, X6, X6 + BNE X7, X0, flush_buffer + + ADD X15, X9 + SLTU X15, X9, X19 + ADD X16, X10, X22 + SLTU X16, X22, X23 + ADD X22, X19, X10 + SLTU X22, X10, X19 + OR X23, X19 + ADD X19, X11 + + MOV $16, X7 + JMP multiply + +done: + MOV X9, (0*8)(X5) // h0 + MOV X10, (1*8)(X5) + MOV X11, (2*8)(X5) + RET diff --git a/vendor/golang.org/x/crypto/ssh/certs.go b/vendor/golang.org/x/crypto/ssh/certs.go index 6f75d77e..fa848f51 100644 --- a/vendor/golang.org/x/crypto/ssh/certs.go +++ b/vendor/golang.org/x/crypto/ssh/certs.go @@ -229,15 +229,20 @@ func parseCert(in []byte, privAlgo string) (*Certificate, error) { return nil, err } c.Reserved = g.Reserved + // Reject a certificate whose signature key is itself a certificate before + // parsing it. Certificates signed by certificates are not supported (see + // PROTOCOL.certkeys), and rejecting after ParsePublicKey returns would allow + // a chain of nested certificates to recurse once per level, exhausting the + // goroutine stack. + if sigAlgo, _, ok := parseString(g.SignatureKey); !ok { + return nil, errShortRead + } else if _, ok := certKeyAlgoNames[string(sigAlgo)]; ok { + return nil, fmt.Errorf("ssh: the signature key type %q is invalid for certificates", sigAlgo) + } k, err := ParsePublicKey(g.SignatureKey) if err != nil { return nil, err } - // The Type() function is intended to return only certificate key types, but - // we use certKeyAlgoNames anyway for safety, to match [Certificate.Type]. - if _, ok := certKeyAlgoNames[k.Type()]; ok { - return nil, fmt.Errorf("ssh: the signature key type %q is invalid for certificates", k.Type()) - } c.SignatureKey = k c.Signature, rest, ok = parseSignatureBody(g.Signature) if !ok || len(rest) > 0 { diff --git a/vendor/golang.org/x/crypto/ssh/channel.go b/vendor/golang.org/x/crypto/ssh/channel.go index afc9aef1..ba3279e9 100644 --- a/vendor/golang.org/x/crypto/ssh/channel.go +++ b/vendor/golang.org/x/crypto/ssh/channel.go @@ -216,6 +216,10 @@ type channel struct { // packetPool has a buffer for each extended channel ID to // save allocations during writes. packetPool map[uint32][]byte + + // closeOnce guards close so it is idempotent: closing the internal Go + // channels (msg, incomingRequests) more than once would panic. + closeOnce sync.Once } // writePacket sends a packet. If the packet is a channel close, it updates @@ -340,7 +344,18 @@ func (ch *channel) handleData(packet []byte) error { if extended == 1 { ch.extPending.write(data) } else if extended > 0 { - // discard other extended data. + // RFC 4254, Section 5.2 defines no extended data types other + // than stderr (type 1, handled above) and this package provides + // no API to read them, so the data is discarded. Credit its + // window back immediately: it can never be read, so the + // deduction above would otherwise shrink the window permanently. + // adjustWindow returns io.EOF if the local side has already + // sent a channel close; ignore it like ReadExtended does, since + // an error returned here would terminate the mux read loop and + // tear down the whole connection. + if err := ch.adjustWindow(length); err != nil && err != io.EOF { + return err + } } else { ch.pending.write(data) } @@ -393,17 +408,19 @@ func (c *channel) ReadExtended(data []byte, extended uint32) (n int, err error) } func (c *channel) close() { - c.pending.eof() - c.extPending.eof() - close(c.msg) - close(c.incomingRequests) - c.writeMu.Lock() - // This is not necessary for a normal channel teardown, but if - // there was another error, it is. - c.sentClose = true - c.writeMu.Unlock() - // Unblock writers. - c.remoteWin.close() + c.closeOnce.Do(func() { + c.pending.eof() + c.extPending.eof() + close(c.msg) + close(c.incomingRequests) + c.writeMu.Lock() + // This is not necessary for a normal channel teardown, but if + // there was another error, it is. + c.sentClose = true + c.writeMu.Unlock() + // Unblock writers. + c.remoteWin.close() + }) } // responseMessageReceived is called when a success or failure message is @@ -493,19 +510,20 @@ func (ch *channel) handlePacket(packet []byte) error { func (m *mux) newChannel(chanType string, direction channelDirection, extraData []byte) *channel { ch := &channel{ - remoteWin: window{Cond: newCond()}, - myWindow: channelWindowSize, - pending: newBuffer(), - extPending: newBuffer(), - direction: direction, - incomingRequests: make(chan *Request, chanSize), - msg: make(chan interface{}, chanSize), - chanType: chanType, - extraData: extraData, - mux: m, - packetPool: make(map[uint32][]byte), - } - ch.localId = m.chanList.add(ch) + remoteWin: window{Cond: newCond()}, + myWindow: channelWindowSize, + maxIncomingPayload: channelMaxPacket, + pending: newBuffer(), + extPending: newBuffer(), + direction: direction, + incomingRequests: make(chan *Request, chanSize), + msg: make(chan interface{}, chanSize), + chanType: chanType, + extraData: extraData, + mux: m, + packetPool: make(map[uint32][]byte), + } + m.chanList.add(ch) return ch } @@ -529,7 +547,6 @@ func (ch *channel) Accept() (Channel, <-chan *Request, error) { if ch.decided { return nil, nil, errDecidedAlready } - ch.maxIncomingPayload = channelMaxPacket confirm := channelOpenConfirmMsg{ PeersID: ch.remoteId, MyID: ch.localId, diff --git a/vendor/golang.org/x/crypto/ssh/client_auth.go b/vendor/golang.org/x/crypto/ssh/client_auth.go index 60af2fc4..138cc900 100644 --- a/vendor/golang.org/x/crypto/ssh/client_auth.go +++ b/vendor/golang.org/x/crypto/ssh/client_auth.go @@ -798,7 +798,7 @@ func (g *gssAPIWithMICCallback) auth(session []byte, user string, c packetConn, return authFailure, nil, fmt.Errorf("GSS-API Error:\n"+ "Major Status: %d\n"+ "Minor Status: %d\n"+ - "Error Message: %s\n", userAuthGSSAPIErrorResp.MajorStatus, userAuthGSSAPIErrorResp.MinorStatus, + "Error Message: %q\n", userAuthGSSAPIErrorResp.MajorStatus, userAuthGSSAPIErrorResp.MinorStatus, userAuthGSSAPIErrorResp.Message) case msgUserAuthGSSAPIToken: userAuthGSSAPITokenReq := &userAuthGSSAPIToken{} diff --git a/vendor/golang.org/x/crypto/ssh/common.go b/vendor/golang.org/x/crypto/ssh/common.go index 2e44e9c9..aed0fd92 100644 --- a/vendor/golang.org/x/crypto/ssh/common.go +++ b/vendor/golang.org/x/crypto/ssh/common.go @@ -419,7 +419,7 @@ type AlgorithmNegotiationError struct { } func (a *AlgorithmNegotiationError) Error() string { - return fmt.Sprintf("ssh: no common algorithm for %s; we offered: %v, peer offered: %v", + return fmt.Sprintf("ssh: no common algorithm for %s; we offered: %q, peer offered: %q", a.What, a.SupportedAlgorithms, a.RequestedAlgorithms) } @@ -544,7 +544,7 @@ func (c *Config) SetDefaults() { if c.Rand == nil { c.Rand = rand.Reader } - if c.Ciphers == nil { + if len(c.Ciphers) == 0 { c.Ciphers = defaultCiphers } var ciphers []string @@ -556,7 +556,7 @@ func (c *Config) SetDefaults() { } c.Ciphers = ciphers - if c.KeyExchanges == nil { + if len(c.KeyExchanges) == 0 { c.KeyExchanges = defaultKexAlgos } var kexs []string @@ -571,7 +571,7 @@ func (c *Config) SetDefaults() { } c.KeyExchanges = kexs - if c.MACs == nil { + if len(c.MACs) == 0 { c.MACs = defaultMACs } var macs []string diff --git a/vendor/golang.org/x/crypto/ssh/connection.go b/vendor/golang.org/x/crypto/ssh/connection.go index 378f6407..9e0ed089 100644 --- a/vendor/golang.org/x/crypto/ssh/connection.go +++ b/vendor/golang.org/x/crypto/ssh/connection.go @@ -17,7 +17,7 @@ type OpenChannelError struct { } func (e *OpenChannelError) Error() string { - return fmt.Sprintf("ssh: rejected: %s (%s)", e.Reason, e.Message) + return fmt.Sprintf("ssh: rejected: %s (%q)", e.Reason, e.Message) } // ConnMetadata holds metadata for the connection. diff --git a/vendor/golang.org/x/crypto/ssh/handshake.go b/vendor/golang.org/x/crypto/ssh/handshake.go index 4be3cbb6..711a7f7c 100644 --- a/vendor/golang.org/x/crypto/ssh/handshake.go +++ b/vendor/golang.org/x/crypto/ssh/handshake.go @@ -162,7 +162,7 @@ func newClientTransport(conn keyingTransport, clientVersion, serverVersion []byt t.remoteAddr = addr t.hostKeyCallback = config.HostKeyCallback t.bannerCallback = config.BannerCallback - if config.HostKeyAlgorithms != nil { + if len(config.HostKeyAlgorithms) > 0 { t.hostKeyAlgorithms = config.HostKeyAlgorithms } else { t.hostKeyAlgorithms = defaultHostKeyAlgos diff --git a/vendor/golang.org/x/crypto/ssh/keys.go b/vendor/golang.org/x/crypto/ssh/keys.go index 64377715..fbbfb6cf 100644 --- a/vendor/golang.org/x/crypto/ssh/keys.go +++ b/vendor/golang.org/x/crypto/ssh/keys.go @@ -485,10 +485,11 @@ func parseRSA(in []byte) (out PublicKey, rest []byte, err error) { return nil, nil, err } - // 8192 bits is also the maximum RSA key size accepted by crypto/tls for - // signature verification: - // https://github.com/golang/go/blob/69801b25/src/crypto/tls/handshake_client.go#L1096 - if w.N.BitLen() > 8192 { + // 16384 bits is the largest RSA key OpenSSH will generate (ssh-keygen + // caps -b at 16384), so it is the practical upper bound for keys seen on + // the wire. Rejecting anything larger bounds the CPU spent verifying an + // attacker-supplied key and signature, mitigating a denial of service. + if w.N.BitLen() > 16384 { return nil, nil, errors.New("ssh: rsa modulus too large") } if w.E.BitLen() > 24 { @@ -1669,13 +1670,13 @@ func parseOpenSSHPrivateKey(key []byte, decrypt openSSHDecryptFunc) (crypto.Priv } // Mirror the validation done in parseRSA for public keys: cap the - // modulus at the same limit enforced by crypto/tls, reject oversized - // or invalid exponents, and additionally bound the prime factors to + // modulus at the OpenSSH-generated maximum, reject oversized or + // invalid exponents, and additionally bound the prime factors to // avoid the expensive CRT coefficient recomputation in pk.Precompute. - if key.N.BitLen() > 8192 { + if key.N.BitLen() > 16384 { return nil, errors.New("ssh: rsa modulus too large") } - if key.P.BitLen() > 4096 || key.Q.BitLen() > 4096 { + if key.P.BitLen() > 8192 || key.Q.BitLen() > 8192 { return nil, errors.New("ssh: rsa prime too large") } if key.E.BitLen() > 24 { diff --git a/vendor/golang.org/x/crypto/ssh/messages.go b/vendor/golang.org/x/crypto/ssh/messages.go index de86f71c..1d23dde2 100644 --- a/vendor/golang.org/x/crypto/ssh/messages.go +++ b/vendor/golang.org/x/crypto/ssh/messages.go @@ -44,16 +44,7 @@ type disconnectMsg struct { } func (d *disconnectMsg) Error() string { - return fmt.Sprintf("ssh: disconnect, reason %d: %q", d.Reason, sanitizeString(d.Message)) -} - -func sanitizeString(s string) string { - return strings.Map(func(r rune) rune { - if r == '\t' || (r >= ' ' && r < 0x7f) { - return r - } - return -1 - }, s) + return fmt.Sprintf("ssh: disconnect, reason %d: %q", d.Reason, d.Message) } // See RFC 4253, section 7.1. diff --git a/vendor/golang.org/x/crypto/ssh/mux.go b/vendor/golang.org/x/crypto/ssh/mux.go index 5775881c..955560bd 100644 --- a/vendor/golang.org/x/crypto/ssh/mux.go +++ b/vendor/golang.org/x/crypto/ssh/mux.go @@ -32,18 +32,21 @@ type chanList struct { offset uint32 } -// Assigns a channel ID to the given channel. -func (c *chanList) add(ch *channel) uint32 { +// add stores the given channel and assigns its localId while holding the +// lock, so that getChan can never return a channel whose localId is not yet +// initialized. +func (c *chanList) add(ch *channel) { c.Lock() defer c.Unlock() for i := range c.chans { if c.chans[i] == nil { c.chans[i] = ch - return uint32(i) + c.offset + ch.localId = uint32(i) + c.offset + return } } c.chans = append(c.chans, ch) - return uint32(len(c.chans)-1) + c.offset + ch.localId = uint32(len(c.chans)-1) + c.offset } // getChan returns the channel for the given ID. @@ -343,8 +346,6 @@ func (m *mux) OpenChannel(chanType string, extra []byte) (Channel, <-chan *Reque func (m *mux) openChannel(chanType string, extra []byte) (*channel, error) { ch := m.newChannel(chanType, channelOutbound, extra) - ch.maxIncomingPayload = channelMaxPacket - open := channelOpenMsg{ ChanType: chanType, PeersWindow: ch.myWindow, diff --git a/vendor/golang.org/x/crypto/ssh/server.go b/vendor/golang.org/x/crypto/ssh/server.go index 3c0fcc95..e0902626 100644 --- a/vendor/golang.org/x/crypto/ssh/server.go +++ b/vendor/golang.org/x/crypto/ssh/server.go @@ -26,10 +26,16 @@ type Permissions struct { // defines "force-command" (only allow the given command to // execute) and "source-address" (only allow connections from // the given address). The SSH package currently only enforces - // the "source-address" critical option. It is up to server - // implementations to enforce other critical options, such as - // "force-command", by checking them after the SSH handshake - // is successful. In general, SSH servers should reject + // the "source-address" critical option: it is validated against + // the client's remote address whenever it is present in the + // Permissions returned by any authentication callback. Its value + // is a comma-separated list of IP addresses and CIDR blocks; + // consistently with OpenSSH, a connection whose remote address is + // not an IP address, such as a Unix domain socket, never matches + // the list and is rejected when the option is present. It is up + // to server implementations to enforce other critical options, + // such as "force-command", by checking them after the SSH + // handshake is successful. In general, SSH servers should reject // connections that specify critical options that are unknown // or not supported. CriticalOptions map[string]string @@ -223,7 +229,9 @@ type ServerConfig struct { // Permissions object can be the same object, optionally modified, or a // completely new object. If VerifiedPublicKeyCallback is non-nil, // PublicKeyCallback is not allowed to return a PartialSuccessError, which - // can instead be returned by VerifiedPublicKeyCallback. + // can instead be returned by VerifiedPublicKeyCallback. The + // signatureAlgorithm argument is the format of the signature that was + // successfully verified. // // VerifiedPublicKeyCallback does not affect which authentication methods // are included in the list of methods that can be attempted by the client. @@ -442,6 +450,10 @@ func (s *connection) serverHandshake(config *ServerConfig) (*Permissions, error) return perms, err } +// checkSourceAddress matches addr against sourceAddrs, a comma-separated list +// of IP addresses and CIDR blocks. Consistently with OpenSSH, a remote address +// that is not IP-based, such as a Unix domain socket, never matches the list +// and is rejected. func checkSourceAddress(addr net.Addr, sourceAddrs string) error { if addr == nil { return errors.New("ssh: no address known for client, but source-address match required") @@ -449,7 +461,7 @@ func checkSourceAddress(addr net.Addr, sourceAddrs string) error { tcpAddr, ok := addr.(*net.TCPAddr) if !ok { - return fmt.Errorf("ssh: remote address %v is not an TCP address when checking source-address match", addr) + return fmt.Errorf("ssh: remote address %v is not a TCP address when checking source-address match", addr) } for _, sourceAddr := range strings.Split(sourceAddrs, ",") { @@ -472,6 +484,21 @@ func checkSourceAddress(addr net.Addr, sourceAddrs string) error { return fmt.Errorf("ssh: remote address %v is not allowed because of source-address restriction", addr) } +// checkSourceAddressCriticalOption enforces the source-address critical +// option, if present in perms, as documented in Permissions.CriticalOptions. +// A present but empty value matches no address, so it denies authentication, +// consistently with OpenSSH, rather than being treated as absent. +func checkSourceAddressCriticalOption(addr net.Addr, perms *Permissions) error { + if perms == nil { + return nil + } + saco, ok := perms.CriticalOptions[sourceAddressCriticalOption] + if !ok { + return nil + } + return checkSourceAddress(addr, saco) +} + func gssExchangeToken(gssapiConfig *GSSAPIWithMICConfig, token []byte, s *connection, sessionID []byte, userAuthReq userAuthRequestMsg) (authErr error, perms *Permissions, err error) { gssAPIServer := gssapiConfig.Server @@ -685,7 +712,7 @@ userAuthLoop: } if userAuthReq.Service != serviceSSH { - return nil, errors.New("ssh: client attempted to negotiate for unknown service: " + userAuthReq.Service) + return nil, fmt.Errorf("ssh: client attempted to negotiate for unknown service: %q", userAuthReq.Service) } if s.user != userAuthReq.User && partialSuccessReturned { @@ -771,7 +798,8 @@ userAuthLoop: pubKey, err := ParsePublicKey(pubKeyData) if err != nil { - return nil, err + authErr = err + break } candidate, ok := cache.get(s.user, pubKeyData) @@ -784,13 +812,14 @@ userAuthLoop: return nil, errors.New("ssh: invalid library usage: PublicKeyCallback must not return partial success when VerifiedPublicKeyCallback is defined") } - if (candidate.result == nil || isPartialSuccessError) && - candidate.perms != nil && - candidate.perms.CriticalOptions != nil && - candidate.perms.CriticalOptions[sourceAddressCriticalOption] != "" { - if err := checkSourceAddress( - s.RemoteAddr(), - candidate.perms.CriticalOptions[sourceAddressCriticalOption]); err != nil { + // This check is authoritative for the Permissions returned by + // PublicKeyCallback: the check at the end of the auth loop sees + // the final Permissions, which VerifiedPublicKeyCallback may + // have replaced, and is skipped on partial success. It also + // makes public key queries fail before the client signs when + // PublicKeyCallback supplies the restriction. + if candidate.result == nil || isPartialSuccessError { + if err := checkSourceAddressCriticalOption(s.RemoteAddr(), candidate.perms); err != nil { candidate.result = err } } @@ -864,14 +893,7 @@ userAuthLoop: // Only call VerifiedPublicKeyCallback after the key has been accepted // and successfully verified. If authErr is non-nil, the key is not // considered verified and the callback must not run. - perms, authErr = config.VerifiedPublicKeyCallback(s, pubKey, perms, algo) - } - if authErr == nil && perms != nil && perms.CriticalOptions != nil { - if saco := perms.CriticalOptions[sourceAddressCriticalOption]; saco != "" { - if err := checkSourceAddress(s.RemoteAddr(), saco); err != nil { - authErr = err - } - } + perms, authErr = config.VerifiedPublicKeyCallback(s, pubKey, perms, sig.Format) } } case "gssapi-with-mic": @@ -925,6 +947,17 @@ userAuthLoop: authErr = fmt.Errorf("ssh: unknown method %q", userAuthReq.Method) } + // The source-address critical option is enforced on the Permissions + // returned by any authentication callback. Permissions returned + // together with a PartialSuccessError skip this check: that is safe + // because they are required to be nil, as enforced in the partial + // success handling below. + if authErr == nil { + if err := checkSourceAddressCriticalOption(s.RemoteAddr(), perms); err != nil { + authErr = err + } + } + authErrs = append(authErrs, authErr) if config.AuthLogCallback != nil { diff --git a/vendor/golang.org/x/crypto/ssh/ssh_gss.go b/vendor/golang.org/x/crypto/ssh/ssh_gss.go index a6249a12..a7a09975 100644 --- a/vendor/golang.org/x/crypto/ssh/ssh_gss.go +++ b/vendor/golang.org/x/crypto/ssh/ssh_gss.go @@ -118,24 +118,28 @@ func parseGSSAPIPayload(payload []byte) (*userAuthRequestGSSAPI, error) { OIDS: make([]asn1.ObjectIdentifier, n), } for i := 0; i < int(n); i++ { - var ( - desiredMech []byte - err error - ) + var desiredMech []byte desiredMech, rest, ok = parseString(rest) if !ok { return nil, errors.New("parse string failed") } - if rest, err = asn1.Unmarshal(desiredMech, &s.OIDS[i]); err != nil { + trailing, err := asn1.Unmarshal(desiredMech, &s.OIDS[i]) + if err != nil { return nil, err } + if len(trailing) != 0 { + return nil, errors.New("trailing bytes after OID") + } + } + if len(rest) != 0 { + return nil, errors.New("trailing bytes after mechanisms") } return s, nil } // See RFC 4462 section 3.6. func buildMIC(sessionID string, username string, service string, authMethod string) []byte { - out := make([]byte, 0, 0) + out := make([]byte, 0) out = appendString(out, sessionID) out = append(out, msgUserAuthRequest) out = appendString(out, username) diff --git a/vendor/golang.org/x/crypto/ssh/streamlocal.go b/vendor/golang.org/x/crypto/ssh/streamlocal.go index 152470fc..8e997da3 100644 --- a/vendor/golang.org/x/crypto/ssh/streamlocal.go +++ b/vendor/golang.org/x/crypto/ssh/streamlocal.go @@ -58,6 +58,7 @@ func (c *Client) dialStreamLocal(socketPath string) (Channel, error) { return nil, err } go DiscardRequests(in) + go io.Copy(io.Discard, ch.Stderr()) return ch, err } @@ -79,6 +80,7 @@ func (l *unixListener) Accept() (net.Conn, error) { return nil, err } go DiscardRequests(incoming) + go io.Copy(io.Discard, ch.Stderr()) return &chanConn{ Channel: ch, diff --git a/vendor/golang.org/x/crypto/ssh/tcpip.go b/vendor/golang.org/x/crypto/ssh/tcpip.go index 78c41fe5..213d8a61 100644 --- a/vendor/golang.org/x/crypto/ssh/tcpip.go +++ b/vendor/golang.org/x/crypto/ssh/tcpip.go @@ -332,6 +332,7 @@ func (l *tcpListener) Accept() (net.Conn, error) { return nil, err } go DiscardRequests(incoming) + go io.Copy(io.Discard, ch.Stderr()) return &chanConn{ Channel: ch, @@ -495,6 +496,7 @@ func (c *Client) dial(laddr string, lport int, raddr string, rport int) (Channel return nil, err } go DiscardRequests(in) + go io.Copy(io.Discard, ch.Stderr()) return ch, nil } diff --git a/vendor/golang.org/x/tools/go/analysis/passes/fieldalignment/fieldalignment.go b/vendor/golang.org/x/tools/go/analysis/passes/fieldalignment/fieldalignment.go index 53c74634..02791bc7 100644 --- a/vendor/golang.org/x/tools/go/analysis/passes/fieldalignment/fieldalignment.go +++ b/vendor/golang.org/x/tools/go/analysis/passes/fieldalignment/fieldalignment.go @@ -14,6 +14,7 @@ import ( "go/token" "go/types" "sort" + "strings" "golang.org/x/tools/go/analysis" "golang.org/x/tools/go/analysis/passes/inspect" @@ -68,37 +69,66 @@ var Analyzer = &analysis.Analyzer{ func run(pass *analysis.Pass) (any, error) { inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector) - nodeFilter := []ast.Node{ - (*ast.StructType)(nil), - } - inspect.Preorder(nodeFilter, func(node ast.Node) { - var s *ast.StructType - var ok bool - if s, ok = node.(*ast.StructType); !ok { - return - } - if tv, ok := pass.TypesInfo.Types[s]; ok { - fieldalignment(pass, s, tv.Type.(*types.Struct)) + for curStruct := range inspect.Root().Preorder((*ast.StructType)(nil)) { + s := curStruct.Node().(*ast.StructType) + // For every named struct defined as "type Name struct { ... }", + // the *ast.StructType node has a parent *ast.TypeSpec, + // which contains the struct's name in its Name field. + name := "struct" // (anonymous) + if spec, ok := curStruct.Parent().Node().(*ast.TypeSpec); ok { + name = spec.Name.Name } - }) + fieldalignment(pass, s, name) + } + return nil, nil } -var unsafePointerTyp = types.Unsafe.Scope().Lookup("Pointer").(*types.TypeName).Type() +func fieldalignment(pass *analysis.Pass, node *ast.StructType, name string) { + var ( + sizes = &gcSizes{ + wordSize: pass.TypesSizes.Sizeof(types.Typ[types.UnsafePointer]), + maxAlign: pass.TypesSizes.Alignof(types.Typ[types.UnsafePointer]), + } -func fieldalignment(pass *analysis.Pass, node *ast.StructType, typ *types.Struct) { - wordSize := pass.TypesSizes.Sizeof(unsafePointerTyp) - maxAlign := pass.TypesSizes.Alignof(unsafePointerTyp) + typ = pass.TypesInfo.TypeOf(node).(*types.Struct) + optimal, indexes = optimalOrder(typ, sizes) + + actualSize = sizes.sizeof(typ) + actualPtrs = sizes.ptrdata(typ) + + optimalSize = sizes.sizeof(optimal) + optimalPtrs = sizes.ptrdata(optimal) + ) + + var message strings.Builder + if actualSize != optimalSize { + // Struct could be smaller. + // TODO(adonovan): IMHO the criterion should be "significantly smaller". + fmt.Fprintf(&message, "%s has size %d", name, actualSize) + actualClass := classSize(actualSize) + if actualClass == -1 { + actualClass = actualSize + fmt.Fprint(&message, " (uses global allocator)") + } else if actualClass != actualSize { + fmt.Fprintf(&message, " (allocator size class %d)", actualClass) + } - s := gcSizes{wordSize, maxAlign} - optimal, indexes := optimalOrder(typ, &s) - optsz, optptrs := s.Sizeof(optimal), s.ptrdata(optimal) + fmt.Fprintf(&message, " but the optimal size is %d", optimalSize) + optimalClass := classSize(optimalSize) + if optimalClass == -1 { + optimalClass = optimalSize + } else if optimalClass != optimalSize { + fmt.Fprintf(&message, " (allocator size class %d)", optimalClass) + } - var message string - if sz := s.Sizeof(typ); sz != optsz { - message = fmt.Sprintf("struct of size %d could be %d", sz, optsz) - } else if ptrs := s.ptrdata(typ); ptrs != optptrs { - message = fmt.Sprintf("struct with %d pointer bytes could be %d", ptrs, optptrs) + wastage := actualClass - optimalClass + if percentage := wastage * 100 / actualClass; percentage > 25 { + fmt.Fprintf(&message, " leading to a waste of %d bytes (%d%%)", wastage, percentage) + } + } else if actualPtrs != optimalPtrs { + // Struct could place pointers more efficiently for GC marking. + fmt.Fprintf(&message, "%s has %d leading bytes of pointer data but optimal value is %d", name, actualPtrs, optimalPtrs) } else { // Already optimal order. return @@ -151,7 +181,7 @@ func fieldalignment(pass *analysis.Pass, node *ast.StructType, typ *types.Struct pass.Report(analysis.Diagnostic{ Pos: node.Pos(), End: node.Pos() + token.Pos(len("struct")), - Message: message, + Message: message.String(), SuggestedFixes: []analysis.SuggestedFix{{ Message: "Rearrange fields", TextEdits: []analysis.TextEdit{{ @@ -179,8 +209,8 @@ func optimalOrder(str *types.Struct, sizes *gcSizes) (*types.Struct, []int) { ft := field.Type() elems[i] = elem{ i, - sizes.Alignof(ft), - sizes.Sizeof(ft), + sizes.alignof(ft), + sizes.sizeof(ft), sizes.ptrdata(ft), } } @@ -240,40 +270,42 @@ func optimalOrder(str *types.Struct, sizes *gcSizes) (*types.Struct, []int) { return types.NewStruct(fields, nil), indexes } -// Code below based on go/types.StdSizes. +// gcSizes implements cmd/compile layout rules, providing ptrdata (GC +// scanning limits) and trailing zero-size field padding not available +// in [types.Sizes]. type gcSizes struct { - WordSize int64 - MaxAlign int64 + wordSize int64 + maxAlign int64 } -func (s *gcSizes) Alignof(T types.Type) int64 { +func (s *gcSizes) alignof(T types.Type) int64 { // For arrays and structs, alignment is defined in terms // of alignment of the elements and fields, respectively. switch t := T.Underlying().(type) { case *types.Array: // spec: "For a variable x of array type: unsafe.Alignof(x) // is the same as unsafe.Alignof(x[0]), but at least 1." - return s.Alignof(t.Elem()) + return s.alignof(t.Elem()) case *types.Struct: // spec: "For a variable x of struct type: unsafe.Alignof(x) // is the largest of the values unsafe.Alignof(x.f) for each // field f of x, but at least 1." max := int64(1) for i, nf := 0, t.NumFields(); i < nf; i++ { - if a := s.Alignof(t.Field(i).Type()); a > max { + if a := s.alignof(t.Field(i).Type()); a > max { max = a } } return max } - a := s.Sizeof(T) // may be 0 + a := s.sizeof(T) // may be 0 // spec: "For a variable x of any type: unsafe.Alignof(x) is at least 1." if a < 1 { return 1 } - if a > s.MaxAlign { - return s.MaxAlign + if a > s.maxAlign { + return s.maxAlign } return a } @@ -294,7 +326,7 @@ var basicSizes = [...]byte{ types.Complex128: 16, } -func (s *gcSizes) Sizeof(T types.Type) int64 { +func (s *gcSizes) sizeof(T types.Type) int64 { switch t := T.Underlying().(type) { case *types.Basic: k := t.Kind() @@ -304,12 +336,12 @@ func (s *gcSizes) Sizeof(T types.Type) int64 { } } if k == types.String { - return s.WordSize * 2 + return s.wordSize * 2 } case *types.Array: - return t.Len() * s.Sizeof(t.Elem()) + return t.Len() * s.sizeof(t.Elem()) case *types.Slice: - return s.WordSize * 3 + return s.wordSize * 3 case *types.Struct: nf := t.NumFields() if nf == 0 { @@ -320,7 +352,7 @@ func (s *gcSizes) Sizeof(T types.Type) int64 { max := int64(1) for i := range nf { ft := t.Field(i).Type() - a, sz := s.Alignof(ft), s.Sizeof(ft) + a, sz := s.alignof(ft), s.sizeof(ft) if a > max { max = a } @@ -331,9 +363,9 @@ func (s *gcSizes) Sizeof(T types.Type) int64 { } return align(o, max) case *types.Interface: - return s.WordSize * 2 + return s.wordSize * 2 } - return s.WordSize // catch-all + return s.wordSize // catch-all } // align returns the smallest y >= x such that y % a == 0. @@ -347,13 +379,13 @@ func (s *gcSizes) ptrdata(T types.Type) int64 { case *types.Basic: switch t.Kind() { case types.String, types.UnsafePointer: - return s.WordSize + return s.wordSize } return 0 case *types.Chan, *types.Map, *types.Pointer, *types.Signature, *types.Slice: - return s.WordSize + return s.wordSize case *types.Interface: - return 2 * s.WordSize + return 2 * s.wordSize case *types.Array: n := t.Len() if n == 0 { @@ -363,7 +395,7 @@ func (s *gcSizes) ptrdata(T types.Type) int64 { if a == 0 { return 0 } - z := s.Sizeof(t.Elem()) + z := s.sizeof(t.Elem()) return (n-1)*z + a case *types.Struct: nf := t.NumFields() @@ -374,7 +406,7 @@ func (s *gcSizes) ptrdata(T types.Type) int64 { var o, p int64 for i := range nf { ft := t.Field(i).Type() - a, sz := s.Alignof(ft), s.Sizeof(ft) + a, sz := s.alignof(ft), s.sizeof(ft) fp := s.ptrdata(ft) o = align(o, a) if fp != 0 { @@ -387,3 +419,16 @@ func (s *gcSizes) ptrdata(T types.Type) int64 { panic("impossible") } + +// Code below based on tools/gopls/internal/golang/hover.go + +// classSize reports the size class for a struct of the specified size, or -1 if unknown. +// See GOROOT/src/runtime/msize.go for details. +func classSize(size int64) int64 { + if size > 1<<15 { + return -1 // avoid allocation + } + // We assume that bytes.Clone doesn't trim, + // and reports the underlying size class + return int64(cap(bytes.Clone(make([]byte, size)))) +} diff --git a/vendor/golang.org/x/tools/go/analysis/passes/modernize/any.go b/vendor/golang.org/x/tools/go/analysis/passes/modernize/any.go index 579ab865..79e2802c 100644 --- a/vendor/golang.org/x/tools/go/analysis/passes/modernize/any.go +++ b/vendor/golang.org/x/tools/go/analysis/passes/modernize/any.go @@ -18,7 +18,7 @@ var AnyAnalyzer = &analysis.Analyzer{ Doc: analyzerutil.MustExtractDoc(doc, "any"), Requires: []*analysis.Analyzer{inspect.Analyzer}, Run: runAny, - URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#any", + URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_any", } // The any pass replaces interface{} with go1.18's 'any'. diff --git a/vendor/golang.org/x/tools/go/analysis/passes/modernize/atomictypes.go b/vendor/golang.org/x/tools/go/analysis/passes/modernize/atomictypes.go index 9df39fb2..6fd618f9 100644 --- a/vendor/golang.org/x/tools/go/analysis/passes/modernize/atomictypes.go +++ b/vendor/golang.org/x/tools/go/analysis/passes/modernize/atomictypes.go @@ -33,7 +33,7 @@ var AtomicTypesAnalyzer = &analysis.Analyzer{ typeindexanalyzer.Analyzer, }, Run: runAtomic, - URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#atomictypes", + URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_atomictypes", } // TODO(mkalil): support the Pointer variants. diff --git a/vendor/golang.org/x/tools/go/analysis/passes/modernize/bloop.go b/vendor/golang.org/x/tools/go/analysis/passes/modernize/bloop.go index ad45d744..d44c8567 100644 --- a/vendor/golang.org/x/tools/go/analysis/passes/modernize/bloop.go +++ b/vendor/golang.org/x/tools/go/analysis/passes/modernize/bloop.go @@ -32,7 +32,7 @@ var BLoopAnalyzer = &analysis.Analyzer{ typeindexanalyzer.Analyzer, }, Run: bloop, - URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#bloop", + URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_bloop", } // bloop updates benchmarks that use "for range b.N", replacing it diff --git a/vendor/golang.org/x/tools/go/analysis/passes/modernize/doc.go b/vendor/golang.org/x/tools/go/analysis/passes/modernize/doc.go index c5545c0c..caf3df95 100644 --- a/vendor/golang.org/x/tools/go/analysis/passes/modernize/doc.go +++ b/vendor/golang.org/x/tools/go/analysis/passes/modernize/doc.go @@ -15,13 +15,16 @@ causing build breakage. However, these problems are generally trivial to fix. We regard any modernizer whose fix changes program behavior to have a serious bug and will endeavor to fix it. -To apply all modernization fixes en masse, you can use the +Since Go 1.26, the 'go fix' command has included the modernize suite, +so to apply all modernization fixes en masse, you can use the following command: - $ go run golang.org/x/tools/go/analysis/passes/modernize/cmd/modernize@latest -fix ./... + $ go fix ./... + +If you need to run a modernizer added or modified since the Go +release, you can use this standalone command: -(Do not use "go get -tool" to add gopls as a dependency of your -module; gopls commands must be built from their release branch.) + $ go run golang.org/x/tools/go/analysis/passes/modernize/cmd/modernize@latest -fix ./... If the tool warns of conflicting fixes, you may need to run it more than once until it has applied all fixes cleanly. This command is @@ -344,6 +347,21 @@ No fix is offered in cases when the runtime type is dynamic, such as: or when the operand has potential side effects. +# Analyzer reflecttypeassert + +reflecttypeassert: replace v.Interface().(T) with reflect.TypeAssert[T](v) + +This analyzer suggests fixes to replace two-valued type assertions on +the result of (reflect.Value).Interface with reflect.TypeAssert, +introduced in go1.25, which avoids the intermediate allocation of an +interface value, for example: + + x, ok := v.Interface().(string) -> x, ok := reflect.TypeAssert[string](v) + +No fix is offered for single-valued assertions, since they panic when +the assertion fails whereas reflect.TypeAssert does not. Nor is a fix +offered for a type switch. + # Analyzer slicesbackward slicesbackward: replace backward loops over slices with slices.Backward @@ -366,6 +384,22 @@ the index and value variables are kept: for i, v := range slices.Backward(s) { ... } +# Analyzer slicesclip + +slicesclip: replace three-index slice expressions with slices.Clip + +The slicesclip analyzer suggests replacing a full slice expression of +the form + + x[:len(x):len(x)] + +which clips the capacity of a slice to its length, with the simpler +and more readable + + slices.Clip(x) + +added in Go 1.21. + # Analyzer slicescontains slicescontains: replace loops with slices.Contains or slices.ContainsFunc @@ -422,7 +456,7 @@ or its "for elem := range x.Len()" equivalent by a range loop over an iterator offered by the same data type: for elem := range x.All() { - use(x.At(i) + use(elem) } where x is one of various well-known types in the standard library. diff --git a/vendor/golang.org/x/tools/go/analysis/passes/modernize/embedlit.go b/vendor/golang.org/x/tools/go/analysis/passes/modernize/embedlit.go index d2c71b57..a30276a0 100644 --- a/vendor/golang.org/x/tools/go/analysis/passes/modernize/embedlit.go +++ b/vendor/golang.org/x/tools/go/analysis/passes/modernize/embedlit.go @@ -33,7 +33,7 @@ var EmbedLitAnalyzer = &analysis.Analyzer{ typeindexanalyzer.Analyzer, }, Run: runEmbedLit, - URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#embedlit", + URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_embedlit", } // Go1.27 introduced the ability to directly access embedded struct fields. @@ -209,15 +209,25 @@ func embedlitCombine(pass *analysis.Pass, index *typeindex.Index, info *types.In case edge.AssignStmt_Rhs: assign := curLit.Parent().Node().(*ast.AssignStmt) // TODO(mkalil): Handle lhs forms that aren't idents, i.e. x.y[i] = T{...}. - if id, ok := assign.Lhs[curLit.ParentEdgeIndex()].(*ast.Ident); ok { + // TODO(mkalil): Handle multi-assignments like t1, t2 := A{}, B{} + if len(assign.Lhs) != 1 { + return nil + } + if id, ok := assign.Lhs[0].(*ast.Ident); ok { lhs = id curStmt = curLit.Parent() } case edge.ValueSpec_Values: spec := curLit.Parent().Node().(*ast.ValueSpec) - lhs = spec.Names[curLit.ParentEdgeIndex()] + // TODO(mkalil): Handle multi-declarations like var (x = A{}; y = B{}) or var x, y = ... + if len(spec.Names) != 1 { + return nil + } + lhs = spec.Names[0] if decl, ok := moreiters.First(curLit.Enclosing((*ast.DeclStmt)(nil))); ok { - curStmt = decl + if gdecl, ok := decl.Node().(*ast.DeclStmt).Decl.(*ast.GenDecl); ok && len(gdecl.Specs) == 1 { + curStmt = decl + } } default: return nil @@ -231,7 +241,8 @@ func embedlitCombine(pass *analysis.Pass, index *typeindex.Index, info *types.In tObj = info.ObjectOf(lhs) // Marks the contiguous block of embedded field assign statements that will // be moved into the struct initialization. - firstStmt, lastStmt inspector.Cursor + firstStmt, lastStmt inspector.Cursor + hasEmbeddedSelection bool ) stmtloop: for { @@ -262,6 +273,15 @@ stmtloop: if obj != tObj { break } + // The selection is from an embedded field if it directly + // assigns an embedded struct field (t.B = B{...}) or if + // the length of the index path is greater than one. + seln := info.Selections[sel] + if v, ok := seln.Obj().(*types.Var); ok && v.Embedded() || + len(seln.Index()) > 1 { + hasEmbeddedSelection = true + } + rhsCur := curStmt.ChildAt(edge.AssignStmt_Rhs, 0) if uses(index, rhsCur, tObj) { break @@ -284,7 +304,8 @@ stmtloop: lastStmt = curStmt } - if !firstStmt.Valid() { + if !firstStmt.Valid() || !hasEmbeddedSelection { + // We should not suggest a fix if none of the selections are from embedded fields. return nil } diff --git a/vendor/golang.org/x/tools/go/analysis/passes/modernize/errorsastype.go b/vendor/golang.org/x/tools/go/analysis/passes/modernize/errorsastype.go index 0e3f17fb..8a3f1c10 100644 --- a/vendor/golang.org/x/tools/go/analysis/passes/modernize/errorsastype.go +++ b/vendor/golang.org/x/tools/go/analysis/passes/modernize/errorsastype.go @@ -27,7 +27,7 @@ import ( var ErrorsAsTypeAnalyzer = &analysis.Analyzer{ Name: "errorsastype", Doc: analyzerutil.MustExtractDoc(doc, "errorsastype"), - URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#errorsastype", + URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_errorsastype", Requires: []*analysis.Analyzer{typeindexanalyzer.Analyzer}, Run: errorsastype, } @@ -228,6 +228,9 @@ func canUseErrorsAsType(info *types.Info, index *typeindex.Index, curCall inspec len(curDecl.Node().(*ast.GenDecl).Specs) != 1 { return // not a simple "var v T" decl } + if curDecl.ParentEdgeKind() != edge.DeclStmt_Decl { + return // package-level var, not a local declaration statement + } // AsType requires that its type argument implements error. // Reject if v does not implement error. if !types.AssignableTo(v.Type(), errorType) { @@ -239,5 +242,5 @@ func canUseErrorsAsType(info *types.Info, index *typeindex.Index, curCall inspec // ... // if errors.As(err, &v) { ... } // with no uses of v outside the IfStmt. - return v, curDecl.Parent(), curIfStmt // curDecl.Parent() is a DeclStmt + return v, curDecl.Parent(), curIfStmt } diff --git a/vendor/golang.org/x/tools/go/analysis/passes/modernize/fmtappendf.go b/vendor/golang.org/x/tools/go/analysis/passes/modernize/fmtappendf.go index 82106541..d67b6ad1 100644 --- a/vendor/golang.org/x/tools/go/analysis/passes/modernize/fmtappendf.go +++ b/vendor/golang.org/x/tools/go/analysis/passes/modernize/fmtappendf.go @@ -30,7 +30,7 @@ var FmtAppendfAnalyzer = &analysis.Analyzer{ typeindexanalyzer.Analyzer, }, Run: fmtappendf, - URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#fmtappendf", + URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_fmtappendf", } // The fmtappend function replaces []byte(fmt.Sprintf(...)) by diff --git a/vendor/golang.org/x/tools/go/analysis/passes/modernize/forvar.go b/vendor/golang.org/x/tools/go/analysis/passes/modernize/forvar.go index ba54daeb..d79f1f9f 100644 --- a/vendor/golang.org/x/tools/go/analysis/passes/modernize/forvar.go +++ b/vendor/golang.org/x/tools/go/analysis/passes/modernize/forvar.go @@ -21,7 +21,7 @@ var ForVarAnalyzer = &analysis.Analyzer{ Doc: analyzerutil.MustExtractDoc(doc, "forvar"), Requires: []*analysis.Analyzer{inspect.Analyzer}, Run: forvar, - URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#forvar", + URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_forvar", } // forvar offers to fix unnecessary copying of a for variable diff --git a/vendor/golang.org/x/tools/go/analysis/passes/modernize/importcomment.go b/vendor/golang.org/x/tools/go/analysis/passes/modernize/importcomment.go index 15387835..de0f6879 100644 --- a/vendor/golang.org/x/tools/go/analysis/passes/modernize/importcomment.go +++ b/vendor/golang.org/x/tools/go/analysis/passes/modernize/importcomment.go @@ -14,7 +14,7 @@ import ( var importCommentAnalyzer = &analysis.Analyzer{ Name: "importcomment", Doc: analyzerutil.MustExtractDoc(doc, "importcomment"), - URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#importcomment", + URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_importcomment", Run: importcomment, } diff --git a/vendor/golang.org/x/tools/go/analysis/passes/modernize/maps.go b/vendor/golang.org/x/tools/go/analysis/passes/modernize/maps.go index 7f3fd4e6..38d0f232 100644 --- a/vendor/golang.org/x/tools/go/analysis/passes/modernize/maps.go +++ b/vendor/golang.org/x/tools/go/analysis/passes/modernize/maps.go @@ -28,7 +28,7 @@ var MapsLoopAnalyzer = &analysis.Analyzer{ Doc: analyzerutil.MustExtractDoc(doc, "mapsloop"), Requires: []*analysis.Analyzer{inspect.Analyzer}, Run: mapsloop, - URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#mapsloop", + URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_mapsloop", } // The mapsloop pass offers to simplify a loop of map insertions: diff --git a/vendor/golang.org/x/tools/go/analysis/passes/modernize/minmax.go b/vendor/golang.org/x/tools/go/analysis/passes/modernize/minmax.go index 9fd86575..928fcf58 100644 --- a/vendor/golang.org/x/tools/go/analysis/passes/modernize/minmax.go +++ b/vendor/golang.org/x/tools/go/analysis/passes/modernize/minmax.go @@ -32,7 +32,7 @@ var MinMaxAnalyzer = &analysis.Analyzer{ typeindexanalyzer.Analyzer, }, Run: minmax, - URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#minmax", + URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_minmax", } // The minmax pass replaces if/else statements with calls to min or max, @@ -451,18 +451,3 @@ func checkMinMaxPattern(ifStmt *ast.IfStmt, falseResult ast.Expr, funcName, para // Check if the sign matches the function name return cond(sign < 0, "min", "max") == funcName } - -// -- utils -- - -func is[T any](x any) bool { - _, ok := x.(T) - return ok -} - -func cond[T any](cond bool, t, f T) T { - if cond { - return t - } else { - return f - } -} diff --git a/vendor/golang.org/x/tools/go/analysis/passes/modernize/modernize.go b/vendor/golang.org/x/tools/go/analysis/passes/modernize/modernize.go index 23dd8ab5..9e950d7c 100644 --- a/vendor/golang.org/x/tools/go/analysis/passes/modernize/modernize.go +++ b/vendor/golang.org/x/tools/go/analysis/passes/modernize/modernize.go @@ -45,8 +45,10 @@ var Suite = []*analysis.Analyzer{ OmitZeroAnalyzer, PlusBuildAnalyzer, RangeIntAnalyzer, + reflectTypeAssertAnalyzer, // awaiting public symbol ReflectTypeForAnalyzer, slicesBackwardAnalyzer, // awaiting public symbol + slicesClipAnalyzer, // awaiting public symbol SlicesContainsAnalyzer, SlicesSortAnalyzer, StdIteratorsAnalyzer, @@ -122,7 +124,7 @@ func filesUsingGoVersion(pass *analysis.Pass, version string) iter.Seq[inspector // specified standard packages or their dependencies. func within(pass *analysis.Pass, pkgs ...string) bool { path := pass.Pkg.Path() - return packagepath.IsStdPackage(path) && + return packagepath.MaybeStdPackage(path) && moreiters.Contains(stdlib.Dependencies(pkgs...), path) } @@ -136,6 +138,7 @@ var ( builtinMake = types.Universe.Lookup("make") builtinNew = types.Universe.Lookup("new") builtinNil = types.Universe.Lookup("nil") + builtinRecover = types.Universe.Lookup("recover") builtinString = types.Universe.Lookup("string") builtinTrue = types.Universe.Lookup("true") byteSliceType = types.NewSlice(types.Typ[types.Byte]) @@ -185,3 +188,16 @@ func isLocal(obj types.Object) bool { } return depth >= 4 } + +func is[T any](x any) bool { + _, ok := x.(T) + return ok +} + +func cond[T any](cond bool, t, f T) T { + if cond { + return t + } else { + return f + } +} diff --git a/vendor/golang.org/x/tools/go/analysis/passes/modernize/newexpr.go b/vendor/golang.org/x/tools/go/analysis/passes/modernize/newexpr.go index 15d52d12..168c09fd 100644 --- a/vendor/golang.org/x/tools/go/analysis/passes/modernize/newexpr.go +++ b/vendor/golang.org/x/tools/go/analysis/passes/modernize/newexpr.go @@ -24,7 +24,7 @@ import ( var NewExprAnalyzer = &analysis.Analyzer{ Name: "newexpr", Doc: analyzerutil.MustExtractDoc(doc, "newexpr"), - URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#newexpr", + URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_newexpr", Requires: []*analysis.Analyzer{inspect.Analyzer}, Run: run, FactTypes: []analysis.Fact{&newLike{}}, diff --git a/vendor/golang.org/x/tools/go/analysis/passes/modernize/omitzero.go b/vendor/golang.org/x/tools/go/analysis/passes/modernize/omitzero.go index 59ba9506..4d93f7f4 100644 --- a/vendor/golang.org/x/tools/go/analysis/passes/modernize/omitzero.go +++ b/vendor/golang.org/x/tools/go/analysis/passes/modernize/omitzero.go @@ -24,7 +24,7 @@ var OmitZeroAnalyzer = &analysis.Analyzer{ Doc: analyzerutil.MustExtractDoc(doc, "omitzero"), Requires: []*analysis.Analyzer{inspect.Analyzer}, Run: omitzero, - URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#omitzero", + URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_omitzero", } // The omitzero pass searches for instances of "omitempty" in a json field tag on a diff --git a/vendor/golang.org/x/tools/go/analysis/passes/modernize/plusbuild.go b/vendor/golang.org/x/tools/go/analysis/passes/modernize/plusbuild.go index 574ce0a8..09877f89 100644 --- a/vendor/golang.org/x/tools/go/analysis/passes/modernize/plusbuild.go +++ b/vendor/golang.org/x/tools/go/analysis/passes/modernize/plusbuild.go @@ -17,7 +17,7 @@ import ( var PlusBuildAnalyzer = &analysis.Analyzer{ Name: "plusbuild", Doc: analyzerutil.MustExtractDoc(doc, "plusbuild"), - URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#plusbuild", + URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_plusbuild", Run: plusbuild, } diff --git a/vendor/golang.org/x/tools/go/analysis/passes/modernize/rangeint.go b/vendor/golang.org/x/tools/go/analysis/passes/modernize/rangeint.go index f7cb965f..9cd76633 100644 --- a/vendor/golang.org/x/tools/go/analysis/passes/modernize/rangeint.go +++ b/vendor/golang.org/x/tools/go/analysis/passes/modernize/rangeint.go @@ -13,8 +13,6 @@ import ( "golang.org/x/tools/go/analysis" "golang.org/x/tools/go/analysis/passes/inspect" - "golang.org/x/tools/go/ast/edge" - "golang.org/x/tools/go/ast/inspector" "golang.org/x/tools/go/types/typeutil" "golang.org/x/tools/internal/analysis/analyzerutil" typeindexanalyzer "golang.org/x/tools/internal/analysis/typeindex" @@ -33,7 +31,7 @@ var RangeIntAnalyzer = &analysis.Analyzer{ typeindexanalyzer.Analyzer, }, Run: rangeint, - URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#rangeint", + URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_rangeint", } // rangeint offers a fix to replace a 3-clause 'for' loop: @@ -112,7 +110,7 @@ func rangeint(pass *analysis.Pass) (any, error) { // limit is a local or unexported global var. // (An exported global may have uses we can't see.) for cur := range typeindex.Uses(v) { - if isScalarLvalue(info, cur) { + if typesinternal.IsAssignedOrAddressTaken(info, cur) { // Limit var is assigned or address-taken. continue nextLoop } @@ -161,7 +159,7 @@ func rangeint(pass *analysis.Pass) (any, error) { // Reject if any is an l-value (assigned or address-taken): // a "for range int" loop does not respect assignments to // the loop variable. - if isScalarLvalue(info, curId) { + if typesinternal.IsAssignedOrAddressTaken(info, curId) { continue nextLoop } } @@ -345,40 +343,3 @@ func rangeint(pass *analysis.Pass) (any, error) { } return nil, nil } - -// isScalarLvalue reports whether the specified identifier is -// address-taken or appears on the left side of an assignment. -// -// This function is valid only for scalars (x = ...), -// not for aggregates (x.a[i] = ...) -func isScalarLvalue(info *types.Info, curId inspector.Cursor) bool { - // Unfortunately we can't simply use info.Types[e].Assignable() - // as it is always true for a variable even when that variable is - // used only as an r-value. So we must inspect enclosing syntax. - - cur := astutil.UnparenEnclosingCursor(curId) - - switch cur.ParentEdgeKind() { - case edge.AssignStmt_Lhs: - assign := cur.Parent().Node().(*ast.AssignStmt) - if assign.Tok != token.DEFINE { - return true // i = j or i += j - } - id := curId.Node().(*ast.Ident) - if v, ok := info.Defs[id]; ok && v.Pos() != id.Pos() { - return true // reassignment of i (i, j := 1, 2) - } - case edge.RangeStmt_Key: - rng := cur.Parent().Node().(*ast.RangeStmt) - if rng.Tok == token.ASSIGN { - return true // "for k, v = range x" is like an AssignStmt to k, v - } - case edge.IncDecStmt_X: - return true // i++, i-- - case edge.UnaryExpr_X: - if cur.Parent().Node().(*ast.UnaryExpr).Op == token.AND { - return true // &i - } - } - return false -} diff --git a/vendor/golang.org/x/tools/go/analysis/passes/modernize/reflect.go b/vendor/golang.org/x/tools/go/analysis/passes/modernize/reflect.go index 10fbdf8b..14446a13 100644 --- a/vendor/golang.org/x/tools/go/analysis/passes/modernize/reflect.go +++ b/vendor/golang.org/x/tools/go/analysis/passes/modernize/reflect.go @@ -30,7 +30,7 @@ var ReflectTypeForAnalyzer = &analysis.Analyzer{ typeindexanalyzer.Analyzer, }, Run: reflecttypefor, - URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#reflecttypefor", + URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_reflecttypefor", } func reflecttypefor(pass *analysis.Pass) (any, error) { diff --git a/vendor/golang.org/x/tools/go/analysis/passes/modernize/reflecttypeassert.go b/vendor/golang.org/x/tools/go/analysis/passes/modernize/reflecttypeassert.go new file mode 100644 index 00000000..ff41e43a --- /dev/null +++ b/vendor/golang.org/x/tools/go/analysis/passes/modernize/reflecttypeassert.go @@ -0,0 +1,118 @@ +// Copyright 2026 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package modernize + +import ( + "go/ast" + "go/token" + + "golang.org/x/tools/go/analysis" + "golang.org/x/tools/go/analysis/passes/inspect" + "golang.org/x/tools/go/ast/edge" + "golang.org/x/tools/internal/analysis/analyzerutil" + typeindexanalyzer "golang.org/x/tools/internal/analysis/typeindex" + "golang.org/x/tools/internal/astutil" + "golang.org/x/tools/internal/refactor" + "golang.org/x/tools/internal/typesinternal" + "golang.org/x/tools/internal/typesinternal/typeindex" + "golang.org/x/tools/internal/versions" +) + +var reflectTypeAssertAnalyzer = &analysis.Analyzer{ + Name: "reflecttypeassert", + Doc: analyzerutil.MustExtractDoc(doc, "reflecttypeassert"), + Requires: []*analysis.Analyzer{ + inspect.Analyzer, + typeindexanalyzer.Analyzer, + }, + Run: reflecttypeassert, + URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_reflecttypeassert", +} + +func reflecttypeassert(pass *analysis.Pass) (any, error) { + var ( + index = pass.ResultOf[typeindexanalyzer.Analyzer].(*typeindex.Index) + info = pass.TypesInfo + + valueInterface = index.Selection("reflect", "Value", "Interface") + ) + + for curCall := range index.Calls(valueInterface) { + call := curCall.Node().(*ast.CallExpr) + // Have: v.Interface() + + sel, ok := call.Fun.(*ast.SelectorExpr) + if !ok { + continue // method expression reflect.Value.Interface(v) + } + + // TypeAssert's argument must be a reflect.Value; a pointer + // receiver would need an explicit dereference in the rewrite. + if !typesinternal.IsTypeNamed(info.TypeOf(sel.X), "reflect", "Value") { + continue + } + + // The call must be the operand of a type assertion + // (not a type switch, whose Type field is nil). + curOperand := astutil.UnparenEnclosingCursor(curCall) + if curOperand.ParentEdgeKind() != edge.TypeAssertExpr_X { + continue + } + curAssert := curOperand.Parent() + assert := curAssert.Node().(*ast.TypeAssertExpr) + if assert.Type == nil { + continue // type switch + } + + // The assertion must be the sole RHS of a two-valued + // assignment, x, ok := v.Interface().(T), so that the + // rewrite preserves the "commaOK" semantics; a single-valued + // assertion panics on failure whereas TypeAssert does not. + curRhs := astutil.UnparenEnclosingCursor(curAssert) + if curRhs.ParentEdgeKind() != edge.AssignStmt_Rhs { + continue + } + assign := curRhs.Parent().Node().(*ast.AssignStmt) + if len(assign.Lhs) != 2 || len(assign.Rhs) != 1 || + (assign.Tok != token.ASSIGN && assign.Tok != token.DEFINE) { + continue + } + + file := astutil.EnclosingFile(curCall) + if !analyzerutil.FileUsesGoVersion(pass, file, versions.Go1_25) { + continue // TypeAssert requires go1.25 + } + + prefix, importEdits := refactor.AddImport(info, file, "reflect", "reflect", "TypeAssert", assert.Pos()) + + tstr := astutil.Format(pass.Fset, assert.Type) + pass.Report(analysis.Diagnostic{ + Pos: assert.Pos(), + End: assert.End(), + Message: "Interface().(" + tstr + ") can be simplified using reflect.TypeAssert", + SuggestedFixes: []analysis.SuggestedFix{{ + // v.Interface().(T) -> reflect.TypeAssert[T](v) + Message: "Replace Interface().(" + tstr + ") by reflect.TypeAssert[" + tstr + "]", + // Edit around sel.X instead of reformatting it, so its + // comments and spacing are preserved; only the type, + // which must move, is reformatted. + TextEdits: append(importEdits, + analysis.TextEdit{ + Pos: assert.Pos(), + End: sel.X.Pos(), + NewText: []byte(prefix + "TypeAssert[" + tstr + "]("), + }, + analysis.TextEdit{ + Pos: sel.X.End(), + End: assert.End(), + NewText: []byte(")"), + }, + ), + }}, + }) + } + + return nil, nil +} diff --git a/vendor/golang.org/x/tools/go/analysis/passes/modernize/slices.go b/vendor/golang.org/x/tools/go/analysis/passes/modernize/slices.go index 6c8ea22b..4fb40a89 100644 --- a/vendor/golang.org/x/tools/go/analysis/passes/modernize/slices.go +++ b/vendor/golang.org/x/tools/go/analysis/passes/modernize/slices.go @@ -27,7 +27,7 @@ var AppendClippedAnalyzer = &analysis.Analyzer{ Doc: analyzerutil.MustExtractDoc(doc, "appendclipped"), Requires: []*analysis.Analyzer{inspect.Analyzer}, Run: appendclipped, - URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#appendclipped", + URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_appendclipped", } // The appendclipped pass offers to simplify a tower of append calls: diff --git a/vendor/golang.org/x/tools/go/analysis/passes/modernize/slicesbackward.go b/vendor/golang.org/x/tools/go/analysis/passes/modernize/slicesbackward.go index 02cd30a2..c65a6c7e 100644 --- a/vendor/golang.org/x/tools/go/analysis/passes/modernize/slicesbackward.go +++ b/vendor/golang.org/x/tools/go/analysis/passes/modernize/slicesbackward.go @@ -19,6 +19,7 @@ import ( typeindexanalyzer "golang.org/x/tools/internal/analysis/typeindex" "golang.org/x/tools/internal/astutil" "golang.org/x/tools/internal/refactor" + "golang.org/x/tools/internal/typesinternal" "golang.org/x/tools/internal/typesinternal/typeindex" "golang.org/x/tools/internal/versions" ) @@ -32,7 +33,7 @@ var slicesBackwardAnalyzer = &analysis.Analyzer{ typeindexanalyzer.Analyzer, }, Run: slicesbackward, - URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#slicesbackward", + URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_slicesbackward", } // slicesbackward offers a fix to replace a manually-written backward loop: @@ -128,7 +129,7 @@ func slicesbackward(pass *analysis.Pass) (any, error) { // (e.g. &i before the loop). bodyCur := curLoop.Child(loop.Body) for curUse := range index.Uses(indexObj) { - if !isScalarLvalue(info, curUse) { + if !typesinternal.IsAssignedOrAddressTaken(info, curUse) { continue } if bodyCur.Contains(curUse) { @@ -160,20 +161,25 @@ func slicesbackward(pass *analysis.Pass) (any, error) { // If so, we also need to check whether s[i] is an lvalue. If we're // mutating the slice or taking an element's address, a fix will not // be offered. + // Modernization to "for _, v := range slices.Backward(s)" is unsafe if + // s[i] is mutated or address-taken (since v would be a local copy of + // the element so s[i] wouldn't get mutated). + // We don't need to worry about indirect selections (e.g. s[i].n++ where + // s is []*item) or indirect references like indexing a slice of slices. if curUse.ParentEdgeKind() == edge.IndexExpr_Index { - if isScalarLvalue(pass.TypesInfo, curUse.Parent()) { + curIdx := curUse.Parent() + if typesinternal.IsAssignedOrAddressTaken(info, curIdx) { continue nextLoop } - idxCur := curUse.Parent() - idxExpr := idxCur.Node().(*ast.IndexExpr) + idxExpr := curIdx.Node().(*ast.IndexExpr) if astutil.EqualSyntax(idxExpr.X, sliceExpr) { sliceIdxs++ // If the current statement is the first in the body of the form // "name := s[i]", save it so we can use "name" as the value // variable in slices.Backward. We can also remove the entire assign // statement. - if firstSliceIdxAssign == nil && idxCur.ParentEdgeKind() == edge.AssignStmt_Rhs { - assignStmt := idxCur.Parent().Node().(*ast.AssignStmt) + if firstSliceIdxAssign == nil && curIdx.ParentEdgeKind() == edge.AssignStmt_Rhs { + assignStmt := curIdx.Parent().Node().(*ast.AssignStmt) if len(assignStmt.Lhs) == 1 && assignStmt.Tok == token.DEFINE { // The condition above implies that assignStmt.Lhs[0] is a valid // identifier. diff --git a/vendor/golang.org/x/tools/go/analysis/passes/modernize/slicesclip.go b/vendor/golang.org/x/tools/go/analysis/passes/modernize/slicesclip.go new file mode 100644 index 00000000..b08cbc69 --- /dev/null +++ b/vendor/golang.org/x/tools/go/analysis/passes/modernize/slicesclip.go @@ -0,0 +1,81 @@ +// Copyright 2026 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package modernize + +import ( + "fmt" + "go/ast" + "go/types" + + "golang.org/x/tools/go/analysis" + "golang.org/x/tools/go/analysis/passes/inspect" + "golang.org/x/tools/go/types/typeutil" + "golang.org/x/tools/internal/analysis/analyzerutil" + "golang.org/x/tools/internal/astutil" + "golang.org/x/tools/internal/refactor" + "golang.org/x/tools/internal/typesinternal" + "golang.org/x/tools/internal/versions" +) + +var slicesClipAnalyzer = &analysis.Analyzer{ + Name: "slicesclip", + Doc: analyzerutil.MustExtractDoc(doc, "slicesclip"), + Requires: []*analysis.Analyzer{ + inspect.Analyzer, + }, + Run: slicesclip, + URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_slicesclip", +} + +func slicesclip(pass *analysis.Pass) (any, error) { + if within(pass, "slices", "runtime") { + return nil, nil + } + info := pass.TypesInfo + + // isLenX reports whether e is a call len(x) where x is + // syntactically identical to the operand x of the slice expr. + isLenX := func(e, x ast.Expr) bool { + call, ok := e.(*ast.CallExpr) + if !ok || len(call.Args) != 1 { + return false + } + return typeutil.Callee(info, call) == builtinLen && + astutil.EqualSyntax(call.Args[0], x) + } + + for curFile := range filesUsingGoVersion(pass, versions.Go1_21) { + file := curFile.Node().(*ast.File) + + for curSlice := range curFile.Preorder((*ast.SliceExpr)(nil)) { + slice := curSlice.Node().(*ast.SliceExpr) + _, ok := info.TypeOf(slice.X).Underlying().(*types.Slice) // in case x is an array/pointer to array + if !slice.Slice3 || slice.Low != nil || !ok { + continue + } + + if isLenX(slice.High, slice.X) && isLenX(slice.Max, slice.X) && typesinternal.NoEffects(info, slice.X) { + // Have x[:len(x):len(x)] -> slices.Clip(x) + prefix, edits := refactor.AddImport(info, file, "slices", "slices", "Clip", slice.Pos()) + sx := astutil.Format(pass.Fset, slice.X) + pass.Report(analysis.Diagnostic{ + Pos: slice.Pos(), + End: slice.End(), + Message: "x[:len(x):len(x)] can be simplified using slices.Clip", + SuggestedFixes: []analysis.SuggestedFix{{ + Message: fmt.Sprintf("Replace with slices.Clip(%s)", sx), + TextEdits: append(edits, analysis.TextEdit{ + Pos: slice.Pos(), + End: slice.End(), + NewText: fmt.Appendf(nil, "%sClip(%s)", prefix, sx), + }), + }}, + }) + } + } + } + + return nil, nil +} diff --git a/vendor/golang.org/x/tools/go/analysis/passes/modernize/slicescontains.go b/vendor/golang.org/x/tools/go/analysis/passes/modernize/slicescontains.go index ed75e05e..b27be6fc 100644 --- a/vendor/golang.org/x/tools/go/analysis/passes/modernize/slicescontains.go +++ b/vendor/golang.org/x/tools/go/analysis/passes/modernize/slicescontains.go @@ -32,7 +32,7 @@ var SlicesContainsAnalyzer = &analysis.Analyzer{ typeindexanalyzer.Analyzer, }, Run: slicescontains, - URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#slicescontains", + URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_slicescontains", } // The slicescontains pass identifies loops that can be replaced by a diff --git a/vendor/golang.org/x/tools/go/analysis/passes/modernize/slicesdelete.go b/vendor/golang.org/x/tools/go/analysis/passes/modernize/slicesdelete.go index 7b3aa875..c623aede 100644 --- a/vendor/golang.org/x/tools/go/analysis/passes/modernize/slicesdelete.go +++ b/vendor/golang.org/x/tools/go/analysis/passes/modernize/slicesdelete.go @@ -25,7 +25,7 @@ var SlicesDeleteAnalyzer = &analysis.Analyzer{ Doc: analyzerutil.MustExtractDoc(doc, "slicesdelete"), Requires: []*analysis.Analyzer{inspect.Analyzer}, Run: slicesdelete, - URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#slicesdelete", + URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_slicesdelete", } // The slicesdelete pass attempts to replace instances of append(s[:i], s[i+k:]...) diff --git a/vendor/golang.org/x/tools/go/analysis/passes/modernize/sortslice.go b/vendor/golang.org/x/tools/go/analysis/passes/modernize/sortslice.go index e22b8c55..08d86676 100644 --- a/vendor/golang.org/x/tools/go/analysis/passes/modernize/sortslice.go +++ b/vendor/golang.org/x/tools/go/analysis/passes/modernize/sortslice.go @@ -28,7 +28,7 @@ var SlicesSortAnalyzer = &analysis.Analyzer{ typeindexanalyzer.Analyzer, }, Run: slicessort, - URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#slicessort", + URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_slicessort", } // The slicessort pass replaces sort.Slice(slice, less) with diff --git a/vendor/golang.org/x/tools/go/analysis/passes/modernize/stditerators.go b/vendor/golang.org/x/tools/go/analysis/passes/modernize/stditerators.go index 19532686..25208863 100644 --- a/vendor/golang.org/x/tools/go/analysis/passes/modernize/stditerators.go +++ b/vendor/golang.org/x/tools/go/analysis/passes/modernize/stditerators.go @@ -28,7 +28,7 @@ var StdIteratorsAnalyzer = &analysis.Analyzer{ typeindexanalyzer.Analyzer, }, Run: stditerators, - URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#stditerators", + URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_stditerators", } // stditeratorsTable records std types that have legacy T.{Len,At} diff --git a/vendor/golang.org/x/tools/go/analysis/passes/modernize/stringsbuilder.go b/vendor/golang.org/x/tools/go/analysis/passes/modernize/stringsbuilder.go index 6aa9c881..ca1cc149 100644 --- a/vendor/golang.org/x/tools/go/analysis/passes/modernize/stringsbuilder.go +++ b/vendor/golang.org/x/tools/go/analysis/passes/modernize/stringsbuilder.go @@ -34,7 +34,7 @@ var StringsBuilderAnalyzer = &analysis.Analyzer{ typeindexanalyzer.Analyzer, }, Run: stringsbuilder, - URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#stringbuilder", + URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_stringsbuilder", } // stringsbuilder replaces string += string in a loop by strings.Builder. diff --git a/vendor/golang.org/x/tools/go/analysis/passes/modernize/stringscut.go b/vendor/golang.org/x/tools/go/analysis/passes/modernize/stringscut.go index ae93d4d3..daa6a678 100644 --- a/vendor/golang.org/x/tools/go/analysis/passes/modernize/stringscut.go +++ b/vendor/golang.org/x/tools/go/analysis/passes/modernize/stringscut.go @@ -35,7 +35,7 @@ var StringsCutAnalyzer = &analysis.Analyzer{ typeindexanalyzer.Analyzer, }, Run: stringscut, - URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#stringscut", + URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_stringscut", } // stringscut offers a fix to replace an occurrence of strings.Index{,Byte} with @@ -513,9 +513,12 @@ func indexArgValid(info *types.Info, index *typeindex.Index, expr ast.Expr, afte info.Types[expr.Fun].IsType() && // make sure this isn't a function that returns a byte slice indexArgValid(info, index, expr.Args[0], afterPos) // check s in []byte(s) case *ast.Ident: - sObj := info.Uses[expr] - sUses := index.Uses(sObj) - return !hasModifyingUses(sUses, afterPos) + for use := range index.Uses(info.Uses[expr]) { + if typesinternal.IsAssignedOrAddressTaken(info, use) { + return false + } + } + return true default: // For now, skip instances where s or substr are not // identifiers, basic lits, or call expressions of the form @@ -612,30 +615,6 @@ func checkIdxUses(info *types.Info, uses iter.Seq[inspector.Cursor], s, substr a return negative, nonnegative, beforeSlice, afterSlice } -// hasModifyingUses reports whether any of the uses involve potential -// modifications. Uses involving assignments before the "afterPos" won't be -// considered. -func hasModifyingUses(uses iter.Seq[inspector.Cursor], afterPos token.Pos) bool { - for curUse := range uses { - ek := curUse.ParentEdgeKind() - if ek == edge.AssignStmt_Lhs { - if curUse.Node().Pos() <= afterPos { - continue - } - // Any use on the LHS is a modifying use. - return true - } else if ek == edge.UnaryExpr_X && - curUse.Parent().Node().(*ast.UnaryExpr).Op == token.AND { - // Modifying use because we might be passing the object by reference (an explicit &). - // We can ignore the case where we have a method call on the expression (which - // has an implicit &) because we know the type of s and substr are strings - // which cannot have methods on them. - return true - } - } - return false -} - // checkIdxComparison reports whether the check is equivalent to i < 0 or its negation, or neither. // For equivalent to i >= 0, we only accept this exact BinaryExpr since // expressions like i > 0 or i >= 1 make a stronger statement about the value of i. diff --git a/vendor/golang.org/x/tools/go/analysis/passes/modernize/stringscutprefix.go b/vendor/golang.org/x/tools/go/analysis/passes/modernize/stringscutprefix.go index 11d33590..6e285456 100644 --- a/vendor/golang.org/x/tools/go/analysis/passes/modernize/stringscutprefix.go +++ b/vendor/golang.org/x/tools/go/analysis/passes/modernize/stringscutprefix.go @@ -31,7 +31,7 @@ var StringsCutPrefixAnalyzer = &analysis.Analyzer{ typeindexanalyzer.Analyzer, }, Run: stringscutprefix, - URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#stringscutprefix", + URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_stringscutprefix", } // stringscutprefix offers a fix to replace an if statement which diff --git a/vendor/golang.org/x/tools/go/analysis/passes/modernize/stringsseq.go b/vendor/golang.org/x/tools/go/analysis/passes/modernize/stringsseq.go index d02a5323..064444dc 100644 --- a/vendor/golang.org/x/tools/go/analysis/passes/modernize/stringsseq.go +++ b/vendor/golang.org/x/tools/go/analysis/passes/modernize/stringsseq.go @@ -28,7 +28,7 @@ var StringsSeqAnalyzer = &analysis.Analyzer{ typeindexanalyzer.Analyzer, }, Run: stringsseq, - URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#stringsseq", + URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_stringsseq", } // stringsseq offers a fix to replace a call to strings.Split with @@ -117,6 +117,8 @@ func stringsseq(pass *analysis.Pass) (any, error) { } switch obj := typeutil.Callee(info, call); obj { + case nil: + // a conversion, not a call case stringsSplit, stringsFields, bytesSplit, bytesFields: oldFnName := obj.Name() seqFnName := fmt.Sprintf("%sSeq", oldFnName) diff --git a/vendor/golang.org/x/tools/go/analysis/passes/modernize/testingcontext.go b/vendor/golang.org/x/tools/go/analysis/passes/modernize/testingcontext.go index 93933052..da723647 100644 --- a/vendor/golang.org/x/tools/go/analysis/passes/modernize/testingcontext.go +++ b/vendor/golang.org/x/tools/go/analysis/passes/modernize/testingcontext.go @@ -33,7 +33,7 @@ var TestingContextAnalyzer = &analysis.Analyzer{ typeindexanalyzer.Analyzer, }, Run: testingContext, - URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#testingcontext", + URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_testingcontext", } // The testingContext pass replaces calls to context.WithCancel from within diff --git a/vendor/golang.org/x/tools/go/analysis/passes/modernize/unsafefuncs.go b/vendor/golang.org/x/tools/go/analysis/passes/modernize/unsafefuncs.go index 34c135ca..08198c9b 100644 --- a/vendor/golang.org/x/tools/go/analysis/passes/modernize/unsafefuncs.go +++ b/vendor/golang.org/x/tools/go/analysis/passes/modernize/unsafefuncs.go @@ -34,7 +34,7 @@ var unsafeFuncsAnalyzer = &analysis.Analyzer{ Doc: analyzerutil.MustExtractDoc(doc, "unsafefuncs"), Requires: []*analysis.Analyzer{inspect.Analyzer}, Run: unsafefuncs, - URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#unsafefuncs", + URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_unsafefuncs", } func unsafefuncs(pass *analysis.Pass) (any, error) { diff --git a/vendor/golang.org/x/tools/go/analysis/passes/modernize/waitgroupgo.go b/vendor/golang.org/x/tools/go/analysis/passes/modernize/waitgroupgo.go index 9af2d3bd..4bc88d0f 100644 --- a/vendor/golang.org/x/tools/go/analysis/passes/modernize/waitgroupgo.go +++ b/vendor/golang.org/x/tools/go/analysis/passes/modernize/waitgroupgo.go @@ -9,6 +9,7 @@ import ( "fmt" "go/ast" "go/printer" + "go/types" "slices" "golang.org/x/tools/go/analysis" @@ -30,7 +31,7 @@ var WaitGroupGoAnalyzer = &analysis.Analyzer{ typeindexanalyzer.Analyzer, }, Run: waitgroup, - URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#waitgroupgo", + URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_waitgroupgo", } // The waitgroupgo pass replaces old more complex code with @@ -112,7 +113,7 @@ func waitgroup(pass *analysis.Pass) (any, error) { astutil.EqualSyntax(ast.Unparen(deferStmt.Call.Fun).(*ast.SelectorExpr).X, addCallRecv) { doneStmt = deferStmt // "defer wg.Done()" - } else if lastStmt, ok := list[len(list)-1].(*ast.ExprStmt); ok { + } else if lastStmt, ok := list[len(list)-1].(*ast.ExprStmt); ok && cannotRecover(lit.Body, info) { if doneCall, ok := lastStmt.X.(*ast.CallExpr); ok && typeutil.Callee(info, doneCall) == syncWaitGroupDone && astutil.EqualSyntax(ast.Unparen(doneCall.Fun).(*ast.SelectorExpr).X, addCallRecv) { @@ -175,3 +176,44 @@ func waitgroup(pass *analysis.Pass) (any, error) { } return nil, nil } + +// cannotRecover reports whether no panic arising in body can be +// recovered. It conservatively treats a defer of anything but a +// recover-free function literal (e.g. a named function) as able to recover. +func cannotRecover(body *ast.BlockStmt, info *types.Info) bool { + res := true + ast.Inspect(body, func(n ast.Node) bool { + switch n := n.(type) { + case *ast.DeferStmt: + lit, ok := ast.Unparen(n.Call.Fun).(*ast.FuncLit) + if !ok || containsRecover(lit.Body, info) { + res = false + } + // Each defer is fully handled here; don't descend into it. + return false + case *ast.FuncLit: + // Defers in nested functions cannot recover panics from this body. + return false + } + return true + }) + return res +} + +func containsRecover(body *ast.BlockStmt, info *types.Info) bool { + found := false + ast.Inspect(body, func(n ast.Node) bool { + switch n := n.(type) { + case *ast.CallExpr: + if typeutil.Callee(info, n) == builtinRecover { + found = true + return false + } + case *ast.FuncLit: + // Recover calls in nested functions cannot recover panics from body. + return false + } + return true + }) + return found +} diff --git a/vendor/golang.org/x/tools/go/analysis/passes/printf/printf.go b/vendor/golang.org/x/tools/go/analysis/passes/printf/printf.go index f82d2eae..6573c3fc 100644 --- a/vendor/golang.org/x/tools/go/analysis/passes/printf/printf.go +++ b/vendor/golang.org/x/tools/go/analysis/passes/printf/printf.go @@ -1184,15 +1184,6 @@ func checkPrint(pass *analysis.Pass, call *ast.CallExpr, name string) { } } } - if strings.HasSuffix(name, "ln") { - // The last item, if a string, should not have a newline. - arg = args[len(args)-1] - if s, ok := stringConstantExpr(pass, arg); ok { - if strings.HasSuffix(s, "\n") { - pass.ReportRangef(call, "%s arg list ends with redundant newline", name) - } - } - } for _, arg := range args { if isFunctionValue(pass, arg) { pass.ReportRangef(call, "%s arg %s is a func value, not called", name, astutil.Format(pass.Fset, arg)) diff --git a/vendor/golang.org/x/tools/go/analysis/passes/stdversion/stdversion.go b/vendor/golang.org/x/tools/go/analysis/passes/stdversion/stdversion.go index d1fda880..3d44c4e8 100644 --- a/vendor/golang.org/x/tools/go/analysis/passes/stdversion/stdversion.go +++ b/vendor/golang.org/x/tools/go/analysis/passes/stdversion/stdversion.go @@ -15,6 +15,7 @@ import ( "golang.org/x/tools/go/analysis" "golang.org/x/tools/go/analysis/passes/inspect" "golang.org/x/tools/go/ast/inspector" + "golang.org/x/tools/internal/stdlib" "golang.org/x/tools/internal/typesinternal" "golang.org/x/tools/internal/versions" ) @@ -64,8 +65,8 @@ func run(pass *analysis.Pass) (any, error) { pkg *types.Package version string } - memo := make(map[key]map[types.Object]string) // records symbol's minimum Go version - disallowedSymbols := func(pkg *types.Package, version string) map[types.Object]string { + memo := make(map[key]map[types.Object]stdlib.Symbol) + disallowedSymbols := func(pkg *types.Package, version string) map[types.Object]stdlib.Symbol { k := key{pkg, version} disallowed, ok := memo[k] if !ok { @@ -98,20 +99,12 @@ func run(pass *analysis.Pass) (any, error) { if fileVersion != "" { if obj, ok := pass.TypesInfo.Uses[n]; ok && obj.Pkg() != nil { disallowed := disallowedSymbols(obj.Pkg(), fileVersion) - if minVersion, ok := disallowed[origin(obj)]; ok { - // Some symbols are accessible before their release but - // only with specific build tags unknown to us here. - // Avoid false positives in such cases. - // TODO(mkalil): move this check into typesinternal.TooNewStdSymbols. - if obj.Pkg().Path() == "testing/synctest" && versions.AtLeast(fileVersion, "go1.24") { - break // requires go1.24 && goexperiment.synctest || go1.25 - } - noun := "module" - if fileVersion != pkgVersion { - noun = "file" - } + if sym, ok := disallowed[origin(obj)]; ok { pass.ReportRangef(n, "%s.%s requires %v or later (%s is %s)", - obj.Pkg().Name(), obj.Name(), minVersion, noun, fileVersion) + obj.Pkg().Name(), sym.Name, + sym.Version, + cond(fileVersion != pkgVersion, "file", "module"), + fileVersion) } } } @@ -134,3 +127,11 @@ func origin(obj types.Object) types.Object { } return obj } + +func cond[T any](cond bool, t, f T) T { + if cond { + return t + } else { + return f + } +} diff --git a/vendor/golang.org/x/tools/go/analysis/passes/unusedresult/unusedresult.go b/vendor/golang.org/x/tools/go/analysis/passes/unusedresult/unusedresult.go index bd32d586..82968f46 100644 --- a/vendor/golang.org/x/tools/go/analysis/passes/unusedresult/unusedresult.go +++ b/vendor/golang.org/x/tools/go/analysis/passes/unusedresult/unusedresult.go @@ -16,7 +16,6 @@ package unusedresult import ( _ "embed" "go/ast" - "go/token" "go/types" "sort" "strings" @@ -27,6 +26,7 @@ import ( "golang.org/x/tools/go/types/typeutil" "golang.org/x/tools/internal/analysis/analyzerutil" "golang.org/x/tools/internal/astutil" + "golang.org/x/tools/internal/typesinternal" ) //go:embed doc.go @@ -172,7 +172,7 @@ func run(pass *analysis.Pass) (any, error) { } // func() string -var sigNoArgsStringResult = types.NewSignatureType(nil, nil, nil, nil, types.NewTuple(types.NewParam(token.NoPos, nil, "", types.Typ[types.String])), false) +var sigNoArgsStringResult = types.NewSignatureType(nil, nil, nil, nil, typesinternal.TupleOf(types.Typ[types.String]), false) type stringSetFlag map[string]bool diff --git a/vendor/golang.org/x/tools/go/ast/inspector/cursor.go b/vendor/golang.org/x/tools/go/ast/inspector/cursor.go index 239b10c4..1c482252 100644 --- a/vendor/golang.org/x/tools/go/ast/inspector/cursor.go +++ b/vendor/golang.org/x/tools/go/ast/inspector/cursor.go @@ -10,6 +10,7 @@ import ( "go/token" "iter" "reflect" + "strings" "golang.org/x/tools/go/ast/edge" ) @@ -110,6 +111,46 @@ func (c Cursor) String() string { return reflect.TypeOf(c.Node()).String() } +// GoString returns a string describing the cursor's path from the +// root, if any. +func (c Cursor) GoString() string { + if !c.Valid() { + return "(invalid)" + } + if c.index < 0 { + return "(root)" + } + // e.g "File.Decls[1].(*ast.GenDecl).Specs[0].(*ast.TypeSpec)" + // + // In hindsight even the File node should have reported a + // virtual ParentEdge of (Root_Files, i) where i is the index + // among the files passed to NewInspector. Then the path would + // read "(root).Files[i]", etc; but we missed the boat. + var buf strings.Builder + buf.WriteString("File") + var visit func(Cursor) + visit = func(c Cursor) { + ek, idx := c.ParentEdge() + if ek == edge.Invalid { + return // File + } + visit(c.Parent()) + fmt.Fprintf(&buf, ".%s", ek.FieldName()) + if idx >= 0 { + fmt.Fprintf(&buf, "[%d]", idx) + } + ftype := ek.FieldType() + if idx >= 0 { + ftype = ftype.Elem() // []T -> T + } + if ftype.Kind() == reflect.Interface { + fmt.Fprintf(&buf, ".(%T)", c.Node()) + } + } + visit(c) + return buf.String() +} + // indices return the [start, end) half-open interval of event indices. func (c Cursor) indices() (int32, int32) { if c.index < 0 { diff --git a/vendor/golang.org/x/tools/go/loader/loader.go b/vendor/golang.org/x/tools/go/loader/loader.go index 9c5f7db1..3c9d4fe7 100644 --- a/vendor/golang.org/x/tools/go/loader/loader.go +++ b/vendor/golang.org/x/tools/go/loader/loader.go @@ -738,7 +738,9 @@ func (conf *Config) parsePackageFiles(bp *build.Package, which rune) ([]*ast.Fil // Preprocess CgoFiles and parse the outputs (sequentially). if which == 'g' && bp.CgoFiles != nil { + ioLimit <- true cgofiles, err := cgo.ProcessFiles(bp, conf.fset(), conf.DisplayPath, conf.ParserMode) + <-ioLimit if err != nil { errs = append(errs, err) } else { diff --git a/vendor/golang.org/x/tools/go/packages/visit.go b/vendor/golang.org/x/tools/go/packages/visit.go index c546b1b6..06747a9d 100644 --- a/vendor/golang.org/x/tools/go/packages/visit.go +++ b/vendor/golang.org/x/tools/go/packages/visit.go @@ -5,11 +5,11 @@ package packages import ( - "cmp" "fmt" "iter" "os" - "slices" + + "golang.org/x/tools/internal/moremaps" ) // Visit visits all the packages in the import graph whose roots are @@ -40,7 +40,7 @@ func Visit(pkgs []*Package, pre func(*Package) bool, post func(*Package)) { seen[pkg] = true if pre == nil || pre(pkg) { - for _, imp := range sorted(pkg.Imports) { // for determinism + for _, imp := range moremaps.Sorted(pkg.Imports) { // for determinism visit(imp) } } @@ -88,7 +88,7 @@ func Postorder(pkgs []*Package) iter.Seq[*Package] { visit = func(pkg *Package) bool { if !seen[pkg] { seen[pkg] = true - for _, imp := range sorted(pkg.Imports) { // for determinism + for _, imp := range moremaps.Sorted(pkg.Imports) { // for determinism if !visit(imp) { return false } @@ -106,28 +106,3 @@ func Postorder(pkgs []*Package) iter.Seq[*Package] { } } } - -// -- copied from golang.org.x/tools/gopls/internal/util/moremaps -- - -// sorted returns an iterator over the entries of m in key order. -func sorted[M ~map[K]V, K cmp.Ordered, V any](m M) iter.Seq2[K, V] { - // TODO(adonovan): use maps.Sorted if proposal #68598 is accepted. - return func(yield func(K, V) bool) { - keys := keySlice(m) - slices.Sort(keys) - for _, k := range keys { - if !yield(k, m[k]) { - break - } - } - } -} - -// KeySlice returns the keys of the map M, like slices.Collect(maps.Keys(m)). -func keySlice[M ~map[K]V, K comparable, V any](m M) []K { - r := make([]K, 0, len(m)) - for k := range m { - r = append(r, k) - } - return r -} diff --git a/vendor/golang.org/x/tools/go/ssa/builder.go b/vendor/golang.org/x/tools/go/ssa/builder.go index 1669d80b..a663af8f 100644 --- a/vendor/golang.org/x/tools/go/ssa/builder.go +++ b/vendor/golang.org/x/tools/go/ssa/builder.go @@ -85,6 +85,7 @@ import ( "slices" "golang.org/x/tools/internal/typeparams" + "golang.org/x/tools/internal/typesinternal" "golang.org/x/tools/internal/versions" ) @@ -124,7 +125,7 @@ var ( // The ssa:deferstack intrinsic returns the current function's defer stack. vDeferStack = &Builtin{ name: "ssa:deferstack", - sig: types.NewSignatureType(nil, nil, nil, nil, types.NewTuple(anonVar(tDeferStack)), false), + sig: types.NewSignatureType(nil, nil, nil, nil, typesinternal.TupleOf(tDeferStack), false), } ) @@ -1719,7 +1720,7 @@ func (b *builder) selectStmt(fn *Function, s *ast.SelectStmt, label *lblock) { for _, st := range states { if st.Dir == types.RecvOnly { chtyp := typeparams.CoreType(fn.typ(st.Chan.Type())).(*types.Chan) - vars = append(vars, anonVar(chtyp.Elem())) + vars = append(vars, newVar("", chtyp.Elem())) } } sel.setType(types.NewTuple(vars...)) diff --git a/vendor/golang.org/x/tools/go/ssa/methods.go b/vendor/golang.org/x/tools/go/ssa/methods.go index 82faadeb..8de0785c 100644 --- a/vendor/golang.org/x/tools/go/ssa/methods.go +++ b/vendor/golang.org/x/tools/go/ssa/methods.go @@ -167,10 +167,18 @@ func (prog *Program) RuntimeTypes() []types.Type { // eliminates the need to eagerly compute all the element // types during SSA building. var runtimeTypes []types.Type - add := func(t types.Type) { runtimeTypes = append(runtimeTypes, t) } var set typeutil.Map // for de-duping identical types for t := range prog.makeInterfaceTypes { - typesinternal.ForEachElement(&set, &prog.MethodSets, t, add) + typesinternal.ForEachElement(prog.MethodSets.MethodSet, t, func(t types.Type, access bool) bool { + if !access { + return false // inaccessible to reflection + } + seen, _ := set.Set(t, true).(bool) + if !seen { + runtimeTypes = append(runtimeTypes, t) + } + return seen + }) } return runtimeTypes diff --git a/vendor/golang.org/x/tools/go/ssa/util.go b/vendor/golang.org/x/tools/go/ssa/util.go index 42f9621c..5dfca720 100644 --- a/vendor/golang.org/x/tools/go/ssa/util.go +++ b/vendor/golang.org/x/tools/go/ssa/util.go @@ -181,19 +181,13 @@ func newVar(name string, typ types.Type) *types.Var { return types.NewParam(token.NoPos, nil, name, typ) } -// anonVar creates an anonymous 'var' for use in a types.Tuple. -func anonVar(typ types.Type) *types.Var { - return newVar("", typ) -} - -var lenResults = types.NewTuple(anonVar(tInt)) +var lenResults = typesinternal.TupleOf(tInt) // makeLen returns the len builtin specialized to type func(T)int. func makeLen(T types.Type) *Builtin { - lenParams := types.NewTuple(anonVar(T)) return &Builtin{ name: "len", - sig: types.NewSignatureType(nil, nil, nil, lenParams, lenResults, false), + sig: types.NewSignatureType(nil, nil, nil, typesinternal.TupleOf(T), lenResults, false), } } diff --git a/vendor/golang.org/x/tools/go/ssa/wrappers.go b/vendor/golang.org/x/tools/go/ssa/wrappers.go index 6cadd049..fbb06743 100644 --- a/vendor/golang.org/x/tools/go/ssa/wrappers.go +++ b/vendor/golang.org/x/tools/go/ssa/wrappers.go @@ -26,6 +26,7 @@ import ( "go/types" "golang.org/x/tools/internal/typeparams" + "golang.org/x/tools/internal/typesinternal" ) // -- wrappers ----------------------------------------------------------- @@ -118,10 +119,12 @@ func (b *builder) buildWrapper(fn *Function) { // For simple indirection wrappers, perform an informative nil-check: // "value method (T).f called using nil *T pointer" if len(indices) == 1 && !isPointer(recvType(fn.object)) { + params := typesinternal.TupleOf(fn.method.recv, tString, tString) + results := typesinternal.TupleOf(fn.method.recv) var c Call c.Call.Value = &Builtin{ name: "ssa:wrapnilchk", - sig: types.NewSignatureType(nil, nil, nil, types.NewTuple(anonVar(fn.method.recv), anonVar(tString), anonVar(tString)), types.NewTuple(anonVar(fn.method.recv)), false), + sig: types.NewSignatureType(nil, nil, nil, params, results, false), } c.Call.Args = []Value{ v, diff --git a/vendor/golang.org/x/tools/go/types/typeutil/callee.go b/vendor/golang.org/x/tools/go/types/typeutil/callee.go index 3d24a8c6..b64a8f45 100644 --- a/vendor/golang.org/x/tools/go/types/typeutil/callee.go +++ b/vendor/golang.org/x/tools/go/types/typeutil/callee.go @@ -7,7 +7,8 @@ package typeutil import ( "go/ast" "go/types" - _ "unsafe" // for linkname + + "golang.org/x/tools/internal/typesinternal" ) // Callee returns the named target of a function call, if any: @@ -19,14 +20,7 @@ import ( // Note: for calls of instantiated functions and methods, Callee returns // the corresponding generic function or method on the generic type. func Callee(info *types.Info, call *ast.CallExpr) types.Object { - obj := info.Uses[usedIdent(info, call.Fun)] - if obj == nil { - return nil - } - if _, ok := obj.(*types.TypeName); ok { - return nil - } - return obj + return typesinternal.Callee(info, call) } // StaticCallee returns the target (function or method) of a static function @@ -35,52 +29,5 @@ func Callee(info *types.Info, call *ast.CallExpr) types.Object { // Note: for calls of instantiated functions and methods, StaticCallee returns // the corresponding generic function or method on the generic type. func StaticCallee(info *types.Info, call *ast.CallExpr) *types.Func { - obj := info.Uses[usedIdent(info, call.Fun)] - fn, _ := obj.(*types.Func) - if fn == nil || interfaceMethod(fn) { - return nil - } - return fn -} - -// usedIdent is the implementation of [internal/typesinternal.UsedIdent]. -// It returns the identifier associated with e. -// See typesinternal.UsedIdent for a fuller description. -// This function should live in typesinternal, but cannot because it would -// create an import cycle. -// -//go:linkname usedIdent golang.org/x/tools/go/types/typeutil.usedIdent -func usedIdent(info *types.Info, e ast.Expr) *ast.Ident { - if info.Types == nil || info.Uses == nil { - panic("one of info.Types or info.Uses is nil; both must be populated") - } - // Look through type instantiation if necessary. - switch d := ast.Unparen(e).(type) { - case *ast.IndexExpr: - if info.Types[d.Index].IsType() { - e = d.X - } - case *ast.IndexListExpr: - e = d.X - } - - switch e := ast.Unparen(e).(type) { - // info.Uses always has the object we want, even for selector expressions. - // We don't need info.Selections. - // See go/types/recording.go:recordSelection. - case *ast.Ident: - return e - case *ast.SelectorExpr: - return e.Sel - } - return nil -} - -// interfaceMethod reports whether its argument is a method of an interface. -// This function should live in typesinternal, but cannot because it would create an import cycle. -// -//go:linkname interfaceMethod golang.org/x/tools/go/types/typeutil.interfaceMethod -func interfaceMethod(f *types.Func) bool { - recv := f.Signature().Recv() - return recv != nil && types.IsInterface(recv.Type()) + return typesinternal.StaticCallee(info, call) } diff --git a/vendor/golang.org/x/tools/internal/analysis/analyzerutil/version.go b/vendor/golang.org/x/tools/internal/analysis/analyzerutil/version.go index 700d53ef..60d7253c 100644 --- a/vendor/golang.org/x/tools/internal/analysis/analyzerutil/version.go +++ b/vendor/golang.org/x/tools/internal/analysis/analyzerutil/version.go @@ -38,7 +38,7 @@ func FileUsesGoVersion(pass *analysis.Pass, file *ast.File, version string) (_re // The bootstrap rule does not cover tests, // and some tests (e.g. debug/elf/file_test.go) rely on this. pkgpath := pass.Pkg.Path() - if packagepath.IsStdPackage(pkgpath) && + if packagepath.MaybeStdPackage(pkgpath) && stdlib.IsBootstrapPackage(pkgpath) && // (excludes "*_test" external test packages) !strings.HasSuffix(pass.Fset.File(file.Pos()).Name(), "_test.go") { // (excludes all tests) fileVersion = stdlib.BootstrapVersion.String() // package must bootstrap diff --git a/vendor/golang.org/x/tools/internal/moremaps/maps.go b/vendor/golang.org/x/tools/internal/moremaps/maps.go new file mode 100644 index 00000000..a1bae078 --- /dev/null +++ b/vendor/golang.org/x/tools/internal/moremaps/maps.go @@ -0,0 +1,116 @@ +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package moremaps contains more functions for working with maps. +package moremaps + +import ( + "cmp" + "iter" + "maps" + "slices" +) + +// Arbitrary returns an arbitrary (key, value) entry from the map and ok is true, if +// the map is not empty. Otherwise, it returns zero values for K and V, and false. +func Arbitrary[K comparable, V any](m map[K]V) (_ K, _ V, ok bool) { + for k, v := range m { + return k, v, true + } + return +} + +// Group returns a new non-nil map containing the elements of s grouped by the +// keys returned from the key func. +func Group[K comparable, V any](s []V, key func(V) K) map[K][]V { + m := make(map[K][]V) + for _, v := range s { + k := key(v) + m[k] = append(m[k], v) + } + return m +} + +// KeySlice returns the keys of the map M, like slices.Collect(maps.Keys(m)). +func KeySlice[M ~map[K]V, K comparable, V any](m M) []K { + r := make([]K, 0, len(m)) + for k := range m { + r = append(r, k) + } + return r +} + +// ValueSlice returns the values of the map M, like slices.Collect(maps.Values(m)). +func ValueSlice[M ~map[K]V, K comparable, V any](m M) []V { + r := make([]V, 0, len(m)) + for _, v := range m { + r = append(r, v) + } + return r +} + +// SameKeys reports whether x and y have equal sets of keys. +func SameKeys[K comparable, V1, V2 any](x map[K]V1, y map[K]V2) bool { + ignoreValues := func(V1, V2) bool { return true } + return maps.EqualFunc(x, y, ignoreValues) +} + +// Sorted returns an iterator over the entries of m in key order. +func Sorted[M ~map[K]V, K cmp.Ordered, V any](m M) iter.Seq2[K, V] { + // TODO(adonovan): use maps.Sorted if proposal #68598 is accepted. + return func(yield func(K, V) bool) { + keys := KeySlice(m) + slices.Sort(keys) + for _, k := range keys { + if !yield(k, m[k]) { + break + } + } + } +} + +// SortedFunc returns an iterator over the entries of m in the key order determined by cmp. +func SortedFunc[M ~map[K]V, K comparable, V any](m M, cmp func(x, y K) int) iter.Seq2[K, V] { + // TODO(adonovan): use maps.SortedFunc if proposal #68598 is accepted. + return func(yield func(K, V) bool) { + keys := KeySlice(m) + slices.SortFunc(keys, cmp) + for _, k := range keys { + if !yield(k, m[k]) { + break + } + } + } +} + +// Delete is like delete(m, k) but reports whether deletion occurred. +func Delete[M ~map[K]V, K comparable, V any](m M, k K) bool { + pre := len(m) + delete(m, k) + return pre != len(m) +} + +// Entry is a key-value pair obtained from a map. +type Entry[K comparable, V any] struct { + Key K + Value V +} + +// Entries returns a new unordered array of the entries of a map. +func Entries[M ~map[K]V, K comparable, V any](m M) []Entry[K, V] { + entries := make([]Entry[K, V], 0, len(m)) + for k, v := range m { + entries = append(entries, Entry[K, V]{k, v}) + } + return entries +} + +// FromEntries returns a new map into which the entries have been inserted in order. +func FromEntries[K comparable, V any](entries []Entry[K, V]) map[K]V { + m := make(map[K]V, len(entries)) + for _, e := range entries { + m[e.Key] = e.Value + } + return m +} diff --git a/vendor/golang.org/x/tools/internal/packagepath/packagepath.go b/vendor/golang.org/x/tools/internal/packagepath/packagepath.go index fa39a13f..7b25340d 100644 --- a/vendor/golang.org/x/tools/internal/packagepath/packagepath.go +++ b/vendor/golang.org/x/tools/internal/packagepath/packagepath.go @@ -36,9 +36,19 @@ func CanImport(from, to string) bool { return true } -// IsStdPackage reports whether the specified package path belongs to a -// package in the standard library (including internal dependencies). -func IsStdPackage(path string) bool { +// MaybeStdPackage reports whether the specified package path might +// belong to a package in the standard library (including internal +// dependencies), based only on its form. +// +// It may spuriously return true, but a result of false is definitive: +// +// MaybeStdPackage("fmt") = true +// MaybeStdPackage("maybe/tomorrow") = true // false positive +// MaybeStdPackage("example.com/foo") = false +// +// For a definitive answer, use [stdlib.HasPackage], which consults a +// huge table. +func MaybeStdPackage(path string) bool { // A standard package has no dot in its first segment. // (It may yet have a dot, e.g. "vendor/golang.org/x/foo".) slash := strings.IndexByte(path, '/') diff --git a/vendor/golang.org/x/tools/internal/refactor/imports.go b/vendor/golang.org/x/tools/internal/refactor/imports.go index 5ce70aee..046038cc 100644 --- a/vendor/golang.org/x/tools/internal/refactor/imports.go +++ b/vendor/golang.org/x/tools/internal/refactor/imports.go @@ -125,13 +125,13 @@ func AddImportEdits(file *ast.File, name, pkgpath string) []Edit { var pos token.Pos if gd, ok := decl0.(*ast.GenDecl); ok && gd.Tok == token.IMPORT && gd.Rparen.IsValid() { // Have existing grouped import ( ... ) decl. - if packagepath.IsStdPackage(pkgpath) && len(gd.Specs) > 0 { + if packagepath.MaybeStdPackage(pkgpath) && len(gd.Specs) > 0 { // Add spec for a std package before // first existing spec, followed by // a blank line if the next one is non-std. first := gd.Specs[0].(*ast.ImportSpec) pos = first.Pos() - if !packagepath.IsStdPackage(first.Path.Value) { + if !packagepath.MaybeStdPackage(first.Path.Value) { newText += "\n" } newText += "\n\t" diff --git a/vendor/golang.org/x/tools/internal/refactor/inline/callee.go b/vendor/golang.org/x/tools/internal/refactor/inline/callee.go index 68e28447..313e0f71 100644 --- a/vendor/golang.org/x/tools/internal/refactor/inline/callee.go +++ b/vendor/golang.org/x/tools/internal/refactor/inline/callee.go @@ -8,6 +8,7 @@ package inline import ( "bytes" + "cmp" "encoding/gob" "fmt" "go/ast" @@ -18,6 +19,7 @@ import ( "strings" "golang.org/x/tools/go/types/typeutil" + "golang.org/x/tools/internal/moremaps" "golang.org/x/tools/internal/typeparams" "golang.org/x/tools/internal/typesinternal" ) @@ -885,6 +887,34 @@ func (s shadowMap) add(info *types.Info, paramIndexes map[types.Object]int, excl return s } +var ( + _ gob.GobEncoder = (*shadowMap)(nil) + _ gob.GobDecoder = (*shadowMap)(nil) +) + +// GobEncode implements gob.GobEncoder, encoding the map's entries in a +// deterministic order so that serialized facts are stable. +func (s *shadowMap) GobEncode() ([]byte, error) { + entries := moremaps.Entries(*s) + slices.SortFunc(entries, func(x, y moremaps.Entry[string, int]) int { + return cmp.Compare(x.Key, y.Key) + }) + var out bytes.Buffer + if err := gob.NewEncoder(&out).Encode(entries); err != nil { + return nil, err + } + return out.Bytes(), nil +} + +func (s *shadowMap) GobDecode(data []byte) error { + var entries []moremaps.Entry[string, int] + if err := gob.NewDecoder(bytes.NewReader(data)).Decode(&entries); err != nil { + return err + } + *s = moremaps.FromEntries(entries) + return nil +} + // fieldObjs returns a map of each types.Object defined by the given signature // to its index in the parameter list. Parameters with missing or blank name // are skipped. diff --git a/vendor/golang.org/x/tools/internal/refactor/inline/calleefx.go b/vendor/golang.org/x/tools/internal/refactor/inline/calleefx.go index 001bf61e..6dcf0b97 100644 --- a/vendor/golang.org/x/tools/internal/refactor/inline/calleefx.go +++ b/vendor/golang.org/x/tools/internal/refactor/inline/calleefx.go @@ -10,6 +10,7 @@ import ( "go/ast" "go/token" "go/types" + "slices" "golang.org/x/tools/internal/typesinternal" ) @@ -71,14 +72,20 @@ func calleefx(info *types.Info, body *ast.BlockStmt, paramInfos map[*types.Var]* // unreferenced by the function body). This lets us // not bother implementing the complete traversal into // control structures. - // - // TODO(adonovan): add them in a deterministic order. - // (This is not a bug but determinism is good.) - for _, pinfo := range paramInfos { + + // Sort params by Index for determinism + sortedParams := make([]*types.Var, 0, len(paramInfos)) + for obj, pinfo := range paramInfos { if !pinfo.IsResult && len(pinfo.Refs) > 0 { - effect(pinfo.Index) + sortedParams = append(sortedParams, obj) } } + slices.SortFunc(sortedParams, func(a, b *types.Var) int { + return paramInfos[a].Index - paramInfos[b].Index + }) + for _, obj := range sortedParams { + effect(paramInfos[obj].Index) + } } var visitExpr func(n ast.Expr) diff --git a/vendor/golang.org/x/tools/internal/refactor/inline/falcon.go b/vendor/golang.org/x/tools/internal/refactor/inline/falcon.go index 037d33bd..884a807a 100644 --- a/vendor/golang.org/x/tools/internal/refactor/inline/falcon.go +++ b/vendor/golang.org/x/tools/internal/refactor/inline/falcon.go @@ -13,6 +13,7 @@ import ( "go/format" "go/token" "go/types" + "slices" "strconv" "strings" @@ -124,11 +125,20 @@ func falcon(logf func(string, ...any), fset *token.FileSet, params map[*types.Va // type mapping st.int = st.typename(types.Typ[types.Int]) st.any = "interface{}" // don't use "any" as it may be shadowed - for obj, info := range st.params { + + // Sort params by Index for determinism + sortedParams := make([]*types.Var, 0, len(st.params)) + for obj := range st.params { if isBasic(obj.Type(), types.IsConstType) { - info.FalconType = st.typename(obj.Type()) + sortedParams = append(sortedParams, obj) } } + slices.SortFunc(sortedParams, func(a, b *types.Var) int { + return st.params[a].Index - st.params[b].Index + }) + for _, obj := range sortedParams { + st.params[obj].FalconType = st.typename(obj.Type()) + } st.stmt(st.decl.Body) diff --git a/vendor/golang.org/x/tools/internal/typesinternal/assignedaddress.go b/vendor/golang.org/x/tools/internal/typesinternal/assignedaddress.go new file mode 100644 index 00000000..020defc3 --- /dev/null +++ b/vendor/golang.org/x/tools/internal/typesinternal/assignedaddress.go @@ -0,0 +1,128 @@ +// Copyright 2026 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package typesinternal + +import ( + "go/ast" + "go/token" + "go/types" + + "golang.org/x/tools/go/ast/edge" + "golang.org/x/tools/go/ast/inspector" +) + +// IsAssignedOrAddressTaken reports whether the expression cur denotes a +// variable and appears in a context that assigns it or that takes its address, +// potentially leading to indirect assignment. +// +// These examples cause IsAssignedOrAddressTaken on the identifier for x to +// return true: +// +// x = 1 +// x++ +// x[i] = 1 (assume x is an array) +// x.a[i] = 1 (assume x.a is a non-pointer struct field) +// use(&x) +// +// whereas these cause it to return false: +// +// y = x +// f(x) +// use(x.a[i]) +// use(*x) +// +// The expression may itself be a compound, for example: +// +// use(&(*ptr)) => IsAssignedOrAddressTaken("*ptr") = true +// x.a[i] = 1 => IsAssignedOrAddressTaken("x.a") = true +// _ = x.a[i] => IsAssignedOrAddressTaken("x.a") = false +// +// A variable's declaration is not considered to be an assignment: +// +// var x int => IsAssignedOrAddressTaken(x) = false +// x := 1 => IsAssignedOrAddressTaken(x) = false +// +// TODO(adonovan): revisit the surprising behavior for declarations. +func IsAssignedOrAddressTaken(info *types.Info, cur inspector.Cursor) bool { + // Unfortunately we can't simply use info.Types[e].Assignable() + // as it is always true for a variable even when that variable is + // used only as an r-value. So we must inspect enclosing syntax. +outer: + // Ascend to outermost aggregate of which + // original cur is a part: + // x -> (x) | x.f | x[i] | x[i:j] + for cur = range cur.Enclosing() { + switch cur.ParentEdgeKind() { + case edge.ParenExpr_X: + // If x is an lvalue, then (x) is an lvalue. + case edge.SelectorExpr_X: + // If x is an lvalue, then x.f is an lvalue iff + // the selection does not traverse a pointer. + sel := cur.Parent().Node().(*ast.SelectorExpr) + if seln, ok := info.Selections[sel]; ok { + // Note: there is a bug in Indirect() where it spuriously returns true + // when both the selection receiver and parameter are pointers. However, + // it's okay in this case because there is no address taken when a + // pointer receiver method is called on a pointer type. + if seln.Indirect() { + return false + } + if seln.Kind() == types.MethodVal { + sig := seln.Obj().Type().(*types.Signature) + if is[*types.Pointer](sig.Recv().Type().Underlying()) { + t := seln.Recv() + // The receiver may be an embedded field, so we need + // to get the inner-most type (right before the method + // call in seln.Index()) + for _, idx := range seln.Index()[:len(seln.Index())-1] { + t = t.Underlying().(*types.Struct).Field(idx).Type() + } + if !is[*types.Pointer](t.Underlying()) { + return true // takes address of receiver + } + } + return false + } + } + case edge.IndexExpr_X, edge.SliceExpr_X: + // If x[i] or x[i:j] is an lvalue, + // then x is an lvalue iff x is an array. + if !is[*types.Array](info.TypeOf(cur.Node().(ast.Expr)).Underlying()) { + return false + } + default: + break outer + } + } + switch cur.ParentEdgeKind() { + case edge.AssignStmt_Lhs: + assign := cur.Parent().Node().(*ast.AssignStmt) + if assign.Tok != token.DEFINE { + return true // x = j or x += j + } + id := cur.Node().(*ast.Ident) + // Re-assigned identifiers are recorded in the Uses map. + if _, ok := info.Uses[id]; ok { + return true // reassignment of x (x, y := 1, 2) + } + case edge.RangeStmt_Key, edge.RangeStmt_Value: + rng := cur.Parent().Node().(*ast.RangeStmt) + if rng.Tok == token.ASSIGN { + return true // "for k, v = range x" is like an AssignStmt to k, v + } + case edge.IncDecStmt_X: + return true // x++, x-- + case edge.UnaryExpr_X: + if cur.Parent().Node().(*ast.UnaryExpr).Op == token.AND { + return true // &x + } + } + return false +} + +func is[T any](x any) bool { + _, ok := x.(T) + return ok +} diff --git a/vendor/golang.org/x/tools/internal/typesinternal/classify_call.go b/vendor/golang.org/x/tools/internal/typesinternal/classify_call.go index 7ebe9768..d5c40a2e 100644 --- a/vendor/golang.org/x/tools/internal/typesinternal/classify_call.go +++ b/vendor/golang.org/x/tools/internal/typesinternal/classify_call.go @@ -8,7 +8,6 @@ import ( "fmt" "go/ast" "go/types" - _ "unsafe" // for go:linkname hack ) // CallKind describes the function position of an [*ast.CallExpr]. @@ -72,11 +71,15 @@ func ClassifyCall(info *types.Info, call *ast.CallExpr) CallKind { if tv.IsBuiltin() { return CallBuiltin } - obj := info.Uses[UsedIdent(info, call.Fun)] + id := UsedIdent(info, call.Fun) + if id == nil { + return CallDynamic + } + obj := info.Uses[id] // Classify the call by the type of the object, if any. switch obj := obj.(type) { case *types.Func: - if interfaceMethod(obj) { + if isInterfaceMethod(obj) { return CallInterface } return CallStatic @@ -127,11 +130,69 @@ func ClassifyCall(info *types.Info, call *ast.CallExpr) CallKind { // Note: if e is an instantiated function or method, UsedIdent returns // the corresponding generic function or method on the generic type. func UsedIdent(info *types.Info, e ast.Expr) *ast.Ident { - return usedIdent(info, e) + if info.Types == nil || info.Uses == nil { + panic("one of info.Types or info.Uses is nil; both must be populated") + } + // Look through type instantiation if necessary. + switch d := ast.Unparen(e).(type) { + case *ast.IndexExpr: + if info.Types[d.Index].IsType() { + e = d.X + } + case *ast.IndexListExpr: + e = d.X + } + + switch e := ast.Unparen(e).(type) { + // info.Uses always has the object we want, even for selector expressions. + // We don't need info.Selections. + // See go/types/recording.go:recordSelection. + case *ast.Ident: + return e + case *ast.SelectorExpr: + return e.Sel + } + return nil +} + +// See [golang.org/x/tools/go/types/typeutil.Callee]. +func Callee(info *types.Info, call *ast.CallExpr) types.Object { + id := UsedIdent(info, call.Fun) + if id == nil { + return nil + } + obj := info.Uses[id] + if obj == nil { + return nil + } + if _, ok := obj.(*types.TypeName); ok { + return nil + } + if fn, ok := obj.(*types.Func); ok { + return fn.Origin() + } + return obj } -//go:linkname usedIdent golang.org/x/tools/go/types/typeutil.usedIdent -func usedIdent(info *types.Info, e ast.Expr) *ast.Ident +// See [golang.org/x/tools/go/types/typeutil.StaticCallee]. +func StaticCallee(info *types.Info, call *ast.CallExpr) *types.Func { + id := UsedIdent(info, call.Fun) + if id == nil { + return nil + } + obj := info.Uses[id] + if obj == nil { + return nil + } + fn, _ := obj.(*types.Func) + if fn == nil || isInterfaceMethod(fn) { + return nil + } + return fn.Origin() +} -//go:linkname interfaceMethod golang.org/x/tools/go/types/typeutil.interfaceMethod -func interfaceMethod(f *types.Func) bool +// isInterfaceMethod reports whether its argument is a method of an interface. +func isInterfaceMethod(f *types.Func) bool { + recv := f.Signature().Recv() + return recv != nil && types.IsInterface(recv.Type()) +} diff --git a/vendor/golang.org/x/tools/internal/typesinternal/element.go b/vendor/golang.org/x/tools/internal/typesinternal/element.go index 89eeea16..bab37fbf 100644 --- a/vendor/golang.org/x/tools/internal/typesinternal/element.go +++ b/vendor/golang.org/x/tools/internal/typesinternal/element.go @@ -7,8 +7,6 @@ package typesinternal import ( "fmt" "go/types" - - "golang.org/x/tools/go/types/typeutil" ) // ForEachElement calls f for type T and each type reachable from its @@ -16,25 +14,24 @@ import ( // type constructors; in addition, for each named type N, the type *N // is added to the result as it may have additional methods. // -// The caller must provide an initially empty set used to de-duplicate -// identical types, potentially across multiple calls to ForEachElement. -// (Its final value holds all the elements seen, matching the arguments -// passed to f.) +// The access argument passed to f indicates whether the type is +// inaccessible to reflection (for example, intermediate tuple types +// or underlying types of named types). // -// TODO(adonovan): share/harmonize with go/callgraph/rta. -func ForEachElement(rtypes *typeutil.Map, msets *typeutil.MethodSetCache, T types.Type, f func(types.Type)) { - var visit func(T types.Type, skip bool) - visit = func(T types.Type, skip bool) { - if !skip { - if seen, _ := rtypes.Set(T, true).(bool); seen { - return // de-dup - } - - f(T) // notify caller of new element type +// The result of f indicates whether the caller has seen this type +// already, so we can prune the traversal. +// +// methodSetOf abstracts (*typeutil.MethodSetCache).MethodSet, +// avoiding an import cycle. +func ForEachElement(methodSetOf func(types.Type) *types.MethodSet, T types.Type, f func(T types.Type, access bool) bool) { + var visit func(T types.Type, access bool) + visit = func(T types.Type, access bool) { + if f(T, access) { + return // duplicate; prune descent } // Recursion over signatures of each method. - tmset := msets.MethodSet(T) + tmset := methodSetOf(T) for method := range tmset.Methods() { sig := method.Type().(*types.Signature) if sig.TypeParams() != nil { @@ -65,13 +62,13 @@ func ForEachElement(rtypes *typeutil.Map, msets *typeutil.MethodSetCache, T type // // TODO(adonovan): document whether or not it is // safe to skip non-exported methods (as RTA does). - visit(sig.Params(), true) // skip the Tuple - visit(sig.Results(), true) // skip the Tuple + visit(sig.Params(), false) // the Tuple is inaccessible + visit(sig.Results(), false) // the Tuple is inaccessible } switch T := T.(type) { case *types.Alias: - visit(types.Unalias(T), skip) // emulates the pre-Alias behavior + visit(types.Unalias(T), access) // emulates the pre-Alias behavior case *types.Basic: // nop @@ -80,49 +77,49 @@ func ForEachElement(rtypes *typeutil.Map, msets *typeutil.MethodSetCache, T type // nop---handled by recursion over method set. case *types.Pointer: - visit(T.Elem(), false) + visit(T.Elem(), true) case *types.Slice: - visit(T.Elem(), false) + visit(T.Elem(), true) case *types.Chan: - visit(T.Elem(), false) + visit(T.Elem(), true) case *types.Map: - visit(T.Key(), false) - visit(T.Elem(), false) + visit(T.Key(), true) + visit(T.Elem(), true) case *types.Signature: if T.Recv() != nil { panic(fmt.Sprintf("Signature %s has Recv %s", T, T.Recv())) } - visit(T.Params(), true) // skip the Tuple - visit(T.Results(), true) // skip the Tuple + visit(T.Params(), false) // the Tuple is inaccessible + visit(T.Results(), false) // the Tuple is inaccessible case *types.Named: // A pointer-to-named type can be derived from a named // type via reflection. It may have methods too. - visit(types.NewPointer(T), false) + visit(types.NewPointer(T), true) // Consider 'type T struct{S}' where S has methods. // Reflection provides no way to get from T to struct{S}, // only to S, so the method set of struct{S} is unwanted, - // so set 'skip' flag during recursion. - visit(T.Underlying(), true) // skip the unnamed type + // so mark it inaccessible during recursion. + visit(T.Underlying(), false) // skip the unnamed type case *types.Array: - visit(T.Elem(), false) + visit(T.Elem(), true) case *types.Struct: for i, n := 0, T.NumFields(); i < n; i++ { // TODO(adonovan): document whether or not // it is safe to skip non-exported fields. - visit(T.Field(i).Type(), false) + visit(T.Field(i).Type(), true) } case *types.Tuple: for i, n := 0, T.Len(); i < n; i++ { - visit(T.At(i).Type(), false) + visit(T.At(i).Type(), true) } case *types.TypeParam, *types.Union: @@ -133,5 +130,5 @@ func ForEachElement(rtypes *typeutil.Map, msets *typeutil.MethodSetCache, T type panic(fmt.Sprintf("ForEachElement called on unexpected type %T", T)) } } - visit(T, false) + visit(T, true) } diff --git a/vendor/golang.org/x/tools/internal/typesinternal/toonew.go b/vendor/golang.org/x/tools/internal/typesinternal/toonew.go index cc86487e..386c59c7 100644 --- a/vendor/golang.org/x/tools/internal/typesinternal/toonew.go +++ b/vendor/golang.org/x/tools/internal/typesinternal/toonew.go @@ -13,20 +13,30 @@ import ( // TooNewStdSymbols computes the set of package-level symbols // exported by pkg that are not available at the specified version. -// The result maps each symbol to its minimum version. // // The pkg is allowed to contain type errors. -func TooNewStdSymbols(pkg *types.Package, version string) map[types.Object]string { - disallowed := make(map[types.Object]string) +func TooNewStdSymbols(pkg *types.Package, version string) map[types.Object]stdlib.Symbol { + disallowed := make(map[types.Object]stdlib.Symbol) + + // Some symbols are accessible before their release but + // only with specific build tags unknown to us here. + // Avoid false positives in such cases. + if pkg.Path() == "testing/synctest" && versions.AtLeast(version, "go1.24") { + // requires go1.24 && goexperiment.synctest || go1.25 + return disallowed + } + if (pkg.Path() == "encoding/json/v2" || pkg.Path() == "encoding/json/jsontext") && versions.AtLeast(version, "go1.25") { + // requires go1.25 && goexperiment.jsonv2 || go1.27 + return disallowed + } // Pass 1: package-level symbols. symbols := stdlib.PackageSymbols[pkg.Path()] for _, sym := range symbols { - symver := sym.Version.String() - if versions.Before(version, symver) { + if versions.Before(version, sym.Version.String()) { switch sym.Kind { case stdlib.Func, stdlib.Var, stdlib.Const, stdlib.Type: - disallowed[pkg.Scope().Lookup(sym.Name)] = symver + disallowed[pkg.Scope().Lookup(sym.Name)] = sym } } } @@ -60,28 +70,36 @@ func TooNewStdSymbols(pkg *types.Package, version string) map[types.Object]strin // spuriously cause the analyzer to report a reference to a // too-new symbol even though this expression compiles just // fine (with the fake implementation) using go1.21. + var noSym stdlib.Symbol + depth := make(map[types.Object]int) for _, sym := range symbols { - symVersion := sym.Version.String() - if !versions.Before(version, symVersion) { + if !versions.Before(version, sym.Version.String()) { continue // allowed } var obj types.Object + var indices []int switch sym.Kind { case stdlib.Field: typename, name := sym.SplitField() - if t := pkg.Scope().Lookup(typename); t != nil && disallowed[t] == "" { - obj, _, _ = types.LookupFieldOrMethod(t.Type(), false, pkg, name) + if t := pkg.Scope().Lookup(typename); t != nil && disallowed[t] == noSym { + obj, indices, _ = types.LookupFieldOrMethod(t.Type(), false, pkg, name) } case stdlib.Method: ptr, recvname, name := sym.SplitMethod() - if t := pkg.Scope().Lookup(recvname); t != nil && disallowed[t] == "" { - obj, _, _ = types.LookupFieldOrMethod(t.Type(), ptr, pkg, name) + if t := pkg.Scope().Lookup(recvname); t != nil && disallowed[t] == noSym { + obj, indices, _ = types.LookupFieldOrMethod(t.Type(), ptr, pkg, name) } } if obj != nil { - disallowed[obj] = symVersion + // In the presence of embedding, two or more "pkg.T.name" + // strings may map to the same types.Object. + // Prefer the Object with the shorter index path. + if min, ok := depth[obj]; !ok || len(indices) < min { + depth[obj] = len(indices) + disallowed[obj] = sym + } } } diff --git a/vendor/golang.org/x/tools/internal/typesinternal/types.go b/vendor/golang.org/x/tools/internal/typesinternal/types.go index d2c0b4c5..9fd48b08 100644 --- a/vendor/golang.org/x/tools/internal/typesinternal/types.go +++ b/vendor/golang.org/x/tools/internal/typesinternal/types.go @@ -270,3 +270,11 @@ func ImplicitFieldSelections(seln types.Selection) iter.Seq2[*types.Var, bool] { } } } + +func TupleOf(elems ...types.Type) *types.Tuple { + params := make([]*types.Var, len(elems)) + for i, elem := range elems { + params[i] = types.NewParam(token.NoPos, nil, "", elem) + } + return types.NewTuple(params...) +} diff --git a/vendor/golang.org/x/tools/refactor/satisfy/find.go b/vendor/golang.org/x/tools/refactor/satisfy/find.go index 720ecc17..42998687 100644 --- a/vendor/golang.org/x/tools/refactor/satisfy/find.go +++ b/vendor/golang.org/x/tools/refactor/satisfy/find.go @@ -11,7 +11,7 @@ // It requires well-typed inputs, and may panic otherwise. // // This package reimplements parts of the type checker. See -// https://go.dev/issue/70638 for a proposal to expose the the work +// https://go.dev/issue/70638 for a proposal to expose the work // already done by the type checker, which would make this package // redundant. package satisfy @@ -355,7 +355,8 @@ func (f *Finder) expr(e ast.Expr) types.Type { if e.Name == "_" { // e.g. "for _ = range x" return tInvalid } - panic("undefined ident: " + e.Name) + // There could be a missing definition, return an invalid type + return tInvalid case *ast.Ellipsis: if e.Elt != nil { @@ -374,7 +375,14 @@ func (f *Finder) expr(e ast.Expr) types.Type { case *types.Struct: for i, elem := range e.Elts { if kv, ok := elem.(*ast.KeyValueExpr); ok { - f.assign(f.info.Uses[kv.Key.(*ast.Ident)].Type(), f.expr(kv.Value)) + // in weird code, kv.Key might not be an identifier + id, ok := kv.Key.(*ast.Ident) + if !ok || f.info.Uses[id] == nil { + f.expr(kv.Value) + continue + + } + f.assign(f.info.Uses[id].Type(), f.expr(kv.Value)) } else { f.assign(T.Field(i).Type(), f.expr(elem)) } @@ -412,7 +420,10 @@ func (f *Finder) expr(e ast.Expr) types.Type { f.expr(e.X) } } else { - return f.info.Uses[e.Sel].Type() // qualified identifier + if obj, ok := f.info.Uses[e.Sel]; ok { + return obj.Type() // qualified identifier + } + return tInvalid } case *ast.IndexExpr: diff --git a/vendor/google.golang.org/protobuf/encoding/protodelim/protodelim.go b/vendor/google.golang.org/protobuf/encoding/protodelim/protodelim.go index 2ef36bbc..ec63689e 100644 --- a/vendor/google.golang.org/protobuf/encoding/protodelim/protodelim.go +++ b/vendor/google.golang.org/protobuf/encoding/protodelim/protodelim.go @@ -10,6 +10,7 @@ import ( "encoding/binary" "fmt" "io" + "math" "google.golang.org/protobuf/encoding/protowire" "google.golang.org/protobuf/internal/errors" @@ -117,7 +118,13 @@ func (o UnmarshalOptions) UnmarshalFrom(r Reader, m proto.Message) error { if maxSize == 0 { maxSize = defaultMaxSize } - if maxSize != -1 && size > uint64(maxSize) { + if maxSize == -1 { + // No limit specified: Just check that size fits into an integer, + // otherwise the make([]byte, size) call below will panic. + if size > math.MaxInt { + return errors.Wrap(&SizeTooLargeError{Size: size, MaxSize: math.MaxInt}, "") + } + } else if size > uint64(maxSize) { return errors.Wrap(&SizeTooLargeError{Size: size, MaxSize: uint64(maxSize)}, "") } diff --git a/vendor/google.golang.org/protobuf/encoding/prototext/decode.go b/vendor/google.golang.org/protobuf/encoding/prototext/decode.go index b5380505..20ec09e1 100644 --- a/vendor/google.golang.org/protobuf/encoding/prototext/decode.go +++ b/vendor/google.golang.org/protobuf/encoding/prototext/decode.go @@ -8,6 +8,7 @@ import ( "fmt" "unicode/utf8" + "google.golang.org/protobuf/encoding/protowire" "google.golang.org/protobuf/internal/encoding/messageset" "google.golang.org/protobuf/internal/encoding/text" "google.golang.org/protobuf/internal/errors" @@ -49,12 +50,19 @@ type UnmarshalOptions struct { protoregistry.MessageTypeResolver protoregistry.ExtensionTypeResolver } + + // RecursionLimit limits how deeply messages may be nested. + // If zero, a default limit is applied. + RecursionLimit int } // Unmarshal reads the given []byte and populates the given [proto.Message] // using options in the UnmarshalOptions object. // The provided message must be mutable (e.g., a non-nil pointer to a message). func (o UnmarshalOptions) Unmarshal(b []byte, m proto.Message) error { + if o.RecursionLimit == 0 { + o.RecursionLimit = protowire.DefaultRecursionLimit + } return o.unmarshal(b, m) } @@ -102,8 +110,14 @@ func (d decoder) syntaxError(pos int, f string, x ...any) error { return errors.New(head+f, x...) } +var errRecursionDepth = errors.New("exceeded maximum recursion depth") + // unmarshalMessage unmarshals into the given protoreflect.Message. func (d decoder) unmarshalMessage(m protoreflect.Message, checkDelims bool) error { + if d.opts.RecursionLimit--; d.opts.RecursionLimit < 0 { + return errRecursionDepth + } + messageDesc := m.Descriptor() if !flags.ProtoLegacy && messageset.IsMessageSet(messageDesc) { return errors.New("no support for proto1 MessageSets") @@ -437,6 +451,10 @@ func (d decoder) unmarshalList(fd protoreflect.FieldDescriptor, list protoreflec // unmarshalMap unmarshals into given protoreflect.Map. A map value is a // textproto message containing {key: , value: }. func (d decoder) unmarshalMap(fd protoreflect.FieldDescriptor, mmap protoreflect.Map) error { + if d.opts.RecursionLimit--; d.opts.RecursionLimit < 0 { + return errRecursionDepth + } + // Determine ahead whether map entry is a scalar type or a message type in // order to call the appropriate unmarshalMapValue func inside // unmarshalMapEntry. diff --git a/vendor/google.golang.org/protobuf/internal/descfmt/stringer.go b/vendor/google.golang.org/protobuf/internal/descfmt/stringer.go index 87e46bd4..0b0dfacb 100644 --- a/vendor/google.golang.org/protobuf/internal/descfmt/stringer.go +++ b/vendor/google.golang.org/protobuf/internal/descfmt/stringer.go @@ -83,12 +83,13 @@ func formatListOpt(vs list, isRoot, allowMulti bool) string { case protoreflect.FileImports: for i := 0; i < vs.Len(); i++ { var rs records - rv := reflect.ValueOf(vs.Get(i)) - rs.Append(rv, []methodAndName{ - {rv.MethodByName("Path"), "Path"}, - {rv.MethodByName("Package"), "Package"}, - {rv.MethodByName("IsPublic"), "IsPublic"}, - {rv.MethodByName("IsWeak"), "IsWeak"}, + fi := vs.Get(i) + rv := reflect.ValueOf(fi) + rs.Append(rv, []attrAndName{ + {fi.Path(), "Path"}, + {fi.Package(), "Package"}, + {fi.IsPublic, "IsPublic"}, + {fi.IsWeak, "IsWeak"}, }...) ss = append(ss, "{"+rs.Join()+"}") } @@ -104,9 +105,9 @@ func formatListOpt(vs list, isRoot, allowMulti bool) string { } } -type methodAndName struct { - method reflect.Value - name string +type attrAndName struct { + attr any + name string } func FormatDesc(s fmt.State, r rune, t protoreflect.Descriptor) { @@ -126,58 +127,58 @@ func formatDescOpt(t protoreflect.Descriptor, isRoot, allowMulti bool, record fu start = rt.Name() + "{" } - _, isFile := t.(protoreflect.FileDescriptor) + fd, isFile := t.(protoreflect.FileDescriptor) rs := records{ allowMulti: allowMulti, record: record, } if t.IsPlaceholder() { if isFile { - rs.Append(rv, []methodAndName{ - {rv.MethodByName("Path"), "Path"}, - {rv.MethodByName("Package"), "Package"}, - {rv.MethodByName("IsPlaceholder"), "IsPlaceholder"}, + rs.Append(rv, []attrAndName{ + {fd.Path(), "Path"}, + {fd.Package(), "Package"}, + {fd.IsPlaceholder(), "IsPlaceholder"}, }...) } else { - rs.Append(rv, []methodAndName{ - {rv.MethodByName("FullName"), "FullName"}, - {rv.MethodByName("IsPlaceholder"), "IsPlaceholder"}, + rs.Append(rv, []attrAndName{ + {t.FullName(), "FullName"}, + {t.IsPlaceholder(), "IsPlaceholder"}, }...) } } else { switch { case isFile: - rs.Append(rv, methodAndName{rv.MethodByName("Syntax"), "Syntax"}) + rs.Append(rv, attrAndName{fd.Syntax(), "Syntax"}) case isRoot: - rs.Append(rv, []methodAndName{ - {rv.MethodByName("Syntax"), "Syntax"}, - {rv.MethodByName("FullName"), "FullName"}, + rs.Append(rv, []attrAndName{ + {t.Syntax(), "Syntax"}, + {t.FullName(), "FullName"}, }...) default: - rs.Append(rv, methodAndName{rv.MethodByName("Name"), "Name"}) + rs.Append(rv, attrAndName{t.Name(), "Name"}) } switch t := t.(type) { case protoreflect.FieldDescriptor: - accessors := []methodAndName{ - {rv.MethodByName("Number"), "Number"}, - {rv.MethodByName("Cardinality"), "Cardinality"}, - {rv.MethodByName("Kind"), "Kind"}, - {rv.MethodByName("HasJSONName"), "HasJSONName"}, - {rv.MethodByName("JSONName"), "JSONName"}, - {rv.MethodByName("HasPresence"), "HasPresence"}, - {rv.MethodByName("IsExtension"), "IsExtension"}, - {rv.MethodByName("IsPacked"), "IsPacked"}, - {rv.MethodByName("IsWeak"), "IsWeak"}, - {rv.MethodByName("IsList"), "IsList"}, - {rv.MethodByName("IsMap"), "IsMap"}, - {rv.MethodByName("MapKey"), "MapKey"}, - {rv.MethodByName("MapValue"), "MapValue"}, - {rv.MethodByName("HasDefault"), "HasDefault"}, - {rv.MethodByName("Default"), "Default"}, - {rv.MethodByName("ContainingOneof"), "ContainingOneof"}, - {rv.MethodByName("ContainingMessage"), "ContainingMessage"}, - {rv.MethodByName("Message"), "Message"}, - {rv.MethodByName("Enum"), "Enum"}, + accessors := []attrAndName{ + {t.Number(), "Number"}, + {t.Cardinality(), "Cardinality"}, + {t.Kind(), "Kind"}, + {t.HasJSONName(), "HasJSONName"}, + {t.JSONName(), "JSONName"}, + {t.HasPresence(), "HasPresence"}, + {t.IsExtension(), "IsExtension"}, + {t.IsPacked(), "IsPacked"}, + {t.IsWeak(), "IsWeak"}, + {t.IsList(), "IsList"}, + {t.IsMap(), "IsMap"}, + {t.MapKey(), "MapKey"}, + {t.MapValue(), "MapValue"}, + {t.HasDefault(), "HasDefault"}, + {t.Default(), "Default"}, + {t.ContainingOneof(), "ContainingOneof"}, + {t.ContainingMessage(), "ContainingMessage"}, + {t.Message(), "Message"}, + {t.Enum(), "Enum"}, } for _, s := range accessors { switch s.name { @@ -223,58 +224,54 @@ func formatDescOpt(t protoreflect.Descriptor, isRoot, allowMulti bool, record fu } case protoreflect.FileDescriptor: - rs.Append(rv, []methodAndName{ - {rv.MethodByName("Path"), "Path"}, - {rv.MethodByName("Package"), "Package"}, - {rv.MethodByName("Imports"), "Imports"}, - {rv.MethodByName("Messages"), "Messages"}, - {rv.MethodByName("Enums"), "Enums"}, - {rv.MethodByName("Extensions"), "Extensions"}, - {rv.MethodByName("Services"), "Services"}, + rs.Append(rv, []attrAndName{ + {t.Path(), "Path"}, + {t.Package(), "Package"}, + {t.Imports(), "Imports"}, + {t.Messages(), "Messages"}, + {t.Enums(), "Enums"}, + {t.Extensions(), "Extensions"}, + {t.Services(), "Services"}, }...) case protoreflect.MessageDescriptor: - rs.Append(rv, []methodAndName{ - {rv.MethodByName("IsMapEntry"), "IsMapEntry"}, - {rv.MethodByName("Fields"), "Fields"}, - {rv.MethodByName("Oneofs"), "Oneofs"}, - {rv.MethodByName("ReservedNames"), "ReservedNames"}, - {rv.MethodByName("ReservedRanges"), "ReservedRanges"}, - {rv.MethodByName("RequiredNumbers"), "RequiredNumbers"}, - {rv.MethodByName("ExtensionRanges"), "ExtensionRanges"}, - {rv.MethodByName("Messages"), "Messages"}, - {rv.MethodByName("Enums"), "Enums"}, - {rv.MethodByName("Extensions"), "Extensions"}, + rs.Append(rv, []attrAndName{ + {t.IsMapEntry(), "IsMapEntry"}, + {t.Fields(), "Fields"}, + {t.Oneofs(), "Oneofs"}, + {t.ReservedNames(), "ReservedNames"}, + {t.ReservedRanges(), "ReservedRanges"}, + {t.RequiredNumbers(), "RequiredNumbers"}, + {t.ExtensionRanges(), "ExtensionRanges"}, + {t.Messages(), "Messages"}, + {t.Enums(), "Enums"}, + {t.Extensions(), "Extensions"}, }...) case protoreflect.EnumDescriptor: - rs.Append(rv, []methodAndName{ - {rv.MethodByName("Values"), "Values"}, - {rv.MethodByName("ReservedNames"), "ReservedNames"}, - {rv.MethodByName("ReservedRanges"), "ReservedRanges"}, - {rv.MethodByName("IsClosed"), "IsClosed"}, + rs.Append(rv, []attrAndName{ + {t.Values(), "Values"}, + {t.ReservedNames(), "ReservedNames"}, + {t.ReservedRanges(), "ReservedRanges"}, + {t.IsClosed(), "IsClosed"}, }...) case protoreflect.EnumValueDescriptor: - rs.Append(rv, []methodAndName{ - {rv.MethodByName("Number"), "Number"}, - }...) + rs.Append(rv, attrAndName{t.Number(), "Number"}) case protoreflect.ServiceDescriptor: - rs.Append(rv, []methodAndName{ - {rv.MethodByName("Methods"), "Methods"}, - }...) + rs.Append(rv, attrAndName{t.Methods(), "Methods"}) case protoreflect.MethodDescriptor: - rs.Append(rv, []methodAndName{ - {rv.MethodByName("Input"), "Input"}, - {rv.MethodByName("Output"), "Output"}, - {rv.MethodByName("IsStreamingClient"), "IsStreamingClient"}, - {rv.MethodByName("IsStreamingServer"), "IsStreamingServer"}, + rs.Append(rv, []attrAndName{ + {t.Input(), "Input"}, + {t.Output(), "Output"}, + {t.IsStreamingClient(), "IsStreamingClient"}, + {t.IsStreamingServer(), "IsStreamingServer"}, }...) } - if m := rv.MethodByName("GoType"); m.IsValid() { - rs.Append(rv, methodAndName{m, "GoType"}) + if m, ok := t.(interface{ GoType() reflect.Type }); ok { + rs.Append(rv, attrAndName{m.GoType(), "GoType"}) } } return start + rs.Join() + end @@ -297,68 +294,66 @@ func (rs *records) AppendRecs(fieldName string, newRecs [2]string) { rs.recs = append(rs.recs, newRecs) } -func (rs *records) Append(v reflect.Value, accessors ...methodAndName) { - for _, a := range accessors { - if rs.record != nil { - rs.record(a.name) - } - var rv reflect.Value - if a.method.IsValid() { - rv = a.method.Call(nil)[0] - } - if v.Kind() == reflect.Struct && !rv.IsValid() { - rv = v.FieldByName(a.name) - } - if !rv.IsValid() { - panic(fmt.Sprintf("unknown accessor: %v.%s", v.Type(), a.name)) - } - if _, ok := rv.Interface().(protoreflect.Value); ok { - rv = rv.MethodByName("Interface").Call(nil)[0] - if !rv.IsNil() { - rv = rv.Elem() - } - } +func (rs *records) Append(v reflect.Value, results ...attrAndName) { + for _, r := range results { + rs.appendAttribute(v, r.name, r.attr) + } +} - // Ignore zero values. - var isZero bool - switch rv.Kind() { - case reflect.Interface, reflect.Slice: - isZero = rv.IsNil() - case reflect.Bool: - isZero = rv.Bool() == false - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - isZero = rv.Int() == 0 - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: - isZero = rv.Uint() == 0 - case reflect.String: - isZero = rv.String() == "" - } - if n, ok := rv.Interface().(list); ok { - isZero = n.Len() == 0 - } - if isZero { - continue +func (rs *records) appendAttribute(val reflect.Value, name string, attrVal any) { + if rs.record != nil { + rs.record(name) + } + if attrVal == nil { + return + } + rv := reflect.ValueOf(attrVal) + if _, ok := rv.Interface().(protoreflect.Value); ok { + rv = rv.MethodByName("Interface").Call(nil)[0] + if !rv.IsNil() { + rv = rv.Elem() } + } - // Format the value. - var s string - v := rv.Interface() - switch v := v.(type) { - case list: - s = formatListOpt(v, false, rs.allowMulti) - case protoreflect.FieldDescriptor, protoreflect.OneofDescriptor, protoreflect.EnumValueDescriptor, protoreflect.MethodDescriptor: - s = string(v.(protoreflect.Descriptor).Name()) - case protoreflect.Descriptor: - s = string(v.FullName()) - case string: - s = strconv.Quote(v) - case []byte: - s = fmt.Sprintf("%q", v) - default: - s = fmt.Sprint(v) - } - rs.recs = append(rs.recs, [2]string{a.name, s}) + // Ignore zero values. + var isZero bool + switch rv.Kind() { + case reflect.Interface, reflect.Slice: + isZero = rv.IsNil() + case reflect.Bool: + isZero = rv.Bool() == false + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + isZero = rv.Int() == 0 + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + isZero = rv.Uint() == 0 + case reflect.String: + isZero = rv.String() == "" + } + if n, ok := rv.Interface().(list); ok { + isZero = n.Len() == 0 + } + if isZero { + return + } + + // Format the value. + var s string + v := rv.Interface() + switch v := v.(type) { + case list: + s = formatListOpt(v, false, rs.allowMulti) + case protoreflect.FieldDescriptor, protoreflect.OneofDescriptor, protoreflect.EnumValueDescriptor, protoreflect.MethodDescriptor: + s = string(v.(protoreflect.Descriptor).Name()) + case protoreflect.Descriptor: + s = string(v.FullName()) + case string: + s = strconv.Quote(v) + case []byte: + s = fmt.Sprintf("%q", v) + default: + s = fmt.Sprint(v) } + rs.recs = append(rs.recs, [2]string{name, s}) } func (rs *records) Join() string { diff --git a/vendor/google.golang.org/protobuf/internal/editiondefaults/editions_defaults.binpb b/vendor/google.golang.org/protobuf/internal/editiondefaults/editions_defaults.binpb index 04696351eeeef14cbbd69fd1f4250530b1fbfd56..ad35ea4c449a6b23a78974a905b3fcba120223c6 100644 GIT binary patch delta 50 zcmbQmxSw&t6m2eLiGDvNNe)H>4lG0U`MWs{jB1 diff --git a/vendor/google.golang.org/protobuf/internal/encoding/defval/default.go b/vendor/google.golang.org/protobuf/internal/encoding/defval/default.go index 328dc733..079a53dd 100644 --- a/vendor/google.golang.org/protobuf/internal/encoding/defval/default.go +++ b/vendor/google.golang.org/protobuf/internal/encoding/defval/default.go @@ -69,19 +69,19 @@ func Unmarshal(s string, k protoreflect.Kind, evs protoreflect.EnumValueDescript } } case protoreflect.Int32Kind, protoreflect.Sint32Kind, protoreflect.Sfixed32Kind: - if v, err := strconv.ParseInt(s, 10, 32); err == nil { + if v, err := strconv.ParseInt(s, 0, 32); err == nil { return protoreflect.ValueOfInt32(int32(v)), nil, nil } case protoreflect.Int64Kind, protoreflect.Sint64Kind, protoreflect.Sfixed64Kind: - if v, err := strconv.ParseInt(s, 10, 64); err == nil { + if v, err := strconv.ParseInt(s, 0, 64); err == nil { return protoreflect.ValueOfInt64(int64(v)), nil, nil } case protoreflect.Uint32Kind, protoreflect.Fixed32Kind: - if v, err := strconv.ParseUint(s, 10, 32); err == nil { + if v, err := strconv.ParseUint(s, 0, 32); err == nil { return protoreflect.ValueOfUint32(uint32(v)), nil, nil } case protoreflect.Uint64Kind, protoreflect.Fixed64Kind: - if v, err := strconv.ParseUint(s, 10, 64); err == nil { + if v, err := strconv.ParseUint(s, 0, 64); err == nil { return protoreflect.ValueOfUint64(uint64(v)), nil, nil } case protoreflect.FloatKind, protoreflect.DoubleKind: diff --git a/vendor/google.golang.org/protobuf/internal/genid/descriptor_gen.go b/vendor/google.golang.org/protobuf/internal/genid/descriptor_gen.go index 65aaf4d2..58aeff84 100644 --- a/vendor/google.golang.org/protobuf/internal/genid/descriptor_gen.go +++ b/vendor/google.golang.org/protobuf/internal/genid/descriptor_gen.go @@ -26,6 +26,7 @@ const ( Edition_EDITION_PROTO3_enum_value = 999 Edition_EDITION_2023_enum_value = 1000 Edition_EDITION_2024_enum_value = 1001 + Edition_EDITION_2026_enum_value = 1002 Edition_EDITION_UNSTABLE_enum_value = 9999 Edition_EDITION_1_TEST_ONLY_enum_value = 1 Edition_EDITION_2_TEST_ONLY_enum_value = 2 @@ -806,11 +807,13 @@ const ( FieldOptions_FeatureSupport_EditionDeprecated_field_name protoreflect.Name = "edition_deprecated" FieldOptions_FeatureSupport_DeprecationWarning_field_name protoreflect.Name = "deprecation_warning" FieldOptions_FeatureSupport_EditionRemoved_field_name protoreflect.Name = "edition_removed" + FieldOptions_FeatureSupport_RemovalError_field_name protoreflect.Name = "removal_error" FieldOptions_FeatureSupport_EditionIntroduced_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.FeatureSupport.edition_introduced" FieldOptions_FeatureSupport_EditionDeprecated_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.FeatureSupport.edition_deprecated" FieldOptions_FeatureSupport_DeprecationWarning_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.FeatureSupport.deprecation_warning" FieldOptions_FeatureSupport_EditionRemoved_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.FeatureSupport.edition_removed" + FieldOptions_FeatureSupport_RemovalError_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.FeatureSupport.removal_error" ) // Field numbers for google.protobuf.FieldOptions.FeatureSupport. @@ -819,6 +822,7 @@ const ( FieldOptions_FeatureSupport_EditionDeprecated_field_number protoreflect.FieldNumber = 2 FieldOptions_FeatureSupport_DeprecationWarning_field_number protoreflect.FieldNumber = 3 FieldOptions_FeatureSupport_EditionRemoved_field_number protoreflect.FieldNumber = 4 + FieldOptions_FeatureSupport_RemovalError_field_number protoreflect.FieldNumber = 5 ) // Names for google.protobuf.OneofOptions. @@ -1152,6 +1156,7 @@ const ( FeatureSet_ENFORCE_NAMING_STYLE_UNKNOWN_enum_value = 0 FeatureSet_STYLE2024_enum_value = 1 FeatureSet_STYLE_LEGACY_enum_value = 2 + FeatureSet_STYLE2026_enum_value = 3 ) // Names for google.protobuf.FeatureSet.VisibilityFeature. diff --git a/vendor/google.golang.org/protobuf/internal/version/version.go b/vendor/google.golang.org/protobuf/internal/version/version.go index 763fd828..58ff0e24 100644 --- a/vendor/google.golang.org/protobuf/internal/version/version.go +++ b/vendor/google.golang.org/protobuf/internal/version/version.go @@ -52,7 +52,7 @@ import ( const ( Major = 1 Minor = 36 - Patch = 11 + Patch = 12 PreRelease = "" ) diff --git a/vendor/google.golang.org/protobuf/reflect/protoreflect/source_gen.go b/vendor/google.golang.org/protobuf/reflect/protoreflect/source_gen.go index 730331e6..86f0d092 100644 --- a/vendor/google.golang.org/protobuf/reflect/protoreflect/source_gen.go +++ b/vendor/google.golang.org/protobuf/reflect/protoreflect/source_gen.go @@ -546,6 +546,8 @@ func (p *SourcePath) appendFieldOptions_FeatureSupport(b []byte) []byte { b = p.appendSingularField(b, "deprecation_warning", nil) case 4: b = p.appendSingularField(b, "edition_removed", nil) + case 5: + b = p.appendSingularField(b, "removal_error", nil) } return b } diff --git a/vendor/google.golang.org/protobuf/types/known/anypb/any.pb.go b/vendor/google.golang.org/protobuf/types/known/anypb/any.pb.go index 1ff0d149..510894f2 100644 --- a/vendor/google.golang.org/protobuf/types/known/anypb/any.pb.go +++ b/vendor/google.golang.org/protobuf/types/known/anypb/any.pb.go @@ -128,120 +128,66 @@ import ( // `Any` contains an arbitrary serialized protocol buffer message along with a // URL that describes the type of the serialized message. // -// Protobuf library provides support to pack/unpack Any values in the form -// of utility functions or additional generated methods of the Any type. -// -// Example 1: Pack and unpack a message in C++. -// -// Foo foo = ...; -// Any any; -// any.PackFrom(foo); -// ... -// if (any.UnpackTo(&foo)) { -// ... -// } -// -// Example 2: Pack and unpack a message in Java. -// -// Foo foo = ...; -// Any any = Any.pack(foo); -// ... -// if (any.is(Foo.class)) { -// foo = any.unpack(Foo.class); -// } -// // or ... -// if (any.isSameTypeAs(Foo.getDefaultInstance())) { -// foo = any.unpack(Foo.getDefaultInstance()); -// } -// -// Example 3: Pack and unpack a message in Python. -// -// foo = Foo(...) -// any = Any() -// any.Pack(foo) -// ... -// if any.Is(Foo.DESCRIPTOR): -// any.Unpack(foo) -// ... -// -// Example 4: Pack and unpack a message in Go -// -// foo := &pb.Foo{...} -// any, err := anypb.New(foo) -// if err != nil { -// ... -// } -// ... -// foo := &pb.Foo{} -// if err := any.UnmarshalTo(foo); err != nil { -// ... -// } -// -// The pack methods provided by protobuf library will by default use -// 'type.googleapis.com/full.type.name' as the type URL and the unpack -// methods only use the fully qualified type name after the last '/' -// in the type URL, for example "foo.bar.com/x/y.z" will yield type -// name "y.z". -// -// JSON -// ==== -// The JSON representation of an `Any` value uses the regular -// representation of the deserialized, embedded message, with an -// additional field `@type` which contains the type URL. Example: -// -// package google.profile; -// message Person { -// string first_name = 1; -// string last_name = 2; -// } -// -// { -// "@type": "type.googleapis.com/google.profile.Person", -// "firstName": , -// "lastName": -// } -// -// If the embedded message type is well-known and has a custom JSON -// representation, that representation will be embedded adding a field -// `value` which holds the custom JSON in addition to the `@type` -// field. Example (for message [google.protobuf.Duration][]): -// -// { -// "@type": "type.googleapis.com/google.protobuf.Duration", -// "value": "1.212s" -// } +// In its binary encoding, an `Any` is an ordinary message; but in other wire +// forms like JSON, it has a special encoding. The format of the type URL is +// described on the `type_url` field. +// +// Protobuf APIs provide utilities to interact with `Any` values: +// +// - A 'pack' operation accepts a message and constructs a generic `Any` wrapper +// around it. +// - An 'unpack' operation reads the content of an `Any` message, either into an +// existing message or a new one. Unpack operations must check the type of the +// value they unpack against the declared `type_url`. +// - An 'is' operation decides whether an `Any` contains a message of the given +// type, i.e. whether it can 'unpack' that type. +// +// The JSON format representation of an `Any` follows one of these cases: +// +// - For types without special-cased JSON encodings, the JSON format +// representation of the `Any` is the same as that of the message, with an +// additional `@type` field which contains the type URL. +// - For types with special-cased JSON encodings (typically called 'well-known' +// types, listed in https://protobuf.dev/programming-guides/json/#any), the +// JSON format representation has a key `@type` which contains the type URL +// and a key `value` which contains the JSON-serialized value. +// +// The text format representation of an `Any` is like a message with one field +// whose name is the type URL in brackets. For example, an `Any` containing a +// `foo.Bar` message may be written `[type.googleapis.com/foo.Bar] { a: 2 }`. type Any struct { state protoimpl.MessageState `protogen:"open.v1"` - // A URL/resource name that uniquely identifies the type of the serialized - // protocol buffer message. This string must contain at least - // one "/" character. The last segment of the URL's path must represent - // the fully qualified name of the type (as in - // `path/google.protobuf.Duration`). The name should be in a canonical form - // (e.g., leading "." is not accepted). + // Identifies the type of the serialized Protobuf message with a URI reference + // consisting of a prefix ending in a slash and the fully-qualified type name. + // + // Example: type.googleapis.com/google.protobuf.StringValue // - // In practice, teams usually precompile into the binary all types that they - // expect it to use in the context of Any. However, for URLs which use the - // scheme `http`, `https`, or no scheme, one can optionally set up a type - // server that maps type URLs to message definitions as follows: + // This string must contain at least one `/` character, and the content after + // the last `/` must be the fully-qualified name of the type in canonical + // form, without a leading dot. Do not write a scheme on these URI references + // so that clients do not attempt to contact them. // - // - If no scheme is provided, `https` is assumed. - // - An HTTP GET on the URL must yield a [google.protobuf.Type][] - // value in binary format, or produce an error. - // - Applications are allowed to cache lookup results based on the - // URL, or have them precompiled into a binary to avoid any - // lookup. Therefore, binary compatibility needs to be preserved - // on changes to types. (Use versioned type names to manage - // breaking changes.) + // The prefix is arbitrary and Protobuf implementations are expected to + // simply strip off everything up to and including the last `/` to identify + // the type. `type.googleapis.com/` is a common default prefix that some + // legacy implementations require. This prefix does not indicate the origin of + // the type, and URIs containing it are not expected to respond to any + // requests. // - // Note: this functionality is not currently available in the official - // protobuf release, and it is not used for type URLs beginning with - // type.googleapis.com. As of May 2023, there are no widely used type server - // implementations and no plans to implement one. + // All type URL strings must be legal URI references with the additional + // restriction (for the text format) that the content of the reference + // must consist only of alphanumeric characters, percent-encoded escapes, and + // characters in the following set (not including the outer backticks): + // `/-.~_!$&()*+,;=`. Despite our allowing percent encodings, implementations + // should not unescape them to prevent confusion with existing parsers. For + // example, `type.googleapis.com%2FFoo` should be rejected. // - // Schemes other than `http`, `https` (or the empty scheme) might be - // used with implementation specific semantics. + // In the original design of `Any`, the possibility of launching a type + // resolution service at these type URLs was considered but Protobuf never + // implemented one and considers contacting these URLs to be problematic and + // a potential security issue. Do not attempt to contact type URLs. TypeUrl string `protobuf:"bytes,1,opt,name=type_url,json=typeUrl,proto3" json:"type_url,omitempty"` - // Must be a valid serialized protocol buffer of the above specified type. + // Holds a Protobuf serialization of the type described by type_url. Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache diff --git a/vendor/google.golang.org/protobuf/types/known/timestamppb/timestamp.pb.go b/vendor/google.golang.org/protobuf/types/known/timestamppb/timestamp.pb.go index 484c21fd..2cd60946 100644 --- a/vendor/google.golang.org/protobuf/types/known/timestamppb/timestamp.pb.go +++ b/vendor/google.golang.org/protobuf/types/known/timestamppb/timestamp.pb.go @@ -153,8 +153,8 @@ import ( // {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional // seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), // are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone -// is required. A proto3 JSON serializer should always use UTC (as indicated by -// "Z") when printing the Timestamp type and a proto3 JSON parser should be +// is required. A ProtoJSON serializer should always use UTC (as indicated by +// "Z") when printing the Timestamp type and a ProtoJSON parser should be // able to accept both UTC and other timezones (as indicated by an offset). // // For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past @@ -173,7 +173,7 @@ import ( type Timestamp struct { state protoimpl.MessageState `protogen:"open.v1"` // Represents seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z. Must - // be between -315576000000 and 315576000000 inclusive (which corresponds to + // be between -62135596800 and 253402300799 inclusive (which corresponds to // 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z). Seconds int64 `protobuf:"varint,1,opt,name=seconds,proto3" json:"seconds,omitempty"` // Non-negative fractions of a second at nanosecond resolution. This field is diff --git a/vendor/modules.txt b/vendor/modules.txt index e197e28c..e053fe7e 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -7,7 +7,7 @@ # charm.land/lipgloss/v2 v2.0.3 ## explicit; go 1.25.0 charm.land/lipgloss/v2 -# code.cloudfoundry.org/credhub-cli v0.0.0-20260727130059-9e78db728bcf +# code.cloudfoundry.org/credhub-cli v0.0.0-20260817130202-803f4962b541 ## explicit; go 1.25.7 code.cloudfoundry.org/credhub-cli/credhub code.cloudfoundry.org/credhub-cli/credhub/auth @@ -432,7 +432,7 @@ github.com/clipperhouse/uax29/v2/graphemes # github.com/cloudfoundry/go-socks5 v0.0.0-20250423223041-4ad5fea42851 ## explicit; go 1.21.0 github.com/cloudfoundry/go-socks5 -# github.com/cloudfoundry/socks5-proxy v0.2.183 +# github.com/cloudfoundry/socks5-proxy v0.2.185 ## explicit; go 1.25.0 github.com/cloudfoundry/socks5-proxy # github.com/containerd/errdefs v1.0.0 @@ -902,8 +902,8 @@ github.com/google/go-containerregistry/pkg/v1/stream github.com/google/go-containerregistry/pkg/v1/tarball github.com/google/go-containerregistry/pkg/v1/types github.com/google/go-containerregistry/pkg/v1/validate -# github.com/google/pprof v0.0.0-20260709232956-b9395ee17fa0 -## explicit; go 1.24.0 +# github.com/google/pprof v0.0.0-20260802141513-ef3492d7dac3 +## explicit; go 1.25.0 github.com/google/pprof/profile # github.com/google/uuid v1.6.0 ## explicit @@ -1190,7 +1190,7 @@ github.com/nunnatsa/ginkgolinter/internal/rules github.com/nunnatsa/ginkgolinter/internal/typecheck github.com/nunnatsa/ginkgolinter/linter github.com/nunnatsa/ginkgolinter/version -# github.com/onsi/ginkgo/v2 v2.32.0 +# github.com/onsi/ginkgo/v2 v2.32.1 ## explicit; go 1.25.0 github.com/onsi/ginkgo/v2 github.com/onsi/ginkgo/v2/config @@ -1579,7 +1579,7 @@ go.yaml.in/yaml/v2 # go.yaml.in/yaml/v3 v3.0.5 ## explicit; go 1.16 go.yaml.in/yaml/v3 -# golang.org/x/crypto v0.54.0 +# golang.org/x/crypto v0.55.0 ## explicit; go 1.25.0 golang.org/x/crypto/blowfish golang.org/x/crypto/chacha20 @@ -1601,14 +1601,14 @@ golang.org/x/exp/slog/internal/buffer # golang.org/x/exp/typeparams v0.0.0-20260209203927-2842357ff358 ## explicit; go 1.24.0 golang.org/x/exp/typeparams -# golang.org/x/mod v0.38.0 +# golang.org/x/mod v0.40.0 ## explicit; go 1.25.0 golang.org/x/mod/internal/lazyregexp golang.org/x/mod/modfile golang.org/x/mod/module golang.org/x/mod/semver golang.org/x/mod/sumdb/dirhash -# golang.org/x/net v0.57.0 +# golang.org/x/net v0.58.0 ## explicit; go 1.25.0 golang.org/x/net/context golang.org/x/net/html @@ -1630,7 +1630,7 @@ golang.org/x/sys/windows/registry # golang.org/x/term v0.45.0 ## explicit; go 1.25.0 golang.org/x/term -# golang.org/x/text v0.40.0 +# golang.org/x/text v0.41.0 ## explicit; go 1.25.0 golang.org/x/text/encoding golang.org/x/text/encoding/charmap @@ -1659,7 +1659,7 @@ golang.org/x/text/runes golang.org/x/text/transform golang.org/x/text/unicode/norm golang.org/x/text/width -# golang.org/x/tools v0.48.0 +# golang.org/x/tools v0.49.0 ## explicit; go 1.25.0 golang.org/x/tools/cover golang.org/x/tools/go/analysis @@ -1748,6 +1748,7 @@ golang.org/x/tools/internal/gopathwalk golang.org/x/tools/internal/imports golang.org/x/tools/internal/modindex golang.org/x/tools/internal/moreiters +golang.org/x/tools/internal/moremaps golang.org/x/tools/internal/packagepath golang.org/x/tools/internal/packagesinternal golang.org/x/tools/internal/pkgbits @@ -1759,7 +1760,7 @@ golang.org/x/tools/internal/typesinternal golang.org/x/tools/internal/typesinternal/typeindex golang.org/x/tools/internal/versions golang.org/x/tools/refactor/satisfy -# google.golang.org/protobuf v1.36.11 +# google.golang.org/protobuf v1.36.12 ## explicit; go 1.23 google.golang.org/protobuf/encoding/protodelim google.golang.org/protobuf/encoding/prototext