From b60521b9bf7748d0adb5dc73de0b15783e6ab203 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 2 Dec 2026 02:40:05 +0000 Subject: [PATCH] fix(deps): update patch updates --- go.mod | 90 +- go.sum | 188 +-- vendor/cloud.google.com/go/auth/CHANGES.md | 9 + .../go/auth/internal/internal.go | 40 +- .../go/auth/internal/version.go | 2 +- .../sdk/storage/azblob/CHANGELOG.md | 5 + .../sdk/storage/azblob/blob/client.go | 16 +- .../azblob/internal/exported/version.go | 2 +- .../aws-sdk-go-v2/aws/go_module_metadata.go | 2 +- .../aws/middleware/user_agent.go | 4 + .../aws/protocol/eventstream/CHANGELOG.md | 10 + .../aws/protocol/eventstream/encode.go | 21 + .../eventstream/go_module_metadata.go | 2 +- .../aws/protocol/eventstream/message.go | 19 +- .../aws/aws-sdk-go-v2/config/CHANGELOG.md | 18 + .../config/go_module_metadata.go | 2 +- .../aws-sdk-go-v2/credentials/CHANGELOG.md | 18 + .../credentials/go_module_metadata.go | 2 +- .../feature/ec2/imds/CHANGELOG.md | 14 + .../feature/ec2/imds/go_module_metadata.go | 2 +- .../internal/configsources/CHANGELOG.md | 14 + .../configsources/go_module_metadata.go | 2 +- .../internal/endpoints/v2/CHANGELOG.md | 14 + .../endpoints/v2/go_module_metadata.go | 2 +- .../internal/sync/singleflight/LICENSE | 3 +- .../aws-sdk-go-v2/internal/v4a/CHANGELOG.md | 14 + .../internal/v4a/go_module_metadata.go | 2 +- .../aws-sdk-go-v2/service/ecs/CHANGELOG.md | 14 + .../service/ecs/go_module_metadata.go | 2 +- .../service/elasticloadbalancing/CHANGELOG.md | 14 + .../go_module_metadata.go | 2 +- .../elasticloadbalancingv2/CHANGELOG.md | 14 + .../go_module_metadata.go | 2 +- .../internal/accept-encoding/CHANGELOG.md | 8 + .../accept-encoding/go_module_metadata.go | 2 +- .../service/internal/checksum/CHANGELOG.md | 14 + .../internal/checksum/go_module_metadata.go | 2 +- .../internal/presigned-url/CHANGELOG.md | 14 + .../presigned-url/go_module_metadata.go | 2 +- .../service/internal/s3shared/CHANGELOG.md | 14 + .../internal/s3shared/go_module_metadata.go | 2 +- .../service/pricing/CHANGELOG.md | 14 + .../service/pricing/go_module_metadata.go | 2 +- .../aws-sdk-go-v2/service/signin/CHANGELOG.md | 14 + .../service/signin/go_module_metadata.go | 2 +- .../aws-sdk-go-v2/service/sso/CHANGELOG.md | 14 + .../service/sso/go_module_metadata.go | 2 +- .../service/ssooidc/CHANGELOG.md | 14 + .../service/ssooidc/go_module_metadata.go | 2 +- .../aws-sdk-go-v2/service/sts/CHANGELOG.md | 18 + .../service/sts/api_op_GetCertificate.go | 233 ++++ .../sts/api_op_GetScopedCredentials.go | 10 +- .../service/sts/api_op_GetTrustBundles.go | 155 +++ .../service/sts/api_op_GetWebIdentityToken.go | 88 +- .../api_op_IssueWorkloadIdentityContext.go | 265 ++++ .../aws-sdk-go-v2/service/sts/common_serde.go | 32 + .../aws-sdk-go-v2/service/sts/generated.json | 3 + .../service/sts/go_module_metadata.go | 2 +- .../service/sts/schemas/schemas.go | 386 +++++- .../service/sts/type_registry.go | 24 + .../service/sts/types/common_serde.go | 32 + .../aws-sdk-go-v2/service/sts/types/enums.go | 75 ++ .../aws-sdk-go-v2/service/sts/types/errors.go | 357 +++++ .../aws-sdk-go-v2/service/sts/types/types.go | 60 + .../aws-sdk-go-v2/service/sts/validators.go | 117 ++ vendor/github.com/aws/smithy-go/CHANGELOG.md | 40 + .../aws/smithy-go/eventstream/encode.go | 21 + .../aws/smithy-go/eventstream/message.go | 19 +- .../aws/smithy-go/go_module_metadata.go | 2 +- .../internal/sync/singleflight/LICENSE | 3 +- .../internal/json/shape_deserializer.go | 14 +- .../http/protocol/internal/xml/error.go | 9 +- .../go-git/go-git/v6/.golangci.yaml | 7 + .../go-git/go-git/v6/.renovaterc.json5 | 8 +- vendor/github.com/go-git/go-git/v6/AGENTS.md | 65 +- .../go-git/go-git/v6/COMPATIBILITY.md | 2 +- .../go-git/go-git/v6/CONTRIBUTING.md | 59 +- vendor/github.com/go-git/go-git/v6/Makefile | 2 +- .../github.com/go-git/go-git/v6/SECURITY.md | 38 - .../go-git/go-git/v6/config/config.go | 14 + .../go-git/go-git/v6/config/modules.go | 70 +- .../v6/internal/packhandle/cursor_reader.go | 9 + .../go-git/v6/internal/pathutil/dotdot.go | 68 + .../go-git/v6/internal/pathutil/dotgit.go | 9 +- .../go-git/go-git/v6/internal/pathutil/hfs.go | 29 +- .../go-git/v6/internal/pathutil/ntfs.go | 304 +++-- .../go-git/v6/internal/pathutil/tree.go | 86 +- .../go-git/v6/internal/pathutil/volume.go | 157 +++ .../v6/{utils => internal}/sync/bufio.go | 5 +- .../v6/{utils => internal}/sync/bytes.go | 0 .../v6/{utils => internal}/sync/zlib.go | 2 +- .../go-git/v6/internal/transport/drain.go | 52 + .../v6/internal/transport/read_finished.go | 39 + .../go-git/go-git/v6/internal/transport/v2.go | 85 +- vendor/github.com/go-git/go-git/v6/options.go | 26 +- .../go-git/v6/plumbing/filemode/filemode.go | 63 +- .../go-git/v6/plumbing/format/config/doc.go | 130 +- .../v6/plumbing/format/config/encoder.go | 94 +- .../v6/plumbing/format/config/format.go | 37 +- .../v6/plumbing/format/config/section.go | 24 +- .../v6/plumbing/format/gitignore/pattern.go | 13 + .../v6/plumbing/format/idxfile/decoder.go | 29 +- .../go-git/v6/plumbing/format/idxfile/doc.go | 134 +- .../v6/plumbing/format/idxfile/lazy_index.go | 5 +- .../v6/plumbing/format/idxfile/writer.go | 12 +- .../v6/plumbing/format/index/decoder.go | 10 +- .../go-git/v6/plumbing/format/index/doc.go | 421 +----- .../v6/plumbing/format/objfile/reader.go | 2 +- .../v6/plumbing/format/objfile/writer.go | 2 +- .../v6/plumbing/format/packfile/common.go | 33 +- .../v6/plumbing/format/packfile/diff_delta.go | 2 +- .../go-git/v6/plumbing/format/packfile/doc.go | 49 +- .../v6/plumbing/format/packfile/encoder.go | 2 +- .../v6/plumbing/format/packfile/fsobject.go | 2 +- .../v6/plumbing/format/packfile/packfile.go | 61 +- .../v6/plumbing/format/packfile/parser.go | 30 +- .../plumbing/format/packfile/patch_delta.go | 18 +- .../v6/plumbing/format/packfile/scanner.go | 140 +- .../format/packfile/scanner_reader.go | 98 +- .../go-git/v6/plumbing/format/revfile/doc.go | 25 +- .../go-git/go-git/v6/plumbing/hash.go | 7 +- .../go-git/v6/plumbing/object/commit.go | 4 +- .../v6/plumbing/object/commit_scanner.go | 33 +- .../go-git/v6/plumbing/object/signature.go | 2 +- .../go-git/go-git/v6/plumbing/object/tag.go | 3 +- .../go-git/v6/plumbing/object/tag_scanner.go | 12 +- .../go-git/go-git/v6/plumbing/object/tree.go | 333 +++-- .../go-git/v6/plumbing/object/treenoder.go | 32 +- .../go-git/go-git/v6/plumbing/objectid.go | 57 +- .../v6/plumbing/protocol/capability/list.go | 6 +- .../v6/plumbing/protocol/packp/advrefs.go | 44 +- .../plumbing/protocol/packp/advrefs_encode.go | 11 +- .../v6/plumbing/protocol/packp/common.go | 1 + .../go-git/v6/plumbing/protocol/packp/doc.go | 736 +---------- .../v6/plumbing/protocol/packp/fetch.go | 24 +- .../v6/plumbing/protocol/packp/lsrefs.go | 133 +- .../v6/plumbing/protocol/packp/shallowupd.go | 24 +- .../plumbing/protocol/packp/sideband/demux.go | 128 +- .../plumbing/protocol/packp/sideband/muxer.go | 8 +- .../plumbing/protocol/packp/ulreq_decode.go | 33 +- .../plumbing/protocol/packp/ulreq_encode.go | 7 +- .../go-git/go-git/v6/plumbing/reference.go | 33 +- .../go-git/v6/plumbing/revlist/object_walk.go | 379 +++--- .../go-git/v6/plumbing/revlist/revlist.go | 65 + .../go-git/v6/plumbing/storer/object.go | 47 + .../go-git/v6/plumbing/transport/common.go | 8 +- .../go-git/v6/plumbing/transport/errors.go | 21 +- .../go-git/v6/plumbing/transport/fetch.go | 83 +- .../v6/plumbing/transport/http/handshake.go | 44 +- .../go-git/v6/plumbing/transport/negotiate.go | 31 +- .../v6/plumbing/transport/pack_stream.go | 75 +- .../go-git/v6/plumbing/transport/push.go | 42 +- .../go-git/v6/plumbing/transport/serve.go | 2 +- .../go-git/v6/plumbing/transport/ssh/auth.go | 28 +- .../go-git/v6/plumbing/transport/ssh/ssh.go | 24 +- .../transport/ssh/sshagent/sshagent.go | 2 +- .../ssh/sshagent/sshagent_windows.go | 8 +- .../v6/plumbing/transport/upload_pack.go | 1164 ++++++++++++----- vendor/github.com/go-git/go-git/v6/remote.go | 65 +- .../github.com/go-git/go-git/v6/repository.go | 22 +- .../go-git/go-git/v6/repository_extensions.go | 12 +- vendor/github.com/go-git/go-git/v6/signer.go | 6 + .../go-git/v6/storage/filesystem/config.go | 11 +- .../v6/storage/filesystem/dotgit/dotgit.go | 395 ++++-- .../v6/storage/filesystem/dotgit/module.go | 100 ++ .../v6/storage/filesystem/dotgit/openpack.go | 11 +- .../dotgit/repository_filesystem.go | 16 + .../v6/storage/filesystem/dotgit/writers.go | 586 +++++++-- .../go-git/v6/storage/filesystem/object.go | 106 +- .../go-git/v6/storage/filesystem/shallow.go | 22 +- .../go-git/v6/storage/filesystem/storage.go | 3 +- .../go-git/v6/storage/memory/storage.go | 10 + .../github.com/go-git/go-git/v6/submodule.go | 14 +- .../go-git/go-git/v6/utils/convert/stat.go | 122 +- .../go-git/go-git/v6/utils/ioutil/context.go | 60 +- .../go-git/go-git/v6/utils/ioutil/sync.go | 2 +- .../go-git/v6/utils/merkletrie/doubleiter.go | 30 +- .../v6/utils/merkletrie/filesystem/node.go | 42 +- .../go-git/go-git/v6/utils/merkletrie/iter.go | 15 +- .../github.com/go-git/go-git/v6/worktree.go | 596 ++++++--- .../go-git/go-git/v6/worktree_commit.go | 99 +- .../go-git/go-git/v6/worktree_fs.go | 187 ++- .../go-git/go-git/v6/worktree_status.go | 21 +- .../go-git/go-git/v6/x/plugin/config/auto.go | 2 +- .../go-git/go-git/v6/x/plugin/config/empty.go | 2 +- .../go-git/v6/x/plugin/config/static.go | 2 +- .../go-git/v6/x/plugin/plugin_config.go | 2 +- .../go-git/v6/x/plugin/plugin_signer.go | 2 +- .../go-openapi/spec/CONTRIBUTORS.md | 4 +- .../go-openapi/strfmt/CONTRIBUTORS.md | 25 +- .../go-openapi/swag/CONTRIBUTORS.md | 4 +- vendor/github.com/pjbgf/sha1cd/Makefile | 30 + .../pjbgf/sha1cd/recompress_amd64.s | 454 +++++++ .../pjbgf/sha1cd/recompress_arm64.s | 523 ++++++++ .../github.com/pjbgf/sha1cd/recompress_asm.go | 73 ++ .../pjbgf/sha1cd/sha1cdblock_amd64.go | 17 +- .../pjbgf/sha1cd/sha1cdblock_arm64.go | 18 +- .../pjbgf/sha1cd/sha1cdblock_generic.go | 200 +-- .../pjbgf/sha1cd/ubc/dvmask_amd64.go | 47 +- .../pjbgf/sha1cd/ubc/dvmask_arm64.go | 29 + .../pjbgf/sha1cd/ubc/dvmask_avx2_amd64.s | 369 ++++++ .../pjbgf/sha1cd/ubc/dvmask_avx512_amd64.s | 52 - .../sha1cd/ubc/dvmask_avx512_table_amd64.go | 111 -- .../pjbgf/sha1cd/ubc/dvmask_neon_arm64.s | 365 ++++++ .../pjbgf/sha1cd/ubc/dvmask_other.go | 2 +- vendor/github.com/pjbgf/sha1cd/ubc/tail.go | 45 + vendor/github.com/pjbgf/sha1cd/ubc/ubc.go | 343 ----- .../pjbgf/sha1cd/ubc/ubc_generated.go | 686 ++++++++++ .../google.golang.org/api/internal/version.go | 2 +- .../option/internaloption/unsaferesolver.go | 12 + .../forked/golang/reflect/deep_equal.go | 2 +- .../client-go/tools/clientcmd/api/helpers.go | 2 +- vendor/modules.txt | 90 +- 213 files changed, 10449 insertions(+), 4537 deletions(-) create mode 100644 vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_GetCertificate.go create mode 100644 vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_GetTrustBundles.go create mode 100644 vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_IssueWorkloadIdentityContext.go delete mode 100644 vendor/github.com/go-git/go-git/v6/SECURITY.md create mode 100644 vendor/github.com/go-git/go-git/v6/internal/pathutil/dotdot.go create mode 100644 vendor/github.com/go-git/go-git/v6/internal/pathutil/volume.go rename vendor/github.com/go-git/go-git/v6/{utils => internal}/sync/bufio.go (73%) rename vendor/github.com/go-git/go-git/v6/{utils => internal}/sync/bytes.go (100%) rename vendor/github.com/go-git/go-git/v6/{utils => internal}/sync/zlib.go (97%) create mode 100644 vendor/github.com/go-git/go-git/v6/internal/transport/drain.go create mode 100644 vendor/github.com/go-git/go-git/v6/internal/transport/read_finished.go create mode 100644 vendor/github.com/go-git/go-git/v6/storage/filesystem/dotgit/module.go create mode 100644 vendor/github.com/pjbgf/sha1cd/recompress_amd64.s create mode 100644 vendor/github.com/pjbgf/sha1cd/recompress_arm64.s create mode 100644 vendor/github.com/pjbgf/sha1cd/recompress_asm.go create mode 100644 vendor/github.com/pjbgf/sha1cd/ubc/dvmask_arm64.go create mode 100644 vendor/github.com/pjbgf/sha1cd/ubc/dvmask_avx2_amd64.s delete mode 100644 vendor/github.com/pjbgf/sha1cd/ubc/dvmask_avx512_amd64.s delete mode 100644 vendor/github.com/pjbgf/sha1cd/ubc/dvmask_avx512_table_amd64.go create mode 100644 vendor/github.com/pjbgf/sha1cd/ubc/dvmask_neon_arm64.s create mode 100644 vendor/github.com/pjbgf/sha1cd/ubc/tail.go create mode 100644 vendor/github.com/pjbgf/sha1cd/ubc/ubc_generated.go diff --git a/go.mod b/go.mod index b6bdc41885..81a618f0ca 100644 --- a/go.mod +++ b/go.mod @@ -15,23 +15,23 @@ require ( github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resourcegraph/armresourcegraph v0.10.0 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources/v4 v4.0.0 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armsubscriptions/v2 v2.0.0 - github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.8.3 + github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.8.4 github.com/IBM-Cloud/power-go-client v1.17.0 github.com/IBM/go-sdk-core/v5 v5.25.4 github.com/IBM/platform-services-go-sdk v0.103.6 github.com/IBM/vpc-go-sdk v0.93.0 github.com/aws/amazon-ec2-instance-selector/v3 v3.1.3 - github.com/aws/aws-sdk-go-v2 v1.48.0 - github.com/aws/aws-sdk-go-v2/config v1.33.21 + github.com/aws/aws-sdk-go-v2 v1.49.0 + github.com/aws/aws-sdk-go-v2/config v1.33.25 github.com/aws/aws-sdk-go-v2/service/ec2 v1.349.0 - github.com/aws/aws-sdk-go-v2/service/ecs v1.106.0 + github.com/aws/aws-sdk-go-v2/service/ecs v1.106.3 github.com/aws/aws-sdk-go-v2/service/eks v1.105.6 - github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing v1.42.0 - github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2 v1.65.0 + github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing v1.42.3 + github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2 v1.65.3 github.com/aws/aws-sdk-go-v2/service/iam v1.66.0 github.com/aws/aws-sdk-go-v2/service/s3 v1.115.0 - github.com/aws/aws-sdk-go-v2/service/sts v1.53.0 - github.com/aws/smithy-go v1.28.9 + github.com/aws/aws-sdk-go-v2/service/sts v1.54.0 + github.com/aws/smithy-go v1.28.13 github.com/coocood/freecache v1.2.7 github.com/go-playground/validator/v10 v10.30.6 github.com/mapt-oss/pulumi-ibmcloud/sdk v0.0.16 @@ -57,16 +57,17 @@ require ( github.com/spf13/cobra v1.10.2 github.com/spf13/pflag v1.1.0 github.com/spf13/viper v1.21.0 + golang.org/x/crypto v0.59.0 golang.org/x/exp v0.0.0-20261117202309-7a49493bfd90 golang.org/x/mod v0.43.0 - google.golang.org/api v0.316.0 + google.golang.org/api v0.317.0 gopkg.in/yaml.v3 v3.0.1 - k8s.io/apimachinery v0.37.2 - k8s.io/client-go v0.37.2 + k8s.io/apimachinery v0.37.3 + k8s.io/client-go v0.37.3 ) require ( - cloud.google.com/go/auth v0.24.4 // indirect + cloud.google.com/go/auth v0.24.5 // indirect cloud.google.com/go/auth/oauth2adapt v0.3.1 // indirect cloud.google.com/go/compute/metadata v0.10.0 // indirect dario.cat/mergo v1.0.2 // indirect @@ -81,20 +82,20 @@ require ( github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect github.com/apparentlymart/go-textseg/v17 v17.0.1 // indirect github.com/atotto/clipboard v0.1.4 // indirect - github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.27 // indirect - github.com/aws/aws-sdk-go-v2/credentials v1.21.3 // indirect - github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.20.9 // indirect - github.com/aws/aws-sdk-go-v2/internal/configsources v1.5.12 // indirect - github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.8.12 // indirect - github.com/aws/aws-sdk-go-v2/internal/v4a v1.5.12 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.25 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.11.13 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.14.12 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.20.12 // indirect - github.com/aws/aws-sdk-go-v2/service/pricing v1.51.6 // indirect - github.com/aws/aws-sdk-go-v2/service/signin v1.14.0 // indirect - github.com/aws/aws-sdk-go-v2/service/sso v1.39.5 // indirect - github.com/aws/aws-sdk-go-v2/service/ssooidc v1.44.5 // indirect + github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.29 // indirect + github.com/aws/aws-sdk-go-v2/credentials v1.21.7 // indirect + github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.20.12 // indirect + github.com/aws/aws-sdk-go-v2/internal/configsources v1.5.15 // indirect + github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.8.15 // indirect + github.com/aws/aws-sdk-go-v2/internal/v4a v1.5.15 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.27 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.11.16 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.14.15 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.20.15 // indirect + github.com/aws/aws-sdk-go-v2/service/pricing v1.51.9 // indirect + github.com/aws/aws-sdk-go-v2/service/signin v1.14.3 // indirect + github.com/aws/aws-sdk-go-v2/service/sso v1.39.8 // indirect + github.com/aws/aws-sdk-go-v2/service/ssooidc v1.44.8 // indirect github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect github.com/blang/semver v3.5.1+incompatible // indirect github.com/blang/semver/v4 v4.0.0 // indirect @@ -130,7 +131,7 @@ require ( github.com/gabriel-vasile/mimetype v1.4.16 // indirect github.com/go-git/gcfg/v2 v2.0.3 // indirect github.com/go-git/go-billy/v6 v6.0.0-beta.1 // indirect - github.com/go-git/go-git/v6 v6.0.0-beta.1 // indirect + github.com/go-git/go-git/v6 v6.0.0-beta.2 // indirect github.com/go-jose/go-jose/v4 v4.1.9 // indirect github.com/go-logr/logr v1.4.4 // indirect github.com/go-logr/stdr v1.2.2 // indirect @@ -141,20 +142,20 @@ require ( github.com/go-openapi/loads v0.25.4 // indirect github.com/go-openapi/runtime v0.33.5 // indirect github.com/go-openapi/runtime/server-middleware v0.33.5 // indirect - github.com/go-openapi/spec v1.0.1 // indirect - github.com/go-openapi/strfmt v0.27.4 // indirect - github.com/go-openapi/swag v0.29.2 // indirect - github.com/go-openapi/swag/cmdutils v0.29.2 // indirect - github.com/go-openapi/swag/conv v0.29.2 // indirect - github.com/go-openapi/swag/fileutils v0.29.2 // indirect - github.com/go-openapi/swag/jsonutils v0.29.2 // indirect - github.com/go-openapi/swag/loading v0.29.2 // indirect - github.com/go-openapi/swag/mangling v0.29.2 // indirect - github.com/go-openapi/swag/netutils v0.29.2 // indirect - github.com/go-openapi/swag/pools v0.29.2 // indirect - github.com/go-openapi/swag/stringutils v0.29.2 // indirect - github.com/go-openapi/swag/typeutils v0.29.2 // indirect - github.com/go-openapi/swag/yamlutils v0.29.2 // indirect + github.com/go-openapi/spec v1.0.2 // indirect + github.com/go-openapi/strfmt v0.27.5 // indirect + github.com/go-openapi/swag v0.29.3 // indirect + github.com/go-openapi/swag/cmdutils v0.29.3 // indirect + github.com/go-openapi/swag/conv v0.29.3 // indirect + github.com/go-openapi/swag/fileutils v0.29.3 // indirect + github.com/go-openapi/swag/jsonutils v0.29.3 // indirect + github.com/go-openapi/swag/loading v0.29.3 // indirect + github.com/go-openapi/swag/mangling v0.29.3 // indirect + github.com/go-openapi/swag/netutils v0.29.3 // indirect + github.com/go-openapi/swag/pools v0.29.3 // indirect + github.com/go-openapi/swag/stringutils v0.29.3 // indirect + github.com/go-openapi/swag/typeutils v0.29.3 // indirect + github.com/go-openapi/swag/yamlutils v0.29.3 // indirect github.com/go-openapi/validate v1.0.3 // indirect github.com/go-playground/locales v0.14.2 // indirect github.com/go-playground/universal-translator v0.18.2 // indirect @@ -168,7 +169,7 @@ require ( github.com/google/go-tpm v0.9.8 // indirect github.com/google/s2a-go v0.1.11 // indirect github.com/google/uuid v1.6.0 // indirect - github.com/googleapis/enterprise-certificate-proxy v0.3.25 // indirect + github.com/googleapis/enterprise-certificate-proxy v0.3.26 // indirect github.com/googleapis/gax-go/v2 v2.27.0 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.34.0 // indirect github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 // indirect @@ -210,7 +211,7 @@ require ( github.com/pelletier/go-toml/v2 v2.4.3 // indirect github.com/pgavlin/fx v0.1.6 // indirect github.com/pierrec/lz4/v4 v4.1.34 // indirect - github.com/pjbgf/sha1cd v0.7.0 // indirect + github.com/pjbgf/sha1cd v0.8.0 // indirect github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pkg/term v1.1.0 // indirect @@ -256,7 +257,6 @@ require ( go.uber.org/multierr v1.11.0 // indirect go.yaml.in/yaml/v2 v2.4.5 // indirect go.yaml.in/yaml/v3 v3.0.6 // indirect - golang.org/x/crypto v0.59.0 // indirect golang.org/x/net v0.63.0 // indirect golang.org/x/oauth2 v0.38.0 // indirect golang.org/x/sync v0.25.0 // indirect @@ -266,7 +266,7 @@ require ( golang.org/x/time v0.16.0 // indirect golang.org/x/tools v0.53.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20261116203732-fd2c7689a808 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20261116203732-fd2c7689a808 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20261118221215-c8830f628b3f // indirect google.golang.org/grpc v1.85.0 // indirect google.golang.org/protobuf v1.36.12 // indirect gopkg.in/inf.v0 v0.9.1 // indirect diff --git a/go.sum b/go.sum index 01c754ab9b..87878d63fc 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -cloud.google.com/go/auth v0.24.4 h1:m49juFKXOaeRwmLgcrd3e4hrwqLDe1+4g8fH0EoznUU= -cloud.google.com/go/auth v0.24.4/go.mod h1:p4UXqfSXnMVUDutk9xePzI8lj8yyoJ3BLsKWv0NSvQk= +cloud.google.com/go/auth v0.24.5 h1:uJmCA/tQ66kowrFndTITFOvuInWrozxTUR0ZW7Ofo98= +cloud.google.com/go/auth v0.24.5/go.mod h1:1sKRPX9E44bRVbJwo7o8P+AhkYZkg1idTQC7Kreq+hI= cloud.google.com/go/auth/oauth2adapt v0.3.1 h1:BKLDdbWS7pafd820dsyFDF6fPEzIGqr7ny6hbTzCCgE= cloud.google.com/go/auth/oauth2adapt v0.3.1/go.mod h1:B1nM4FJDxoDqAt3PXFG4IflUoQ5kvWAOOM3R+5wAszg= cloud.google.com/go/compute/metadata v0.10.0 h1:pyKMUQSwchgkIBBJGdILqQbs/BNJXqwSA7Ej6LAvvtY= @@ -30,8 +30,8 @@ github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armsubscriptions github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armsubscriptions/v2 v2.0.0/go.mod h1:Rn/a97OKDAoOGvk5/OFjqObHHqWyoMMVSGtikqbKcAg= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage v1.8.1 h1:/Zt+cDPnpC3OVDm/JKLOs7M2DKmLRIIp3XIx9pHHiig= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage v1.8.1/go.mod h1:Ng3urmn6dYe8gnbCMoHHVl5APYz2txho3koEkV2o2HA= -github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.8.3 h1:zoPQ7KXGgzqeUmNWl+b6IwVAqsb5lROEJhqAmqXQtm0= -github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.8.3/go.mod h1:ei/sDx/dwDIUtZE3PQP1u8+qrA+CRy4q7qW+A2MbgB4= +github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.8.4 h1:G4fzNxZQ1JvZs7Ct8yGlKHzaDWQY/F2gx8K09PX06qU= +github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.8.4/go.mod h1:ei/sDx/dwDIUtZE3PQP1u8+qrA+CRy4q7qW+A2MbgB4= github.com/Azure/azure-sdk-for-go/sdk/storage/internal v0.1.0 h1:X/bTwe0qpvmvPPutc+LWo7T4cKMqDP9JHP4k+Co9ZB4= github.com/Azure/azure-sdk-for-go/sdk/storage/internal v0.1.0/go.mod h1:+kX7ahyFelQ42F3RScM2CFgHJljp0phc/FieKLYVpFI= github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1 h1:WJTmL004Abzc5wDB5VtZG2PJk5ndYDgVacGqfirKxjM= @@ -78,56 +78,56 @@ github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI= github.com/aws/amazon-ec2-instance-selector/v3 v3.1.3 h1:13qtG4reL2+2UiCm2U7gM9QJthDO8hPPzvn7hTjHask= github.com/aws/amazon-ec2-instance-selector/v3 v3.1.3/go.mod h1:wdlMRtz9G4IO6H1yZPsqfGBxR8E6B/bdxHlGkls4kGQ= -github.com/aws/aws-sdk-go-v2 v1.48.0 h1:tFU7EJVm7MfyaXLsXdYTZ0Vd6vwt9OljCyqq0gqk0Mc= -github.com/aws/aws-sdk-go-v2 v1.48.0/go.mod h1:oeKU5p+TQBnpeLmU42WZLWvzv+ORLn+74n4QVLnm/Z0= -github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.27 h1:3dMP9eEmHVosFN1QiD24IJBKVY8m6iUfVYXqRCT118Q= -github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.27/go.mod h1:KH4PKcqtjy1m0656eqQV2v53xE04ddJzuNloEKqlHkI= -github.com/aws/aws-sdk-go-v2/config v1.33.21 h1:NY1d3yXmplUSYnUAue0sR88svD+SJiaI+YJGp8TxSNg= -github.com/aws/aws-sdk-go-v2/config v1.33.21/go.mod h1:pVJNXUXaCLu9a/4/liTklg9zR3yO0xm/XBEQhgg5nzc= -github.com/aws/aws-sdk-go-v2/credentials v1.21.3 h1:bh+9VoJ4eDzJVEY6jfdNTBa0Dx7tdr+lWSPNovU1vXc= -github.com/aws/aws-sdk-go-v2/credentials v1.21.3/go.mod h1:4CNs0EBvjDEpyaXSYCdNeNRhFjHFX2Y373tFUaeTYXA= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.20.9 h1:oH1E0tjN0g+ZRusbX1dsuat4FJ0z05l8hWaycSbDuNc= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.20.9/go.mod h1:3ZaQGigIoaS45x9HgnLZ4sP475Fs7QoxU3IsZX/J3h4= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.5.12 h1:W0yUUzKBA8SofGQ0yZafEUuZq9UxfvijRgdc6vcRQPA= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.5.12/go.mod h1:xwKv6vwBNdpPFOxEm/ld4IODZK2s/1ksHvdBqLfH6Gs= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.8.12 h1:lqSi8qvAnKC1vfosImdmOsuiJLr/jdybZX5299beB6Q= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.8.12/go.mod h1:rqPQE2vqkW9YHx5+Gp55sx1wsTM4xtGQLl+TKMjxxrs= -github.com/aws/aws-sdk-go-v2/internal/v4a v1.5.12 h1:uvX2yaL+aMjkmnrLPPlR/zwjoKFRMoNhhJfeGjfk6qc= -github.com/aws/aws-sdk-go-v2/internal/v4a v1.5.12/go.mod h1:dicT+2eNhHHqGkxHO7LoXw3QghIUGuzgdmFqaSTopgI= +github.com/aws/aws-sdk-go-v2 v1.49.0 h1:nfIScsXPSCz+vXIKz49IjNPHmC4oT72SLPVc8P0OBbU= +github.com/aws/aws-sdk-go-v2 v1.49.0/go.mod h1:XwfdWCjuiyYPbYF4ObLoa5I25KjV0ry6d105smVjNKY= +github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.29 h1:LfdRwpJ0Dfh+vpqHevmmnFnMoc3/lfB4pdHOfWpLfH4= +github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.29/go.mod h1:r6fijnrGRQ4OnSGyHYuFcC7G6wdwB4Ld8WhiIaGZHx0= +github.com/aws/aws-sdk-go-v2/config v1.33.25 h1:dcb1dA3N4ACXRxSIDKNSqplFMwy8wCf+CMLc3UIzxOc= +github.com/aws/aws-sdk-go-v2/config v1.33.25/go.mod h1:r53NM09IWscZ+6CiR0VHDYdSKazgyEQFqeUONVdD3ok= +github.com/aws/aws-sdk-go-v2/credentials v1.21.7 h1:KtckEwHoY6AlldyiX4QAtekiL0S/AITVIYdqZnWWWcA= +github.com/aws/aws-sdk-go-v2/credentials v1.21.7/go.mod h1:YnM7TYbV1J65/yn/4E0Rnj9A/UO2OTeiGNZP8tcYKRw= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.20.12 h1:iVrZnlJUz886rp/2yOWxK+AbtR8ZwVNVO2kE3//Bgc8= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.20.12/go.mod h1:fLzXWXb9TJfRF5BzXeQaX6FInXezaQq8Uz0BRmMGuUE= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.5.15 h1:Y0fe1Hcly/OSHtSWzuQrXGt3RtRjso063UbwZgyCHyQ= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.5.15/go.mod h1:52lvlO6umU2TRGxZJfCtjOR6xnbJotZD11mmzhJLQzI= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.8.15 h1:g2qcH0dUfjjigOI+HQB3DLXDq/8c84uH1ii/SDkwatg= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.8.15/go.mod h1:yGE7vsxRwTs6YBSYcE1j/KNA7EmAGEgBX+TAH0AAvk0= +github.com/aws/aws-sdk-go-v2/internal/v4a v1.5.15 h1:XKIkHY7yRHnTJrixMmcA1qIm3qenDe/vmOtf/xiuWYE= +github.com/aws/aws-sdk-go-v2/internal/v4a v1.5.15/go.mod h1:HqYW3gHCQl0tF6dO7kXgc0wFe1Yng0hgCEI7Xa3rK54= github.com/aws/aws-sdk-go-v2/service/ec2 v1.349.0 h1:30gjdtdFyjtXYz//o8mtR/yA3gVmOO6JhKVQHfS9XUs= github.com/aws/aws-sdk-go-v2/service/ec2 v1.349.0/go.mod h1:uMJiOkxaT3pV+LAeAvEaXToZ2x3nEnN53HnPdj+pcNo= -github.com/aws/aws-sdk-go-v2/service/ecs v1.106.0 h1:RlkTN5iUcm+9f3cFuj79xn2aFKHAQypaHteDKhjImGY= -github.com/aws/aws-sdk-go-v2/service/ecs v1.106.0/go.mod h1:NE+iSRHkh9PV3OzFElTZV8WneVYfnFP0AefD99xqejY= +github.com/aws/aws-sdk-go-v2/service/ecs v1.106.3 h1:R59Acpk4hghRLi6eOx1IYiNYBM+JcwFZ6zFG+x2HqbE= +github.com/aws/aws-sdk-go-v2/service/ecs v1.106.3/go.mod h1:KITKukkDG+rBj9Y+c4YXkvwUBiNM6wjYBJzCXNm+1Og= github.com/aws/aws-sdk-go-v2/service/eks v1.105.6 h1:Uy58lpLYdqznK5ozOITAyGfQOfmYmWw2SxPVZj/FQ9I= github.com/aws/aws-sdk-go-v2/service/eks v1.105.6/go.mod h1:494vYQNNS0SK+FQUw8PHIUISgxSerulBuvNVUPeXvx0= -github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing v1.42.0 h1:U4efTqRuWGQj4q1c1VnZ4TtHem7zQpJLohB+Q4kLbaQ= -github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing v1.42.0/go.mod h1:TUJWoGlyRadZJ7kLuheM8ACUH1mDYOrumQM0yT0iXwY= -github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2 v1.65.0 h1:uSptE/uhZImKHU8XuJQs+eE451Fc8wWlkvUnZqqYeGQ= -github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2 v1.65.0/go.mod h1:KBzMXNBXsVqVRQykh9z7GlsKHB2+IhLGYlBU303OAX0= +github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing v1.42.3 h1:RVy57NgdDZzl6D3A3Uhg0Qxr1kPfRyj/es4roRicn9g= +github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing v1.42.3/go.mod h1:AYcLamLiNfqi3RKzCRKUQP4aNv72dlM0apZh6LLjvb4= +github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2 v1.65.3 h1:n/JOxF53cGWesGMmvgpDprGA2sW6oDx2cFHa6kikZfw= +github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2 v1.65.3/go.mod h1:hG6wKC1FJdtVKipImxQ5/imvwhUtfbDXm7kCmyiCWxw= github.com/aws/aws-sdk-go-v2/service/iam v1.66.0 h1:Et/ryIAvtfaq7A1tM2GVFm4PJnL9FQS4qdPVw4nqXv4= github.com/aws/aws-sdk-go-v2/service/iam v1.66.0/go.mod h1:mD7Udn/gwt5GfYA31g6LQRdwCRp0M33vQ11b4sVCc38= -github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.25 h1:rKwkY3Z+fvt2W0msjdNs6uNewPmXzPayQ961oyuWhes= -github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.25/go.mod h1:dBuAadQKd1F4Q4ZOg8gnFmuSHMRE40Pe3IfFwbtC4lE= -github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.11.13 h1:U5HZ8FpTr6tyvulf1nT11Nw4KG1CAsXkuQGdUrIjZ/E= -github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.11.13/go.mod h1:dUfvCU1NaE+b3vqNENDiJncUQW7Djl5pmgUlcjesVqk= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.14.12 h1:wzAqMZ2O4+ij9HQqIrk+P9PBGacE0wOTuWB7Mo97//I= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.14.12/go.mod h1:/0TfyruByHsOlphzP26xDTRe2DKD0J1I1Uyy2TyP8EI= -github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.20.12 h1:H0IaQayT3TLiGIHiNnleQZTbndDlx7LGZ0NWZ5mDwjA= -github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.20.12/go.mod h1:YuJJNxaOjnknLIrscBmkLhIpnmg9LzHd25sQRKUboGU= -github.com/aws/aws-sdk-go-v2/service/pricing v1.51.6 h1:T3+nJAQ0rJmlUC+X9zUhTJU92FqcFkIBwQtnFVIcHJI= -github.com/aws/aws-sdk-go-v2/service/pricing v1.51.6/go.mod h1:DDGMpdyCsXgy7M7o8gm4jI8ogjyMUaJJVFY4q9XyEmc= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.27 h1:2jIfOe8ZuoStxOkRtVU45zxgvt/qeIRChhm2USOS6g8= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.27/go.mod h1:LpMjYa8iT3kMkAxsVCGfyXkBDOOKsziY6S2wSpEvY70= +github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.11.16 h1:D2smhPZgqVLuc8rmuvb6wrG4sgut9iv1BN8W2twFtfo= +github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.11.16/go.mod h1:HheOgBYcgoZgeKSLVEmk9whxHERlVXAKTVWK3xizKeo= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.14.15 h1:ds6Pm/S5xYXPmiqyebd0AeK0zHAAO7qHP1+JZauFnpA= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.14.15/go.mod h1:WqaHpxUhwzsE+NYp2TQitKclpwhi1XYp6wMsdg+yd/k= +github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.20.15 h1:5w2E7ndu7XOt62yvu2vGm/Rv7WDn1oQjrJ7Dt1NTVTM= +github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.20.15/go.mod h1:1WgfBCsJYL6E7T2QkkE8kQvo7uG+5+z2LpaQ9L6pjZs= +github.com/aws/aws-sdk-go-v2/service/pricing v1.51.9 h1:KOUF0NTfsBURJW01MBUsg6smDxhkbqvjiwmlPOP3TIo= +github.com/aws/aws-sdk-go-v2/service/pricing v1.51.9/go.mod h1:RXXOB0eqtPdoI6XSXnrIcjcrJxPO/zXo5VHZDwkomwM= github.com/aws/aws-sdk-go-v2/service/s3 v1.115.0 h1:oV2uKPg8nko04rMAed8TLFPIOzEOIx6roOYceImhcwg= github.com/aws/aws-sdk-go-v2/service/s3 v1.115.0/go.mod h1:8NhAIBVYkVHq0hIbbzujdoou0VkKwMdG+De9e5oX6qI= -github.com/aws/aws-sdk-go-v2/service/signin v1.14.0 h1:bIEk1HfTd3MGzvDa5YOQUodGr96D9+UTnmBLBB8ZJ10= -github.com/aws/aws-sdk-go-v2/service/signin v1.14.0/go.mod h1:LdwHjKqPE9VCC7sTlWcOAizZx3ZJYjmfwC/EW2tIIAE= -github.com/aws/aws-sdk-go-v2/service/sso v1.39.5 h1:ANAoa+qt3/9kXnvQVgUyxcTzhzZf4DqaBS+M2DQrELU= -github.com/aws/aws-sdk-go-v2/service/sso v1.39.5/go.mod h1:vsMi+SSR7xGQXtV430LVi49qbv/R+U+upHHSp1W/+QI= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.44.5 h1:uIOBLMhef4N16WguadoHKuBy9etdz+RKTeqzchXErAI= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.44.5/go.mod h1:NwWmkFLtsTVyXQpbzPOlYLwEoANkdCFjJRtrNcbg/vY= -github.com/aws/aws-sdk-go-v2/service/sts v1.53.0 h1:my9Y6lxcqvPV5k4OTqnxr8XbiTDDRos1leEh050Z93U= -github.com/aws/aws-sdk-go-v2/service/sts v1.53.0/go.mod h1:MG6N8U9+lY4LqchrlHPqCOSr7hyxw70XU0Et2YR3eNA= -github.com/aws/smithy-go v1.28.9 h1:zkZ058OpNX0iGTK24b+ZUEQSMc11CBA6oO7xtKZfzkY= -github.com/aws/smithy-go v1.28.9/go.mod h1:YE2RhdIuDbA5E5bTdciG9KrW3+TiEONeUWCqxX9i1Fc= +github.com/aws/aws-sdk-go-v2/service/signin v1.14.3 h1:iWgA/aDj99JAb3VO5PWw9iF5weoTQm7wxLEMT0Ex/MY= +github.com/aws/aws-sdk-go-v2/service/signin v1.14.3/go.mod h1:7YfGlRtvWLx6EfPOM89plg0AcIyuFqOHhfK2iMCOI34= +github.com/aws/aws-sdk-go-v2/service/sso v1.39.8 h1:0fKFg9h8VR5qEHNgDn7CRMvYSsZHl0sBsMyeWsF6YXc= +github.com/aws/aws-sdk-go-v2/service/sso v1.39.8/go.mod h1:0zVH+3FrAkRJ7da4EBDyfEGKTsvXK3sgyjw7FnohF3g= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.44.8 h1:SDuU4vlszzKfTlvNejSjcP1bye5vcrgZF6Ru3hybNsU= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.44.8/go.mod h1:Un05dkqLD6qwNJCHqtXiAWkj+2lKJ4aeXaAy/3fdrEA= +github.com/aws/aws-sdk-go-v2/service/sts v1.54.0 h1:DU77JKbCAMbgk/02a25f+TNk+t6PoR3K7bhOXKULeDM= +github.com/aws/aws-sdk-go-v2/service/sts v1.54.0/go.mod h1:3skcGfglqLhKpz95YNfXrpAZAFZz8OYkj/MH5JxDxkI= +github.com/aws/smithy-go v1.28.13 h1:cBdveQH7NJe99gJKArwOKc11/57r17Gjq374TgDs6LY= +github.com/aws/smithy-go v1.28.13/go.mod h1:YE2RhdIuDbA5E5bTdciG9KrW3+TiEONeUWCqxX9i1Fc= github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8= github.com/aymanbagabas/go-udiff v0.4.1 h1:OEIrQ8maEeDBXQDoGCbbTTXYJMYRCRO1fnodZ12Gv5o= @@ -212,10 +212,10 @@ github.com/go-git/gcfg/v2 v2.0.3 h1:1JJuq344l9ATEFu7/rhdBOLiTw5vnn+q8YBxGLDX8Kw= github.com/go-git/gcfg/v2 v2.0.3/go.mod h1:/lv2NsxvhepuMrldsFilrgct6pxzpGdSRC13ydTLSLs= github.com/go-git/go-billy/v6 v6.0.0-beta.1 h1:OJ4r207zcEbeq/DJNajQUOMd+pph3r9A7hRq1Sjl1bA= github.com/go-git/go-billy/v6 v6.0.0-beta.1/go.mod h1:QGOWN4CzmtRfpFeCw5paG3RJyKdTwsfGASkxBVkIaAU= -github.com/go-git/go-git-fixtures/v6 v6.0.0-alpha.1 h1:gmqi2jvsreu0s8JMLylYDFq4sbjHwwlhktMw0DUg3mA= -github.com/go-git/go-git-fixtures/v6 v6.0.0-alpha.1/go.mod h1:ECf1MqJlBdYpKggBrOXjo/0EnvRZx6D++I86UYjPgAQ= -github.com/go-git/go-git/v6 v6.0.0-beta.1 h1:1t+vJYGDBN6f9GRWskgWx5UjXPFUa7wfffZZZ2C5GtA= -github.com/go-git/go-git/v6 v6.0.0-beta.1/go.mod h1:ugDlr38Wwc+fOw85J+Oluh5TNXQtJgYMcriOljg3l4s= +github.com/go-git/go-git-fixtures/v6 v6.0.0-alpha.1.0.20261119064959-a5796c55ab4e h1:4qZ5xqI6Atmig430SbJ+IpYf+5d2cj277jnANnLwG44= +github.com/go-git/go-git-fixtures/v6 v6.0.0-alpha.1.0.20261119064959-a5796c55ab4e/go.mod h1:DvqXlJDOI/eY7inoU6CuBwNJjwHRJEcTHsJSoT41Wzc= +github.com/go-git/go-git/v6 v6.0.0-beta.2 h1:xPClEAR83zK7f63A0YS+QnECgeQl+GvsAD7UkJKqDEo= +github.com/go-git/go-git/v6 v6.0.0-beta.2/go.mod h1:U8gYDezgjxZN/TRHewlAXfwNUHGiH4GPW/kuPa/aCtg= github.com/go-jose/go-jose/v4 v4.1.9 h1:pKfeQkig1NmgK4hJrZYXLEYURXfoJB61Larw0uIW4gY= github.com/go-jose/go-jose/v4 v4.1.9/go.mod h1:x4oUasVrzR7071A4TnHLGSPpNOm2a21K9Kf04k1rs08= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= @@ -237,36 +237,36 @@ github.com/go-openapi/runtime v0.33.5 h1:+75EEOU6yv55alsXrkK7BV+vfiQg2ZJb9lAfXx8 github.com/go-openapi/runtime v0.33.5/go.mod h1:cvmwmMVxhBn/wzfz/VAeUEbe/E1jSCQ9HoNMwDmd+qs= github.com/go-openapi/runtime/server-middleware v0.33.5 h1:Kw2mZgKrLrqrq80yP35WPrQMT2oT3zytJRICqprMagY= github.com/go-openapi/runtime/server-middleware v0.33.5/go.mod h1:f/7HY8zgRWGpXO+aYTCXBtTTuhB+HUjY8L++uqoS5WU= -github.com/go-openapi/spec v1.0.1 h1:lj2vdGpNDcVgwRc6qXdw6qt/KQpCtSa9tnUH6vpDPDk= -github.com/go-openapi/spec v1.0.1/go.mod h1:M//GWQGtDUAjnP37gE6fInLgaczB+FatoipV3H1fYw8= -github.com/go-openapi/strfmt v0.27.4 h1:E1xsvHb8R9vsuYru4TP2PVVTv9AIgSFAUACUZrFQfCI= -github.com/go-openapi/strfmt v0.27.4/go.mod h1:SCOff81PPhU26acBiW96jHaFycEbT2nkQRvojM+V2z0= -github.com/go-openapi/swag v0.29.2 h1:9n8frkcsuQRA0INU31VbxNxt1zBaHxrHYGEf5BUjFi4= -github.com/go-openapi/swag v0.29.2/go.mod h1:RkCiX1gCVXWgLOavDXE3ALJrQ/VO2ziiIzOUs3z10xo= -github.com/go-openapi/swag/cmdutils v0.29.2 h1:cXEzX/nWCODon251f+1HgL75/R4XXML5IZxgLCWMoro= -github.com/go-openapi/swag/cmdutils v0.29.2/go.mod h1:XziaSVzYqkDvpWXzASfWajw2YvJrLscq610O2XiyqJw= -github.com/go-openapi/swag/conv v0.29.2 h1:8c9shoB8l0QRSR6ymq1llHdBWDqpIgJfjTGHx3Vuhm0= -github.com/go-openapi/swag/conv v0.29.2/go.mod h1:AZS0YigTNf8qNtD6WqJz/N4RUNmpr76SyjFGkq4+p6Q= -github.com/go-openapi/swag/fileutils v0.29.2 h1:mdUL+Vw5ah1fO1AvFCoHeIyv7YZsCz2MN3KNqd/lLVI= -github.com/go-openapi/swag/fileutils v0.29.2/go.mod h1:7QKmmodjAebaq61lGVJa8ldLdGeMF4DSgYv8tXOGGo0= -github.com/go-openapi/swag/jsonutils v0.29.2 h1:uZNSD2/rJDYAfvsLYkykTzXuyxM3QpDKV9jhRHrMu6k= -github.com/go-openapi/swag/jsonutils v0.29.2/go.mod h1:ONTdNvj3Y+IXRzfa17E+Rgt2ns/qiSOYjIo2K7v2yDs= -github.com/go-openapi/swag/jsonutils/fixtures_test v0.29.2 h1:w+Fd6EBOMGlC74GYGHqCLGyb3Bpams8TtNrgM/SG4jo= -github.com/go-openapi/swag/jsonutils/fixtures_test v0.29.2/go.mod h1:HC2egPORFzbj/gf05Zrfgz8Mgplx3oW7hgGi7pjZVhM= -github.com/go-openapi/swag/loading v0.29.2 h1:QU1ry24e6r6Shoxe380Nx0X5iKkpRO+hJffsyJ2dVlY= -github.com/go-openapi/swag/loading v0.29.2/go.mod h1:DqilDjuiJKETecsS4TRopWG1acUDsfqN39ZmQhPu6uI= -github.com/go-openapi/swag/mangling v0.29.2 h1:ltdo3K0tTP4P6zWhVVWDU9D37/YYBuMJRdZxiS2Dtog= -github.com/go-openapi/swag/mangling v0.29.2/go.mod h1:RjDi4TnItAenS3cgCXSpIl1kKbjG7il6pnmQVl/8bp8= -github.com/go-openapi/swag/netutils v0.29.2 h1:dBli6jyUa93sDS/XYWShJzf4+nnVfFKfvY9SLUaUzB8= -github.com/go-openapi/swag/netutils v0.29.2/go.mod h1:1pM6Xg/Um8E1eps3umWl8Hme3ByWXOtHsvFC0CULHUE= -github.com/go-openapi/swag/pools v0.29.2 h1:PlGoDRF8WtSyXkedZZkpW3f9wDhFf3u8KtaBcmgmh8c= -github.com/go-openapi/swag/pools v0.29.2/go.mod h1:V3lhxVT4qDYRqc2MRSSbLsTYIYV/2HlHafhyEkmzLIc= -github.com/go-openapi/swag/stringutils v0.29.2 h1:lcnBxwAaysT3bMUVBfn9V/PkfVqkurpqufKU6rTUMGk= -github.com/go-openapi/swag/stringutils v0.29.2/go.mod h1:i9cdh7sGaa0nm3CqIvH5IM5h2QClk1wns2ktKeILvRI= -github.com/go-openapi/swag/typeutils v0.29.2 h1:O7aVvkTs3pXwikgtrPLenigEMdQFgONKRooQA9pgf2I= -github.com/go-openapi/swag/typeutils v0.29.2/go.mod h1:7+GDG+uz9Ke+eVt4rClZg7wklSDp8hT/mKNh/pC26TE= -github.com/go-openapi/swag/yamlutils v0.29.2 h1:IFKFFeDnuIwzfsuWRQU+rI8iL3g4XyAYjV/RlnlxPLM= -github.com/go-openapi/swag/yamlutils v0.29.2/go.mod h1:7MGqtcrK73sxQ4ceiyIf8qiXS/s09JLMdR5esK5euYQ= +github.com/go-openapi/spec v1.0.2 h1:he/1tHjyi+fpihu27rCIOhX6JXIk6stR0635RZfshTE= +github.com/go-openapi/spec v1.0.2/go.mod h1:EST/+XYtBNCApIt+lcRKRV7QPWi5MscHp/fJ/nw668Y= +github.com/go-openapi/strfmt v0.27.5 h1:5eY3a5ww8oKbq2LXtM5jMec9Kcr9G+Imrf3zwAijWDo= +github.com/go-openapi/strfmt v0.27.5/go.mod h1:SwN57PtXhi3zS28oAxcdDMdtcrAdBQmijIQJtk46G0I= +github.com/go-openapi/swag v0.29.3 h1:SzBuixgab/AJksPECXpV8w0oIkXZr6Z2IC9hx3dMmmI= +github.com/go-openapi/swag v0.29.3/go.mod h1:tAnDRnwrvLV7t+idPU9VK7iJWyQfTEahGO8IQ3vVrik= +github.com/go-openapi/swag/cmdutils v0.29.3 h1:8uVCR5cuRuZ9J+ewkYL7cp4fJETkepb8AOBVHwnoy7M= +github.com/go-openapi/swag/cmdutils v0.29.3/go.mod h1:XziaSVzYqkDvpWXzASfWajw2YvJrLscq610O2XiyqJw= +github.com/go-openapi/swag/conv v0.29.3 h1:/vaxRbi6PfPJ7g6HqvmdJ0IPyKkANeo+HtkJh/QDdrQ= +github.com/go-openapi/swag/conv v0.29.3/go.mod h1:Qd/EJRmzwUilbXMtNR9qh+U7NIH+oCx14TWyC4pzZWM= +github.com/go-openapi/swag/fileutils v0.29.3 h1:p+4vok5vLSAO4D59z2pF/jDTh3cm0QyOjfJ2mzwwh7s= +github.com/go-openapi/swag/fileutils v0.29.3/go.mod h1:QuX/4l/zjt26j94viIATatgVnCCrdxwd7JRBUOm2cyw= +github.com/go-openapi/swag/jsonutils v0.29.3 h1:9vZ8Qvxw61RBnV4k5BAUpRhA4dDXabIGscG3DWOkEgM= +github.com/go-openapi/swag/jsonutils v0.29.3/go.mod h1:RRDDZ0z9hqlhP5hM8/YX1H1FI5wBJn8FZSX0mXR+gzQ= +github.com/go-openapi/swag/jsonutils/fixtures_test v0.29.3 h1:hTWVgH+1bz2YGDZ2JsaZPz4lLcn492ggFR3bwQxFmvE= +github.com/go-openapi/swag/jsonutils/fixtures_test v0.29.3/go.mod h1:/mwNNvXkSpl+PekNdh4LGVhFrwECVqIf+DE4MGbGXHE= +github.com/go-openapi/swag/loading v0.29.3 h1:vQR/DlDXYSTacBh7sDLX8GGKLa34K9XP0ZnIf4znzqg= +github.com/go-openapi/swag/loading v0.29.3/go.mod h1:UTHC1ElgJgd6hyDWLKsQQQ+ctOpbGou9Li0bU6YXWOA= +github.com/go-openapi/swag/mangling v0.29.3 h1:bZYiYi7nn+G1Ou7YFKJi63HL2upZWYaE+2cuUThp6N0= +github.com/go-openapi/swag/mangling v0.29.3/go.mod h1:4QdO0G7O0URCr2YNDE8n243Xn2sQuTUO3BtJDIQHy0k= +github.com/go-openapi/swag/netutils v0.29.3 h1:w5qCxSl4HEoVoMa2pxzr10Y0K5FZ+T5Gyg9bCNXyWE8= +github.com/go-openapi/swag/netutils v0.29.3/go.mod h1:EADoBrxE4M4SGwfe0KIOtBhr7cEbc3Ilm6tOmtND8So= +github.com/go-openapi/swag/pools v0.29.3 h1:EPno+8co2WEVgXxplC1DDLVHKZ5KJIWBVTz2wf7psgc= +github.com/go-openapi/swag/pools v0.29.3/go.mod h1:sha8gSzKH7U9rGlVpkKQzlicApUrxNsCzxGxzcFWpbs= +github.com/go-openapi/swag/stringutils v0.29.3 h1:M3ZYfZ4TjQtWtEqPq6uw1g2N74hb/EnD5SK6Uj1264U= +github.com/go-openapi/swag/stringutils v0.29.3/go.mod h1:xHQlugcQB3hFAt/3nOxOxfo4aogLZScAro76qHyl6Uc= +github.com/go-openapi/swag/typeutils v0.29.3 h1:iNE6NAhIIq0uoTVVrKJO9omcHIiF93Evkwr5PcLN2mk= +github.com/go-openapi/swag/typeutils v0.29.3/go.mod h1:uwx2j8FylxfLFKAfoD/GDfxNMDm6dqeJ+aQzIXVzsgU= +github.com/go-openapi/swag/yamlutils v0.29.3 h1:9BhUEKQ87xMfDo6T9HPIdWW9oa4A6S/SSkvqsz2FwMw= +github.com/go-openapi/swag/yamlutils v0.29.3/go.mod h1:6QCYkEw0MIl5erPgiYKdrr7NDEU5Hvg1DsHBrL/wuA8= github.com/go-openapi/testify/enable/yaml/v2 v2.8.1 h1:BIMg/qqur4MXPPHLE3nftDfHdXrw5GwZEsNEw7zraYA= github.com/go-openapi/testify/enable/yaml/v2 v2.8.1/go.mod h1:74sM7nseyEwJFZ9yRNI77kCQAM5h8nZ4TmXI86voDHs= github.com/go-openapi/testify/v2 v2.8.1 h1:zk3S6KaDY1iQW91vsOJc25Ql1xm5bhPrZKdnL930bRQ= @@ -315,8 +315,8 @@ github.com/google/s2a-go v0.1.11 h1:7v1V1TraNGP63WptsAkNqr2w8jgm4vM6A6qx6Lsw9iM= github.com/google/s2a-go v0.1.11/go.mod h1:pz4tyvwXvJLLbyrkh6FW1eS2zPUXMaTmyNhYtyP2tNw= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/googleapis/enterprise-certificate-proxy v0.3.25 h1:n/6K8rCcoQQjGZ+o5irYrdwAFZIclQMXq0yeJyK2FaI= -github.com/googleapis/enterprise-certificate-proxy v0.3.25/go.mod h1:hEjCmnoakQzv5ImLUp6alkY7XgLlNoAxwTXmhHHNIsI= +github.com/googleapis/enterprise-certificate-proxy v0.3.26 h1:tUkykWT2z14BrEzpDRZfRUW0paM9bdGJJPbVWxcC0k4= +github.com/googleapis/enterprise-certificate-proxy v0.3.26/go.mod h1:aS/AqV2rt5SAjRYqyz5Jl6DumcsGb8jClwvux6Glpok= github.com/googleapis/gax-go/v2 v2.27.0 h1:qe2iQOUzxb3fd6x6ewpIEixPQhJ+0Ihc/RRZhKA/2g0= github.com/googleapis/gax-go/v2 v2.27.0/go.mod h1:RofiqDw3ehcG4L0H1zO3D2Itpwd3/uS/7wdmbNDF1DE= github.com/grpc-ecosystem/grpc-gateway/v2 v2.34.0 h1:vzlTzzi4tHLa/JQdIE5LeXw6SEX5EVVhq/VPqKHnKOk= @@ -429,8 +429,8 @@ github.com/pgavlin/fx/v2 v2.0.12 h1:SjjaJ68Dt8Z4zHwOpY/RPijd7lShs6xYupJbF9ra00M= github.com/pgavlin/fx/v2 v2.0.12/go.mod h1:M/nF/ooAOy+NUBooYYXl2REARzJ/giPJxfMs8fINfKc= github.com/pierrec/lz4/v4 v4.1.34 h1:5cPY8+z/ffHDpF6Pvv5FffjtZOJJQEiG75267Ol3QtU= github.com/pierrec/lz4/v4 v4.1.34/go.mod h1:R7aiqKav9M7+k1JW19D7y7rcavDvw9Te/YTdFJyNXBs= -github.com/pjbgf/sha1cd v0.7.0 h1:ZRNPKHj+gfkLBf0KJv/p1Hmz+7bqCT5o311YX0nq+DA= -github.com/pjbgf/sha1cd v0.7.0/go.mod h1:pKR5Li+qTCo+ebqITZfwPlJGoCFCvSO00qxjbNtTUFQ= +github.com/pjbgf/sha1cd v0.8.0 h1:DaMqV3j5helL3+K5evP+0WuAc/FFrzZJhOkSKjFrkBU= +github.com/pjbgf/sha1cd v0.8.0/go.mod h1:pKR5Li+qTCo+ebqITZfwPlJGoCFCvSO00qxjbNtTUFQ= github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -661,14 +661,14 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4= gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E= -google.golang.org/api v0.316.0 h1:nwaBinxtopJcOPwNYkvuRo7JA2nKppWzzk1sSORUWp4= -google.golang.org/api v0.316.0/go.mod h1:kn5kd1IMbs2x4hq99GcaTOumC0fnMYMwLNAfFxzpISU= +google.golang.org/api v0.317.0 h1:FAf4nkScNr1Zz2ng17GJFT5Cv+eJCy03T2xGcn0PJ4g= +google.golang.org/api v0.317.0/go.mod h1:4uj+S38vspRU3wb5PSAGB/syOzQVKJ6LNMmuvlr6NII= google.golang.org/genproto v0.0.0-20261012220534-4341edf3f941 h1:CXq2XEi5aEyLjjPZIwqrmQH8ZY4ctUwK7uyAx3mjX/U= google.golang.org/genproto v0.0.0-20261012220534-4341edf3f941/go.mod h1:3gK0ehnhP0V7/x3ypGoLyT3d0n6TSi/EcsphIjHrcz4= google.golang.org/genproto/googleapis/api v0.0.0-20261116203732-fd2c7689a808 h1:138uiCpAaz8IK/8xoJcj2MQUWL5MMtaV7ofVoQJpuY8= google.golang.org/genproto/googleapis/api v0.0.0-20261116203732-fd2c7689a808/go.mod h1:Q/ieadaUFs1Xg9kiCENqJcpZMo0aTO4nUCWroI7gAdQ= -google.golang.org/genproto/googleapis/rpc v0.0.0-20261116203732-fd2c7689a808 h1:fTdQSdJnh58Hq9AG3truAGfWr7VEZ3tCU3DE5kDnTDE= -google.golang.org/genproto/googleapis/rpc v0.0.0-20261116203732-fd2c7689a808/go.mod h1:OaIUM3+LpYcK2GXM4FTmhWoIq371Owdr+Cc7/BsYHHc= +google.golang.org/genproto/googleapis/rpc v0.0.0-20261118221215-c8830f628b3f h1:aDW6Vb2T1K0xbAgW+ED8iz39WlgjjX/OKiNh6tXv/+g= +google.golang.org/genproto/googleapis/rpc v0.0.0-20261118221215-c8830f628b3f/go.mod h1:OaIUM3+LpYcK2GXM4FTmhWoIq371Owdr+Cc7/BsYHHc= google.golang.org/grpc v1.85.0 h1:BPBCfuVRQ1qvBhKDOq9uvQllMvO59rKsYhXpp7Dd8vw= google.golang.org/grpc v1.85.0/go.mod h1:0rQrOD58yjal/0EaVbGBANindixsCZNQPDV3VKtaKuQ= google.golang.org/protobuf v1.36.12 h1:pJOKDDOyeXErUroCihFAd5LQuwXBSpVnKGrj5o/fwxc= @@ -688,12 +688,12 @@ gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -k8s.io/api v0.37.2 h1:PnxqnUFy93jr2GcpWDkKOm8wfy25kT9wa572MuQS8oc= -k8s.io/api v0.37.2/go.mod h1:+NVRLft99kx+Jg9v34GmHw867Dapim89TSyCsn2hK+M= -k8s.io/apimachinery v0.37.2 h1:G4t9RGoPDbQML38hz/kQQiltttgd3egg2ODCR8aIc2o= -k8s.io/apimachinery v0.37.2/go.mod h1:qaAvSNvgU2x07wRM95MSHSJTPQ/ob/LeNAGbeDgqQJg= -k8s.io/client-go v0.37.2 h1:sgFtyRZukGkOrsu+QgS7LYnbFFJ5ut3MchdBNduD//E= -k8s.io/client-go v0.37.2/go.mod h1:bo3LFC8YbCtKFPX21Yj8puMsoJLAv/+SvuOODma0s54= +k8s.io/api v0.37.3 h1:FJiwAdL36Qacogp5Q78ANthlzjGHHOo3cNYsI3p4F7I= +k8s.io/api v0.37.3/go.mod h1:o60SYkL1mnbKTXxr01zf7OaRG6aAErSzdOXEmcjVsNw= +k8s.io/apimachinery v0.37.3 h1:0fC5KINyhJo/QZBIkJ2IeqdWtrI+0WGNAFMnTE8HIjI= +k8s.io/apimachinery v0.37.3/go.mod h1:OsyLAd4Zzn4L724/ZEQPnH0a6Kn282D6B4LEh8RZ7EM= +k8s.io/client-go v0.37.3 h1:lWCiKUqAZ4KRcRyvT0tc4+Z0oZM9mzEjdjvIuw0F+RE= +k8s.io/client-go v0.37.3/go.mod h1:4AMX9QbbAtkVjM+Uq+D6wxcEBKLoDFvoAyXuV5IyWtE= k8s.io/klog/v2 v2.140.0 h1:Tf+J3AH7xnUzZyVVXhTgGhEKnFqye14aadWv7bzXdzc= k8s.io/klog/v2 v2.140.0/go.mod h1:o+/RWfJ6PwpnFn7OyAG3QnO47BFsymfEfrz6XyYSSp0= k8s.io/kube-openapi v0.0.0-20261104182252-5bee61fc5225 h1:HOQQvGlqZPbN+4aXdqQhLdh87oE5dhLn3Br9q/FWPKw= diff --git a/vendor/cloud.google.com/go/auth/CHANGES.md b/vendor/cloud.google.com/go/auth/CHANGES.md index 5cd04cdb68..1e23259866 100644 --- a/vendor/cloud.google.com/go/auth/CHANGES.md +++ b/vendor/cloud.google.com/go/auth/CHANGES.md @@ -1,5 +1,14 @@ # Changes +## [0.24.5](https://github.com/googleapis/google-cloud-go/compare/auth/v0.24.4...auth/v0.24.5) (2026-11-25) + + +### Bug Fixes + +* **auth/credentials/downscope:** Update universe resolution ([#20967](https://github.com/googleapis/google-cloud-go/issues/20967)) ([16e0475](https://github.com/googleapis/google-cloud-go/commit/16e0475f95988d1336f86b410bea47a6bf4dc741)) +* **auth:** Add ES256 length validation ([#20949](https://github.com/googleapis/google-cloud-go/issues/20949)) ([35958cc](https://github.com/googleapis/google-cloud-go/commit/35958cc69e5d5e711357140f3314ac5519776cf8)) +* **auth:** Improve directpath resolution ([#21004](https://github.com/googleapis/google-cloud-go/issues/21004)) ([ceeb6a1](https://github.com/googleapis/google-cloud-go/commit/ceeb6a14f159e696e83ef596e6fc8ffca1acfab8)) + ## [0.24.4](https://github.com/googleapis/google-cloud-go/compare/auth/v0.24.3...auth/v0.24.4) (2026-11-09) diff --git a/vendor/cloud.google.com/go/auth/internal/internal.go b/vendor/cloud.google.com/go/auth/internal/internal.go index d79e0ffbe5..b9fd50ac0c 100644 --- a/vendor/cloud.google.com/go/auth/internal/internal.go +++ b/vendor/cloud.google.com/go/auth/internal/internal.go @@ -25,6 +25,7 @@ import ( "io" "net/http" "os" + "strings" "sync" "time" @@ -185,21 +186,25 @@ func (p StaticProperty) GetProperty(context.Context) (string, error) { // ComputeUniverseDomainProvider fetches the credentials universe domain from // the google cloud metadata service. type ComputeUniverseDomainProvider struct { - MetadataClient *metadata.Client - universeDomainOnce sync.Once - universeDomain string - universeDomainErr error + MetadataClient *metadata.Client + mu sync.Mutex + universeDomain string } // GetProperty fetches the credentials universe domain from the google cloud -// metadata service. +// metadata service. Successful lookups are cached for the lifetime of the +// provider; errors are not cached so subsequent calls may retry. func (c *ComputeUniverseDomainProvider) GetProperty(ctx context.Context) (string, error) { - c.universeDomainOnce.Do(func() { - c.universeDomain, c.universeDomainErr = getMetadataUniverseDomain(ctx, c.MetadataClient) - }) - if c.universeDomainErr != nil { - return "", c.universeDomainErr + c.mu.Lock() + defer c.mu.Unlock() + if c.universeDomain != "" { + return c.universeDomain, nil } + ud, err := getMetadataUniverseDomain(ctx, c.MetadataClient) + if err != nil { + return "", err + } + c.universeDomain = ud return c.universeDomain, nil } @@ -212,14 +217,19 @@ var httpGetMetadataUniverseDomain = func(ctx context.Context, client *metadata.C func getMetadataUniverseDomain(ctx context.Context, client *metadata.Client) (string, error) { universeDomain, err := httpGetMetadataUniverseDomain(ctx, client) - if err == nil { - return universeDomain, nil + if err != nil { + var notDefined metadata.NotDefinedError + if errors.As(err, ¬Defined) { + // http.StatusNotFound (404) + return DefaultUniverseDomain, nil + } + return "", err } - if _, ok := err.(metadata.NotDefinedError); ok { - // http.StatusNotFound (404) + universeDomain = strings.TrimSpace(universeDomain) + if universeDomain == "" { return DefaultUniverseDomain, nil } - return "", err + return universeDomain, nil } // FormatIAMServiceAccountResource sets a service account name in an IAM resource diff --git a/vendor/cloud.google.com/go/auth/internal/version.go b/vendor/cloud.google.com/go/auth/internal/version.go index ffd63808b7..7030be1f59 100644 --- a/vendor/cloud.google.com/go/auth/internal/version.go +++ b/vendor/cloud.google.com/go/auth/internal/version.go @@ -17,4 +17,4 @@ package internal // Version is the current tagged release of the library. -const Version = "0.24.4" +const Version = "0.24.5" diff --git a/vendor/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/CHANGELOG.md b/vendor/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/CHANGELOG.md index 71afd1bb09..ca2c9969de 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/CHANGELOG.md +++ b/vendor/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/CHANGELOG.md @@ -1,5 +1,10 @@ # Release History +## 1.8.4 (2026-12-01) + +### Bugs Fixed +* Fixed `GetSASURL` on blob clients to return an error when the snapshot timestamp is invalid. + ## 1.8.3 (2026-11-02) ### Bugs Fixed diff --git a/vendor/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/blob/client.go b/vendor/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/blob/client.go index df8e8f6a6d..fcd1df1885 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/blob/client.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/blob/client.go @@ -277,10 +277,18 @@ func (b *Client) GetSASURL(permissions sas.BlobPermissions, expiry time.Time, o return "", err } - t, err := time.Parse(SnapshotTimeFormat, urlParts.Snapshot) - - if err != nil { - t = time.Time{} + // An empty snapshot means a base blob (or version) SAS. A non-empty snapshot must parse to a + // non-zero time; otherwise the SAS would silently be scoped to the base blob (sr=b) instead + // of the snapshot (sr=bs). + var t time.Time + if urlParts.Snapshot != "" { + t, err = time.Parse(SnapshotTimeFormat, urlParts.Snapshot) + if err != nil { + return "", fmt.Errorf("invalid snapshot %q: %s", urlParts.Snapshot, err) + } + if t.IsZero() { + return "", fmt.Errorf("invalid snapshot %q: snapshot time must not be the zero time", urlParts.Snapshot) + } } st := o.format() diff --git a/vendor/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/internal/exported/version.go b/vendor/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/internal/exported/version.go index dc29458290..790374ddc8 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/internal/exported/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/internal/exported/version.go @@ -5,5 +5,5 @@ package exported const ( ModuleName = "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob" - ModuleVersion = "v1.8.3" + ModuleVersion = "v1.8.4" ) diff --git a/vendor/github.com/aws/aws-sdk-go-v2/aws/go_module_metadata.go b/vendor/github.com/aws/aws-sdk-go-v2/aws/go_module_metadata.go index 01b4fac85a..e63f84f9d1 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/aws/go_module_metadata.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/aws/go_module_metadata.go @@ -3,4 +3,4 @@ package aws // goModuleVersion is the tagged release for this module -const goModuleVersion = "1.48.0" +const goModuleVersion = "1.49.0" diff --git a/vendor/github.com/aws/aws-sdk-go-v2/aws/middleware/user_agent.go b/vendor/github.com/aws/aws-sdk-go-v2/aws/middleware/user_agent.go index 157a71505c..e3f5ee5bd1 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/aws/middleware/user_agent.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/aws/middleware/user_agent.go @@ -140,6 +140,10 @@ const ( UserAgentFeatureCredentialsProfileLogin = "AC" UserAgentFeatureCredentialsLogin = "AD" + + UserAgentFeatureS3CustomPartSize = "AX" + UserAgentFeatureS3FilePath = "Ab" + UserAgentFeatureS3TransferDirectIO = "Ai" ) var credentialSourceToFeature = map[aws.CredentialSource]UserAgentFeature{ diff --git a/vendor/github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream/CHANGELOG.md b/vendor/github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream/CHANGELOG.md index 99407899b6..0f0e13c0c7 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream/CHANGELOG.md +++ b/vendor/github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream/CHANGELOG.md @@ -1,3 +1,13 @@ +# v1.7.29 (2026-11-27) + +* **Dependency Update**: Update smithy-go to v1.28.11 + +# v1.7.28 (2026-11-25) + +* **Bug Fix**: Return an error when encoding an event stream message too long for its 32-bit length field instead of writing a truncated length. +* **Bug Fix**: Validate event stream message prelude lengths when decoding. +* **Dependency Update**: Update to smithy-go v1.28.10. + # v1.7.27 (2026-11-10) * **Dependency Update**: Update to smithy-go v1.28.9. diff --git a/vendor/github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream/encode.go b/vendor/github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream/encode.go index f2e37c8b39..269464257b 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream/encode.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream/encode.go @@ -61,6 +61,10 @@ func (e *Encoder) Encode(w io.Writer, msg Message) (err error) { return err } + if err = validateMessageLen(uint64(e.headersBuf.Len()), uint64(len(msg.Payload))); err != nil { + return err + } + crc := crc32.New(crc32IEEETable) hashWriter := io.MultiWriter(writer, crc) @@ -111,6 +115,23 @@ func logMessageEncode(logger logging.Logger, msgBuf *bytes.Buffer, msg Message, fmt.Fprintf(w, "Raw message:\n%s\n", hex.Dump(msgBuf.Bytes())) } +// validateMessageLen returns an error if a message with the given headers and +// payload lengths would be longer than maxMsgLen. The sum is computed in 64 +// bits so it cannot wrap the way the prelude's 32-bit length field would. +func validateMessageLen(headersLen, payloadLen uint64) error { + if total := minMsgLen + headersLen + payloadLen; total > maxMsgLen { + // Convert through a variable: int(maxMsgLen) would fail to compile on + // 32-bit systems, where the constant overflows int. + maxLen := uint64(maxMsgLen) + return LengthError{ + Part: "message", + Want: int(maxLen), + Have: int(total), + } + } + return nil +} + func encodePrelude(w io.Writer, crc hash.Hash32, headersLen, payloadLen uint32) error { p := messagePrelude{ Length: minMsgLen + headersLen + payloadLen, diff --git a/vendor/github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream/go_module_metadata.go b/vendor/github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream/go_module_metadata.go index cee4196055..8466e68473 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream/go_module_metadata.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream/go_module_metadata.go @@ -3,4 +3,4 @@ package eventstream // goModuleVersion is the tagged release for this module -const goModuleVersion = "1.7.27" +const goModuleVersion = "1.7.29" diff --git a/vendor/github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream/message.go b/vendor/github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream/message.go index 1a77654f7e..e381d91669 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream/message.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream/message.go @@ -4,6 +4,7 @@ import ( "bytes" "encoding/binary" "hash/crc32" + "math" ) const preludeLen = 8 @@ -11,6 +12,11 @@ const preludeCRCLen = 4 const msgCRCLen = 4 const minMsgLen = preludeLen + preludeCRCLen + msgCRCLen +// maxMsgLen is the largest total message length that the prelude's 32-bit +// length field can hold. It is a limit of the wire format, not a size policy; +// headers and payload together can be at most maxMsgLen-minMsgLen bytes. +const maxMsgLen = math.MaxUint32 + var crc32IEEETable = crc32.MakeTable(crc32.IEEE) // A Message provides the eventstream message representation. @@ -78,14 +84,25 @@ func (p messagePrelude) PayloadLen() uint32 { return p.Length - p.HeadersLen - minMsgLen } +// ValidateLens checks that the prelude's total and headers lengths are +// consistent before they are used to read the rest of the message. Without +// these checks PayloadLen would underflow for a total length below +// HeadersLen+minMsgLen. func (p messagePrelude) ValidateLens() error { - if p.Length == 0 { + if p.Length < minMsgLen { return LengthError{ Part: "message prelude", Want: minMsgLen, Have: int(p.Length), } } + if p.HeadersLen > p.Length-minMsgLen { + return LengthError{ + Part: "message headers", + Want: int(p.Length - minMsgLen), + Have: int(p.HeadersLen), + } + } return nil } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/config/CHANGELOG.md b/vendor/github.com/aws/aws-sdk-go-v2/config/CHANGELOG.md index 0fbfb9031a..fbc1ac80ed 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/config/CHANGELOG.md +++ b/vendor/github.com/aws/aws-sdk-go-v2/config/CHANGELOG.md @@ -1,3 +1,21 @@ +# v1.33.25 (2026-12-01.2) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.33.24 (2026-12-01) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.33.23 (2026-11-27) + +* **Dependency Update**: Update smithy-go to v1.28.11 +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.33.22 (2026-11-25) + +* **Dependency Update**: Update to smithy-go v1.28.10. +* **Dependency Update**: Updated to the latest SDK module versions + # v1.33.21 (2026-11-19) * **Dependency Update**: Updated to the latest SDK module versions diff --git a/vendor/github.com/aws/aws-sdk-go-v2/config/go_module_metadata.go b/vendor/github.com/aws/aws-sdk-go-v2/config/go_module_metadata.go index da244af01f..aeeca3639e 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/config/go_module_metadata.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/config/go_module_metadata.go @@ -3,4 +3,4 @@ package config // goModuleVersion is the tagged release for this module -const goModuleVersion = "1.33.21" +const goModuleVersion = "1.33.25" diff --git a/vendor/github.com/aws/aws-sdk-go-v2/credentials/CHANGELOG.md b/vendor/github.com/aws/aws-sdk-go-v2/credentials/CHANGELOG.md index 583d72f234..2032a8055f 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/credentials/CHANGELOG.md +++ b/vendor/github.com/aws/aws-sdk-go-v2/credentials/CHANGELOG.md @@ -1,3 +1,21 @@ +# v1.21.7 (2026-12-01.2) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.21.6 (2026-12-01) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.21.5 (2026-11-27) + +* **Dependency Update**: Update smithy-go to v1.28.11 +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.21.4 (2026-11-25) + +* **Dependency Update**: Update to smithy-go v1.28.10. +* **Dependency Update**: Updated to the latest SDK module versions + # v1.21.3 (2026-11-19) * **Dependency Update**: Updated to the latest SDK module versions diff --git a/vendor/github.com/aws/aws-sdk-go-v2/credentials/go_module_metadata.go b/vendor/github.com/aws/aws-sdk-go-v2/credentials/go_module_metadata.go index a8d4df7e24..3da0d7dc41 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/credentials/go_module_metadata.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/credentials/go_module_metadata.go @@ -3,4 +3,4 @@ package credentials // goModuleVersion is the tagged release for this module -const goModuleVersion = "1.21.3" +const goModuleVersion = "1.21.7" diff --git a/vendor/github.com/aws/aws-sdk-go-v2/feature/ec2/imds/CHANGELOG.md b/vendor/github.com/aws/aws-sdk-go-v2/feature/ec2/imds/CHANGELOG.md index 7dd6b34185..d5c5fa2735 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/feature/ec2/imds/CHANGELOG.md +++ b/vendor/github.com/aws/aws-sdk-go-v2/feature/ec2/imds/CHANGELOG.md @@ -1,3 +1,17 @@ +# v1.20.12 (2026-12-01) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.20.11 (2026-11-27) + +* **Dependency Update**: Update smithy-go to v1.28.11 +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.20.10 (2026-11-25) + +* **Dependency Update**: Update to smithy-go v1.28.10. +* **Dependency Update**: Updated to the latest SDK module versions + # v1.20.9 (2026-11-10) * **Dependency Update**: Update to smithy-go v1.28.9. diff --git a/vendor/github.com/aws/aws-sdk-go-v2/feature/ec2/imds/go_module_metadata.go b/vendor/github.com/aws/aws-sdk-go-v2/feature/ec2/imds/go_module_metadata.go index 835c9ef417..0098872c6d 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/feature/ec2/imds/go_module_metadata.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/feature/ec2/imds/go_module_metadata.go @@ -3,4 +3,4 @@ package imds // goModuleVersion is the tagged release for this module -const goModuleVersion = "1.20.9" +const goModuleVersion = "1.20.12" diff --git a/vendor/github.com/aws/aws-sdk-go-v2/internal/configsources/CHANGELOG.md b/vendor/github.com/aws/aws-sdk-go-v2/internal/configsources/CHANGELOG.md index 5475e5d82e..27451d4413 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/internal/configsources/CHANGELOG.md +++ b/vendor/github.com/aws/aws-sdk-go-v2/internal/configsources/CHANGELOG.md @@ -1,3 +1,17 @@ +# v1.5.15 (2026-12-01) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.5.14 (2026-11-27) + +* **Dependency Update**: Update smithy-go to v1.28.11 +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.5.13 (2026-11-25) + +* **Dependency Update**: Update to smithy-go v1.28.10. +* **Dependency Update**: Updated to the latest SDK module versions + # v1.5.12 (2026-11-10) * **Dependency Update**: Update to smithy-go v1.28.9. diff --git a/vendor/github.com/aws/aws-sdk-go-v2/internal/configsources/go_module_metadata.go b/vendor/github.com/aws/aws-sdk-go-v2/internal/configsources/go_module_metadata.go index cb6804e5f4..d8311353a0 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/internal/configsources/go_module_metadata.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/internal/configsources/go_module_metadata.go @@ -3,4 +3,4 @@ package configsources // goModuleVersion is the tagged release for this module -const goModuleVersion = "1.5.12" +const goModuleVersion = "1.5.15" diff --git a/vendor/github.com/aws/aws-sdk-go-v2/internal/endpoints/v2/CHANGELOG.md b/vendor/github.com/aws/aws-sdk-go-v2/internal/endpoints/v2/CHANGELOG.md index 542f014eec..bea3dfd6ec 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/internal/endpoints/v2/CHANGELOG.md +++ b/vendor/github.com/aws/aws-sdk-go-v2/internal/endpoints/v2/CHANGELOG.md @@ -1,3 +1,17 @@ +# v2.8.15 (2026-12-01) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v2.8.14 (2026-11-27) + +* **Dependency Update**: Update smithy-go to v1.28.11 +* **Dependency Update**: Updated to the latest SDK module versions + +# v2.8.13 (2026-11-25) + +* **Dependency Update**: Update to smithy-go v1.28.10. +* **Dependency Update**: Updated to the latest SDK module versions + # v2.8.12 (2026-11-10) * **Dependency Update**: Update to smithy-go v1.28.9. diff --git a/vendor/github.com/aws/aws-sdk-go-v2/internal/endpoints/v2/go_module_metadata.go b/vendor/github.com/aws/aws-sdk-go-v2/internal/endpoints/v2/go_module_metadata.go index 951b4b4655..e1cb0fb050 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/internal/endpoints/v2/go_module_metadata.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/internal/endpoints/v2/go_module_metadata.go @@ -3,4 +3,4 @@ package endpoints // goModuleVersion is the tagged release for this module -const goModuleVersion = "2.8.12" +const goModuleVersion = "2.8.15" diff --git a/vendor/github.com/aws/aws-sdk-go-v2/internal/sync/singleflight/LICENSE b/vendor/github.com/aws/aws-sdk-go-v2/internal/sync/singleflight/LICENSE index fe6a62006a..6a66aea5ea 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/internal/sync/singleflight/LICENSE +++ b/vendor/github.com/aws/aws-sdk-go-v2/internal/sync/singleflight/LICENSE @@ -14,7 +14,7 @@ distribution. contributors may be used to endorse or promote products derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY THE COPYIGHT HOLDERS AND CONTRIBUTORS +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT @@ -25,4 +25,3 @@ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - diff --git a/vendor/github.com/aws/aws-sdk-go-v2/internal/v4a/CHANGELOG.md b/vendor/github.com/aws/aws-sdk-go-v2/internal/v4a/CHANGELOG.md index 45cf5a82ee..bd8977cfb9 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/internal/v4a/CHANGELOG.md +++ b/vendor/github.com/aws/aws-sdk-go-v2/internal/v4a/CHANGELOG.md @@ -1,3 +1,17 @@ +# v1.5.15 (2026-12-01) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.5.14 (2026-11-27) + +* **Dependency Update**: Update smithy-go to v1.28.11 +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.5.13 (2026-11-25) + +* **Dependency Update**: Update to smithy-go v1.28.10. +* **Dependency Update**: Updated to the latest SDK module versions + # v1.5.12 (2026-11-10) * **Dependency Update**: Update to smithy-go v1.28.9. diff --git a/vendor/github.com/aws/aws-sdk-go-v2/internal/v4a/go_module_metadata.go b/vendor/github.com/aws/aws-sdk-go-v2/internal/v4a/go_module_metadata.go index 33a6a969ed..db46ca35b3 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/internal/v4a/go_module_metadata.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/internal/v4a/go_module_metadata.go @@ -3,4 +3,4 @@ package v4a // goModuleVersion is the tagged release for this module -const goModuleVersion = "1.5.12" +const goModuleVersion = "1.5.15" diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/ecs/CHANGELOG.md b/vendor/github.com/aws/aws-sdk-go-v2/service/ecs/CHANGELOG.md index 0657aefb10..6a70d6fe72 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/ecs/CHANGELOG.md +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/ecs/CHANGELOG.md @@ -1,3 +1,17 @@ +# v1.106.3 (2026-12-01) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.106.2 (2026-11-27) + +* **Dependency Update**: Update smithy-go to v1.28.11 +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.106.1 (2026-11-25) + +* **Dependency Update**: Update to smithy-go v1.28.10. +* **Dependency Update**: Updated to the latest SDK module versions + # v1.106.0 (2026-11-16) * **Feature**: Amazon ECS gateway connectors now support a configurable deregistration delay (0-3600 seconds, default 300 seconds). diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/ecs/go_module_metadata.go b/vendor/github.com/aws/aws-sdk-go-v2/service/ecs/go_module_metadata.go index 661fa7c706..7d2213bd9a 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/ecs/go_module_metadata.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/ecs/go_module_metadata.go @@ -3,4 +3,4 @@ package ecs // goModuleVersion is the tagged release for this module -const goModuleVersion = "1.106.0" +const goModuleVersion = "1.106.3" diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing/CHANGELOG.md b/vendor/github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing/CHANGELOG.md index 3f50263d5c..9b3b8d851d 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing/CHANGELOG.md +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing/CHANGELOG.md @@ -1,3 +1,17 @@ +# v1.42.3 (2026-12-01) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.42.2 (2026-11-27) + +* **Dependency Update**: Update smithy-go to v1.28.11 +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.42.1 (2026-11-25) + +* **Dependency Update**: Update to smithy-go v1.28.10. +* **Dependency Update**: Updated to the latest SDK module versions + # v1.42.0 (2026-11-10) * **Feature**: Enable schema-based (de)serialization for this service. diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing/go_module_metadata.go b/vendor/github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing/go_module_metadata.go index f89db2eea5..407c178aa8 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing/go_module_metadata.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing/go_module_metadata.go @@ -3,4 +3,4 @@ package elasticloadbalancing // goModuleVersion is the tagged release for this module -const goModuleVersion = "1.42.0" +const goModuleVersion = "1.42.3" diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2/CHANGELOG.md b/vendor/github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2/CHANGELOG.md index 6b4f0c9693..943de0b33b 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2/CHANGELOG.md +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2/CHANGELOG.md @@ -1,3 +1,17 @@ +# v1.65.3 (2026-12-01) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.65.2 (2026-11-27) + +* **Dependency Update**: Update smithy-go to v1.28.11 +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.65.1 (2026-11-25) + +* **Dependency Update**: Update to smithy-go v1.28.10. +* **Dependency Update**: Updated to the latest SDK module versions + # v1.65.0 (2026-11-19) * **Feature**: Network Load Balancer now supports mutual TLS (mTLS), letting you authenticate client certificates before granting access. You can configure a trust store of certificate authorities on your Network Load Balancer, which will then verify the client certificate on each inbound connection. diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2/go_module_metadata.go b/vendor/github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2/go_module_metadata.go index e6c4781c9d..f914999572 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2/go_module_metadata.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2/go_module_metadata.go @@ -3,4 +3,4 @@ package elasticloadbalancingv2 // goModuleVersion is the tagged release for this module -const goModuleVersion = "1.65.0" +const goModuleVersion = "1.65.3" diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding/CHANGELOG.md b/vendor/github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding/CHANGELOG.md index c706bc1299..343e8b8d99 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding/CHANGELOG.md +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding/CHANGELOG.md @@ -1,3 +1,11 @@ +# v1.13.27 (2026-11-27) + +* **Dependency Update**: Update smithy-go to v1.28.11 + +# v1.13.26 (2026-11-25) + +* **Dependency Update**: Update to smithy-go v1.28.10. + # v1.13.25 (2026-11-10) * **Dependency Update**: Update to smithy-go v1.28.9. diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding/go_module_metadata.go b/vendor/github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding/go_module_metadata.go index eb0aa9d9c0..7466eed57d 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding/go_module_metadata.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding/go_module_metadata.go @@ -3,4 +3,4 @@ package acceptencoding // goModuleVersion is the tagged release for this module -const goModuleVersion = "1.13.25" +const goModuleVersion = "1.13.27" diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/internal/checksum/CHANGELOG.md b/vendor/github.com/aws/aws-sdk-go-v2/service/internal/checksum/CHANGELOG.md index a3725736f4..7440d60398 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/internal/checksum/CHANGELOG.md +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/internal/checksum/CHANGELOG.md @@ -1,3 +1,17 @@ +# v1.11.16 (2026-12-01) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.11.15 (2026-11-27) + +* **Dependency Update**: Update smithy-go to v1.28.11 +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.11.14 (2026-11-25) + +* **Dependency Update**: Update to smithy-go v1.28.10. +* **Dependency Update**: Updated to the latest SDK module versions + # v1.11.13 (2026-11-10) * **Dependency Update**: Update to smithy-go v1.28.9. diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/internal/checksum/go_module_metadata.go b/vendor/github.com/aws/aws-sdk-go-v2/service/internal/checksum/go_module_metadata.go index 54c6a03940..d77b023e88 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/internal/checksum/go_module_metadata.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/internal/checksum/go_module_metadata.go @@ -3,4 +3,4 @@ package checksum // goModuleVersion is the tagged release for this module -const goModuleVersion = "1.11.13" +const goModuleVersion = "1.11.16" diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/internal/presigned-url/CHANGELOG.md b/vendor/github.com/aws/aws-sdk-go-v2/service/internal/presigned-url/CHANGELOG.md index f30ea9c5b0..4a0c61dc40 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/internal/presigned-url/CHANGELOG.md +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/internal/presigned-url/CHANGELOG.md @@ -1,3 +1,17 @@ +# v1.14.15 (2026-12-01) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.14.14 (2026-11-27) + +* **Dependency Update**: Update smithy-go to v1.28.11 +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.14.13 (2026-11-25) + +* **Dependency Update**: Update to smithy-go v1.28.10. +* **Dependency Update**: Updated to the latest SDK module versions + # v1.14.12 (2026-11-10) * **Dependency Update**: Update to smithy-go v1.28.9. diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/internal/presigned-url/go_module_metadata.go b/vendor/github.com/aws/aws-sdk-go-v2/service/internal/presigned-url/go_module_metadata.go index cbb4fb1811..9d4a4ba977 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/internal/presigned-url/go_module_metadata.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/internal/presigned-url/go_module_metadata.go @@ -3,4 +3,4 @@ package presignedurl // goModuleVersion is the tagged release for this module -const goModuleVersion = "1.14.12" +const goModuleVersion = "1.14.15" diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/internal/s3shared/CHANGELOG.md b/vendor/github.com/aws/aws-sdk-go-v2/service/internal/s3shared/CHANGELOG.md index a12bfc87f7..82807bddee 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/internal/s3shared/CHANGELOG.md +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/internal/s3shared/CHANGELOG.md @@ -1,3 +1,17 @@ +# v1.20.15 (2026-12-01) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.20.14 (2026-11-27) + +* **Dependency Update**: Update smithy-go to v1.28.11 +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.20.13 (2026-11-25) + +* **Dependency Update**: Update to smithy-go v1.28.10. +* **Dependency Update**: Updated to the latest SDK module versions + # v1.20.12 (2026-11-10) * **Dependency Update**: Update to smithy-go v1.28.9. diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/internal/s3shared/go_module_metadata.go b/vendor/github.com/aws/aws-sdk-go-v2/service/internal/s3shared/go_module_metadata.go index 6ec4bc7c99..07262498b4 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/internal/s3shared/go_module_metadata.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/internal/s3shared/go_module_metadata.go @@ -3,4 +3,4 @@ package s3shared // goModuleVersion is the tagged release for this module -const goModuleVersion = "1.20.12" +const goModuleVersion = "1.20.15" diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/pricing/CHANGELOG.md b/vendor/github.com/aws/aws-sdk-go-v2/service/pricing/CHANGELOG.md index b74f1b9eac..b9207079e9 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/pricing/CHANGELOG.md +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/pricing/CHANGELOG.md @@ -1,3 +1,17 @@ +# v1.51.9 (2026-12-01) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.51.8 (2026-11-27) + +* **Dependency Update**: Update smithy-go to v1.28.11 +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.51.7 (2026-11-25) + +* **Dependency Update**: Update to smithy-go v1.28.10. +* **Dependency Update**: Updated to the latest SDK module versions + # v1.51.6 (2026-11-10) * **Dependency Update**: Update to smithy-go v1.28.9. diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/pricing/go_module_metadata.go b/vendor/github.com/aws/aws-sdk-go-v2/service/pricing/go_module_metadata.go index 0f65f9ecff..7b05e0e41e 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/pricing/go_module_metadata.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/pricing/go_module_metadata.go @@ -3,4 +3,4 @@ package pricing // goModuleVersion is the tagged release for this module -const goModuleVersion = "1.51.6" +const goModuleVersion = "1.51.9" diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/signin/CHANGELOG.md b/vendor/github.com/aws/aws-sdk-go-v2/service/signin/CHANGELOG.md index b5cb0145f0..d982f5ad52 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/signin/CHANGELOG.md +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/signin/CHANGELOG.md @@ -1,3 +1,17 @@ +# v1.14.3 (2026-12-01) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.14.2 (2026-11-27) + +* **Dependency Update**: Update smithy-go to v1.28.11 +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.14.1 (2026-11-25) + +* **Dependency Update**: Update to smithy-go v1.28.10. +* **Dependency Update**: Updated to the latest SDK module versions + # v1.14.0 (2026-11-18) * **Feature**: These APIs enable customers and administrators to list, view, and revoke AWS Sign-In Sessions programmatically using the AWS CLI and SDKs, providing greater visibility and control over authenticated access. diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/signin/go_module_metadata.go b/vendor/github.com/aws/aws-sdk-go-v2/service/signin/go_module_metadata.go index 0a486019a1..6880a6fb12 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/signin/go_module_metadata.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/signin/go_module_metadata.go @@ -3,4 +3,4 @@ package signin // goModuleVersion is the tagged release for this module -const goModuleVersion = "1.14.0" +const goModuleVersion = "1.14.3" diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/sso/CHANGELOG.md b/vendor/github.com/aws/aws-sdk-go-v2/service/sso/CHANGELOG.md index ed31cc38eb..aa6fa53a56 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/sso/CHANGELOG.md +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/sso/CHANGELOG.md @@ -1,3 +1,17 @@ +# v1.39.8 (2026-12-01) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.39.7 (2026-11-27) + +* **Dependency Update**: Update smithy-go to v1.28.11 +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.39.6 (2026-11-25) + +* **Dependency Update**: Update to smithy-go v1.28.10. +* **Dependency Update**: Updated to the latest SDK module versions + # v1.39.5 (2026-11-10) * **Dependency Update**: Update to smithy-go v1.28.9. diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/sso/go_module_metadata.go b/vendor/github.com/aws/aws-sdk-go-v2/service/sso/go_module_metadata.go index 52e9d074c0..29fd94df5a 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/sso/go_module_metadata.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/sso/go_module_metadata.go @@ -3,4 +3,4 @@ package sso // goModuleVersion is the tagged release for this module -const goModuleVersion = "1.39.5" +const goModuleVersion = "1.39.8" diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/CHANGELOG.md b/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/CHANGELOG.md index 1c3e0469d7..a921490577 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/CHANGELOG.md +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/CHANGELOG.md @@ -1,3 +1,17 @@ +# v1.44.8 (2026-12-01) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.44.7 (2026-11-27) + +* **Dependency Update**: Update smithy-go to v1.28.11 +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.44.6 (2026-11-25) + +* **Dependency Update**: Update to smithy-go v1.28.10. +* **Dependency Update**: Updated to the latest SDK module versions + # v1.44.5 (2026-11-10) * **Dependency Update**: Update to smithy-go v1.28.9. diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/go_module_metadata.go b/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/go_module_metadata.go index bad9004976..f14458580e 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/go_module_metadata.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/ssooidc/go_module_metadata.go @@ -3,4 +3,4 @@ package ssooidc // goModuleVersion is the tagged release for this module -const goModuleVersion = "1.44.5" +const goModuleVersion = "1.44.8" diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/CHANGELOG.md b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/CHANGELOG.md index 90a00e0660..1600713d1d 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/CHANGELOG.md +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/CHANGELOG.md @@ -1,3 +1,21 @@ +# v1.54.0 (2026-12-01.2) + +* **Feature**: Adds support for agent and workload identity (preview). AWS services can attest workloads and obtain verified identities for them from AWS STS. These identities are carried into role sessions, can be used to request JWT-SVIDs and X.509-SVIDs, and can be referenced in IAM policy conditions. + +# v1.53.3 (2026-12-01) + +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.53.2 (2026-11-27) + +* **Dependency Update**: Update smithy-go to v1.28.11 +* **Dependency Update**: Updated to the latest SDK module versions + +# v1.53.1 (2026-11-25) + +* **Dependency Update**: Update to smithy-go v1.28.10. +* **Dependency Update**: Updated to the latest SDK module versions + # v1.53.0 (2026-11-19) * **Feature**: AWS STS adds GetScopedCredentials and expands Trusted Identity Propagation (TIP) to IAM federation and IAM Roles Anywhere. GetScopedCredentials reduces an existing session's permissions and duration. TIP carries verified user or workload identity for authorization and CloudTrail auditing. diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_GetCertificate.go b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_GetCertificate.go new file mode 100644 index 0000000000..8e5569dc64 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_GetCertificate.go @@ -0,0 +1,233 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package sts + +import ( + "context" + "github.com/aws/aws-sdk-go-v2/service/sts/schemas" + smithy "github.com/aws/smithy-go" + "github.com/aws/smithy-go/middleware" + "time" +) + +// Returns an X.509 SPIFFE Verifiable Identity Document (X509-SVID) for the +// workload identity of the calling session. Your workload can use the certificate +// to prove its identity to peers, for example in mutual TLS (mTLS). The X.509 +// signer of the workload identity provider that issued the workload identity of +// the session signs the certificate in the Amazon Web Services Region that you +// send the request to. +// +// You can call GetCertificate only with temporary credentials for a role session +// that has a workload identity, and the workload identity provider must use the +// SPIFFE naming scheme. You can't call it with long-term IAM user credentials or +// with federated user credentials from GetFederationToken. Amazon Web Services STS denies the +// request if the calling session doesn't have a workload identity. Amazon Web +// Services STS also denies the request if the workload identity template or +// provider of the session no longer exists. +// +// Amazon Web Services STS takes the identity in the certificate from the calling +// session, not from the request. Amazon Web Services STS uses only the public key +// from the certificate signing request (CSR) that you provide. The certificate +// chain in the response can include the root certificate authority (CA) +// certificate, so don't use it as a source of trust anchors. To verify +// certificates that Amazon Web Services STS issues, get trust anchors only from GetTrustBundles. +// +// To call GetCertificate , you must have permission for the sts:GetCertificate +// action. Because Amazon Web Services STS issues the certificate on your behalf, +// you must also have permission for the acm-pca:IssueCertificate and +// acm-pca:GetCertificate actions on the certificate authority (CA) that the signer +// of the workload identity provider uses. +// +// Amazon Web Services STS returns some errors from Amazon Web Services Private CA +// to you. If Amazon Web Services Private CA denies the request, the request fails +// with an access denied error. Check your permissions on the CA. If the account +// that owns the CA has exceeded its Amazon Web Services Private CA quota for +// issuing certificates, the request fails with a throttling error. Check the +// quotas for Amazon Web Services Private CA in that account. +// +// The GetCertificate API is not available on the STS global endpoint. Send +// requests to an STS endpoint in an Amazon Web Services Region. +func (c *Client) GetCertificate(ctx context.Context, params *GetCertificateInput, optFns ...func(*Options)) (*GetCertificateOutput, error) { + if params == nil { + params = &GetCertificateInput{} + } + + result, metadata, err := c.invokeOperation(ctx, "GetCertificate", params, optFns, c.addOperationGetCertificateMiddlewares) + if err != nil { + return nil, err + } + + out := result.(*GetCertificateOutput) + out.ResultMetadata = metadata + return out, nil +} + +type GetCertificateInput struct { + + // A PEM-encoded PKCS #10 certificate signing request (CSR) that contains the + // public key for the certificate. The CSR must be signed with the matching private + // key. + // + // Amazon Web Services STS uses only the public key from the CSR. Amazon Web + // Services STS ignores the subject, subject alternative names (SANs), and + // requested extensions in the CSR. The signing algorithm of the certificate is set + // by the signer of the workload identity provider, not by the CSR. + // + // The CSR can be up to 32,768 characters long. If the CSR is blank, can't be + // parsed, has a signature that doesn't verify, or uses a key type or key size that + // the signer doesn't support, the request fails with + // MalformedCertificateSigningRequestException . + // + // This member is required. + CertificateSigningRequest *string + + // The time, in seconds, that the certificate is valid. The value can range from + // 3,600 seconds (1 hour) to 43,200 seconds (12 hours). If you don't specify a + // value, the certificate is valid for 43,200 seconds (12 hours). + // + // The expiration of the calling session doesn't limit this value. The certificate + // can remain valid after the session that requested it expires. This differs from + // GetWebIdentityToken , which rejects a token duration that ends after the calling + // session expires. + MaxDurationSeconds *int32 + + noSmithyDocumentSerde +} + +func (v *GetCertificateInput) Serialize(s smithy.ShapeSerializer) { + s.WriteStruct(schemas.GetCertificateRequest) + v.SerializeMembers(s) + s.CloseStruct() +} + +func (v *GetCertificateInput) SerializeMembers(s smithy.ShapeSerializer) { + if v.CertificateSigningRequest != nil { + s.WriteString(schemas.GetCertificateRequest_CertificateSigningRequest, *v.CertificateSigningRequest) + } + if v.MaxDurationSeconds != nil { + s.WriteInt32(schemas.GetCertificateRequest_MaxDurationSeconds, *v.MaxDurationSeconds) + } +} + +// Contains the response to a successful GetCertificate request. +type GetCertificateOutput struct { + + // The issued X.509 certificate (X509-SVID), PEM-encoded. The certificate has an + // empty subject distinguished name (DN) and one URI subject alternative name (SAN) + // that contains the SPIFFE ID of the workload. You can use the certificate for + // both client and server authentication. + Certificate *string + + // The PEM-encoded certificate chain that links the certificate to the root + // certificate authority (CA), in the same format that Amazon Web Services Private + // CA returns. The chain can include the root CA certificate. Don't use the chain + // as a source of trust anchors. To get the trust anchors for the provider, call GetTrustBundles. + CertificateChain *string + + // The date and time, in UTC, when the certificate expires. This is + // MaxDurationSeconds after Amazon Web Services STS issued the certificate, or 12 + // hours if you didn't specify MaxDurationSeconds . + NotAfter *time.Time + + // The date and time, in UTC, when the certificate becomes valid. To allow for + // differences between clocks, Amazon Web Services STS sets this to five minutes + // before it issues the certificate. + NotBefore *time.Time + + // The SPIFFE ID of the workload, for example + // spiffe://example.org/payments/checkout . This is the same value as the URI + // subject alternative name (SAN) of the certificate, and comes from the calling + // session. + Subject *string + + // Metadata pertaining to the operation's result. + ResultMetadata middleware.Metadata + + noSmithyDocumentSerde +} + +func (v *GetCertificateOutput) Serialize(s smithy.ShapeSerializer) { + s.WriteStruct(schemas.GetCertificateResponse) + v.SerializeMembers(s) + s.CloseStruct() +} + +func (v *GetCertificateOutput) SerializeMembers(s smithy.ShapeSerializer) { + if v.Certificate != nil { + s.WriteString(schemas.GetCertificateResponse_Certificate, *v.Certificate) + } + if v.CertificateChain != nil { + s.WriteString(schemas.GetCertificateResponse_CertificateChain, *v.CertificateChain) + } + if v.NotAfter != nil { + s.WriteTime(schemas.GetCertificateResponse_NotAfter, *v.NotAfter) + } + if v.NotBefore != nil { + s.WriteTime(schemas.GetCertificateResponse_NotBefore, *v.NotBefore) + } + if v.Subject != nil { + s.WriteString(schemas.GetCertificateResponse_Subject, *v.Subject) + } +} +func (v *GetCertificateOutput) Deserialize(d smithy.ShapeDeserializer) error { + return smithy.ReadStruct(d, schemas.GetCertificateResponse, func(s *smithy.Schema) error { + switch s { + case schemas.GetCertificateResponse_Certificate: + v.Certificate = new(string) + return d.ReadString(schemas.GetCertificateResponse_Certificate, v.Certificate) + case schemas.GetCertificateResponse_CertificateChain: + v.CertificateChain = new(string) + return d.ReadString(schemas.GetCertificateResponse_CertificateChain, v.CertificateChain) + case schemas.GetCertificateResponse_NotAfter: + v.NotAfter = new(time.Time) + return d.ReadTime(schemas.GetCertificateResponse_NotAfter, v.NotAfter) + case schemas.GetCertificateResponse_NotBefore: + v.NotBefore = new(time.Time) + return d.ReadTime(schemas.GetCertificateResponse_NotBefore, v.NotBefore) + case schemas.GetCertificateResponse_Subject: + v.Subject = new(string) + return d.ReadString(schemas.GetCertificateResponse_Subject, v.Subject) + } + return nil + }) +} +func (c *Client) addOperationGetCertificateMiddlewares(stack *middleware.Stack, options Options) (err error) { + if err := stack.Serialize.Add(&serializeRequestMiddleware{options: &options, operationSchema: smithy.NewOperationSchema(schemas.GetCertificate, schemas.GetCertificateRequest, schemas.GetCertificateResponse)}, middleware.After); err != nil { + return err + } + if err := stack.Deserialize.Add(&deserializeResponseMiddleware{options: &options, operationSchema: smithy.NewOperationSchema(schemas.GetCertificate, schemas.GetCertificateRequest, schemas.GetCertificateResponse), output: &GetCertificateOutput{}}, middleware.After); err != nil { + return err + } + + if err = addResolveEndpointMiddleware(stack, options); err != nil { + return err + } + if err = addComputePayloadSHA256(stack); err != nil { + return err + } + if err = addRecordResponseTiming(stack, options); err != nil { + return err + } + if err = addCredentialSource(stack, options); err != nil { + return err + } + if err = addOpGetCertificateValidationMiddleware(stack); err != nil { + return err + } + if err = addRequestIDRetrieverMiddleware(stack); err != nil { + return err + } + if err = addResponseErrorMiddleware(stack); err != nil { + return err + } + if err = addRequestResponseLogging(stack, options); err != nil { + return err + } + if err = addDisableHTTPSMiddleware(stack, options); err != nil { + return err + } + if err = addInterceptors(stack, options); err != nil { + return err + } + return nil +} diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_GetScopedCredentials.go b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_GetScopedCredentials.go index a7b482533f..20d1abafa7 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_GetScopedCredentials.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_GetScopedCredentials.go @@ -75,12 +75,12 @@ type GetScopedCredentialsInput struct { // of the valid character list (\u0020 through \u00FF). It can also include the tab // (\u0009), linefeed (\u000A), and carriage return (\u000D) characters. // - // An internal conversion compresses the inline scope down policy into a packed - // binary format that has a separate limit. If the packed policy exceeds this - // limit, the request fails with PackedPolicyTooLarge . + // If the session token exceeds the maximum allowed size, GetScopedCredentials + // returns a PackedPolicyTooLarge error. Reduce the size of the scope down policy + // and try again. // - // If the document is not valid IAM policy JSON, the request fails with - // MalformedPolicyDocument . + // If the document is not valid IAM policy JSON, GetScopedCredentials returns a + // MalformedPolicyDocument error. Correct the policy document and try again. Policy *string // A caller-supplied description of the scoped session. The value cannot exceed diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_GetTrustBundles.go b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_GetTrustBundles.go new file mode 100644 index 0000000000..6e4e97ba5b --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_GetTrustBundles.go @@ -0,0 +1,155 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package sts + +import ( + "context" + "github.com/aws/aws-sdk-go-v2/service/sts/schemas" + "github.com/aws/aws-sdk-go-v2/service/sts/types" + smithy "github.com/aws/smithy-go" + "github.com/aws/smithy-go/middleware" +) + +// Returns the trust bundles for a workload identity provider. Relying parties use +// a trust bundle to verify the X509-SVIDs and JWT-SVIDs of the workloads of that +// provider. For more information, see GetCertificateand GetWebIdentityToken. +// +// A trust bundle contains the public keys that the provider currently publishes. +// Amazon Web Services STS publishes the key of a new signer before the signer +// starts signing. After a signer stops signing, Amazon Web Services STS continues +// to publish its key for at least as long as any certificate or token that it +// signed is valid. Get the trust bundle again at the interval in its +// spiffe_refresh_hint value, and trust every key that it contains. If the provider +// has no signers, the trust bundle contains no keys. +// +// You can get the trust bundles for a provider that your account owns. For a +// provider that an organization owns, you can get its trust bundles from any +// account in that organization. If you specify a provider that doesn't exist or +// that is outside that scope, the request fails with ResourceNotFoundException . +// +// You can call GetTrustBundles with long-term or temporary credentials. You must +// have permission for the sts:GetTrustBundles action. The action doesn't support +// resource-level permissions. +// +// The GetTrustBundles API is not available on the STS global endpoint. Send +// requests to an STS endpoint in an Amazon Web Services Region. +func (c *Client) GetTrustBundles(ctx context.Context, params *GetTrustBundlesInput, optFns ...func(*Options)) (*GetTrustBundlesOutput, error) { + if params == nil { + params = &GetTrustBundlesInput{} + } + + result, metadata, err := c.invokeOperation(ctx, "GetTrustBundles", params, optFns, c.addOperationGetTrustBundlesMiddlewares) + if err != nil { + return nil, err + } + + out := result.(*GetTrustBundlesOutput) + out.ResultMetadata = metadata + return out, nil +} + +type GetTrustBundlesInput struct { + + // The Amazon Resource Name (ARN) of the workload identity provider. The ARN of a + // provider that an account owns contains the account ID, and the ARN of a provider + // that an organization owns contains the organization ID in place of the account + // ID. For example: + // + // - arn:aws:iam::444455556666:workload-identity-provider/provider-id + // + // - arn:aws:iam::o-a1b2c3d4e5:workload-identity-provider/provider-id + // + // If the value isn't a valid workload identity provider ARN, the request fails + // with a validation error. + // + // This member is required. + ProviderArn *string + + noSmithyDocumentSerde +} + +func (v *GetTrustBundlesInput) Serialize(s smithy.ShapeSerializer) { + s.WriteStruct(schemas.GetTrustBundlesRequest) + v.SerializeMembers(s) + s.CloseStruct() +} + +func (v *GetTrustBundlesInput) SerializeMembers(s smithy.ShapeSerializer) { + if v.ProviderArn != nil { + s.WriteString(schemas.GetTrustBundlesRequest_ProviderArn, *v.ProviderArn) + } +} + +// Contains the response to a successful GetTrustBundles request. +type GetTrustBundlesOutput struct { + + // The trust bundles for the provider, one for each trust domain. Currently, this + // list contains one trust bundle, for the trust domain of the provider. + TrustBundles []types.TrustBundleEntry + + // Metadata pertaining to the operation's result. + ResultMetadata middleware.Metadata + + noSmithyDocumentSerde +} + +func (v *GetTrustBundlesOutput) Serialize(s smithy.ShapeSerializer) { + s.WriteStruct(schemas.GetTrustBundlesResponse) + v.SerializeMembers(s) + s.CloseStruct() +} + +func (v *GetTrustBundlesOutput) SerializeMembers(s smithy.ShapeSerializer) { + if v.TrustBundles != nil { + serializetrustBundleListType(s, schemas.GetTrustBundlesResponse_TrustBundles, v.TrustBundles) + } +} +func (v *GetTrustBundlesOutput) Deserialize(d smithy.ShapeDeserializer) error { + return smithy.ReadStruct(d, schemas.GetTrustBundlesResponse, func(s *smithy.Schema) error { + switch s { + case schemas.GetTrustBundlesResponse_TrustBundles: + return deserializetrustBundleListType(d, schemas.GetTrustBundlesResponse_TrustBundles, &v.TrustBundles) + } + return nil + }) +} +func (c *Client) addOperationGetTrustBundlesMiddlewares(stack *middleware.Stack, options Options) (err error) { + if err := stack.Serialize.Add(&serializeRequestMiddleware{options: &options, operationSchema: smithy.NewOperationSchema(schemas.GetTrustBundles, schemas.GetTrustBundlesRequest, schemas.GetTrustBundlesResponse)}, middleware.After); err != nil { + return err + } + if err := stack.Deserialize.Add(&deserializeResponseMiddleware{options: &options, operationSchema: smithy.NewOperationSchema(schemas.GetTrustBundles, schemas.GetTrustBundlesRequest, schemas.GetTrustBundlesResponse), output: &GetTrustBundlesOutput{}}, middleware.After); err != nil { + return err + } + + if err = addResolveEndpointMiddleware(stack, options); err != nil { + return err + } + if err = addComputePayloadSHA256(stack); err != nil { + return err + } + if err = addRecordResponseTiming(stack, options); err != nil { + return err + } + if err = addCredentialSource(stack, options); err != nil { + return err + } + if err = addOpGetTrustBundlesValidationMiddleware(stack); err != nil { + return err + } + if err = addRequestIDRetrieverMiddleware(stack); err != nil { + return err + } + if err = addResponseErrorMiddleware(stack); err != nil { + return err + } + if err = addRequestResponseLogging(stack, options); err != nil { + return err + } + if err = addDisableHTTPSMiddleware(stack, options); err != nil { + return err + } + if err = addInterceptors(stack, options); err != nil { + return err + } + return nil +} diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_GetWebIdentityToken.go b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_GetWebIdentityToken.go index 892d13b777..b46bdb8a52 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_GetWebIdentityToken.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_GetWebIdentityToken.go @@ -18,11 +18,32 @@ import ( // token is signed by Amazon Web Services STS and can be publicly verified using // the verification keys published at the issuer's JWKS endpoint. // -// The sub (subject) claim contains the identity that SubjectMode selects. -// Whichever subject mode you use, the principal_id claim under the -// https://sts.amazonaws.com/ namespace contains the ARN of the principal that -// requested the token, when that principal has an ARN. For a role session, this is -// the ARN of the role. +// For a token of type AWSIdentity (the default), the sub (subject) claim contains +// the identity that SubjectMode selects. Whichever subject mode you use, the +// principal_id claim under the https://sts.amazonaws.com/ namespace contains the +// ARN of the principal that requested the token, when that principal has an ARN. +// For a role session, this is the ARN of the role. +// +// If you set TokenType to JWT_SVID , Amazon Web Services STS instead returns a JWT +// SPIFFE Verifiable Identity Document (JWT-SVID) for the workload identity of the +// calling session. You can request a JWT-SVID only with temporary credentials for +// a role session that has a workload identity, and the workload identity provider +// must use the SPIFFE naming scheme. Amazon Web Services STS sets the sub claim +// to the SPIFFE ID of the workload and the iss claim from the workload identity +// provider, and signs the token with the JWT signer of the provider. +// +// A JWT-SVID contains only the sub , aud , iss , iat , exp , and jti claims. You +// must specify exactly one audience for a JWT-SVID, and you can't specify Tags . +// +// The iss claim of a JWT-SVID identifies a public issuer endpoint that publishes +// OpenID Connect (OIDC) discovery metadata and a JSON Web Key Set (JWKS) for the +// provider. Services that verify the token (relying parties) can verify a JWT-SVID +// through standard OIDC discovery from the iss value, in the same way as a token +// of type AWSIdentity . They can also verify it with the trust bundle that GetTrustBundles +// returns. +// +// TokenType is mutually exclusive with SubjectMode and Scope . If you specify +// TokenType , with either value, you can't also specify SubjectMode or Scope . // // The GetWebIdentityToken API is not available on the STS Global endpoint. func (c *Client) GetWebIdentityToken(ctx context.Context, params *GetWebIdentityTokenInput, optFns ...func(*Options)) (*GetWebIdentityTokenOutput, error) { @@ -47,12 +68,15 @@ type GetWebIdentityTokenInput struct { // validate and use the token. The external service should verify this claim to // ensure the token was intended for their use. // + // If you set TokenType to JWT_SVID , you must specify exactly one audience. + // // This member is required. Audience []string // The cryptographic algorithm to use for signing the JSON Web Token (JWT). Valid // values are RS256 (RSA with SHA-256) and ES384 (ECDSA using P-384 curve with - // SHA-384). + // SHA-384). You can use either algorithm with both token types, AWSIdentity and + // JWT_SVID . // // This member is required. SigningAlgorithm *string @@ -62,6 +86,12 @@ type GetWebIdentityTokenInput struct { // specified, the default duration is 300 seconds (5 minutes). The token is // designed to be short-lived and should be used for proof of identity, then // exchanged for credentials or short-lived tokens in the external service. + // + // The token can't remain valid after the calling session expires. If the + // requested duration ends after the calling session expires, Amazon Web Services + // STS rejects the request with SessionDurationEscalationException . This applies + // to both token types. A certificate from GetCertificate, in contrast, can remain valid after + // the session that requested it expires. DurationSeconds *int32 // One or more OAuth 2.0 scope values to include in the JSON Web Token (JWT). @@ -77,6 +107,10 @@ type GetWebIdentityTokenInput struct { // You can't repeat a scope value. Scope values are case sensitive. This means // that read and READ are separate values. // + // Scope and TokenType are mutually exclusive. If you specify both, Amazon Web + // Services STS rejects the request with a validation error, whichever value of + // TokenType you specify. + // // You can specify Scope only when SubjectMode is OriginIdentity and you request // exactly one audience. To specify Scope , the calling principal must have // permission for the sts:SetWebIdentityTokenScope action in addition to @@ -90,6 +124,10 @@ type GetWebIdentityTokenInput struct { // Token (JWT). Valid values are AWSIdentity and OriginIdentity . If you don't // specify a value, Amazon Web Services STS uses AWSIdentity . // + // SubjectMode and TokenType are mutually exclusive. If you specify both, Amazon + // Web Services STS rejects the request with a validation error, whichever value of + // TokenType you specify. + // // - AWSIdentity – The sub claim contains the ARN of the calling Amazon Web // Services principal. // @@ -117,8 +155,38 @@ type GetWebIdentityTokenInput struct { // An optional list of tags to include in the JSON Web Token (JWT). These tags are // added as custom claims to the JWT and can be used by the downstream service for // authorization decisions. + // + // You can't specify Tags if you set TokenType to JWT_SVID . Tags []types.Tag + // The type of token to return. Valid values are AWSIdentity and JWT_SVID . If you + // don't specify a value, Amazon Web Services STS uses AWSIdentity . Each value + // returns the following type of token: + // + // AWSIdentity A JSON Web Token (JWT) that represents the calling Amazon Web + // Services identity. You can verify it with the keys at the issuer's JSON Web Key + // Set (JWKS) endpoint. + // + // JWT_SVID A JWT SPIFFE Verifiable Identity Document (JWT-SVID) for the workload + // identity of the calling session. You can request a JWT-SVID only with temporary + // credentials for a role session that has a workload identity, and the workload + // identity provider must use the SPIFFE naming scheme. Amazon Web Services STS + // sets the sub claim to the SPIFFE ID of the workload and the iss claim from the + // workload identity provider. You can't set either value in the request. You can + // verify a JWT-SVID through OIDC discovery from its iss claim, or with the trust + // bundle that GetTrustBundles returns. + // + // With JWT_SVID , you must specify exactly one audience, and you can't specify + // Tags . + // + // TokenType is mutually exclusive with SubjectMode and Scope . If you specify + // TokenType , with either value, and also specify SubjectMode or Scope , Amazon + // Web Services STS rejects the request with a validation error. + // + // You can use the sts:TokenType condition key in a policy to control which token + // types a principal can request. + TokenType types.WebIdentityTokenTypeType + noSmithyDocumentSerde } @@ -147,6 +215,9 @@ func (v *GetWebIdentityTokenInput) SerializeMembers(s smithy.ShapeSerializer) { if v.Tags != nil { serializetagListType(s, schemas.GetWebIdentityTokenRequest_Tags, v.Tags) } + if v.TokenType != "" { + s.WriteString(schemas.GetWebIdentityTokenRequest_TokenType, string(v.TokenType)) + } } type GetWebIdentityTokenOutput struct { @@ -166,6 +237,11 @@ type GetWebIdentityTokenOutput struct { // token by passing tags as request parameters to the GetWebIdentityToken API. The // token is signed using the specified signing algorithm and can be verified using // the verification keys available at the issuer's JWKS endpoint. + // + // If you set TokenType to JWT_SVID , the token is a SPIFFE JWT-SVID instead. A + // JWT-SVID contains only the sub (the SPIFFE ID of the workload), aud , iss , iat + // , exp , and jti claims. You can verify it through OIDC discovery from its iss + // claim, or with the trust bundle that GetTrustBundles returns. WebIdentityToken *string // Metadata pertaining to the operation's result. diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_IssueWorkloadIdentityContext.go b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_IssueWorkloadIdentityContext.go new file mode 100644 index 0000000000..b9886e08dc --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/api_op_IssueWorkloadIdentityContext.go @@ -0,0 +1,265 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package sts + +import ( + "context" + "github.com/aws/aws-sdk-go-v2/service/sts/schemas" + "github.com/aws/aws-sdk-go-v2/service/sts/types" + smithy "github.com/aws/smithy-go" + "github.com/aws/smithy-go/middleware" + "time" +) + +// Issues a workload identity context for a workload that an Amazon Web Services +// service runs for you. The service passes the context to AssumeRolein ProvidedContexts to +// get temporary security credentials for the workload. The resulting role session +// has the workload identity. If the workload identity provider uses the SPIFFE +// naming scheme, your workload can then call GetCertificate, or GetWebIdentityToken with a TokenType of JWT_SVID . +// +// Amazon Web Services services that run workloads call this operation with their +// own service credentials. You don't call it yourself. The service describes the +// workload in an attestation document, and names a workload identity template in +// WorkloadIdentityTemplateArn . Amazon Web Services STS builds the identity of the +// workload from the template and the attested values. +// +// The service must also name the account and the resource that it acts for, which +// Amazon Web Services STS makes available as the aws:SourceAccount and +// aws:SourceArn condition keys. For a template that an account owns, the source +// account must be that account. For one that an organization owns, the source +// account must be a member of that organization. +// +// Amazon Web Services STS issues the context only if the template has an +// attestation policy, and that policy allows the calling service to issue it for +// the attested values. The attestation policy sees each attested value as a +// condition key whose name begins with aws:WorkloadAttestation/aws/ . If the +// policy doesn't allow the request, or the template doesn't exist, the request +// fails with AccessDenied . +// +// A context can be redeemed only by the service that requested it, with the same +// source account and source ARN, only for the role in TargetRoleArn , and only +// until Expiration . The role session that AssumeRole returns ends no later than +// SessionExpiration . The trust policy of the role must allow the sts:AssumeRole +// action for the calling service. +// +// The IssueWorkloadIdentityContext API is not available on the STS global +// endpoint or in every partition. Send requests to an STS endpoint in an Amazon +// Web Services Region where the API is available. +func (c *Client) IssueWorkloadIdentityContext(ctx context.Context, params *IssueWorkloadIdentityContextInput, optFns ...func(*Options)) (*IssueWorkloadIdentityContextOutput, error) { + if params == nil { + params = &IssueWorkloadIdentityContextInput{} + } + + result, metadata, err := c.invokeOperation(ctx, "IssueWorkloadIdentityContext", params, optFns, c.addOperationIssueWorkloadIdentityContextMiddlewares) + if err != nil { + return nil, err + } + + out := result.(*IssueWorkloadIdentityContextOutput) + out.ResultMetadata = metadata + return out, nil +} + +type IssueWorkloadIdentityContextInput struct { + + // The facts that the calling service attests about the workload, as a JSON + // object. The keys and value types that the document can contain are set for each + // calling service. The document must be a single JSON object of up to 2,048 + // characters, with at least one key. Each value is a non-empty string of printable + // characters. + // + // Amazon Web Services STS records the attestation document in the CloudTrail + // event for the request, so don't put secrets in it. If the document isn't valid, + // the request fails with InvalidAttestationDocumentException . + // + // This member is required. + AttestationDocument *string + + // The time, in seconds, during which the calling service can pass the context to + // AssumeRole . The value can range from 60 seconds (1 minute) to 300 seconds (5 + // minutes). If you don't specify a value, the value is 60 seconds. + DurationSeconds *int32 + + // The longest time, in seconds, that a role session from this context can last, + // counted from when Amazon Web Services STS issues the context. The value can + // range from 900 seconds (15 minutes) to 43,200 seconds (12 hours). The role + // session that AssumeRole returns ends at the earlier of this time and the + // session duration that the AssumeRole request sets. + // + // If you don't specify a value, the context doesn't limit the session duration. + SessionDurationSeconds *int32 + + // The Amazon Resource Name (ARN) of the role that the calling service assumes + // with the context. The role must be in the account that owns the template. For a + // template that an organization owns, the role must be in the source account. If + // the role doesn't exist or is in another account, the request fails with + // AccessDenied . + // + // If you don't specify a role, the response contains only the Subject and the + // ProviderArn , with no context assertion to pass to AssumeRole . + TargetRoleArn *string + + // The Amazon Resource Name (ARN) of the workload identity template that Amazon + // Web Services STS uses to build the identity of the workload from the attested + // values. The ARN of a template that an organization owns contains the + // organization ID in place of the account ID. + // + // If you don't specify a template, the request fails with a validation error. + WorkloadIdentityTemplateArn *string + + noSmithyDocumentSerde +} + +func (v *IssueWorkloadIdentityContextInput) Serialize(s smithy.ShapeSerializer) { + s.WriteStruct(schemas.IssueWorkloadIdentityContextRequest) + v.SerializeMembers(s) + s.CloseStruct() +} + +func (v *IssueWorkloadIdentityContextInput) SerializeMembers(s smithy.ShapeSerializer) { + if v.AttestationDocument != nil { + s.WriteString(schemas.IssueWorkloadIdentityContextRequest_AttestationDocument, *v.AttestationDocument) + } + if v.DurationSeconds != nil { + s.WriteInt32(schemas.IssueWorkloadIdentityContextRequest_DurationSeconds, *v.DurationSeconds) + } + if v.SessionDurationSeconds != nil { + s.WriteInt32(schemas.IssueWorkloadIdentityContextRequest_SessionDurationSeconds, *v.SessionDurationSeconds) + } + if v.TargetRoleArn != nil { + s.WriteString(schemas.IssueWorkloadIdentityContextRequest_TargetRoleArn, *v.TargetRoleArn) + } + if v.WorkloadIdentityTemplateArn != nil { + s.WriteString(schemas.IssueWorkloadIdentityContextRequest_WorkloadIdentityTemplateArn, *v.WorkloadIdentityTemplateArn) + } +} + +// Contains the response to a successful IssueWorkloadIdentityContext request. +type IssueWorkloadIdentityContextOutput struct { + + // The context to pass to AssumeRole in ProvidedContexts . ProviderArn is the ARN of the + // workload identity provider that issued the context. ContextAssertion is the + // signed and encrypted context. It is present only if the request specified + // TargetRoleArn . + // + // Pass the context as the only entry in ProvidedContexts . Treat the context + // assertion like a credential until it expires. + // + // This member is required. + ProvidedContext *types.ProvidedContext + + // The identifier of the workload, up to 256 characters. For a workload identity + // provider that uses the SPIFFE naming scheme, this is the SPIFFE ID of the + // workload, for example spiffe://example.org/payments/checkout . A role session + // from this context carries this value as the identity of the workload. + // + // This member is required. + Subject *string + + // The Amazon Web Services service principal that can pass the context to + // AssumeRole . This is the service principal of the caller. Present only if the + // request specified TargetRoleArn . + Audience *string + + // The date and time, in UTC, after which AssumeRole no longer accepts the + // context. Present only if the request specified TargetRoleArn . + Expiration *time.Time + + // The latest date and time, in UTC, at which a role session from this context can + // end. Present only if the request specified both TargetRoleArn and + // SessionDurationSeconds . + SessionExpiration *time.Time + + // Metadata pertaining to the operation's result. + ResultMetadata middleware.Metadata + + noSmithyDocumentSerde +} + +func (v *IssueWorkloadIdentityContextOutput) Serialize(s smithy.ShapeSerializer) { + s.WriteStruct(schemas.IssueWorkloadIdentityContextResponse) + v.SerializeMembers(s) + s.CloseStruct() +} + +func (v *IssueWorkloadIdentityContextOutput) SerializeMembers(s smithy.ShapeSerializer) { + if v.Audience != nil { + s.WriteString(schemas.IssueWorkloadIdentityContextResponse_Audience, *v.Audience) + } + if v.Expiration != nil { + s.WriteTime(schemas.IssueWorkloadIdentityContextResponse_Expiration, *v.Expiration) + } + if v.ProvidedContext != nil { + s.WriteStruct(schemas.IssueWorkloadIdentityContextResponse_ProvidedContext) + v.ProvidedContext.SerializeMembers(s) + s.CloseStruct() + } + if v.SessionExpiration != nil { + s.WriteTime(schemas.IssueWorkloadIdentityContextResponse_SessionExpiration, *v.SessionExpiration) + } + if v.Subject != nil { + s.WriteString(schemas.IssueWorkloadIdentityContextResponse_Subject, *v.Subject) + } +} +func (v *IssueWorkloadIdentityContextOutput) Deserialize(d smithy.ShapeDeserializer) error { + return smithy.ReadStruct(d, schemas.IssueWorkloadIdentityContextResponse, func(s *smithy.Schema) error { + switch s { + case schemas.IssueWorkloadIdentityContextResponse_Audience: + v.Audience = new(string) + return d.ReadString(schemas.IssueWorkloadIdentityContextResponse_Audience, v.Audience) + case schemas.IssueWorkloadIdentityContextResponse_Expiration: + v.Expiration = new(time.Time) + return d.ReadTime(schemas.IssueWorkloadIdentityContextResponse_Expiration, v.Expiration) + case schemas.IssueWorkloadIdentityContextResponse_ProvidedContext: + v.ProvidedContext = &types.ProvidedContext{} + return v.ProvidedContext.Deserialize(d) + case schemas.IssueWorkloadIdentityContextResponse_SessionExpiration: + v.SessionExpiration = new(time.Time) + return d.ReadTime(schemas.IssueWorkloadIdentityContextResponse_SessionExpiration, v.SessionExpiration) + case schemas.IssueWorkloadIdentityContextResponse_Subject: + v.Subject = new(string) + return d.ReadString(schemas.IssueWorkloadIdentityContextResponse_Subject, v.Subject) + } + return nil + }) +} +func (c *Client) addOperationIssueWorkloadIdentityContextMiddlewares(stack *middleware.Stack, options Options) (err error) { + if err := stack.Serialize.Add(&serializeRequestMiddleware{options: &options, operationSchema: smithy.NewOperationSchema(schemas.IssueWorkloadIdentityContext, schemas.IssueWorkloadIdentityContextRequest, schemas.IssueWorkloadIdentityContextResponse)}, middleware.After); err != nil { + return err + } + if err := stack.Deserialize.Add(&deserializeResponseMiddleware{options: &options, operationSchema: smithy.NewOperationSchema(schemas.IssueWorkloadIdentityContext, schemas.IssueWorkloadIdentityContextRequest, schemas.IssueWorkloadIdentityContextResponse), output: &IssueWorkloadIdentityContextOutput{}}, middleware.After); err != nil { + return err + } + + if err = addResolveEndpointMiddleware(stack, options); err != nil { + return err + } + if err = addComputePayloadSHA256(stack); err != nil { + return err + } + if err = addRecordResponseTiming(stack, options); err != nil { + return err + } + if err = addCredentialSource(stack, options); err != nil { + return err + } + if err = addOpIssueWorkloadIdentityContextValidationMiddleware(stack); err != nil { + return err + } + if err = addRequestIDRetrieverMiddleware(stack); err != nil { + return err + } + if err = addResponseErrorMiddleware(stack); err != nil { + return err + } + if err = addRequestResponseLogging(stack, options); err != nil { + return err + } + if err = addDisableHTTPSMiddleware(stack, options); err != nil { + return err + } + if err = addInterceptors(stack, options); err != nil { + return err + } + return nil +} diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/common_serde.go b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/common_serde.go index 55fc074845..cb09c2f818 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/common_serde.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/common_serde.go @@ -45,6 +45,16 @@ func serializetagListType(s smithy.ShapeSerializer, schema *smithy.Schema, v []t s.CloseList() } +func serializetrustBundleListType(s smithy.ShapeSerializer, schema *smithy.Schema, v []types.TrustBundleEntry) { + s.WriteList(schema) + for _, vv := range v { + s.WriteStruct(schema.ListMember()) + vv.SerializeMembers(s) + s.CloseStruct() + } + s.CloseList() +} + func serializewebIdentityTokenAudienceListType(s smithy.ShapeSerializer, schema *smithy.Schema, v []string) { s.WriteList(schema) for _, vv := range v { @@ -140,6 +150,28 @@ func deserializetagListType(d smithy.ShapeDeserializer, s *smithy.Schema, v *[]t }) } +func deserializetrustBundleListType(d smithy.ShapeDeserializer, s *smithy.Schema, v *[]types.TrustBundleEntry) error { + *v = make([]types.TrustBundleEntry, 0) + var vv types.TrustBundleEntry + return smithy.ReadList(d, s, func() error { + if isNil, err := d.ReadNil(s.ListMember()); err != nil { + return err + } else if isNil { + var zero types.TrustBundleEntry + *v = append(*v, zero) + return nil + } + + vv = types.TrustBundleEntry{} + if err := vv.Deserialize(d); err != nil { + return err + } + + *v = append(*v, vv) + return nil + }) +} + func deserializewebIdentityTokenAudienceListType(d smithy.ShapeDeserializer, s *smithy.Schema, v *[]string) error { *v = make([]string, 0) var vv string diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/generated.json b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/generated.json index 14f545b8ca..6df0d5dfa0 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/generated.json +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/generated.json @@ -18,11 +18,14 @@ "api_op_DecodeAuthorizationMessage.go", "api_op_GetAccessKeyInfo.go", "api_op_GetCallerIdentity.go", + "api_op_GetCertificate.go", "api_op_GetDelegatedAccessToken.go", "api_op_GetFederationToken.go", "api_op_GetScopedCredentials.go", "api_op_GetSessionToken.go", + "api_op_GetTrustBundles.go", "api_op_GetWebIdentityToken.go", + "api_op_IssueWorkloadIdentityContext.go", "auth.go", "common_serde.go", "doc.go", diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/go_module_metadata.go b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/go_module_metadata.go index 3c0a8b2b0e..36d463b1f1 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/go_module_metadata.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/go_module_metadata.go @@ -3,4 +3,4 @@ package sts // goModuleVersion is the tagged release for this module -const goModuleVersion = "1.53.0" +const goModuleVersion = "1.54.0" diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/schemas/schemas.go b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/schemas/schemas.go index 509446e30a..5bc12c6536 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/schemas/schemas.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/schemas/schemas.go @@ -43,6 +43,11 @@ var GetCallerIdentity = smithy.NewSchema(smithy.ShapeID{ Name: "GetCallerIdentity", }, smithy.ShapeTypeOperation, 0) +var GetCertificate = smithy.NewSchema(smithy.ShapeID{ + Namespace: "com.amazonaws.sts", + Name: "GetCertificate", +}, smithy.ShapeTypeOperation, 0) + var GetDelegatedAccessToken = smithy.NewSchema(smithy.ShapeID{ Namespace: "com.amazonaws.sts", Name: "GetDelegatedAccessToken", @@ -63,11 +68,21 @@ var GetSessionToken = smithy.NewSchema(smithy.ShapeID{ Name: "GetSessionToken", }, smithy.ShapeTypeOperation, 0) +var GetTrustBundles = smithy.NewSchema(smithy.ShapeID{ + Namespace: "com.amazonaws.sts", + Name: "GetTrustBundles", +}, smithy.ShapeTypeOperation, 0) + var GetWebIdentityToken = smithy.NewSchema(smithy.ShapeID{ Namespace: "com.amazonaws.sts", Name: "GetWebIdentityToken", }, smithy.ShapeTypeOperation, 0) +var IssueWorkloadIdentityContext = smithy.NewSchema(smithy.ShapeID{ + Namespace: "com.amazonaws.sts", + Name: "IssueWorkloadIdentityContext", +}, smithy.ShapeTypeOperation, 0) + var _AWSSecurityTokenServiceV20110615 = smithy.NewSchema(smithy.ShapeID{ Namespace: "com.amazonaws.sts", Name: "AWSSecurityTokenServiceV20110615", @@ -95,6 +110,11 @@ var _arnType = smithy.NewSchema(smithy.ShapeID{ Name: "arnType", }, smithy.ShapeTypeString, 0) +var _assertionAudienceType = smithy.NewSchema(smithy.ShapeID{ + Namespace: "com.amazonaws.sts", + Name: "assertionAudienceType", +}, smithy.ShapeTypeString, 0) + var _assumedRoleIdType = smithy.NewSchema(smithy.ShapeID{ Namespace: "com.amazonaws.sts", Name: "assumedRoleIdType", @@ -108,11 +128,26 @@ var AssumedRoleUser_AssumedRoleId *smithy.Schema var AssumedRoleUser_Arn *smithy.Schema +var _attestationDocumentType = smithy.NewSchema(smithy.ShapeID{ + Namespace: "com.amazonaws.sts", + Name: "attestationDocumentType", +}, smithy.ShapeTypeString, 0) + var _Audience = smithy.NewSchema(smithy.ShapeID{ Namespace: "com.amazonaws.sts", Name: "Audience", }, smithy.ShapeTypeString, 0) +var _certificateBodyType = smithy.NewSchema(smithy.ShapeID{ + Namespace: "com.amazonaws.sts", + Name: "certificateBodyType", +}, smithy.ShapeTypeString, 0) + +var _certificateSigningRequestType = smithy.NewSchema(smithy.ShapeID{ + Namespace: "com.amazonaws.sts", + Name: "certificateSigningRequestType", +}, smithy.ShapeTypeString, 0) + var _clientTokenType = smithy.NewSchema(smithy.ShapeID{ Namespace: "com.amazonaws.sts", Name: "clientTokenType", @@ -243,6 +278,42 @@ var _insufficientSessionLifetimeMessage = smithy.NewSchema(smithy.ShapeID{ Name: "insufficientSessionLifetimeMessage", }, smithy.ShapeTypeString, 0) +var InvalidAttestationDocumentException = smithy.NewSchema(smithy.ShapeID{ + Namespace: "com.amazonaws.sts", + Name: "InvalidAttestationDocumentException", +}, smithy.ShapeTypeStructure, 2, &smithytraits.Error{Type: "client"}, + &smithytraits.HTTPError{Code: 400}, + &smithytraits.AWSQueryError{ErrorCode: "InvalidAttestationDocument", + StatusCode: 400}) +var InvalidAttestationDocumentException_message *smithy.Schema + +var InvalidAttestationDocumentException_reason *smithy.Schema + +var _invalidAttestationDocumentMessage = smithy.NewSchema(smithy.ShapeID{ + Namespace: "com.amazonaws.sts", + Name: "invalidAttestationDocumentMessage", +}, smithy.ShapeTypeString, 0) + +var invalidAttestationDocumentReason = smithy.NewSchema(smithy.ShapeID{ + Namespace: "com.amazonaws.sts", + Name: "invalidAttestationDocumentReason", +}, smithy.ShapeTypeEnum, 8) +var invalidAttestationDocumentReason_PROVIDER_NOT_FOUND *smithy.Schema + +var invalidAttestationDocumentReason_CANNOT_PARSE *smithy.Schema + +var invalidAttestationDocumentReason_DUPLICATE_KEY *smithy.Schema + +var invalidAttestationDocumentReason_INVALID_KEY *smithy.Schema + +var invalidAttestationDocumentReason_INVALID_VALUE *smithy.Schema + +var invalidAttestationDocumentReason_TOO_LARGE *smithy.Schema + +var invalidAttestationDocumentReason_UNEXPECTED_ATTESTATION *smithy.Schema + +var invalidAttestationDocumentReason_UNRESOLVED_TEMPLATE_VARIABLE *smithy.Schema + var _invalidAuthorizationMessage = smithy.NewSchema(smithy.ShapeID{ Namespace: "com.amazonaws.sts", Name: "invalidAuthorizationMessage", @@ -299,6 +370,34 @@ var _InvalidSubjectCredentialsMessage = smithy.NewSchema(smithy.ShapeID{ Name: "InvalidSubjectCredentialsMessage", }, smithy.ShapeTypeString, 0) +var InvalidWorkloadIdentityConfigurationException = smithy.NewSchema(smithy.ShapeID{ + Namespace: "com.amazonaws.sts", + Name: "InvalidWorkloadIdentityConfigurationException", +}, smithy.ShapeTypeStructure, 2, &smithytraits.Error{Type: "client"}, + &smithytraits.HTTPError{Code: 400}, + &smithytraits.AWSQueryError{ErrorCode: "InvalidWorkloadIdentityConfiguration", + StatusCode: 400}) +var InvalidWorkloadIdentityConfigurationException_message *smithy.Schema + +var InvalidWorkloadIdentityConfigurationException_reason *smithy.Schema + +var _invalidWorkloadIdentityConfigurationMessage = smithy.NewSchema(smithy.ShapeID{ + Namespace: "com.amazonaws.sts", + Name: "invalidWorkloadIdentityConfigurationMessage", +}, smithy.ShapeTypeString, 0) + +var invalidWorkloadIdentityConfigurationReason = smithy.NewSchema(smithy.ShapeID{ + Namespace: "com.amazonaws.sts", + Name: "invalidWorkloadIdentityConfigurationReason", +}, smithy.ShapeTypeEnum, 4) +var invalidWorkloadIdentityConfigurationReason_UNRENDERABLE_TEMPLATE *smithy.Schema + +var invalidWorkloadIdentityConfigurationReason_IDENTIFIER_TOO_LARGE *smithy.Schema + +var invalidWorkloadIdentityConfigurationReason_CASE_ONLY_DUPLICATE_TAG_KEYS *smithy.Schema + +var invalidWorkloadIdentityConfigurationReason_UNSUPPORTED_TAG_KEY_CHARACTERS *smithy.Schema + var _Issuer = smithy.NewSchema(smithy.ShapeID{ Namespace: "com.amazonaws.sts", Name: "Issuer", @@ -323,6 +422,20 @@ var _JWTPayloadSizeExceededException2 = smithy.NewSchema(smithy.ShapeID{ Name: "JWTPayloadSizeExceededException2", }, smithy.ShapeTypeString, 0) +var MalformedCertificateSigningRequestException = smithy.NewSchema(smithy.ShapeID{ + Namespace: "com.amazonaws.sts", + Name: "MalformedCertificateSigningRequestException", +}, smithy.ShapeTypeStructure, 1, &smithytraits.Error{Type: "client"}, + &smithytraits.HTTPError{Code: 400}, + &smithytraits.AWSQueryError{ErrorCode: "MalformedCertificateSigningRequestException", + StatusCode: 400}) +var MalformedCertificateSigningRequestException_message *smithy.Schema + +var _malformedCertificateSigningRequestMessage = smithy.NewSchema(smithy.ShapeID{ + Namespace: "com.amazonaws.sts", + Name: "malformedCertificateSigningRequestMessage", +}, smithy.ShapeTypeString, 0) + var MalformedPolicyDocumentException = smithy.NewSchema(smithy.ShapeID{ Namespace: "com.amazonaws.sts", Name: "MalformedPolicyDocumentException", @@ -433,6 +546,20 @@ var _ProvidedContextsListType = smithy.NewSchema(smithy.ShapeID{ }, smithy.ShapeTypeList, 1) var _ProvidedContextsListType_member *smithy.Schema +var RegionalSignerUnavailableException = smithy.NewSchema(smithy.ShapeID{ + Namespace: "com.amazonaws.sts", + Name: "RegionalSignerUnavailableException", +}, smithy.ShapeTypeStructure, 1, &smithytraits.Error{Type: "client"}, + &smithytraits.HTTPError{Code: 404}, + &smithytraits.AWSQueryError{ErrorCode: "RegionalSignerUnavailableException", + StatusCode: 404}) +var RegionalSignerUnavailableException_message *smithy.Schema + +var _regionalSignerUnavailableMessage = smithy.NewSchema(smithy.ShapeID{ + Namespace: "com.amazonaws.sts", + Name: "regionalSignerUnavailableMessage", +}, smithy.ShapeTypeString, 0) + var RegionDisabledException = smithy.NewSchema(smithy.ShapeID{ Namespace: "com.amazonaws.sts", Name: "RegionDisabledException", @@ -447,6 +574,34 @@ var _regionDisabledMessage = smithy.NewSchema(smithy.ShapeID{ Name: "regionDisabledMessage", }, smithy.ShapeTypeString, 0) +var _resourceIdType = smithy.NewSchema(smithy.ShapeID{ + Namespace: "com.amazonaws.sts", + Name: "resourceIdType", +}, smithy.ShapeTypeString, 0) + +var ResourceNotFoundException = smithy.NewSchema(smithy.ShapeID{ + Namespace: "com.amazonaws.sts", + Name: "ResourceNotFoundException", +}, smithy.ShapeTypeStructure, 3, &smithytraits.Error{Type: "client"}, + &smithytraits.HTTPError{Code: 404}, + &smithytraits.AWSQueryError{ErrorCode: "ResourceNotFoundException", + StatusCode: 404}) +var ResourceNotFoundException_message *smithy.Schema + +var ResourceNotFoundException_ResourceId *smithy.Schema + +var ResourceNotFoundException_ResourceType *smithy.Schema + +var _resourceNotFoundMessage = smithy.NewSchema(smithy.ShapeID{ + Namespace: "com.amazonaws.sts", + Name: "resourceNotFoundMessage", +}, smithy.ShapeTypeString, 0) + +var _resourceTypeType = smithy.NewSchema(smithy.ShapeID{ + Namespace: "com.amazonaws.sts", + Name: "resourceTypeType", +}, smithy.ShapeTypeString, 0) + var _roleDurationSecondsType = smithy.NewSchema(smithy.ShapeID{ Namespace: "com.amazonaws.sts", Name: "roleDurationSecondsType", @@ -529,6 +684,20 @@ var _sessionTokenUtilizationType = smithy.NewSchema(smithy.ShapeID{ Name: "sessionTokenUtilizationType", }, smithy.ShapeTypeInteger, 0) +var SignerNotConfiguredException = smithy.NewSchema(smithy.ShapeID{ + Namespace: "com.amazonaws.sts", + Name: "SignerNotConfiguredException", +}, smithy.ShapeTypeStructure, 1, &smithytraits.Error{Type: "client"}, + &smithytraits.HTTPError{Code: 404}, + &smithytraits.AWSQueryError{ErrorCode: "SignerNotConfiguredException", + StatusCode: 404}) +var SignerNotConfiguredException_message *smithy.Schema + +var _signerNotConfiguredMessage = smithy.NewSchema(smithy.ShapeID{ + Namespace: "com.amazonaws.sts", + Name: "signerNotConfiguredMessage", +}, smithy.ShapeTypeString, 0) + var _sourceIdentityType = smithy.NewSchema(smithy.ShapeID{ Namespace: "com.amazonaws.sts", Name: "sourceIdentityType", @@ -618,6 +787,30 @@ var _transactionContextValueType = smithy.NewSchema(smithy.ShapeID{ Name: "transactionContextValueType", }, smithy.ShapeTypeString, 0, &smithytraits.Sensitive{}) +var _trustBundleDocumentType = smithy.NewSchema(smithy.ShapeID{ + Namespace: "com.amazonaws.sts", + Name: "trustBundleDocumentType", +}, smithy.ShapeTypeString, 0) + +var TrustBundleEntry = smithy.NewSchema(smithy.ShapeID{ + Namespace: "com.amazonaws.sts", + Name: "TrustBundleEntry", +}, smithy.ShapeTypeStructure, 2) +var TrustBundleEntry_TrustDomain *smithy.Schema + +var TrustBundleEntry_Bundle *smithy.Schema + +var _trustBundleListType = smithy.NewSchema(smithy.ShapeID{ + Namespace: "com.amazonaws.sts", + Name: "trustBundleListType", +}, smithy.ShapeTypeList, 1) +var _trustBundleListType_member *smithy.Schema + +var _trustDomainType = smithy.NewSchema(smithy.ShapeID{ + Namespace: "com.amazonaws.sts", + Name: "trustDomainType", +}, smithy.ShapeTypeString, 0) + var TrustedIdentityPropagationContext = smithy.NewSchema(smithy.ShapeID{ Namespace: "com.amazonaws.sts", Name: "TrustedIdentityPropagationContext", @@ -685,6 +878,39 @@ var _webIdentityTokenType = smithy.NewSchema(smithy.ShapeID{ Name: "webIdentityTokenType", }, smithy.ShapeTypeString, 0, &smithytraits.Sensitive{}) +var webIdentityTokenTypeType = smithy.NewSchema(smithy.ShapeID{ + Namespace: "com.amazonaws.sts", + Name: "webIdentityTokenTypeType", +}, smithy.ShapeTypeEnum, 2) +var webIdentityTokenTypeType_AWS_IDENTITY *smithy.Schema + +var webIdentityTokenTypeType_JWT_SVID *smithy.Schema + +var _workloadIdentityCertificateMaxDurationSecondsType = smithy.NewSchema(smithy.ShapeID{ + Namespace: "com.amazonaws.sts", + Name: "workloadIdentityCertificateMaxDurationSecondsType", +}, smithy.ShapeTypeInteger, 0) + +var _workloadIdentityContextDurationSecondsType = smithy.NewSchema(smithy.ShapeID{ + Namespace: "com.amazonaws.sts", + Name: "workloadIdentityContextDurationSecondsType", +}, smithy.ShapeTypeInteger, 0) + +var _workloadIdentitySessionDurationSecondsType = smithy.NewSchema(smithy.ShapeID{ + Namespace: "com.amazonaws.sts", + Name: "workloadIdentitySessionDurationSecondsType", +}, smithy.ShapeTypeInteger, 0) + +var _workloadIdentitySubjectType = smithy.NewSchema(smithy.ShapeID{ + Namespace: "com.amazonaws.sts", + Name: "workloadIdentitySubjectType", +}, smithy.ShapeTypeString, 0) + +var _workloadIdentityTemplateArnType = smithy.NewSchema(smithy.ShapeID{ + Namespace: "com.amazonaws.sts", + Name: "workloadIdentityTemplateArnType", +}, smithy.ShapeTypeString, 0) + var AssumeRoleRequest = smithy.NewSchema(smithy.ShapeID{ Namespace: "com.amazonaws.sts", Name: "AssumeRoleRequest", @@ -884,6 +1110,28 @@ var GetCallerIdentityResponse_Account *smithy.Schema var GetCallerIdentityResponse_Arn *smithy.Schema +var GetCertificateRequest = smithy.NewSchema(smithy.ShapeID{ + Namespace: "com.amazonaws.sts", + Name: "GetCertificateRequest", +}, smithy.ShapeTypeStructure, 2) +var GetCertificateRequest_CertificateSigningRequest *smithy.Schema + +var GetCertificateRequest_MaxDurationSeconds *smithy.Schema + +var GetCertificateResponse = smithy.NewSchema(smithy.ShapeID{ + Namespace: "com.amazonaws.sts", + Name: "GetCertificateResponse", +}, smithy.ShapeTypeStructure, 5) +var GetCertificateResponse_Certificate *smithy.Schema + +var GetCertificateResponse_CertificateChain *smithy.Schema + +var GetCertificateResponse_NotBefore *smithy.Schema + +var GetCertificateResponse_NotAfter *smithy.Schema + +var GetCertificateResponse_Subject *smithy.Schema + var GetDelegatedAccessTokenRequest = smithy.NewSchema(smithy.ShapeID{ Namespace: "com.amazonaws.sts", Name: "GetDelegatedAccessTokenRequest", @@ -980,10 +1228,22 @@ var GetSessionTokenResponse_SessionTokenUtilization *smithy.Schema var GetSessionTokenResponse_SessionTokenSize *smithy.Schema +var GetTrustBundlesRequest = smithy.NewSchema(smithy.ShapeID{ + Namespace: "com.amazonaws.sts", + Name: "GetTrustBundlesRequest", +}, smithy.ShapeTypeStructure, 1) +var GetTrustBundlesRequest_ProviderArn *smithy.Schema + +var GetTrustBundlesResponse = smithy.NewSchema(smithy.ShapeID{ + Namespace: "com.amazonaws.sts", + Name: "GetTrustBundlesResponse", +}, smithy.ShapeTypeStructure, 1) +var GetTrustBundlesResponse_TrustBundles *smithy.Schema + var GetWebIdentityTokenRequest = smithy.NewSchema(smithy.ShapeID{ Namespace: "com.amazonaws.sts", Name: "GetWebIdentityTokenRequest", -}, smithy.ShapeTypeStructure, 6) +}, smithy.ShapeTypeStructure, 7) var GetWebIdentityTokenRequest_Audience *smithy.Schema var GetWebIdentityTokenRequest_DurationSeconds *smithy.Schema @@ -996,6 +1256,8 @@ var GetWebIdentityTokenRequest_SubjectMode *smithy.Schema var GetWebIdentityTokenRequest_Tags *smithy.Schema +var GetWebIdentityTokenRequest_TokenType *smithy.Schema + var GetWebIdentityTokenResponse = smithy.NewSchema(smithy.ShapeID{ Namespace: "com.amazonaws.sts", Name: "GetWebIdentityTokenResponse", @@ -1004,6 +1266,34 @@ var GetWebIdentityTokenResponse_WebIdentityToken *smithy.Schema var GetWebIdentityTokenResponse_Expiration *smithy.Schema +var IssueWorkloadIdentityContextRequest = smithy.NewSchema(smithy.ShapeID{ + Namespace: "com.amazonaws.sts", + Name: "IssueWorkloadIdentityContextRequest", +}, smithy.ShapeTypeStructure, 5) +var IssueWorkloadIdentityContextRequest_WorkloadIdentityTemplateArn *smithy.Schema + +var IssueWorkloadIdentityContextRequest_AttestationDocument *smithy.Schema + +var IssueWorkloadIdentityContextRequest_TargetRoleArn *smithy.Schema + +var IssueWorkloadIdentityContextRequest_DurationSeconds *smithy.Schema + +var IssueWorkloadIdentityContextRequest_SessionDurationSeconds *smithy.Schema + +var IssueWorkloadIdentityContextResponse = smithy.NewSchema(smithy.ShapeID{ + Namespace: "com.amazonaws.sts", + Name: "IssueWorkloadIdentityContextResponse", +}, smithy.ShapeTypeStructure, 5) +var IssueWorkloadIdentityContextResponse_ProvidedContext *smithy.Schema + +var IssueWorkloadIdentityContextResponse_Subject *smithy.Schema + +var IssueWorkloadIdentityContextResponse_Audience *smithy.Schema + +var IssueWorkloadIdentityContextResponse_Expiration *smithy.Schema + +var IssueWorkloadIdentityContextResponse_SessionExpiration *smithy.Schema + // Initialize schema members after all schemas are declared to avoid // initialization cycles func init() { @@ -1033,6 +1323,26 @@ func init() { InsufficientSessionLifetimeException_message = InsufficientSessionLifetimeException.AddMember("message", _insufficientSessionLifetimeMessage) + invalidAttestationDocumentReason_PROVIDER_NOT_FOUND = invalidAttestationDocumentReason.AddMember("PROVIDER_NOT_FOUND", smithyprelude.Unit) + + invalidAttestationDocumentReason_CANNOT_PARSE = invalidAttestationDocumentReason.AddMember("CANNOT_PARSE", smithyprelude.Unit) + + invalidAttestationDocumentReason_DUPLICATE_KEY = invalidAttestationDocumentReason.AddMember("DUPLICATE_KEY", smithyprelude.Unit) + + invalidAttestationDocumentReason_INVALID_KEY = invalidAttestationDocumentReason.AddMember("INVALID_KEY", smithyprelude.Unit) + + invalidAttestationDocumentReason_INVALID_VALUE = invalidAttestationDocumentReason.AddMember("INVALID_VALUE", smithyprelude.Unit) + + invalidAttestationDocumentReason_TOO_LARGE = invalidAttestationDocumentReason.AddMember("TOO_LARGE", smithyprelude.Unit) + + invalidAttestationDocumentReason_UNEXPECTED_ATTESTATION = invalidAttestationDocumentReason.AddMember("UNEXPECTED_ATTESTATION", smithyprelude.Unit) + + invalidAttestationDocumentReason_UNRESOLVED_TEMPLATE_VARIABLE = invalidAttestationDocumentReason.AddMember("UNRESOLVED_TEMPLATE_VARIABLE", smithyprelude.Unit) + + InvalidAttestationDocumentException_message = InvalidAttestationDocumentException.AddMember("message", _invalidAttestationDocumentMessage, &smithytraits.XMLName{Name: "Message"}) + + InvalidAttestationDocumentException_reason = InvalidAttestationDocumentException.AddMember("reason", invalidAttestationDocumentReason) + InvalidAuthorizationMessageException_message = InvalidAuthorizationMessageException.AddMember("message", _invalidAuthorizationMessage) InvalidContextAssertionException_message = InvalidContextAssertionException.AddMember("message", _InvalidContextAssertionMessage) @@ -1041,8 +1351,22 @@ func init() { InvalidSubjectCredentialsException_message = InvalidSubjectCredentialsException.AddMember("message", _InvalidSubjectCredentialsMessage) + invalidWorkloadIdentityConfigurationReason_UNRENDERABLE_TEMPLATE = invalidWorkloadIdentityConfigurationReason.AddMember("UNRENDERABLE_TEMPLATE", smithyprelude.Unit) + + invalidWorkloadIdentityConfigurationReason_IDENTIFIER_TOO_LARGE = invalidWorkloadIdentityConfigurationReason.AddMember("IDENTIFIER_TOO_LARGE", smithyprelude.Unit) + + invalidWorkloadIdentityConfigurationReason_CASE_ONLY_DUPLICATE_TAG_KEYS = invalidWorkloadIdentityConfigurationReason.AddMember("CASE_ONLY_DUPLICATE_TAG_KEYS", smithyprelude.Unit) + + invalidWorkloadIdentityConfigurationReason_UNSUPPORTED_TAG_KEY_CHARACTERS = invalidWorkloadIdentityConfigurationReason.AddMember("UNSUPPORTED_TAG_KEY_CHARACTERS", smithyprelude.Unit) + + InvalidWorkloadIdentityConfigurationException_message = InvalidWorkloadIdentityConfigurationException.AddMember("message", _invalidWorkloadIdentityConfigurationMessage, &smithytraits.XMLName{Name: "Message"}) + + InvalidWorkloadIdentityConfigurationException_reason = InvalidWorkloadIdentityConfigurationException.AddMember("reason", invalidWorkloadIdentityConfigurationReason) + JWTPayloadSizeExceededException_message = JWTPayloadSizeExceededException.AddMember("message", _JWTPayloadSizeExceededException2) + MalformedCertificateSigningRequestException_message = MalformedCertificateSigningRequestException.AddMember("message", _malformedCertificateSigningRequestMessage) + MalformedPolicyDocumentException_message = MalformedPolicyDocumentException.AddMember("message", _malformedPolicyDocumentMessage) OriginIdentity_Subject = OriginIdentity.AddMember("Subject", _originIdentitySubjectType) @@ -1067,14 +1391,24 @@ func init() { _ProvidedContextsListType_member = _ProvidedContextsListType.AddMember("member", ProvidedContext) + RegionalSignerUnavailableException_message = RegionalSignerUnavailableException.AddMember("message", _regionalSignerUnavailableMessage) + RegionDisabledException_message = RegionDisabledException.AddMember("message", _regionDisabledMessage) + ResourceNotFoundException_message = ResourceNotFoundException.AddMember("message", _resourceNotFoundMessage) + + ResourceNotFoundException_ResourceId = ResourceNotFoundException.AddMember("ResourceId", _resourceIdType) + + ResourceNotFoundException_ResourceType = ResourceNotFoundException.AddMember("ResourceType", _resourceTypeType) + ScopedSession_ScopedSessionId = ScopedSession.AddMember("ScopedSessionId", _scopedSessionIdType) ScopedSession_Arn = ScopedSession.AddMember("Arn", _arnType) SessionDurationEscalationException_message = SessionDurationEscalationException.AddMember("message", _SessionDurationEscalationException2) + SignerNotConfiguredException_message = SignerNotConfiguredException.AddMember("message", _signerNotConfiguredMessage) + Tag_Key = Tag.AddMember("Key", _tagKeyType) Tag_Value = Tag.AddMember("Value", _tagValueType) @@ -1089,6 +1423,12 @@ func init() { TransactionContext_IdentityProvider = TransactionContext.AddMember("IdentityProvider", _transactionContextIdentityProviderMapType) + TrustBundleEntry_TrustDomain = TrustBundleEntry.AddMember("TrustDomain", _trustDomainType) + + TrustBundleEntry_Bundle = TrustBundleEntry.AddMember("Bundle", _trustBundleDocumentType) + + _trustBundleListType_member = _trustBundleListType.AddMember("member", TrustBundleEntry) + TrustedIdentityPropagationContext_OriginIdentity = TrustedIdentityPropagationContext.AddMember("OriginIdentity", OriginIdentity) TrustedIdentityPropagationContext_TransactionContext = TrustedIdentityPropagationContext.AddMember("TransactionContext", TransactionContext) @@ -1099,6 +1439,10 @@ func init() { webIdentityTokenSubjectModeType_ORIGIN_IDENTITY = webIdentityTokenSubjectModeType.AddMember("ORIGIN_IDENTITY", smithyprelude.Unit) + webIdentityTokenTypeType_AWS_IDENTITY = webIdentityTokenTypeType.AddMember("AWS_IDENTITY", smithyprelude.Unit) + + webIdentityTokenTypeType_JWT_SVID = webIdentityTokenTypeType.AddMember("JWT_SVID", smithyprelude.Unit) + AssumeRoleRequest_RoleArn = AssumeRoleRequest.AddMember("RoleArn", _arnType) AssumeRoleRequest_RoleSessionName = AssumeRoleRequest.AddMember("RoleSessionName", _roleSessionNameType) @@ -1241,6 +1585,20 @@ func init() { GetCallerIdentityResponse_Arn = GetCallerIdentityResponse.AddMember("Arn", _arnType) + GetCertificateRequest_CertificateSigningRequest = GetCertificateRequest.AddMember("CertificateSigningRequest", _certificateSigningRequestType) + + GetCertificateRequest_MaxDurationSeconds = GetCertificateRequest.AddMember("MaxDurationSeconds", _workloadIdentityCertificateMaxDurationSecondsType) + + GetCertificateResponse_Certificate = GetCertificateResponse.AddMember("Certificate", _certificateBodyType) + + GetCertificateResponse_CertificateChain = GetCertificateResponse.AddMember("CertificateChain", _certificateBodyType) + + GetCertificateResponse_NotBefore = GetCertificateResponse.AddMember("NotBefore", _dateType) + + GetCertificateResponse_NotAfter = GetCertificateResponse.AddMember("NotAfter", _dateType) + + GetCertificateResponse_Subject = GetCertificateResponse.AddMember("Subject", _workloadIdentitySubjectType) + GetDelegatedAccessTokenRequest_TradeInToken = GetDelegatedAccessTokenRequest.AddMember("TradeInToken", _tradeInTokenType) GetDelegatedAccessTokenResponse_Credentials = GetDelegatedAccessTokenResponse.AddMember("Credentials", Credentials) @@ -1305,6 +1663,10 @@ func init() { GetSessionTokenResponse_SessionTokenSize = GetSessionTokenResponse.AddMember("SessionTokenSize", _sessionTokenSizeType) + GetTrustBundlesRequest_ProviderArn = GetTrustBundlesRequest.AddMember("ProviderArn", _arnType) + + GetTrustBundlesResponse_TrustBundles = GetTrustBundlesResponse.AddMember("TrustBundles", _trustBundleListType) + GetWebIdentityTokenRequest_Audience = GetWebIdentityTokenRequest.AddMember("Audience", _webIdentityTokenAudienceListType) GetWebIdentityTokenRequest_DurationSeconds = GetWebIdentityTokenRequest.AddMember("DurationSeconds", _webIdentityTokenDurationSecondsType) @@ -1317,8 +1679,30 @@ func init() { GetWebIdentityTokenRequest_Tags = GetWebIdentityTokenRequest.AddMember("Tags", _tagListType) + GetWebIdentityTokenRequest_TokenType = GetWebIdentityTokenRequest.AddMember("TokenType", webIdentityTokenTypeType) + GetWebIdentityTokenResponse_WebIdentityToken = GetWebIdentityTokenResponse.AddMember("WebIdentityToken", _webIdentityTokenType) GetWebIdentityTokenResponse_Expiration = GetWebIdentityTokenResponse.AddMember("Expiration", _dateType) + IssueWorkloadIdentityContextRequest_WorkloadIdentityTemplateArn = IssueWorkloadIdentityContextRequest.AddMember("WorkloadIdentityTemplateArn", _workloadIdentityTemplateArnType) + + IssueWorkloadIdentityContextRequest_AttestationDocument = IssueWorkloadIdentityContextRequest.AddMember("AttestationDocument", _attestationDocumentType) + + IssueWorkloadIdentityContextRequest_TargetRoleArn = IssueWorkloadIdentityContextRequest.AddMember("TargetRoleArn", _arnType) + + IssueWorkloadIdentityContextRequest_DurationSeconds = IssueWorkloadIdentityContextRequest.AddMember("DurationSeconds", _workloadIdentityContextDurationSecondsType) + + IssueWorkloadIdentityContextRequest_SessionDurationSeconds = IssueWorkloadIdentityContextRequest.AddMember("SessionDurationSeconds", _workloadIdentitySessionDurationSecondsType) + + IssueWorkloadIdentityContextResponse_ProvidedContext = IssueWorkloadIdentityContextResponse.AddMember("ProvidedContext", ProvidedContext) + + IssueWorkloadIdentityContextResponse_Subject = IssueWorkloadIdentityContextResponse.AddMember("Subject", _Subject) + + IssueWorkloadIdentityContextResponse_Audience = IssueWorkloadIdentityContextResponse.AddMember("Audience", _assertionAudienceType) + + IssueWorkloadIdentityContextResponse_Expiration = IssueWorkloadIdentityContextResponse.AddMember("Expiration", _dateType) + + IssueWorkloadIdentityContextResponse_SessionExpiration = IssueWorkloadIdentityContextResponse.AddMember("SessionExpiration", _dateType) + } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/type_registry.go b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/type_registry.go index f8a5c6db1e..58624c52b7 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/type_registry.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/type_registry.go @@ -31,6 +31,10 @@ var TypeRegistry = &smithy.TypeRegistry{ Schema: schemas.InsufficientSessionLifetimeException, New: func() any { return &types.InsufficientSessionLifetimeException{} }, }, + "com.amazonaws.sts#InvalidAttestationDocumentException": { + Schema: schemas.InvalidAttestationDocumentException, + New: func() any { return &types.InvalidAttestationDocumentException{} }, + }, "com.amazonaws.sts#InvalidAuthorizationMessageException": { Schema: schemas.InvalidAuthorizationMessageException, New: func() any { return &types.InvalidAuthorizationMessageException{} }, @@ -47,10 +51,18 @@ var TypeRegistry = &smithy.TypeRegistry{ Schema: schemas.InvalidSubjectCredentialsException, New: func() any { return &types.InvalidSubjectCredentialsException{} }, }, + "com.amazonaws.sts#InvalidWorkloadIdentityConfigurationException": { + Schema: schemas.InvalidWorkloadIdentityConfigurationException, + New: func() any { return &types.InvalidWorkloadIdentityConfigurationException{} }, + }, "com.amazonaws.sts#JWTPayloadSizeExceededException": { Schema: schemas.JWTPayloadSizeExceededException, New: func() any { return &types.JWTPayloadSizeExceededException{} }, }, + "com.amazonaws.sts#MalformedCertificateSigningRequestException": { + Schema: schemas.MalformedCertificateSigningRequestException, + New: func() any { return &types.MalformedCertificateSigningRequestException{} }, + }, "com.amazonaws.sts#MalformedPolicyDocumentException": { Schema: schemas.MalformedPolicyDocumentException, New: func() any { return &types.MalformedPolicyDocumentException{} }, @@ -63,13 +75,25 @@ var TypeRegistry = &smithy.TypeRegistry{ Schema: schemas.PackedPolicyTooLargeException, New: func() any { return &types.PackedPolicyTooLargeException{} }, }, + "com.amazonaws.sts#RegionalSignerUnavailableException": { + Schema: schemas.RegionalSignerUnavailableException, + New: func() any { return &types.RegionalSignerUnavailableException{} }, + }, "com.amazonaws.sts#RegionDisabledException": { Schema: schemas.RegionDisabledException, New: func() any { return &types.RegionDisabledException{} }, }, + "com.amazonaws.sts#ResourceNotFoundException": { + Schema: schemas.ResourceNotFoundException, + New: func() any { return &types.ResourceNotFoundException{} }, + }, "com.amazonaws.sts#SessionDurationEscalationException": { Schema: schemas.SessionDurationEscalationException, New: func() any { return &types.SessionDurationEscalationException{} }, }, + "com.amazonaws.sts#SignerNotConfiguredException": { + Schema: schemas.SignerNotConfiguredException, + New: func() any { return &types.SignerNotConfiguredException{} }, + }, }, } diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/types/common_serde.go b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/types/common_serde.go index 256d315e0d..a0cd48399f 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/types/common_serde.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/types/common_serde.go @@ -44,6 +44,16 @@ func serializetagListType(s smithy.ShapeSerializer, schema *smithy.Schema, v []T s.CloseList() } +func serializetrustBundleListType(s smithy.ShapeSerializer, schema *smithy.Schema, v []TrustBundleEntry) { + s.WriteList(schema) + for _, vv := range v { + s.WriteStruct(schema.ListMember()) + vv.SerializeMembers(s) + s.CloseStruct() + } + s.CloseList() +} + func serializewebIdentityTokenAudienceListType(s smithy.ShapeSerializer, schema *smithy.Schema, v []string) { s.WriteList(schema) for _, vv := range v { @@ -139,6 +149,28 @@ func deserializetagListType(d smithy.ShapeDeserializer, s *smithy.Schema, v *[]T }) } +func deserializetrustBundleListType(d smithy.ShapeDeserializer, s *smithy.Schema, v *[]TrustBundleEntry) error { + *v = make([]TrustBundleEntry, 0) + var vv TrustBundleEntry + return smithy.ReadList(d, s, func() error { + if isNil, err := d.ReadNil(s.ListMember()); err != nil { + return err + } else if isNil { + var zero TrustBundleEntry + *v = append(*v, zero) + return nil + } + + vv = TrustBundleEntry{} + if err := vv.Deserialize(d); err != nil { + return err + } + + *v = append(*v, vv) + return nil + }) +} + func deserializewebIdentityTokenAudienceListType(d smithy.ShapeDeserializer, s *smithy.Schema, v *[]string) error { *v = make([]string, 0) var vv string diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/types/enums.go b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/types/enums.go index 058623e823..514fa1f1e0 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/types/enums.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/types/enums.go @@ -2,6 +2,62 @@ package types +type InvalidAttestationDocumentReason string + +// Enum values for InvalidAttestationDocumentReason +const ( + InvalidAttestationDocumentReasonProviderNotFound InvalidAttestationDocumentReason = "providerNotFound" + InvalidAttestationDocumentReasonCannotParse InvalidAttestationDocumentReason = "cannotParse" + InvalidAttestationDocumentReasonDuplicateKey InvalidAttestationDocumentReason = "duplicateKey" + InvalidAttestationDocumentReasonInvalidKey InvalidAttestationDocumentReason = "invalidKey" + InvalidAttestationDocumentReasonInvalidValue InvalidAttestationDocumentReason = "invalidValue" + InvalidAttestationDocumentReasonTooLarge InvalidAttestationDocumentReason = "tooLarge" + InvalidAttestationDocumentReasonUnexpectedAttestation InvalidAttestationDocumentReason = "unexpectedAttestation" + InvalidAttestationDocumentReasonUnresolvedTemplateVariable InvalidAttestationDocumentReason = "unresolvedTemplateVariable" +) + +// Values returns all known values for InvalidAttestationDocumentReason. Note that +// this can be expanded in the future, and so it is only as up to date as the +// client. +// +// The ordering of this slice is not guaranteed to be stable across updates. +func (InvalidAttestationDocumentReason) Values() []InvalidAttestationDocumentReason { + return []InvalidAttestationDocumentReason{ + "providerNotFound", + "cannotParse", + "duplicateKey", + "invalidKey", + "invalidValue", + "tooLarge", + "unexpectedAttestation", + "unresolvedTemplateVariable", + } +} + +type InvalidWorkloadIdentityConfigurationReason string + +// Enum values for InvalidWorkloadIdentityConfigurationReason +const ( + InvalidWorkloadIdentityConfigurationReasonUnrenderableTemplate InvalidWorkloadIdentityConfigurationReason = "unrenderableTemplate" + InvalidWorkloadIdentityConfigurationReasonIdentifierTooLarge InvalidWorkloadIdentityConfigurationReason = "identifierTooLarge" + InvalidWorkloadIdentityConfigurationReasonCaseOnlyDuplicateTagKeys InvalidWorkloadIdentityConfigurationReason = "caseOnlyDuplicateTagKeys" + InvalidWorkloadIdentityConfigurationReasonUnsupportedTagKeyCharacters InvalidWorkloadIdentityConfigurationReason = "unsupportedTagKeyCharacters" +) + +// Values returns all known values for InvalidWorkloadIdentityConfigurationReason. +// Note that this can be expanded in the future, and so it is only as up to date as +// the client. +// +// The ordering of this slice is not guaranteed to be stable across updates. +func (InvalidWorkloadIdentityConfigurationReason) Values() []InvalidWorkloadIdentityConfigurationReason { + return []InvalidWorkloadIdentityConfigurationReason{ + "unrenderableTemplate", + "identifierTooLarge", + "caseOnlyDuplicateTagKeys", + "unsupportedTagKeyCharacters", + } +} + type WebIdentityTokenSubjectModeType string // Enum values for WebIdentityTokenSubjectModeType @@ -21,3 +77,22 @@ func (WebIdentityTokenSubjectModeType) Values() []WebIdentityTokenSubjectModeTyp "OriginIdentity", } } + +type WebIdentityTokenTypeType string + +// Enum values for WebIdentityTokenTypeType +const ( + WebIdentityTokenTypeTypeAwsIdentity WebIdentityTokenTypeType = "AWSIdentity" + WebIdentityTokenTypeTypeJwtSvid WebIdentityTokenTypeType = "JWT_SVID" +) + +// Values returns all known values for WebIdentityTokenTypeType. Note that this +// can be expanded in the future, and so it is only as up to date as the client. +// +// The ordering of this slice is not guaranteed to be stable across updates. +func (WebIdentityTokenTypeType) Values() []WebIdentityTokenTypeType { + return []WebIdentityTokenTypeType{ + "AWSIdentity", + "JWT_SVID", + } +} diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/types/errors.go b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/types/errors.go index d17753d474..372aed7ce8 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/types/errors.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/types/errors.go @@ -259,6 +259,69 @@ func (v *InsufficientSessionLifetimeException) Deserialize(d smithy.ShapeDeseria }) } +// Amazon Web Services STS can't use the attestation document in the request. The +// reason member says why. Correct the attestation document and then retry the +// request. +type InvalidAttestationDocumentException struct { + Message *string + + ErrorCodeOverride *string + + Reason InvalidAttestationDocumentReason + + noSmithyDocumentSerde +} + +func (e *InvalidAttestationDocumentException) Error() string { + return fmt.Sprintf("%s: %s", e.ErrorCode(), e.ErrorMessage()) +} +func (e *InvalidAttestationDocumentException) ErrorMessage() string { + if e.Message == nil { + return "" + } + return *e.Message +} +func (e *InvalidAttestationDocumentException) ErrorCode() string { + if e == nil || e.ErrorCodeOverride == nil { + return "InvalidAttestationDocument" + } + return *e.ErrorCodeOverride +} +func (e *InvalidAttestationDocumentException) ErrorFault() smithy.ErrorFault { + return smithy.FaultClient +} +func (v *InvalidAttestationDocumentException) Serialize(s smithy.ShapeSerializer) { + s.WriteStruct(schemas.InvalidAttestationDocumentException) + v.SerializeMembers(s) + s.CloseStruct() +} + +func (v *InvalidAttestationDocumentException) SerializeMembers(s smithy.ShapeSerializer) { + if v.Message != nil { + s.WriteString(schemas.InvalidAttestationDocumentException_message, *v.Message) + } + if v.Reason != "" { + s.WriteString(schemas.InvalidAttestationDocumentException_reason, string(v.Reason)) + } +} +func (v *InvalidAttestationDocumentException) Deserialize(d smithy.ShapeDeserializer) error { + return smithy.ReadStruct(d, schemas.InvalidAttestationDocumentException, func(s *smithy.Schema) error { + switch s { + case schemas.InvalidAttestationDocumentException_message: + v.Message = new(string) + return d.ReadString(schemas.InvalidAttestationDocumentException_message, v.Message) + case schemas.InvalidAttestationDocumentException_reason: + var ev string + if err := d.ReadString(schemas.InvalidAttestationDocumentException_reason, &ev); err != nil { + return err + } + v.Reason = InvalidAttestationDocumentReason(ev) + return nil + } + return nil + }) +} + // The error returned if the message passed to DecodeAuthorizationMessage was // invalid. This can happen if the token contains invalid characters, such as line // breaks, or if the message has expired. @@ -460,6 +523,71 @@ func (v *InvalidSubjectCredentialsException) Deserialize(d smithy.ShapeDeseriali }) } +// Amazon Web Services STS can't issue a workload identity context because the +// workload identity template or workload identity provider has a configuration +// that Amazon Web Services STS can't use, or that doesn't work with the values in +// the request. The reason member says why. Ask the administrator of the resource +// to correct it, and then retry the request. +type InvalidWorkloadIdentityConfigurationException struct { + Message *string + + ErrorCodeOverride *string + + Reason InvalidWorkloadIdentityConfigurationReason + + noSmithyDocumentSerde +} + +func (e *InvalidWorkloadIdentityConfigurationException) Error() string { + return fmt.Sprintf("%s: %s", e.ErrorCode(), e.ErrorMessage()) +} +func (e *InvalidWorkloadIdentityConfigurationException) ErrorMessage() string { + if e.Message == nil { + return "" + } + return *e.Message +} +func (e *InvalidWorkloadIdentityConfigurationException) ErrorCode() string { + if e == nil || e.ErrorCodeOverride == nil { + return "InvalidWorkloadIdentityConfiguration" + } + return *e.ErrorCodeOverride +} +func (e *InvalidWorkloadIdentityConfigurationException) ErrorFault() smithy.ErrorFault { + return smithy.FaultClient +} +func (v *InvalidWorkloadIdentityConfigurationException) Serialize(s smithy.ShapeSerializer) { + s.WriteStruct(schemas.InvalidWorkloadIdentityConfigurationException) + v.SerializeMembers(s) + s.CloseStruct() +} + +func (v *InvalidWorkloadIdentityConfigurationException) SerializeMembers(s smithy.ShapeSerializer) { + if v.Message != nil { + s.WriteString(schemas.InvalidWorkloadIdentityConfigurationException_message, *v.Message) + } + if v.Reason != "" { + s.WriteString(schemas.InvalidWorkloadIdentityConfigurationException_reason, string(v.Reason)) + } +} +func (v *InvalidWorkloadIdentityConfigurationException) Deserialize(d smithy.ShapeDeserializer) error { + return smithy.ReadStruct(d, schemas.InvalidWorkloadIdentityConfigurationException, func(s *smithy.Schema) error { + switch s { + case schemas.InvalidWorkloadIdentityConfigurationException_message: + v.Message = new(string) + return d.ReadString(schemas.InvalidWorkloadIdentityConfigurationException_message, v.Message) + case schemas.InvalidWorkloadIdentityConfigurationException_reason: + var ev string + if err := d.ReadString(schemas.InvalidWorkloadIdentityConfigurationException_reason, &ev); err != nil { + return err + } + v.Reason = InvalidWorkloadIdentityConfigurationReason(ev) + return nil + } + return nil + }) +} + // The requested token payload size exceeds the maximum allowed size. Reduce the // number of request tags included in the GetWebIdentityToken API call to reduce // the token payload size. @@ -509,6 +637,58 @@ func (v *JWTPayloadSizeExceededException) Deserialize(d smithy.ShapeDeserializer }) } +// The certificate signing request (CSR) isn't valid. The CSR is blank, isn't a +// valid PEM-encoded PKCS #10 request, has a signature that doesn't verify, or uses +// a key type or key size that the signer doesn't support. Correct the CSR and then +// retry the request. +type MalformedCertificateSigningRequestException struct { + Message *string + + ErrorCodeOverride *string + + noSmithyDocumentSerde +} + +func (e *MalformedCertificateSigningRequestException) Error() string { + return fmt.Sprintf("%s: %s", e.ErrorCode(), e.ErrorMessage()) +} +func (e *MalformedCertificateSigningRequestException) ErrorMessage() string { + if e.Message == nil { + return "" + } + return *e.Message +} +func (e *MalformedCertificateSigningRequestException) ErrorCode() string { + if e == nil || e.ErrorCodeOverride == nil { + return "MalformedCertificateSigningRequestException" + } + return *e.ErrorCodeOverride +} +func (e *MalformedCertificateSigningRequestException) ErrorFault() smithy.ErrorFault { + return smithy.FaultClient +} +func (v *MalformedCertificateSigningRequestException) Serialize(s smithy.ShapeSerializer) { + s.WriteStruct(schemas.MalformedCertificateSigningRequestException) + v.SerializeMembers(s) + s.CloseStruct() +} + +func (v *MalformedCertificateSigningRequestException) SerializeMembers(s smithy.ShapeSerializer) { + if v.Message != nil { + s.WriteString(schemas.MalformedCertificateSigningRequestException_message, *v.Message) + } +} +func (v *MalformedCertificateSigningRequestException) Deserialize(d smithy.ShapeDeserializer) error { + return smithy.ReadStruct(d, schemas.MalformedCertificateSigningRequestException, func(s *smithy.Schema) error { + switch s { + case schemas.MalformedCertificateSigningRequestException_message: + v.Message = new(string) + return d.ReadString(schemas.MalformedCertificateSigningRequestException_message, v.Message) + } + return nil + }) +} + // The request was rejected because the policy document was malformed. The error // message describes the specific error. type MalformedPolicyDocumentException struct { @@ -666,6 +846,68 @@ func (v *PackedPolicyTooLargeException) Deserialize(d smithy.ShapeDeserializer) }) } +// The workload identity provider has a signer of the requested type, but no +// signer in the Amazon Web Services Region that you sent the request to can sign +// it right now. This can happen for the following reasons: +// +// - The signer isn't active yet. A newly added signer doesn't start signing +// until its scheduled start time. Retry the request after that time. +// +// - The certificate authority (CA) that the signer uses for GetCertificate can't +// issue certificates in this Region, for example because you disabled the CA, it +// expired, or it doesn't exist in this Region. Make sure that the signing CA is +// active and properly configured, or ask your administrator to check its status. +// +// - The account that owns the workload identity provider for GetCertificate +// isn't active. For example, the account is suspended or closed. +type RegionalSignerUnavailableException struct { + Message *string + + ErrorCodeOverride *string + + noSmithyDocumentSerde +} + +func (e *RegionalSignerUnavailableException) Error() string { + return fmt.Sprintf("%s: %s", e.ErrorCode(), e.ErrorMessage()) +} +func (e *RegionalSignerUnavailableException) ErrorMessage() string { + if e.Message == nil { + return "" + } + return *e.Message +} +func (e *RegionalSignerUnavailableException) ErrorCode() string { + if e == nil || e.ErrorCodeOverride == nil { + return "RegionalSignerUnavailableException" + } + return *e.ErrorCodeOverride +} +func (e *RegionalSignerUnavailableException) ErrorFault() smithy.ErrorFault { + return smithy.FaultClient +} +func (v *RegionalSignerUnavailableException) Serialize(s smithy.ShapeSerializer) { + s.WriteStruct(schemas.RegionalSignerUnavailableException) + v.SerializeMembers(s) + s.CloseStruct() +} + +func (v *RegionalSignerUnavailableException) SerializeMembers(s smithy.ShapeSerializer) { + if v.Message != nil { + s.WriteString(schemas.RegionalSignerUnavailableException_message, *v.Message) + } +} +func (v *RegionalSignerUnavailableException) Deserialize(d smithy.ShapeDeserializer) error { + return smithy.ReadStruct(d, schemas.RegionalSignerUnavailableException, func(s *smithy.Schema) error { + switch s { + case schemas.RegionalSignerUnavailableException_message: + v.Message = new(string) + return d.ReadString(schemas.RegionalSignerUnavailableException_message, v.Message) + } + return nil + }) +} + // STS is not activated in the requested region for the account that is being // asked to generate credentials. The account administrator must use the IAM // console to activate STS in that region. For more information, see [Activating and Deactivating STS in an Amazon Web Services Region]in the IAM @@ -718,6 +960,70 @@ func (v *RegionDisabledException) Deserialize(d smithy.ShapeDeserializer) error }) } +// The specified resource doesn't exist, or you don't have access to it. Verify +// that the resource identifier is correct and that you have permission to access +// the resource. +type ResourceNotFoundException struct { + Message *string + + ErrorCodeOverride *string + + ResourceId *string + ResourceType *string + + noSmithyDocumentSerde +} + +func (e *ResourceNotFoundException) Error() string { + return fmt.Sprintf("%s: %s", e.ErrorCode(), e.ErrorMessage()) +} +func (e *ResourceNotFoundException) ErrorMessage() string { + if e.Message == nil { + return "" + } + return *e.Message +} +func (e *ResourceNotFoundException) ErrorCode() string { + if e == nil || e.ErrorCodeOverride == nil { + return "ResourceNotFoundException" + } + return *e.ErrorCodeOverride +} +func (e *ResourceNotFoundException) ErrorFault() smithy.ErrorFault { return smithy.FaultClient } +func (v *ResourceNotFoundException) Serialize(s smithy.ShapeSerializer) { + s.WriteStruct(schemas.ResourceNotFoundException) + v.SerializeMembers(s) + s.CloseStruct() +} + +func (v *ResourceNotFoundException) SerializeMembers(s smithy.ShapeSerializer) { + if v.ResourceId != nil { + s.WriteString(schemas.ResourceNotFoundException_ResourceId, *v.ResourceId) + } + if v.ResourceType != nil { + s.WriteString(schemas.ResourceNotFoundException_ResourceType, *v.ResourceType) + } + if v.Message != nil { + s.WriteString(schemas.ResourceNotFoundException_message, *v.Message) + } +} +func (v *ResourceNotFoundException) Deserialize(d smithy.ShapeDeserializer) error { + return smithy.ReadStruct(d, schemas.ResourceNotFoundException, func(s *smithy.Schema) error { + switch s { + case schemas.ResourceNotFoundException_ResourceId: + v.ResourceId = new(string) + return d.ReadString(schemas.ResourceNotFoundException_ResourceId, v.ResourceId) + case schemas.ResourceNotFoundException_ResourceType: + v.ResourceType = new(string) + return d.ReadString(schemas.ResourceNotFoundException_ResourceType, v.ResourceType) + case schemas.ResourceNotFoundException_message: + v.Message = new(string) + return d.ReadString(schemas.ResourceNotFoundException_message, v.Message) + } + return nil + }) +} + // The requested token duration would extend the session beyond its original // expiration time. You cannot use this operation to extend the lifetime of a // session beyond what was granted when the session was originally created. @@ -768,3 +1074,54 @@ func (v *SessionDurationEscalationException) Deserialize(d smithy.ShapeDeseriali return nil }) } + +// The workload identity provider for the calling session doesn't have a signer +// for the type of credential that you requested. To call GetCertificate , the +// provider must have an X.509 signer. To call GetWebIdentityToken with a TokenType +// of JWT_SVID , the provider must have a JWT signer. Add a signer of that type to +// the provider, or ask your administrator to add one, and then retry the request. +type SignerNotConfiguredException struct { + Message *string + + ErrorCodeOverride *string + + noSmithyDocumentSerde +} + +func (e *SignerNotConfiguredException) Error() string { + return fmt.Sprintf("%s: %s", e.ErrorCode(), e.ErrorMessage()) +} +func (e *SignerNotConfiguredException) ErrorMessage() string { + if e.Message == nil { + return "" + } + return *e.Message +} +func (e *SignerNotConfiguredException) ErrorCode() string { + if e == nil || e.ErrorCodeOverride == nil { + return "SignerNotConfiguredException" + } + return *e.ErrorCodeOverride +} +func (e *SignerNotConfiguredException) ErrorFault() smithy.ErrorFault { return smithy.FaultClient } +func (v *SignerNotConfiguredException) Serialize(s smithy.ShapeSerializer) { + s.WriteStruct(schemas.SignerNotConfiguredException) + v.SerializeMembers(s) + s.CloseStruct() +} + +func (v *SignerNotConfiguredException) SerializeMembers(s smithy.ShapeSerializer) { + if v.Message != nil { + s.WriteString(schemas.SignerNotConfiguredException_message, *v.Message) + } +} +func (v *SignerNotConfiguredException) Deserialize(d smithy.ShapeDeserializer) error { + return smithy.ReadStruct(d, schemas.SignerNotConfiguredException, func(s *smithy.Schema) error { + switch s { + case schemas.SignerNotConfiguredException_message: + v.Message = new(string) + return d.ReadString(schemas.SignerNotConfiguredException_message, v.Message) + } + return nil + }) +} diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/types/types.go b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/types/types.go index 8ac27f3c1d..f69b78d32e 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/types/types.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/types/types.go @@ -470,6 +470,66 @@ func (v *TransactionContext) Deserialize(d smithy.ShapeDeserializer) error { }) } +// A SPIFFE trust bundle and the trust domain that it belongs to. +type TrustBundleEntry struct { + + // The SPIFFE trust bundle for the trust domain, as a JSON document. The document + // is a JSON Web Key (JWK) Set, as defined in [RFC 7517], with the following members: + // + // - spiffe_refresh_hint – How often, in seconds, to get the trust bundle again. + // + // - keys – The public keys for the trust domain. A key with a use value of + // x509-svid verifies X509-SVIDs, and its x5c member contains the root + // certificate authority (CA) certificate. A key with a use value of jwt-svid + // verifies JWT-SVIDs, and its kid member matches the kid header of the JWT-SVIDs + // that it signs. + // + // For more information, see [SPIFFE Trust Domain and Bundle]. + // + // [RFC 7517]: https://tools.ietf.org/html/rfc7517 + // [SPIFFE Trust Domain and Bundle]: https://github.com/spiffe/spiffe/blob/main/standards/SPIFFE_Trust_Domain_and_Bundle.md + // + // This member is required. + Bundle *string + + // The SPIFFE trust domain that the trust bundle is for, for example example.org . + // The SPIFFE IDs of workloads in this trust domain begin with spiffe:// followed + // by the trust domain. + // + // This member is required. + TrustDomain *string + + noSmithyDocumentSerde +} + +func (v *TrustBundleEntry) Serialize(s smithy.ShapeSerializer) { + s.WriteStruct(schemas.TrustBundleEntry) + v.SerializeMembers(s) + s.CloseStruct() +} + +func (v *TrustBundleEntry) SerializeMembers(s smithy.ShapeSerializer) { + if v.Bundle != nil { + s.WriteString(schemas.TrustBundleEntry_Bundle, *v.Bundle) + } + if v.TrustDomain != nil { + s.WriteString(schemas.TrustBundleEntry_TrustDomain, *v.TrustDomain) + } +} +func (v *TrustBundleEntry) Deserialize(d smithy.ShapeDeserializer) error { + return smithy.ReadStruct(d, schemas.TrustBundleEntry, func(s *smithy.Schema) error { + switch s { + case schemas.TrustBundleEntry_Bundle: + v.Bundle = new(string) + return d.ReadString(schemas.TrustBundleEntry_Bundle, v.Bundle) + case schemas.TrustBundleEntry_TrustDomain: + v.TrustDomain = new(string) + return d.ReadString(schemas.TrustBundleEntry_TrustDomain, v.TrustDomain) + } + return nil + }) +} + // The trusted identity propagation context that Amazon Web Services STS set in a // session from the identity provider's token. A member is absent when the session // has none of its keys. diff --git a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/validators.go b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/validators.go index 4d37dd22a1..0ba96e50e0 100644 --- a/vendor/github.com/aws/aws-sdk-go-v2/service/sts/validators.go +++ b/vendor/github.com/aws/aws-sdk-go-v2/service/sts/validators.go @@ -130,6 +130,26 @@ func (m *validateOpGetAccessKeyInfo) HandleInitialize(ctx context.Context, in mi return next.HandleInitialize(ctx, in) } +type validateOpGetCertificate struct { +} + +func (*validateOpGetCertificate) ID() string { + return "OperationInputValidation" +} + +func (m *validateOpGetCertificate) HandleInitialize(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) ( + out middleware.InitializeOutput, metadata middleware.Metadata, err error, +) { + input, ok := in.Parameters.(*GetCertificateInput) + if !ok { + return out, metadata, fmt.Errorf("unknown input parameters type %T", in.Parameters) + } + if err := validateOpGetCertificateInput(input); err != nil { + return out, metadata, err + } + return next.HandleInitialize(ctx, in) +} + type validateOpGetDelegatedAccessToken struct { } @@ -170,6 +190,26 @@ func (m *validateOpGetFederationToken) HandleInitialize(ctx context.Context, in return next.HandleInitialize(ctx, in) } +type validateOpGetTrustBundles struct { +} + +func (*validateOpGetTrustBundles) ID() string { + return "OperationInputValidation" +} + +func (m *validateOpGetTrustBundles) HandleInitialize(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) ( + out middleware.InitializeOutput, metadata middleware.Metadata, err error, +) { + input, ok := in.Parameters.(*GetTrustBundlesInput) + if !ok { + return out, metadata, fmt.Errorf("unknown input parameters type %T", in.Parameters) + } + if err := validateOpGetTrustBundlesInput(input); err != nil { + return out, metadata, err + } + return next.HandleInitialize(ctx, in) +} + type validateOpGetWebIdentityToken struct { } @@ -190,6 +230,26 @@ func (m *validateOpGetWebIdentityToken) HandleInitialize(ctx context.Context, in return next.HandleInitialize(ctx, in) } +type validateOpIssueWorkloadIdentityContext struct { +} + +func (*validateOpIssueWorkloadIdentityContext) ID() string { + return "OperationInputValidation" +} + +func (m *validateOpIssueWorkloadIdentityContext) HandleInitialize(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) ( + out middleware.InitializeOutput, metadata middleware.Metadata, err error, +) { + input, ok := in.Parameters.(*IssueWorkloadIdentityContextInput) + if !ok { + return out, metadata, fmt.Errorf("unknown input parameters type %T", in.Parameters) + } + if err := validateOpIssueWorkloadIdentityContextInput(input); err != nil { + return out, metadata, err + } + return next.HandleInitialize(ctx, in) +} + func addOpAssumeRoleValidationMiddleware(stack *middleware.Stack) error { return stack.Initialize.Add(&validateOpAssumeRole{}, middleware.After) } @@ -214,6 +274,10 @@ func addOpGetAccessKeyInfoValidationMiddleware(stack *middleware.Stack) error { return stack.Initialize.Add(&validateOpGetAccessKeyInfo{}, middleware.After) } +func addOpGetCertificateValidationMiddleware(stack *middleware.Stack) error { + return stack.Initialize.Add(&validateOpGetCertificate{}, middleware.After) +} + func addOpGetDelegatedAccessTokenValidationMiddleware(stack *middleware.Stack) error { return stack.Initialize.Add(&validateOpGetDelegatedAccessToken{}, middleware.After) } @@ -222,10 +286,18 @@ func addOpGetFederationTokenValidationMiddleware(stack *middleware.Stack) error return stack.Initialize.Add(&validateOpGetFederationToken{}, middleware.After) } +func addOpGetTrustBundlesValidationMiddleware(stack *middleware.Stack) error { + return stack.Initialize.Add(&validateOpGetTrustBundles{}, middleware.After) +} + func addOpGetWebIdentityTokenValidationMiddleware(stack *middleware.Stack) error { return stack.Initialize.Add(&validateOpGetWebIdentityToken{}, middleware.After) } +func addOpIssueWorkloadIdentityContextValidationMiddleware(stack *middleware.Stack) error { + return stack.Initialize.Add(&validateOpIssueWorkloadIdentityContext{}, middleware.After) +} + func validateTag(v *types.Tag) error { if v == nil { return nil @@ -374,6 +446,21 @@ func validateOpGetAccessKeyInfoInput(v *GetAccessKeyInfoInput) error { } } +func validateOpGetCertificateInput(v *GetCertificateInput) error { + if v == nil { + return nil + } + invalidParams := smithy.InvalidParamsError{Context: "GetCertificateInput"} + if v.CertificateSigningRequest == nil { + invalidParams.Add(smithy.NewErrParamRequired("CertificateSigningRequest")) + } + if invalidParams.Len() > 0 { + return invalidParams + } else { + return nil + } +} + func validateOpGetDelegatedAccessTokenInput(v *GetDelegatedAccessTokenInput) error { if v == nil { return nil @@ -409,6 +496,21 @@ func validateOpGetFederationTokenInput(v *GetFederationTokenInput) error { } } +func validateOpGetTrustBundlesInput(v *GetTrustBundlesInput) error { + if v == nil { + return nil + } + invalidParams := smithy.InvalidParamsError{Context: "GetTrustBundlesInput"} + if v.ProviderArn == nil { + invalidParams.Add(smithy.NewErrParamRequired("ProviderArn")) + } + if invalidParams.Len() > 0 { + return invalidParams + } else { + return nil + } +} + func validateOpGetWebIdentityTokenInput(v *GetWebIdentityTokenInput) error { if v == nil { return nil @@ -431,3 +533,18 @@ func validateOpGetWebIdentityTokenInput(v *GetWebIdentityTokenInput) error { return nil } } + +func validateOpIssueWorkloadIdentityContextInput(v *IssueWorkloadIdentityContextInput) error { + if v == nil { + return nil + } + invalidParams := smithy.InvalidParamsError{Context: "IssueWorkloadIdentityContextInput"} + if v.AttestationDocument == nil { + invalidParams.Add(smithy.NewErrParamRequired("AttestationDocument")) + } + if invalidParams.Len() > 0 { + return invalidParams + } else { + return nil + } +} diff --git a/vendor/github.com/aws/smithy-go/CHANGELOG.md b/vendor/github.com/aws/smithy-go/CHANGELOG.md index 6203a1a5db..d3d6a2641b 100644 --- a/vendor/github.com/aws/smithy-go/CHANGELOG.md +++ b/vendor/github.com/aws/smithy-go/CHANGELOG.md @@ -1,3 +1,43 @@ +# Release (2026-12-01.2) + +## General Highlights +* **Dependency Update**: Updated to the latest SDK module versions + +## Module Highlights +* `github.com/aws/smithy-go`: v1.28.13 + * **Bug Fix**: Return a generic API error instead of a deserialization error when a query or restXml error response has an empty body. + +# Release (2026-12-01) + +## General Highlights +* **Dependency Update**: Updated to the latest SDK module versions + +## Module Highlights +* `github.com/aws/smithy-go`: v1.28.12 + * **Bug Fix**: Fix a panic in rpcv2 when a response for an operation with no output has a non-empty body. + * **Bug Fix**: Fix rpcv2Cbor deserialization of indefinite-length byte strings. + * **Bug Fix**: Fix testing.CompareCBOR rejecting floats and epoch timestamps that use a different but equivalent numeric encoding. + +# Release (2026-11-27) + +## General Highlights +* **Dependency Update**: Updated to the latest SDK module versions + +## Module Highlights +* `github.com/aws/smithy-go`: v1.28.11 + * **Bug Fix**: Fix JSON blob test error comparison on Go 1.27. + +# Release (2026-11-24) + +## General Highlights +* **Dependency Update**: Updated to the latest SDK module versions + +## Module Highlights +* `github.com/aws/smithy-go`: v1.28.10 + * **Bug Fix**: Reduce JSON blob deserialization CPU time and allocations by decoding unescaped base64 directly from the input. + * **Bug Fix**: Return an error when encoding an event stream message too long for its 32-bit length field instead of writing a truncated length. + * **Bug Fix**: Validate event stream message prelude lengths when decoding. + # Release (2026-11-09) ## General Highlights diff --git a/vendor/github.com/aws/smithy-go/eventstream/encode.go b/vendor/github.com/aws/smithy-go/eventstream/encode.go index f2e37c8b39..269464257b 100644 --- a/vendor/github.com/aws/smithy-go/eventstream/encode.go +++ b/vendor/github.com/aws/smithy-go/eventstream/encode.go @@ -61,6 +61,10 @@ func (e *Encoder) Encode(w io.Writer, msg Message) (err error) { return err } + if err = validateMessageLen(uint64(e.headersBuf.Len()), uint64(len(msg.Payload))); err != nil { + return err + } + crc := crc32.New(crc32IEEETable) hashWriter := io.MultiWriter(writer, crc) @@ -111,6 +115,23 @@ func logMessageEncode(logger logging.Logger, msgBuf *bytes.Buffer, msg Message, fmt.Fprintf(w, "Raw message:\n%s\n", hex.Dump(msgBuf.Bytes())) } +// validateMessageLen returns an error if a message with the given headers and +// payload lengths would be longer than maxMsgLen. The sum is computed in 64 +// bits so it cannot wrap the way the prelude's 32-bit length field would. +func validateMessageLen(headersLen, payloadLen uint64) error { + if total := minMsgLen + headersLen + payloadLen; total > maxMsgLen { + // Convert through a variable: int(maxMsgLen) would fail to compile on + // 32-bit systems, where the constant overflows int. + maxLen := uint64(maxMsgLen) + return LengthError{ + Part: "message", + Want: int(maxLen), + Have: int(total), + } + } + return nil +} + func encodePrelude(w io.Writer, crc hash.Hash32, headersLen, payloadLen uint32) error { p := messagePrelude{ Length: minMsgLen + headersLen + payloadLen, diff --git a/vendor/github.com/aws/smithy-go/eventstream/message.go b/vendor/github.com/aws/smithy-go/eventstream/message.go index 1a77654f7e..e381d91669 100644 --- a/vendor/github.com/aws/smithy-go/eventstream/message.go +++ b/vendor/github.com/aws/smithy-go/eventstream/message.go @@ -4,6 +4,7 @@ import ( "bytes" "encoding/binary" "hash/crc32" + "math" ) const preludeLen = 8 @@ -11,6 +12,11 @@ const preludeCRCLen = 4 const msgCRCLen = 4 const minMsgLen = preludeLen + preludeCRCLen + msgCRCLen +// maxMsgLen is the largest total message length that the prelude's 32-bit +// length field can hold. It is a limit of the wire format, not a size policy; +// headers and payload together can be at most maxMsgLen-minMsgLen bytes. +const maxMsgLen = math.MaxUint32 + var crc32IEEETable = crc32.MakeTable(crc32.IEEE) // A Message provides the eventstream message representation. @@ -78,14 +84,25 @@ func (p messagePrelude) PayloadLen() uint32 { return p.Length - p.HeadersLen - minMsgLen } +// ValidateLens checks that the prelude's total and headers lengths are +// consistent before they are used to read the rest of the message. Without +// these checks PayloadLen would underflow for a total length below +// HeadersLen+minMsgLen. func (p messagePrelude) ValidateLens() error { - if p.Length == 0 { + if p.Length < minMsgLen { return LengthError{ Part: "message prelude", Want: minMsgLen, Have: int(p.Length), } } + if p.HeadersLen > p.Length-minMsgLen { + return LengthError{ + Part: "message headers", + Want: int(p.Length - minMsgLen), + Have: int(p.HeadersLen), + } + } return nil } diff --git a/vendor/github.com/aws/smithy-go/go_module_metadata.go b/vendor/github.com/aws/smithy-go/go_module_metadata.go index a7331b2992..24abef5e57 100644 --- a/vendor/github.com/aws/smithy-go/go_module_metadata.go +++ b/vendor/github.com/aws/smithy-go/go_module_metadata.go @@ -3,4 +3,4 @@ package smithy // goModuleVersion is the tagged release for this module -const goModuleVersion = "1.28.9" +const goModuleVersion = "1.28.13" diff --git a/vendor/github.com/aws/smithy-go/internal/sync/singleflight/LICENSE b/vendor/github.com/aws/smithy-go/internal/sync/singleflight/LICENSE index fe6a62006a..6a66aea5ea 100644 --- a/vendor/github.com/aws/smithy-go/internal/sync/singleflight/LICENSE +++ b/vendor/github.com/aws/smithy-go/internal/sync/singleflight/LICENSE @@ -14,7 +14,7 @@ distribution. contributors may be used to endorse or promote products derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY THE COPYIGHT HOLDERS AND CONTRIBUTORS +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT @@ -25,4 +25,3 @@ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - diff --git a/vendor/github.com/aws/smithy-go/transport/http/protocol/internal/json/shape_deserializer.go b/vendor/github.com/aws/smithy-go/transport/http/protocol/internal/json/shape_deserializer.go index 47e9561b3e..98ca74a7c4 100644 --- a/vendor/github.com/aws/smithy-go/transport/http/protocol/internal/json/shape_deserializer.go +++ b/vendor/github.com/aws/smithy-go/transport/http/protocol/internal/json/shape_deserializer.go @@ -355,12 +355,18 @@ func (d *ShapeDeserializer) ReadBlob(s *smithy.Schema, v *[]byte) error { return fmt.Errorf("expected string, got %s", tok) } - sv, err := unquote(tok) - if err != nil { - return err + encoded := tok[1 : len(tok)-1] + // The parser already checked for escapes. Unescaped base64 can be + // decoded without another scan or a temporary string copy. + if d.p.escaped { + var ok bool + encoded, ok = stdlib.UnquoteBytes(tok) + if !ok { + return fmt.Errorf("cannot unquote %s", tok) + } } - b, err := base64.StdEncoding.DecodeString(sv) + b, err := base64.StdEncoding.AppendDecode([]byte{}, encoded) if err != nil { return fmt.Errorf("decode base64 blob: %w", err) } diff --git a/vendor/github.com/aws/smithy-go/transport/http/protocol/internal/xml/error.go b/vendor/github.com/aws/smithy-go/transport/http/protocol/internal/xml/error.go index 366cf491de..b9432ef1d8 100644 --- a/vendor/github.com/aws/smithy-go/transport/http/protocol/internal/xml/error.go +++ b/vendor/github.com/aws/smithy-go/transport/http/protocol/internal/xml/error.go @@ -1,6 +1,9 @@ package xml -import "encoding/xml" +import ( + "encoding/xml" + "io" +) type protocolError struct { Code string `xml:"Code"` @@ -18,6 +21,10 @@ func GetProtocolErrorInfo(payload []byte) (code, message string, errorBody []byt message = code errorBody, err = ExtractElement(payload, "Error") + if err == io.EOF { + err = nil + return + } if err != nil || len(errorBody) == 0 { return } diff --git a/vendor/github.com/go-git/go-git/v6/.golangci.yaml b/vendor/github.com/go-git/go-git/v6/.golangci.yaml index 2cef1b0ecf..6532704665 100644 --- a/vendor/github.com/go-git/go-git/v6/.golangci.yaml +++ b/vendor/github.com/go-git/go-git/v6/.golangci.yaml @@ -38,6 +38,13 @@ linters: - path: _test\.go linters: - errcheck + # These constructors return unexported types on purpose. revive only + # reports them on Go 1.26, so inline nolint directives would be flagged + # as unused by nolintlint on Go 1.27. + - path: (internal/server/http/http|x/plugin/plugin_config|x/plugin/plugin_signer|x/plugin/config/(auto|empty|static))\.go + linters: + - revive + text: unexported-return formatters: enable: diff --git a/vendor/github.com/go-git/go-git/v6/.renovaterc.json5 b/vendor/github.com/go-git/go-git/v6/.renovaterc.json5 index 0a351ed4e8..bd950f12bb 100644 --- a/vendor/github.com/go-git/go-git/v6/.renovaterc.json5 +++ b/vendor/github.com/go-git/go-git/v6/.renovaterc.json5 @@ -14,12 +14,13 @@ "enabled": false }, { - "description": "Re-enable go-billy v5 on the v5 release line", + "description": "Re-enable go-billy v5 and sha1cd on the v5 release line", "matchBaseBranches": [ "releases/v5.x" ], "matchPackageNames": [ - "github.com/go-git/go-billy/v5" + "github.com/go-git/go-billy/v5", + "github.com/pjbgf/sha1cd" ], "enabled": true }, @@ -29,7 +30,8 @@ "releases/v5.x" ], "matchPackageNames": [ - "github.com/go-git/go-billy/v5" + "github.com/go-git/go-billy/v5", + "github.com/pjbgf/sha1cd" ], "matchUpdateTypes": ["major"], "enabled": false diff --git a/vendor/github.com/go-git/go-git/v6/AGENTS.md b/vendor/github.com/go-git/go-git/v6/AGENTS.md index 519a73e7c3..51e1f4cea2 100644 --- a/vendor/github.com/go-git/go-git/v6/AGENTS.md +++ b/vendor/github.com/go-git/go-git/v6/AGENTS.md @@ -60,35 +60,74 @@ All new features and non-critical fixes target `main`. Backports to ## Commit Message Format ``` -: , . [Fixes #] +: , + + + +[Fixes #] + + ``` -Examples: +Examples of title lines: ``` -plumbing: transport, Add HTTP/2 support. Fixes #456 -storage: filesystem, Fix config.worktree overlay for linked worktrees. +plumbing: transport, Add HTTP/2 support +storage: filesystem, Fix config.worktree overlay for linked worktrees ``` -- The title line is NOT followed by a blank line before the body. -- The body starts on the very next line after the title. +- The title names the package and subpackage that changed, followed by + a capitalised, imperative summary without a trailing period. Keep it + around 50 characters where the prefix allows. +- A blank line MUST separate the title from the body. +- Wrap the body at 72 characters. +- Reference issues in the body, not the title. When the change closes + an issue, end the body with `Fixes #`. - A blank line separates the body from trailers. +### Writing a Good Commit Message + +A commit message is read by reviewers today and by whoever runs +`git blame` years from now. The diff already shows *what* changed; the +message should explain *why*. + +- Start with the problem or the benefit: what was wrong, missing or + costly, and in which situation it shows up. +- Then describe how the change addresses it, at the level of approach + rather than a line-by-line restatement of the diff. +- State behaviour changes and compatibility consequences plainly, + including who is affected. +- When the change follows upstream Git behaviour, say so and reference + the Git source or documentation it relies on. +- Write plain, concise prose in short paragraphs. Avoid filler such as + "This commit ...". Use bullets only for genuinely parallel items. +- Put code identifiers, flags, file paths and commands in backticks. +- Only make claims that have been verified. If a later commit in the same + pull request makes an earlier message untrue, fix that message before + the pull request is merged. + ### AI-Assisted Commits All commits produced with AI assistance MUST include an `Assisted-by` -trailer identifying the agent: +trailer naming the tool and, where known, the model, without an email +address: ``` -plumbing: object, Fix delta offset decoding for large pack files. -Ensure the offset calculation correctly handles the variable-length -encoding used for offsets > 2 GiB. +plumbing: object, Fix delta offset decoding for large pack files + +Pack offsets of 2 GiB or more are kept in the idx's 64-bit offset +table, with the 32-bit entry holding an index into it and its MSB +set. The decoder read that entry as the offset itself, so objects +past 2 GiB in a pack resolved to the wrong location. + +Follow the index into the 64-bit table when the MSB is set, as Git +does when reading large offsets from the idx. -Assisted-by: Claude Sonnet 4.6 +Assisted-by: Claude Sonnet 4.6 ``` -Adjust name and address to match the actual tool used (e.g. -`Assisted-by: Copilot `). +Adjust the name to match the tool and model actually used, or name only +the tool when the model is not known (e.g. `Assisted-by: GitHub Copilot`). ## Git Behaviour Compliance diff --git a/vendor/github.com/go-git/go-git/v6/COMPATIBILITY.md b/vendor/github.com/go-git/go-git/v6/COMPATIBILITY.md index 6a7ab273fe..e0870433c9 100644 --- a/vendor/github.com/go-git/go-git/v6/COMPATIBILITY.md +++ b/vendor/github.com/go-git/go-git/v6/COMPATIBILITY.md @@ -62,7 +62,7 @@ compatibility status with go-git. | Feature | Sub-feature | Status | Notes | Examples | | ------------- | ----------- | ------ | ---------------------------------------------------- | -------- | | `apply` | | ❌ | | | -| `cherry-pick` | | ⚠️ (partial) | It supports default merge strategy `--strategy=ort` and underlying auto-conflict resolve strategy options `--strategy-option` which are `theirs` and `ours`.| | +| `cherry-pick` | | ❌ | Removed in v6. Returns once a three-way merge exists. | | | `diff` | | ✅ | Patch object with UnifiedDiff output representation. | | | `rebase` | | ❌ | | | | `revert` | | ❌ | | | diff --git a/vendor/github.com/go-git/go-git/v6/CONTRIBUTING.md b/vendor/github.com/go-git/go-git/v6/CONTRIBUTING.md index 0dbb38213b..46793ccadb 100644 --- a/vendor/github.com/go-git/go-git/v6/CONTRIBUTING.md +++ b/vendor/github.com/go-git/go-git/v6/CONTRIBUTING.md @@ -108,7 +108,7 @@ Signed-off-by: Jane Smith Git makes this easy — pass `-s` (or `--signoff`) when committing: ```sh -git commit -s -m "plumbing: packp, fix capability parsing" +git commit -s ``` To sign off commits you have already made: @@ -122,18 +122,67 @@ DCO sign-off is verified automatically on every pull request. PRs with unsigned ### Format of the commit message -Every commit message should describe what was changed, under which context and, if applicable, the GitHub issue it relates to: +Every commit message has a title, a body and trailers, each separated by +a blank line: ``` -plumbing: packp, Skip argument validations for unknown capabilities. Fixes #623 +: , + + + +[Fixes #] + + ``` -The format can be described more formally as follows: +For example: ``` -: , . [Fixes #] +plumbing: packp, Skip argument validations for unknown capabilities + +Unknown capabilities were validated like known ones that take no +argument, so a server advertising one with a value, such as +`oldref=HEAD:refs/heads/v2`, made decoding the whole capability list +fail with `ErrArguments`. + +Apply the argument checks to known capabilities only, and for unknown +ones reject just empty arguments. + +Fixes # + +Signed-off-by: Jane Smith ``` +- The title names the package and subpackage that changed, followed by + a capitalised, imperative summary without a trailing period. Keep it + around 50 characters where the prefix allows. +- A blank line MUST separate the title from the body. +- Wrap the body at 72 characters. +- Reference issues in the body, not the title. When the change closes + an issue, end the body with `Fixes #`. +- A blank line separates the body from trailers. + +### Writing a good commit message + +A commit message is read by reviewers today and by whoever runs +`git blame` years from now. The diff already shows *what* changed; the +message should explain *why*. + +- Start with the problem or the benefit: what was wrong, missing or + costly, and in which situation it shows up. +- Then describe how the change addresses it, at the level of approach + rather than a line-by-line restatement of the diff. +- State behaviour changes and compatibility consequences plainly, + including who is affected. +- When the change follows upstream Git behaviour, say so and reference + the Git source or documentation it relies on. +- Write plain, concise prose in short paragraphs. Avoid filler such as + "This commit ...". Use bullets only for genuinely parallel items. +- Put code identifiers, flags, file paths and commands in backticks. +- Only make claims that have been verified. If a later commit in the same + pull request makes an earlier message untrue, fix that message before + the pull request is merged. + [discord server]: https://discord.gg/8hrxYEVPE5 [StackOverflow go-git tag]: https://stackoverflow.com/questions/tagged/go-git [Issues]: https://github.com/go-git/go-git/issues diff --git a/vendor/github.com/go-git/go-git/v6/Makefile b/vendor/github.com/go-git/go-git/v6/Makefile index 889ffd7ac2..66c23b0883 100644 --- a/vendor/github.com/go-git/go-git/v6/Makefile +++ b/vendor/github.com/go-git/go-git/v6/Makefile @@ -15,7 +15,7 @@ COVERAGE_REPORT = coverage.out COVERAGE_MODE = count # renovate: datasource=github-tags depName=golangci/golangci-lint -GOLANGCI_VERSION ?= v2.13.2 +GOLANGCI_VERSION ?= v2.15.0 TOOLS_BIN := $(shell mkdir -p build/tools && realpath build/tools) GOLANGCI = $(TOOLS_BIN)/golangci-lint-$(GOLANGCI_VERSION) diff --git a/vendor/github.com/go-git/go-git/v6/SECURITY.md b/vendor/github.com/go-git/go-git/v6/SECURITY.md deleted file mode 100644 index 0d2f8d038f..0000000000 --- a/vendor/github.com/go-git/go-git/v6/SECURITY.md +++ /dev/null @@ -1,38 +0,0 @@ -# go-git Security Policy - -The purpose of this security policy is to outline `go-git`'s process -for reporting, handling and disclosing security sensitive information. - -## Supported Versions - -The project follows a version support policy where only the latest minor -release is actively supported. Therefore, only issues that impact the latest -minor release will be fixed. Users are encouraged to upgrade to the latest -minor/patch release to benefit from the most up-to-date features, bug fixes, -and security enhancements.​ - -The supported versions policy applies to both the `go-git` library and its -associated repositories within the `go-git` org. - -## Reporting Security Issues - -Please report any security vulnerabilities or potential weaknesses in `go-git` -privately via go-git-security@googlegroups.com. Do not publicly disclose the -details of the vulnerability until a fix has been implemented and released. - -During the process the project maintainers will investigate the report, so please -provide detailed information, including steps to reproduce, affected versions, and any mitigations if known. - -The project maintainers will acknowledge the receipt of the report and work with -the reporter to validate and address the issue. - -Please note that `go-git` does not have any bounty programs, and therefore do -not provide financial compensation for disclosures. - -## Security Disclosure Process - -The project maintainers will make every effort to promptly address security issues. - -Once a security vulnerability is fixed, a security advisory will be published to notify users and provide appropriate mitigation measures. - -All `go-git` advisories can be found at https://github.com/go-git/go-git/security/advisories. diff --git a/vendor/github.com/go-git/go-git/v6/config/config.go b/vendor/github.com/go-git/go-git/v6/config/config.go index c2ac95b330..160cb3c2fa 100644 --- a/vendor/github.com/go-git/go-git/v6/config/config.go +++ b/vendor/github.com/go-git/go-git/v6/config/config.go @@ -95,6 +95,11 @@ type Config struct { // directional characters that HFS+ would normalize away). // When unset, defaults to true on macOS. ProtectHFS OptBool + // IgnoreCase reports that the worktree filesystem is + // case-insensitive. Status and Clean then skip the repository's + // directory in any case, such as .GIT, as Git does; otherwise + // they skip only .git. Unset means false, as in Git. + IgnoreCase OptBool } User user @@ -481,6 +486,7 @@ const ( hooksPathKey = "hooksPath" protectNTFSKey = "protectNTFS" protectHFSKey = "protectHFS" + ignoreCaseKey = "ignoreCase" indexSection = "index" skipHashKey = "skipHash" formatKey = "format" @@ -554,6 +560,10 @@ func (c *Config) unmarshalCore() { c.Core.ProtectHFS = parsed } + if parsed := parseConfigBool(s.Options.Get(ignoreCaseKey)); parsed.IsSet() { + c.Core.IgnoreCase = parsed + } + if fileMode := s.Options.Get(fileModeKey); fileMode == "false" { c.Core.FileMode = false } @@ -797,6 +807,10 @@ func (c *Config) marshalCore() { if c.Core.ProtectHFS.IsSet() { s.SetOption(protectHFSKey, c.Core.ProtectHFS.FormatBool()) } + + if c.Core.IgnoreCase.IsSet() { + s.SetOption(ignoreCaseKey, c.Core.IgnoreCase.FormatBool()) + } } func (c *Config) marshalExtensions() { diff --git a/vendor/github.com/go-git/go-git/v6/config/modules.go b/vendor/github.com/go-git/go-git/v6/config/modules.go index 22adda44ca..a6c861fd78 100644 --- a/vendor/github.com/go-git/go-git/v6/config/modules.go +++ b/vendor/github.com/go-git/go-git/v6/config/modules.go @@ -4,8 +4,6 @@ import ( "bytes" "errors" "fmt" - "regexp" - "strings" "github.com/go-git/go-git/v6/internal/pathutil" format "github.com/go-git/go-git/v6/plumbing/format/config" @@ -23,9 +21,6 @@ var ( ErrModuleBadName = errors.New("ignoring suspicious submodule name") ) -// Matches module paths with dotdot ".." components. -var dotdotPath = regexp.MustCompile(`(^|[/\\])\.\.([/\\]|$)`) - // Modules defines the submodules properties, represents a .gitmodules file // https://www.kernel.org/pub/software/scm/git/docs/gitmodules.html type Modules struct { @@ -109,61 +104,42 @@ func (m *Submodule) Validate() error { return ErrModuleEmptyPath } - if m.URL == "" { - return ErrModuleEmptyURL + // The path is validated before the URL is checked for emptiness. + // unmarshalSubmodules drops a stanza only on ErrModuleBadPath or + // ErrModuleBadName, so a stanza carrying `path = ..` and no `url =` + // would otherwise be reported as ErrModuleEmptyURL and kept with its + // unsafe Path intact. + // + // pathutil.ValidSubmodulePath is the validator Submodule.Repository + // runs on this Path before it chroots to it, so the parser applies the + // same gate: a stanza it keeps is one whose Path can reach that chroot. + // The error is flattened to ErrModuleBadPath, the sentinel the parser + // drops a stanza on. + // + // Path is worktree-relative and is attacker-controlled via .gitmodules, + // so its component rules run on every host. Only the volume prefix rule + // is host-dependent, because filepath.VolumeName recognises a drive + // letter on Windows alone. + if err := pathutil.ValidSubmodulePath(m.Path); err != nil { + return ErrModuleBadPath } - if dotdotPath.MatchString(m.Path) { - return ErrModuleBadPath + if m.URL == "" { + return ErrModuleEmptyURL } return nil } -// validSubmoduleName mirrors canonical Git's check_submodule_name in -// submodule-config.c [1]: reject empty names and any name with a ".." -// path component, using both '/' and '\\' as separators so the rule -// is consistent across platforms. The component check is delegated to -// `pathutil.IsHFSDot` and `pathutil.IsNTFSDot` with `.` as the needle, -// which both cover the bare ".." case and reject components that -// resolve to ".." after HFS+ Unicode normalisation (ignored code -// points, e.g. `..`) or NTFS trailing-space/dot/ADS -// canonicalisation (e.g. `.. `, `..::$INDEX_ALLOCATION`). -// `.gitmodules` is attacker-controlled by definition, so both checks -// run unconditionally regardless of host OS. -// -// The additional checks (bare ".", NUL byte, leading or trailing -// separator, drive-letter prefix) close go-git-specific edge cases -// the canonical loop does not exercise: canonical Git treats names -// as opaque C strings, while Go strings carry NULs through and the -// billy filesystem layer is path-aware in ways Git's working storage -// is not. -// -// [1]: https://github.com/git/git/blob/v2.54.0/submodule-config.c#L214-L237 +// validSubmoduleName validates storage names below .git/modules with +// pathutil.ValidStorageName, which DotGit.Module applies too. func validSubmoduleName(name string) error { - if name == "" || name == "." { - return ErrModuleBadName - } - for _, seg := range strings.FieldsFunc(name, isPathSep) { - if pathutil.IsHFSDot(seg, ".") || pathutil.IsNTFSDot(seg, ".", "") { - return ErrModuleBadName - } - } - // go-git-specific defensive checks beyond canonical Git. - if strings.ContainsRune(name, 0) { - return ErrModuleBadName - } - if isPathSep(rune(name[0])) || isPathSep(rune(name[len(name)-1])) { - return ErrModuleBadName - } - if len(name) >= 2 && name[1] == ':' { + if !pathutil.ValidStorageName(name) { return ErrModuleBadName } return nil } -func isPathSep(r rune) bool { return r == '/' || r == '\\' } - func (m *Submodule) unmarshal(s *format.Subsection) { m.raw = s diff --git a/vendor/github.com/go-git/go-git/v6/internal/packhandle/cursor_reader.go b/vendor/github.com/go-git/go-git/v6/internal/packhandle/cursor_reader.go index d2f1fc2e54..6476aa792d 100644 --- a/vendor/github.com/go-git/go-git/v6/internal/packhandle/cursor_reader.go +++ b/vendor/github.com/go-git/go-git/v6/internal/packhandle/cursor_reader.go @@ -42,6 +42,15 @@ func newCursorReader(sf *sharedfile.SharedFile, size int64) (*cursorReader, erro return &cursorReader{sf: sf, file: f, size: size}, nil } +// Name returns the name the underlying .pack file was opened with, or "" +// when the file returned by [Source.Open] does not report one. +func (c *cursorReader) Name() string { + if n, ok := c.file.(interface{ Name() string }); ok { + return n.Name() + } + return "" +} + func (c *cursorReader) Read(p []byte) (int, error) { if c.closed.Load() || c.sf.IsClosed() { return 0, fs.ErrClosed diff --git a/vendor/github.com/go-git/go-git/v6/internal/pathutil/dotdot.go b/vendor/github.com/go-git/go-git/v6/internal/pathutil/dotdot.go new file mode 100644 index 0000000000..06c9c26fa3 --- /dev/null +++ b/vendor/github.com/go-git/go-git/v6/internal/pathutil/dotdot.go @@ -0,0 +1,68 @@ +package pathutil + +import "strings" + +// IsDotOrDotDotName reports whether one path component names the +// current or the parent directory. It takes a single component, never +// a whole path. It matches the literal "." and "..", and the NTFS and +// HFS+ spellings those filesystems fold back to "..". Submodule paths and +// storage names apply it; tree and worktree paths refuse only the literal +// names, as Git's verify_dotfile does. +// +// Runs of periods ("...", "....") and spellings that fold to "." +// rather than ".." (". ", ". .", ".") are excluded. IsDotName +// owns the spellings of ".". +func IsDotOrDotDotName(name string) bool { + return name == "." || name == ".." || + IsHFSDotDot(name) || IsNTFSDotDot(name) +} + +// IsDotName reports whether one path component names the current +// directory. It matches the literal ".", and the NTFS and HFS+ +// spellings those filesystems fold back to "." — ". ", ". .", ".:", +// "." and ".". IsDotOrDotDotName owns the parent +// equivalents. +// +// Runs of periods ("...", "....") are excluded, as C Git carries them in +// POSIX trees and indexes. +// +// A component that folds to "." resolves to the directory holding it, +// so a path built from one addresses that directory rather than +// something below it. Submodule paths and storage names apply this; +// tree and worktree paths do not, where such a component only names +// an ordinary file. +func IsDotName(name string) bool { + return name == "." || IsHFSDotCurrent(name) || IsNTFSDotCurrent(name) +} + +// ValidStorageName reports whether name is safe as a submodule's storage +// name, the path below .git/modules where its Git directory is kept. It +// refuses an empty name, a NUL, a leading or trailing separator, a drive +// prefix, and a component that names the current or the parent directory, +// literally or in an NTFS or HFS+ spelling. Both separators are recognized +// on every host. A run of periods, such as "...", is accepted, as in Git. +// +// Upstream Git's check_submodule_name[1] refuses only an empty name and a +// literal ".." component. The rest is a deliberate go-git policy, stricter +// than Git, that keeps a name from addressing anything but a directory +// below .git/modules. It applies on every host, whatever core.protectNTFS +// and core.protectHFS say. +// +// [1]: https://github.com/git/git/blob/v2.54.0/submodule-config.c#L214-L237 +func ValidStorageName(name string) bool { + if name == "" || strings.ContainsRune(name, 0) { + return false + } + if isPathSep(rune(name[0])) || isPathSep(rune(name[len(name)-1])) { + return false + } + if len(name) >= 2 && name[1] == ':' { + return false + } + for _, part := range strings.FieldsFunc(name, isPathSep) { + if IsDotOrDotDotName(part) || IsDotName(part) { + return false + } + } + return true +} diff --git a/vendor/github.com/go-git/go-git/v6/internal/pathutil/dotgit.go b/vendor/github.com/go-git/go-git/v6/internal/pathutil/dotgit.go index e50ee9ce5d..487304164b 100644 --- a/vendor/github.com/go-git/go-git/v6/internal/pathutil/dotgit.go +++ b/vendor/github.com/go-git/go-git/v6/internal/pathutil/dotgit.go @@ -7,11 +7,10 @@ import "strings" // components (and as submodule names) because they refer to the // repository's own metadata directory. // -// File names that do not conform to the 8.3 format (up to eight -// characters for the basename, three for the file extension) are -// associated with a so-called "short name" on NTFS — at least on -// the `C:` drive by default — which means that `git~1/` is a valid -// way to refer to `.git/`. +// NTFS can give a file whose name does not fit the 8.3 pattern a second, +// generated short name, and usually does so on the system drive. For +// `.git` that short name is `git~1`, so either spelling reaches the +// same directory. func IsDotGitName(name string) bool { switch strings.ToLower(name) { case ".git", "git~1": diff --git a/vendor/github.com/go-git/go-git/v6/internal/pathutil/hfs.go b/vendor/github.com/go-git/go-git/v6/internal/pathutil/hfs.go index 57e2c81e81..6d3794a56e 100644 --- a/vendor/github.com/go-git/go-git/v6/internal/pathutil/hfs.go +++ b/vendor/github.com/go-git/go-git/v6/internal/pathutil/hfs.go @@ -1,6 +1,9 @@ package pathutil -import "unicode" +import ( + "unicode" + "unicode/utf8" +) // hfsIgnoredCodepoints contains Unicode code points that HFS+ ignores // during path normalization. A path component containing these @@ -10,7 +13,7 @@ import "unicode" // // See upstream Git utf8.c next_hfs_char in tag v2.54.0[1]. // -// [1]: https://github.com/git/git/blob/v2.54.0/utf8.c#L703-L740 +// [1]: https://github.com/git/git/blob/v2.54.0/utf8.c#L703-L739 var hfsIgnoredCodepoints = map[rune]struct{}{ 0x200c: {}, // ZERO WIDTH NON-JOINER 0x200d: {}, // ZERO WIDTH JOINER @@ -37,11 +40,14 @@ var hfsIgnoredCodepoints = map[rune]struct{}{ // mirrors upstream Git's is_hfs_dot_generic and is the building // block of IsHFSDotGit / IsHFSDotGitmodules. // -// Reference: upstream Git utf8.c is_hfs_dot_generic at L741-L774 and -// the dotgit family at L784-L809 in tag v2.54.0[1]. +// Reference: upstream Git utf8.c is_hfs_dot_generic at L741-L773 and +// the dotgit family at L784-L807 in tag v2.54.0[1]. // -// [1]: https://github.com/git/git/blob/v2.54.0/utf8.c#L741-L809 +// [1]: https://github.com/git/git/blob/v2.54.0/utf8.c#L741-L807 func IsHFSDot(part, needle string) bool { + if part == "" || (part[0] < utf8.RuneSelf && part[0] != '.') { + return false + } runes := []rune(part) i := 0 @@ -93,6 +99,19 @@ func IsHFSDot(part, needle string) bool { // IsHFSDotGit reports whether part is an HFS+ equivalent of ".git". func IsHFSDotGit(part string) bool { return IsHFSDot(part, "git") } +// IsHFSDotDot reports whether part is an HFS+ equivalent of "..". +// HFS+ drops a fixed set of ignorable code points during +// normalisation, so ".." names the parent directory on an +// HFS+ volume. +func IsHFSDotDot(part string) bool { return IsHFSDot(part, ".") } + +// IsHFSDotCurrent reports whether part is an HFS+ equivalent of ".". +// The empty needle leaves IsHFSDot matching a lone period surrounded +// by ignorable code points, so "." and "." name the +// current directory on an HFS+ volume. The literal "." matches too; +// IsDotName owns that comparison. +func IsHFSDotCurrent(part string) bool { return IsHFSDot(part, "") } + // IsHFSDotGitmodules reports whether part is an HFS+ equivalent of // ".gitmodules", catching attempts to plant the file via Unicode // code points that HFS+ would strip during normalisation. diff --git a/vendor/github.com/go-git/go-git/v6/internal/pathutil/ntfs.go b/vendor/github.com/go-git/go-git/v6/internal/pathutil/ntfs.go index de1e00be8c..935781c4e8 100644 --- a/vendor/github.com/go-git/go-git/v6/internal/pathutil/ntfs.go +++ b/vendor/github.com/go-git/go-git/v6/internal/pathutil/ntfs.go @@ -2,56 +2,89 @@ package pathutil import "strings" -// IsNTFSDotGit ports upstream Git's is_ntfs_dotgit. It detects path -// components that NTFS would resolve to ".git": the canonical name -// itself and its 8.3 short-name alias "git~1", each followed by any -// number of trailing spaces or periods (which NTFS silently trims) -// and an optional Alternate Data Stream suffix (":"). The -// bare strings ".git" and "git~1" also match, mirroring upstream. +// IsNTFSDotGit reports whether part, a path component, is a spelling NTFS +// resolves to ".git": the name itself or its 8.3 short name "git~1", in any +// case, followed by any number of spaces and periods, which NTFS drops, and +// optionally by an alternate data stream suffix (":"). // -// Reference: upstream Git path.c is_ntfs_dotgit at L1415-L1449 -// in tag v2.54.0[1]. -// -// [1]: https://github.com/git/git/blob/v2.54.0/path.c#L1415-L1449 +// Git refuses the same components under core.protectNTFS; see the +// description of that setting in git-config(1). func IsNTFSDotGit(part string) bool { - var i int - switch { - case len(part) >= 4 && part[0] == '.' && - asciiToLower(part[1]) == 'g' && - asciiToLower(part[2]) == 'i' && - asciiToLower(part[3]) == 't': - i = 4 - case len(part) >= 5 && - asciiToLower(part[0]) == 'g' && - asciiToLower(part[1]) == 'i' && - asciiToLower(part[2]) == 't' && - part[3] == '~' && part[4] == '1': - i = 5 - default: + // Every alias starts with one of the two names, so most components are + // settled by their first bytes. + if !hasASCIIFoldPrefix(part, ".git") && !hasASCIIFoldPrefix(part, "git~1") { return false } + base, _, _ := strings.Cut(part, ":") + base = strings.TrimRight(base, " .") + return asciiEqualFold(base, ".git") || asciiEqualFold(base, "git~1") +} - for ; i < len(part); i++ { - c := part[i] - if c == ':' { - return true +// IsNTFSDotDot reports whether part is an NTFS spelling of ".." +// that a comparison against the literal ".." misses: ".." followed +// by a tail of spaces and periods containing at least one space, or +// ".." followed by an Alternate Data Stream colon. ".. ", ".. .", +// "..:$DATA" and "..::$INDEX_ALLOCATION" match. ".." itself does +// not; the literal comparison in IsDotOrDotDotName owns that. +// +// A tail of periods alone ("...", "....") does not match. C Git +// carries such names on POSIX. Win32 trims trailing spaces and +// periods, except for exactly "." and "..". validPath consults +// Win32ValidPath only on Windows with core.protectNTFS enabled. +func IsNTFSDotDot(part string) bool { + // Only the literal-dot pattern in IsNTFSDot matches a needle + // this short. It requires two leading periods, so the slice + // below needs no additional length guard. + if !IsNTFSDot(part, ".", "") { + return false + } + return strings.ContainsAny(part[2:], " :") +} + +// IsNTFSDotCurrent reports whether part is an NTFS spelling of "." +// that a comparison against the literal "." misses: "." followed by a +// tail of spaces and periods containing at least one space, or "." +// followed by an Alternate Data Stream colon. ". ", ". .", ".:$DATA" +// and ".::$INDEX_ALLOCATION" match. +// +// The empty needle degenerates IsNTFSDot: the length guards skip both +// short-name patterns, leaving a leading period followed only by +// spaces, periods or an ADS colon. That admits ".", ".." and runs of +// periods, which this function excludes the way IsNTFSDotDot does — +// by requiring a space or a colon in the tail. IsDotName and +// IsDotOrDotDotName own the literal spellings. +func IsNTFSDotCurrent(part string) bool { + // Only the literal-dot pattern in IsNTFSDot matches an empty + // needle. It requires one leading period, so the slice below + // needs no additional length guard. + if !IsNTFSDot(part, "", "") { + return false + } + return strings.ContainsAny(part[1:], " :") +} + +// Win32ValidPath checks one path component for illegal Win32 characters, +// trailing spaces or periods, and reserved device names. The worktree +// wrapper applies it on Windows with core.protectNTFS enabled; metadata +// aliases are checked separately on every host. +// +// Follows upstream Git's is_valid_win32_path with allow_literal_nul=false. +// The caller splits path separators and rejects volume prefixes before +// checking components, so every colon here is invalid. Embedded NUL bytes +// are also rejected rather than treated as C string terminators. +// +// https://github.com/git/git/blob/v2.54.0/compat/mingw.c#L3347-L3469 +func Win32ValidPath(part string) bool { + for i := 0; i < len(part); i++ { + if part[i] < 0x20 { + return false } - if c != '.' && c != ' ' { + switch part[i] { + case ':', '<', '>', '"', '|', '?', '*': return false } } - return true -} - -// WindowsValidPath reports whether part is a valid Windows / NTFS -// path component for the worktree filesystem abstraction. It rejects -// NTFS-disguised variants of `.git` and `git~1` (trailing spaces, -// periods, Alternate Data Streams) and Windows reserved device -// names. Bare `.git` and `git~1` are allowed at this layer; the -// caller decides whether they are permissible at the current path -// position. -func WindowsValidPath(part string) bool { - if IsNTFSDotGit(part) && !IsDotGitName(part) { + if endsInSpaceOrPeriod(part) { return false } return !isWindowsReservedName(part) @@ -62,11 +95,14 @@ func WindowsValidPath(part string) bool { // spaces, extensions, and NTFS Alternate Data Streams) matches one of // these case-insensitively. // -// See upstream Git compat/mingw.c is_valid_win32_path(). +// See upstream Git's is_valid_win32_path reserved-name scanner at +// compat/mingw.c#L3372-L3448 in tag v2.54.0[1]. +// +// [1]: https://github.com/git/git/blob/v2.54.0/compat/mingw.c#L3372-L3448 var windowsReservedNames = []string{ "CON", "PRN", "AUX", "NUL", "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9", - "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9", + "LPT0", "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9", "CONIN$", "CONOUT$", } @@ -78,123 +114,117 @@ func isWindowsReservedName(part string) bool { if !strings.EqualFold(part[:len(name)], name) { continue } - // Exact match or followed by space, dot, colon (ADS), or separator. - if len(part) == len(name) { + suffix := strings.TrimLeft(part[len(name):], " ") + if suffix == "" { return true } - switch part[len(name)] { - case ' ', '.', ':': + switch suffix[0] { + case '.', ':': return true } } return false } -// IsNTFSDot ports upstream Git's is_ntfs_dot_generic. It detects NTFS -// path-component variants of a dotfile name that attackers can use to -// bypass case-insensitive comparisons against the canonical name on -// Windows. The dotgit parameter is the lowercase name without the -// leading dot (e.g. "gitmodules"); shortnamePrefix is the canonical -// 6-character NTFS short-name prefix used as a fall-back match -// (e.g. "gi7eba" for ".gitmodules"). +// endsInSpaceOrPeriod reports whether part ends in a space or a +// period, with "." and ".." excepted. Win32 path canonicalisation +// strips both characters from the end of a component, so a component +// that ends in one names something other than what it spells: "foo " +// opens "foo", and ".gitattributes " collides with +// ".gitattributes". // -// Reference: upstream Git path.c is_ntfs_dot_generic at L1451-L1507 -// in tag v2.54.0[1]. +// Upstream Git makes the same check at each segment boundary in +// is_valid_win32_path, at compat/mingw.c L3363-L3366 in tag +// v2.54.0[1]: a segment may not end in a space or a period, unless +// it is made of periods only and is no longer than two of them. That +// leaves "." and ".." as the only exceptions, which is how the rule +// is written below. // -// [1]: https://github.com/git/git/blob/v2.54.0/path.c#L1451-L1507 -func IsNTFSDot(name, dotgit, shortnamePrefix string) bool { - // onlySpacesAndPeriods returns true when the suffix from start - // onwards consists only of trailing spaces and periods, possibly - // terminated by a NTFS Alternate Data Stream colon. Mirrors the - // only_spaces_and_periods label in upstream's is_ntfs_dot_generic. - onlySpacesAndPeriods := func(start int) bool { - for i := start; i < len(name); i++ { - c := name[i] - if c == ':' { - return true - } - if c != ' ' && c != '.' { - return false - } - } - return true +// [1]: https://github.com/git/git/blob/v2.54.0/compat/mingw.c#L3363-L3366 +func endsInSpaceOrPeriod(part string) bool { + if part == "" || part == "." || part == ".." { + return false } + c := part[len(part)-1] + return c == ' ' || c == '.' +} - // Pattern 1: "." prefix + trailing spaces / periods / ADS. - if len(name) >= len(dotgit)+1 && name[0] == '.' && - strings.EqualFold(name[1:1+len(dotgit)], dotgit) { - if onlySpacesAndPeriods(len(dotgit) + 1) { - return true - } +// IsNTFSDot reports whether name, a path component, is a spelling NTFS +// resolves to the file "." + dotgit. dotgit is the lowercase name without +// its leading dot ("gitmodules"), and shortnamePrefix the six-character +// prefix of the hash-style short name NTFS generates for it ("gi7eba"), or +// empty to leave that form out. +// +// NTFS compares names without regard to case, drops trailing spaces and +// periods, and takes everything from the first colon on as the name of an +// alternate data stream of the same file. Besides its long name a file +// answers to an 8.3 short name: the first six characters, "~" and a digit +// from 1 to 4, or, once those are taken, a prefix derived from a hash of +// the name, "~" and a number, eight characters in all. +// +// An empty dotgit matches every component NTFS reduces to a bare dot, +// "." and ".." included. +func IsNTFSDot(name, dotgit, shortnamePrefix string) bool { + const shortNameLen = 8 + + // Every alias starts with a dot or has a tilde in its short name, so + // most names are settled without looking further. + if name == "" || (name[0] != '.' && strings.IndexByte(name[:min(shortNameLen, len(name))], '~') < 0) { + return false + } + // A name that starts with a dot can only be the long form. + if name[0] == '.' && !hasASCIIFoldPrefix(name[1:], dotgit) { + return false } - // Pattern 2: standard NTFS short name ~[1-4]. - if len(dotgit) >= 6 && len(name) >= 8 && - strings.EqualFold(name[:6], dotgit[:6]) && - name[6] == '~' && name[7] >= '1' && name[7] <= '4' { - if onlySpacesAndPeriods(8) { - return true - } + base, _, _ := strings.Cut(name, ":") + + if rest, ok := strings.CutPrefix(base, "."); ok && len(rest) >= len(dotgit) && + asciiEqualFold(rest[:len(dotgit)], dotgit) && + strings.Trim(rest[len(dotgit):], " .") == "" { + return true } - // Pattern 3: fall-back NTFS short name keyed by shortnamePrefix. - if len(shortnamePrefix) < 6 || len(name) < 8 { + if len(base) < shortNameLen || strings.Trim(base[shortNameLen:], " .") != "" { return false } - sawTilde := false - i := 0 - for i < 8 { - c := name[i] - switch { - case sawTilde: - if c < '0' || c > '9' { - return false - } - case c == '~': - i++ - if i >= len(name) || name[i] < '1' || name[i] > '9' { - return false - } - sawTilde = true - case i >= 6: - return false - case c&0x80 != 0: - return false - default: - if asciiToLower(c) != shortnamePrefix[i] { - return false - } - } - i++ + stem, number, ok := strings.Cut(base[:shortNameLen], "~") + if !ok { + return false } - return onlySpacesAndPeriods(8) + + if len(stem) == 6 && len(dotgit) >= 6 && asciiEqualFold(stem, dotgit[:6]) && + number[0] >= '1' && number[0] <= '4' { + return true + } + + return len(shortnamePrefix) == 6 && len(stem) <= 6 && + asciiEqualFold(stem, shortnamePrefix[:len(stem)]) && + number[0] != '0' && strings.Trim(number, "0123456789") == "" } -// IsNTFSDotGitmodules reports whether part is an NTFS equivalent of -// ".gitmodules" — the file name or any variant that NTFS would -// resolve to it. The 6-character canonical short-name prefix "gi7eba" -// mirrors upstream Git's is_ntfs_dotgitmodules. +// IsNTFSDotGitmodules reports whether part is a name NTFS resolves to +// ".gitmodules": the name itself in any case, with trailing spaces, +// periods or a stream suffix, or one of its short names. "gi7eba" is the +// prefix of the hash-style short name NTFS gives ".gitmodules". func IsNTFSDotGitmodules(part string) bool { return IsNTFSDot(part, "gitmodules", "gi7eba") } -// IsNTFSDotGitattributes reports whether part is an NTFS equivalent -// of ".gitattributes". The short-name prefix "gi7d29" mirrors upstream -// Git's is_ntfs_dotgitattributes. +// IsNTFSDotGitattributes reports whether part is a name NTFS resolves to +// ".gitattributes", whose hash-style short name starts with "gi7d29". func IsNTFSDotGitattributes(part string) bool { return IsNTFSDot(part, "gitattributes", "gi7d29") } -// IsNTFSDotGitignore reports whether part is an NTFS equivalent of -// ".gitignore". The short-name prefix "gi250a" mirrors upstream Git's -// is_ntfs_dotgitignore. +// IsNTFSDotGitignore reports whether part is a name NTFS resolves to +// ".gitignore", whose hash-style short name starts with "gi250a". func IsNTFSDotGitignore(part string) bool { return IsNTFSDot(part, "gitignore", "gi250a") } -// IsNTFSDotMailmap reports whether part is an NTFS equivalent of -// ".mailmap". The short-name prefix "maba30" mirrors upstream Git's -// is_ntfs_dotmailmap. +// IsNTFSDotMailmap reports whether part is a name NTFS resolves to +// ".mailmap", whose hash-style short name starts with "maba30". func IsNTFSDotMailmap(part string) bool { return IsNTFSDot(part, "mailmap", "maba30") } @@ -205,3 +235,23 @@ func asciiToLower(c byte) byte { } return c } + +// hasASCIIFoldPrefix reports whether s starts with prefix, ASCII case aside. +func hasASCIIFoldPrefix(s, prefix string) bool { + return len(s) >= len(prefix) && asciiEqualFold(s[:len(prefix)], prefix) +} + +// asciiEqualFold reports whether a and b are equal when ASCII letters are +// compared without regard to case. Unlike strings.EqualFold it folds +// nothing else, so no non-ASCII character is taken for a letter. +func asciiEqualFold(a, b string) bool { + if len(a) != len(b) { + return false + } + for i := 0; i < len(a); i++ { + if asciiToLower(a[i]) != asciiToLower(b[i]) { + return false + } + } + return true +} diff --git a/vendor/github.com/go-git/go-git/v6/internal/pathutil/tree.go b/vendor/github.com/go-git/go-git/v6/internal/pathutil/tree.go index e610cd4a8b..acb8e69193 100644 --- a/vendor/github.com/go-git/go-git/v6/internal/pathutil/tree.go +++ b/vendor/github.com/go-git/go-git/v6/internal/pathutil/tree.go @@ -6,35 +6,45 @@ import ( "strings" ) -// ErrInvalidPath is returned by ValidTreePath when its argument is -// not a safe path to materialise into the worktree. +// ErrInvalidPath is returned by ValidTreePath, and wrapped by the +// worktree filesystem wrapper's own path refusals, when a path is not +// safe to materialise into the worktree. var ErrInvalidPath = fmt.Errorf("invalid path") // ValidTreePath rejects path strings that, if materialised into a // worktree, would let an attacker-controlled tree entry escape the // worktree or rewrite repository metadata. It rejects: // -// - control characters (< 0x20, 0x7f); -// - empty paths and "." / ".." components; -// - Windows volume name prefixes (e.g. C:); -// - .git, its 8.3 NTFS short-name git~1, plus their HFS+ and NTFS -// variants — at every position, not just the root. +// - empty paths and control bytes (< 0x20, 0x7f); +// - "." and ".." components, only the literal names, as Git's +// verify_dotfile; +// - .git, its 8.3 NTFS short name git~1, and their HFS+ and NTFS +// variants — at every position, not just the root; +// - Windows volume name prefixes (e.g. C:), which +// filepath.VolumeName recognises only on Windows. // -// HFS+/NTFS variants of `.git` are always rejected at this layer -// regardless of runtime config: tree paths are canonical UTF-8 with -// no zero-width characters or NTFS short-name forms, so an entry -// that looks like a disguised `.git` is suspicious anywhere. Windows -// reserved device names (CON, NUL, etc.) are not policed here — they -// are legitimate filenames on non-Windows filesystems and upstream -// Git accepts them. The wrapper layer (validPath in package git) -// rejects them at materialisation time when core.protectNTFS is on. +// Both slash forms separate components. Every rule applies regardless +// of core.protectHFS and core.protectNTFS: tree paths are canonical +// UTF-8 with no zero-width characters or NTFS short-name forms, so an +// entry that looks like a disguise is suspicious anywhere. That is +// stricter than C Git, which gates the disguise checks on those two +// settings and can store such names on POSIX. // -// Mirrors upstream Git's verify_path_internal at read-cache.c#L987 -// in tag v2.54.0[1] with protect_hfs / protect_ntfs treated as -// always-on for `.git`-disguise detection (tree paths are not -// application-supplied) and is_valid_win32_path left to the wrapper. +// Win32ValidPath's character, trailing-space/period and device rules do +// not belong here — applying them would make an ordinary POSIX +// repository unreadable, and upstream likewise compiles +// is_valid_win32_path only for MinGW and MSVC. A component of periods +// alone therefore passes this gate. The worktree wrapper's validPath +// applies those rules on a Win32 host with core.protectNTFS. // -// [1]: https://github.com/git/git/blob/v2.54.0/read-cache.c#L987 +// A rejected entry interrupts tree iteration and checkout; entries +// yielded before it have already been seen by the caller. +// +// Mirrors upstream Git's verify_path_internal at read-cache.c#L987-L1048 +// in tag v2.54.0[1], with protect_hfs and protect_ntfs treated as +// always-on and is_valid_win32_path left to the wrapper. +// +// [1]: https://github.com/git/git/blob/v2.54.0/read-cache.c#L987-L1048 func ValidTreePath(p string) error { for i := 0; i < len(p); i++ { if p[i] < 0x20 || p[i] == 0x7f { @@ -42,7 +52,7 @@ func ValidTreePath(p string) error { } } - parts := strings.FieldsFunc(p, func(r rune) bool { return r == '\\' || r == '/' }) + parts := strings.FieldsFunc(p, isPathSep) if len(parts) == 0 { return fmt.Errorf("%w: %q", ErrInvalidPath, p) } @@ -53,6 +63,8 @@ func ValidTreePath(p string) error { } for _, part := range parts { + // Only the literal names, as Git's verify_dotfile: an NTFS or + // HFS+ spelling of ".." is an ordinary name in a tree. if part == "." || part == ".." { return fmt.Errorf("%w %q: cannot use %q", ErrInvalidPath, p, part) } @@ -64,3 +76,35 @@ func ValidTreePath(p string) error { return nil } + +// ValidSubmodulePath applies ValidTreePath and the rule a submodule +// path needs beyond it: no NTFS or HFS+ spelling of "." or "..". +// Submodule.Repository chroots the submodule worktree to this path, so +// such a component scopes the submodule to the superproject worktree +// root instead of a directory below it, and a checkout then +// materialises the submodule's blobs over the superproject's own +// files. +// +// ValidTreePath stays tolerant of these because an ordinary tree entry +// only names a file there, and C Git's verify_path carries such names +// on POSIX. C Git does not validate the .gitmodules path at all — the +// gitlink path it uses comes from the index — so this rule is a +// deliberate go-git policy, stricter than Git, for the one place a +// tree-controlled string becomes a chroot base. It applies on every +// host, whatever core.protectNTFS and core.protectHFS say. +func ValidSubmodulePath(p string) error { + if err := ValidTreePath(p); err != nil { + return err + } + + // A submodule path is chrooted into, so the NTFS and HFS+ spellings + // of "." and "..", which a tree may carry as ordinary names, are + // refused here. + for _, part := range strings.FieldsFunc(p, isPathSep) { + if IsDotName(part) || IsDotOrDotDotName(part) { + return fmt.Errorf("%w %q: cannot use %q", ErrInvalidPath, p, part) + } + } + + return nil +} diff --git a/vendor/github.com/go-git/go-git/v6/internal/pathutil/volume.go b/vendor/github.com/go-git/go-git/v6/internal/pathutil/volume.go new file mode 100644 index 0000000000..895419c4db --- /dev/null +++ b/vendor/github.com/go-git/go-git/v6/internal/pathutil/volume.go @@ -0,0 +1,157 @@ +// Derived from src/internal/filepathlite/path_windows.go in Go +// 1.26.5[1], with only the two unexported helpers renamed, and +// distributed under Go's licence[2], reproduced here: +// +// Copyright 2009 The Go Authors. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google LLC nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// [1]: https://github.com/golang/go/blob/go1.26.5/src/internal/filepathlite/path_windows.go +// [2]: https://github.com/golang/go/blob/go1.26.5/LICENSE + +package pathutil + +// HasVolumeName takes one whole path and reports whether it has a +// Windows volume prefix, independent of the host. It is equivalent to +// filepath.VolumeName(p) != "" evaluated on Windows with Go 1.26; Go +// 1.27 reports no volume name for a candidate holding a ".." component +// (golang/go#58451), and this package keeps the Go 1.26 answer, which +// refuses such a path on both toolchains. Like Go, it treats a drive +// prefix as a single byte followed by a colon; it does not recognize +// a multibyte UTF-8 drive letter. +func HasVolumeName(p string) bool { return volumeNameLen(p) != 0 } + +// volumeNameLen returns length of the leading volume name by Windows +// rules, on every host. +// +// See: +// https://learn.microsoft.com/en-us/dotnet/standard/io/file-path-formats +// https://googleprojectzero.blogspot.com/2016/02/the-definitive-guide-on-win32-to-nt.html +func volumeNameLen(path string) int { + switch { + case len(path) >= 2 && path[1] == ':': + // Path starts with a drive letter. + // + // Not all Windows functions necessarily enforce the requirement that + // drive letters be in the set A-Z, and we don't try to here. + // + // We don't handle the case of a path starting with a non-ASCII character, + // in which case the "drive letter" might be multiple bytes long. + return 2 + + case len(path) == 0 || !isPathSeparator(path[0]): + // Path does not have a volume component. + return 0 + + case pathHasPrefixFold(path, `\\.\UNC`): + // We're going to treat the UNC host and share as part of the volume + // prefix for historical reasons, but this isn't really principled; + // Windows's own GetFullPathName will happily remove the first + // component of the path in this space, converting + // \\.\unc\a\b\..\c into \\.\unc\a\c. + return uncLen(path, len(`\\.\UNC\`)) + + case pathHasPrefixFold(path, `\\.`) || + pathHasPrefixFold(path, `\\?`) || pathHasPrefixFold(path, `\??`): + // Path starts with \\.\, and is a Local Device path; or + // path starts with \\?\ or \??\ and is a Root Local Device path. + // + // We treat the next component after the \\.\ prefix as + // part of the volume name, which means Clean(`\\?\c:\`) + // won't remove the trailing \. (See #64028.) + if len(path) == 3 { + return 3 // exactly \\. + } + _, rest, ok := cutPath(path[4:]) + if !ok { + return len(path) + } + return len(path) - len(rest) - 1 + + case len(path) >= 2 && isPathSeparator(path[1]): + // Path starts with \\, and is a UNC path. + return uncLen(path, 2) + } + return 0 +} + +// pathHasPrefixFold tests whether the path s begins with prefix, +// ignoring case and treating all path separators as equivalent. +// If s is longer than prefix, then s[len(prefix)] must be a path separator. +func pathHasPrefixFold(s, prefix string) bool { + if len(s) < len(prefix) { + return false + } + for i := 0; i < len(prefix); i++ { + if isPathSeparator(prefix[i]) { + if !isPathSeparator(s[i]) { + return false + } + } else if asciiToUpper(prefix[i]) != asciiToUpper(s[i]) { + return false + } + } + if len(s) > len(prefix) && !isPathSeparator(s[len(prefix)]) { + return false + } + return true +} + +// uncLen returns the length of the volume prefix of a UNC path. +// prefixLen is the prefix prior to the start of the UNC host; +// for example, for "//host/share", the prefixLen is len("//")==2. +func uncLen(path string, prefixLen int) int { + count := 0 + for i := prefixLen; i < len(path); i++ { + if isPathSeparator(path[i]) { + count++ + if count == 2 { + return i + } + } + } + return len(path) +} + +// cutPath slices path around the first path separator. +func cutPath(path string) (before, after string, found bool) { + for i := range path { + if isPathSeparator(path[i]) { + return path[:i], path[i+1:], true + } + } + return path, "", false +} + +func isPathSeparator(c byte) bool { return c == '\\' || c == '/' } + +func asciiToUpper(c byte) byte { + if 'a' <= c && c <= 'z' { + return c - ('a' - 'A') + } + return c +} diff --git a/vendor/github.com/go-git/go-git/v6/utils/sync/bufio.go b/vendor/github.com/go-git/go-git/v6/internal/sync/bufio.go similarity index 73% rename from vendor/github.com/go-git/go-git/v6/utils/sync/bufio.go rename to vendor/github.com/go-git/go-git/v6/internal/sync/bufio.go index 9f4aa291c5..d263a859ee 100644 --- a/vendor/github.com/go-git/go-git/v6/utils/sync/bufio.go +++ b/vendor/github.com/go-git/go-git/v6/internal/sync/bufio.go @@ -24,10 +24,13 @@ func GetBufioReader(reader io.Reader) *bufio.Reader { return r } -// PutBufioReader puts reader back into its sync.Pool. +// PutBufioReader puts reader back into its sync.Pool. It drops the reference +// to the underlying io.Reader first, so the pool does not keep that reader, +// and anything it holds, alive. reader must not be used afterwards. func PutBufioReader(reader *bufio.Reader) { if reader == nil { return } + reader.Reset(nil) bufioReader.Put(reader) } diff --git a/vendor/github.com/go-git/go-git/v6/utils/sync/bytes.go b/vendor/github.com/go-git/go-git/v6/internal/sync/bytes.go similarity index 100% rename from vendor/github.com/go-git/go-git/v6/utils/sync/bytes.go rename to vendor/github.com/go-git/go-git/v6/internal/sync/bytes.go diff --git a/vendor/github.com/go-git/go-git/v6/utils/sync/zlib.go b/vendor/github.com/go-git/go-git/v6/internal/sync/zlib.go similarity index 97% rename from vendor/github.com/go-git/go-git/v6/utils/sync/zlib.go rename to vendor/github.com/go-git/go-git/v6/internal/sync/zlib.go index 6be0284a15..971de1d1a9 100644 --- a/vendor/github.com/go-git/go-git/v6/utils/sync/zlib.go +++ b/vendor/github.com/go-git/go-git/v6/internal/sync/zlib.go @@ -17,7 +17,7 @@ type ZlibReader = plugin.ZlibReader // ZlibWriter is an alias of plugin.ZlibWriter. type ZlibWriter = plugin.ZlibWriter -var errNilZlibReader = errors.New("utils/sync: zlib reader source is nil") +var errNilZlibReader = errors.New("internal/sync: zlib reader source is nil") var ( zlibInitBytes = []byte{0x78, 0x9c, 0x01, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x01} diff --git a/vendor/github.com/go-git/go-git/v6/internal/transport/drain.go b/vendor/github.com/go-git/go-git/v6/internal/transport/drain.go new file mode 100644 index 0000000000..cefb6da81e --- /dev/null +++ b/vendor/github.com/go-git/go-git/v6/internal/transport/drain.go @@ -0,0 +1,52 @@ +package transport + +import ( + "errors" + "io" +) + +// ErrPackJunk is returned when pack data follows the pack trailer. The wording +// is that of Git's index-pack, which reports it only for a pack read from a +// regular file. transport.ErrPackJunk aliases this value. +var ErrPackJunk = errors.New("pack has junk at the end") + +// DrainPackSection reads the rest of a multiplexed pack response from demuxer, +// once the object storage has stored the pack, up to its closing flush-pkt. +// Progress still goes to the demuxer's Progress, and an error the server sends +// on the error band is returned. +// +// Pack data after the trailer fails the fetch with [ErrPackJunk]. Git's +// outcome depends on how the pack is unpacked and on timing. Its demuxer +// writes such data into the pipe to index-pack or unpack-objects, and that +// write fails the fetch with "error in sideband demultiplexer" if the +// unpacker has already exited, which junk larger than the pipe plus what +// the unpacker reads ahead (up to 128 KiB) guarantees. index-pack checks for +// junk only when its input is a regular file. On a fetch it writes what it +// read past the trailer to stdout. fetch-pack reads that only when it keeps +// the pack, and then rejects it as malformed output unless it is made of +// hex lines, which it takes as gitmodules OIDs. Junk the unpacker never +// read, still in the pipe, lets the fetch succeed. unpack-objects, used for +// small fetches, writes what it read past the trailer to stdout as well, and +// the fetch succeeds (Git v2.56.0: builtin/index-pack.c:1302-1306 and +// 1656-1657, builtin/unpack-objects.c:693-694, fetch-pack.c:924-942, +// 1076-1089 and 1103-1104, run-command.c:1150-1154). +// upload-pack never sends pack data after the pack, so the check fails +// such a fetch where the storage leaves the junk unread, rather than depend +// on timing. +// +// Empty pack-data packets, which servers send as keepalives, are not data. +// The pack is already stored by then, so the fetch reports an error although +// its objects are in storage. +// +// The check is best effort: it sees only what the storage left unread. +// Filesystem storage, the default, reads the pack source in 64 KiB chunks +// and stops at the trailer, and memory storage's parser buffers too, so +// each drops junk that arrives within the last chunk it read and reports +// only what follows. +func DrainPackSection(demuxer io.Reader) error { + n, err := io.Copy(io.Discard, demuxer) + if err == nil && n > 0 { + err = ErrPackJunk + } + return err +} diff --git a/vendor/github.com/go-git/go-git/v6/internal/transport/read_finished.go b/vendor/github.com/go-git/go-git/v6/internal/transport/read_finished.go new file mode 100644 index 0000000000..2a01369cba --- /dev/null +++ b/vendor/github.com/go-git/go-git/v6/internal/transport/read_finished.go @@ -0,0 +1,39 @@ +package transport + +import ( + "context" + "errors" +) + +// ReadFinished reports whether the reader wrapped by ioutil.NewContextReader +// or ioutil.NewContextReadCloser has finished with the reader underneath it, +// so that reader (typically a network connection) may be closed after a read +// returned err. +// +// It has not when this context's cancellation is what ended the read. The +// wrapper returns from its <-ctx.Done() branch while the goroutine it started +// can still be blocked in the underlying Read, and closing would race that +// goroutine. Nothing is leaked by leaving it, because a reader bound to the +// same context is torn down by that context anyway. Any other outcome, success +// included, means the last Read arrived over the result channel and the +// goroutine is finished, so the underlying reader must be closed or it and its +// connection are held for the life of the process. +// +// A cancellation error alone is not enough to answer no. A deadline belonging +// to something else, such as a storer or a wrapped inner operation, can +// surface as DeadlineExceeded while this context is still live, and treating +// that as unsafe leaks the reader. A cancelled context alone is not enough +// either. It can be cancelled an instant after a read that had already +// finished, and skipping the close there leaks it too. +// +// The two together are not exact. Once this context is done, a cancellation +// that came from somewhere else reads the same as its own, and the close is +// skipped for a read that had in fact finished. The reader that answer is +// wrong about is a reader bound to a context that is already done, which its +// own teardown closes. A reader bound to something else is leaked. +func ReadFinished(ctx context.Context, err error) bool { + if ctx.Err() == nil { + return true + } + return !errors.Is(err, context.Canceled) && !errors.Is(err, context.DeadlineExceeded) +} diff --git a/vendor/github.com/go-git/go-git/v6/internal/transport/v2.go b/vendor/github.com/go-git/go-git/v6/internal/transport/v2.go index cbb0b7148c..5e8f676dfe 100644 --- a/vendor/github.com/go-git/go-git/v6/internal/transport/v2.go +++ b/vendor/github.com/go-git/go-git/v6/internal/transport/v2.go @@ -9,6 +9,7 @@ import ( "strings" "github.com/go-git/go-git/v6/plumbing" + formatcfg "github.com/go-git/go-git/v6/plumbing/format/config" "github.com/go-git/go-git/v6/plumbing/format/packfile" "github.com/go-git/go-git/v6/plumbing/protocol/capability" "github.com/go-git/go-git/v6/plumbing/protocol/packp" @@ -83,10 +84,9 @@ func lsRefsSupportsUnborn(server capability.List) bool { // LsRefs lists references using the v2 ls-refs command run through cmd. It // always requests peeled tags and symref targets so HEAD resolves to its -// branch, and requests unborn HEAD reporting when the server advertises it. The -// returned references include a symbolic HEAD (and an unborn HEAD as a symref -// whose target has no hash reference) so callers can detect an unborn branch. -func LsRefs(ctx context.Context, cmd CommandFunc, server capability.List, refPrefixes []string) ([]*plumbing.Reference, error) { +// branch, and requests unborn HEAD reporting when the server advertises it. An +// unborn HEAD is returned as a symbolic reference and named by UnbornHead. +func LsRefs(ctx context.Context, cmd CommandFunc, server capability.List, refPrefixes []string) (*packp.LsRefsOutput, error) { args := &packp.LsRefsArgs{ Peel: true, Symrefs: true, @@ -99,20 +99,20 @@ func LsRefs(ctx context.Context, cmd CommandFunc, server capability.List, refPre return nil, err } - return out.References, nil + return out, nil } -// HasHashRef reports whether refs contains at least one hash (non-symbolic) -// reference. A v2 ls-refs result with only a symbolic or unborn HEAD and no -// hash references corresponds to an empty repository, so callers treat the -// absence of hash references the same as the v0/v1 empty advertisement. -func HasHashRef(refs []*plumbing.Reference) bool { - for _, r := range refs { - if r.Type() == plumbing.HashReference { - return true - } +// IsEmptyLsRefs reports whether out advertises no reference with an object id, +// the v2 equivalent of an empty v0/v1 advertisement. An unborn HEAD is not a +// reference (connect.c process_ref_v2), and the decoder keeps it in References +// once at most. A symbolic HEAD that carries an object id is a reference, even +// when a ref-prefix left its target out of the result. +func IsEmptyLsRefs(out *packp.LsRefsOutput) bool { + n := len(out.References) + if out.UnbornHead != "" { + n-- } - return false + return n == 0 } // wantsLocal reports whether every wanted object is already present in haves, so @@ -209,6 +209,15 @@ func FetchV2(ctx context.Context, st storage.Storer, req *FetchRequest, round Fe Shallows: out.ShallowInfo.Shallows, Unshallows: out.ShallowInfo.Unshallows, } + // Git dies on a bad shallow line before it reads the pack, so + // a rejected update stores nothing. The fetch fails, so the + // response is closed without draining it for reuse. + if err := CheckShallowUpdate(st, shallowInfo); err != nil { + if c, ok := packReader.(io.Closer); ok { + _ = c.Close() + } + return err + } } if out.Acknowledgments != nil { @@ -226,7 +235,7 @@ func FetchV2(ctx context.Context, st storage.Storer, req *FetchRequest, round Fe streamErr := streamPackfile(ctx, st, packReader, req.Progress, req.Filter) // streamPackfile wraps packReader in a NewContextReader, so // whether this may be closed is that wrapper's question to answer. - if ioutil.ReadFinished(ctx, streamErr) { + if ReadFinished(ctx, streamErr) { closeReader(packReader) } if streamErr != nil { @@ -242,7 +251,7 @@ func FetchV2(ctx context.Context, st storage.Storer, req *FetchRequest, round Fe } if shallowInfo != nil { - if err := updateShallow(st, shallowInfo); err != nil { + if err := UpdateShallow(st, shallowInfo); err != nil { return err } } @@ -265,9 +274,20 @@ func streamPackfile(ctx context.Context, st storage.Storer, packReader io.Reader // The marker is left empty. Git fills it with the refs it sought on // this path and leaves it empty when repacking, and accepts either, // because only the file's presence is ever consulted. - return packfile.UpdatePromisorObjectStorage(st, demuxer, "") + if err := packfile.UpdatePromisorObjectStorage(st, demuxer, ""); err != nil { + return err + } + } else if err := packfile.UpdateObjectStorage(st, demuxer); err != nil { + return err } - return packfile.UpdateObjectStorage(st, demuxer) + + // Storage that parses the pack stops reading at its trailer, so read the + // rest of the section here: an error the server sends after the pack + // must fail the fetch, as must pack data after it, trailing progress + // must reach the caller, and a stream session must be left after the + // flush-pkt for its next command. The packfile section is always muxed, + // and the demuxer stops at its closing flush-pkt. + return DrainPackSection(demuxer) } // closeReader drains and closes r when it owns a closable resource (such as an @@ -282,8 +302,31 @@ func closeReader(r io.Reader) { } } -// updateShallow merges a shallow-info update into st's shallow boundary. -func updateShallow(st storage.Storer, info *packp.ShallowUpdate) error { +// CheckShallowUpdate returns an error when info holds an object ID that is +// not of st's object format. Call it before the pack is read, so that a +// rejected fetch leaves storage as it was. +func CheckShallowUpdate(st storage.Storer, info *packp.ShallowUpdate) error { + cfg, err := st.Config() + if err != nil { + return err + } + format := formatcfg.DefaultObjectFormat + if cfg != nil && cfg.Extensions.ObjectFormat != formatcfg.UnsetObjectFormat { + format = cfg.Extensions.ObjectFormat + } + for _, hashes := range [][]plumbing.Hash{info.Shallows, info.Unshallows} { + for _, h := range hashes { + if h.HexSize() != format.HexSize() { + return fmt.Errorf("shallow update: %s is not a %s object ID", h, format) + } + } + } + return nil +} + +// UpdateShallow merges a shallow update into st's shallow boundary. The +// update must have passed [CheckShallowUpdate]. +func UpdateShallow(st storage.Storer, info *packp.ShallowUpdate) error { shallows, err := st.Shallow() if err != nil { return err diff --git a/vendor/github.com/go-git/go-git/v6/options.go b/vendor/github.com/go-git/go-git/v6/options.go index 539e0686a0..fa59ab7ba5 100644 --- a/vendor/github.com/go-git/go-git/v6/options.go +++ b/vendor/github.com/go-git/go-git/v6/options.go @@ -124,18 +124,6 @@ const ( FastForwardMerge MergeStrategy = iota ) -// OrtMergeStrategyOption defines the merge strategy options for the ORT merge strategy, which can only resolve two heads using a 3-way merge algorithm. -// Since Git v2.50.0, ORT is synonym of recursive. -type OrtMergeStrategyOption int8 - -const ( - // TheirsMergeStrategy is a merge strategy option that auto-resolves the changes by accepting the incoming version of the changes. - TheirsMergeStrategy OrtMergeStrategyOption = iota - - // OursMergeStrategy is a merge strategy option that auto-resolves the changes by accepting our version of the changes and rejecting the incoming changes. - OursMergeStrategy -) - // Validate validates the fields and sets the default values. func (o *CloneOptions) Validate() error { if o.URL == "" { @@ -468,12 +456,6 @@ type ResetOptions struct { // SkipSparseDirValidation will skip the validation for SparseDirs. SkipSparseDirValidation bool - - // fromTree is used internally by Checkout to pass the tree that the - // worktree is currently at, before HEAD is updated. This ensures that - // HardReset and KeepReset properly diff from the actual previous state - // rather than the new HEAD. - fromTree *object.Tree } // Validate validates the fields and sets the default values. @@ -601,7 +583,9 @@ type CommitOptions struct { // len(Parents) is zero, the hash of HEAD reference is used. Parents []plumbing.Hash // Signer denotes a cryptographic signer to sign the commit with. - // A nil value here means the commit will not be signed. + // When nil, the commit is signed only if commit.gpgSign is enabled in the + // config. The registered ObjectSigner plugin is then used, and + // ErrNoObjectSigner is returned if there is none. Signer Signer // Amend will create a new commit object and replace the commit that HEAD currently // points to. Cannot be used with All nor Parents. @@ -696,7 +680,9 @@ type CreateTagOptions struct { // ending in a newline. Message string // Signer denotes a cryptographic signer to sign the tag with. - // A nil value here means the tag will not be signed. + // When nil, the tag is signed only if tag.gpgSign is enabled in the + // config. The registered ObjectSigner plugin is then used, and + // ErrNoObjectSigner is returned if there is none. Signer Signer } diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/filemode/filemode.go b/vendor/github.com/go-git/go-git/v6/plumbing/filemode/filemode.go index 4dd77ba715..f239ecf31a 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/filemode/filemode.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/filemode/filemode.go @@ -3,7 +3,9 @@ package filemode import ( "encoding/binary" + "errors" "fmt" + "math" "os" "strconv" ) @@ -65,22 +67,32 @@ func New(s string) (FileMode, error) { return FileMode(n), nil } -// FromBytes parses a FileMode from a byte slice containing an octal -// number. This avoids allocating a string when parsing from binary data. +// FromBytes parses b, a run of octal digits such as the mode of a tree +// entry, as a FileMode. It accepts leading zeros, so zero-padded modes +// such as "040000", written by early Git versions, or +// "00000000000100644" parse. It avoids allocating a string when +// parsing from binary data. // -// Please note this function does not check if the returned FileMode -// is valid in git or if it is malformed. +// If b is empty, contains a byte other than '0' to '7', or holds a +// value wider than 32 bits, FromBytes returns [Empty] and an error, as +// [New] does. +// +// FromBytes does not check whether the result is a valid tree entry +// mode. Use [FileMode.Canonical] to normalize the result. func FromBytes(b []byte) (FileMode, error) { - if len(b) == 0 || len(b) > 7 { - return Empty, fmt.Errorf("invalid mode length: %d", len(b)) + if len(b) == 0 { + return Empty, errors.New("empty mode") } var mode uint32 for _, c := range b { if c < '0' || c > '7' { - return Empty, fmt.Errorf("invalid octal character: %c", c) + return Empty, fmt.Errorf("invalid octal character: %q", c) + } + if mode > math.MaxUint32>>3 { + return Empty, errors.New("mode wider than 32 bits") } - mode = mode*8 + uint32(c-'0') + mode = mode<<3 | uint32(c-'0') } return FileMode(mode), nil } @@ -181,6 +193,41 @@ func (m FileMode) IsFile() bool { m == Symlink } +// Canonical returns the mode Git acts on for a tree entry stored with +// mode m, as Git's canon_mode[1] does. It is meant for modes read from +// tree objects: [Empty], which go-git elsewhere uses for an absent +// entry, becomes [Submodule] like any other unknown type. +// +// Only the file type bits (m & 0o170000) and the owner execute bit +// (0o100) count: +// +// - type 0o100000 is [Executable] if the owner execute bit is set, +// and [Regular] otherwise, so [Deprecated] and 0o100011 both +// become Regular; +// - type 0o120000 is [Symlink] and type 0o040000 is [Dir], whatever +// their permission bits; +// - any other type is [Submodule]. +// +// The result is never malformed (see [FileMode.IsMalformed]), and +// Canonical of a canonical mode returns it unchanged. +// +// [1]: https://github.com/git/git/blob/v2.55.0/object.h#L133-L154 +func (m FileMode) Canonical() FileMode { + switch m & 0o170000 { + case 0o100000: + if m&0o100 != 0 { + return Executable + } + return Regular + case 0o120000: + return Symlink + case 0o040000: + return Dir + default: + return Submodule + } +} + // ToOSFileMode returns the os.FileMode to be used when creating file // system elements with the given git mode and a nil error on success. // diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/format/config/doc.go b/vendor/github.com/go-git/go-git/v6/plumbing/format/config/doc.go index 6dad4296f8..8624623ba9 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/format/config/doc.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/format/config/doc.go @@ -1,121 +1,19 @@ -// Package config implements encoding and decoding of git config files. +// Package config implements encoding and decoding of Git configuration +// files. // -// Configuration File -// ------------------ +// A configuration file is a list of sections, each holding options and, +// optionally, named subsections with options of their own: // -// The Git configuration file contains a number of variables that affect -// the Git commands' behavior. The `.git/config` file in each repository -// is used to store the configuration for that repository, and -// `$HOME/.gitconfig` is used to store a per-user configuration as -// fallback values for the `.git/config` file. The file `/etc/gitconfig` -// can be used to store a system-wide default configuration. +// [core] +// bare = false +// [remote "origin"] +// url = https://example.com/repo.git +// fetch = +refs/heads/*:refs/remotes/origin/* // -// The configuration variables are used by both the Git plumbing -// and the porcelains. The variables are divided into sections, wherein -// the fully qualified variable name of the variable itself is the last -// dot-separated segment and the section name is everything before the last -// dot. The variable names are case-insensitive, allow only alphanumeric -// characters and `-`, and must start with an alphabetic character. Some -// variables may appear multiple times; we say then that the variable is -// multivalued. +// A [Decoder] reads a file into a [Config], and an [Encoder] writes one +// back. The package deals with the syntax only and gives no meaning to the +// options, which is left to the go-git config package. // -// Syntax -// ~~~~~~ -// -// The syntax is fairly flexible and permissive; whitespaces are mostly -// ignored. The '#' and ';' characters begin comments to the end of line, -// blank lines are ignored. -// -// The file consists of sections and variables. A section begins with -// the name of the section in square brackets and continues until the next -// section begins. Section names are case-insensitive. Only alphanumeric -// characters, `-` and `.` are allowed in section names. Each variable -// must belong to some section, which means that there must be a section -// header before the first setting of a variable. -// -// Sections can be further divided into subsections. To begin a subsection -// put its name in double quotes, separated by space from the section name, -// in the section header, like in the example below: -// -// -------- -// [section "subsection"] -// -// -------- -// -// Subsection names are case sensitive and can contain any characters except -// newline (doublequote `"` and backslash can be included by escaping them -// as `\"` and `\\`, respectively). Section headers cannot span multiple -// lines. Variables may belong directly to a section or to a given subsection. -// You can have `[section]` if you have `[section "subsection"]`, but you -// don't need to. -// -// There is also a deprecated `[section.subsection]` syntax. With this -// syntax, the subsection name is converted to lower-case and is also -// compared case sensitively. These subsection names follow the same -// restrictions as section names. -// -// All the other lines (and the remainder of the line after the section -// header) are recognized as setting variables, in the form -// 'name = value' (or just 'name', which is a short-hand to say that -// the variable is the boolean "true"). -// The variable names are case-insensitive, allow only alphanumeric characters -// and `-`, and must start with an alphabetic character. -// -// A line that defines a value can be continued to the next line by -// ending it with a `\`; the backquote and the end-of-line are -// stripped. Leading whitespaces after 'name =', the remainder of the -// line after the first comment character '#' or ';', and trailing -// whitespaces of the line are discarded unless they are enclosed in -// double quotes. Internal whitespaces within the value are retained -// verbatim. -// -// Inside double quotes, double quote `"` and backslash `\` characters -// must be escaped: use `\"` for `"` and `\\` for `\`. -// -// The following escape sequences (beside `\"` and `\\`) are recognized: -// `\n` for newline character (NL), `\t` for horizontal tabulation (HT, TAB) -// and `\b` for backspace (BS). Other char escape sequences (including octal -// escape sequences) are invalid. -// -// Includes -// ~~~~~~~~ -// -// You can include one config file from another by setting the special -// `include.path` variable to the name of the file to be included. The -// variable takes a pathname as its value, and is subject to tilde -// expansion. -// -// The included file is expanded immediately, as if its contents had been -// found at the location of the include directive. If the value of the -// `include.path` variable is a relative path, the path is considered to be -// relative to the configuration file in which the include directive was -// found. See below for examples. -// -// -// Example -// ~~~~~~~ -// -// # Core variables -// [core] -// ; Don't trust file modes -// filemode = false -// -// # Our diff algorithm -// [diff] -// external = /usr/local/bin/diff-wrapper -// renames = true -// -// [branch "devel"] -// remote = origin -// merge = refs/heads/devel -// -// # Proxy settings -// [core] -// gitProxy="ssh" for "kernel.org" -// gitProxy=default-proxy ; for the rest -// -// [include] -// path = /path/to/foo.inc ; include by absolute path -// path = foo ; expand "foo" relative to the current file -// path = ~/foo ; expand "foo" in your `$HOME` directory +// The syntax is specified in git-config(1), under "CONFIGURATION FILE": +// https://git-scm.com/docs/git-config#_configuration_file package config diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/format/config/encoder.go b/vendor/github.com/go-git/go-git/v6/plumbing/format/config/encoder.go index 2502b6eae1..c4b1cd4e47 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/format/config/encoder.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/format/config/encoder.go @@ -1,6 +1,7 @@ package config import ( + "errors" "fmt" "io" "strings" @@ -11,6 +12,15 @@ type Encoder struct { w io.Writer } +var ( + // ErrInvalidSectionName is returned when a section name is not one Git accepts. + ErrInvalidSectionName = errors.New("invalid section name") + // ErrInvalidSubsectionName is returned when a subsection name is not one Git accepts. + ErrInvalidSubsectionName = errors.New("invalid subsection name") + // ErrInvalidKey is returned when an option key is not one Git accepts. + ErrInvalidKey = errors.New("invalid key") +) + var ( subsectionReplacer = strings.NewReplacer(`"`, `\"`, `\`, `\\`) valueReplacer = strings.NewReplacer(`"`, `\"`, `\`, `\\`, "\n", `\n`, "\t", `\t`, "\b", `\b`) @@ -23,6 +33,10 @@ func NewEncoder(w io.Writer) *Encoder { // Encode writes the config in git config format to the stream of the encoder. func (e *Encoder) Encode(cfg *Config) error { + if err := validateNames(cfg); err != nil { + return err + } + for _, s := range cfg.Sections { if err := e.encodeSection(s); err != nil { return err @@ -63,7 +77,7 @@ func (e *Encoder) encodeSubsection(sectionName string, s *Subsection) error { func (e *Encoder) encodeOptions(opts Options) error { for _, o := range opts { var value string - if strings.ContainsAny(o.Value, "#;\"\t\n\\") || strings.HasPrefix(o.Value, " ") || strings.HasSuffix(o.Value, " ") { + if strings.ContainsAny(o.Value, "#;\"\t\n\r\\") || strings.HasPrefix(o.Value, " ") || strings.HasSuffix(o.Value, " ") { value = `"` + valueReplacer.Replace(o.Value) + `"` } else { value = o.Value @@ -81,3 +95,81 @@ func (e *Encoder) printf(msg string, args ...any) error { _, err := fmt.Fprintf(e.w, msg, args...) return err } + +// validateNames refuses the section, subsection and key names that Git +// itself cannot write or read back, so that a name can neither break the +// syntax of the file nor smuggle in extra sections or options. The rules +// follow git_config_parse_key and store_create_section in Git's config.c: +// +// - keys are non-empty, start with an ASCII letter and otherwise hold +// only ASCII letters, digits and "-"; +// - sections are non-empty and hold only ASCII letters, digits and "-". +// Git splits a "." into section and subsection, so a dotted section +// cannot be written as one; +// - subsections hold anything but a newline or a NUL. Git keeps the NUL +// and then treats the name as a C string, which truncates it. +func validateNames(cfg *Config) error { + for _, s := range cfg.Sections { + if !isValidSectionName(s.Name) { + return fmt.Errorf("%w: %q", ErrInvalidSectionName, s.Name) + } + + if err := validateKeys(s.Options); err != nil { + return err + } + + for _, ss := range s.Subsections { + if strings.ContainsAny(ss.Name, "\n\x00") { + return fmt.Errorf("%w: %q", ErrInvalidSubsectionName, ss.Name) + } + + if err := validateKeys(ss.Options); err != nil { + return err + } + } + } + + return nil +} + +func validateKeys(opts Options) error { + for _, o := range opts { + if !isValidKey(o.Key) { + return fmt.Errorf("%w: %q", ErrInvalidKey, o.Key) + } + } + + return nil +} + +func isValidSectionName(name string) bool { + if name == "" { + return false + } + + for i := 0; i < len(name); i++ { + if c := name[i]; !isAlnum(c) && c != '-' { + return false + } + } + + return true +} + +func isValidKey(key string) bool { + if key == "" || !isAlpha(key[0]) { + return false + } + + for i := 1; i < len(key); i++ { + if c := key[i]; !isAlnum(c) && c != '-' { + return false + } + } + + return true +} + +func isAlpha(c byte) bool { return c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' } + +func isAlnum(c byte) bool { return isAlpha(c) || c >= '0' && c <= '9' } diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/format/config/format.go b/vendor/github.com/go-git/go-git/v6/plumbing/format/config/format.go index c0c9b9e288..cea3013b9f 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/format/config/format.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/format/config/format.go @@ -9,31 +9,19 @@ import "errors" type RepositoryFormatVersion string const ( - // Version0 is the format defined by the initial version of git, - // including but not limited to the format of the repository - // directory, the repository configuration file, and the object - // and ref storage. - // - // Specifying the complete behavior of git is beyond the scope - // of this document. + // Version0 is the original repository format. It predates extensions, + // and only the few that Git supported before it tied them to the + // format version take effect in it: noop, preciousObjects, + // partialClone and worktreeConfig. Version0 = "0" - // Version1 is identical to version 0, with the following exceptions: - // - // 1. When reading the core.repositoryformatversion variable, a git - // implementation which supports version 1 MUST also read any - // configuration keys found in the extensions section of the - // configuration file. + // Version1 is Version0 with support for every extension: all keys of + // the extensions section of the configuration file take effect, and a + // repository that sets one the implementation does not know, or sets + // a known one to a value it does not understand, must be refused. // - // 2. If a version-1 repository specifies any extensions.* keys that - // the running git has not implemented, the operation MUST NOT proceed. - // Similarly, if the value of any known key is not understood by the - // implementation, the operation MUST NOT proceed. - // - // Note that if no extensions are specified in the config file, then - // core.repositoryformatversion SHOULD be set to 0 (setting it to 1 provides - // no benefit, and makes the repository incompatible with older - // implementations of git). + // A repository that uses no extensions gains nothing from this version + // and is better left at Version0, which older implementations can read. Version1 = "1" // DefaultRepositoryFormatVersion holds the default repository format version. @@ -89,6 +77,11 @@ func (f ObjectFormat) HexSize() int { // ErrInvalidObjectFormat is returned when an invalid ObjectFormat is used. var ErrInvalidObjectFormat = errors.New("invalid object format") +// ErrObjectFormatMismatch is returned when data or an object ID uses another +// object format than the one expected, such as a SHA-256 hash given to a +// SHA-1 index. +var ErrObjectFormatMismatch = errors.New("object format mismatch") + const ( // SHA1Size is the size of SHA1 hash. SHA1Size = 20 diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/format/config/section.go b/vendor/github.com/go-git/go-git/v6/plumbing/format/config/section.go index c50d578ee3..6a6e6deee8 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/format/config/section.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/format/config/section.go @@ -7,25 +7,17 @@ import ( ) // Section is the representation of a section inside git configuration files. -// Each Section contains Options that are used by both the Git plumbing -// and the porcelains. -// Sections can be further divided into subsections. To begin a subsection -// put its name in double quotes, separated by space from the section name, -// in the section header, like in the example below: +// A section has a name, options of its own, and any number of named +// subsections, each with their own options: // +// [section] +// option1 = value1 // [section "subsection"] +// option2 = value2 +// option3 // -// All the other lines (and the remainder of the line after the section header) -// are recognized as option variables, in the form "name = value" (or just name, -// which is a short-hand to say that the variable is the boolean "true"). -// The variable names are case-insensitive, allow only alphanumeric characters -// and -, and must start with an alphabetic character: -// -// [section "subsection1"] -// option1 = value1 -// option2 -// [section "subsection2"] -// option3 = value2 +// An option written without a value, like option3, reads as boolean true. +// Section and option names are case-insensitive; subsection names are not. type Section struct { Name string Options Options diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/format/gitignore/pattern.go b/vendor/github.com/go-git/go-git/v6/plumbing/format/gitignore/pattern.go index 3ea1e8ecef..ae6ff824c4 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/format/gitignore/pattern.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/format/gitignore/pattern.go @@ -73,6 +73,19 @@ func ParsePattern(p string, domain []string) Pattern { } res.pattern = strings.Split(p, patternDirSep) + + // Like git, read a segment made only of three or more asterisks as "**". + // A trailing one in a directory-only rule is left alone: "**" there would + // stop matching files below the directory, which "*" still does. + for i, seg := range res.pattern { + if res.dirOnly && i == len(res.pattern)-1 { + break + } + if len(seg) > len(zeroToManyDirs) && strings.Trim(seg, "*") == "" { + res.pattern[i] = zeroToManyDirs + } + } + return &res } diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/format/idxfile/decoder.go b/vendor/github.com/go-git/go-git/v6/plumbing/format/idxfile/decoder.go index c6466ab776..34ed8d35b5 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/format/idxfile/decoder.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/format/idxfile/decoder.go @@ -40,7 +40,7 @@ const ( // Input is the input to a [Decoder]. The decoder reads loose-object // bytes from it and calls Stat to learn the on-disk length, which it -// uses to validate the canonical-Git size formula before any +// uses to validate the size bounds before any // allocations driven by the fanout table. // // [os.File] and the go-billy [File] type satisfy Input directly. @@ -247,18 +247,25 @@ func readIdxChecksum(idx *MemoryIndex, r io.Reader) error { return nil } -// validateIdxV2Size enforces the size formula used by canonical Git -// load_idx for idx v2 files: the on-disk length must lie within -// [minSize, maxSize] where +// validateIdxV2Size checks that the length of an idx v2 file fits the object +// count its fanout declares. The length must lie within [minSize, maxSize] +// where // // perObject = hashsz + crc32Len + offset32Len // minSize = headerLen + fanoutLen + trailerHashes*hashsz + nr*perObject // maxSize = minSize + (nr-1)*offset64Len when nr > 0 // // with nr taken from the last fanout entry and hashsz from the -// configured object ID size. Multiplications use a self-checking -// overflow guard so inputs whose claimed object count overflows the -// formula are rejected rather than wrapping into a smaller value. +// configured object ID size. The 64-bit offset table holds an entry for +// each object whose offset does not fit in 31 bits, and for any other the +// writer chose to store there. Git accepts at most nr-1 entries when it +// opens an index, and the same bounds apply here. An index that gives +// every object a 64-bit entry, as `git index-pack --index-version=2,0` +// writes, is therefore rejected, as it is by Git. +// +// Multiplications use a self-checking overflow guard so inputs whose +// claimed object count overflows the formula are rejected rather than +// wrapping into a smaller value. func validateIdxV2Size(idx *MemoryIndex, idxSize int64) error { nr := int64(idx.Fanout[fanout-1]) hashsz := int64(idx.idSize()) @@ -276,8 +283,8 @@ func validateIdxV2Size(idx *MemoryIndex, idxSize int64) error { } // minIdxV2Size returns the minimum on-disk size of an idx v2 file -// holding nr objects with the given hash size, mirroring the -// computation in canonical Git load_idx. Returns -1 when any +// holding nr objects with the given hash size: the fixed parts and one +// record per object, with no 64-bit offsets. Returns -1 when any // intermediate multiplication or addition would overflow int64. func minIdxV2Size(nr, hashsz int64) int64 { perObject := hashsz + crc32Len + offset32Len @@ -295,8 +302,8 @@ func minIdxV2Size(nr, hashsz int64) int64 { } // maxIdxV2Size returns the maximum on-disk size of an idx v2 file -// holding nr objects with the given hash size, mirroring the -// computation in canonical Git load_idx. Returns -1 on overflow. +// holding nr objects with the given hash size: the minimum plus nr-1 +// 64-bit offsets. Returns -1 on overflow. func maxIdxV2Size(nr, hashsz int64) int64 { minSize := minIdxV2Size(nr, hashsz) if minSize < 0 { diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/format/idxfile/doc.go b/vendor/github.com/go-git/go-git/v6/plumbing/format/idxfile/doc.go index 20afeb772f..8eef1ff79b 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/format/idxfile/doc.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/format/idxfile/doc.go @@ -1,128 +1,12 @@ -// Package idxfile implements encoding and decoding of packfile idx files. +// Package idxfile implements encoding and decoding of packfile index +// (pack-*.idx) files. // -// == Original (version 1) pack-*.idx files have the following format: +// An index maps object ids to their offset and CRC-32 in the accompanying +// packfile. Only version 2 of the format is supported, with either SHA-1 or +// SHA-256 object ids. [MemoryIndex] holds a decoded index in memory, +// [LazyIndex] reads from the file on demand, and [Writer] builds an index +// while a packfile is being parsed. // -// - The header consists of 256 4-byte network byte order -// integers. N-th entry of this table records the number of -// objects in the corresponding pack, the first byte of whose -// object name is less than or equal to N. This is called the -// 'first-level fan-out' table. -// -// - The header is followed by sorted 24-byte entries, one entry -// per object in the pack. Each entry is: -// -// 4-byte network byte order integer, recording where the -// object is stored in the packfile as the offset from the -// beginning. -// -// 20-byte object name. -// -// - The file is concluded with a trailer: -// -// A copy of the 20-byte SHA1 checksum at the end of -// corresponding packfile. -// -// 20-byte SHA1-checksum of all of the above. -// -// Pack Idx file: -// -// -- +--------------------------------+ -// fanout | fanout[0] = 2 (for example) |-. -// table +--------------------------------+ | -// | fanout[1] | | -// +--------------------------------+ | -// | fanout[2] | | -// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | -// | fanout[255] = total objects |---. -// -- +--------------------------------+ | | -// main | offset | | | -// index | object name 00XXXXXXXXXXXXXXXX | | | -// tab +--------------------------------+ | | -// | offset | | | -// | object name 00XXXXXXXXXXXXXXXX | | | -// +--------------------------------+<+ | -// .-| offset | | -// | | object name 01XXXXXXXXXXXXXXXX | | -// | +--------------------------------+ | -// | | offset | | -// | | object name 01XXXXXXXXXXXXXXXX | | -// | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | -// | | offset | | -// | | object name FFXXXXXXXXXXXXXXXX | | -// --| +--------------------------------+<--+ -// trailer | | packfile checksum | -// | +--------------------------------+ -// | | idxfile checksum | -// | +--------------------------------+ -// .---------. -// | -// Pack file entry: <+ -// -// packed object header: -// 1-byte size extension bit (MSB) -// type (next 3 bit) -// size0 (lower 4-bit) -// n-byte sizeN (as long as MSB is set, each 7-bit) -// size0..sizeN form 4+7+7+..+7 bit integer, size0 -// is the least significant part, and sizeN is the -// most significant part. -// packed object data: -// If it is not DELTA, then deflated bytes (the size above -// is the size before compression). -// If it is REF_DELTA, then -// 20-byte base object name SHA1 (the size above is the -// size of the delta data that follows). -// delta data, deflated. -// If it is OFS_DELTA, then -// n-byte offset (see below) interpreted as a negative -// offset from the type-byte of the header of the -// ofs-delta entry (the size above is the size of -// the delta data that follows). -// delta data, deflated. -// -// offset encoding: -// n bytes with MSB set in all but the last one. -// The offset is then the number constructed by -// concatenating the lower 7 bit of each byte, and -// for n >= 2 adding 2^7 + 2^14 + ... + 2^(7*(n-1)) -// to the result. -// -// == Version 2 pack-*.idx files support packs larger than 4 GiB, and -// have some other reorganizations. They have the format: -// -// - A 4-byte magic number '\377tOc' which is an unreasonable -// fanout[0] value. -// -// - A 4-byte version number (= 2) -// -// - A 256-entry fan-out table just like v1. -// -// - A table of sorted 20-byte SHA1 object names. These are -// packed together without offset values to reduce the cache -// footprint of the binary search for a specific object name. -// -// - A table of 4-byte CRC32 values of the packed object data. -// This is new in v2 so compressed data can be copied directly -// from pack to pack during repacking without undetected -// data corruption. -// -// - A table of 4-byte offset values (in network byte order). -// These are usually 31-bit pack file offsets, but large -// offsets are encoded as an index into the next table with -// the msbit set. -// -// - A table of 8-byte offset entries (empty for pack files less -// than 2 GiB). Pack files are organized with heavily used -// objects toward the front, so most object references should -// not need to refer to this table. -// -// - The same trailer as a v1 pack file: -// -// A copy of the 20-byte SHA1 checksum at the end of -// corresponding packfile. -// -// 20-byte SHA1-checksum of all of the above. -// -// Source: -// https://www.kernel.org/pub/software/scm/git/docs/v1.7.5/technical/pack-format.txt +// The on-disk layout is specified in gitformat-pack(5): +// https://git-scm.com/docs/gitformat-pack package idxfile diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/format/idxfile/lazy_index.go b/vendor/github.com/go-git/go-git/v6/plumbing/format/idxfile/lazy_index.go index 20d464f16b..cbaddf17bb 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/format/idxfile/lazy_index.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/format/idxfile/lazy_index.go @@ -9,8 +9,9 @@ import ( "time" "github.com/go-git/go-git/v6/internal/sharedfile" + gsync "github.com/go-git/go-git/v6/internal/sync" "github.com/go-git/go-git/v6/plumbing" - gsync "github.com/go-git/go-git/v6/utils/sync" + formatcfg "github.com/go-git/go-git/v6/plumbing/format/config" "github.com/go-git/go-git/v6/x/fdpool" ) @@ -422,7 +423,7 @@ func (s *LazyIndex) CloseIdleDescriptors() error { // position (0..count-1) if found. func (s *LazyIndex) findHashPos(idx io.ReaderAt, h plumbing.Hash) (int, bool, error) { if h.Size() != s.hashSize { - return 0, false, fmt.Errorf("hash size mismatch: %d %d", h.Size(), s.hashSize) + return 0, false, fmt.Errorf("%w: %d-byte hash, index has %d", formatcfg.ErrObjectFormatMismatch, h.Size(), s.hashSize) } first := int(h.Bytes()[0]) var lo int diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/format/idxfile/writer.go b/vendor/github.com/go-git/go-git/v6/plumbing/format/idxfile/writer.go index 27e7ad01d3..3689e4d701 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/format/idxfile/writer.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/format/idxfile/writer.go @@ -8,9 +8,17 @@ import ( "sync" "github.com/go-git/go-git/v6/plumbing" + formatcfg "github.com/go-git/go-git/v6/plumbing/format/config" "github.com/go-git/go-git/v6/utils/binary" ) +// maxObjectsPrealloc caps the up-front capacity reserved from the pack's +// declared object count, so a header advertising an absurd quantity cannot +// trigger a multi-gigabyte allocation. The slice still grows organically +// beyond this hint. It mirrors the bound the packfile parser applies to its +// own cache, which cannot be imported from here without a cycle. +const maxObjectsPrealloc = 1 << 16 // 64 Ki entries + // objects implements sort.Interface and uses hash as sorting key. type objects []Entry @@ -69,7 +77,7 @@ func (w *Writer) Finished() bool { // OnHeader implements packfile.Observer interface. func (w *Writer) OnHeader(count uint32) error { w.count = count - w.objects = make(objects, 0, count) + w.objects = make(objects, 0, min(count, maxObjectsPrealloc)) return nil } @@ -122,7 +130,7 @@ func (w *Writer) createIndex() (*MemoryIndex, error) { bucket := -1 for i, o := range w.objects { if o.Hash.Size() != w.checksum.Size() { - return nil, fmt.Errorf("object hash size mismatch: %d instead of %d", o.Hash.Size(), w.checksum.Size()) + return nil, fmt.Errorf("%w: %d-byte object hash, want %d", formatcfg.ErrObjectFormatMismatch, o.Hash.Size(), w.checksum.Size()) } fan := o.Hash.Bytes()[0] diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/format/index/decoder.go b/vendor/github.com/go-git/go-git/v6/plumbing/format/index/decoder.go index 4cb95c6e4c..ff462aeab1 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/format/index/decoder.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/format/index/decoder.go @@ -342,8 +342,9 @@ func (d *Decoder) readExtension(idx *Index) error { } trace.Internal.Printf("index: end-of-index-entry extension decoded, offset %d hash %s", idx.EndOfIndexEntry.Offset, idx.EndOfIndexEntry.Hash) default: - // See https://git-scm.com/docs/index-format, which says: - // If the first byte is 'A'..'Z' the extension is optional and can be ignored. + // An extension whose signature starts with an uppercase letter is + // optional and may be skipped; any other must be understood. See + // https://git-scm.com/docs/gitformat-index. if header[0] < 'A' || header[0] > 'Z' { trace.Internal.Printf("index: unknown mandatory extension %s", string(header[:])) return ErrUnknownExtension @@ -480,9 +481,8 @@ func (d *treeExtensionDecoder) readEntry() (*TreeEntry, error) { e.Trees = subtrees - // An entry can be in an invalidated state and is represented by having a - // negative number in the entry_count field. In this case, there is no - // object name and the next entry starts immediately after the newline. + // A negative entry count marks the entry as invalidated. Such an entry + // carries no object name, so the next one follows the newline directly. if i < 0 { trace.Internal.Printf("index: tree extension entry %q invalidated (entry count %d)", e.Path, i) return nil, nil diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/format/index/doc.go b/vendor/github.com/go-git/go-git/v6/plumbing/format/index/doc.go index 9e5529306c..d685d054b8 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/format/index/doc.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/format/index/doc.go @@ -1,410 +1,13 @@ -// Package index implements encoding and decoding of index format files. -// -// Git index format -// -// == The Git index file has the following format -// -// All binary numbers are in network byte order. -// In a repository using the traditional SHA-1, checksums and object IDs -// (object names) mentioned below are all computed using SHA-1. Similarly, -// in SHA-256 repositories, these values are computed using SHA-256. -// Version 2 is described here unless stated otherwise. -// -// - A 12-byte header consisting of -// -// 4-byte signature: -// The signature is { 'D', 'I', 'R', 'C' } (stands for "dircache") -// -// 4-byte version number: -// The current supported versions are 2, 3 and 4. -// -// 32-bit number of index entries. -// -// - A number of sorted index entries (see below). -// -// - Extensions -// -// Extensions are identified by signature. Optional extensions can -// be ignored if Git does not understand them. -// -// 4-byte extension signature. If the first byte is 'A'..'Z' the -// extension is optional and can be ignored. -// -// 32-bit size of the extension -// -// Extension data -// -// - Hash checksum over the content of the index file before this checksum. -// -// == Index entry -// -// Index entries are sorted in ascending order on the name field, -// interpreted as a string of unsigned bytes (i.e. memcmp() order, no -// localization, no special casing of directory separator '/'). Entries -// with the same name are sorted by their stage field. -// -// An index entry typically represents a file. However, if sparse-checkout -// is enabled in cone mode (`core.sparseCheckoutCone` is enabled) and the -// `extensions.sparseIndex` extension is enabled, then the index may -// contain entries for directories outside of the sparse-checkout definition. -// These entries have mode `040000`, include the `SKIP_WORKTREE` bit, and -// the path ends in a directory separator. -// -// 32-bit ctime seconds, the last time a file's metadata changed -// this is stat(2) data -// -// 32-bit ctime nanosecond fractions -// this is stat(2) data -// -// 32-bit mtime seconds, the last time a file's data changed -// this is stat(2) data -// -// 32-bit mtime nanosecond fractions -// this is stat(2) data -// -// 32-bit dev -// this is stat(2) data -// -// 32-bit ino -// this is stat(2) data -// -// 32-bit mode, split into (high to low bits) -// -// 16-bit unused, must be zero -// -// 4-bit object type -// valid values in binary are 1000 (regular file), 1010 (symbolic link) -// and 1110 (gitlink) -// -// 3-bit unused, must be zero -// -// 9-bit unix permission. Only 0755 and 0644 are valid for regular files. -// Symbolic links and gitlinks have value 0 in this field. -// -// 32-bit uid -// this is stat(2) data -// -// 32-bit gid -// this is stat(2) data -// -// 32-bit file size -// This is the on-disk size from stat(2), truncated to 32-bit. -// -// Object name for the represented object -// -// A 16-bit 'flags' field split into (high to low bits) -// -// 1-bit assume-valid flag -// -// 1-bit extended flag (must be zero in version 2) -// -// 2-bit stage (during merge) -// -// 12-bit name length if the length is less than 0xFFF; otherwise 0xFFF -// is stored in this field. -// -// (Version 3 or later) A 16-bit field, only applicable if the -// "extended flag" above is 1, split into (high to low bits). -// -// 1-bit reserved for future -// -// 1-bit skip-worktree flag (used by sparse checkout) -// -// 1-bit intent-to-add flag (used by "git add -N") -// -// 13-bit unused, must be zero -// -// Entry path name (variable length) relative to top level directory -// (without leading slash). '/' is used as path separator. The special -// path components ".", ".." and ".git" (without quotes) are disallowed. -// Trailing slash is also disallowed. -// -// The exact encoding is undefined, but the '.' and '/' characters -// are encoded in 7-bit ASCII and the encoding cannot contain a NUL -// byte (iow, this is a UNIX pathname). -// -// (Version 4) In version 4, the entry path name is prefix-compressed -// relative to the path name for the previous entry (the very first -// entry is encoded as if the path name for the previous entry is an -// empty string). At the beginning of an entry, an integer N in the -// variable width encoding (the same encoding as the offset is encoded -// for OFS_DELTA pack entries; see linkgit:gitformat-pack[5]) is stored, followed -// by a NUL-terminated string S. Removing N bytes from the end of the -// path name for the previous entry, and replacing it with the string S -// yields the path name for this entry. -// -// 1-8 nul bytes as necessary to pad the entry to a multiple of eight bytes -// while keeping the name NUL-terminated. -// -// (Version 4) In version 4, the padding after the pathname does not -// exist. -// -// Interpretation of index entries in split index mode is completely -// different. See below for details. -// -// == Extensions -// -// === Cache tree -// -// Since the index does not record entries for directories, the cache -// entries cannot describe tree objects that already exist in the object -// database for regions of the index that are unchanged from an existing -// commit. The cache tree extension stores a recursive tree structure that -// describes the trees that already exist and completely match sections of -// the cache entries. This speeds up tree object generation from the index -// for a new commit by only computing the trees that are "new" to that -// commit. It also assists when comparing the index to another tree, such -// as `HEAD^{tree}`, since sections of the index can be skipped when a tree -// comparison demonstrates equality. -// -// The recursive tree structure uses nodes that store a number of cache -// entries, a list of subnodes, and an object ID (OID). The OID references -// the existing tree for that node, if it is known to exist. The subnodes -// correspond to subdirectories that themselves have cache tree nodes. The -// number of cache entries corresponds to the number of cache entries in -// the index that describe paths within that tree's directory. -// -// The extension tracks the full directory structure in the cache tree -// extension, but this is generally smaller than the full cache entry list. -// -// When a path is updated in index, Git invalidates all nodes of the -// recursive cache tree corresponding to the parent directories of that -// path. We store these tree nodes as being "invalid" by using "-1" as the -// number of cache entries. Invalid nodes still store a span of index -// entries, allowing Git to focus its efforts when reconstructing a full -// cache tree. -// -// The signature for this extension is { 'T', 'R', 'E', 'E' }. -// -// A series of entries fill the entire extension; each of which -// consists of: -// -// - NUL-terminated path component (relative to its parent directory); -// -// - ASCII decimal number of entries in the index that is covered by the -// tree this entry represents (entry_count); -// -// - A space (ASCII 32); -// -// - ASCII decimal number that represents the number of subtrees this -// tree has; -// -// - A newline (ASCII 10); and -// -// - Object name for the object that would result from writing this span -// of index as a tree. -// -// An entry can be in an invalidated state and is represented by having -// a negative number in the entry_count field. In this case, there is no -// object name and the next entry starts immediately after the newline. -// When writing an invalid entry, -1 should always be used as entry_count. -// -// The entries are written out in the top-down, depth-first order. The -// first entry represents the root level of the repository, followed by the -// first subtree--let's call this A--of the root level (with its name -// relative to the root level), followed by the first subtree of A (with -// its name relative to A), and so on. The specified number of subtrees -// indicates when the current level of the recursive stack is complete. -// -// === Resolve undo -// -// A conflict is represented in the index as a set of higher stage entries. -// When a conflict is resolved (e.g. with "git add path"), these higher -// stage entries will be removed and a stage-0 entry with proper resolution -// is added. -// -// When these higher stage entries are removed, they are saved in the -// resolve undo extension, so that conflicts can be recreated (e.g. with -// "git checkout -m"), in case users want to redo a conflict resolution -// from scratch. -// -// The signature for this extension is { 'R', 'E', 'U', 'C' }. -// -// A series of entries fill the entire extension; each of which -// consists of: -// -// - NUL-terminated pathname the entry describes (relative to the root of -// the repository, i.e. full pathname); -// -// - Three NUL-terminated ASCII octal numbers, entry mode of entries in -// stage 1 to 3 (a missing stage is represented by "0" in this field); -// and -// -// - At most three object names of the entry in stages from 1 to 3 -// (nothing is written for a missing stage). -// -// === Split index -// -// In split index mode, the majority of index entries could be stored -// in a separate file. This extension records the changes to be made on -// top of that to produce the final index. -// -// The signature for this extension is { 'l', 'i', 'n', 'k' }. -// -// The extension consists of: -// -// - Hash of the shared index file. The shared index file path -// is $GIT_DIR/sharedindex.. If all bits are zero, the -// index does not require a shared index file. -// -// - An ewah-encoded delete bitmap, each bit represents an entry in the -// shared index. If a bit is set, its corresponding entry in the -// shared index will be removed from the final index. Note, because -// a delete operation changes index entry positions, but we do need -// original positions in replace phase, it's best to just mark -// entries for removal, then do a mass deletion after replacement. -// -// - An ewah-encoded replace bitmap, each bit represents an entry in -// the shared index. If a bit is set, its corresponding entry in the -// shared index will be replaced with an entry in this index -// file. All replaced entries are stored in sorted order in this -// index. The first "1" bit in the replace bitmap corresponds to the -// first index entry, the second "1" bit to the second entry and so -// on. Replaced entries may have empty path names to save space. -// -// The remaining index entries after replaced ones will be added to the -// final index. These added entries are also sorted by entry name then -// stage. -// -// == Untracked cache -// -// Untracked cache saves the untracked file list and necessary data to -// verify the cache. The signature for this extension is { 'U', 'N', -// 'T', 'R' }. -// -// The extension starts with -// -// - A sequence of NUL-terminated strings, preceded by the size of the -// sequence in variable width encoding. Each string describes the -// environment where the cache can be used. -// -// - Stat data of $GIT_DIR/info/exclude. See "Index entry" section from -// ctime field until "file size". -// -// - Stat data of core.excludesFile -// -// - 32-bit dir_flags (see struct dir_struct) -// -// - Hash of $GIT_DIR/info/exclude. A null hash means the file -// does not exist. -// -// - Hash of core.excludesFile. A null hash means the file does -// not exist. -// -// - NUL-terminated string of per-dir exclude file name. This usually -// is ".gitignore". -// -// - The number of following directory blocks, variable width -// encoding. If this number is zero, the extension ends here with a -// following NUL. -// -// - A number of directory blocks in depth-first-search order, each -// consists of -// -// - The number of untracked entries, variable width encoding. -// -// - The number of sub-directory blocks, variable width encoding. -// -// - The directory name terminated by NUL. -// -// - A number of untracked file/dir names terminated by NUL. -// -// The remaining data of each directory block is grouped by type: -// -// - An ewah bitmap, the n-th bit marks whether the n-th directory has -// valid untracked cache entries. -// -// - An ewah bitmap, the n-th bit records "check-only" bit of -// read_directory_recursive() for the n-th directory. -// -// - An ewah bitmap, the n-th bit indicates whether hash and stat data -// is valid for the n-th directory and exists in the next data. -// -// - An array of stat data. The n-th data corresponds with the n-th -// "one" bit in the previous ewah bitmap. -// -// - An array of hashes. The n-th hash corresponds with the n-th "one" bit -// in the previous ewah bitmap. -// -// - One NUL. -// -// == File System Monitor cache -// -// The file system monitor cache tracks files for which the core.fsmonitor -// hook has told us about changes. The signature for this extension is -// { 'F', 'S', 'M', 'N' }. -// -// The extension starts with -// -// - 32-bit version number: the current supported versions are 1 and 2. -// -// - (Version 1) -// 64-bit time: the extension data reflects all changes through the given -// time which is stored as the nanoseconds elapsed since midnight, -// January 1, 1970. -// -// - (Version 2) -// A null terminated string: an opaque token defined by the file system -// monitor application. The extension data reflects all changes relative -// to that token. -// -// - 32-bit bitmap size: the size of the CE_FSMONITOR_VALID bitmap. -// -// - An ewah bitmap, the n-th bit indicates whether the n-th index entry -// is not CE_FSMONITOR_VALID. -// -// == End of Index Entry -// -// The End of Index Entry (EOIE) is used to locate the end of the variable -// length index entries and the beginning of the extensions. Code can take -// advantage of this to quickly locate the index extensions without having -// to parse through all of the index entries. -// -// Because it must be able to be loaded before the variable length cache -// entries and other index extensions, this extension must be written last. -// The signature for this extension is { 'E', 'O', 'I', 'E' }. -// -// The extension consists of: -// -// - 32-bit offset to the end of the index entries -// -// - Hash over the extension types and their sizes (but not -// their contents). E.g. if we have "TREE" extension that is N-bytes -// long, "REUC" extension that is M-bytes long, followed by "EOIE", -// then the hash would be: -// -// Hash("TREE" + + -// "REUC" + ) -// -// == Index Entry Offset Table -// -// The Index Entry Offset Table (IEOT) is used to help address the CPU -// cost of loading the index by enabling multi-threading the process of -// converting cache entries from the on-disk format to the in-memory format. -// The signature for this extension is { 'I', 'E', 'O', 'T' }. -// -// The extension consists of: -// -// - 32-bit version (currently 1) -// -// - A number of index offset entries each consisting of: -// -// - 32-bit offset from the beginning of the file to the first cache entry -// in this block of entries. -// -// - 32-bit count of cache entries in this block -// -// == Sparse Directory Entries -// -// When using sparse-checkout in cone mode, some entire directories within -// the index can be summarized by pointing to a tree object instead of the -// entire expanded list of paths within that tree. An index containing such -// entries is a "sparse index". Index format versions 4 and less were not -// implemented with such entries in mind. Thus, for these versions, an -// index containing sparse directory entries will include this extension -// with signature { 's', 'd', 'i', 'r' }. Like the split-index extension, -// tools should avoid interacting with a sparse index unless they understand -// this extension. -// -// Source: https://github.com/git/git/blob/master/Documentation/gitformat-index.adoc +// Package index implements encoding and decoding of the Git index file, +// also known as the staging area or directory cache. +// +// A [Decoder] reads index versions 2, 3 and 4. Besides the entries +// themselves, it decodes the cache tree, resolve undo and end-of-index-entry +// extensions into [Tree], [ResolveUndo] and [EndOfIndexEntry]; other +// optional extensions are skipped, and an unknown mandatory extension is an +// error. An [Encoder] writes the entries in versions 2, 3 and 4, without +// extensions. +// +// The on-disk layout is specified in gitformat-index(5): +// https://git-scm.com/docs/gitformat-index package index diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/format/objfile/reader.go b/vendor/github.com/go-git/go-git/v6/plumbing/format/objfile/reader.go index 4c4280d420..a1c76f4ae0 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/format/objfile/reader.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/format/objfile/reader.go @@ -5,10 +5,10 @@ import ( "io" "strconv" + "github.com/go-git/go-git/v6/internal/sync" "github.com/go-git/go-git/v6/plumbing" format "github.com/go-git/go-git/v6/plumbing/format/config" "github.com/go-git/go-git/v6/plumbing/format/packfile" - "github.com/go-git/go-git/v6/utils/sync" ) // Errors returned by the objfile package. diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/format/objfile/writer.go b/vendor/github.com/go-git/go-git/v6/plumbing/format/objfile/writer.go index accaff8282..c28a51c3f4 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/format/objfile/writer.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/format/objfile/writer.go @@ -5,9 +5,9 @@ import ( "io" "strconv" + "github.com/go-git/go-git/v6/internal/sync" "github.com/go-git/go-git/v6/plumbing" format "github.com/go-git/go-git/v6/plumbing/format/config" - "github.com/go-git/go-git/v6/utils/sync" ) // ErrOverflow is returned when the declared data length is exceeded. diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/format/packfile/common.go b/vendor/github.com/go-git/go-git/v6/plumbing/format/packfile/common.go index 3b88a1776e..6d820ed653 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/format/packfile/common.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/format/packfile/common.go @@ -27,7 +27,14 @@ const ( ) // UpdateObjectStorage updates the storer with the objects in the given -// packfile. +// packfile. If s implements [storer.PackfileWriter], the packfile is written +// with [WritePackfileToObjectStorage]; otherwise it is parsed into s. +// +// UpdateObjectStorage may return before packfile reaches EOF, and may also +// read and discard data that follows the pack trailer, so packfile is left at +// no particular position. A caller that reads on must use a reader that keeps +// its own framing, such as a sideband demuxer, rather than rely on the bytes +// after the pack still being there. func UpdateObjectStorage(s storer.Storer, packfile io.Reader) error { if trace.Performance.Enabled() { start := time.Now() @@ -85,6 +92,10 @@ func SupportsPromisorPacks(s storer.Storer) bool { // ErrPromisorPacksUnsupported rather than silently producing the corruption this // marking exists to prevent. Storage that writes no packfiles at all stores the // objects individually, where there is no marking to lose. +// +// Like UpdateObjectStorage, UpdatePromisorObjectStorage may return before +// packfile reaches EOF, and may read and discard data that follows the pack +// trailer. func UpdatePromisorObjectStorage(s storer.Storer, packfile io.Reader, marker string) error { if trace.Performance.Enabled() { start := time.Now() @@ -110,7 +121,11 @@ func UpdatePromisorObjectStorage(s storer.Storer, packfile io.Reader, marker str } // WritePackfileToObjectStorage writes all the packfile objects into the given -// object storage. +// object storage. If the writer returned by sw implements +// [storer.PackReader], its ReadPack is called with packfile, which may stop +// at the pack trailer or read and discard bytes past it, so packfile is left +// at no particular position. Otherwise packfile is copied to the writer until +// EOF. func WritePackfileToObjectStorage( sw storer.PackfileWriter, packfile io.Reader, @@ -126,7 +141,12 @@ func WritePackfileToObjectStorage( func copyPackfile(w io.WriteCloser, packfile io.Reader) (err error) { defer ioutil.CheckClose(w, &err) - n, err := ioutil.CopyBufferPool(w, packfile) + var n int64 + if pr, ok := w.(storer.PackReader); ok { + n, err = pr.ReadPack(packfile) + } else { + n, err = ioutil.CopyBufferPool(w, packfile) + } if err == nil && n == 0 { return ErrEmptyPackfile } @@ -140,11 +160,8 @@ func copyPackfile(w io.WriteCloser, packfile io.Reader) (err error) { // 12-byte pack header) and strictly less than deltaOffset, since an // OFS-delta can only reference an earlier entry in the same pack. // -// Mirrors canonical Git's predicate in packfile.c[1]: -// -// base_offset = delta_obj_offset - base_offset; -// if (base_offset <= 0 || base_offset >= delta_obj_offset) -// return 0; /* out of bound */ +// Git applies the same bounds when it resolves the base of an OFS-delta in +// packfile.c[1], and treats a base outside them as out of bound. // // Returns a wrapped ErrMalformedPackfile when the bounds are violated; // returns nil otherwise. diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/format/packfile/diff_delta.go b/vendor/github.com/go-git/go-git/v6/plumbing/format/packfile/diff_delta.go index 96472b7199..4c1af6be91 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/format/packfile/diff_delta.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/format/packfile/diff_delta.go @@ -3,10 +3,10 @@ package packfile import ( "bytes" + "github.com/go-git/go-git/v6/internal/sync" "github.com/go-git/go-git/v6/plumbing" packutil "github.com/go-git/go-git/v6/plumbing/format/packfile/util" "github.com/go-git/go-git/v6/utils/ioutil" - "github.com/go-git/go-git/v6/utils/sync" ) // See https://github.com/jelmer/dulwich/blob/master/dulwich/pack.py and diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/format/packfile/doc.go b/vendor/github.com/go-git/go-git/v6/plumbing/format/packfile/doc.go index bd96a65971..73af59955d 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/format/packfile/doc.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/format/packfile/doc.go @@ -1,38 +1,13 @@ -// Package packfile implements encoding and decoding of packfile format. -// -// == pack-*.pack files have the following format: -// -// - A header appears at the beginning and consists of the following: -// -// 4-byte signature: -// The signature is: {'P', 'A', 'C', 'K'} -// -// 4-byte version number (network byte order): -// GIT currently accepts version number 2 or 3 but -// generates version 2 only. -// -// 4-byte number of objects contained in the pack (network byte order) -// -// Observation: we cannot have more than 4G versions ;-) and -// more than 4G objects in a pack. -// -// - The header is followed by number of object entries, each of -// which looks like this: -// -// (undeltified representation) -// n-byte type and length (3-bit type, (n-1)*7+4-bit length) -// compressed data -// -// (deltified representation) -// n-byte type and length (3-bit type, (n-1)*7+4-bit length) -// 20-byte base object name -// compressed delta data -// -// Observation: length of each object is encoded in a variable -// length format and is not constrained to 32-bit or anything. -// -// - The trailer records 20-byte SHA1 checksum of all of the above. -// -// Source: -// https://www.kernel.org/pub/software/scm/git/docs/v1.7.5/technical/pack-protocol.txt +// Package packfile implements encoding and decoding of packfiles +// (pack-*.pack), the format Git uses to store and transfer objects. +// +// A packfile holds a sequence of objects, each stored either whole or as a +// delta against another object. [Scanner] and [Parser] read a pack as a +// stream, [Packfile] gives random access to an indexed pack, and [Encoder] +// writes one, optionally choosing deltas through [DeltaSelector]. Only +// version 2 of the format is supported, with either SHA-1 or SHA-256 +// object ids. +// +// The on-disk layout is specified in gitformat-pack(5): +// https://git-scm.com/docs/gitformat-pack package packfile diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/format/packfile/encoder.go b/vendor/github.com/go-git/go-git/v6/plumbing/format/packfile/encoder.go index 8edada711a..ab580b7cc9 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/format/packfile/encoder.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/format/packfile/encoder.go @@ -7,13 +7,13 @@ import ( "io" "github.com/go-git/go-git/v6/config" + "github.com/go-git/go-git/v6/internal/sync" "github.com/go-git/go-git/v6/plumbing" cfgformat "github.com/go-git/go-git/v6/plumbing/format/config" "github.com/go-git/go-git/v6/plumbing/hash" "github.com/go-git/go-git/v6/plumbing/storer" "github.com/go-git/go-git/v6/utils/binary" "github.com/go-git/go-git/v6/utils/ioutil" - "github.com/go-git/go-git/v6/utils/sync" ) // ObjectSelector decides which objects go into a pack and in what diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/format/packfile/fsobject.go b/vendor/github.com/go-git/go-git/v6/plumbing/format/packfile/fsobject.go index 7181315812..8a5a9b31ba 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/format/packfile/fsobject.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/format/packfile/fsobject.go @@ -10,11 +10,11 @@ import ( billy "github.com/go-git/go-billy/v6" + "github.com/go-git/go-git/v6/internal/sync" "github.com/go-git/go-git/v6/plumbing" "github.com/go-git/go-git/v6/plumbing/cache" "github.com/go-git/go-git/v6/plumbing/format/idxfile" "github.com/go-git/go-git/v6/utils/ioutil" - "github.com/go-git/go-git/v6/utils/sync" ) // probeSize is the byte count for the closed-FD probe. A one-byte diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/format/packfile/packfile.go b/vendor/github.com/go-git/go-git/v6/plumbing/format/packfile/packfile.go index 5570b92efa..7eeafca1b2 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/format/packfile/packfile.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/format/packfile/packfile.go @@ -3,6 +3,7 @@ package packfile import ( "bufio" "crypto" + "errors" "fmt" "io" "io/fs" @@ -11,13 +12,13 @@ import ( billy "github.com/go-git/go-billy/v6" + gogitsync "github.com/go-git/go-git/v6/internal/sync" "github.com/go-git/go-git/v6/plumbing" "github.com/go-git/go-git/v6/plumbing/cache" format "github.com/go-git/go-git/v6/plumbing/format/config" "github.com/go-git/go-git/v6/plumbing/format/idxfile" "github.com/go-git/go-git/v6/plumbing/storer" "github.com/go-git/go-git/v6/utils/ioutil" - gogitsync "github.com/go-git/go-git/v6/utils/sync" ) var ( @@ -124,6 +125,64 @@ func (p *Packfile) GetByOffset(offset int64) (plumbing.EncodedObject, error) { return p.getByOffset(offset) } +// ExternalBaseError is returned by [Packfile.GetTypeByOffset] when a delta +// chain ends at a REF_DELTA base that is not in the packfile, as in a thin +// pack. The object's type is that of Base, which the caller can look up +// elsewhere. +type ExternalBaseError struct { + // Base is the hash of the base object. + Base plumbing.Hash +} + +func (e *ExternalBaseError) Error() string { + return fmt.Sprintf("delta base %s is not in the packfile", e.Base) +} + +// GetTypeByOffset returns the type of the object at offset. A delta's type +// is its base's, found by following the chain of bases through their headers +// alone, so no object is inflated. A REF_DELTA base that is not in this +// packfile returns an [*ExternalBaseError] naming it. +func (p *Packfile) GetTypeByOffset(offset int64) (plumbing.ObjectType, error) { + if p.closed.Load() { + return plumbing.InvalidObject, fs.ErrClosed + } + if err := p.init(); err != nil { + return plumbing.InvalidObject, err + } + p.m.Lock() + defer p.m.Unlock() + // Re-check after Lock: Close may have flipped closed and torn + // down the scanner between the early Load and the Lock. + if p.closed.Load() { + return plumbing.InvalidObject, fs.ErrClosed + } + + for range maxDeltaChainDepth + 1 { + oh, err := p.scanner.objectHeaderAt(offset) + if err != nil { + return plumbing.InvalidObject, err + } + switch oh.Type { + case plumbing.OFSDeltaObject: + offset = oh.OffsetReference + case plumbing.REFDeltaObject: + if obj, ok := p.cache.Get(oh.Reference); ok { + return obj.Type(), nil + } + offset, err = p.FindOffset(oh.Reference) + if errors.Is(err, plumbing.ErrObjectNotFound) { + return plumbing.InvalidObject, &ExternalBaseError{Base: oh.Reference} + } + if err != nil { + return plumbing.InvalidObject, err + } + default: + return oh.Type, nil + } + } + return plumbing.InvalidObject, fmt.Errorf("%w: delta chain depth exceeds %d", ErrMalformedPackfile, maxDeltaChainDepth) +} + // GetSizeByOffset retrieves the size of the encoded object from the // packfile with the given offset. func (p *Packfile) GetSizeByOffset(offset int64) (size int64, err error) { diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/format/packfile/parser.go b/vendor/github.com/go-git/go-git/v6/plumbing/format/packfile/parser.go index c9533f6252..b63848e7cc 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/format/packfile/parser.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/format/packfile/parser.go @@ -6,12 +6,13 @@ import ( "fmt" "io" stdsync "sync" + "sync/atomic" + "github.com/go-git/go-git/v6/internal/sync" "github.com/go-git/go-git/v6/plumbing" format "github.com/go-git/go-git/v6/plumbing/format/config" "github.com/go-git/go-git/v6/plumbing/storer" "github.com/go-git/go-git/v6/utils/ioutil" - "github.com/go-git/go-git/v6/utils/sync" ) var ( @@ -78,6 +79,7 @@ type Parser struct { objectFormat format.ObjectFormat checksum plumbing.Hash + size atomic.Int64 m stdsync.Mutex parsed bool } @@ -215,14 +217,11 @@ func (p *Parser) Parse() (plumbing.Hash, error) { case FooterSection: p.checksum = data.Value().(plumbing.Hash) + p.size.Store(p.scanner.packSize) } } - err := p.scanner.Error() - if err != nil { - if errors.Is(err, io.EOF) && p.scanner.objects == 0 { - return plumbing.ZeroHash, ErrEmptyPackfile - } + if err := p.scanner.Error(); err != nil { return plumbing.ZeroHash, err } @@ -243,6 +242,14 @@ func (p *Parser) Parse() (plumbing.Hash, error) { return p.checksum, p.onFooter(p.checksum) } +// Size returns the length in bytes of the pack read by Parse, from its +// signature through its trailing checksum. Data after the checksum is not +// counted. Size returns 0 until Parse has read the checksum. It is safe to +// call concurrently with Parse, including from an [Observer]. +func (p *Parser) Size() int64 { + return p.size.Load() +} + func (p *Parser) ensureContent(oh *ObjectHeader) error { // Skip if this object already has the correct content. if oh.content != nil && oh.content.Len() == int(oh.Size) && !oh.Hash.IsZero() { @@ -297,10 +304,14 @@ func (p *Parser) ensureContent(oh *ObjectHeader) error { // // Any REF-delta not reached through the depth-first walk has a base // outside this pack and is processed via the external-reference -// placeholder path. An OFS-delta whose recorded negative offset does -// not match any in-pack object header is rejected as malformed input. +// placeholder path, after which the walk continues into its own delta +// children, as canonical Git's fix_unresolved_deltas[2] does once it +// has read the missing base. An OFS-delta whose recorded negative +// offset does not match any in-pack object header is rejected as +// malformed input. // // [1]: https://github.com/git/git/blob/v2.54.0/builtin/index-pack.c#L1103 +// [2]: https://github.com/git/git/blob/v2.54.0/builtin/index-pack.c#L1475 func (p *Parser) resolveDeltas(ofsDeltas, refDeltas []*ObjectHeader) error { // Map sizes correspond to the count of distinct parent offsets / // hashes, not the count of delta entries. Real packs cluster many @@ -369,6 +380,9 @@ func (p *Parser) resolveDeltas(ofsDeltas, refDeltas []*ObjectHeader) error { if err := p.processDelta(d); err != nil { return fmt.Errorf("processing ref-delta at offset %v: %w", d.Offset, err) } + if err := visit(d); err != nil { + return err + } } for _, d := range ofsDeltas { diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/format/packfile/patch_delta.go b/vendor/github.com/go-git/go-git/v6/plumbing/format/packfile/patch_delta.go index df7a8c8e78..fde8b682b2 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/format/packfile/patch_delta.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/format/packfile/patch_delta.go @@ -8,11 +8,11 @@ import ( "io" "math" + "github.com/go-git/go-git/v6/internal/sync" "github.com/go-git/go-git/v6/plumbing" format "github.com/go-git/go-git/v6/plumbing/format/config" packutil "github.com/go-git/go-git/v6/plumbing/format/packfile/util" "github.com/go-git/go-git/v6/utils/ioutil" - "github.com/go-git/go-git/v6/utils/sync" ) // See https://github.com/git/git/blob/49fa3dc76179e04b0833542fa52d0f287a4955ac/delta.h @@ -273,8 +273,8 @@ func ReaderFromDelta(base plumbing.EncodedObject, deltaRC io.Reader) (io.ReadClo } } - // Mirror upstream's `data != top` post-loop check: every byte - // of the delta payload must be consumed. + // As upstream does once its loop ends, check that every byte + // of the delta payload was consumed. if _, err := deltaBuf.ReadByte(); err == nil { _ = dstWr.CloseWithError(ErrInvalidDelta) return @@ -392,8 +392,8 @@ func validateDeltaOps(delta []byte, srcSz, targetSz uint) error { } } - // Mirror upstream's `data != top` post-loop check: every byte of - // the delta payload must be consumed. + // As upstream does once its loop ends, check that every byte of + // the delta payload was consumed. if len(delta) != 0 { return ErrInvalidDelta } @@ -473,8 +473,8 @@ func patchDelta(dst *bytes.Buffer, src, delta []byte) error { } } - // Mirror upstream's `data != top` post-loop check: every byte of - // the delta payload must be consumed. + // As upstream does once its loop ends, check that every byte of + // the delta payload was consumed. if len(delta) != 0 { return ErrInvalidDelta } @@ -596,8 +596,8 @@ func patchDeltaWriter(dst io.Writer, base io.ReaderAt, baseSz int64, delta []byt } } - // Mirror upstream's `data != top` post-loop check: every byte of - // the delta payload must be consumed. + // As upstream does once its loop ends, check that every byte of + // the delta payload was consumed. if _, err := deltaBuf.ReadByte(); err == nil { return 0, plumbing.ZeroHash, ErrInvalidDelta } else if err != io.EOF { diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/format/packfile/scanner.go b/vendor/github.com/go-git/go-git/v6/plumbing/format/packfile/scanner.go index ece4f24afc..f2e13f0195 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/format/packfile/scanner.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/format/packfile/scanner.go @@ -12,6 +12,7 @@ import ( "io" "sync" + gogitsync "github.com/go-git/go-git/v6/internal/sync" "github.com/go-git/go-git/v6/plumbing" format "github.com/go-git/go-git/v6/plumbing/format/config" packutil "github.com/go-git/go-git/v6/plumbing/format/packfile/util" @@ -19,18 +20,18 @@ import ( "github.com/go-git/go-git/v6/plumbing/storer" "github.com/go-git/go-git/v6/utils/binary" "github.com/go-git/go-git/v6/utils/ioutil" - gogitsync "github.com/go-git/go-git/v6/utils/sync" ) var ( - // ErrEmptyPackfile is returned by ReadHeader when no data is found in the packfile. + // ErrEmptyPackfile is returned when the packfile holds no data. ErrEmptyPackfile = NewError("empty packfile") - // ErrBadSignature is returned by ReadHeader when the signature in the packfile is incorrect. + // ErrBadSignature is returned when the packfile does not start with the + // pack signature, including when it is too short to hold one. ErrBadSignature = NewError("bad signature") // ErrMalformedPackfile is returned when the packfile format is incorrect. ErrMalformedPackfile = NewError("malformed pack file") - // ErrUnsupportedVersion is returned by ReadHeader when the packfile version is - // different than VersionSupported. + // ErrUnsupportedVersion is returned when the packfile version is not + // VersionSupported. ErrUnsupportedVersion = NewError("unsupported packfile version") // ErrSeekNotSupported returned if seek is not support. ErrSeekNotSupported = NewError("not seek support") @@ -39,6 +40,13 @@ var ( // packfile never produces more data than the declared size; exceeding it // indicates a structurally invalid entry. ErrInflatedSizeMismatch = errors.New("packfile: inflated object exceeds declared size") + // ErrInflatedSizeShort is the converse: the object inflated to fewer + // bytes than its header declared. Canonical Git enforces the same + // equality when it unpacks an entry: the stream has to end exactly at + // the declared size. The + // declared size is what the object id is computed over, so a short + // stream would otherwise be indexed under an id that does not hash it. + ErrInflatedSizeShort = errors.New("inflated object size mismatch") ) // boundedWriter passes writes through to w up to limit bytes total, then @@ -168,6 +176,8 @@ type Scanner struct { packhash gogithash.Hash // objectIdSize holds the object ID size. objectIDSize int + // packSize holds the size of the pack, set once its checksum is read. + packSize int64 // next holds what state function should be executed on the next // call to Scan(). @@ -267,6 +277,7 @@ func (r *Scanner) Reset() error { r.objIndex = -1 r.version = 0 r.objects = 0 + r.packSize = 0 r.packData = PackData{} r.err = nil r.nextFn = packHeaderSignature @@ -332,14 +343,23 @@ func (r *Scanner) inflateContent(contentOffset int64, writer io.Writer, declared return err } - zr, err := gogitsync.GetZlibReader(r.scannerReader) + // See objectEntry for why zlib reads rbuf directly. + zr, err := gogitsync.GetZlibReader(r.scannerReader.rbuf) if err != nil { return fmt.Errorf("zlib reset error: %w", err) } defer gogitsync.PutZlibReader(zr) - _, err = ioutil.CopyBufferPool(bounded, zr) - return err + n, err := ioutil.CopyBufferPool(bounded, zr) + if err != nil { + return err + } + if n != declaredSize { + return ErrInflatedSizeShort + } + // zlib read rbuf directly, so offset only catches up on a flush. A Scan + // that follows reads offset before it flushes. + return r.Flush() } // scan goes through the next stateFn. @@ -369,11 +389,12 @@ type stateFn func(*Scanner) (stateFn, error) // that handles the entire packfile header. func packHeaderSignature(r *Scanner) (stateFn, error) { start := make([]byte, 4) - n, err := r.Read(start) - if err != nil { - if n == 0 && err == io.EOF { - return nil, ErrEmptyPackfile - } + // Input too short to hold a signature falls through to ErrBadSignature. + _, err := io.ReadFull(r, start) + if err == io.EOF { + return nil, ErrEmptyPackfile + } + if err != nil && err != io.ErrUnexpectedEOF { return nil, fmt.Errorf("read signature: %w", err) } @@ -425,43 +446,27 @@ func packObjectsQty(r *Scanner) (stateFn, error) { return nil, nil } -// objectEntry handles the object entries within a packfile. This is generally -// split between object headers and their contents. -// -// The object header contains the object type and size. If the type cannot be parsed, -// [ErrMalformedPackfile] is returned. -// -// When SHA256 is enabled, the scanner will also calculate the SHA256 for each object. -func objectEntry(r *Scanner) (stateFn, error) { - if r.objIndex+1 >= int(r.objects) { - return packFooter, nil - } - r.objIndex++ - - offset := r.offset - - if err := r.Flush(); err != nil { - return nil, err - } - r.crc.Reset() - +// readObjectHeader reads the header of the object entry at offset, the +// reader's current position: its type, size and, for a delta, its base. It +// leaves the reader at the start of the entry's compressed content. +func (r *Scanner) readObjectHeader(offset int64) (ObjectHeader, error) { b := []byte{0} _, err := r.Read(b) if err != nil { - return nil, err + return ObjectHeader{}, err } typ := packutil.ObjectType(b[0]) if !typ.Valid() { - return nil, fmt.Errorf("%w: invalid object type: %v", ErrMalformedPackfile, b[0]) + return ObjectHeader{}, fmt.Errorf("%w: invalid object type: %v", ErrMalformedPackfile, b[0]) } size, err := packutil.VariableLengthSize(b[0], r) if err != nil { if errors.Is(err, packutil.ErrLengthOverflow) { - return nil, fmt.Errorf("%w: %w", ErrMalformedPackfile, err) + return ObjectHeader{}, fmt.Errorf("%w: %w", ErrMalformedPackfile, err) } - return nil, err + return ObjectHeader{}, err } oh := ObjectHeader{ @@ -479,24 +484,71 @@ func objectEntry(r *Scanner) (stateFn, error) { if oh.Type == plumbing.OFSDeltaObject { no, err := binary.ReadVariableWidthInt(r.scannerReader) if err != nil { - return nil, err + return ObjectHeader{}, err } if err := ValidateOFSDeltaBase(oh.Offset, no); err != nil { - return nil, err + return ObjectHeader{}, err } oh.OffsetReference = oh.Offset - no } else { oh.Reference.ResetBySize(r.objectIDSize) _, err := oh.Reference.ReadFrom(r.scannerReader) if err != nil { - return nil, err + return ObjectHeader{}, err } } } + return oh, nil +} + +// objectHeaderAt reads the header of the object entry at offset without +// reading its content, so the content is neither inflated nor hashed. The +// header's Hash, ContentOffset and Crc32 are not set. +func (r *Scanner) objectHeaderAt(offset int64) (ObjectHeader, error) { + if err := r.SeekFromStart(offset); err != nil { + return ObjectHeader{}, err + } + if err := r.Flush(); err != nil { + return ObjectHeader{}, err + } + return r.readObjectHeader(offset) +} + +// objectEntry handles the object entries within a packfile. This is generally +// split between object headers and their contents. +// +// The object header contains the object type and size. If the type cannot be parsed, +// [ErrMalformedPackfile] is returned. +// +// When SHA256 is enabled, the scanner will also calculate the SHA256 for each object. +func objectEntry(r *Scanner) (stateFn, error) { + if r.objIndex+1 >= int(r.objects) { + return packFooter, nil + } + r.objIndex++ + + offset := r.offset + + if err := r.Flush(); err != nil { + return nil, err + } + r.crc.Reset() + + oh, err := r.readObjectHeader(offset) + if err != nil { + return nil, err + } + oh.ContentOffset = r.offset - zr, err := gogitsync.GetZlibReader(r.scannerReader) + // zlib must read the *bufio.Reader itself, not scannerReader. flate + // decodes a *bufio.Reader without an interface call per byte, and + // klauspost/compress/flate only uses its specialised decoder for such + // concrete types. scannerReader still sees every consumed byte, because + // it captures them as they enter rbuf. Passing scannerReader here made + // BenchmarkScannerBasic about 15% slower. + zr, err := gogitsync.GetZlibReader(r.scannerReader.rbuf) if err != nil { return nil, fmt.Errorf("zlib reset error: %w", err) } @@ -532,10 +584,13 @@ func objectEntry(r *Scanner) (stateFn, error) { // the resolved object. mw = &boundedWriter{w: mw, limit: oh.Size} - _, err = ioutil.CopyBufferPool(mw, zr) + n, err := ioutil.CopyBufferPool(mw, zr) if err != nil { return nil, err } + if n != oh.Size { + return nil, fmt.Errorf("%w: %w", ErrMalformedPackfile, ErrInflatedSizeShort) + } if err := r.Flush(); err != nil { return nil, err @@ -577,6 +632,7 @@ func packFooter(r *Scanner) (stateFn, error) { r.packData.Section = FooterSection r.packData.checksum = checksum + r.packSize = r.offset r.nextFn = nil return nil, nil diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/format/packfile/scanner_reader.go b/vendor/github.com/go-git/go-git/v6/plumbing/format/packfile/scanner_reader.go index 2caca3e31c..559f7ae719 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/format/packfile/scanner_reader.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/format/packfile/scanner_reader.go @@ -10,22 +10,58 @@ import ( // reader supports it. // - Keeps track of the current read position, for when the underlying reader // isn't an io.SeekReader, but we still want to know the current offset. -// - Writes to the hash writer what it reads, with the aid of a smaller buffer. -// The buffer helps avoid a performance penalty for performing small writes -// to the crc32 hash writer. +// - Writes to the hash writer every byte that is consumed from rbuf, in +// stream order. // -// Note that this is passed on to zlib, and it must support io.BytesReader, else -// it won't be able to just read the content of the current object, but rather it -// will read the entire packfile. +// Bytes are captured as they enter rbuf, not as they leave it. That lets +// callers read from rbuf directly, which zlib needs to take the fast +// *bufio.Reader decode path. A byte that has entered rbuf is written to the +// hash writer only once it has been consumed, which is when the logical +// position (filled minus rbuf.Buffered) has moved past it. commit performs +// that write. It runs before every refill of rbuf and on Flush, so the hash +// writer always sees exactly the consumed bytes at object boundaries. // // scannerReader is not thread-safe. type scannerReader struct { reader io.Reader crc io.Writer rbuf *bufio.Reader - wbuf *bufio.Writer offset int64 seeker io.Seeker + + src teeSource + base int64 + filled int64 + committed int64 + // pending[head:] holds bytes that entered rbuf but are not hashed yet. + pending []byte + head int +} + +// teeSource sits between rbuf and the underlying reader. It records every +// byte handed to rbuf so commit can hash it once it has been consumed. +type teeSource struct { + sr *scannerReader +} + +func (t *teeSource) Read(p []byte) (int, error) { + sr := t.sr + if err := sr.commit(); err != nil { + return 0, err + } + // Every byte before head is hashed. A refill usually follows a fully + // consumed buffer, so the slide below moves few or no bytes. + if sr.head > 0 { + n := copy(sr.pending, sr.pending[sr.head:]) + sr.pending = sr.pending[:n] + sr.head = 0 + } + n, err := sr.reader.Read(p) + if n > 0 { + sr.pending = append(sr.pending, p[:n]...) + sr.filled += int64(n) + } + return n, err } func newScannerReader(r io.Reader, h io.Writer, rbuf *bufio.Reader) *scannerReader { @@ -35,19 +71,25 @@ func newScannerReader(r io.Reader, h io.Writer, rbuf *bufio.Reader) *scannerRead sr := &scannerReader{ rbuf: rbuf, - wbuf: bufio.NewWriterSize(nil, 64), crc: h, } + sr.src.sr = sr sr.Reset(r) return sr } +func (r *scannerReader) resetTracking() { + r.base = r.offset + r.filled = 0 + r.committed = 0 + r.pending = r.pending[:0] + r.head = 0 + r.rbuf.Reset(&r.src) +} + func (r *scannerReader) Reset(reader io.Reader) { r.reader = reader - r.rbuf.Reset(r.reader) - r.wbuf.Reset(r.crc) - r.offset = 0 seeker, ok := r.reader.(io.ReadSeeker) @@ -56,15 +98,30 @@ func (r *scannerReader) Reset(reader io.Reader) { if ok { r.offset, _ = seeker.Seek(0, io.SeekStart) } + r.resetTracking() +} + +// commit writes the consumed but not yet hashed bytes to the hash writer and +// brings offset up to date with reads that bypassed scannerReader. +func (r *scannerReader) commit() error { + consumed := r.filled - int64(r.rbuf.Buffered()) + r.offset = r.base + consumed + k := consumed - r.committed + if k <= 0 { + return nil + } + var err error + if r.crc != nil { + _, err = r.crc.Write(r.pending[r.head : r.head+int(k)]) + } + r.head += int(k) + r.committed = consumed + return err } func (r *scannerReader) Read(p []byte) (n int, err error) { n, err = r.rbuf.Read(p) - r.offset += int64(n) - if _, err := r.wbuf.Write(p[:n]); err != nil { - return n, err - } return n, err } @@ -72,19 +129,21 @@ func (r *scannerReader) ReadByte() (b byte, err error) { b, err = r.rbuf.ReadByte() if err == nil { r.offset++ - return b, r.wbuf.WriteByte(b) } return b, err } +// Flush hashes every byte consumed so far. func (r *scannerReader) Flush() error { - return r.wbuf.Flush() + return r.commit() } // Seek seeks to a location. If the underlying reader is not an io.ReadSeeker, // then only whence=io.SeekCurrent is supported, any other operation fails. func (r *scannerReader) Seek(offset int64, whence int) (int64, error) { - var err error + if err := r.commit(); err != nil { + return -1, err + } if r.seeker == nil { if whence != io.SeekCurrent || offset != 0 { @@ -96,8 +155,9 @@ func (r *scannerReader) Seek(offset int64, whence int) (int64, error) { return r.offset, nil } + var err error r.offset, err = r.seeker.Seek(offset, whence) - r.rbuf.Reset(r.reader) + r.resetTracking() return r.offset, err } diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/format/revfile/doc.go b/vendor/github.com/go-git/go-git/v6/plumbing/format/revfile/doc.go index 1f8e22eba8..775ea5c0e7 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/format/revfile/doc.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/format/revfile/doc.go @@ -1,21 +1,12 @@ -// Package revfile implements encoding and decoding logic of reverse -// index files (RIDX). +// Package revfile implements encoding and decoding of packfile reverse +// index (pack-*.rev) files. // -// This package is thread-safe. -// -// RIDX files are named "pack-*.rev" and have the format: -// - A 4-byte magic number '0x52494458' ('RIDX'). -// - A 4-byte version identifier (= 1). -// - A 4-byte hash function identifier (= 1 for SHA-1, 2 for SHA-256). -// - A table of index positions (one per packed object, num_objects in -// total, each a 4-byte unsigned integer in network order), sorted by -// their corresponding offsets in the packfile. -// - A trailer, containing a: -// checksum of the corresponding packfile, and -// a checksum of all of the above. +// A reverse index lists the objects of a pack in the order they are stored +// in it, which makes it cheap to go from a pack offset back to an object. +// Version 1 of the format is supported, for SHA-1 and SHA-256 packs. // -// All 4-byte numbers are in network order. +// This package is thread-safe. // -// Refer to: -// https://github.com/git/git/blob/master/Documentation/gitformat-pack.adoc +// The on-disk layout is specified in gitformat-pack(5): +// https://git-scm.com/docs/gitformat-pack package revfile diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/hash.go b/vendor/github.com/go-git/go-git/v6/plumbing/hash.go index c97bd0b987..dab1083674 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/hash.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/hash.go @@ -14,7 +14,10 @@ import ( // Hash SHA1 hashed content type Hash = ObjectID -// ZeroHash is an ObjectID with value zero. +// ZeroHash is the SHA-1 ObjectID with value zero. It equals the zero +// value of ObjectID. A SHA-256 zero id is not == ZeroHash. Use +// [ObjectID.IsZero] to test for a zero id of any format, and [ZeroID] +// to get the zero id of a given format. var ZeroHash ObjectID // NewHash return a new Hash based on a hexadecimal hash representation. @@ -22,7 +25,7 @@ var ZeroHash ObjectID // // deprecated: Use the new FromHex instead. func NewHash(s string) Hash { - h, _ := FromHex(s) + h, _ := fromHexLax(s) return h } diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/object/commit.go b/vendor/github.com/go-git/go-git/v6/plumbing/object/commit.go index 22b3e68db6..f7840deae4 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/object/commit.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/object/commit.go @@ -10,10 +10,10 @@ import ( "github.com/ProtonMail/go-crypto/openpgp" + "github.com/go-git/go-git/v6/internal/sync" "github.com/go-git/go-git/v6/plumbing" "github.com/go-git/go-git/v6/plumbing/storer" "github.com/go-git/go-git/v6/utils/ioutil" - "github.com/go-git/go-git/v6/utils/sync" ) const ( @@ -274,6 +274,8 @@ func (c *Commit) Decode(o plumbing.EncodedObject) (err error) { if !s.sawTree { return fmt.Errorf("%w: missing tree header", ErrMalformedCommit) } + c.Signature = s.sig.String() + c.SignatureSHA256 = s.sig256.String() c.Message = s.msgbuf.String() return nil } diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/object/commit_scanner.go b/vendor/github.com/go-git/go-git/v6/plumbing/object/commit_scanner.go index d33277e431..2dec8e555e 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/object/commit_scanner.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/object/commit_scanner.go @@ -36,8 +36,17 @@ type commitScanner struct { sawTree, sawAuthor, sawCommitter bool sawEncoding bool - // extra is the multi-line ExtraHeader currently being assembled. - extra *ExtraHeader + // sig and sig256 accumulate the gpgsig and gpgsig-sha256 values across + // lines and repeated headers. Appending to a string field instead would + // copy the whole value on every line, which is quadratic in the number + // of lines. (*Commit).Decode moves them into the Commit once scanning + // ends. + sig, sig256 strings.Builder + + // extra is the multi-line ExtraHeader currently being assembled, and + // extraValue accumulates its value for the same reason as sig. + extra *ExtraHeader + extraValue strings.Builder } // commitState is one step of the decoder state machine. Each function reads @@ -220,15 +229,18 @@ func scanHeaders(s *commitScanner) (commitState, error) { s.sawEncoding = true } case headerpgp: - s.c.Signature += string(data) + "\n" + s.sig.Write(data) + s.sig.WriteByte('\n') next = scanPgpCont case headerpgp256: - s.c.SignatureSHA256 += string(data) + "\n" + s.sig256.Write(data) + s.sig256.WriteByte('\n') next = scanPgp256Cont default: h, multiline := parseExtraHeader(originalLine) if multiline { s.extra = &h + s.extraValue.WriteString(h.Value) next = scanExtraCont } else { s.c.ExtraHeaders = append(s.c.ExtraHeaders, h) @@ -250,20 +262,20 @@ func scanHeaders(s *commitScanner) (commitState, error) { // (commit.c:1186). Mergetag continuations go through scanExtraCont // because mergetag is modelled as an entry in ExtraHeaders. func scanPgpCont(s *commitScanner) (commitState, error) { - return continuationCont(s, &s.c.Signature, scanPgpCont) + return continuationCont(s, &s.sig, scanPgpCont) } func scanPgp256Cont(s *commitScanner) (commitState, error) { - return continuationCont(s, &s.c.SignatureSHA256, scanPgp256Cont) + return continuationCont(s, &s.sig256, scanPgp256Cont) } -func continuationCont(s *commitScanner, dst *string, self commitState) (commitState, error) { +func continuationCont(s *commitScanner, dst *strings.Builder, self commitState) (commitState, error) { line, err := s.readLine() if err != nil && err != io.EOF { return nil, err } if len(line) > 0 && line[0] == ' ' { - *dst += string(line[1:]) + dst.Write(line[1:]) if err == io.EOF { return nil, nil } @@ -284,7 +296,7 @@ func scanExtraCont(s *commitScanner) (commitState, error) { return nil, err } if len(line) > 0 && line[0] == ' ' { - s.extra.Value += string(line[1:]) + s.extraValue.Write(line[1:]) if err == io.EOF { s.finaliseExtra() return nil, nil @@ -299,7 +311,8 @@ func scanExtraCont(s *commitScanner) (commitState, error) { } func (s *commitScanner) finaliseExtra() { - s.extra.Value = strings.TrimRight(s.extra.Value, "\n") + s.extra.Value = strings.TrimRight(s.extraValue.String(), "\n") + s.extraValue.Reset() s.c.ExtraHeaders = append(s.c.ExtraHeaders, *s.extra) s.extra = nil } diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/object/signature.go b/vendor/github.com/go-git/go-git/v6/plumbing/object/signature.go index 771eb62755..d296073d91 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/object/signature.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/object/signature.go @@ -4,9 +4,9 @@ import ( "bytes" "io" + "github.com/go-git/go-git/v6/internal/sync" "github.com/go-git/go-git/v6/plumbing" "github.com/go-git/go-git/v6/utils/ioutil" - "github.com/go-git/go-git/v6/utils/sync" ) const ( diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/object/tag.go b/vendor/github.com/go-git/go-git/v6/plumbing/object/tag.go index c25c7ac625..5a8c6376c2 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/object/tag.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/object/tag.go @@ -7,10 +7,10 @@ import ( "github.com/ProtonMail/go-crypto/openpgp" + "github.com/go-git/go-git/v6/internal/sync" "github.com/go-git/go-git/v6/plumbing" "github.com/go-git/go-git/v6/plumbing/storer" "github.com/go-git/go-git/v6/utils/ioutil" - "github.com/go-git/go-git/v6/utils/sync" ) // ErrMalformedTag is returned when a tag object cannot be decoded because @@ -120,6 +120,7 @@ func (t *Tag) Decode(o plumbing.EncodedObject) (err error) { } } + t.SignatureSHA256 = s.sig256.String() data := s.msgbuf.Bytes() if sm, _ := parseSignedBytes(data); sm >= 0 { t.Signature = string(data[sm:]) diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/object/tag_scanner.go b/vendor/github.com/go-git/go-git/v6/plumbing/object/tag_scanner.go index a263bd3f9a..b545bc8dbe 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/object/tag_scanner.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/object/tag_scanner.go @@ -5,6 +5,7 @@ import ( "bytes" "fmt" "io" + "strings" "github.com/go-git/go-git/v6/plumbing" ) @@ -34,6 +35,12 @@ type tagScanner struct { // parse_buffer_signed_by_header (commit.c:1186) accumulates every // occurrence into one signature buffer, so we do the same. sawObject, sawType, sawName, sawTagger bool + + // sig256 accumulates the gpgsig-sha256 value across lines and repeated + // headers. Appending to a string field instead would copy the whole + // value on every line, which is quadratic in the number of lines. + // (*Tag).Decode moves it into the Tag once scanning ends. + sig256 strings.Builder } // tagState is one step of the decoder state machine. Each function reads @@ -187,7 +194,8 @@ func scanTagHeaders(s *tagScanner) (tagState, error) { // Out-of-canonical-position duplicates are dropped, mirroring the // strict ordering of upstream's parse_tag_buffer. case headerpgp256: - s.t.SignatureSHA256 += string(data) + "\n" + s.sig256.Write(data) + s.sig256.WriteByte('\n') next = scanTagPgp256Cont default: // Unknown header — silently dropped (the Tag struct does not @@ -212,7 +220,7 @@ func scanTagPgp256Cont(s *tagScanner) (tagState, error) { return nil, err } if len(line) > 0 && line[0] == ' ' { - s.t.SignatureSHA256 += string(line[1:]) + s.sig256.Write(line[1:]) if err == io.EOF { return nil, nil } diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/object/tree.go b/vendor/github.com/go-git/go-git/v6/plumbing/object/tree.go index 77799ad4c3..d7c33b48c0 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/object/tree.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/object/tree.go @@ -6,17 +6,16 @@ import ( "errors" "fmt" "io" - "path" "path/filepath" "sort" "strings" "github.com/go-git/go-git/v6/internal/pathutil" + "github.com/go-git/go-git/v6/internal/sync" "github.com/go-git/go-git/v6/plumbing" "github.com/go-git/go-git/v6/plumbing/filemode" "github.com/go-git/go-git/v6/plumbing/storer" "github.com/go-git/go-git/v6/utils/ioutil" - "github.com/go-git/go-git/v6/utils/sync" ) const ( @@ -45,8 +44,14 @@ var ( // [1]: https://github.com/git/git/blob/v2.54.0/fsck.c#L26 const maxTreeEntryNameLen = 4096 -// Tree is basically like a directory - it references a bunch of other trees -// and/or blobs (i.e. files and sub-directories) +// Tree represents a Git tree, which contains entries for files and subtrees. +// +// Decode accepts some structurally invalid trees, including duplicate names +// and names containing slashes, but rejects malformed encoding and empty names. +// Validate checks structural constraints on this tree without loading subtrees. +// Read methods do not call Validate: FindEntry, TreeEntryFile, and TreeWalker.Next +// apply path checks, and FindEntry descends only through directory entries. +// Internal diff walkers can disable path validation. type Tree struct { Entries []TreeEntry Hash plumbing.Hash @@ -84,8 +89,12 @@ type TreeEntry struct { Hash plumbing.Hash } -// File returns the hash of the file identified by the `path` argument. -// The path is interpreted as relative to the tree receiver. +// File returns the file at path, relative to the tree. +// +// Errors from FindEntry are reported as ErrFileNotFound. Call FindEntry +// directly to distinguish invalid paths and unreadable subtrees from missing +// entries. A missing or wrong-type blob also reports ErrFileNotFound; +// other blob read errors are returned unchanged. func (t *Tree) File(path string) (*File, error) { e, err := t.FindEntry(path) if err != nil { @@ -103,8 +112,12 @@ func (t *Tree) File(path string) (*File, error) { return NewFile(path, e.Mode, blob), nil } -// Size returns the plaintext size of an object, without reading it -// into memory. +// Size returns the plaintext size of the object at path without reading it +// into memory. The path is relative to the tree. +// +// Errors from FindEntry are reported as ErrEntryNotFound. Call FindEntry +// directly to distinguish invalid paths and unreadable subtrees from missing +// entries. func (t *Tree) Size(path string) (int64, error) { e, err := t.FindEntry(path) if err != nil { @@ -114,8 +127,15 @@ func (t *Tree) Size(path string) (int64, error) { return t.s.EncodedObjectSize(e.Hash) } -// Tree returns the tree identified by the `path` argument. -// The path is interpreted as relative to the tree receiver. +// Tree returns the tree at path, relative to the receiver. +// Intermediate entries must have mode filemode.Dir. The final entry's object +// is read as a tree regardless of its mode, allowing inspection of entries +// whose mode does not match their object type. Callers materializing the tree +// must check that entry's mode themselves. +// +// Errors from FindEntry and plumbing.ErrObjectNotFound from the final object +// read are reported as ErrDirectoryNotFound. Other read and decode errors +// are returned unchanged. func (t *Tree) Tree(path string) (*Tree, error) { e, err := t.FindEntry(path) if err != nil { @@ -149,13 +169,27 @@ func (t *Tree) TreeEntryFile(e *TreeEntry) (*File, error) { return NewFile(e.Name, e.Mode, blob), nil } -// FindEntry search a TreeEntry in this tree or any subtree. +// FindEntry returns the entry at path, relative to the tree. +// The path is checked with pathutil.ValidTreePath, which rejects traversal +// and reserved names such as .git. Use Entries to inspect unvalidated names. +// +// Only entries with mode filemode.Dir can be traversed, even if a symlink or +// gitlink entry points to a tree object. The final entry is returned without +// reading its object; use its hash with GetTree to inspect a referenced tree. // -// The lookup path is validated against pathutil.ValidTreePath to -// prevent attacker-controlled tree contents from leaking past this -// boundary as `.git`-shaped or path-traversal-shaped names. Callers -// that legitimately need to look up unsafe paths should walk the -// tree manually. +// Duplicate names are not rejected, so lookup depends on their modes and order. +// Call Validate on each tree along the path to reject duplicates; validating +// only the root does not validate its subtrees. +// +// Use errors.Is to match errors. A missing final entry returns ErrEntryNotFound; +// a missing intermediate entry or one with a non-directory mode reports +// ErrDirectoryNotFound. An intermediate directory pointing to another object +// type reports ErrInvalidTree; an absent subtree reports plumbing.ErrObjectNotFound. +// Path-validation errors are returned unchanged. +// +// Subtree read and decode errors identify the entry and wrap the cause, except +// that causes matching io.EOF are included only as text to distinguish read +// failures from normal iterator exhaustion. func (t *Tree) FindEntry(path string) (*TreeEntry, error) { if err := pathutil.ValidTreePath(path); err != nil { return nil, err @@ -202,15 +236,15 @@ func (t *Tree) dir(baseName string) (*Tree, error) { return nil, ErrDirectoryNotFound } - obj, err := t.s.EncodedObject(plumbing.TreeObject, entry.Hash) - if err != nil { - return nil, err + // The entry mode determines whether a path can descend, even when the + // referenced object's type disagrees. Unlike Git's object peeling, the + // typed read below requires a tree object, not a commit or tag naming one. + // See https://github.com/git/git/blob/v2.54.0/tree-walk.c#L568-L633. + if entry.Mode != filemode.Dir { + return nil, fmt.Errorf("%w: entry %q has mode %s", ErrDirectoryNotFound, baseName, entry.Mode) } - tree := &Tree{s: t.s} - err = tree.Decode(obj) - - return tree, err + return readSubtree(t.s, entry) } func (t *Tree) entry(baseName string) (*TreeEntry, error) { @@ -253,7 +287,10 @@ func (t *Tree) searchEntryIndex(name string) int { }) } -// Files returns a FileIter allowing to iterate over the Tree +// Files returns an iterator over the files in the tree and its subtrees. +// Entry names may contain slashes in malformed trees. Call Validate on every +// traversed tree to require single-component entry names; validating only the +// root does not validate its subtrees. func (t *Tree) Files() *FileIter { return NewFileIter(t.s, t) } @@ -301,27 +338,14 @@ func (t *Tree) Decode(o plumbing.EncodedObject) (err error) { var prevSortName string for { - // Use ReadSlice to get a view into bufio's internal buffer, - // avoiding a string allocation for the mode (which is parsed - // into a uint32 immediately and doesn't need to persist). - modeSlice, err := r.ReadSlice(' ') - if err != nil { - if err == io.EOF { - if len(modeSlice) != 0 { - return fmt.Errorf("%w: missing mode terminator", ErrMalformedTree) - } - break - } - - return err + mode, err := readTreeEntryMode(r) + if err == io.EOF { + break } - modeSlice = modeSlice[:len(modeSlice)-1] // strip delimiter - - mode, err := filemode.FromBytes(modeSlice) if err != nil { - return fmt.Errorf("%w: malformed mode", ErrMalformedTree) + return err } - mode = canonicalTreeMode(mode) + mode = mode.Canonical() nameSlice, err := r.ReadSlice(0) if err == bufio.ErrBufferFull { @@ -393,19 +417,54 @@ func treeEntrySortName(e *TreeEntry) string { return e.Name } -func canonicalTreeMode(mode filemode.FileMode) filemode.FileMode { - switch mode & 0o170000 { - case 0o040000: - return filemode.Dir - case 0o100000: - if mode&0o111 != 0 { - return filemode.Executable +// readTreeEntryMode reads the mode of the next tree entry from r, +// consuming the space that ends it. It returns io.EOF when r holds no +// further entries. +// +// Git's parse_mode[1] accepts any nonempty run of octal digits and keeps +// the low 16 bits of a wider value. readTreeEntryMode keeps the low 32 +// bits; [filemode.FileMode.Canonical] reads only bits both keep, so the +// canonical mode is the one Git acts on. A mode longer than r's buffer +// is read in chunks, so memory use does not grow with its length. +// +// [1]: https://github.com/git/git/blob/v2.55.0/object.h#L200-L215 +func readTreeEntryMode(r *bufio.Reader) (filemode.FileMode, error) { + var ( + mode uint32 + seen bool + ) + for { + // ReadSlice returns a view into bufio's internal buffer, which + // avoids allocating for a mode that is parsed immediately. + chunk, err := r.ReadSlice(' ') + switch err { + case nil: + chunk = chunk[:len(chunk)-1] // strip delimiter + case bufio.ErrBufferFull: + case io.EOF: + if !seen && len(chunk) == 0 { + return filemode.Empty, io.EOF + } + return filemode.Empty, fmt.Errorf("%w: missing mode terminator", ErrMalformedTree) + default: + return filemode.Empty, err + } + + for _, c := range chunk { + if c < '0' || c > '7' { + return filemode.Empty, fmt.Errorf("%w: malformed mode", ErrMalformedTree) + } + // Overflow wraps, keeping the low 32 bits. + mode = mode<<3 | uint32(c-'0') + } + seen = seen || len(chunk) > 0 + + if err == nil { + if !seen { + return filemode.Empty, fmt.Errorf("%w: malformed mode", ErrMalformedTree) + } + return filemode.FileMode(mode), nil } - return filemode.Regular - case 0o120000: - return filemode.Symlink - default: - return filemode.Submodule } } @@ -462,11 +521,11 @@ func (t *Tree) Encode(o plumbing.EncodedObject) (err error) { // together via errors.Join. // // Two fsck_tree warnings — zero-padded modes and the non-canonical -// 0100664 bits — are not surfaced here. Both rely on inspecting the -// original octal string from the wire, which canonicalTreeMode -// discards during Decode. Detecting them would require a parallel -// raw-mode field on TreeEntry; the structural rules below are the -// load-bearing ones for refusing malformed trees. +// 0100664 bits — are not surfaced here. Both need the mode as stored, +// which Decode replaces with [filemode.FileMode.Canonical]. Detecting +// them would require a parallel raw-mode field on TreeEntry; the +// structural rules below are the load-bearing ones for refusing +// malformed trees. // // [1]: https://github.com/git/git/blob/v2.54.0/fsck.c#L616-L800 func (t *Tree) Validate() error { @@ -504,8 +563,8 @@ func (t *Tree) Validate() error { } } - // Mode validation against the canonical set. Decode normalises - // the wire bytes via canonicalTreeMode, so this rule mainly + // Mode validation against the canonical set. Decode stores + // FileMode.Canonical of the wire mode, so this rule mainly // catches programmatically-built trees with garbage modes; // the zero-padded-mode and non-canonical-bit checks fsck_tree // runs against the raw wire form are out of reach without @@ -593,8 +652,9 @@ func (t *Tree) PatchContext(ctx context.Context, to *Tree) (*Patch, error) { // treeEntryIter facilitates iterating through the TreeEntry objects in a Tree. type treeEntryIter struct { - t *Tree - pos int + t *Tree + pos int + parentBaseLen int } func (iter *treeEntryIter) Next() (TreeEntry, error) { @@ -629,7 +689,7 @@ type TreeWalker struct { // tree walker. func NewTreeWalker(t *Tree, recursive bool, seen map[plumbing.Hash]bool) *TreeWalker { stack := make([]*treeEntryIter, 0, startingStackSize) - stack = append(stack, &treeEntryIter{t, 0}) + stack = append(stack, &treeEntryIter{t: t}) return &TreeWalker{ stack: stack, @@ -641,21 +701,32 @@ func NewTreeWalker(t *Tree, recursive bool, seen map[plumbing.Hash]bool) *TreeWa } } -// Next returns the next object from the tree. Objects are returned in order -// and subtrees are included. After the last object has been returned further -// calls to Next() will return io.EOF. +// Next returns the next entry in tree order, including directory entries. +// After the last entry, Next returns io.EOF. +// +// Entry names are checked with pathutil.ValidTreePath unless the internal +// skipPathValidation flag is set. Callers inspecting unvalidated names can +// read Tree.Entries directly. Path checks do not validate filesystem state. // -// Each entry's name is validated against pathutil.ValidTreePath as it -// surfaces, so callers that funnel the returned name into filesystem -// or archive output can trust it is free of `.git`-shaped components, -// HFS+/NTFS variants, Windows reserved names, and traversal sequences. -// A malformed entry stops the walk with the validator's error; -// inspection-only callers that need to enumerate raw, unvalidated -// names can read Tree.Entries directly or set skipPathValidation. +// In a recursive walk, a subtree that cannot be read or decoded is reported +// as an error that names the subtree's hash and path and wraps the cause. +// A directory entry pointing to another object type reports ErrInvalidTree; +// an absent subtree reports plumbing.ErrObjectNotFound; a malformed one +// reports a decode error such as ErrMalformedTree. Causes matching io.EOF +// are included only as text so that errors.Is(err, io.EOF) identifies only +// normal exhaustion. Git's `git ls-tree -r` fails in the same situation, +// with "Could not read " for a missing subtree or a decode error such +// as "too-short tree object" for a malformed one. // -// In the current implementation any objects which cannot be found in the -// underlying repository will be skipped automatically. It is possible that this -// may change in future versions. +// After a path-validation or subtree-read error, calling Next again skips +// the failed entry and continues with its siblings, so a caller may choose +// to skip unreadable subtrees. ErrMaxTreeDepth is terminal: it reports no +// entry and repeats on subsequent calls. +// +// Missing subtrees are errors even in partial clones: go-git does not lazily +// fetch them, and omitting their entries could produce an incomplete index. +// A walk that does not recurse does not read subtrees, so an unreadable +// subtree is returned as an ordinary entry. func (w *TreeWalker) Next() (name string, entry TreeEntry, err error) { var obj *Tree for { @@ -674,10 +745,10 @@ func (w *TreeWalker) Next() (name string, entry TreeEntry, err error) { entry, err = w.stack[current].Next() if err == io.EOF { - // Finished with the current tree, move back up to the parent + // Restore one tree level, which can span several path components + // when a malformed directory entry's name contains slashes. + w.base = w.base[:w.stack[current].parentBaseLen] w.stack = w.stack[:current] - w.base, _ = path.Split(w.base) - w.base = strings.TrimSuffix(w.base, "/") continue } @@ -695,15 +766,14 @@ func (w *TreeWalker) Next() (name string, entry TreeEntry, err error) { } } - if entry.Mode == filemode.Dir { - obj, err = GetTree(w.s, entry.Hash) - } - name = simpleJoin(w.base, entry.Name) - if err != nil { - err = io.EOF - return name, entry, err + if w.recursive && entry.Mode == filemode.Dir { + obj, err = readSubtree(w.s, &entry) + if err != nil { + err = fmt.Errorf("reading tree %s for %q: %w", entry.Hash, name, err) + return name, entry, err + } } break @@ -714,13 +784,100 @@ func (w *TreeWalker) Next() (name string, entry TreeEntry, err error) { } if obj != nil { - w.stack = append(w.stack, &treeEntryIter{obj, 0}) + w.stack = append(w.stack, &treeEntryIter{t: obj, parentBaseLen: len(w.base)}) w.base = simpleJoin(w.base, entry.Name) } return name, entry, err } +// readSubtree reads a directory entry's tree for lookup or enumeration. +// Decode errors are preserved without another lookup, which could obscure +// the original failure. +func readSubtree(s storer.EncodedObjectStorer, e *TreeEntry) (*Tree, error) { + obj, err := s.EncodedObject(plumbing.TreeObject, e.Hash) + if err != nil { + return nil, subtreeReadError(s, e, err) + } + tree, err := DecodeTree(s, obj) + if err != nil { + return nil, subtreeError(e, err) + } + return tree, nil +} + +// subtreeReadError distinguishes a missing object from a wrong-type object. +// Typed lookups can return plumbing.ErrObjectNotFound for either, so an +// untyped lookup is needed. If it finds a tree, preserve the original error; +// otherwise report the wrong type or the untyped lookup's error. +func subtreeReadError(s storer.EncodedObjectStorer, e *TreeEntry, err error) error { + obj, perr := s.EncodedObject(plumbing.AnyObject, e.Hash) + if perr != nil { + return subtreeError(e, perr) + } + + if obj.Type() != plumbing.TreeObject { + return fmt.Errorf("%w: entry %q has mode %s but points at a %s", + ErrInvalidTree, e.Name, e.Mode, obj.Type()) + } + + return subtreeError(e, err) +} + +// subtreeError identifies the entry and wraps cause unless it matches io.EOF. +// EOF causes are included only as text so a failed read cannot be mistaken for +// iterator exhaustion. No sentinel replaces them: EOF alone does not establish +// that the object is missing or invalid. Causes joined with EOF keep the +// identity of the errors joined alongside it, which callers match to tell a +// missing subtree from an invalid one. +func subtreeError(e *TreeEntry, cause error) error { + if !errors.Is(cause, io.EOF) { + return fmt.Errorf("%w: entry %q has mode %s", cause, e.Name, e.Mode) + } + + text := fmt.Sprintf("entry %q has mode %s: %v", e.Name, e.Mode, cause) + kept := causesBesidesEOF(cause) + if kept == nil { + return errors.New(text) + } + + return &subtreeEOFError{text: text, cause: kept} +} + +// causesBesidesEOF returns the errors joined into err that do not match io.EOF, +// or nil when it joins none. An error that wraps io.EOF along a single chain +// cannot be separated from it, so it is left out. +func causesBesidesEOF(err error) error { + joined, ok := err.(interface{ Unwrap() []error }) + if !ok { + return nil + } + + var kept []error + for _, c := range joined.Unwrap() { + if !errors.Is(c, io.EOF) { + kept = append(kept, c) + continue + } + if inner := causesBesidesEOF(c); inner != nil { + kept = append(kept, inner) + } + } + + return errors.Join(kept...) +} + +// subtreeEOFError reports a subtree read that failed with io.EOF among its +// causes. Its message names every cause while its chain omits io.EOF. +type subtreeEOFError struct { + text string + cause error +} + +func (e *subtreeEOFError) Error() string { return e.text } + +func (e *subtreeEOFError) Unwrap() error { return e.cause } + // Tree returns the tree that the tree walker most recently operated on. func (w *TreeWalker) Tree() *Tree { current := len(w.stack) - 1 diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/object/treenoder.go b/vendor/github.com/go-git/go-git/v6/plumbing/object/treenoder.go index 0284a14165..b94b002ee8 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/object/treenoder.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/object/treenoder.go @@ -1,8 +1,11 @@ package object import ( + "fmt" "io" + "strings" + "github.com/go-git/go-git/v6/internal/pathutil" "github.com/go-git/go-git/v6/plumbing" "github.com/go-git/go-git/v6/plumbing/filemode" "github.com/go-git/go-git/v6/utils/merkletrie/noder" @@ -82,8 +85,19 @@ func (t *treeNoder) Children() ([]noder.Noder, error) { // is is own parent. parent := t.parent if !t.isRoot() { + // Check the name as Tree.FindEntry would before descending, so a + // diff never reports a path below a directory named "..", ".git" + // or "a/b". Leaf names are not checked here. + if err := validSubtreeName(t.name); err != nil { + return nil, err + } + + // Read the subtree by the entry this noder was built from, so an + // unreadable one reports the same errors a recursive walk does, + // rather than Tree.Tree's ErrDirectoryNotFound. var err error - if parent, err = t.parent.Tree(t.name); err != nil { + entry := TreeEntry{Name: t.name, Mode: t.mode, Hash: t.hash} + if parent, err = readSubtree(t.parent.s, &entry); err != nil { return nil, err } } @@ -93,6 +107,17 @@ func (t *treeNoder) Children() ([]noder.Noder, error) { return t.children, err } +// validSubtreeName checks that name can be looked up as a single +// directory component by Tree.FindEntry: a valid tree path without a +// slash, which FindEntry would treat as a separator. +func validSubtreeName(name string) error { + if strings.Contains(name, "/") { + return fmt.Errorf("%w %q: contains a slash", pathutil.ErrInvalidPath, name) + } + + return pathutil.ValidTreePath(name) +} + // Returns the children of a tree as treenoders. // Efficiency is key here. func transformChildren(t *Tree) ([]noder.Noder, error) { @@ -110,7 +135,10 @@ func transformChildren(t *Tree) ([]noder.Noder, error) { // filesystem, so it must enumerate the tree faithfully — including entries // with names that are unsafe to check out but valid per upstream Git (e.g. // control characters). Path safety is enforced at materialisation - // boundaries (FindEntry, TreeEntryFile, archive, FileIter), not here. + // boundaries (FindEntry, TreeEntryFile, archive, FileIter, and the + // worktree filesystem wrapper's validPath, which the tree-derived + // deletes in resetWorktreeToTree reach without passing any of the + // others), not here. walker.skipPathValidation = true // don't defer walker.Close() for efficiency reasons. for { diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/objectid.go b/vendor/github.com/go-git/go-git/v6/plumbing/objectid.go index 2697ec7e07..047be0bb88 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/objectid.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/objectid.go @@ -13,11 +13,20 @@ var empty = make([]byte, format.SHA256Size) // FromHex parses a hexadecimal string and returns an ObjectID // and a boolean confirming whether the operation was successful. -// The object format is inferred from the length of the input. -// -// For backwards compatibility, partial hashes will be handled as -// being SHA1. +// The object format is inferred from the length of the input, which +// must be exactly that of a SHA-1 or a SHA-256 id. func FromHex(in string) (ObjectID, bool) { + if len(in) != format.SHA1HexSize && len(in) != format.SHA256HexSize { + return ObjectID{}, false + } + return fromHexLax(in) +} + +// fromHexLax parses a hexadecimal string of any length. Input of any +// length other than a SHA-256 id is handled as SHA-1. Shorter input +// is zero-padded and longer input is truncated. It keeps the behaviour +// [NewHash] has always had. +func fromHexLax(in string) (ObjectID, bool) { var id ObjectID if len(in) == format.SHA256HexSize { @@ -56,13 +65,39 @@ func FromBytes(in []byte) (ObjectID, bool) { return id, true } +// ZeroID returns the zero ObjectID for the object format [f]. Unknown +// formats yield the SHA-1 zero, which is [ZeroHash]. +func ZeroID(f format.ObjectFormat) ObjectID { + if f == format.SHA256 { + return ObjectID{format: format.SHA256} + } + return ObjectID{} +} + // ObjectID represents the ID of a Git object. The object data is kept // in its hexadecimal form. +// +// Every id has exactly one representation regardless of how it was +// produced (parsed, hashed, decoded or read), so ==, [ObjectID.Equal] +// and map keys always agree. SHA-1 ids never carry an explicit format, +// which makes the zero value equal to [ZeroHash]. SHA-256 ids always +// carry their format. Bytes past the format's size are always zero. +// Ids of different formats are never equal, including their zero ids. +// Use [ObjectID.IsZero] to test for a zero id of any format. type ObjectID struct { hash [format.SHA256Size]byte format format.ObjectFormat } +// Format returns the object format of the ObjectID. Ids that carry no +// explicit format are SHA-1. +func (s ObjectID) Format() format.ObjectFormat { + if s.format == format.SHA256 { + return format.SHA256 + } + return format.SHA1 +} + // HexSize returns the size for the hex representation of the current // object. func (s ObjectID) HexSize() int { @@ -79,9 +114,10 @@ func (s ObjectID) Compare(b []byte) int { return bytes.Compare(s.hash[:s.Size()], b) } -// Equal returns true if [in] equals the current object. +// Equal returns true if [in] equals the current object. Ids of +// different object formats are never equal. It is equivalent to ==. func (s ObjectID) Equal(in ObjectID) bool { - return bytes.Equal(s.hash[:], in.hash[:]) + return s == in } // Bytes returns the slice of bytes representing the hash in hexadecimal. @@ -98,7 +134,9 @@ func (s ObjectID) HasPrefix(prefix []byte) bool { return bytes.HasPrefix(s.hash[:s.Size()], prefix) } -// IsZero returns true if the hash is zero. +// IsZero returns true if the hash is zero, whatever its object format. +// It is the only format-agnostic zero test, as == [ZeroHash] only +// matches the SHA-1 zero id. func (s ObjectID) IsZero() bool { return bytes.Equal(s.hash[:], empty) } @@ -110,9 +148,10 @@ func (s ObjectID) String() string { } // Write writes the hexadecimal representation of the ObjectID from [in] -// directly into the current object. +// directly into the current object. At most the ObjectID's current size +// is written, and any bytes in [in] past it are ignored. func (s *ObjectID) Write(in []byte) (int, error) { - n := copy(s.hash[:], in) + n := copy(s.hash[:s.Size()], in) return n, nil } diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/protocol/capability/list.go b/vendor/github.com/go-git/go-git/v6/plumbing/protocol/capability/list.go index fec4fd3ffb..6cdaf3b38a 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/protocol/capability/list.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/protocol/capability/list.go @@ -73,7 +73,7 @@ func EncodeList(l *List) []byte { // Get returns the values for a capability func (l *List) Get(capability string) []string { - if l.m == nil { + if l == nil || l.m == nil { return nil } if _, ok := l.m[capability]; !ok { @@ -115,7 +115,7 @@ func (l *List) Add(c string, values ...string) { // Supports returns true if capability is present func (l *List) Supports(capability string) bool { - if l.m == nil { + if l == nil || l.m == nil { return false } _, ok := l.m[capability] @@ -141,7 +141,7 @@ func (l *List) Delete(capability string) { // All returns a slice with all defined capabilities. func (l *List) All() []string { - if len(l.sort) == 0 { + if l == nil || len(l.sort) == 0 { return nil } diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/protocol/packp/advrefs.go b/vendor/github.com/go-git/go-git/v6/plumbing/protocol/packp/advrefs.go index 5220acca78..886a2d9dd1 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/protocol/packp/advrefs.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/protocol/packp/advrefs.go @@ -1,8 +1,6 @@ -// Package packp implements encoding and decoding of the Git packfile protocol messages. package packp import ( - "fmt" "sort" "strings" @@ -60,7 +58,7 @@ func (a *AdvRefs) ResolvedHead() (*plumbing.Reference, error) { } if a.supportSymrefs() { - return a.resolvedHeadFromSymref(head) + return a.resolvedHeadFromSymref(head), nil } return a.resolvedHeadFromHeuristic(head), nil @@ -68,15 +66,11 @@ func (a *AdvRefs) ResolvedHead() (*plumbing.Reference, error) { // resolvedHeadFromSymref resolves HEAD using the symref capability. // Returns head unchanged if no HEAD entry exists in the symref map. -func (a *AdvRefs) resolvedHeadFromSymref(head *plumbing.Reference) (*plumbing.Reference, error) { - symrefs, err := a.symRefMap() - if err != nil { - return nil, err - } - if target, ok := symrefs[plumbing.HEAD]; ok { - return plumbing.NewSymbolicReference(plumbing.HEAD, target), nil +func (a *AdvRefs) resolvedHeadFromSymref(head *plumbing.Reference) *plumbing.Reference { + if target, ok := a.symRefMap()[plumbing.HEAD]; ok { + return plumbing.NewSymbolicReference(plumbing.HEAD, target) } - return head, nil + return head } // ResolvedReferences returns all references with HEAD resolved to a @@ -86,12 +80,8 @@ func (a *AdvRefs) ResolvedReferences() ([]*plumbing.Reference, error) { refs := make([]*plumbing.Reference, len(a.References)) copy(refs, a.References) - symrefs, err := a.symRefMap() - if err != nil { - return nil, err - } if a.supportSymrefs() { - for name, target := range symrefs { + for name, target := range a.symRefMap() { symRef := plumbing.NewSymbolicReference(name, target) found := false for i, ref := range refs { @@ -121,17 +111,27 @@ func (a *AdvRefs) ResolvedReferences() ([]*plumbing.Reference, error) { } // symRefMap parses the symref capability values into a name→target map. -func (a *AdvRefs) symRefMap() (map[plumbing.ReferenceName]plumbing.ReferenceName, error) { +// +// It follows upstream connect.c parse_one_symref_info, which splits a value +// at its first colon and ignores it when either side fails +// check_refname_format(name, REFNAME_ALLOW_ONELEVEL), instead of failing the +// whole advertisement. +// See https://github.com/git/git/blob/f357b9c2c77eae1a1d37dfa44c1dda53f532a82a/connect.c#L183-L207. +func (a *AdvRefs) symRefMap() map[plumbing.ReferenceName]plumbing.ReferenceName { symrefs := a.Capabilities.Get(capability.SymRef) m := make(map[plumbing.ReferenceName]plumbing.ReferenceName, len(symrefs)) for _, symref := range symrefs { - chunks := strings.Split(symref, ":") - if len(chunks) != 2 { - return nil, fmt.Errorf("bad number of `:` in symref value (%q)", symref) + name, target, ok := strings.Cut(symref, ":") + if !ok { + continue + } + n, t := plumbing.ReferenceName(name), plumbing.ReferenceName(target) + if !validAdvertisedName(n) || !validAdvertisedName(t) { + continue } - m[plumbing.ReferenceName(chunks[0])] = plumbing.ReferenceName(chunks[1]) + m[n] = t } - return m, nil + return m } // resolvedHeadFromHeuristic tries to convert HEAD from a HashReference to diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/protocol/packp/advrefs_encode.go b/vendor/github.com/go-git/go-git/v6/plumbing/protocol/packp/advrefs_encode.go index b07874ac8b..89d09b6a77 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/protocol/packp/advrefs_encode.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/protocol/packp/advrefs_encode.go @@ -7,8 +7,10 @@ import ( "strings" "github.com/go-git/go-git/v6/plumbing" + "github.com/go-git/go-git/v6/plumbing/format/config" "github.com/go-git/go-git/v6/plumbing/format/pktline" "github.com/go-git/go-git/v6/plumbing/protocol" + "github.com/go-git/go-git/v6/plumbing/protocol/capability" ) // Encode writes the AdvRefs encoding to a writer. @@ -33,9 +35,14 @@ func (a *AdvRefs) Encode(w io.Writer) error { // Write first line: hash SP refname NUL capabilities caps := a.Capabilities.String() if firstName == "" { - // No refs: zero-id capabilities^{} + // No refs: zero-id capabilities^{}. The zero id is spelled in the + // advertised object format, which clients use to parse the line. + var format config.ObjectFormat + if v := a.Capabilities.Get(capability.ObjectFormat); len(v) > 0 { + format = config.ObjectFormat(v[0]) + } firstLine := fmt.Sprintf("%s %s\x00%s\n", - plumbing.ZeroHash.String(), "capabilities^{}", caps) + plumbing.ZeroID(format).String(), "capabilities^{}", caps) if _, err := pktline.WriteString(w, firstLine); err != nil { return err } diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/protocol/packp/common.go b/vendor/github.com/go-git/go-git/v6/plumbing/protocol/packp/common.go index 15f6e7d671..b596a04737 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/protocol/packp/common.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/protocol/packp/common.go @@ -25,6 +25,7 @@ var ( deepenCommits = []byte("deepen ") deepenSince = []byte("deepen-since ") deepenReference = []byte("deepen-not ") + filterSpec = []byte("filter ") // shallow-update unshallow = []byte("unshallow ") diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/protocol/packp/doc.go b/vendor/github.com/go-git/go-git/v6/plumbing/protocol/packp/doc.go index 4950d1d662..cb71a30f55 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/protocol/packp/doc.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/protocol/packp/doc.go @@ -1,724 +1,14 @@ +// Package packp implements encoding and decoding of the messages of the +// Git pack protocol: reference advertisements, upload and update requests, +// negotiation responses, shallow updates, status reports, and the commands +// of protocol version 2. +// +// The wire formats are specified in gitprotocol-common(5), +// gitprotocol-pack(5), gitprotocol-capabilities(5) and gitprotocol-v2(5): +// https://git-scm.com/docs/gitprotocol-pack +// +// To see what Git itself sends and receives for an operation, run it with +// packet tracing enabled: +// +// GIT_TRACE_PACKET=true git ls-remote https://github.com/go-git/go-git package packp - -/* - -A nice way to trace the real data transmitted and received by git, use: - -GIT_TRACE_PACKET=true git ls-remote http://github.com/src-d/go-git -GIT_TRACE_PACKET=true git clone http://github.com/src-d/go-git - -Here follows a copy of the current protocol specification at the time of -this writing. - -(Please notice that most http git servers will add a flush-pkt after the -first pkt-line when using HTTP smart.) - - -Documentation Common to Pack and Http Protocols -=============================================== - -ABNF Notation -------------- - -ABNF notation as described by RFC 5234 is used within the protocol documents, -except the following replacement core rules are used: ----- - HEXDIG = DIGIT / "a" / "b" / "c" / "d" / "e" / "f" ----- - -We also define the following common rules: ----- - NUL = %x00 - zero-id = 40*"0" - obj-id = 40*(HEXDIGIT) - - refname = "HEAD" - refname /= "refs/" ----- - -A refname is a hierarchical octet string beginning with "refs/" and -not violating the 'git-check-ref-format' command's validation rules. -More specifically, they: - -. They can include slash `/` for hierarchical (directory) - grouping, but no slash-separated component can begin with a - dot `.`. - -. They must contain at least one `/`. This enforces the presence of a - category like `heads/`, `tags/` etc. but the actual names are not - restricted. - -. They cannot have two consecutive dots `..` anywhere. - -. They cannot have ASCII control characters (i.e. bytes whose - values are lower than \040, or \177 `DEL`), space, tilde `~`, - caret `^`, colon `:`, question-mark `?`, asterisk `*`, - or open bracket `[` anywhere. - -. They cannot end with a slash `/` or a dot `.`. - -. They cannot end with the sequence `.lock`. - -. They cannot contain a sequence `@{`. - -. They cannot contain a `\\`. - - -pkt-line Format ---------------- - -Much (but not all) of the payload is described around pkt-lines. - -A pkt-line is a variable length binary string. The first four bytes -of the line, the pkt-len, indicates the total length of the line, -in hexadecimal. The pkt-len includes the 4 bytes used to contain -the length's hexadecimal representation. - -A pkt-line MAY contain binary data, so implementors MUST ensure -pkt-line parsing/formatting routines are 8-bit clean. - -A non-binary line SHOULD BE terminated by an LF, which if present -MUST be included in the total length. Receivers MUST treat pkt-lines -with non-binary data the same whether or not they contain the trailing -LF (stripping the LF if present, and not complaining when it is -missing). - -The maximum length of a pkt-line's data component is 65516 bytes. -Implementations MUST NOT send pkt-line whose length exceeds 65520 -(65516 bytes of payload + 4 bytes of length data). - -Implementations SHOULD NOT send an empty pkt-line ("0004"). - -A pkt-line with a length field of 0 ("0000"), called a flush-pkt, -is a special case and MUST be handled differently than an empty -pkt-line ("0004"). - ----- - pkt-line = data-pkt / flush-pkt - - data-pkt = pkt-len pkt-payload - pkt-len = 4*(HEXDIG) - pkt-payload = (pkt-len - 4)*(OCTET) - - flush-pkt = "0000" ----- - -Examples (as C-style strings): - ----- - pkt-line actual value - --------------------------------- - "0006a\n" "a\n" - "0005a" "a" - "000bfoobar\n" "foobar\n" - "0004" "" ----- - -Packfile transfer protocols -=========================== - -Git supports transferring data in packfiles over the ssh://, git://, http:// and -file:// transports. There exist two sets of protocols, one for pushing -data from a client to a server and another for fetching data from a -server to a client. The three transports (ssh, git, file) use the same -protocol to transfer data. http is documented in http-protocol.txt. - -The processes invoked in the canonical Git implementation are 'upload-pack' -on the server side and 'fetch-pack' on the client side for fetching data; -then 'receive-pack' on the server and 'send-pack' on the client for pushing -data. The protocol functions to have a server tell a client what is -currently on the server, then for the two to negotiate the smallest amount -of data to send in order to fully update one or the other. - -pkt-line Format ---------------- - -The descriptions below build on the pkt-line format described in -protocol-common.txt. When the grammar indicate `PKT-LINE(...)`, unless -otherwise noted the usual pkt-line LF rules apply: the sender SHOULD -include a LF, but the receiver MUST NOT complain if it is not present. - -Transports ----------- -There are three transports over which the packfile protocol is -initiated. The Git transport is a simple, unauthenticated server that -takes the command (almost always 'upload-pack', though Git -servers can be configured to be globally writable, in which 'receive- -pack' initiation is also allowed) with which the client wishes to -communicate and executes it and connects it to the requesting -process. - -In the SSH transport, the client just runs the 'upload-pack' -or 'receive-pack' process on the server over the SSH protocol and then -communicates with that invoked process over the SSH connection. - -The file:// transport runs the 'upload-pack' or 'receive-pack' -process locally and communicates with it over a pipe. - -Git Transport -------------- - -The Git transport starts off by sending the command and repository -on the wire using the pkt-line format, followed by a NUL byte and a -hostname parameter, terminated by a NUL byte. - - 0032git-upload-pack /project.git\0host=myserver.com\0 - --- - git-proto-request = request-command SP pathname NUL [ host-parameter NUL ] - request-command = "git-upload-pack" / "git-receive-pack" / - "git-upload-archive" ; case sensitive - pathname = *( %x01-ff ) ; exclude NUL - host-parameter = "host=" hostname [ ":" port ] --- - -Only host-parameter is allowed in the git-proto-request. Clients -MUST NOT attempt to send additional parameters. It is used for the -git-daemon name based virtual hosting. See --interpolated-path -option to git daemon, with the %H/%CH format characters. - -Basically what the Git client is doing to connect to an 'upload-pack' -process on the server side over the Git protocol is this: - - $ echo -e -n \ - "0039git-upload-pack /schacon/gitbook.git\0host=example.com\0" | - nc -v example.com 9418 - -If the server refuses the request for some reasons, it could abort -gracefully with an error message. - ----- - error-line = PKT-LINE("ERR" SP explanation-text) ----- - - -SSH Transport -------------- - -Initiating the upload-pack or receive-pack processes over SSH is -executing the binary on the server via SSH remote execution. -It is basically equivalent to running this: - - $ ssh git.example.com "git-upload-pack '/project.git'" - -For a server to support Git pushing and pulling for a given user over -SSH, that user needs to be able to execute one or both of those -commands via the SSH shell that they are provided on login. On some -systems, that shell access is limited to only being able to run those -two commands, or even just one of them. - -In an ssh:// format URI, it's absolute in the URI, so the '/' after -the host name (or port number) is sent as an argument, which is then -read by the remote git-upload-pack exactly as is, so it's effectively -an absolute path in the remote filesystem. - - git clone ssh://user@example.com/project.git - | - v - ssh user@example.com "git-upload-pack '/project.git'" - -In a "user@host:path" format URI, its relative to the user's home -directory, because the Git client will run: - - git clone user@example.com:project.git - | - v - ssh user@example.com "git-upload-pack 'project.git'" - -The exception is if a '~' is used, in which case -we execute it without the leading '/'. - - ssh://user@example.com/~alice/project.git, - | - v - ssh user@example.com "git-upload-pack '~alice/project.git'" - -A few things to remember here: - -- The "command name" is spelled with dash (e.g. git-upload-pack), but - this can be overridden by the client; - -- The repository path is always quoted with single quotes. - -Fetching Data From a Server ---------------------------- - -When one Git repository wants to get data that a second repository -has, the first can 'fetch' from the second. This operation determines -what data the server has that the client does not then streams that -data down to the client in packfile format. - - -Reference Discovery -------------------- - -When the client initially connects the server will immediately respond -with a listing of each reference it has (all branches and tags) along -with the object name that each reference currently points to. - - $ echo -e -n "0039git-upload-pack /schacon/gitbook.git\0host=example.com\0" | - nc -v example.com 9418 - 00887217a7c7e582c46cec22a130adf4b9d7d950fba0 HEAD\0multi_ack thin-pack - side-band side-band-64k ofs-delta shallow no-progress include-tag - 00441d3fcd5ced445d1abc402225c0b8a1299641f497 refs/heads/integration - 003f7217a7c7e582c46cec22a130adf4b9d7d950fba0 refs/heads/master - 003cb88d2441cac0977faf98efc80305012112238d9d refs/tags/v0.9 - 003c525128480b96c89e6418b1e40909bf6c5b2d580f refs/tags/v1.0 - 003fe92df48743b7bc7d26bcaabfddde0a1e20cae47c refs/tags/v1.0^{} - 0000 - -The returned response is a pkt-line stream describing each ref and -its current value. The stream MUST be sorted by name according to -the C locale ordering. - -If HEAD is a valid ref, HEAD MUST appear as the first advertised -ref. If HEAD is not a valid ref, HEAD MUST NOT appear in the -advertisement list at all, but other refs may still appear. - -The stream MUST include capability declarations behind a NUL on the -first ref. The peeled value of a ref (that is "ref^{}") MUST be -immediately after the ref itself, if presented. A conforming server -MUST peel the ref if it's an annotated tag. - ----- - advertised-refs = (no-refs / list-of-refs) - *shallow - flush-pkt - - no-refs = PKT-LINE(zero-id SP "capabilities^{}" - NUL capability-list) - - list-of-refs = first-ref *other-ref - first-ref = PKT-LINE(obj-id SP refname - NUL capability-list) - - other-ref = PKT-LINE(other-tip / other-peeled) - other-tip = obj-id SP refname - other-peeled = obj-id SP refname "^{}" - - shallow = PKT-LINE("shallow" SP obj-id) - - capability-list = capability *(SP capability) - capability = 1*(LC_ALPHA / DIGIT / "-" / "_") - LC_ALPHA = %x61-7A ----- - -Server and client MUST use lowercase for obj-id, both MUST treat obj-id -as case-insensitive. - -See protocol-capabilities.txt for a list of allowed server capabilities -and descriptions. - -Packfile Negotiation --------------------- -After reference and capabilities discovery, the client can decide to -terminate the connection by sending a flush-pkt, telling the server it can -now gracefully terminate, and disconnect, when it does not need any pack -data. This can happen with the ls-remote command, and also can happen when -the client already is up-to-date. - -Otherwise, it enters the negotiation phase, where the client and -server determine what the minimal packfile necessary for transport is, -by telling the server what objects it wants, its shallow objects -(if any), and the maximum commit depth it wants (if any). The client -will also send a list of the capabilities it wants to be in effect, -out of what the server said it could do with the first 'want' line. - ----- - upload-request = want-list - *shallow-line - *1depth-request - flush-pkt - - want-list = first-want - *additional-want - - shallow-line = PKT-LINE("shallow" SP obj-id) - - depth-request = PKT-LINE("deepen" SP depth) / - PKT-LINE("deepen-since" SP timestamp) / - PKT-LINE("deepen-not" SP ref) - - first-want = PKT-LINE("want" SP obj-id SP capability-list) - additional-want = PKT-LINE("want" SP obj-id) - - depth = 1*DIGIT ----- - -Clients MUST send all the obj-ids it wants from the reference -discovery phase as 'want' lines. Clients MUST send at least one -'want' command in the request body. Clients MUST NOT mention an -obj-id in a 'want' command which did not appear in the response -obtained through ref discovery. - -The client MUST write all obj-ids which it only has shallow copies -of (meaning that it does not have the parents of a commit) as -'shallow' lines so that the server is aware of the limitations of -the client's history. - -The client now sends the maximum commit history depth it wants for -this transaction, which is the number of commits it wants from the -tip of the history, if any, as a 'deepen' line. A depth of 0 is the -same as not making a depth request. The client does not want to receive -any commits beyond this depth, nor does it want objects needed only to -complete those commits. Commits whose parents are not received as a -result are defined as shallow and marked as such in the server. This -information is sent back to the client in the next step. - -Once all the 'want's and 'shallow's (and optional 'deepen') are -transferred, clients MUST send a flush-pkt, to tell the server side -that it is done sending the list. - -Otherwise, if the client sent a positive depth request, the server -will determine which commits will and will not be shallow and -send this information to the client. If the client did not request -a positive depth, this step is skipped. - ----- - shallow-update = *shallow-line - *unshallow-line - flush-pkt - - shallow-line = PKT-LINE("shallow" SP obj-id) - - unshallow-line = PKT-LINE("unshallow" SP obj-id) ----- - -If the client has requested a positive depth, the server will compute -the set of commits which are no deeper than the desired depth. The set -of commits start at the client's wants. - -The server writes 'shallow' lines for each -commit whose parents will not be sent as a result. The server writes -an 'unshallow' line for each commit which the client has indicated is -shallow, but is no longer shallow at the currently requested depth -(that is, its parents will now be sent). The server MUST NOT mark -as unshallow anything which the client has not indicated was shallow. - -Now the client will send a list of the obj-ids it has using 'have' -lines, so the server can make a packfile that only contains the objects -that the client needs. In multi_ack mode, the canonical implementation -will send up to 32 of these at a time, then will send a flush-pkt. The -canonical implementation will skip ahead and send the next 32 immediately, -so that there is always a block of 32 "in-flight on the wire" at a time. - ----- - upload-haves = have-list - compute-end - - have-list = *have-line - have-line = PKT-LINE("have" SP obj-id) - compute-end = flush-pkt / PKT-LINE("done") ----- - -If the server reads 'have' lines, it then will respond by ACKing any -of the obj-ids the client said it had that the server also has. The -server will ACK obj-ids differently depending on which ack mode is -chosen by the client. - -In multi_ack mode: - - * the server will respond with 'ACK obj-id continue' for any common - commits. - - * once the server has found an acceptable common base commit and is - ready to make a packfile, it will blindly ACK all 'have' obj-ids - back to the client. - - * the server will then send a 'NAK' and then wait for another response - from the client - either a 'done' or another list of 'have' lines. - -In multi_ack_detailed mode: - - * the server will differentiate the ACKs where it is signaling - that it is ready to send data with 'ACK obj-id ready' lines, and - signals the identified common commits with 'ACK obj-id common' lines. - -Without either multi_ack or multi_ack_detailed: - - * upload-pack sends "ACK obj-id" on the first common object it finds. - After that it says nothing until the client gives it a "done". - - * upload-pack sends "NAK" on a flush-pkt if no common object - has been found yet. If one has been found, and thus an ACK - was already sent, it's silent on the flush-pkt. - -After the client has gotten enough ACK responses that it can determine -that the server has enough information to send an efficient packfile -(in the canonical implementation, this is determined when it has received -enough ACKs that it can color everything left in the --date-order queue -as common with the server, or the --date-order queue is empty), or the -client determines that it wants to give up (in the canonical implementation, -this is determined when the client sends 256 'have' lines without getting -any of them ACKed by the server - meaning there is nothing in common and -the server should just send all of its objects), then the client will send -a 'done' command. The 'done' command signals to the server that the client -is ready to receive its packfile data. - -However, the 256 limit *only* turns on in the canonical client -implementation if we have received at least one "ACK %s continue" -during a prior round. This helps to ensure that at least one common -ancestor is found before we give up entirely. - -Once the 'done' line is read from the client, the server will either -send a final 'ACK obj-id' or it will send a 'NAK'. 'obj-id' is the object -name of the last commit determined to be common. The server only sends -ACK after 'done' if there is at least one common base and multi_ack or -multi_ack_detailed is enabled. The server always sends NAK after 'done' -if there is no common base found. - -Then the server will start sending its packfile data. - ----- - server-response = *ack_multi ack / nak - ack_multi = PKT-LINE("ACK" SP obj-id ack_status) - ack_status = "continue" / "common" / "ready" - ack = PKT-LINE("ACK" SP obj-id) - nak = PKT-LINE("NAK") ----- - -A simple clone may look like this (with no 'have' lines): - ----- - C: 0054want 74730d410fcb6603ace96f1dc55ea6196122532d multi_ack \ - side-band-64k ofs-delta\n - C: 0032want 7d1665144a3a975c05f1f43902ddaf084e784dbe\n - C: 0032want 5a3f6be755bbb7deae50065988cbfa1ffa9ab68a\n - C: 0032want 7e47fe2bd8d01d481f44d7af0531bd93d3b21c01\n - C: 0032want 74730d410fcb6603ace96f1dc55ea6196122532d\n - C: 0000 - C: 0009done\n - - S: 0008NAK\n - S: [PACKFILE] ----- - -An incremental update (fetch) response might look like this: - ----- - C: 0054want 74730d410fcb6603ace96f1dc55ea6196122532d multi_ack \ - side-band-64k ofs-delta\n - C: 0032want 7d1665144a3a975c05f1f43902ddaf084e784dbe\n - C: 0032want 5a3f6be755bbb7deae50065988cbfa1ffa9ab68a\n - C: 0000 - C: 0032have 7e47fe2bd8d01d481f44d7af0531bd93d3b21c01\n - C: [30 more have lines] - C: 0032have 74730d410fcb6603ace96f1dc55ea6196122532d\n - C: 0000 - - S: 003aACK 7e47fe2bd8d01d481f44d7af0531bd93d3b21c01 continue\n - S: 003aACK 74730d410fcb6603ace96f1dc55ea6196122532d continue\n - S: 0008NAK\n - - C: 0009done\n - - S: 0031ACK 74730d410fcb6603ace96f1dc55ea6196122532d\n - S: [PACKFILE] ----- - - -Packfile Data -------------- - -Now that the client and server have finished negotiation about what -the minimal amount of data that needs to be sent to the client is, the server -will construct and send the required data in packfile format. - -See pack-format.txt for what the packfile itself actually looks like. - -If 'side-band' or 'side-band-64k' capabilities have been specified by -the client, the server will send the packfile data multiplexed. - -Each packet starting with the packet-line length of the amount of data -that follows, followed by a single byte specifying the sideband the -following data is coming in on. - -In 'side-band' mode, it will send up to 999 data bytes plus 1 control -code, for a total of up to 1000 bytes in a pkt-line. In 'side-band-64k' -mode it will send up to 65519 data bytes plus 1 control code, for a -total of up to 65520 bytes in a pkt-line. - -The sideband byte will be a '1', '2' or a '3'. Sideband '1' will contain -packfile data, sideband '2' will be used for progress information that the -client will generally print to stderr and sideband '3' is used for error -information. - -If no 'side-band' capability was specified, the server will stream the -entire packfile without multiplexing. - - -Pushing Data To a Server ------------------------- - -Pushing data to a server will invoke the 'receive-pack' process on the -server, which will allow the client to tell it which references it should -update and then send all the data the server will need for those new -references to be complete. Once all the data is received and validated, -the server will then update its references to what the client specified. - -Authentication --------------- - -The protocol itself contains no authentication mechanisms. That is to be -handled by the transport, such as SSH, before the 'receive-pack' process is -invoked. If 'receive-pack' is configured over the Git transport, those -repositories will be writable by anyone who can access that port (9418) as -that transport is unauthenticated. - -Reference Discovery -------------------- - -The reference discovery phase is done nearly the same way as it is in the -fetching protocol. Each reference obj-id and name on the server is sent -in packet-line format to the client, followed by a flush-pkt. The only -real difference is that the capability listing is different - the only -possible values are 'report-status', 'delete-refs', 'ofs-delta' and -'push-options'. - -Reference Update Request and Packfile Transfer ----------------------------------------------- - -Once the client knows what references the server is at, it can send a -list of reference update requests. For each reference on the server -that it wants to update, it sends a line listing the obj-id currently on -the server, the obj-id the client would like to update it to and the name -of the reference. - -This list is followed by a flush-pkt. Then the push options are transmitted -one per packet followed by another flush-pkt. After that the packfile that -should contain all the objects that the server will need to complete the new -references will be sent. - ----- - update-request = *shallow ( command-list | push-cert ) [packfile] - - shallow = PKT-LINE("shallow" SP obj-id) - - command-list = PKT-LINE(command NUL capability-list) - *PKT-LINE(command) - flush-pkt - - command = create / delete / update - create = zero-id SP new-id SP name - delete = old-id SP zero-id SP name - update = old-id SP new-id SP name - - old-id = obj-id - new-id = obj-id - - push-cert = PKT-LINE("push-cert" NUL capability-list LF) - PKT-LINE("certificate version 0.1" LF) - PKT-LINE("pusher" SP ident LF) - PKT-LINE("pushee" SP url LF) - PKT-LINE("nonce" SP nonce LF) - PKT-LINE(LF) - *PKT-LINE(command LF) - *PKT-LINE(gpg-signature-lines LF) - PKT-LINE("push-cert-end" LF) - - packfile = "PACK" 28*(OCTET) ----- - -If the receiving end does not support delete-refs, the sending end MUST -NOT ask for delete command. - -If the receiving end does not support push-cert, the sending end -MUST NOT send a push-cert command. When a push-cert command is -sent, command-list MUST NOT be sent; the commands recorded in the -push certificate is used instead. - -The packfile MUST NOT be sent if the only command used is 'delete'. - -A packfile MUST be sent if either create or update command is used, -even if the server already has all the necessary objects. In this -case the client MUST send an empty packfile. The only time this -is likely to happen is if the client is creating -a new branch or a tag that points to an existing obj-id. - -The server will receive the packfile, unpack it, then validate each -reference that is being updated that it hasn't changed while the request -was being processed (the obj-id is still the same as the old-id), and -it will run any update hooks to make sure that the update is acceptable. -If all of that is fine, the server will then update the references. - -Push Certificate ----------------- - -A push certificate begins with a set of header lines. After the -header and an empty line, the protocol commands follow, one per -line. Note that the trailing LF in push-cert PKT-LINEs is _not_ -optional; it must be present. - -Currently, the following header fields are defined: - -`pusher` ident:: - Identify the GPG key in "Human Readable Name " - format. - -`pushee` url:: - The repository URL (anonymized, if the URL contains - authentication material) the user who ran `git push` - intended to push into. - -`nonce` nonce:: - The 'nonce' string the receiving repository asked the - pushing user to include in the certificate, to prevent - replay attacks. - -The GPG signature lines are a detached signature for the contents -recorded in the push certificate before the signature block begins. -The detached signature is used to certify that the commands were -given by the pusher, who must be the signer. - -Report Status -------------- - -After receiving the pack data from the sender, the receiver sends a -report if 'report-status' capability is in effect. -It is a short listing of what happened in that update. It will first -list the status of the packfile unpacking as either 'unpack ok' or -'unpack [error]'. Then it will list the status for each of the references -that it tried to update. Each line is either 'ok [refname]' if the -update was successful, or 'ng [refname] [error]' if the update was not. - ----- - report-status = unpack-status - 1*(command-status) - flush-pkt - - unpack-status = PKT-LINE("unpack" SP unpack-result) - unpack-result = "ok" / error-msg - - command-status = command-ok / command-fail - command-ok = PKT-LINE("ok" SP refname) - command-fail = PKT-LINE("ng" SP refname SP error-msg) - - error-msg = 1*(OCTECT) ; where not "ok" ----- - -Updates can be unsuccessful for a number of reasons. The reference can have -changed since the reference discovery phase was originally sent, meaning -someone pushed in the meantime. The reference being pushed could be a -non-fast-forward reference and the update hooks or configuration could be -set to not allow that, etc. Also, some references can be updated while others -can be rejected. - -An example client/server communication might look like this: - ----- - S: 007c74730d410fcb6603ace96f1dc55ea6196122532d refs/heads/local\0report-status delete-refs ofs-delta\n - S: 003e7d1665144a3a975c05f1f43902ddaf084e784dbe refs/heads/debug\n - S: 003f74730d410fcb6603ace96f1dc55ea6196122532d refs/heads/master\n - S: 003f74730d410fcb6603ace96f1dc55ea6196122532d refs/heads/team\n - S: 0000 - - C: 003e7d1665144a3a975c05f1f43902ddaf084e784dbe 74730d410fcb6603ace96f1dc55ea6196122532d refs/heads/debug\n - C: 003e74730d410fcb6603ace96f1dc55ea6196122532d 5a3f6be755bbb7deae50065988cbfa1ffa9ab68a refs/heads/master\n - C: 0000 - C: [PACKDATA] - - S: 000eunpack ok\n - S: 0018ok refs/heads/debug\n - S: 002ang refs/heads/master non-fast-forward\n ----- -*/ diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/protocol/packp/fetch.go b/vendor/github.com/go-git/go-git/v6/plumbing/protocol/packp/fetch.go index 04bbbd42d4..2008889c7b 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/protocol/packp/fetch.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/protocol/packp/fetch.go @@ -175,26 +175,27 @@ func (r *FetchArgs) Encode(w io.Writer) error { // Decode reads v2 fetch command arguments from a reader until a flush-pkt // is encountered. The caller is responsible for reading the delim-pkt -// and command header before calling Decode. +// and command header before calling Decode. Decode returns an error for +// an argument it does not know, and for a delim-pkt, an empty line or the end of +// the stream before the flush-pkt. func (r *FetchArgs) Decode(rd io.Reader) error { for { l, pkt, err := pktline.ReadLine(rd) if err != nil { if errors.Is(err, io.EOF) { - return nil + return errors.New("expected flush after fetch arguments") } return err } - if l == pktline.Flush || l == pktline.Delim { + if l == pktline.Flush { return nil } - - line := strings.TrimSpace(string(pkt)) - if len(line) == 0 { - return nil + if l == pktline.Delim { + return errors.New("expected flush after fetch arguments") } + line := strings.TrimSpace(string(pkt)) switch { case strings.HasPrefix(line, "want "): h, ok := parseFullHash(line[5:]) @@ -274,6 +275,11 @@ func (r *FetchArgs) Decode(rd io.Reader) error { case line == "wait-for-done": r.WaitForDone = true + + default: + // Upstream dies on anything else rather than answer a request + // it did not understand (upload-pack.c, process_args). + return fmt.Errorf("unexpected line: %q", line) } } } @@ -763,12 +769,12 @@ func (r *FetchOutput) encodeAcknowledgments(w io.Writer) error { func (r *FetchOutput) encodeShallowInfo(w io.Writer) error { for _, h := range r.ShallowInfo.Shallows { - if _, err := pktline.Writef(w, "shallow %s\n", h); err != nil { + if _, err := pktline.Writef(w, "shallow %s", h); err != nil { return err } } for _, h := range r.ShallowInfo.Unshallows { - if _, err := pktline.Writef(w, "unshallow %s\n", h); err != nil { + if _, err := pktline.Writef(w, "unshallow %s", h); err != nil { return err } } diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/protocol/packp/lsrefs.go b/vendor/github.com/go-git/go-git/v6/plumbing/protocol/packp/lsrefs.go index 457475e5a0..28e0c449df 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/protocol/packp/lsrefs.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/protocol/packp/lsrefs.go @@ -137,6 +137,11 @@ func (r *LsRefsArgs) Decode(rd io.Reader) error { // consumed by the transport layer and not seen by Decode. type LsRefsOutput struct { References []*plumbing.Reference + // UnbornHead is the symref target of HEAD when the server reported HEAD + // as unborn. References still holds HEAD as a single symbolic reference + // to it. It tells an unborn HEAD apart from a HEAD whose target a + // ref-prefix left out, since both decode to the same symbolic reference. + UnbornHead plumbing.ReferenceName } // Encode writes the ls-refs response lines as pkt-lines following the v2 @@ -186,6 +191,7 @@ func (r *LsRefsOutput) Encode(w io.Writer) error { // Decode reads ref lines until a flush-pkt. func (r *LsRefsOutput) Decode(rd io.Reader) error { + unbornAt := -1 for { l, pkt, err := pktline.ReadLine(rd) if err != nil { @@ -205,62 +211,101 @@ func (r *LsRefsOutput) Decode(rd io.Reader) error { continue } - refs, err := parseLsRefsLine(line) + refs, unbornHead, err := parseLsRefsLine(line) if err != nil { return err } + if unbornHead != "" { + r.UnbornHead = unbornHead + // A repeated unborn HEAD replaces the earlier one, since upstream + // keeps the last target (connect.c process_ref_v2). Keeping a + // single entry lets callers discount it from References. + if unbornAt >= 0 { + r.References[unbornAt] = refs[0] + continue + } + unbornAt = len(r.References) + } r.References = append(r.References, refs...) } } // parseLsRefsLine parses a single ref line from ls-refs output. // Format: SP [SP ...] LF -// Returns one or two references (base + peeled if the peeled attribute is present). -func parseLsRefsLine(line string) ([]*plumbing.Reference, error) { - // Fields tolerates the SP-separated grammar without producing empty tokens - // on repeated spaces: [oid-or-unborn, refname, attr1, attr2, ...]. - parts := strings.Fields(line) +// Returns one or two references (base + peeled if the peeled attribute is present), +// and the symref target of HEAD when the line reports HEAD as unborn. +// +// It follows upstream connect.c process_ref_v2, which ignores a ref with an +// invalid name and an invalid symref-target instead of failing the whole +// advertisement. +// See https://github.com/git/git/blob/f357b9c2c77eae1a1d37dfa44c1dda53f532a82a/connect.c#L393-L490. +func parseLsRefsLine(line string) (refs []*plumbing.Reference, unbornHead plumbing.ReferenceName, err error) { + // Upstream splits on each single space, so a repeated space yields an empty + // field: [oid-or-unborn, refname, attr1, attr2, ...]. Splitting on any + // whitespace would instead cut a ref name at a non-ASCII space, which a + // valid name may hold. + parts := strings.Split(line, " ") if len(parts) < 2 { - return nil, fmt.Errorf("malformed ref line: %q", line) + return nil, "", fmt.Errorf("malformed ref line: %q", line) } oidStr := parts[0] refName := plumbing.ReferenceName(parts[1]) + attrs := parts[2:] + + // Only HEAD can be unborn, and upstream skips any other unborn line. For + // HEAD it reads only the first symref-target and ignores the line when + // that target is missing or invalid, so a clone falls back to its default + // branch. + if oidStr == "unborn" { + if refName != plumbing.HEAD { + return nil, "", nil + } + for _, attr := range attrs { + target, ok := strings.CutPrefix(attr, "symref-target:") + if !ok { + continue + } + unbornHead = plumbing.ReferenceName(target) + if !validSymrefTarget(unbornHead) { + return nil, "", nil + } + return []*plumbing.Reference{plumbing.NewSymbolicReference(refName, unbornHead)}, unbornHead, nil + } + return nil, "", nil + } + + hash, ok := parseFullHash(oidStr) + if !ok { + return nil, "", fmt.Errorf("malformed object id: %q", oidStr) + } + + // Upstream skips a ref with an invalid name before reading its attributes. + if !validAdvertisedName(refName) { + return nil, "", nil + } var symrefTarget plumbing.ReferenceName var peeledHash plumbing.Hash hasPeeled := false - for _, attr := range parts[2:] { - if strings.HasPrefix(attr, "symref-target:") { - symrefTarget = plumbing.ReferenceName(attr[len("symref-target:"):]) - } else if strings.HasPrefix(attr, "peeled:") { - h, ok := parseFullHash(attr[len("peeled:"):]) + for _, attr := range attrs { + if target, ok := strings.CutPrefix(attr, "symref-target:"); ok { + // Upstream ignores an invalid target and keeps any earlier valid + // one, so a ref left without a target is reported by its object id. + if t := plumbing.ReferenceName(target); validSymrefTarget(t) { + symrefTarget = t + } + } else if p, ok := strings.CutPrefix(attr, "peeled:"); ok { + h, ok := parseFullHash(p) if !ok { - return nil, fmt.Errorf("malformed peeled hash: %q", attr) + return nil, "", fmt.Errorf("malformed peeled hash: %q", attr) } peeledHash = h hasPeeled = true } } - var refs []*plumbing.Reference - - // Handle unborn refs - if oidStr == "unborn" { - if symrefTarget == "" { - return nil, fmt.Errorf("malformed unborn ref line, missing symref-target: %q", line) - } - refs = append(refs, plumbing.NewSymbolicReference(refName, symrefTarget)) - return refs, nil - } - - // Regular hash ref - hash, ok := parseFullHash(oidStr) - if !ok { - return nil, fmt.Errorf("malformed object id: %q", oidStr) - } - if symrefTarget != "" { refs = append(refs, plumbing.NewSymbolicReference(refName, symrefTarget)) } else { @@ -275,13 +320,33 @@ func parseLsRefsLine(line string) ([]*plumbing.Reference, error) { )) } - return refs, nil + return refs, "", nil +} + +// validAdvertisedName reports whether an advertised ref name passes upstream's +// check_refname_format(name, REFNAME_ALLOW_ONELEVEL). Validate has no +// one-level mode, so a one-level name is checked as the last component of a +// name under refs/, which applies the same component rules. "@" is the only +// whole-name rule that the prefix would hide. +func validAdvertisedName(name plumbing.ReferenceName) bool { + if strings.Contains(string(name), "/") { + return name.Validate() == nil + } + return name != "@" && plumbing.ReferenceName("refs/"+name).Validate() == nil +} + +// validSymrefTarget reports whether a symref-target advertised by the remote is +// a valid reference name. Upstream checks it with check_refname_format(target, +// 0), which refuses one-level names, so HEAD is refused as well even though +// Validate admits it. +// See https://github.com/git/git/commit/8cb7e2e031978c59381adf086fd1c0ce1e3a7315. +func validSymrefTarget(target plumbing.ReferenceName) bool { + return target != plumbing.HEAD && target.Validate() == nil } // parseFullHash strictly parses a full-length SHA-1 or SHA-256 object id in hex -// form. Object ids on the wire are always full length, so unlike -// plumbing.FromHex (which zero-pads shorter input as a partial SHA-1) it rejects -// anything that is not exactly an object-id length, refusing malformed input. +// form. Object ids on the wire are always full length, so it rejects anything +// that is not exactly an object-id length, refusing malformed input. func parseFullHash(s string) (plumbing.Hash, bool) { if !plumbing.IsHash(s) { return plumbing.ZeroHash, false diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/protocol/packp/shallowupd.go b/vendor/github.com/go-git/go-git/v6/plumbing/protocol/packp/shallowupd.go index de0b8f758c..b3cfe8726e 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/protocol/packp/shallowupd.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/protocol/packp/shallowupd.go @@ -9,11 +9,6 @@ import ( "github.com/go-git/go-git/v6/plumbing/format/pktline" ) -const ( - shallowLineLen = 48 - unshallowLineLen = 50 -) - // ShallowUpdate represents shallow/unshallow updates during fetch. type ShallowUpdate struct { Shallows []plumbing.Hash @@ -48,7 +43,7 @@ func (r *ShallowUpdate) Decode(reader io.Reader) error { } func (r *ShallowUpdate) decodeShallowLine(line []byte) error { - hash, err := r.decodeLine(line, shallow, shallowLineLen) + hash, err := r.decodeLine(line, shallow) if err != nil { return err } @@ -58,7 +53,7 @@ func (r *ShallowUpdate) decodeShallowLine(line []byte) error { } func (r *ShallowUpdate) decodeUnshallowLine(line []byte) error { - hash, err := r.decodeLine(line, unshallow, unshallowLineLen) + hash, err := r.decodeLine(line, unshallow) if err != nil { return err } @@ -67,25 +62,24 @@ func (r *ShallowUpdate) decodeUnshallowLine(line []byte) error { return nil } -func (r *ShallowUpdate) decodeLine(line, prefix []byte, expLen int) (plumbing.Hash, error) { - if len(line) != expLen { - return plumbing.ZeroHash, fmt.Errorf("malformed %s%q", prefix, line) +func (r *ShallowUpdate) decodeLine(line, prefix []byte) (plumbing.Hash, error) { + hash, ok := parseFullHash(string(line[len(prefix):])) + if !ok { + return plumbing.ZeroHash, fmt.Errorf("malformed shallow update line: %q", line) } - - raw := string(line[expLen-40 : expLen]) - return plumbing.NewHash(raw), nil + return hash, nil } // Encode writes the shallow update to the writer. func (r *ShallowUpdate) Encode(w io.Writer) error { for _, h := range r.Shallows { - if _, err := pktline.Writef(w, "%s%s\n", shallow, h.String()); err != nil { + if _, err := pktline.Writef(w, "%s%s", shallow, h.String()); err != nil { return err } } for _, h := range r.Unshallows { - if _, err := pktline.Writef(w, "%s%s\n", unshallow, h.String()); err != nil { + if _, err := pktline.Writef(w, "%s%s", unshallow, h.String()); err != nil { return err } } diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/protocol/packp/sideband/demux.go b/vendor/github.com/go-git/go-git/v6/plumbing/protocol/packp/sideband/demux.go index 9df8f5f12b..367054794a 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/protocol/packp/sideband/demux.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/protocol/packp/sideband/demux.go @@ -37,9 +37,12 @@ type Demuxer struct { s *pktline.Scanner max int - pending []byte + pending []byte // rest of the current packet; aliases the scanner buffer + err error // first error returned by Read - // Progress is where the progress messages are stored + // Progress is where the progress messages are stored. A message is + // written with its control characters masked, as the server chooses them + // and the writer is usually a terminal; see sanitize. Progress Progress } @@ -67,13 +70,22 @@ func NewDemuxer(t Type, r io.Reader) *Demuxer { // // Read will return io.EOF when a flush packet is received after reading all // the PackData channel data. +// +// After Read returns an error, including io.EOF, later calls return the same +// error without reading from the underlying reader, so any data following +// the flush-pkt is left unread. func (d *Demuxer) Read(b []byte) (read int, err error) { + if d.err != nil { + return 0, d.err + } + req := len(b) for read < req { n, err := d.doRead(b[read:req]) read += n if err != nil { + d.err = err return read, err } } @@ -82,28 +94,22 @@ func (d *Demuxer) Read(b []byte) (read int, err error) { } func (d *Demuxer) doRead(b []byte) (int, error) { - read, err := d.nextPackData() - size := len(read) - wanted := len(b) - - if size > wanted { - d.pending = bytes.Clone(read[wanted:]) + if len(d.pending) > 0 { + n := copy(b, d.pending) + d.pending = d.pending[n:] + return n, nil } - if wanted > size { - wanted = size - } + read, err := d.nextPackData() + n := copy(b, read) + // The scanner keeps read valid until its next Scan, which happens only + // once pending is drained, so the rest of the packet is not copied. + d.pending = read[n:] - size = copy(b, read[:wanted]) - return size, err + return n, err } func (d *Demuxer) nextPackData() ([]byte, error) { - content := d.getPending() - if len(content) != 0 { - return content, nil - } - if !d.s.Scan() { if err := d.s.Err(); err != nil { return nil, err @@ -118,7 +124,7 @@ func (d *Demuxer) nextPackData() ([]byte, error) { return nil, ErrMaxPackedExceeded } - content = d.s.Bytes() + content := d.s.Bytes() if len(content) < 1 { return nil, fmt.Errorf("invalid sideband pktline %04x %q", l, content) } @@ -128,25 +134,91 @@ func (d *Demuxer) nextPackData() ([]byte, error) { return content[1:], nil case ProgressMessage: if d.Progress != nil { - _, err := d.Progress.Write(content[1:]) + _, err := d.Progress.Write(sanitize(content[1:], true)) return nil, err } case ErrorMessage: - return nil, fmt.Errorf("unexpected error: %s", content[1:]) + return nil, fmt.Errorf("unexpected error: %s", sanitize(content[1:], false)) default: - return nil, fmt.Errorf("unknown channel %s", content) + return nil, fmt.Errorf("unknown channel %s", sanitize(content, false)) } return nil, nil } -func (d *Demuxer) getPending() (b []byte) { - if len(d.pending) == 0 { - return nil +const ( + asciiESC = 0x1b + asciiDEL = 0x7f +) + +// sanitize returns message with terminal control sequences neutralised, so +// that text from the progress and error channels is safe to print. Carriage +// return is kept only when keepCR is true. It returns message itself when +// nothing needs changing. +// +// Tab, line feed and color sequences pass through, as hooks commonly color +// their output and a color sequence cannot move the cursor, erase text or +// reach the terminal's input. Every other control character is written in +// caret notation, "^[" for an escape, so that it shows up instead of +// taking effect. Bytes from 0x80 up are left alone: they are what UTF-8 +// text is made of. +func sanitize(message []byte, keepCR bool) []byte { + var ( + out []byte + copied int // message[:copied] is already in out + ) + + for i := 0; i < len(message); { + c := message[i] + if c == asciiESC { + if n := colorSequenceLen(message[i:]); n > 0 { + i += n + continue + } + } + isControl := c < ' ' || c == asciiDEL + if !isControl || c == '\t' || c == '\n' || (c == '\r' && keepCR) { + i++ + continue + } + + // Caret notation pairs NUL with "@", 1 to 26 with "A" to "Z" and + // so on through "_"; DEL is "?". + letter := '@' + c + if c == asciiDEL { + letter = '?' + } + + if out == nil { + out = make([]byte, 0, len(message)+len(message)/8+1) + } + if i > copied { + out = append(out, message[copied:i]...) + } + out = append(out, '^', letter) + i++ + copied = i } - content := d.pending - d.pending = nil + if out == nil { + return message + } + return append(out, message[copied:]...) +} + +// colorSequenceLen returns the length of the color sequence at the start of +// b, or 0 when b does not start with one. +// +// A color sequence (SGR) is ESC "[", parameters made of digits, ";" and +// ":", and a final "m". The parameters may be empty. +func colorSequenceLen(b []byte) int { + if len(b) < 2 || b[0] != asciiESC || b[1] != '[' { + return 0 + } - return content + afterParams := bytes.TrimLeft(b[2:], "0123456789;:") + if len(afterParams) == 0 || afterParams[0] != 'm' { + return 0 + } + return len(b) - len(afterParams) + 1 } diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/protocol/packp/sideband/muxer.go b/vendor/github.com/go-git/go-git/v6/plumbing/protocol/packp/sideband/muxer.go index 742cbb18a5..55528f57dc 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/protocol/packp/sideband/muxer.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/protocol/packp/sideband/muxer.go @@ -2,6 +2,7 @@ package sideband import ( "io" + "sync" "github.com/go-git/go-git/v6/plumbing/format/pktline" ) @@ -11,6 +12,8 @@ import ( type Muxer struct { max int w io.Writer + mu sync.Mutex + buf []byte } const chLen = 1 @@ -61,6 +64,9 @@ func (m *Muxer) WriteChannel(t Channel, p []byte) (int, error) { func (m *Muxer) doWrite(ch Channel, p []byte) (int, error) { sz := min(len(p), m.max) - _, err := pktline.Write(m.w, ch.WithPayload(p[:sz])) + m.mu.Lock() + defer m.mu.Unlock() + m.buf = append(append(m.buf[:0], byte(ch)), p[:sz]...) + _, err := pktline.Write(m.w, m.buf) return sz, err } diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/protocol/packp/ulreq_decode.go b/vendor/github.com/go-git/go-git/v6/plumbing/protocol/packp/ulreq_decode.go index 019b39f669..cf77140ac6 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/protocol/packp/ulreq_decode.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/protocol/packp/ulreq_decode.go @@ -166,12 +166,14 @@ func (req *UploadRequest) Decode(r io.Reader) error { return nil } - // After deepen , only flush-pkt is valid + // After deepen , only filter or flush-pkt is valid if req.Depth.Deepen > 0 { if bytes.HasPrefix(line, deepenSince) || bytes.HasPrefix(line, deepenReference) { return ErrDeepenMutuallyExclusive } - return decodeError("unexpected payload while expecting a flush-pkt: %q", line) + if !bytes.HasPrefix(line, filterSpec) { + return decodeError("unexpected payload while expecting a flush-pkt: %q", line) + } } // After deepen-since/deepen-not, only deepen-since/deepen-not or flush is valid if deepenRevList && bytes.HasPrefix(line, deepen) && !bytes.HasPrefix(line, deepenSince) && !bytes.HasPrefix(line, deepenReference) { @@ -179,7 +181,32 @@ func (req *UploadRequest) Decode(r io.Reader) error { } } - // Unexpected payload after shallows or wants + // filter , sent last by fetch-pack. upload-pack accepts it + // only when the first want line requested the filter capability, and + // at most once. + if bytes.HasPrefix(line, filterSpec) { + if !req.Capabilities.Supports(capability.Filter) { + return decodeError("filter capability not negotiated") + } + spec := bytes.TrimPrefix(line, filterSpec) + if len(spec) == 0 { + return decodeError("empty filter-spec") + } + req.Filter = Filter(spec) + + ok, err := nextLine() + if err != nil { + return err + } + if !ok || len(line) == 0 { + return nil + } + if bytes.HasPrefix(line, filterSpec) { + return decodeError("multiple filter-specs cannot be combined") + } + } + + // Unexpected payload after wants, shallows, deepens or filter if len(line) != 0 { return decodeError("unexpected payload while expecting a flush-pkt: %q", line) } diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/protocol/packp/ulreq_encode.go b/vendor/github.com/go-git/go-git/v6/plumbing/protocol/packp/ulreq_encode.go index a4c760ce48..e2c89755f4 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/protocol/packp/ulreq_encode.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/protocol/packp/ulreq_encode.go @@ -6,17 +6,22 @@ import ( "github.com/go-git/go-git/v6/plumbing" "github.com/go-git/go-git/v6/plumbing/format/pktline" + "github.com/go-git/go-git/v6/plumbing/protocol/capability" ) // Encode writes the UlReq encoding of u to the stream. // // All the payloads will end with a newline character. Wants and // shallows are sorted alphabetically. A depth of 0 means no depth -// request is sent. +// request is sent. A non-empty Filter requires the filter capability +// in Capabilities. func (req *UploadRequest) Encode(w io.Writer) error { if len(req.Wants) == 0 { return fmt.Errorf("empty wants provided") } + if req.Filter != "" && !req.Capabilities.Supports(capability.Filter) { + return fmt.Errorf("filter %q set without the filter capability", req.Filter) + } plumbing.HashesSort(req.Wants) diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/reference.go b/vendor/github.com/go-git/go-git/v6/plumbing/reference.go index 0e36798aa7..eda832a4e7 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/reference.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/reference.go @@ -278,28 +278,21 @@ var ctrlSeqs = regexp.MustCompile(`[\000-\037\177]`) // This functions does not support the --refspec-pattern, --normalize, and // --allow-onelevel options. // -// Git imposes the following rules on how references are named: +// The rules, numbered as in git-check-ref-format(1) so that the code below can +// refer to them: // -// 1. They can include slash / for hierarchical (directory) grouping, but no -// slash-separated component can begin with a dot . or end with the -// sequence .lock. -// 2. They must contain at least one /. This enforces the presence of a -// category like heads/, tags/ etc. but the actual names are not -// restricted. If the --allow-onelevel option is used, this rule is -// waived. -// 3. They cannot have two consecutive dots .. anywhere. -// 4. They cannot have ASCII control characters (i.e. bytes whose values are -// lower than \040, or \177 DEL), space, tilde ~, caret ^, or colon : +// 1. No component, as separated by "/", starts with "." or ends with ".lock". +// 2. The name has at least one "/", so that it sits in a category such as +// heads/ or tags/. +// 3. No ".." anywhere. +// 4. No ASCII control character (below 0x20, or DEL), space, "~", "^" or ":" // anywhere. -// 5. They cannot have question-mark ?, asterisk *, or open bracket [ -// anywhere. See the --refspec-pattern option below for an exception to this -// rule. -// 6. They cannot begin or end with a slash / or contain multiple consecutive -// slashes (see the --normalize option below for an exception to this rule). -// 7. They cannot end with a dot .. -// 8. They cannot contain a sequence @{. -// 9. They cannot be the single character @. -// 10. They cannot contain a \. +// 5. No "?", "*" or "[" anywhere. +// 6. No leading or trailing "/", and no empty component. +// 7. No trailing ".". +// 8. No "@{" anywhere. +// 9. Not the name "@" by itself. +// 10. No backslash anywhere. // // A leading "-" is not among them, and neither is a component spelled "@". // Git restricts a leading "-" when a branch or a tag is created, in diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/revlist/object_walk.go b/vendor/github.com/go-git/go-git/v6/plumbing/revlist/object_walk.go index 1012bc1d53..db51590d6d 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/revlist/object_walk.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/revlist/object_walk.go @@ -3,6 +3,7 @@ package revlist import ( "errors" "fmt" + "slices" "sort" "github.com/go-git/go-git/v6/plumbing" @@ -19,8 +20,14 @@ type objectWalk struct { havesQueue []*object.Commit wantsSeen map[plumbing.Hash]struct{} havesSeen map[plumbing.Hash]struct{} - seen map[plumbing.Hash]struct{} - result []plumbing.Hash + // seen holds objects that are already in result or excluded by the + // haves side (haves tips and edge parents), with the type they were + // seen as: their own for commits and tags, the one their tree entry + // mode implies for trees and blobs. A seen tree is never walked + // again: everything below it is seen too, or could not be read. + // Anything that adds a tree here must uphold this. + seen map[plumbing.Hash]plumbing.ObjectType + result []plumbing.Hash } func newObjectWalk(s storer.EncodedObjectStorer) (*objectWalk, error) { @@ -34,7 +41,7 @@ func newObjectWalk(s storer.EncodedObjectStorer) (*objectWalk, error) { shallows: shallows, wantsSeen: make(map[plumbing.Hash]struct{}), havesSeen: make(map[plumbing.Hash]struct{}), - seen: make(map[plumbing.Hash]struct{}), + seen: make(map[plumbing.Hash]plumbing.ObjectType), }, nil } @@ -87,7 +94,7 @@ func (w *objectWalk) seedWants(wants []plumbing.Hash) error { if err != nil { return fmt.Errorf("decoding tag %s: %w", h, err) } - w.seen[tag.Hash] = struct{}{} + w.seen[tag.Hash] = plumbing.TagObject w.result = append(w.result, tag.Hash) wants = append(wants, tag.Target) case plumbing.TreeObject: @@ -99,7 +106,7 @@ func (w *objectWalk) seedWants(wants []plumbing.Hash) error { return err } case plumbing.BlobObject: - w.seen[h] = struct{}{} + w.seen[h] = plumbing.BlobObject w.result = append(w.result, h) default: return fmt.Errorf("unsupported object type %s for %s", o.Type(), h) @@ -110,7 +117,7 @@ func (w *objectWalk) seedWants(wants []plumbing.Hash) error { // seedHaves enqueues each have commit and pre-populates seen with all // tree/blob objects reachable from the haves tips. Non-commit objects -// (tags, trees, blobs) are marked as seen so the diff walk skips them. +// (tags, trees, blobs) are marked as seen so the tree walk skips them. // Missing objects (ErrObjectNotFound) are tolerated since the remote // may advertise refs we don't have locally. func (w *objectWalk) seedHaves(haves []plumbing.Hash) error { @@ -147,14 +154,14 @@ func (w *objectWalk) seedHaves(haves []plumbing.Hash) error { if err != nil { return fmt.Errorf("decoding haves tag %s: %w", h, err) } - w.seen[tag.Hash] = struct{}{} + w.seen[tag.Hash] = plumbing.TagObject haves = append(haves, tag.Target) case plumbing.TreeObject: if t, err := object.GetTree(w.s, h); err == nil { markTreeSeen(w.s, t, w.seen) } case plumbing.BlobObject: - w.seen[h] = struct{}{} + w.seen[h] = plumbing.BlobObject } } return nil @@ -180,16 +187,15 @@ func (w *objectWalk) walk() error { // propagate to parents. A commit painted from both sides is a // boundary. The walk stops when all queue entries are boundaries // (all stale), so only the overlap region is traversed. - flags := make(map[plumbing.Hash]uint8) - var queue []*object.Commit + q := newPaintQueue() for _, c := range w.wantsQueue { - flags[c.Hash] |= wantPaint - insertSorted(&queue, c) + q.paint(c.Hash, wantPaint) + q.push(c) } for _, c := range w.havesQueue { - flags[c.Hash] |= havePaint - insertSorted(&queue, c) + q.paint(c.Hash, havePaint) + q.push(c) } w.wantsQueue = nil w.havesQueue = nil @@ -197,11 +203,10 @@ func (w *objectWalk) walk() error { var newCommits []*object.Commit var missing []missingParent - for len(queue) > 0 { - lc := queue[0] - queue = queue[1:] - - f := flags[lc.Hash] + // Once every queued entry is stale, no new commits can be + // discovered. + for q.active > 0 { + lc, f := q.pop() // Want-only commit — tentatively new. if f == wantPaint { @@ -210,16 +215,10 @@ func (w *objectWalk) walk() error { // Propagate this commit's flags to parents. if _, shallow := w.shallows[lc.Hash]; !shallow { - if err := w.propagate(&queue, flags, &missing, lc, f); err != nil { + if err := w.propagate(q, &missing, lc, f); err != nil { return err } } - - // If all remaining queue entries have both flags, no new - // commits can be discovered — stop early. - if allStale(queue, flags) { - break - } } // Validate recorded missing parents now that all paint has settled. @@ -229,25 +228,64 @@ func (w *objectWalk) walk() error { // walk terminated). Otherwise the want side references history we // cannot traverse — match Git's behavior and error. for _, mp := range missing { - if flags[mp.child]&havePaint != 0 { + if q.flags[mp.child]&havePaint != 0 { continue } return fmt.Errorf("commit %s has missing parent %s", mp.child, mp.hash) } - // Phase 2: collect tree objects for new commits, skipping any - // that were painted by haves after being added to newCommits. + // Phase 2: drop new commits that were painted by haves after being + // added. Then, like Git's mark_edges_uninteresting, mark the trees + // of all edge parents (parents of new commits painted by haves) as + // seen before collecting any new tree, so that objects moved or + // copied from them are not sent. Shallow commits have no parents + // here, as with Git's grafts. + newCommits = slices.DeleteFunc(newCommits, func(c *object.Commit) bool { + return q.flags[c.Hash]&havePaint != 0 + }) for _, lc := range newCommits { - if flags[lc.Hash]&havePaint != 0 { + if _, shallow := w.shallows[lc.Hash]; shallow { continue } - if err := w.processCommitTrees(lc); err != nil { + for _, ph := range lc.ParentHashes { + if q.flags[ph]&havePaint == 0 { + continue + } + if err := w.markEdgeTreeSeen(ph); err != nil { + return err + } + } + } + for _, lc := range newCommits { + if err := w.collectCommit(lc); err != nil { return err } } return nil } +// markEdgeTreeSeen marks the tree of edge parent h as seen. A missing +// edge parent is tolerated, as it may be beyond the haves boundary, but +// the root tree of one that is present must be readable. +func (w *objectWalk) markEdgeTreeSeen(h plumbing.Hash) error { + c, err := object.GetCommit(w.s, h) + if err != nil { + if errors.Is(err, plumbing.ErrObjectNotFound) { + return nil + } + return fmt.Errorf("getting parent commit %s: %w", h, err) + } + if _, ok := w.seen[c.TreeHash]; ok { + return nil // shared with an edge already marked + } + t, err := c.Tree() + if err != nil { + return fmt.Errorf("getting parent tree for %s: %w", h, err) + } + markTreeSeen(w.s, t, w.seen) + return nil +} + // missingParent records a parent commit that could not be loaded during // the painted walk, along with the child from which it was reached. // Validation is deferred until the walk completes so that havePaint @@ -264,13 +302,11 @@ type missingParent struct { // walk, where we can tell whether the child was eventually painted by // haves (in which case the missing parent is behind the haves boundary // and tolerable, matching Git's behavior). -func (w *objectWalk) propagate(queue *[]*object.Commit, flags map[plumbing.Hash]uint8, missing *[]missingParent, lc *object.Commit, f uint8) error { +func (w *objectWalk) propagate(q *paintQueue, missing *[]missingParent, lc *object.Commit, f uint8) error { for _, ph := range lc.ParentHashes { - pf := flags[ph] - if pf|f == pf { + if !q.paint(ph, f) { continue // parent already has all our flags } - flags[ph] = pf | f pc, err := object.GetCommit(w.s, ph) if err != nil { @@ -280,26 +316,79 @@ func (w *objectWalk) propagate(queue *[]*object.Commit, flags map[plumbing.Hash] } return fmt.Errorf("getting parent commit %s: %w", ph, err) } - insertSorted(queue, pc) + q.push(pc) } return nil } -// allStale returns true when every commit in the queue has both paint -// flags, meaning all remaining commits are boundaries and no new -// commits can be discovered. -func allStale(queue []*object.Commit, flags map[plumbing.Hash]uint8) bool { - for _, c := range queue { - if flags[c.Hash]&wantPaint == 0 || flags[c.Hash]&havePaint == 0 { - return false - } +// paintQueue is the priority queue of the painted commit walk. It holds +// the paint flags of every commit reached so far and counts the queued +// entries that are not yet stale, so the walk can tell when to stop +// without rescanning the queue. A commit may be queued more than once, +// and its flags may change while it is queued. +type paintQueue struct { + commits []*object.Commit + flags map[plumbing.Hash]uint8 + // queued is the number of entries in commits for each hash. + queued map[plumbing.Hash]int + // active is the number of entries in commits whose commit is not + // stale. + active int +} + +func newPaintQueue() *paintQueue { + return &paintQueue{ + flags: make(map[plumbing.Hash]uint8), + queued: make(map[plumbing.Hash]int), + } +} + +// stale reports whether f marks a commit reachable from both wants and +// haves. +func stale(f uint8) bool { + return f&(wantPaint|havePaint) == wantPaint|havePaint +} + +// paint adds f to the flags of h and reports whether they changed. +func (q *paintQueue) paint(h plumbing.Hash, f uint8) bool { + old := q.flags[h] + if old|f == old { + return false + } + q.flags[h] = old | f + if !stale(old) && stale(old|f) { + q.active -= q.queued[h] } return true } -// walkFull is the fast path when there are no haves. It walks all -// commits and collects every reachable tree/blob via a simple seen-set -// traversal — no per-commit tree diffs needed. +// push queues c, ordered by committer time. +func (q *paintQueue) push(c *object.Commit) { + insertSorted(&q.commits, c) + q.queued[c.Hash]++ + if !stale(q.flags[c.Hash]) { + q.active++ + } +} + +// pop removes the newest commit from the queue and returns it with its +// current flags. +func (q *paintQueue) pop() (*object.Commit, uint8) { + c := q.commits[0] + q.commits = q.commits[1:] + if q.queued[c.Hash]--; q.queued[c.Hash] == 0 { + delete(q.queued, c.Hash) + } + f := q.flags[c.Hash] + if !stale(f) { + q.active-- + } + return c, f +} + +// walkFull is the fast path when there are no haves. It walks every +// commit reachable from the wants and collects all of their trees and +// blobs, without painting. func (w *objectWalk) walkFull() error { for len(w.wantsQueue) > 0 { lc := w.wantsQueue[0] @@ -308,16 +397,8 @@ func (w *objectWalk) walkFull() error { if _, ok := w.seen[lc.Hash]; ok { continue } - w.seen[lc.Hash] = struct{}{} - w.result = append(w.result, lc.Hash) - - tree, err := lc.Tree() - if err != nil { - return fmt.Errorf("getting tree for %s: %w", lc.Hash, err) - } - - if err := collectAllTreeObjects(w.s, tree, w.seen, &w.result); err != nil { - return fmt.Errorf("collecting tree objects for %s: %w", lc.Hash, err) + if err := w.collectCommit(lc); err != nil { + return err } if _, ok := w.shallows[lc.Hash]; ok { @@ -339,37 +420,21 @@ func (w *objectWalk) walkFull() error { return nil } -// processCommitTrees collects new tree/blob objects for a commit by -// diffing its tree against its parents' trees. -func (w *objectWalk) processCommitTrees(lc *object.Commit) error { +// collectCommit adds lc and every tree and blob reachable from it that +// is not already seen to the result. +func (w *objectWalk) collectCommit(lc *object.Commit) error { if _, ok := w.seen[lc.Hash]; !ok { - w.seen[lc.Hash] = struct{}{} + w.seen[lc.Hash] = plumbing.CommitObject w.result = append(w.result, lc.Hash) } - newTree, err := lc.Tree() + tree, err := lc.Tree() if err != nil { return fmt.Errorf("getting tree for %s: %w", lc.Hash, err) } - var oldTrees []*object.Tree - for i := 0; i < lc.NumParents(); i++ { - parent, err := lc.Parent(i) - if err != nil { - if errors.Is(err, plumbing.ErrObjectNotFound) { - continue // parent may be beyond haves boundary - } - return fmt.Errorf("getting parent commit %s: %w", lc.ParentHashes[i], err) - } - pt, err := parent.Tree() - if err != nil { - return fmt.Errorf("getting parent tree for %s: %w", parent.Hash, err) - } - oldTrees = append(oldTrees, pt) - } - - if err := collectChangedTreeObjects(w.s, newTree, oldTrees, w.seen, &w.result); err != nil { - return fmt.Errorf("diffing trees for %s: %w", lc.Hash, err) + if err := collectAllTreeObjects(w.s, tree, w.seen, &w.result); err != nil { + return fmt.Errorf("collecting tree objects for %s: %w", lc.Hash, err) } return nil @@ -386,114 +451,35 @@ func insertSorted(q *[]*object.Commit, c *object.Commit) { (*q)[i] = c } -// collectChangedTreeObjects walks newTree, comparing entry hashes against -// all oldTrees. An entry is considered unchanged if any old tree contains the -// same name with the same hash. Only new or modified tree and blob hashes are -// added to result. -func collectChangedTreeObjects( - s storer.EncodedObjectStorer, - newTree *object.Tree, - oldTrees []*object.Tree, - seen map[plumbing.Hash]struct{}, - result *[]plumbing.Hash, -) error { - // If newTree matches any old tree exactly, nothing changed. - for _, ot := range oldTrees { - if newTree.Hash == ot.Hash { - return nil - } - } - - if _, ok := seen[newTree.Hash]; !ok { - seen[newTree.Hash] = struct{}{} - *result = append(*result, newTree.Hash) - } - - // Build per-parent entry indexes for O(1) lookup. - oldEntryMaps := make([]map[string]plumbing.Hash, len(oldTrees)) - for i, ot := range oldTrees { - oldEntryMaps[i] = make(map[string]plumbing.Hash, len(ot.Entries)) - for _, e := range ot.Entries { - oldEntryMaps[i][e.Name] = e.Hash - } - } - - for _, e := range newTree.Entries { - // Skip blobs we've already collected. Directories are not skipped - // here — a tree hash being "seen" means the hash itself was added - // to the result, but a prior diff-walk may not have collected all - // of its children. The recursive call handles dedup for trees. - if e.Mode != filemode.Dir { - if _, ok := seen[e.Hash]; ok { - continue - } - } - if e.Mode == filemode.Submodule { - continue - } - - // If same name has same hash in any parent tree, unchanged—skip. - unchanged := false - for _, m := range oldEntryMaps { - if oh, ok := m[e.Name]; ok && oh == e.Hash { - unchanged = true - break - } - } - if unchanged { - continue - } - - if e.Mode == filemode.Dir { - // Recurse into changed subtree. Collect the old versions of - // this subtree from all parents that have it. - newSub, err := object.GetTree(s, e.Hash) - if err != nil { - return fmt.Errorf("getting subtree %s: %w", e.Hash, err) - } - var oldSubs []*object.Tree - for _, m := range oldEntryMaps { - if oh, ok := m[e.Name]; ok { - if ot, err := object.GetTree(s, oh); err == nil { - oldSubs = append(oldSubs, ot) - } - } - } - if err := collectChangedTreeObjects(s, newSub, oldSubs, seen, result); err != nil { - return err - } - } else { - seen[e.Hash] = struct{}{} - *result = append(*result, e.Hash) - } - } - - return nil -} - // collectAllTreeObjects recursively walks a tree, adding all unseen -// tree and blob hashes to result. This is faster than collectChangedTreeObjects -// when we need all objects (no haves to diff against). +// tree and blob hashes to result. A seen tree is skipped without +// descending into it, as all of its contents are seen as well. An +// object seen as a tree and used as a blob, or the other way around, +// fails with plumbing.ErrInvalidType, as it does in Git. func collectAllTreeObjects( s storer.EncodedObjectStorer, t *object.Tree, - seen map[plumbing.Hash]struct{}, + seen map[plumbing.Hash]plumbing.ObjectType, result *[]plumbing.Hash, ) error { - if _, ok := seen[t.Hash]; ok { - return nil + if typ, ok := seen[t.Hash]; ok { + return checkSeenType(t.Hash, typ, plumbing.TreeObject) } - seen[t.Hash] = struct{}{} + seen[t.Hash] = plumbing.TreeObject *result = append(*result, t.Hash) for _, e := range t.Entries { if e.Mode == filemode.Submodule { continue } - if _, ok := seen[e.Hash]; ok { + typ := entryType(e.Mode) + if seenTyp, ok := seen[e.Hash]; ok { + if err := checkSeenType(e.Hash, seenTyp, typ); err != nil { + return err + } continue } - if e.Mode == filemode.Dir { + if typ == plumbing.TreeObject { sub, err := object.GetTree(s, e.Hash) if err != nil { return fmt.Errorf("getting subtree %s: %w", e.Hash, err) @@ -502,21 +488,25 @@ func collectAllTreeObjects( return err } } else { - seen[e.Hash] = struct{}{} + seen[e.Hash] = plumbing.BlobObject *result = append(*result, e.Hash) } } return nil } -// markTreeSeen recursively adds all tree and blob hashes in t to seen. -// Objects added to seen are not added to result — this is used to mark -// haves-reachable objects so they are skipped during diff walks. -func markTreeSeen(s storer.EncodedObjectStorer, t *object.Tree, seen map[plumbing.Hash]struct{}) { +// markTreeSeen adds t and every tree and blob below it to seen, without +// adding them to result. It excludes the objects reachable from haves +// tips and edge parents. As Git's mark_tree_uninteresting does for edge +// parents, a subtree that cannot be read is still marked by hash, but +// not descended into, so it is neither read nor sent when a want +// references it. An object already seen as another type keeps that +// type, so collectAllTreeObjects reports the conflict if a want uses it. +func markTreeSeen(s storer.EncodedObjectStorer, t *object.Tree, seen map[plumbing.Hash]plumbing.ObjectType) { if _, ok := seen[t.Hash]; ok { return } - seen[t.Hash] = struct{}{} + seen[t.Hash] = plumbing.TreeObject for _, e := range t.Entries { if e.Mode == filemode.Submodule { continue @@ -524,12 +514,35 @@ func markTreeSeen(s storer.EncodedObjectStorer, t *object.Tree, seen map[plumbin if _, ok := seen[e.Hash]; ok { continue } - if e.Mode == filemode.Dir { - if sub, err := object.GetTree(s, e.Hash); err == nil { - markTreeSeen(s, sub, seen) + typ := entryType(e.Mode) + if typ == plumbing.TreeObject { + sub, err := object.GetTree(s, e.Hash) + if err != nil { + seen[e.Hash] = plumbing.TreeObject + continue } + markTreeSeen(s, sub, seen) } else { - seen[e.Hash] = struct{}{} + seen[e.Hash] = plumbing.BlobObject } } } + +// entryType returns the object type a tree entry with mode m refers to. +// Submodule entries refer to commits in another repository and are +// skipped by the callers. +func entryType(m filemode.FileMode) plumbing.ObjectType { + if m == filemode.Dir { + return plumbing.TreeObject + } + return plumbing.BlobObject +} + +// checkSeenType returns an error when h, seen as type seen, is used as +// type used. +func checkSeenType(h plumbing.Hash, seen, used plumbing.ObjectType) error { + if seen == used { + return nil + } + return fmt.Errorf("%w: %s is used as both a %s and a %s", plumbing.ErrInvalidType, h, seen, used) +} diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/revlist/revlist.go b/vendor/github.com/go-git/go-git/v6/plumbing/revlist/revlist.go index 845563b1ce..9ba3f03cba 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/revlist/revlist.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/revlist/revlist.go @@ -16,6 +16,14 @@ type objectWalker interface { // Objects computes object hashes reachable from wants while excluding // commits reachable from haves. // +// The built-in walk also excludes every tree and blob reachable from the +// tree of each have commit, and from the tree of each edge commit: one +// reachable from haves that is a parent of a commit it returns. +// git rev-list --objects excludes only the edge commits' trees +// (mark_edges_uninteresting in Git's list-objects.c), so the result can be +// a subset of Git's, but it never lacks an object a client with those +// haves needs: their full trees are already on the client. +// // If s implements objectWalker, its RevListObjects method is used. // Otherwise, Objects expands haves first to establish commit boundaries, // then walks wants in the same object store. @@ -27,11 +35,68 @@ func Objects( if walker, ok := s.(objectWalker); ok { return walker.RevListObjects(wants, haves) } + return walkObjects(s, wants, haves, nil) +} + +// ShallowObjectWalker is implemented by storers that walk objects for +// ObjectsWithShallows themselves and can bound the walk at shallow commits. +// +// RevListObjectsWithShallows returns the hashes of the objects reachable +// from wants, the commits to send, excluding those reachable from haves, +// the commits the client already has. Each of shallows is treated as a +// shallow commit: the commit and its tree are included, its parents are +// not walked. A shallow commit reachable from haves is still excluded, as +// upstream does for commits the client has unshallowed. shallows come on +// top of the storer's own shallow commits, +// which must still bound the walk, and they bound the walk from haves as +// well as the walk from wants; the built-in walk does both, as upstream's +// graft set does. A walker that applied shallows to the wants alone would +// walk the haves past the shallow commits and withhold history the +// client lacks. Hashes in shallows that are missing or not commits are +// ignored. +// +// To fall back, an implementation calls ObjectsWithShallows on the inner +// storer it wraps, never on itself: that dispatches back to the method +// and recurses until the stack overflows. The same holds for Objects and +// a storer that has RevListObjects. A storer without this method gets the +// built-in walk. +type ShallowObjectWalker interface { + RevListObjectsWithShallows(wants, haves, shallows []plumbing.Hash) ([]plumbing.Hash, error) +} +// ObjectsWithShallows is Objects with each of shallows also treated as a +// shallow commit, on top of s's own: its parents are not walked, from the +// wants or from the haves. A shallow fetch's new boundary is passed this +// way. +// +// If s implements ShallowObjectWalker, its RevListObjectsWithShallows +// method is used. Otherwise the built-in walk is used, because +// RevListObjects cannot see shallows. With no shallows it is Objects. +func ObjectsWithShallows( + s storer.EncodedObjectStorer, + wants, + haves, + shallows []plumbing.Hash, +) ([]plumbing.Hash, error) { + if len(shallows) == 0 { + return Objects(s, wants, haves) + } + if walker, ok := s.(ShallowObjectWalker); ok { + return walker.RevListObjectsWithShallows(wants, haves, shallows) + } + return walkObjects(s, wants, haves, shallows) +} + +// walkObjects is the built-in walk of Objects, with shallows treated as +// shallow commits on top of s's own. +func walkObjects(s storer.EncodedObjectStorer, wants, haves, shallows []plumbing.Hash) ([]plumbing.Hash, error) { w, err := newObjectWalk(s) if err != nil { return nil, err } + for _, h := range shallows { + w.shallows[h] = struct{}{} + } if err := w.seedHaves(haves); err != nil { return nil, err } diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/storer/object.go b/vendor/github.com/go-git/go-git/v6/plumbing/storer/object.go index 840d387f02..8e65d23d2b 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/storer/object.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/storer/object.go @@ -46,6 +46,37 @@ type EncodedObjectStorer interface { AddAlternate(remote string) error } +// EncodedObjectTypeStorer is an optional interface for an +// [EncodedObjectStorer] that can tell an object's type without reading the +// object itself, as Git's odb_read_object_info does. +// +// A type that embeds a storage implementing it, such as +// *filesystem.ObjectStorage or *memory.ObjectStorage, gets its +// EncodedObjectType promoted. A wrapper that overrides EncodedObject, to hide +// or rewrite objects, must then override EncodedObjectType as well, or +// [EncodedObjectType] answers from the embedded storage and bypasses the +// override. +type EncodedObjectTypeStorer interface { + // EncodedObjectType returns the type of the object h, or + // plumbing.ErrObjectNotFound when there is no such object. + EncodedObjectType(h plumbing.Hash) (plumbing.ObjectType, error) +} + +// EncodedObjectType returns the type of the object h in s. It asks s through +// [EncodedObjectTypeStorer] when s implements it, and reads the object +// otherwise. A wrapper storage whose EncodedObject must be honoured has to +// implement EncodedObjectType too; see [EncodedObjectTypeStorer]. +func EncodedObjectType(s EncodedObjectStorer, h plumbing.Hash) (plumbing.ObjectType, error) { + if ts, ok := s.(EncodedObjectTypeStorer); ok { + return ts.EncodedObjectType(h) + } + obj, err := s.EncodedObject(plumbing.AnyObject, h) + if err != nil { + return plumbing.InvalidObject, err + } + return obj.Type(), nil +} + // DeltaObjectStorer is an EncodedObjectStorer that can return delta // objects. type DeltaObjectStorer interface { @@ -117,6 +148,22 @@ type PromisorPackfileWriter interface { PromisorPackfileWriter(marker string) (io.WriteCloser, error) } +// PackReader is an optional interface for the writer returned by +// [PackfileWriter] or [PromisorPackfileWriter]. A writer that implements it +// is given the packfile's source instead of having the packfile copied to it. +type PackReader interface { + // ReadPack reads a packfile from r and stores it as the writer's Write + // would, returning once the pack's trailing checksum has been read rather + // than when r reaches EOF. Its last read of r may take bytes past the + // trailer, which are discarded, so r is left at no particular position. + // It returns the number of bytes read from r. An empty r returns 0, nil, + // and a stream that ends before the trailer is an error. + // + // ReadPack is called at most once, instead of Write. The writer's Close + // is still called afterwards, and is what stores the pack. + ReadPack(r io.Reader) (n int64, err error) +} + // PromisorObjectStorer is an optional interface for ObjectStorer // implementations that track which packs came from a promisor remote. // diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/transport/common.go b/vendor/github.com/go-git/go-git/v6/plumbing/transport/common.go index 3d169e0b9a..eb6207b7a2 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/transport/common.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/transport/common.go @@ -26,9 +26,10 @@ func (f DialContextFunc) DialContext(ctx context.Context, network, addr string) } // RemoteError represents an error returned by the remote. -// TODO: embed error type RemoteError struct { Reason string + + err error } // Error implements the error interface. @@ -36,6 +37,11 @@ func (e *RemoteError) Error() string { return e.Reason } +// Unwrap returns the local error the remote's stderr explains, if any. +func (e *RemoteError) Unwrap() error { + return e.err +} + // NewRemoteError creates a new RemoteError. func NewRemoteError(reason string) error { return &RemoteError{Reason: reason} diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/transport/errors.go b/vendor/github.com/go-git/go-git/v6/plumbing/transport/errors.go index 92bba3319b..0edfc1a3ef 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/transport/errors.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/transport/errors.go @@ -21,6 +21,14 @@ var ( ErrInvalidRequest = errors.New("invalid request") ) +// ErrPackJunk is returned by a fetch, through [FetchPack] or a v2 +// [Session.Fetch], when the storage leaves pack data unread after the pack +// trailer. The pack is already stored by then. Git's outcome for such data +// depends on how it unpacks the pack, and the check is best effort: the +// fetch reports only junk the storage left unread, so small junk can go +// unnoticed. See [FetchPack]. +var ErrPackJunk = internal.ErrPackJunk + // Transport capability and support errors. var ( ErrConnectUnsupported = errors.New("transport does not support raw connections") @@ -70,6 +78,17 @@ type CredentialsDroppedError struct { func (e *CredentialsDroppedError) Error() string { return fmt.Sprintf( "credentials for %s were not sent to %s because a redirect crossed an origin boundary", - e.From, e.To, + originString(e.From), originString(e.To), ) } + +// originString renders u, or "" when u is nil. Passing a nil *url.URL to +// fmt directly would rely on fmt recovering the nil dereference in +// (*url.URL).String, and on Windows the hardware fault behind that can +// corrupt the heap (golang/go#81238). +func originString(u *url.URL) string { + if u == nil { + return "" + } + return u.String() +} diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/transport/fetch.go b/vendor/github.com/go-git/go-git/v6/plumbing/transport/fetch.go index 89f96a135c..ec81ea683c 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/transport/fetch.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/transport/fetch.go @@ -4,6 +4,7 @@ import ( "context" "io" + internal "github.com/go-git/go-git/v6/internal/transport" "github.com/go-git/go-git/v6/plumbing/format/packfile" "github.com/go-git/go-git/v6/plumbing/protocol/capability" "github.com/go-git/go-git/v6/plumbing/protocol/packp" @@ -13,6 +14,20 @@ import ( ) // FetchPack fetches a packfile from the remote into the given storage. +// +// caps must be the capabilities the fetch was negotiated with: as +// [NegotiatePack] requests side-band only when req.Progress is set, packf is +// read as multiplexed only when caps support side-band and req.Progress is +// non-nil. A multiplexed response is read up to its closing flush-pkt, and +// an error the remote sends on the error band, even after the pack, fails +// the fetch. So does pack data the storage left unread after the pack +// trailer, with [ErrPackJunk], although the pack is then already stored. +// Otherwise packf may be left unread past the pack trailer. +// +// FetchPack closes packf before it returns, whether or not the fetch fails, +// unless cancelling ctx ended a read of packf. That read may still be +// blocked, so packf is then left open, and the caller should tie it to ctx so +// that cancelling ctx also closes it. func FetchPack( ctx context.Context, st storage.Storer, @@ -21,6 +36,15 @@ func FetchPack( shallowInfo *packp.ShallowUpdate, req *FetchRequest, ) error { + // Git dies on a bad shallow line before it reads the pack, so a rejected + // update stores nothing. + if shallowInfo != nil { + if err := internal.CheckShallowUpdate(st, shallowInfo); err != nil { + _ = packf.Close() + return err + } + } + packf = ioutil.NewContextReadCloser(ctx, packf) var demuxer *sideband.Demuxer @@ -31,7 +55,10 @@ func FetchPack( demuxer = sideband.NewDemuxer(sideband.Sideband, reader) } - if demuxer != nil && req.Progress != nil { + // Sideband is only requested when there is progress to report (see + // NegotiatePack), so only then is the response muxed. + muxed := demuxer != nil && req.Progress != nil + if muxed { demuxer.Progress = req.Progress reader = demuxer } @@ -46,51 +73,37 @@ func FetchPack( // repacking (repack-promisor.c), and accepts either, because only the // file's presence is ever consulted — packfile.c tests it with access(2) // and never opens it. + var err error if req.Filter != "" { - if err := packfile.UpdatePromisorObjectStorage(st, reader, ""); err != nil { - return err - } - } else if err := packfile.UpdateObjectStorage(st, reader); err != nil { - return err + err = packfile.UpdatePromisorObjectStorage(st, reader, "") + } else { + err = packfile.UpdateObjectStorage(st, reader) } - if err := packf.Close(); err != nil { - return err + // Storage that parses the pack stops reading at its trailer, so read the + // rest of the response here: an error the server sends after the pack + // must fail the fetch, as must pack data after it, and trailing progress + // must reach the caller. The demuxer stops at the closing flush-pkt; an + // unmuxed response has no end marker, so reading on would wait for the + // server to close. + if err == nil && muxed { + err = internal.DrainPackSection(demuxer) } - if shallowInfo != nil { - if err := updateShallow(st, shallowInfo); err != nil { - return err - } + // A read the context cancelled may still be blocked in the goroutine + // NewContextReadCloser started, and closing packf would race it. + if internal.ReadFinished(ctx, err) { + ioutil.CheckClose(packf, &err) } - - return nil -} - -func updateShallow(st storage.Storer, shallowInfo *packp.ShallowUpdate) error { - shallows, err := st.Shallow() if err != nil { return err } -outer: - for _, s := range shallowInfo.Shallows { - for _, oldS := range shallows { - if s == oldS { - continue outer - } - } - shallows = append(shallows, s) - } - - for _, s := range shallowInfo.Unshallows { - for i, oldS := range shallows { - if s == oldS { - shallows = append(shallows[:i], shallows[i+1:]...) - break - } + if shallowInfo != nil { + if err := internal.UpdateShallow(st, shallowInfo); err != nil { + return err } } - return st.SetShallow(shallows) + return nil } diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/transport/http/handshake.go b/vendor/github.com/go-git/go-git/v6/plumbing/transport/http/handshake.go index fad490643e..7f5c6f17df 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/transport/http/handshake.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/transport/http/handshake.go @@ -18,9 +18,18 @@ import ( "github.com/go-git/go-git/v6/plumbing/protocol/packp" transport "github.com/go-git/go-git/v6/plumbing/transport" "github.com/go-git/go-git/v6/storage" - "github.com/go-git/go-git/v6/utils/ioutil" ) +// maxReceivePackContentLength matches Git v2.54.0's default HTTP push framing. +// http_post_buffer holds 16 packets of LARGE_PACKET_MAX (65520 bytes each). +// rpc_read_from_out requires one packet of free space before every read, even +// the final flush, leaving (16 - 1) * 65520 bytes for a fixed-length body. +// post_rpc uses unknown-length framing for larger requests. See: +// https://github.com/git/git/blob/v2.54.0/http.c +// https://github.com/git/git/blob/v2.54.0/pkt-line.h +// https://github.com/git/git/blob/v2.54.0/remote-curl.c +const maxReceivePackContentLength = 15 * 65520 + // wrapDropped annotates err with the origin crossing that withheld credentials, // when there was a crossing, a credential to withhold, and err is an // authentication failure. The error keeps its type and message. @@ -365,14 +374,18 @@ func (s *smartPackSession) GetRemoteRefs(ctx context.Context, opts *transport.Ge if opts != nil { prefixes = opts.RefPrefixes } - refs, err := internal.LsRefs(ctx, s.Command, s.caps, prefixes) + out, err := internal.LsRefs(ctx, s.Command, s.caps, prefixes) if err != nil { return nil, err } - if !forPush && !internal.HasHashRef(refs) { + if !forPush && internal.IsEmptyLsRefs(out) { return nil, transport.ErrEmptyRemoteRepository } - return transport.NewRemoteRefs(refs), nil + rr := transport.NewRemoteRefs(out.References) + // A ref-prefix can leave HEAD's target out of the result, so take an + // unborn HEAD from ls-refs rather than inferring it from the refs. + rr.Unborn = out.UnbornHead + return rr, nil } if s.refs == nil { @@ -435,7 +448,7 @@ func (s *smartPackSession) Fetch(ctx context.Context, st storage.Storer, req *tr shallows, err := transport.NegotiatePack(ctx, st, s.caps, true, neg, neg, req) if err != nil { - if ioutil.ReadFinished(ctx, err) { + if internal.ReadFinished(ctx, err) { neg.closeResponse() } return err @@ -447,7 +460,19 @@ func (s *smartPackSession) Fetch(ctx context.Context, st storage.Storer, req *tr } } err = transport.FetchPack(ctx, st, s.caps, io.NopCloser(neg), shallows, req) - if ioutil.ReadFinished(ctx, err) { + if err == nil { + // FetchPack may stop at the pack trailer. Read the body to its end + // so that the connection can be reused, up to maxDrainSize so that + // a server that keeps sending cannot hold the fetch. A broken body + // fails the fetch, as it did when the pack was copied to EOF. + // + // The cap deliberately differs from Git: remote-curl hands every + // byte of the body to fetch-pack and so reads it to the end + // (rpc_in, remote-curl.c:828-846 at v2.54.0). Past the cap the + // response is abandoned rather than drained. + _, err = io.Copy(io.Discard, io.LimitReader(neg, maxDrainSize)) + } + if internal.ReadFinished(ctx, err) { neg.closeResponse() } return err @@ -500,7 +525,7 @@ func (s *smartPackSession) fetchV2(ctx context.Context, st storage.Storer, req * func (s *smartPackSession) Push(ctx context.Context, st storage.Storer, req *transport.PushRequest) error { rwc := &httpRequester{session: s, ctx: ctx} err := transport.SendPack(ctx, st, s.caps, rwc, io.NopCloser(rwc), req) - if ioutil.ReadFinished(ctx, err) && rwc.resp != nil { + if internal.ReadFinished(ctx, err) && rwc.resp != nil { _ = rwc.resp.Body.Close() } return err @@ -577,6 +602,9 @@ func (r *httpRequester) doPost() error { if err != nil { return err } + if r.session.service == transport.ReceivePackService && httpReq.ContentLength > maxReceivePackContentLength { + httpReq.ContentLength = -1 + } httpReq.Header.Set("Content-Type", fmt.Sprintf("application/x-%s-request", r.session.service)) httpReq.Header.Set("Accept", fmt.Sprintf("application/x-%s-result", r.session.service)) httpReq.Header.Set("User-Agent", capability.DefaultAgent()) @@ -643,7 +671,7 @@ func (n *httpNegotiator) Close() error { // altogether, so no request follows that the connection could serve. // // Whether the body was read to its end is the caller's affair. So is whether -// closing is safe at all — ioutil.ReadFinished answers that, and a caller that +// closing is safe at all. internal.ReadFinished answers that, and a caller that // does not ask races the context reader wrapped around this body. func (n *httpNegotiator) closeResponse() { if n.current != nil && n.current.resp != nil { diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/transport/negotiate.go b/vendor/github.com/go-git/go-git/v6/plumbing/transport/negotiate.go index ffa3fbf869..f56b7c4caa 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/transport/negotiate.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/transport/negotiate.go @@ -239,9 +239,13 @@ func NegotiatePack( } } - readc := make(chan error) + // The server sends its shallow-update before it reads any haves + // (upload-pack.c receive_needs), so read it first, as git's + // fetch-pack does. if !statelessRPC { - go func() { readc <- readShallows(statelessRPC, reader, req, &shallowInfo, firstRound) }() + if err := readShallows(statelessRPC, reader, req, &shallowInfo, firstRound); err != nil { + return nil, err + } } if err := uphav.Encode(writer); err != nil { @@ -255,27 +259,14 @@ func NegotiatePack( if err := readShallows(statelessRPC, reader, req, &shallowInfo, firstRound); err != nil { return nil, err } - } else { - if err := <-readc; err != nil { - return nil, err - } } - go func() { - defer close(readc) - if done || len(uphav.Haves) > 0 { - var srvrs packp.ServerResponse - if err := srvrs.Decode(reader); err != nil { - readc <- fmt.Errorf("decoding server-response: %w", err) - return - } - applyServerACKs(statelessRPC, srvrs.ACKs, common, &statelessCommon, &gotContinue, &gotReady, &inVein) + if done || len(uphav.Haves) > 0 { + var srvrs packp.ServerResponse + if err := srvrs.Decode(reader); err != nil { + return nil, fmt.Errorf("decoding server-response: %w", err) } - readc <- nil - }() - - if err := <-readc; err != nil { - return nil, err + applyServerACKs(statelessRPC, srvrs.ACKs, common, &statelessCommon, &gotContinue, &gotReady, &inVein) } if sendDoneAfterReady { break diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/transport/pack_stream.go b/vendor/github.com/go-git/go-git/v6/plumbing/transport/pack_stream.go index 3cdf440fa2..ad4261f947 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/transport/pack_stream.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/transport/pack_stream.go @@ -6,6 +6,7 @@ import ( "errors" "io" "strings" + "sync" internal "github.com/go-git/go-git/v6/internal/transport" "github.com/go-git/go-git/v6/plumbing/protocol" @@ -26,6 +27,9 @@ type StreamSession struct { version protocol.Version caps capability.List refs *packp.AdvRefs + + closeOnce sync.Once + closeErr error } // NewStreamSession creates a session from an open Conn. @@ -112,14 +116,18 @@ func (s *StreamSession) GetRemoteRefs(ctx context.Context, opts *GetRemoteRefsOp if opts != nil { prefixes = opts.RefPrefixes } - refs, err := internal.LsRefs(ctx, s.Command, s.caps, prefixes) + out, err := internal.LsRefs(ctx, s.Command, s.caps, prefixes) if err != nil { return nil, err } - if !forPush && !internal.HasHashRef(refs) { + if !forPush && internal.IsEmptyLsRefs(out) { return nil, ErrEmptyRemoteRepository } - return NewRemoteRefs(refs), nil + rr := NewRemoteRefs(out.References) + // A ref-prefix can leave HEAD's target out of the result, so take an + // unborn HEAD from ls-refs rather than inferring it from the refs. + rr.Unborn = out.UnbornHead + return rr, nil } if s.refs == nil { @@ -136,8 +144,12 @@ func (s *StreamSession) GetRemoteRefs(ctx context.Context, opts *GetRemoteRefsOp return NewRemoteRefs(refs), nil } -// Fetch implements PackSession. +// Fetch implements PackSession. If ctx is done while Fetch runs, the session +// is closed, even if Fetch then returns nil. func (s *StreamSession) Fetch(ctx context.Context, st storage.Storer, req *FetchRequest) error { + stop := s.closeOnDone(ctx) + defer stop() + if s.version == protocol.V2 { if req.Filter != "" && !internal.FetchSupports(s.caps, "filter") { return ErrFilterNotSupported @@ -158,25 +170,29 @@ func (s *StreamSession) Fetch(ctx context.Context, st storage.Storer, req *Fetch return out, s.r, nil } if err := internal.FetchV2(ctx, st, req, round); err != nil { - return s.wrapStderr(err) + return s.wrapStderr(ctx, err) } return nil } shallows, err := NegotiatePack(ctx, st, s.caps, false, s.r, s.w, req) if err != nil { - return s.wrapStderr(err) + return s.wrapStderr(ctx, err) } if err := FetchPack(ctx, st, s.caps, io.NopCloser(s.r), shallows, req); err != nil { - return s.wrapStderr(err) + return s.wrapStderr(ctx, err) } return nil } -// Push implements PackSession. +// Push implements PackSession. If ctx is done while Push runs, the session is +// closed, even if Push then returns nil. func (s *StreamSession) Push(ctx context.Context, st storage.Storer, req *PushRequest) error { + stop := s.closeOnDone(ctx) + defer stop() + if err := SendPack(ctx, st, s.caps, s.w, io.NopCloser(s.r), req); err != nil { - return s.wrapStderr(err) + return s.wrapStderr(ctx, err) } return nil } @@ -186,12 +202,17 @@ func (s *StreamSession) Push(ctx context.Context, st storage.Storer, req *PushRe // carries the capabilities collected during the handshake (the agent and the // server's object-format), so callers only provide the command arguments. // -// Command is only valid on a session that negotiated Protocol v2. +// Command is only valid on a session that negotiated Protocol v2. If ctx is +// done while Command runs, the session is closed, even if Command then returns +// nil. func (s *StreamSession) Command(ctx context.Context, cmd string, req packp.CommandArgs, resp packp.Decoder) error { if s.version != protocol.V2 { return ErrUnsupportedVersion } + stop := s.closeOnDone(ctx) + defer stop() + cr := &packp.CommandRequest{ Command: cmd, Capabilities: s.commandCapabilities(), @@ -199,12 +220,12 @@ func (s *StreamSession) Command(ctx context.Context, cmd string, req packp.Comma } if err := cr.Encode(ioutil.NewContextWriter(ctx, s.w)); err != nil { - return s.wrapStderr(err) + return s.wrapStderr(ctx, err) } if resp != nil { if err := resp.Decode(ioutil.NewContextReader(ctx, s.r)); err != nil { - return s.wrapStderr(err) + return s.wrapStderr(ctx, err) } } @@ -220,10 +241,25 @@ func (s *StreamSession) commandCapabilities() capability.List { return internal.ClientCapabilities(s.caps) } +// closeOnDone closes the session once ctx is done, until stop is called. The +// context wrappers cannot end a read or write already in flight, and a write +// to a peer that has stopped reading never ends on its own; closing the +// connection ends both. +func (s *StreamSession) closeOnDone(ctx context.Context) (stop func() bool) { + return context.AfterFunc(ctx, func() { _ = s.Close() }) +} + // wrapStderr checks if the underlying connection has stderr output and // returns it as a RemoteError so that remote error messages surface at -// the operation site rather than at Close time. -func (s *StreamSession) wrapStderr(err error) error { +// the operation site rather than at Close time. The RemoteError wraps err. +func (s *StreamSession) wrapStderr(ctx context.Context, err error) error { + // Once ctx is done the session is closed, which also ends the remote's + // stderr, and what it wrote there would replace the error the caller + // cancelled with. A deadline that is not ctx's own leaves stderr to + // explain the failure. + if ctx.Err() != nil { + return err + } type stderrer interface { Stderr() io.Reader } @@ -231,15 +267,20 @@ func (s *StreamSession) wrapStderr(err error) error { if r := se.Stderr(); r != nil { b, readErr := io.ReadAll(r) if readErr == nil && len(b) > 0 { - return NewRemoteError(strings.TrimSpace(string(b))) + return &RemoteError{Reason: strings.TrimSpace(string(b)), err: err} } } } return err } -// Close implements Session. -func (s *StreamSession) Close() error { return s.conn.Close() } +// Close implements Session. It is safe to call more than once and +// concurrently: only the first call closes the connection, and later calls +// return its result. +func (s *StreamSession) Close() error { + s.closeOnce.Do(func() { s.closeErr = s.conn.Close() }) + return s.closeErr +} // Archive implements Archiver. It speaks the git-upload-archive wire // protocol over the session's existing connection. diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/transport/push.go b/vendor/github.com/go-git/go-git/v6/plumbing/transport/push.go index e7c14f7165..823dcc9499 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/transport/push.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/transport/push.go @@ -5,7 +5,9 @@ import ( "errors" "fmt" "io" + "slices" + "github.com/go-git/go-git/v6/plumbing/format/config" "github.com/go-git/go-git/v6/plumbing/protocol/capability" "github.com/go-git/go-git/v6/plumbing/protocol/packp" "github.com/go-git/go-git/v6/plumbing/protocol/packp/sideband" @@ -16,7 +18,7 @@ import ( // SendPack sends a packfile to a remote server. func SendPack( ctx context.Context, - _ storage.Storer, + st storage.Storer, caps capability.List, writer io.WriteCloser, reader io.ReadCloser, @@ -40,7 +42,12 @@ func SendPack( return fmt.Errorf("packfile is required for push request with new objects") } - upreq := buildUpdateRequests(caps, req) + format, err := pushObjectFormat(st, caps) + if err != nil { + return err + } + + upreq := buildUpdateRequests(caps, format, req) if err := upreq.Encode(writer); err != nil { return err } @@ -121,7 +128,33 @@ func SendPack( return reportError } -func buildUpdateRequests(caps capability.List, req *PushRequest) *packp.UpdateRequests { +// pushObjectFormat returns the repository's object format after checking that +// the server accepts it, as Git's send-pack does before sending any command. +// A server that advertises no object-format only speaks sha1. Any of the +// advertised values may match. +func pushObjectFormat(st storage.Storer, caps capability.List) (config.ObjectFormat, error) { + format := config.SHA1 + if st != nil { + cfg, err := st.Config() + if err != nil { + return config.UnsetObjectFormat, fmt.Errorf("reading object format: %w", err) + } + if cfg != nil && cfg.Extensions.ObjectFormat != config.UnsetObjectFormat { + format = cfg.Extensions.ObjectFormat + } + } + + advertised := caps.Get(capability.ObjectFormat) + if !caps.Supports(capability.ObjectFormat) { + advertised = []string{config.SHA1.String()} + } + if !slices.Contains(advertised, format.String()) { + return config.UnsetObjectFormat, fmt.Errorf("the receiving end does not support this repository's hash algorithm %q", format) + } + return format, nil +} + +func buildUpdateRequests(caps capability.List, format config.ObjectFormat, req *PushRequest) *packp.UpdateRequests { upreq := &packp.UpdateRequests{} if caps.Supports(capability.ReportStatus) { @@ -143,6 +176,9 @@ func buildUpdateRequests(caps capability.List, req *PushRequest) *packp.UpdateRe if len(req.Options) > 0 && caps.Supports(capability.PushOptions) { upreq.Capabilities.Set(capability.PushOptions) } + if caps.Supports(capability.ObjectFormat) { + upreq.Capabilities.Set(capability.ObjectFormat, format.String()) + } if caps.Supports(capability.Agent) { upreq.Capabilities.Set(capability.Agent, capability.DefaultAgent()) } diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/transport/serve.go b/vendor/github.com/go-git/go-git/v6/plumbing/transport/serve.go index c4056e2a82..cea1f9b25a 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/transport/serve.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/transport/serve.go @@ -80,8 +80,8 @@ func AdvertiseRefs( ar.Capabilities.Set(capability.Sideband) ar.Capabilities.Set(capability.NoProgress) ar.Capabilities.Set(capability.Shallow) - ar.Capabilities.Set(capability.ObjectFormat, objectFormat(st).String()) } + ar.Capabilities.Set(capability.ObjectFormat, objectFormat(st).String()) // Set references if err := addReferences(st, ar, !forPush); err != nil { diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/transport/ssh/auth.go b/vendor/github.com/go-git/go-git/v6/plumbing/transport/ssh/auth.go index da4a7bbb7e..6336efe926 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/transport/ssh/auth.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/transport/ssh/auth.go @@ -140,11 +140,16 @@ type PublicKeysCallback struct { User string Callback func() (signers []gossh.Signer, err error) HostKeyCallbackHelper + + // agentConn is the SSH agent connection opened by NewSSHAgentAuth. + agentConn net.Conn } // NewSSHAgentAuth returns a PublicKeysCallback based on an SSH agent. It opens // a pipe with the SSH agent and uses the pipe as the implementer of the public -// key callback function. +// key callback function. The pipe stays open until [PublicKeysCallback.Close] +// is called, so callers must close the returned PublicKeysCallback once it is +// no longer needed. func NewSSHAgentAuth(u string) (*PublicKeysCallback, error) { var err error if u == "" { @@ -154,17 +159,32 @@ func NewSSHAgentAuth(u string) (*PublicKeysCallback, error) { } } - a, _, err := sshagent.New() + a, conn, err := sshagent.New() if err != nil { return nil, fmt.Errorf("error creating SSH agent: %w", err) } return &PublicKeysCallback{ - User: u, - Callback: a.Signers, + User: u, + Callback: a.Signers, + agentConn: conn, }, nil } +// Close closes the SSH agent connection opened by [NewSSHAgentAuth]. The +// Callback stops working once it is closed. Close is a no-op when the +// PublicKeysCallback was not created by NewSSHAgentAuth. +func (a *PublicKeysCallback) Close() error { + if a == nil || a.agentConn == nil { + return nil + } + err := a.agentConn.Close() + if errors.Is(err, net.ErrClosed) { + return nil + } + return err +} + // ClientConfig returns the ssh.ClientConfig for public key callback authentication. func (a *PublicKeysCallback) ClientConfig(_ context.Context, _ *transport.Request) (*gossh.ClientConfig, error) { trace.SSH.Printf("ssh: %s user=%s", publicKeysCallbackName, a.User) diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/transport/ssh/ssh.go b/vendor/github.com/go-git/go-git/v6/plumbing/transport/ssh/ssh.go index db100ddf02..16f6e4c7c6 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/transport/ssh/ssh.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/transport/ssh/ssh.go @@ -65,10 +65,15 @@ func (t *Transport) Connect(ctx context.Context, req *transport.Request) (transp } func (t *Transport) connect(ctx context.Context, req *transport.Request) (*sshConn, error) { - config, err := t.resolveConfig(ctx, req) + config, agentConn, err := t.resolveConfig(ctx, req) if err != nil { return nil, err } + if agentConn != nil { + // The agent is only asked to sign during the SSH handshake, which is + // over by the time connect returns. + defer func() { _ = agentConn.Close() }() + } hostWithPort, err := t.resolveHostWithPort(ctx, req) if err != nil { @@ -152,9 +157,13 @@ func (t *Transport) connect(ctx context.Context, req *transport.Request) (*sshCo return conn, nil } -func (t *Transport) resolveConfig(ctx context.Context, req *transport.Request) (*gossh.ClientConfig, error) { +// resolveConfig returns the SSH client config for req. When it falls back to +// SSH agent auth, it also returns the agent connection, which the caller must +// close. +func (t *Transport) resolveConfig(ctx context.Context, req *transport.Request) (*gossh.ClientConfig, io.Closer, error) { if t.opts.ClientConfig != nil { - return t.opts.ClientConfig(ctx, req) + config, err := t.opts.ClientConfig(ctx, req) + return config, nil, err } username := DefaultUsername @@ -168,9 +177,14 @@ func (t *Transport) resolveConfig(ctx context.Context, req *transport.Request) ( auth, err := NewSSHAgentAuth(username) if err != nil { - return nil, err + return nil, nil, err + } + config, err := auth.ClientConfig(ctx, req) + if err != nil { + _ = auth.Close() + return nil, nil, err } - return auth.ClientConfig(ctx, req) + return config, auth, nil } func (t *Transport) dial(ctx context.Context, network, addr string, config *gossh.ClientConfig) (*gossh.Client, error) { diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/transport/ssh/sshagent/sshagent.go b/vendor/github.com/go-git/go-git/v6/plumbing/transport/ssh/sshagent/sshagent.go index f80706f159..734fa74710 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/transport/ssh/sshagent/sshagent.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/transport/ssh/sshagent/sshagent.go @@ -43,7 +43,7 @@ func New() (agent.Agent, net.Conn, error) { trace.SSH.Printf("ssh: net.Dial unix sock %s", sshAuthSock) conn, err := net.Dial("unix", sshAuthSock) if err != nil { - return nil, nil, fmt.Errorf("error connecting to SSH_AUTH_SOCK: %v", err) + return nil, nil, fmt.Errorf("error connecting to SSH_AUTH_SOCK: %w", err) } return agent.NewClient(conn), conn, nil diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/transport/ssh/sshagent/sshagent_windows.go b/vendor/github.com/go-git/go-git/v6/plumbing/transport/ssh/sshagent/sshagent_windows.go index 7330f099fb..597cfaf04d 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/transport/ssh/sshagent/sshagent_windows.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/transport/ssh/sshagent/sshagent_windows.go @@ -25,7 +25,7 @@ package sshagent import ( - "errors" + "fmt" "io" "net" "sync" @@ -63,11 +63,11 @@ func New() (agent.Agent, net.Conn, error) { trace.SSH.Printf("ssh: winio.DialPipe %s", sshAgentPipe) conn, err := winio.DialPipe(sshAgentPipe, nil) if err != nil { - return nil, nil, errors.New( - "SSH agent requested, but could not detect Pageant or Windows native SSH agent", + return nil, nil, fmt.Errorf( + "SSH agent requested, but could not detect Pageant or Windows native SSH agent: %w", err, ) } - return agent.NewClient(conn), nil, nil + return agent.NewClient(conn), conn, nil } type conn struct { diff --git a/vendor/github.com/go-git/go-git/v6/plumbing/transport/upload_pack.go b/vendor/github.com/go-git/go-git/v6/plumbing/transport/upload_pack.go index 663129c7ef..8d2c039ebb 100644 --- a/vendor/github.com/go-git/go-git/v6/plumbing/transport/upload_pack.go +++ b/vendor/github.com/go-git/go-git/v6/plumbing/transport/upload_pack.go @@ -2,11 +2,12 @@ package transport import ( "bufio" + "cmp" "context" "errors" "fmt" "io" - "math" + "slices" "strings" "time" @@ -111,20 +112,25 @@ func UploadPack( var done bool var haves []plumbing.Hash var upreq *packp.UploadRequest - var reachable map[plumbing.Hash]struct{} - var multiAck, multiAckDetailed bool + var common *commonHaves + var anyMultiAck, multiAckDetailed bool var caps capability.List var wants []plumbing.Hash - var ack packp.ACK + var plan *shallowPlan firstRound := true for !done { - writec := make(chan error) - if firstRound || opts.StatelessRPC { + if firstRound { upreq = &packp.UploadRequest{} if err := upreq.Decode(rd); err != nil { return fmt.Errorf("decoding upload-request: %w", err) } + // filter is never advertised, so refuse a filter line as + // upload-pack does with uploadpack.allowFilter unset. + if upreq.Filter != "" { + return fmt.Errorf("%w: %q", ErrFilterNotSupported, upreq.Filter) + } + wants = upreq.Wants caps = upreq.Capabilities @@ -132,48 +138,64 @@ func UploadPack( return fmt.Errorf("closing reader: %w", err) } - // Collect the objects reachable from the wants. Only membership - // is tested later, when a client have is checked against this - // set, so walk the wants once instead of once per want. - objs, err := revlist.Objects(st, wants, nil) + multiAckDetailed = caps.Supports(capability.MultiACKDetailed) + // Either form, where upstream tests data->multi_ack. + anyMultiAck = multiAckDetailed || caps.Supports(capability.MultiACK) + + // TODO: support deepen-since, and deepen-not + if !upreq.Depth.DeepenSince.IsZero() || len(upreq.Depth.DeepenNot) > 0 { + return fmt.Errorf("unsupported depth: %+v", upreq.Depth) + } + plan, err = planShallow(ctx, st, wants, shallowRequest{ + clientShallows: upreq.Shallows, + depth: upreq.Depth.Deepen, + }) if err != nil { - return fmt.Errorf("getting objects: %w", err) + return fmt.Errorf("planning shallow fetch: %w", err) } - reachable = make(map[plumbing.Hash]struct{}, len(objs)) - for _, h := range objs { - reachable[h] = struct{}{} + // Before negotiation starts, upstream send_unshallow adds the + // parents of unshallowed commits to want_obj, so ok_to_give_up + // requires them to reach a common commit too, and the client's + // shallow commits and the new boundary are registered as + // shallow, so neither walk goes past them. + negotiated := wants + var grafts []plumbing.Hash + if plan != nil { + negotiated = slices.Concat(wants, plan.extraWants) + grafts = plan.grafts + } + common, err = newCommonHaves(st, negotiated, grafts) + if err != nil { + return err } - // Encode objects to packfile and write to client - multiAck = caps.Supports(capability.MultiACK) - multiAckDetailed = caps.Supports(capability.MultiACKDetailed) - - go func() { - // TODO: support deepen-since, and deepen-not - var shupd packp.ShallowUpdate - if !upreq.Depth.IsZero() { - if upreq.Depth.Deepen > 0 { - if err := getShallowCommits(st, wants, upreq.Depth.Deepen, &shupd); err != nil { - writec <- fmt.Errorf("getting shallow commits: %w", err) - return - } - } else { - writec <- fmt.Errorf("unsupported depth: %+v", upreq.Depth) - return - } - - if err := shupd.Encode(w); err != nil { - writec <- fmt.Errorf("sending shallow-update: %w", err) - return - } + // Upstream follows a deepen with the shallow update and a flush + // even when both lists are empty (receive_needs). + if plan != nil && plan.deepened { + shupd := packp.ShallowUpdate{Shallows: plan.shallows, Unshallows: plan.unshallows} + if err := shupd.Encode(w); err != nil { + return fmt.Errorf("sending shallow-update: %w", err) } + } - writec <- nil - }() + // A stateless client may end its first request here, having + // asked only for the shallow list, and sends its haves in the + // next. It is owed neither acknowledgments nor a pack: upstream + // upload_pack peeks with PACKET_READ_GENTLE_ON_EOF and stops. + if opts.StatelessRPC { + if _, _, err := pktline.PeekLine(rd); errors.Is(err, io.EOF) { + return w.Close() + } + } + } - if err := <-writec; err != nil { - return err + // UploadHaves.Decode takes EOF for a flush. Upstream dies when a + // stateful client hangs up mid-negotiation, so do the same instead of + // looping on empty rounds. + if !opts.StatelessRPC { + if _, _, err := pktline.PeekLine(rd); errors.Is(err, io.EOF) { + return fmt.Errorf("decoding upload-haves: %w", io.ErrUnexpectedEOF) } } @@ -189,81 +211,84 @@ func UploadPack( haves = append(haves, uphav.Haves...) done = uphav.Done - var acks []packp.ACK - for _, hu := range uphav.Haves { - _, ok := reachable[hu] - - var status packp.ACKStatus - if multiAckDetailed { - status = packp.ACKCommon - if !ok { - status = packp.ACKReady - } - } else if multiAck { - status = packp.ACKContinue + // Acknowledge the haves as upstream get_common_commits does: a have is + // common when the server has it, and "ready" is only promised once + // every want reaches a common have (ok_to_give_up). + var resps []packp.ServerResponse + ack := func(a packp.ACK) { + resps = append(resps, packp.ServerResponse{ACKs: []packp.ACK{a}}) + } + nak := func() { resps = append(resps, packp.ServerResponse{}) } + gotCommon, gotOther := false, false + for _, h := range uphav.Haves { + if err := ctx.Err(); err != nil { + return err } - - if ok || multiAck || multiAckDetailed { - ack = packp.ACK{Hash: hu, Status: status} - acks = append(acks, ack) - if !multiAck && !multiAckDetailed { - break + ok, err := common.add(h) + if err != nil { + return fmt.Errorf("checking have %s: %w", h, err) + } + if !ok { + gotOther = true + if anyMultiAck { + ready, err := common.okToGiveUp(ctx) + if err != nil { + return fmt.Errorf("checking negotiation: %w", err) + } + if ready { + status := packp.ACKContinue + if multiAckDetailed { + status = packp.ACKReady + } + ack(packp.ACK{Hash: h, Status: status}) + } } + continue } - } - go func() { - defer close(writec) - - if len(haves) > 0 { - // Encode ACKs to client when we have haves - srvrsp := packp.ServerResponse{ACKs: acks} - if err := srvrsp.Encode(w); err != nil { - writec <- fmt.Errorf("sending acks server-response: %w", err) - return - } + gotCommon = true + switch { + case multiAckDetailed: + ack(packp.ACK{Hash: h, Status: packp.ACKCommon}) + case anyMultiAck: + ack(packp.ACK{Hash: h, Status: packp.ACKContinue}) + case len(common.counted) == 1: + ack(packp.ACK{Hash: h}) } + } + if done { switch { - case !done: - if multiAck || multiAckDetailed { - // Encode a NAK for multi-ack - srvrsp := packp.ServerResponse{} - if err := srvrsp.Encode(w); err != nil { - writec <- fmt.Errorf("sending nak server-response: %w", err) - return - } - } - case !ack.Hash.IsZero() && (multiAck || multiAckDetailed): - // We're done, send the final ACK - ack.Status = 0 - srvrsp := packp.ServerResponse{ACKs: []packp.ACK{ack}} - if err := srvrsp.Encode(w); err != nil { - writec <- fmt.Errorf("sending final ack server-response: %w", err) - return + case len(common.counted) == 0: + nak() + case anyMultiAck: + ack(packp.ACK{Hash: common.last}) + } + } else { + if multiAckDetailed && gotCommon && !gotOther { + ready, err := common.okToGiveUp(ctx) + if err != nil { + return fmt.Errorf("checking negotiation: %w", err) } - case ack.Hash.IsZero() && len(haves) == 0: - // No haves were sent. Emit the single terminal NAK. - // - // When haves *were* sent, the ServerResponse{ACKs: acks} - // write above already emitted a NAK (encodeServerResponse - // writes NAK when ACKs is empty). Emitting another one here - // would produce two consecutive "0008NAK\n" pktlines; - // ServerResponse.Decode consumes only the first, and the - // second would then be misread by the sideband demuxer as - // a frame with channel byte 'N' ("unknown channel NAK"). - srvrsp := packp.ServerResponse{} - if err := srvrsp.Encode(w); err != nil { - writec <- fmt.Errorf("sending final nak server-response: %w", err) - return + if ready { + ack(packp.ACK{Hash: common.last, Status: packp.ACKReady}) } } + if len(common.counted) == 0 || anyMultiAck { + nak() + } + } - writec <- nil - }() + for _, resp := range resps { + if err := resp.Encode(w); err != nil { + return fmt.Errorf("sending server-response: %w", err) + } + } - if err := <-writec; err != nil { - return err + // A stateless round that is not done ends here; the client sends the + // next round as a new request. + if opts.StatelessRPC && !done { + return w.Close() } firstRound = false @@ -275,7 +300,7 @@ func UploadPack( return fmt.Errorf("closing reader: %w", err) } - objs, err := objectsToUpload(st, wants, haves) + objs, err := plan.objects(st, wants, haves) if err != nil { _ = w.Close() return fmt.Errorf("getting objects to upload: %w", err) @@ -327,73 +352,60 @@ func objectsToUpload(st storage.Storer, wants, haves []plumbing.Hash) ([]plumbin return revlist.Objects(st, wants, haves) } -func getShallowCommits(st storage.Storer, heads []plumbing.Hash, depth int, upd *packp.ShallowUpdate) error { - var i, curDepth int - var commit *object.Commit - depths := map[*object.Commit]int{} - stack := []object.Object{} - - for commit != nil || i < len(heads) || len(stack) > 0 { - if commit == nil { - if i < len(heads) { - obj, err := st.EncodedObject(plumbing.CommitObject, heads[i]) - i++ - if err != nil { - continue - } - - commit, err = object.DecodeCommit(st, obj) - if err != nil { - commit = nil - continue - } +// getShallowCommits returns the shallow boundary of a fetch limited to depth +// commits: the commits whose shortest distance from heads is exactly depth (a +// head is at depth 1), following every parent. It mirrors upstream +// get_shallows_or_depth (shallow.c), the walk behind get_shallow_commits. +// Heads that do not peel to a commit are skipped, and an infinite depth +// (infiniteDepth or more) has no boundary. +func getShallowCommits(ctx context.Context, st storage.Storer, heads []plumbing.Hash, depth int) ([]plumbing.Hash, error) { + if depth >= infiniteDepth { + return nil, nil + } - depths[commit] = 0 - curDepth = 0 - } else if len(stack) > 0 { - commit = stack[len(stack)-1].(*object.Commit) - stack = stack[:len(stack)-1] - curDepth = depths[commit] - } + // Walking breadth-first visits every commit first at its shortest depth, + // so a commit reached again through a longer path is skipped. + visited := make(map[plumbing.Hash]struct{}) + var level []plumbing.Hash + for _, h := range heads { + c, ok := peelToCommit(st, h) + if !ok { + continue } - - curDepth++ - - if depth != math.MaxInt && curDepth >= depth { - upd.Shallows = append(upd.Shallows, commit.Hash) - commit = nil + if _, ok := visited[c.Hash]; ok { continue } + visited[c.Hash] = struct{}{} + level = append(level, c.Hash) + } - upd.Unshallows = append(upd.Unshallows, commit.Hash) + for d := 1; len(level) > 0; d++ { + if d == depth { + plumbing.HashesSort(level) + return level, nil + } - parents := commit.Parents() - commit = nil - for { - parent, err := parents.Next() - if err == io.EOF { - break + var next []plumbing.Hash + for _, h := range level { + if err := ctx.Err(); err != nil { + return nil, err } + c, err := object.GetCommit(st, h) if err != nil { - return err + return nil, fmt.Errorf("getting commit %s: %w", h, err) } - - if depths[parent] != 0 && curDepth >= depths[parent] { - continue - } - - depths[parent] = curDepth - - if _, err := parents.Next(); err == nil { - stack = append(stack, parent) - } else { - commit = parent - curDepth = depths[commit] + for _, p := range c.ParentHashes { + if _, ok := visited[p]; ok { + continue + } + visited[p] = struct{}{} + next = append(next, p) } } + level = next } - return nil + return nil, nil } // shallowFrontierDepth returns the depth, counted from the wants (a tip is at @@ -401,7 +413,7 @@ func getShallowCommits(st storage.Storer, heads []plumbing.Hash, depth int, upd // reachable. It mirrors upstream get_shallows_depth (shallow.c): the value // offsets a deepen-relative request so the new depth is measured from the // client's existing shallow boundary rather than from the tips. -func shallowFrontierDepth(st storage.Storer, heads, shallows []plumbing.Hash) (int, error) { +func shallowFrontierDepth(ctx context.Context, st storage.Storer, heads, shallows []plumbing.Hash) (int, error) { shallowSet := make(map[plumbing.Hash]struct{}, len(shallows)) for _, h := range shallows { shallowSet[h] = struct{}{} @@ -420,6 +432,9 @@ func shallowFrontierDepth(st storage.Storer, heads, shallows []plumbing.Hash) (i } } for len(stack) > 0 { + if err := ctx.Err(); err != nil { + return 0, err + } f := stack[len(stack)-1] stack = stack[:len(stack)-1] if d, ok := seen[f.hash]; ok && d <= f.depth { @@ -655,13 +670,19 @@ func peelToNonTag(st storage.Storer, h plumbing.Hash) (plumbing.Hash, bool) { // left open, so the caller loops to read the client's next command=fetch round // (the stateful negotiation continues until the server is ready). A stateless // (HTTP) round always concludes, since the client re-POSTs each round. -func serveFetchV2(_ context.Context, st storage.Storer, w io.WriteCloser, args *packp.FetchArgs, opts *UploadPackRequest) (concluded bool, err error) { +func serveFetchV2(ctx context.Context, st storage.Storer, w io.WriteCloser, args *packp.FetchArgs, opts *UploadPackRequest) (concluded bool, err error) { wants := args.Wants haves := args.Haves - clientShallows := args.Shallows - depth := args.Deepen done := args.Done + // fetch=filter is not advertised. Upstream rejects the argument as an + // unexpected line before acting on any other, so do the same rather than + // send a pack the client takes for a filtered one. + if args.Filter != "" { + _ = w.Close() + return true, fmt.Errorf("%w: %q", ErrFilterNotSupported, args.Filter) + } + // No 'want' lines: the client guessed it didn't want anything. Upstream // emits no response at all here (upload-pack.c, UPLOAD_DONE), so write // nothing and just close the stream, no stray flush packet. @@ -676,28 +697,47 @@ func serveFetchV2(_ context.Context, st storage.Storer, w io.WriteCloser, args * // - done -> no acknowledgments section; packfile follows. // - no haves -> clone-like; no acknowledgments section; packfile follows. // - haves and !done -> emit an acknowledgments section. ACK every common - // object. "ready" is sent only once every want is - // reachable from the common haves (upstream's + // have not already implied by an earlier one. + // "ready" is sent only once every want reaches a + // common have or a parent of one (upstream's // ok_to_give_up); then the packfile follows in the // same response. Otherwise the section ends without a // packfile and the client negotiates again with more // haves (NAK when there is no common object at all). if !done && len(haves) > 0 { - var common []plumbing.Hash + // Unlike v0/v1, upstream negotiates before send_shallow_info adds the + // parents of unshallowed commits to the wants and registers the + // client's shallow commits, so neither applies here. The server's + // own shallow commits do, and newCommonHaves reads them. + common, err := newCommonHaves(st, wants, nil) + if err != nil { + _ = w.Close() + return true, err + } for _, h := range haves { - if _, err := st.EncodedObject(plumbing.AnyObject, h); err == nil { - common = append(common, h) + if err := ctx.Err(); err != nil { + _ = w.Close() + return true, err + } + if _, err := common.add(h); err != nil { + _ = w.Close() + return true, fmt.Errorf("checking have %s: %w", h, err) } } - out.Acknowledgments = &packp.Acknowledgments{ACKs: common} + out.Acknowledgments = &packp.Acknowledgments{ACKs: common.counted} - // "ready" is withheld until every want is reachable from the common - // haves (upstream's ok_to_give_up). Declaring it on the first common + // "ready" is withheld until every want reaches a common have + // (upstream's ok_to_give_up). Declaring it on the first common // have would force single-round negotiation and a larger pack. When not // ready (including no common object at all, which encodes as NAK), the // acknowledgments section stands alone and the client refines its haves // in the next request. - if len(common) == 0 || !wantsReachableFromHaves(st, wants, common) { + ready, err := common.okToGiveUp(ctx) + if err != nil { + _ = w.Close() + return true, fmt.Errorf("checking negotiation: %w", err) + } + if !ready { if err := out.Encode(w); err != nil { return true, err } @@ -713,123 +753,33 @@ func serveFetchV2(_ context.Context, st storage.Storer, w io.WriteCloser, args * out.Acknowledgments.Ready = true } - // shallow-info: a shallow fetch bounds the history sent. The boundary forms - // mirror upstream send_shallow_list (upload-pack.c): - // - deepen : a depth boundary from the wants (getShallowCommits). - // - deepen-since / deepen-not: a date/ref boundary (getShallowCommitsByRevList, - // mirroring deepen_by_rev_list). - // Upstream forbids combining deepen with deepen-since/deepen-not, and so do we. - // deepen-relative only changes how the depth is counted: for a fresh fetch - // (no client shallows) relative and absolute depth coincide, and for an - // already-shallow client the depth is offset by the existing boundary's - // distance from the wants (see the deepen-relative handling below). - since := args.DeepenSince notTips, err := resolveDeepenNot(st, args.DeepenNot) if err != nil { _ = w.Close() return true, fmt.Errorf("resolving deepen-not: %w", err) } - revList := !since.IsZero() || len(notTips) > 0 - if depth > 0 && revList { + plan, err := planShallow(ctx, st, wants, shallowRequest{ + clientShallows: args.Shallows, + depth: args.Deepen, + relative: args.DeepenRelative, + since: args.DeepenSince, + notTips: notTips, + }) + if err != nil { _ = w.Close() - return true, fmt.Errorf("deepen and deepen-since (or deepen-not) cannot be used together") - } - - // A deepen was requested when depth > 0 or a rev-list bound was given. - // haveNewBoundary records that separately from len(newBoundary): a deepen - // that reaches full history yields an empty boundary, which still drives - // shallow-info and the unshallow lines and must not be mistaken for "no - // deepen requested". newBoundary is the grafting boundary for the deepened - // view (nil/empty means graft nothing: full history). - var newBoundary []plumbing.Hash - var haveNewBoundary bool - if depth > 0 || revList { - var shupd packp.ShallowUpdate - computed := true - if revList { - err = getShallowCommitsByRevList(st, wants, since, notTips, &shupd) - } else { - effectiveDepth := depth - if args.DeepenRelative && len(clientShallows) > 0 { - // deepen-relative counts depth from the client's existing - // shallow boundary, not from the wants. Mirror upstream - // get_shallow_commits (shallow.c): offset the absolute depth by - // the depth at which that boundary sits from the wants. - cur, derr := shallowFrontierDepth(st, wants, clientShallows) - if derr != nil { - _ = w.Close() - return true, fmt.Errorf("computing shallow frontier depth: %w", derr) - } - if cur == 0 { - // No client shallow is reachable from the wants; upstream - // computes no new boundary and leaves the client's view - // unchanged. Skip the deepen entirely. - computed = false - } else { - effectiveDepth = depth + cur - } - } - if computed { - err = getShallowCommits(st, wants, effectiveDepth, &shupd) - } - } - if err != nil { - _ = w.Close() - return true, fmt.Errorf("computing shallow commits: %w", err) - } - if computed { - haveNewBoundary = true - newBoundary = shupd.Shallows - } - } - - var objs []plumbing.Hash - if len(clientShallows) > 0 { - // The client already has a shallow view (it sent "shallow" lines). - // A single object walk cannot graft the wanted history at the new - // boundary while also grafting the client's have-history at its existing - // boundary, so compute two views and send their difference: - // newView = objects reachable from the wants, grafted at the new - // boundary (the client's deepened view). - // clientView = objects the client already has, reachable from its haves - // grafted at its existing shallow boundary. - // newView \ clientView is exactly what the client is missing. It never - // omits a needed object; at worst it re-sends one the client has, which - // is harmless. This is what bounds a deepen of an already-shallow clone. - boundary := clientShallows - if haveNewBoundary { - // The deepened boundary, which may be empty: a deepen that reaches - // full history grafts nothing and unshallows the old boundary. - boundary = newBoundary - } - newView, nerr := objectsToUpload(&shallowBoundaryStorer{Storer: st, boundary: boundary}, wants, nil) - if nerr != nil { - _ = w.Close() - return true, fmt.Errorf("getting objects to upload: %w", nerr) - } - clientView, cerr := objectsToUpload(&shallowBoundaryStorer{Storer: st, boundary: clientShallows}, haves, nil) - if cerr != nil { - _ = w.Close() - return true, fmt.Errorf("getting client objects: %w", cerr) - } - objs = hashDifference(newView, clientView) - if haveNewBoundary { - out.ShallowInfo = &packp.ShallowInfo{ - Shallows: newBoundary, - Unshallows: unshallowedCommits(clientShallows, newBoundary, newView), - } - } - } else { - packSt := st - if haveNewBoundary && len(newBoundary) > 0 { - out.ShallowInfo = &packp.ShallowInfo{Shallows: newBoundary} - packSt = &shallowBoundaryStorer{Storer: st, boundary: newBoundary} - } - objs, err = objectsToUpload(packSt, wants, haves) - if err != nil { - _ = w.Close() - return true, fmt.Errorf("getting objects to upload: %w", err) - } + return true, fmt.Errorf("planning shallow fetch: %w", err) + } + // Upstream send_shallow_info writes the section, even when empty, when + // there is a deepen request or a client shallow line. Serving from a + // shallow repository is not handled. + if plan != nil { + out.ShallowInfo = &packp.ShallowInfo{Shallows: plan.shallows, Unshallows: plan.unshallows} + } + + objs, err := plan.objects(st, wants, haves) + if err != nil { + _ = w.Close() + return true, fmt.Errorf("getting objects to upload: %w", err) } // include-tag: add annotated tags whose target is in the pack (auto-tag @@ -876,47 +826,228 @@ func serveFetchV2(_ context.Context, st storage.Storer, w io.WriteCloser, args * return true, w.Close() } -// hashDifference returns the elements of a that are not in b, preserving a's -// order. It computes the objects a deepened client is missing (newView minus the -// client's existing view). -func hashDifference(a, b []plumbing.Hash) []plumbing.Hash { - set := make(map[plumbing.Hash]struct{}, len(b)) - for _, h := range b { - set[h] = struct{}{} +// infiniteDepth is git's INFINITE_DEPTH, the depth that --unshallow requests. +const infiniteDepth = 0x7fffffff + +// shallowRequest is the shallow part of a fetch request; v0/v1 and v2 requests +// both map onto it. +type shallowRequest struct { + clientShallows []plumbing.Hash + depth int + relative bool + since time.Time + notTips []plumbing.Hash +} + +// shallowPlan bounds the objects sent to a shallow or deepening client. It is +// computed from the wants alone, before negotiation, because v0/v1 send the +// shallow update ahead of reading the client's haves. +type shallowPlan struct { + // deepened reports whether the client asked to deepen, and so is owed the + // shallow and unshallow lines below. + deepened bool + shallows []plumbing.Hash + unshallows []plumbing.Hash + + // grafts are walked as parentless commits: the client's shallow commits, + // beyond which it has nothing, and the new boundary, beyond which nothing + // is sent. + grafts []plumbing.Hash + // extraWants are the parents of unshallowed commits. The graft on an + // unshallowed commit stops the walk from the client's haves, while its + // history down to the new boundary is still sent from here. + extraWants []plumbing.Hash +} + +// planShallow computes the shallow boundary, the unshallowed commits and the +// object-walk grafts for a fetch of wants, mirroring upstream +// send_shallow_list, deepen and send_unshallow (upload-pack.c). It returns a +// nil plan when the client neither is shallow nor asks to deepen, and an +// error when deepen is combined with deepen-since or deepen-not. The walks +// stop with ctx's error once ctx is done. +func planShallow(ctx context.Context, st storage.Storer, wants []plumbing.Hash, req shallowRequest) (*shallowPlan, error) { + var err error + if req.clientShallows, err = knownClientShallows(st, req.clientShallows); err != nil { + return nil, err + } + revList := !req.since.IsZero() || len(req.notTips) > 0 + if req.depth > 0 && revList { + return nil, errors.New("deepen and deepen-since (or deepen-not) cannot be used together") + } + if req.depth <= 0 && !revList && len(req.clientShallows) == 0 { + return nil, nil } - var out []plumbing.Hash - for _, h := range a { - if _, ok := set[h]; !ok { - out = append(out, h) + + plan := &shallowPlan{grafts: req.clientShallows} + switch { + case revList: + plan.shallows, err = getShallowCommitsByRevList(ctx, st, wants, req.since, req.notTips) + case req.depth > 0: + depth := req.depth + if depth >= infiniteDepth && len(req.clientShallows) > 0 { + shallows, serr := st.Shallow() + if serr != nil { + return nil, fmt.Errorf("reading shallow commits: %w", serr) + } + if len(shallows) == 0 { + // Upstream deepen (upload-pack.c): an infinite deepen from a + // complete repository unshallows every client shallow commit, + // reachable from the wants or not. + plan.deepened = true + for _, h := range req.clientShallows { + if err := ctx.Err(); err != nil { + return nil, err + } + c, cerr := object.GetCommit(st, h) + if cerr != nil { + return nil, fmt.Errorf("getting commit %s: %w", h, cerr) + } + plan.unshallows = append(plan.unshallows, h) + plan.extraWants = append(plan.extraWants, c.ParentHashes...) + } + return plan, nil + } + } + if req.relative && len(req.clientShallows) > 0 { + // deepen-relative counts from the client's boundary: offset the + // depth by that boundary's distance from the wants, as upstream + // get_shallow_commits does. + cur, ferr := shallowFrontierDepth(ctx, st, wants, req.clientShallows) + if ferr != nil { + return nil, fmt.Errorf("computing shallow frontier depth: %w", ferr) + } + if cur == 0 { + // No client shallow commit is reachable from the wants, so + // upstream leaves the client's view unchanged. + return plan, nil + } + depth += cur } + plan.shallows, err = getShallowCommits(ctx, st, wants, depth) + default: + // Shallow lines without a deepen: the client's boundary only bounds + // what it has. + return plan, nil } - return out + if err != nil { + return nil, fmt.Errorf("computing shallow commits: %w", err) + } + + plan.deepened = true + plan.unshallows, plan.extraWants, err = unshallowedCommits(ctx, st, wants, req.clientShallows, plan.shallows) + if err != nil { + return nil, fmt.Errorf("computing unshallowed commits: %w", err) + } + plan.grafts = slices.Concat(req.clientShallows, plan.shallows) + clientShallows := make(map[plumbing.Hash]struct{}, len(req.clientShallows)) + for _, h := range req.clientShallows { + clientShallows[h] = struct{}{} + } + // The client already records its own shallow commits; upstream + // send_shallow skips those flagged CLIENT_SHALLOW. + plan.shallows = slices.DeleteFunc(plan.shallows, func(h plumbing.Hash) bool { + _, ok := clientShallows[h] + return ok + }) + return plan, nil } -// unshallowedCommits returns the client's shallow commits that the deepened view -// now includes as interior commits (their parents are being sent), so the client -// can clear their shallow mark. Commits still on the new boundary stay shallow. -// Mirrors upstream send_unshallow (upload-pack.c). -func unshallowedCommits(clientShallows, newBoundary, newView []plumbing.Hash) []plumbing.Hash { - inView := make(map[plumbing.Hash]struct{}, len(newView)) - for _, h := range newView { - inView[h] = struct{}{} +// knownClientShallows returns the client's shallow commits that st has, each +// once, mirroring upstream process_shallow (upload-pack.c): a shallow line +// naming an object the server does not have is ignored, a repeated one is +// collapsed, and one naming an object that is not a commit is an error. +func knownClientShallows(st storage.Storer, shallows []plumbing.Hash) ([]plumbing.Hash, error) { + if len(shallows) == 0 { + return shallows, nil } - boundary := make(map[plumbing.Hash]struct{}, len(newBoundary)) - for _, h := range newBoundary { - boundary[h] = struct{}{} + known := make([]plumbing.Hash, 0, len(shallows)) + seen := make(map[plumbing.Hash]struct{}, len(shallows)) + for _, h := range shallows { + if _, ok := seen[h]; ok { + continue + } + seen[h] = struct{}{} + _, err := object.GetCommit(st, h) + if errors.Is(err, plumbing.ErrObjectNotFound) { + // A typed lookup reports another type as not found too. + if st.HasEncodedObject(h) == nil { + return nil, fmt.Errorf("invalid shallow object %s", h) + } + continue + } + if err != nil { + return nil, fmt.Errorf("getting commit %s: %w", h, err) + } + known = append(known, h) + } + return known, nil +} + +// objects returns the objects to pack for a plan, or for an unbounded fetch +// when p is nil. +func (p *shallowPlan) objects(st storage.Storer, wants, haves []plumbing.Hash) ([]plumbing.Hash, error) { + if p == nil { + return objectsToUpload(st, wants, haves) + } + wants = slices.Concat(wants, p.extraWants) + return revlist.ObjectsWithShallows(st, wants, haves, p.grafts) +} + +// unshallowedCommits returns the client's shallow commits that a deepen to +// boundary makes interior, and their parents. Mirrors upstream send_unshallow +// (upload-pack.c): such a commit is reachable from the wants without crossing +// the boundary, and is not on it. +func unshallowedCommits(ctx context.Context, st storage.Storer, wants, clientShallows, boundary []plumbing.Hash) (unshallows, parents []plumbing.Hash, err error) { + if len(clientShallows) == 0 { + return nil, nil, nil + } + + stop := make(map[plumbing.Hash]struct{}, len(boundary)) + for _, h := range boundary { + stop[h] = struct{}{} + } + within := make(map[plumbing.Hash]struct{}) + var stack []plumbing.Hash + for _, h := range wants { + if c, ok := peelToCommit(st, h); ok { + stack = append(stack, c.Hash) + } + } + for len(stack) > 0 { + if err := ctx.Err(); err != nil { + return nil, nil, err + } + h := stack[len(stack)-1] + stack = stack[:len(stack)-1] + if _, ok := within[h]; ok { + continue + } + within[h] = struct{}{} + if _, ok := stop[h]; ok { + continue + } + c, err := object.GetCommit(st, h) + if err != nil { + return nil, nil, fmt.Errorf("getting commit %s: %w", h, err) + } + stack = append(stack, c.ParentHashes...) } - var out []plumbing.Hash - for _, cs := range clientShallows { - if _, ok := inView[cs]; !ok { - continue // not part of the deepened view + + for _, h := range clientShallows { + if _, ok := within[h]; !ok { + continue } - if _, ok := boundary[cs]; ok { - continue // still a boundary commit + if _, ok := stop[h]; ok { + continue } - out = append(out, cs) + c, err := object.GetCommit(st, h) + if err != nil { + return nil, nil, fmt.Errorf("getting commit %s: %w", h, err) + } + unshallows = append(unshallows, h) + parents = append(parents, c.ParentHashes...) } - return out + return unshallows, parents, nil } // resolveDeepenNot resolves each deepen-not argument (a ref name or an object @@ -949,10 +1080,13 @@ func resolveDeepenNot(st storage.Storer, refs []string) ([]plumbing.Hash, error) // reachableCommits returns the set of commits reachable from tips (inclusive), // used as the exclusion set for deepen-not. -func reachableCommits(st storage.Storer, tips []plumbing.Hash) (map[plumbing.Hash]struct{}, error) { +func reachableCommits(ctx context.Context, st storage.Storer, tips []plumbing.Hash) (map[plumbing.Hash]struct{}, error) { seen := make(map[plumbing.Hash]struct{}) stack := append([]plumbing.Hash(nil), tips...) for len(stack) > 0 { + if err := ctx.Err(); err != nil { + return nil, err + } h := stack[len(stack)-1] stack = stack[:len(stack)-1] if _, ok := seen[h]; ok { @@ -977,10 +1111,10 @@ func reachableCommits(st storage.Storer, tips []plumbing.Hash) (map[plumbing.Has // Unlike git's rev-list traversal it does not apply the date "slop" used to // tolerate out-of-order committer timestamps, so under clock skew the boundary // may differ by a few commits; the resulting shallow clone is still valid. -func getShallowCommitsByRevList(st storage.Storer, heads []plumbing.Hash, since time.Time, notTips []plumbing.Hash, upd *packp.ShallowUpdate) error { - exclude, err := reachableCommits(st, notTips) +func getShallowCommitsByRevList(ctx context.Context, st storage.Storer, heads []plumbing.Hash, since time.Time, notTips []plumbing.Hash) ([]plumbing.Hash, error) { + exclude, err := reachableCommits(ctx, st, notTips) if err != nil { - return err + return nil, err } included := make(map[plumbing.Hash]struct{}) @@ -988,6 +1122,9 @@ func getShallowCommitsByRevList(st storage.Storer, heads []plumbing.Hash, since visited := make(map[plumbing.Hash]struct{}) stack := append([]plumbing.Hash(nil), heads...) for len(stack) > 0 { + if err := ctx.Err(); err != nil { + return nil, err + } h := stack[len(stack)-1] stack = stack[:len(stack)-1] if _, ok := visited[h]; ok { @@ -1009,16 +1146,17 @@ func getShallowCommitsByRevList(st storage.Storer, heads []plumbing.Hash, since stack = append(stack, c.ParentHashes...) } + var shallows []plumbing.Hash for h := range included { for _, p := range parents[h] { if _, ok := included[p]; !ok { - upd.Shallows = append(upd.Shallows, h) + shallows = append(shallows, h) break } } } - plumbing.HashesSort(upd.Shallows) - return nil + plumbing.HashesSort(shallows) + return shallows, nil } // includeReachableTags implements the fetch "include-tag" feature: for every @@ -1076,68 +1214,368 @@ func includeReachableTags(st storage.Storer, objs []plumbing.Hash) ([]plumbing.H return added, nil } -// shallowBoundaryStorer reports an additional set of shallow commits (the -// per-request boundary) on top of any the repository already has. revlist's -// object walk stops at shallow commits while still collecting their full trees, -// so wrapping the storer bounds a shallow fetch's packfile to the requested -// depth — the boundary commits ship complete, their ancestors are omitted — -// without the blob loss a plain have-exclusion would cause. -type shallowBoundaryStorer struct { - storage.Storer - boundary []plumbing.Hash +// commonHaves is the negotiation state of a fetch: the client's haves that +// the server also has, as upstream tracks them in have_obj and with the +// THEY_HAVE flag, and the last answer of okToGiveUp. +type commonHaves struct { + st storage.Storer + // wants are the commits that must reach the client's history before + // negotiation can stop. + wants []plumbing.Hash + // grafts are the commits taken as parentless, upstream's registered + // shallow commits. + grafts map[plumbing.Hash]struct{} + + // counted holds the common haves not already implied by an earlier one, + // upstream's have_obj. + counted []plumbing.Hash + // theyHave holds every common have and the parents of common commits, + // upstream's THEY_HAVE flag. + theyHave map[plumbing.Hash]struct{} + // oldest is the committer date, in seconds since the epoch, of the oldest + // common commit; the walk in okToGiveUp does not go below it. Zero means + // no common commit yet, as upstream's oldest_have, so a commit dated zero + // does not pin it. + oldest int64 + // last is the most recent common have. + last plumbing.Hash + // added holds every have add has processed and whether the server has + // it, so a repeated have is not read again. + added map[plumbing.Hash]bool + + // nodes holds the commits read so far, nil for a commit the server does + // not have. Upstream keeps parsed commits in memory and clears only its + // marks between walks; keeping them here makes a repeated walk as cheap. + nodes map[plumbing.Hash]*commitNode + // starts are the wants peeled to commits, oldest first. okToGiveUp fills + // it on its first walk and sets startsKnown, as no want may peel to one. + starts []plumbing.Hash + startsKnown bool + // checked reports that ready holds the answer of okToGiveUp for the + // current theyHave and oldest. + checked bool + ready bool + // gen numbers the walks of okToGiveUp. A node stamped with the current + // gen was visited, or reaches a common commit, in this walk, as + // upstream marks commits and clears the marks after each walk. + gen uint64 + // stack is the walk's stack, kept so that each walk reuses its backing + // array rather than growing a new one. + stack []*commitNode } -func (s *shallowBoundaryStorer) Shallow() ([]plumbing.Hash, error) { - base, err := s.Storer.Shallow() +// newCommonHaves returns the negotiation state of a fetch of wants, before +// any have is known, in which the commits in grafts and the server's own +// shallow commits have no parents. Upstream registers the latter when it +// reads the repository, so they bound both walks in every protocol version. +func newCommonHaves(st storage.Storer, wants, grafts []plumbing.Hash) (*commonHaves, error) { + shallows, err := st.Shallow() + if err != nil { + return nil, fmt.Errorf("reading shallow commits: %w", err) + } + c := &commonHaves{ + st: st, + wants: wants, + grafts: make(map[plumbing.Hash]struct{}, len(grafts)+len(shallows)), + theyHave: map[plumbing.Hash]struct{}{}, + added: map[plumbing.Hash]bool{}, + nodes: map[plumbing.Hash]*commitNode{}, + } + for _, h := range slices.Concat(grafts, shallows) { + c.grafts[h] = struct{}{} + } + return c, nil +} + +// commitNode is what the negotiation needs of a commit. +type commitNode struct { + // date is the committer date, in seconds since the epoch. + date int64 + // parents are none for a grafted commit. + parents []plumbing.Hash + // parentNodes holds the nodes of the first resolved parents, nil for a + // parent the server does not have. A walk resolves the parents in order, + // the first time it scans each, so later walks follow them without + // looking them up in nodes. + parentNodes []*commitNode + resolved int + // theyHave mirrors the commit's membership of commonHaves.theyHave. + theyHave bool + // visited and reaches hold the gen of the last walk of okToGiveUp that + // visited the commit, and that found it reaches a common commit. + visited, reaches uint64 +} + +// remember records commit in nodes and returns its node. +func (c *commonHaves) remember(commit *object.Commit) *commitNode { + n := &commitNode{date: commit.Committer.When.Unix(), parents: commit.ParentHashes} + if _, ok := c.grafts[commit.Hash]; ok { + n.parents = nil + } + _, n.theyHave = c.theyHave[commit.Hash] + c.nodes[commit.Hash] = n + return n +} + +// markHave adds h to theyHave and reports whether it was not there yet. +func (c *commonHaves) markHave(h plumbing.Hash) bool { + if _, ok := c.theyHave[h]; ok { + return false + } + c.theyHave[h] = struct{}{} + if n := c.nodes[h]; n != nil { + n.theyHave = true + } + return true +} + +// node returns the node of commit h, reading it only if nodes does not hold +// it yet, or nil if the server does not have h. +func (c *commonHaves) node(h plumbing.Hash) (*commitNode, error) { + if n, ok := c.nodes[h]; ok { + return n, nil + } + commit, err := object.GetCommit(c.st, h) + if errors.Is(err, plumbing.ErrObjectNotFound) { + c.nodes[h] = nil + return nil, nil + } if err != nil { return nil, err } - if len(s.boundary) == 0 { - return base, nil + return c.remember(commit), nil +} + +// parentNode returns the node of the i-th parent of n, as node does, and +// keeps it in n so that the next walk does not look it up again. The parents +// before i must have been resolved already, as a walk scans them in order. +func (c *commonHaves) parentNode(n *commitNode, i int) (*commitNode, error) { + if i < n.resolved { + return n.parentNodes[i], nil } - return append(append([]plumbing.Hash(nil), base...), s.boundary...), nil + p, err := c.node(n.parents[i]) + if err != nil { + return nil, err + } + if n.parentNodes == nil { + n.parentNodes = make([]*commitNode, len(n.parents)) + } + n.parentNodes[i] = p + n.resolved = i + 1 + return p, nil } -// wantsReachableFromHaves reports whether every want is reachable from the set -// of common haves — upstream's ok_to_give_up (upload-pack.c). A want is anchored -// when a common have is the want itself or one of its ancestors, i.e. the want -// can reach a have by walking parents. Tags are peeled to commits first, as the -// ancestry walk operates on commits. Returns false (keep negotiating) if any -// want cannot be resolved to a commit or is not yet anchored. -func wantsReachableFromHaves(st storage.Storer, wants, commonHaves []plumbing.Hash) bool { - haveSet := make(map[plumbing.Hash]struct{}, len(commonHaves)) - haveCommits := make([]*object.Commit, 0, len(commonHaves)) - for _, h := range commonHaves { - haveSet[h] = struct{}{} - if c, ok := peelToCommit(st, h); ok { - haveCommits = append(haveCommits, c) +// add records the have h and reports whether the server has it, returning an +// error if the object cannot be read. It mirrors upstream got_oid and +// do_got_oid: the parents of a common commit count as had before the commit +// itself is checked, and the oldest common commit bounds okToGiveUp. A have +// that adds no commit to theyHave and does not move that bound, such as a +// repeated have or a blob, keeps the answer okToGiveUp last gave. +// +// A have add has already processed is answered without reading it again, and +// a commit an earlier walk read is not read again either. Of any other +// object only the type is looked up, as upstream does for a have that is not +// a commit, so a have naming a large blob, or a delta against one, is not +// inflated; a commit is then read. +func (c *commonHaves) add(h plumbing.Hash) (bool, error) { + if had, ok := c.added[h]; ok { + if had { + c.last = h + } + return had, nil + } + + n, isCommit := c.nodes[h] + if !isCommit || n == nil { + typ, err := storer.EncodedObjectType(c.st, h) + if errors.Is(err, plumbing.ErrObjectNotFound) { + c.added[h] = false + return false, nil + } + if err != nil { + return false, err + } + isCommit = typ == plumbing.CommitObject + if isCommit { + commit, err := object.GetCommit(c.st, h) + if err != nil { + return false, err + } + n = c.remember(commit) } } + c.added[h] = true - for _, wHash := range wants { - wc, ok := peelToCommit(st, wHash) - if !ok { - return false + c.last = h + if isCommit { + if c.oldest == 0 || n.date < c.oldest { + c.oldest = n.date + c.checked = false } - if _, ok := haveSet[wc.Hash]; ok { - continue + for _, p := range n.parents { + if c.markHave(p) { + c.checked = false + } } - anchored := false - for _, hc := range haveCommits { - if hc.Hash == wc.Hash { - anchored = true - break + } + if c.markHave(h) { + c.counted = append(c.counted, h) + if isCommit { + c.checked = false + } + } + return true, nil +} + +// okToGiveUp reports whether every want reaches a commit the client has, so +// that negotiation can stop. It mirrors upstream ok_to_give_up and +// can_all_from_reach_with_flag (commit-reach.c): a depth-first walk per want, +// oldest want first, sharing what earlier walks in the same call learned, +// that does not descend below the oldest common commit. Upstream orders the +// wants by generation number and then by date; without a commit-graph every +// generation number is the same, so the date decides. It reports false while +// no have is common, as upstream does. A want that does not peel to a commit +// cannot be judged by ancestry and does not hold negotiation back, but one +// that cannot be read is an error, unlike upstream in one case; see +// peelWant. +// +// The answer depends only on theyHave, oldest and the wants, so it is +// returned again without a walk until add changes one of them. Otherwise it +// walks again from scratch, as upstream does for every have it lacks, but +// over the commits in nodes, so only commits no earlier walk reached are read +// from storage. It is not monotonic: when a commit is dated before its parent, +// a lower cutoff can let the walk from one want visit a commit before the +// walk from another want marks it, and a true answer can turn false. A walk +// that finds ctx done stops and returns ctx's error. +func (c *commonHaves) okToGiveUp(ctx context.Context) (bool, error) { + if len(c.counted) == 0 { + return false, nil + } + if c.checked { + return c.ready, nil + } + + if !c.startsKnown { + for _, w := range c.wants { + start, err := peelWant(c.st, w) + if err != nil { + c.starts = c.starts[:0] + return false, fmt.Errorf("reading want %s: %w", w, err) } - if isAnc, err := hc.IsAncestor(wc); err == nil && isAnc { - anchored = true + if start != nil { + c.remember(start) + c.starts = append(c.starts, start.Hash) + } + } + slices.SortStableFunc(c.starts, func(a, b plumbing.Hash) int { + return cmp.Compare(c.nodes[a].date, c.nodes[b].date) + }) + c.startsKnown = true + } + + c.gen++ + gen := c.gen + marked := func(n *commitNode) bool { + return n.theyHave || n.reaches == gen + } + + for _, start := range c.starts { + sn := c.nodes[start] + sn.visited = gen + c.stack = append(c.stack[:0], sn) + stack := c.stack + for len(stack) > 0 { + if err := ctx.Err(); err != nil { + return false, err + } + top := stack[len(stack)-1] + if marked(top) { + stack = stack[:len(stack)-1] + if len(stack) > 0 { + stack[len(stack)-1].reaches = gen + } + continue + } + + // The parents are scanned from the first one each time the walk + // returns to a commit, so a parent marked since marks the commit, + // and the scan still goes on to walk any parent not yet visited. + // What this visits decides what later walks skip. + pushed := false + for i := range top.parents { + n, err := c.parentNode(top, i) + if err != nil { + return false, err + } + if n == nil { + // A parent the server lacks is never walked, but may + // still be one the client has. + if _, ok := c.theyHave[top.parents[i]]; ok { + top.reaches = gen + } + continue + } + if marked(n) { + top.reaches = gen + } + if n.visited == gen { + continue + } + n.visited = gen + if c.oldest != 0 && n.date < c.oldest { + continue + } + stack = append(stack, n) + pushed = true break } + if !pushed { + stack = stack[:len(stack)-1] + } } - if !anchored { - return false + c.stack = stack + + if !marked(sn) { + c.checked, c.ready = true, false + return false, nil + } + } + + c.checked, c.ready = true, true + return true, nil +} + +// peelWant resolves the want h to the commit okToGiveUp walks from, +// following annotated tags. It returns no commit, and no error, when h peels +// to an object that is not a commit, or to a tag whose target the server does +// not have: upstream can_all_from_reach_with_flag skips both, as deref_tag +// gives no object for the latter. Any other failure to read h, a tag or the +// commit is returned. For the want itself that matches upstream, which dies +// on a want it cannot parse (receive_needs). It does not for a tag's target +// that exists but cannot be read: upstream's deref_tag gives no object for it +// too, so upstream skips that want where this returns the error. +func peelWant(st storage.Storer, h plumbing.Hash) (*object.Commit, error) { + for want := true; ; want = false { + typ, err := storer.EncodedObjectType(st, h) + if !want && errors.Is(err, plumbing.ErrObjectNotFound) { + return nil, nil + } + if err != nil { + return nil, err + } + switch typ { + case plumbing.CommitObject: + return object.GetCommit(st, h) + case plumbing.TagObject: + tag, err := object.GetTag(st, h) + if err != nil { + return nil, err + } + h = tag.Target + default: + return nil, nil } } - return true } // peelToCommit resolves h to a commit, following annotated tags. It returns diff --git a/vendor/github.com/go-git/go-git/v6/remote.go b/vendor/github.com/go-git/go-git/v6/remote.go index 4825facd6a..7b525cab82 100644 --- a/vendor/github.com/go-git/go-git/v6/remote.go +++ b/vendor/github.com/go-git/go-git/v6/remote.go @@ -335,7 +335,11 @@ func (r *Remote) addReachableTags(localRefs []*plumbing.Reference, remoteRefs st } if isAncestor, err := tagCommit.IsAncestor(c); err == nil && isAncestor { - *cmds = append(*cmds, &packp.Command{Name: tag.Name(), New: tag.Hash()}) + *cmds = append(*cmds, &packp.Command{ + Name: tag.Name(), + Old: plumbing.ZeroID(tag.Hash().Format()), + New: tag.Hash(), + }) } } } @@ -657,11 +661,8 @@ func referenceStorageFromRefs(refs []*plumbing.Reference, filterPeeled bool) mem // storer will not take can arrive even after the advertisement has been // filtered — "+refs/*:refs/*" onto a remote name go-git holds to a stricter // rule than check_refname_format, say. Git answers per-reference rather than -// per-fetch, in get_fetch_map: -// -// error(_("* Ignoring funny ref '%s' locally"), (*rmp)->peer_ref->name); -// -// and finishes with the references that remain, exiting 0. +// per-fetch: get_fetch_map (remote.c) reports the name it is ignoring, and the +// fetch finishes with the references that remain, exiting 0. // // Every arm of the storer's name gate wraps plumbing.ErrInvalidReferenceName, // so this recognises all of them rather than the format rule alone. That @@ -689,15 +690,9 @@ func unstorableRefName(name, source plumbing.ReferenceName, err error) bool { // out of the storer, so a single unusable name costs that one reference rather // than the whole fetch. // -// This is filter_refs in fetch-pack.c, which checks the same thing in the same -// place and says nothing about it: -// -// if (starts_with(ref->name, "refs/") && -// check_refname_format(ref->name, 0)) { -// /* trash or a peeled value; do not even add it to unmatched list */ -// free_one_ref(ref); -// continue; -// } +// This is what Git does in filter_refs (fetch-pack.c): an advertised name under +// refs/ that fails the format check is dropped without a message, before it +// can be matched against anything. // // Only names under refs/ are judged, as there: HEAD is advertised and is not // one. Git also relies on this to drop the null-object-id entries it emits for @@ -946,7 +941,7 @@ func (r *Remote) deleteReferences(rs config.RefSpec, cmd := &packp.Command{ Name: ref.Name(), Old: ref.Hash(), - New: plumbing.ZeroHash, + New: plumbing.ZeroID(ref.Hash().Format()), } *cmds = append(*cmds, cmd) return nil @@ -963,7 +958,7 @@ func (r *Remote) addObject(rs config.RefSpec, cmd := &packp.Command{ Name: rs.Dst(""), - Old: plumbing.ZeroHash, + Old: plumbing.ZeroID(localObject.Format()), New: localObject, } remoteRef, err := remoteRefs.Reference(cmd.Name) @@ -1007,7 +1002,7 @@ func (r *Remote) addReferenceIfRefSpecMatches(rs config.RefSpec, cmd := &packp.Command{ Name: rs.Dst(localRef.Name()), - Old: plumbing.ZeroHash, + Old: plumbing.ZeroID(localRef.Hash().Format()), New: localRef.Hash(), } @@ -1071,7 +1066,7 @@ func (r *Remote) checkForceWithLease(localRef *plumbing.Reference, cmd *packp.Co } func checkTagUpdate(cmd *packp.Command) error { - if cmd.Name.IsTag() && cmd.Old != plumbing.ZeroHash { + if cmd.Name.IsTag() && !cmd.Old.IsZero() { return fmt.Errorf("tag already exists: %s", cmd.Name.String()) } @@ -1504,24 +1499,22 @@ func (r *Remote) updateLocalReferenceStorage( } } - if tagMode == plumbing.NoTags { - return updated, nil - } - - tags := fetchedRefs - if isWildcard { - tags = remoteRefs - } - tagUpdated, tagForceNeeded, err := r.buildFetchedTags(tags, tagMode == plumbing.AllTags, force) - if err != nil { - return updated, err - } + if tagMode != plumbing.NoTags { + tags := fetchedRefs + if isWildcard { + tags = remoteRefs + } + tagUpdated, tagForceNeeded, err := r.buildFetchedTags(tags, tagMode == plumbing.AllTags, force) + if err != nil { + return updated, err + } - if tagUpdated { - updated = true - } - if tagForceNeeded { - forceNeeded = true + if tagUpdated { + updated = true + } + if tagForceNeeded { + forceNeeded = true + } } if forceNeeded { diff --git a/vendor/github.com/go-git/go-git/v6/repository.go b/vendor/github.com/go-git/go-git/v6/repository.go index 35078fb4e4..39b46a9bc3 100644 --- a/vendor/github.com/go-git/go-git/v6/repository.go +++ b/vendor/github.com/go-git/go-git/v6/repository.go @@ -974,7 +974,7 @@ func (r *Repository) createTagObject(name string, hash plumbing.Hash, opts *Crea // Use Has before Get so the key is not frozen when no plugin is // registered, allowing callers to register one later. if !plugin.Has(plugin.ObjectSigner()) { - return plumbing.ZeroHash, fmt.Errorf("cannot auto-sign tag: disable tag.gpgSign or register an ObjectSigner plugin") + return plumbing.ZeroHash, fmt.Errorf("%w: tag.gpgSign is enabled, disable it, pass a Signer or register an ObjectSigner plugin", ErrNoObjectSigner) } signer, err = plugin.Get(plugin.ObjectSigner()) @@ -2041,12 +2041,22 @@ func (r *Repository) resolveHashPrefix(hashStr string) []plumbing.Hash { if hashStr == "" { return nil } - if len(hashStr) == plumbing.ZeroHash.HexSize() { - h, ok := plumbing.FromHex(hashStr) - if !ok { - return nil + // A full id has the length of the repository's object format. Shorter + // input, such as 40 hex digits in a SHA-256 repository, is a prefix. + // Only full-id lengths depend on the format, so the config is read + // for those alone. + if n := len(hashStr); n == formatcfg.SHA1.HexSize() || n == formatcfg.SHA256.HexSize() { + hexSize := formatcfg.DefaultObjectFormat.HexSize() + if cfg, err := r.Storer.Config(); err == nil && cfg != nil { + hexSize = cfg.Extensions.ObjectFormat.HexSize() + } + if n == hexSize { + h, ok := plumbing.FromHex(hashStr) + if !ok { + return nil + } + return []plumbing.Hash{h} } - return []plumbing.Hash{h} } // Partial hash. diff --git a/vendor/github.com/go-git/go-git/v6/repository_extensions.go b/vendor/github.com/go-git/go-git/v6/repository_extensions.go index 637a926a01..ae5e955656 100644 --- a/vendor/github.com/go-git/go-git/v6/repository_extensions.go +++ b/vendor/github.com/go-git/go-git/v6/repository_extensions.go @@ -31,15 +31,13 @@ var ( // Some extensions are storage-specific, those are defined by the Storers // themselves by implementing the ExtensionChecker interface. builtinExtensions = map[string]struct{}{ - // noop does not change git’s behavior at all. - // It is useful only for testing format-1 compatibility. - // - // This extension is respected regardless of the - // core.repositoryFormatVersion setting. + // noop has no effect. It exists so that extension handling can + // be tested, and is accepted whatever the repository format + // version is. "noop": {}, - // noop-v1 does not change git’s behavior at all. - // It is useful only for testing format-1 compatibility. + // noop-v1 has no effect either, and is accepted only in a + // repository of format version 1. "noop-v1": {}, } diff --git a/vendor/github.com/go-git/go-git/v6/signer.go b/vendor/github.com/go-git/go-git/v6/signer.go index 5f0fe0e6a9..d1940cda91 100644 --- a/vendor/github.com/go-git/go-git/v6/signer.go +++ b/vendor/github.com/go-git/go-git/v6/signer.go @@ -2,11 +2,17 @@ package git import ( "context" + "errors" "io" "github.com/go-git/go-git/v6/plumbing" ) +// ErrNoObjectSigner is returned when commit.gpgSign or tag.gpgSign is enabled +// in the Git configuration, but no Signer was provided and no ObjectSigner +// plugin is registered. +var ErrNoObjectSigner = errors.New("no object signer available") + // signableObject is an object which can be signed. type signableObject interface { EncodeWithoutSignature(o plumbing.EncodedObject) error diff --git a/vendor/github.com/go-git/go-git/v6/storage/filesystem/config.go b/vendor/github.com/go-git/go-git/v6/storage/filesystem/config.go index 2816edaba8..fab41ed3ba 100644 --- a/vendor/github.com/go-git/go-git/v6/storage/filesystem/config.go +++ b/vendor/github.com/go-git/go-git/v6/storage/filesystem/config.go @@ -23,6 +23,9 @@ type ConfigStorage struct { // When the worktreeConfig extension is active and a config.worktree file // exists, the returned config would be the worktree config overlayed over // the commonDir config. +// +// dotgit.DotGit reads core.protectNTFS with the same overlay on its own +// (protectNTFS in dotgit/module.go); keep the two in step. func (c *ConfigStorage) Config() (conf *config.Config, err error) { f, err := c.dir.Config() if err != nil { @@ -95,18 +98,18 @@ func (c *ConfigStorage) SetConfig(cfg *config.Config) (err error) { } } - f, err := c.dir.ConfigWriter() + b, err := cfg.Marshal() if err != nil { return err } - defer ioutil.CheckClose(f, &err) - - b, err := cfg.Marshal() + f, err := c.dir.ConfigWriter() if err != nil { return err } + defer ioutil.CheckClose(f, &err) + _, err = f.Write(b) return err } diff --git a/vendor/github.com/go-git/go-git/v6/storage/filesystem/dotgit/dotgit.go b/vendor/github.com/go-git/go-git/v6/storage/filesystem/dotgit/dotgit.go index 82c32d0ffe..9213a496aa 100644 --- a/vendor/github.com/go-git/go-git/v6/storage/filesystem/dotgit/dotgit.go +++ b/vendor/github.com/go-git/go-git/v6/storage/filesystem/dotgit/dotgit.go @@ -60,6 +60,7 @@ const ( packPrefix = "pack-" packExt = ".pack" idxExt = ".idx" + revExt = ".rev" // promisorExt marks a pack as having been received from a promisor // remote, meaning objects it references but does not contain are @@ -342,12 +343,19 @@ type DotGit struct { objectList []plumbing.Hash // sorted objectMap map[plumbing.Hash]struct{} packList []plumbing.Hash - packMap map[plumbing.Hash]struct{} + packBases map[plumbing.Hash][]string // packHandles caches one [*packhandle.PackHandle] per pack hash, // guarded by packHandlesMu. Lazy-initialised on first use. packHandlesMu sync.Mutex packHandles map[plumbing.Hash]*packhandle.PackHandle + + // foundBases records, outside ExclusiveAccess, the base name of every + // pack the last directory listing found, guarded by foundBasesMu. With + // it, one listing serves every pack not named pack-, and the + // directory is listed again only when a recorded pack's .pack is gone. + foundBasesMu sync.Mutex + foundBases map[plumbing.Hash]string } // New returns a DotGit value ready to be used. The path argument must @@ -411,7 +419,7 @@ func (d *DotGit) Close() error { } } - d.packMap = nil + d.packBases = nil return errors.Join(phErrs...) } @@ -550,28 +558,32 @@ func (d *DotGit) NewPromisorObjectPack(marker string) (*PackWriter, error) { // PromisorObjectPacks returns the hashes of the packs that were received from a // promisor remote, that is those carrying a .promisor marker. func (d *DotGit) PromisorObjectPacks() ([]plumbing.Hash, error) { - packs, err := d.ObjectPacks() + packs, bases, err := d.packCatalog() if err != nil { return nil, err } var promisors []plumbing.Hash for _, h := range packs { - ok, err := d.hasPromisor(h) - if err != nil { - return nil, err - } - if ok { - promisors = append(promisors, h) + for _, base := range bases[h] { + ok, err := d.hasPromisor(base) + if err != nil { + return nil, err + } + if ok { + promisors = append(promisors, h) + break + } } } return promisors, nil } -// hasPromisor reports whether the pack carries a .promisor marker. -func (d *DotGit) hasPromisor(hash plumbing.Hash) (bool, error) { - fi, err := d.fs.Lstat(d.objectPackPath(hash, promisorExt[1:])) +// hasPromisor reports whether the pack stored under base carries a .promisor +// marker. +func (d *DotGit) hasPromisor(base string) (bool, error) { + fi, err := d.fs.Lstat(d.packFilePath(base, promisorExt)) if err != nil { if os.IsNotExist(err) { return false, nil @@ -585,110 +597,227 @@ func (d *DotGit) hasPromisor(hash plumbing.Hash) (bool, error) { // files. Packs without indexes are ignored because they cannot be read, and // PackWriter publishes each index before making its pack visible. func (d *DotGit) ObjectPacks() ([]plumbing.Hash, error) { + packs, _, err := d.packCatalog() + return packs, err +} + +// packCatalog returns the readable packs, along with the base names (the file +// name without its extension) each one is stored under. Under ExclusiveAccess +// the result is cached until the pack set changes. +func (d *DotGit) packCatalog() ([]plumbing.Hash, map[plumbing.Hash][]string, error) { if !d.options.ExclusiveAccess { - return d.objectPacks() + return d.scanPacks() } - err := d.genPackList() - if err != nil { - return nil, err + if err := d.genPackList(); err != nil { + return nil, nil, err } - return d.packList, nil + return d.packList, d.packBases, nil } -func (d *DotGit) objectPacks() ([]plumbing.Hash, error) { - packDir := d.fs.Join(objectsPath, packPath) - files, err := d.fs.ReadDir(packDir) +// scanPacks lists objects/pack: like git, any .pack with an .idx of the same +// base name is a pack whatever its prefix, so the loose- packs of +// `git maintenance run --task=loose-objects` are read alongside pack-. +// Unlike git, the base name must end in -, which is the pack checksum +// and the key the pack is listed under; two names sharing a hash hold the +// same pack, and pack-, the name go-git itself writes, is listed first. +// +// Names starting with a dot are skipped: `git repack` writes its packs as +// .tmp--pack- and then renames them, so reading one races with +// the rename. Git loads them too but retries a pack that vanishes; go-git +// would fail the read instead. +func (d *DotGit) scanPacks() ([]plumbing.Hash, map[plumbing.Hash][]string, error) { + bases := make(map[plumbing.Hash][]string) + files, err := d.fs.ReadDir(d.fs.Join(objectsPath, packPath)) if err != nil { if os.IsNotExist(err) { - return nil, nil + return nil, bases, nil } - return nil, err + return nil, nil, err } - packs := make([]plumbing.Hash, 0, len(files)) - indexes := make(map[string]struct{}, len(files)) + var withPack []string + withIdx := make(map[string]struct{}, len(files)) for _, f := range files { n := f.Name() - if !strings.HasPrefix(n, packPrefix) { + if strings.HasPrefix(n, ".") { + continue + } + if base, ok := strings.CutSuffix(n, packExt); ok { + withPack = append(withPack, base) + } else if base, ok := strings.CutSuffix(n, idxExt); ok { + withIdx[base] = struct{}{} + } + } + + packs := make([]plumbing.Hash, 0, len(withPack)) + for _, base := range withPack { + if _, ok := withIdx[base]; !ok { continue } - switch { - case strings.HasSuffix(n, packExt): - name := n[len(packPrefix) : len(n)-len(packExt)] - h := plumbing.NewHash(name) - if !h.IsZero() && h.String() == name { - packs = append(packs, h) - } - case strings.HasSuffix(n, idxExt): - name := n[len(packPrefix) : len(n)-len(idxExt)] - h := plumbing.NewHash(name) - if !h.IsZero() && h.String() == name { - indexes[name] = struct{}{} - } + h, ok := packBaseHash(base) + if !ok { + continue + } + + if _, seen := bases[h]; !seen { + packs = append(packs, h) + } + if base == packPrefix+h.String() { + bases[h] = slices.Insert(bases[h], 0, base) + } else { + bases[h] = append(bases[h], base) } } - return slices.DeleteFunc(packs, func(h plumbing.Hash) bool { - _, ok := indexes[h.String()] - return !ok - }), nil + return packs, bases, nil } -func (d *DotGit) objectPackPath(hash plumbing.Hash, extension string) string { - return d.fs.Join(objectsPath, packPath, fmt.Sprintf("pack-%s.%s", hash.String(), extension)) +// packBaseHash parses the hash from a pack base name of the form +// -, which is how `git pack-objects ` names its +// output. +func packBaseHash(base string) (plumbing.Hash, bool) { + i := strings.LastIndexByte(base, '-') + if i < 0 { + return plumbing.ZeroHash, false + } + + hex := base[i+1:] + h := plumbing.NewHash(hex) + return h, !h.IsZero() && h.String() == hex } -func (d *DotGit) objectPackOpen(hash plumbing.Hash, extension string) (billy.File, error) { - err := d.hasPack(hash) - if err != nil { - return nil, err +// cachedPackBase returns the base name the pack is listed under in the +// ExclusiveAccess catalog. +func (d *DotGit) cachedPackBase(hash plumbing.Hash) (string, error) { + if err := d.genPackList(); err != nil { + return "", err } - path := d.objectPackPath(hash, extension) - pack, err := d.fs.Open(path) - if err != nil { + bases, ok := d.packBases[hash] + if !ok { + return "", ErrPackfileNotFound + } + + return bases[0], nil +} + +// withPackFile calls op with the path of the pack's file with extension ext. +// A file that does not exist is reported as [ErrPackfileNotFound], whatever +// the access mode. Outside ExclusiveAccess, op is tried on the base name the +// last directory listing found the pack under, or pack- when it has +// not been listed, and the directory is listed again only when the pack has +// not been listed or its .pack is gone, so the common case costs no syscall +// beyond op itself. +func (d *DotGit) withPackFile(hash plumbing.Hash, ext string, op func(path string) error) error { + opAt := func(base string) error { + err := op(d.packFilePath(base, ext)) if os.IsNotExist(err) { - return nil, ErrPackfileNotFound + return ErrPackfileNotFound } + return err + } - return nil, err + if d.options.ExclusiveAccess { + base, err := d.cachedPackBase(hash) + if err != nil { + return err + } + + return opAt(base) + } + + d.foundBasesMu.Lock() + base, recorded := d.foundBases[hash] + d.foundBasesMu.Unlock() + if !recorded { + base = packPrefix + hash.String() + } + + err := opAt(base) + if !errors.Is(err, ErrPackfileNotFound) { + return err } - return pack, nil + // A recorded name can go stale, for instance when another goroutine + // lists the directory while DeleteOldObjectPackAndIndex removes the + // pack. The lazy index reopens the .idx without opening the .pack, so + // the .pack is checked before trusting the record. + if recorded && ext != packExt { + if _, statErr := d.fs.Lstat(d.packFilePath(base, packExt)); statErr == nil { + return err + } + } + + _, bases, scanErr := d.scanPacks() + if scanErr != nil { + return scanErr + } + + found := make(map[plumbing.Hash]string, len(bases)) + for h, b := range bases { + found[h] = b[0] + } + d.foundBasesMu.Lock() + d.foundBases = found + d.foundBasesMu.Unlock() + + listed, ok := found[hash] + if !ok || listed == base { + return err + } + + return opAt(listed) +} + +// packFilePath returns the path of the file with extension ext of the pack +// stored under base. +func (d *DotGit) packFilePath(base, ext string) string { + return d.fs.Join(objectsPath, packPath, base+ext) +} + +// objectPackOpen opens the pack's file with extension ext. +func (d *DotGit) objectPackOpen(hash plumbing.Hash, ext string) (billy.File, error) { + var f billy.File + err := d.withPackFile(hash, ext, func(path string) (err error) { + f, err = d.fs.Open(path) + return err + }) + + return f, err +} + +// packFileSize returns the size of the pack's file with extension ext. +func (d *DotGit) packFileSize(hash plumbing.Hash, ext string) (int64, error) { + var size int64 + err := d.withPackFile(hash, ext, func(path string) error { + fi, err := d.fs.Stat(path) + if err != nil { + return err + } + size = fi.Size() + return nil + }) + + return size, err } // ObjectPack returns a fs.File of the given packfile. func (d *DotGit) ObjectPack(hash plumbing.Hash) (billy.File, error) { - err := d.hasPack(hash) - if err != nil { - return nil, err - } - - return d.objectPackOpen(hash, `pack`) + return d.objectPackOpen(hash, packExt) } // ObjectPackIdx returns a fs.File of the index file for a given packfile. func (d *DotGit) ObjectPackIdx(hash plumbing.Hash) (billy.File, error) { - err := d.hasPack(hash) - if err != nil { - return nil, err - } - - return d.objectPackOpen(hash, `idx`) + return d.objectPackOpen(hash, idxExt) } // ObjectPackRev returns a fs.File of the reverse index file for a given packfile. func (d *DotGit) ObjectPackRev(hash plumbing.Hash) (billy.File, error) { - err := d.hasPack(hash) - if err != nil { - return nil, err - } - - return d.objectPackOpen(hash, `rev`) + return d.objectPackOpen(hash, revExt) } // OpenPackRev returns a [idxfile.ReadAtCloser] for the reverse index of the given @@ -763,24 +892,19 @@ func (d *DotGit) packHandle(hash plumbing.Hash) (*packhandle.PackHandle, error) return h, nil } - if err := d.hasPack(hash); err != nil { - return nil, err + if d.options.ExclusiveAccess { + if _, err := d.cachedPackBase(hash); err != nil { + return nil, err + } } - packPath := d.objectPackPath(hash, "pack") - idxPath := d.objectPackPath(hash, "idx") - sources := packhandle.Sources{ Pack: packhandle.Source{ Open: func() (packhandle.ReadAtCloser, error) { return d.ObjectPack(hash) }, Size: func() (int64, error) { - fi, err := d.fs.Stat(packPath) - if err != nil { - return 0, err - } - return fi.Size(), nil + return d.packFileSize(hash, packExt) }, }, Idx: packhandle.Source{ @@ -788,11 +912,7 @@ func (d *DotGit) packHandle(hash plumbing.Hash) (*packhandle.PackHandle, error) return d.ObjectPackIdx(hash) }, Size: func() (int64, error) { - fi, err := d.fs.Stat(idxPath) - if err != nil { - return 0, err - } - return fi.Size(), nil + return d.packFileSize(hash, idxExt) }, }, Rev: packhandle.Source{ @@ -896,7 +1016,13 @@ func (a packHandleAdapter) PackHash() (plumbing.Hash, error) { return m.ID, nil } -// DeleteOldObjectPackAndIndex removes a pack and its index if older than t. +// DeleteOldObjectPackAndIndex removes the pack- copy of a pack and its +// index if older than t. Copies under other names, such as the loose- +// packs of `git maintenance run --task=loose-objects`, are left in place, and +// while they are, pack- files that are missing are not an error: those +// packs hold objects that only the index or a reflog reach, which a repack +// that walks only the refs does not copy into the pack that replaces them. +// // The .pack, .idx, .rev and .promisor files are each attempted independently; // any failures are joined into the returned error so a partial failure cannot // leave orphaned siblings on disk. A missing .rev is not an error — the @@ -913,9 +1039,23 @@ func (d *DotGit) DeleteOldObjectPackAndIndex(hash plumbing.Hash, t time.Time) er errs = append(errs, err) } - packPath := d.objectPackPath(hash, `pack`) + base := packPrefix + hash.String() + _, listed, err := d.scanPacks() + if err != nil { + errs = append(errs, err) + return errors.Join(errs...) + } + // While the pack stays readable under another name, whatever is left of + // pack- is an orphan, and files missing from it are not an error. + storedElsewhere := slices.ContainsFunc(listed[hash], func(b string) bool { return b != base }) + + packPath := d.packFilePath(base, packExt) + fi, err := d.fs.Stat(packPath) + if storedElsewhere && os.IsNotExist(err) { + return errors.Join(errs...) + } + if !t.IsZero() { - fi, err := d.fs.Stat(packPath) if err != nil { errs = append(errs, err) return errors.Join(errs...) @@ -936,24 +1076,32 @@ func (d *DotGit) DeleteOldObjectPackAndIndex(hash plumbing.Hash, t time.Time) er if err := d.fs.Remove(packPath); err != nil { if !os.IsNotExist(err) { packGone = false + errs = append(errs, err) + } else if !storedElsewhere { + errs = append(errs, err) } - errs = append(errs, err) } - siblings := []string{`idx`, `rev`} + siblings := []string{idxExt, revExt} if packGone { - siblings = append(siblings, `promisor`) + siblings = append(siblings, promisorExt) } for _, ext := range siblings { - if err := d.fs.Remove(d.objectPackPath(hash, ext)); err != nil { - if (ext == `rev` || ext == `promisor`) && os.IsNotExist(err) { + if err := d.fs.Remove(d.packFilePath(base, ext)); err != nil { + if (storedElsewhere || ext == revExt || ext == promisorExt) && os.IsNotExist(err) { continue } errs = append(errs, err) } } + // A reader may have recorded pack- since cleanPackList dropped the + // records above. + d.foundBasesMu.Lock() + delete(d.foundBases, hash) + d.foundBasesMu.Unlock() + d.packHandlesMu.Lock() ph, ok := d.packHandles[hash] if ok { @@ -1155,9 +1303,13 @@ func (d *DotGit) hasObject(h plumbing.Hash) error { // The errors are joined and returned so callers can surface them // rather than silently masking I/O failures during cleanup. func (d *DotGit) cleanPackList() error { - d.packMap = nil + d.packBases = nil d.packList = nil + d.foundBasesMu.Lock() + d.foundBases = nil + d.foundBasesMu.Unlock() + d.packHandlesMu.Lock() handles := d.packHandles d.packHandles = nil @@ -1173,41 +1325,16 @@ func (d *DotGit) cleanPackList() error { } func (d *DotGit) genPackList() error { - if d.packMap != nil { + if d.packBases != nil { return nil } - op, err := d.objectPacks() + packs, bases, err := d.scanPacks() if err != nil { return err } - d.packMap = make(map[plumbing.Hash]struct{}, len(op)) - d.packList = nil - - for _, h := range op { - d.packList = append(d.packList, h) - d.packMap[h] = struct{}{} - } - - return nil -} - -func (d *DotGit) hasPack(h plumbing.Hash) error { - if !d.options.ExclusiveAccess { - return nil - } - - err := d.genPackList() - if err != nil { - return err - } - - _, ok := d.packMap[h] - if !ok { - return ErrPackfileNotFound - } - + d.packList, d.packBases = packs, bases return nil } @@ -1351,7 +1478,8 @@ func (d *DotGit) checkReferenceAndTruncate(f billy.File, old *plumbing.Reference } // SetRef stores a reference, optionally checking that old matches the current value. -// The reference name must pass the write checks described by DotGit. +// The reference name must pass the write checks described by DotGit, and the +// target of a symbolic reference must pass the read checks. func (d *DotGit) SetRef(r, old *plumbing.Reference) error { if err := validNewReferenceName(r.Name()); err != nil { return err @@ -1360,6 +1488,15 @@ func (d *DotGit) SetRef(r, old *plumbing.Reference) error { var content string switch r.Type() { case plumbing.SymbolicReference: + // The target becomes a path under .git each time the reference is + // resolved, and a remote can choose it through a symref-target. Git + // writes a target verbatim and refuses to resolve one that fails + // refname_is_safe, so only path safety is required here. A target + // that fails the format rules, such as clone's refs/heads/.invalid + // placeholder, is still accepted. + if err := validReferenceName(r.Target()); err != nil { + return fmt.Errorf("symbolic reference %q target: %w", r.Name(), err) + } content = fmt.Sprintf("ref: %s\n", r.Target()) case plumbing.HashReference: content = fmt.Sprintln(r.Hash().String()) @@ -1898,7 +2035,15 @@ func (d *DotGit) PackRefs() (err error) { // cleaned. The config-layer parser also validates submodule names, // but Module may be reached from any caller that constructs a // Submodule struct programmatically and so bypasses the parser. +// +// path.Clean does not account for filesystem-specific aliases of the +// current or the parent directory, so the name is checked with +// pathutil.ValidStorageName, as the config layer checks it, before the +// path is constructed. func (d *DotGit) Module(name string) (billy.Filesystem, error) { + if err := d.checkModuleName(name, runtime.GOOS == "windows"); err != nil { + return nil, err + } p := d.fs.Join(modulePath, name) cleaned := path.Clean(filepath.ToSlash(p)) if cleaned != modulePath && !strings.HasPrefix(cleaned, modulePath+"/") { diff --git a/vendor/github.com/go-git/go-git/v6/storage/filesystem/dotgit/module.go b/vendor/github.com/go-git/go-git/v6/storage/filesystem/dotgit/module.go new file mode 100644 index 0000000000..0c26ba3dcb --- /dev/null +++ b/vendor/github.com/go-git/go-git/v6/storage/filesystem/dotgit/module.go @@ -0,0 +1,100 @@ +package dotgit + +import ( + "errors" + "strings" + + "github.com/go-git/go-billy/v6" + + "github.com/go-git/go-git/v6/config" + "github.com/go-git/go-git/v6/internal/pathutil" +) + +// ErrModuleNameInvalid is returned by [DotGit.Module] when a submodule +// name stays below the modules/ subtree but cannot name a directory +// there: it holds a NUL or ends in a separator, or, on Windows under +// core.protectNTFS, one of its components is not a valid Win32 file name. +// A name that addresses modules/ itself or a directory outside it returns +// [ErrModuleNameEscape] instead. +var ErrModuleNameInvalid = errors.New("submodule name is not a valid storage name") + +// checkModuleName refuses a storage name Module must not use. win32 +// applies the rules of a Windows host, so both hosts' policies can be +// tested on either. +// +// Creating the directory on Windows needs a valid Win32 name, as Git's +// mingw mkdir wrapper requires under core.protectNTFS, its default[1]. +// With the setting off, Git's is_valid_win32_path accepts any name[2], +// and so does Module. The .gitmodules parser does not apply this check, +// as Git lists such a submodule. +// +// [1]: https://github.com/git/git/blob/v2.54.0/compat/mingw.c#L597-L606 +// [2]: https://github.com/git/git/blob/v2.54.0/compat/mingw.c#L3347-L3353 +func (d *DotGit) checkModuleName(name string, win32 bool) error { + if !pathutil.ValidStorageName(name) { + if moduleNameEscapes(name) { + return ErrModuleNameEscape + } + return ErrModuleNameInvalid + } + if !win32 { + return nil + } + for part := range strings.FieldsFuncSeq(name, isModuleNameSep) { + // The configuration is read only for a name the check refuses, + // so an ordinary name costs no read. + if !pathutil.Win32ValidPath(part) && d.protectNTFS() { + return ErrModuleNameInvalid + } + } + return nil +} + +// moduleNameEscapes reports whether a name pathutil.ValidStorageName +// refuses would address modules/ itself or a directory outside it: an +// empty name, a leading separator or drive prefix, or a component naming +// "." or "..", literally or in an NTFS or HFS+ spelling. The other names +// it refuses, with a NUL or a trailing separator, stay below modules/. +func moduleNameEscapes(name string) bool { + if name == "" || isModuleNameSep(rune(name[0])) || (len(name) >= 2 && name[1] == ':') { + return true + } + for part := range strings.FieldsFuncSeq(name, isModuleNameSep) { + if pathutil.IsDotOrDotDotName(part) || pathutil.IsDotName(part) { + return true + } + } + return false +} + +func isModuleNameSep(r rune) bool { return r == '/' || r == '\\' } + +// protectNTFS reports core.protectNTFS as the repository's configuration +// sets it, with a config.worktree overlaying it as ConfigStorage does. +// Unset, it is true, Git's default on every host. A configuration that +// cannot be read counts as unset, so the check stays on. +func (d *DotGit) protectNTFS() bool { + v, worktreeConfig := readProtectNTFS(d.Config) + if worktreeConfig { + if wv, _ := readProtectNTFS(d.ConfigWorktree); wv.IsSet() { + v = wv + } + } + return !v.IsSet() || v.IsTrue() +} + +// readProtectNTFS reads core.protectNTFS and extensions.worktreeConfig +// from the file open returns. A missing or unreadable file reports both +// unset. +func readProtectNTFS(open func() (billy.File, error)) (config.OptBool, bool) { + f, err := open() + if err != nil { + return config.OptBoolUnset, false + } + defer func() { _ = f.Close() }() + cfg, err := config.ReadConfig(f) + if err != nil { + return config.OptBoolUnset, false + } + return cfg.Core.ProtectNTFS, cfg.Extensions.WorktreeConfig +} diff --git a/vendor/github.com/go-git/go-git/v6/storage/filesystem/dotgit/openpack.go b/vendor/github.com/go-git/go-git/v6/storage/filesystem/dotgit/openpack.go index db4ee30595..2dc2185058 100644 --- a/vendor/github.com/go-git/go-git/v6/storage/filesystem/dotgit/openpack.go +++ b/vendor/github.com/go-git/go-git/v6/storage/filesystem/dotgit/openpack.go @@ -46,10 +46,19 @@ func (d *DotGit) OpenPackForReading(hash plumbing.Hash) (billy.File, error) { return nil, errors.New("dotgit: pack reader does not support ReadAt") } + // The handle resolved which base name the pack is stored under when + // it opened the file, so the name comes from that file rather than + // from another lookup. FSObject reopens the pack by this name. + named, ok := pr.(interface{ Name() string }) + if !ok || named.Name() == "" { + _ = pr.Close() + return nil, errors.New("dotgit: pack reader does not report its file name") + } + return &readOnlyPackFile{ cursor: pr, ra: ra, - name: d.objectPackPath(hash, "pack"), + name: named.Name(), fs: d.fs, }, nil } diff --git a/vendor/github.com/go-git/go-git/v6/storage/filesystem/dotgit/repository_filesystem.go b/vendor/github.com/go-git/go-git/v6/storage/filesystem/dotgit/repository_filesystem.go index 924fe30ee7..b6ed5c6eea 100644 --- a/vendor/github.com/go-git/go-git/v6/storage/filesystem/dotgit/repository_filesystem.go +++ b/vendor/github.com/go-git/go-git/v6/storage/filesystem/dotgit/repository_filesystem.go @@ -100,6 +100,16 @@ func (fs *RepositoryFilesystem) Remove(filename string) error { return fs.mapToRepositoryFsByPath(filename).Remove(filename) } +// Chmod changes the mode of a file in the appropriate filesystem. It returns +// [billy.ErrNotSupported] when that filesystem cannot change modes. +func (fs *RepositoryFilesystem) Chmod(name string, mode os.FileMode) error { + c, ok := fs.mapToRepositoryFsByPath(name).(billy.Chmod) + if !ok { + return billy.ErrNotSupported + } + return c.Chmod(name, mode) +} + // Join joins path elements using the dot-git filesystem. func (fs *RepositoryFilesystem) Join(elem ...string) string { return fs.dotGitFs.Join(elem...) @@ -140,6 +150,12 @@ func (fs *RepositoryFilesystem) Chroot(path string) (billy.Filesystem, error) { return fs.mapToRepositoryFsByPath(path).Chroot(path) } +// CommonFilesystem returns the filesystem of the common directory, or nil +// when there is none, as for a repository that is not a linked worktree. +func (fs *RepositoryFilesystem) CommonFilesystem() billy.Filesystem { + return fs.commonDotGitFs +} + // Root returns the root path of the dot-git filesystem. func (fs *RepositoryFilesystem) Root() string { return fs.dotGitFs.Root() diff --git a/vendor/github.com/go-git/go-git/v6/storage/filesystem/dotgit/writers.go b/vendor/github.com/go-git/go-git/v6/storage/filesystem/dotgit/writers.go index 65b010aa72..f9d096b860 100644 --- a/vendor/github.com/go-git/go-git/v6/storage/filesystem/dotgit/writers.go +++ b/vendor/github.com/go-git/go-git/v6/storage/filesystem/dotgit/writers.go @@ -1,11 +1,14 @@ package dotgit import ( + "bytes" "crypto" "errors" "fmt" "hash" "io" + "os" + "sync" "sync/atomic" "github.com/go-git/go-billy/v6" @@ -17,14 +20,18 @@ import ( "github.com/go-git/go-git/v6/plumbing/format/packfile" "github.com/go-git/go-git/v6/plumbing/format/revfile" githash "github.com/go-git/go-git/v6/plumbing/hash" + "github.com/go-git/go-git/v6/plumbing/storer" + "github.com/go-git/go-git/v6/utils/ioutil" + "github.com/go-git/go-git/v6/utils/trace" ) -// PackWriter is a io.Writer that generates the packfile index simultaneously, -// a packfile.Decoder is used with a file reader to read the file being written -// this operation is synchronized with the write operations. -// The packfile is written in a temp file, when Close is called this file -// is renamed/moved (depends on the Filesystem implementation) to the final -// location, if the PackWriter is not used, nothing is written. +var _ storer.PackReader = (*PackWriter)(nil) + +var errReadPackCalled = errors.New("dotgit: ReadPack already called") + +// A PackWriter writes a packfile to a temporary file, building its index as +// the data arrives through [PackWriter.Write] or [PackWriter.ReadPack]. +// [PackWriter.Close] moves the pack and its index into place. type PackWriter struct { Notify func(plumbing.Hash, *idxfile.Writer) @@ -32,9 +39,12 @@ type PackWriter struct { fr, fw billy.File synced *syncedReader checksum plumbing.Hash + size int64 parser *packfile.Parser writer *idxfile.Writer - result chan error + parsed chan struct{} // closed when buildIndex returns + parseErr error // valid once parsed is closed + readPack atomic.Bool // set once ReadPack is called format formatcfg.ObjectFormat writeRev bool // promisor, when non-nil, writes a .promisor sidecar next to the pack @@ -58,7 +68,7 @@ func newPackWrite(fs billy.Filesystem, format formatcfg.ObjectFormat, writeRev b fw: fw, fr: fr, synced: newSyncedReader(fw, fr), - result: make(chan error), + parsed: make(chan struct{}), format: format, writeRev: writeRev, } @@ -70,8 +80,8 @@ func newPackWrite(fs billy.Filesystem, format formatcfg.ObjectFormat, writeRev b } func (w *PackWriter) buildIndex() { + defer close(w.parsed) w.writer = new(idxfile.Writer) - var err error w.parser = packfile.NewParser(w.synced, packfile.WithScannerObservers(w.writer), @@ -79,30 +89,60 @@ func (w *PackWriter) buildIndex() { h, err := w.parser.Parse() if err != nil { - w.result <- err + w.parseErr = err return } w.checksum = h - w.result <- nil + w.size = w.parser.Size() } -// waitBuildIndex waits until buildIndex function finishes, this can terminate -// with a packfile.ErrEmptyPackfile, this means that nothing was written so we -// ignore the error +// waitBuildIndex waits for buildIndex and returns its error, treating an +// empty pack as success. It may be called any number of times. func (w *PackWriter) waitBuildIndex() error { - err := <-w.result - if errors.Is(err, packfile.ErrEmptyPackfile) { + <-w.parsed + if errors.Is(w.parseErr, packfile.ErrEmptyPackfile) { return nil } - return err + return w.parseErr } +// Write appends p to the pack. Once [PackWriter.ReadPack] has been called, +// Write returns an error. func (w *PackWriter) Write(p []byte) (int, error) { + if w.readPack.Load() { + return 0, errReadPackCalled + } + return w.synced.Write(p) } +// ReadPack reads a packfile from r and writes it as [PackWriter.Write] does, +// returning once the pack trailer has been parsed rather than when r reaches +// EOF. Data previously passed to Write is parsed first. ReadPack calls Read +// on r only when the parser needs more data, so it reads past the trailer +// no more than the final Read returns. Those bytes are counted in the result +// but are not part of the saved pack. +// +// ReadPack returns the number of bytes read from r and any error parsing the +// pack, which wraps an error r returned before the trailer. An error returned +// by the Read that completes the pack is ignored. If r is empty, ReadPack +// returns 0, nil. +// +// ReadPack returns an error if it has already been called. Write must not be +// called concurrently with it, and [PackWriter.Close] must still be called. +func (w *PackWriter) ReadPack(r io.Reader) (int64, error) { + if !w.readPack.CompareAndSwap(false, true) { + return 0, errReadPackCalled + } + + cr := &countingReader{r: r} + w.synced.pull(cr) + err := w.waitBuildIndex() + return cr.n, err +} + // Close closes all the file descriptors and save the final packfile, if nothing // was written, the tempfiles are deleted without writing a packfile. func (w *PackWriter) Close() (err error) { @@ -110,24 +150,26 @@ func (w *PackWriter) Close() (err error) { if err == nil && w.Notify != nil && w.writer != nil && w.writer.Finished() { w.Notify(w.checksum, w.writer) } - - close(w.result) }() if err := w.synced.Close(); err != nil { return err } - if err := w.waitBuildIndex(); err != nil { - return err - } + parseErr := w.waitBuildIndex() - if err := w.fr.Close(); err != nil { - return err + // Drop anything written after the pack's checksum: it is not part of the + // pack, and git rejects a .pack with "junk at the end". + var truncErr error + if parseErr == nil && w.size > 0 && w.synced.size() > w.size { + truncErr = w.fw.Truncate(w.size) } - if err := w.fw.Close(); err != nil { - return err + // Close both handles whatever happened, and remove the temporary pack + // when anything failed, returning the cleanup's errors with the cause. + closeErr := errors.Join(truncErr, w.fr.Close(), w.fw.Close()) + if parseErr != nil || closeErr != nil { + return errors.Join(parseErr, closeErr, w.clean()) } if w.writer == nil || !w.writer.Finished() { @@ -141,7 +183,24 @@ func (w *PackWriter) clean() error { return w.fs.Remove(w.fw.Name()) } -func (w *PackWriter) save() error { +// save moves the pack into place with the files that describe it. Each is +// written to a temporary file and renamed to its final name in the order +// Git's index-pack uses[1]: the promisor marker, the pack, its reverse index +// and the index last, so a reader never finds an index whose pack is missing. +// index-pack creates the marker in place instead; renaming it too means a +// failed save never leaves a partial one. A final name that already exists +// is kept when it holds what this writer would write, as Git checks[2]; +// one that does not, such as a truncated index a failed save left, fails +// the save before any file is placed. The promisor marker is kept whatever +// it holds, as index-pack keeps an existing one. +// +// On failure only the temporary files this writer made are removed. A file +// under a final name may be one another writer of the same pack found in +// place and is relying on, so none is ever removed here. +// +// [1]: https://github.com/git/git/blob/v2.54.0/builtin/index-pack.c#L1606-L1638 +// [2]: https://github.com/git/git/blob/v2.54.0/object-file.c#L589-L640 +func (w *PackWriter) save() (err error) { base := w.fs.Join(objectsPath, packPath, fmt.Sprintf("pack-%s", w.checksum)) h := githash.New(crypto.SHA1) @@ -149,105 +208,294 @@ func (w *PackWriter) save() error { h = githash.New(crypto.SHA256) } - // Pack files are content addressable. Each file is checked - // individually — if it already exists on disk, skip creating it. - idxPath := fmt.Sprintf("%s.idx", base) - exists, err := fileExists(w.fs, idxPath) - if err != nil { - return err - } - if !exists { - idx, err := w.fs.Create(idxPath) - if err != nil { - return err + temps := map[string]struct{}{w.fw.Name(): {}} + defer func() { + if err == nil { + return } - - if err := w.encodeIdx(idx, h); err != nil { - _ = idx.Close() - return err + for name := range temps { + if rerr := w.fs.Remove(name); rerr != nil && !errors.Is(rerr, os.ErrNotExist) { + err = errors.Join(err, rerr) + } } + }() - if err := idx.Close(); err != nil { - return err + // discard removes temp when final is already in place. As in Git's + // finalize_object_file[1], failing to remove it only warrants a warning: + // final is what readers use, and the save carries on. + // + // [1]: https://github.com/git/git/blob/v2.54.0/object-file.c#L652-L712 + discard := func(temp string) { + if err := w.fs.Remove(temp); err != nil && !errors.Is(err, os.ErrNotExist) { + trace.General.Printf("failed to remove %s: %v", temp, err) + return } - fixPermissions(w.fs, idxPath) + delete(temps, temp) } - if w.writeRev { - revPath := fmt.Sprintf("%s.rev", base) - exists, err := fileExists(w.fs, revPath) - if err != nil { - return err - } - if !exists { - rev, err := w.fs.Create(revPath) + // checked holds the finals already found to match their temporary file. + checked := map[string]bool{} + + // differ reports that final, already in place, does not hold what temp + // holds. It names final so that a user can remove one an earlier failed + // save left, which fails every save of the pack until removed. + differ := func(temp, final string) error { + return fmt.Errorf("files %q and %q differ in contents; remove %q if an earlier failed save left it", + temp, final, final) + } + + // keep discards temp in favour of final, which is already there. As + // Git's finalize_object_file checks for a collision[1], final must hold + // what temp holds when compare is set: a final file whose contents + // differ, such as a truncated index left by a failed save, fails the + // save rather than being kept. A final that is gone by the time it is + // compared is reported as errVanished. + // + // [1]: https://github.com/git/git/blob/v2.54.0/object-file.c#L589-L640 + keep := func(temp, final string, compare bool) error { + if compare { + same, err := sameContents(w.fs, temp, final) if err != nil { return err } + if !same { + return differ(temp, final) + } + } + discard(temp) + return nil + } - if err := w.encodeRev(rev, h); err != nil { - _ = rev.Close() + // place renames temp to final and records that it is no longer this + // writer's to remove, or keeps final when it is already there. A + // final another writer places between the check and the rename is + // replaced on POSIX, where rename silently overwrites; Git avoids + // that with link(), which go-billy does not offer. On Windows a + // rename over a read-only file fails, and placed files are made + // read-only, so there the rename fails and final is kept. A + // placed file is made read-only unless writable is set. writable also + // marks a final that is kept whatever it holds, as the promisor marker + // is; any other final is compared unless the check of every final + // below already found this one to match. beforeRename, when set, runs + // once, just before temp is renamed. + // + // A final that goes away before it is compared, as a repack removes a + // redundant pack, is placed anew. Git retries that up to six times[1], + // and so does place. Only a final place has seen gone is compared + // again: whatever is there afterwards is another file. A final swapped + // for another in a single step after the check is still taken as + // matching, which needs local write access to objects/pack. + // + // [1]: https://github.com/git/git/blob/v2.54.0/object-file.c#L700-L705 + place := func(temp, final string, writable bool, beforeRename func() error) error { + if temp == "" { + return nil + } + trusted := checked[final] + for retries := 0; ; retries++ { + exists, err := fileExists(w.fs, final) + if err != nil { return err } - - if err := rev.Close(); err != nil { + if !exists { + trusted = false + if beforeRename != nil { + if err := beforeRename(); err != nil { + return err + } + beforeRename = nil + } + err := w.fs.Rename(temp, final) + if err == nil { + delete(temps, temp) + if !writable { + fixPermissions(w.fs, final) + } + return nil + } + if exists, _ := fileExists(w.fs, final); !exists { + return err + } + } + err = keep(temp, final, !writable && !trusted) + if !errors.Is(err, errVanished) { return err } - fixPermissions(w.fs, revPath) + if retries >= maxVanishedRetries { + return fmt.Errorf("unable to write repeatedly vanishing file %q", final) + } } } - packPath := fmt.Sprintf("%s.pack", base) - exists, err = fileExists(w.fs, packPath) + // stage writes a temporary file for final, even when final exists, so + // place can compare the two. + stage := func(prefix string, write func(io.Writer) error) (string, error) { + f, err := w.fs.TempFile(w.fs.Join(objectsPath, packPath), prefix) + if err != nil { + return "", err + } + temps[f.Name()] = struct{}{} + if err := write(f); err != nil { + _ = f.Close() + return "", err + } + return f.Name(), f.Close() + } + + idxPath := base + ".idx" + idxTemp, err := stage("tmp_idx_", func(f io.Writer) error { return w.encodeIdx(f, h) }) if err != nil { return err } - // The marker is written before the pack is moved into place, and only for a - // pack this writer is placing. A pack visible without its marker looks + var revTemp string + revPath := base + ".rev" + if w.writeRev { + revTemp, err = stage("tmp_rev_", func(f io.Writer) error { return w.encodeRev(f, h) }) + if err != nil { + return err + } + } + + packPath := base + ".pack" + + // Every final already in place is checked before any file is placed. + // Git places the pack first too, but Git leaves no partial index + // behind; go-git's older saves could, and a pack placed next to an + // index that does not match it would be listed through that index. + finals := []struct{ temp, final string }{ + {w.fw.Name(), packPath}, + {revTemp, revPath}, + {idxTemp, idxPath}, + } + for _, f := range finals { + if f.temp == "" { + continue + } + exists, err := fileExists(w.fs, f.final) + if err != nil { + return err + } + if !exists { + continue + } + same, err := sameContents(w.fs, f.temp, f.final) + if errors.Is(err, errVanished) { + // The final went away, as a repack removes a redundant pack, + // so place renames the temporary file instead. + continue + } + if err != nil { + return err + } + if !same { + return differ(f.temp, f.final) + } + checked[f.final] = true + } + + // The marker is placed just before the pack, and only when this writer + // renames the pack into place. A pack visible without its marker looks // ordinary, so whatever the promisor remote withheld would read as // corruption until the marker landed; crashing in that window must not be // able to produce a repository git refuses to gc. // - // An identical pack already on disk is left exactly as it is, marked or - // not. Packs are content addressed, so the same hash means the same - // objects, and nothing is missing that was not missing before; marking it - // now would newly declare the repository a partial clone on the strength of - // a duplicate. - if w.promisor != nil && !exists { - promisorPath := fmt.Sprintf("%s%s", base, promisorExt) - promisorExists, err := fileExists(w.fs, promisorPath) - if err != nil { - return err - } - if !promisorExists { - f, err := w.fs.Create(promisorPath) + // A pack already on disk is left exactly as it is, marked or not. Packs + // are content addressed, so the same hash means the same objects, and + // nothing is missing that was not missing before; marking it now would + // newly declare the repository a partial clone on the strength of a + // duplicate. place decides which it is when it gets to the pack: a pack + // it finds in place is left unmarked, and one that went away after the + // check of every final is placed anew with its marker. One another + // writer places after place found it missing is marked too, as the + // marker goes in before the rename that then finds the pack there. + var markPack func() error + if w.promisor != nil { + markPack = func() error { + promisorTemp, err := stage("tmp_promisor_", func(f io.Writer) error { + _, err := io.WriteString(f, *w.promisor) + return err + }) if err != nil { return err } + // The marker keeps the 0600 its temporary file was created with, + // as index-pack --promisor creates it[1]. fetch-pack rewrites an + // existing marker in place[2], which a read-only one would refuse. + // + // [1]: https://github.com/git/git/blob/v2.54.0/builtin/index-pack.c#L1557-L1587 + // [2]: https://github.com/git/git/blob/v2.54.0/pack-write.c#L601-L614 + return place(promisorTemp, base+promisorExt, true, nil) + } + } - if _, err := io.WriteString(f, *w.promisor); err != nil { - _ = f.Close() - return err - } + if err := place(w.fw.Name(), packPath, false, markPack); err != nil { + return err + } + if err := place(revTemp, revPath, false, nil); err != nil { + return err + } + return place(idxTemp, idxPath, false, nil) +} - if err := f.Close(); err != nil { - return err - } - } +// maxVanishedRetries is how many times a save places a final anew that went +// away before it was compared, as Git's finalize_object_file does. +const maxVanishedRetries = 6 + +// errVanished reports that a file sameContents was to compare against is not +// there, as Git's check_collision reports CHECK_COLLISION_DEST_VANISHED. +var errVanished = errors.New("file vanished") + +// sameContents reports whether the files a and b in fs hold the same bytes. +// It returns errVanished when b does not exist. +func sameContents(fs billy.Filesystem, a, b string) (same bool, err error) { + fa, err := fs.Open(a) + if err != nil { + return false, err } + defer ioutil.CheckClose(fa, &err) + fb, err := fs.Open(b) + if errors.Is(err, os.ErrNotExist) { + return false, errVanished + } + if err != nil { + return false, err + } + defer ioutil.CheckClose(fb, &err) - if !exists { - if err := w.fs.Rename(w.fw.Name(), packPath); err != nil { - return err - } - fixPermissions(w.fs, packPath) - } else { - // Pack already exists, clean up the temp file. - return w.clean() + sa, err := fs.Stat(a) + if err != nil { + return false, err + } + sb, err := fs.Stat(b) + if errors.Is(err, os.ErrNotExist) { + return false, errVanished + } + if err != nil { + return false, err + } + if sa.Size() != sb.Size() { + return false, nil } - return nil + bufA, bufB := make([]byte, 32*1024), make([]byte, 32*1024) + for { + na, errA := io.ReadFull(fa, bufA) + nb, errB := io.ReadFull(fb, bufB) + if na != nb || !bytes.Equal(bufA[:na], bufB[:nb]) { + return false, nil + } + endA := errors.Is(errA, io.EOF) || errors.Is(errA, io.ErrUnexpectedEOF) + endB := errors.Is(errB, io.EOF) || errors.Is(errB, io.ErrUnexpectedEOF) + switch { + case errA != nil && !endA: + return false, errA + case errB != nil && !endB: + return false, errB + case endA || endB: + return endA == endB, nil + } + } } // fileExists checks whether path already exists as a regular file. @@ -283,73 +531,103 @@ func (w *PackWriter) encodeRev(writer io.Writer, h hash.Hash) error { return revfile.Encode(writer, h, idx) } +// syncedReader lets a reader trail a writer on the same file: Read +// blocks while it has consumed everything written so far, until the +// next Write or Close, or, once pull has set a source, fetches more from +// it. State is guarded by a single mutex so a wake-up can never slip +// between the reader's check and its wait. type syncedReader struct { w io.Writer r io.ReadSeeker - blocked, done atomic.Uint32 - written, read atomic.Uint64 - news chan bool + mu sync.Mutex + cond *sync.Cond + written, read int64 + done bool + src io.Reader // set by pull; read when the reader catches up + srcBuf []byte // what src is read into; set by pull + srcErr error // sticky error from src, io.EOF included } +// srcBufSize is the size of the buffer src is read into. Read is called +// with the parser's much smaller buffer, and reading src into that would +// take a write to the file for every few KiB. It fits the largest +// side-band-64k packet. +const srcBufSize = 64 << 10 + func newSyncedReader(w io.Writer, r io.ReadSeeker) *syncedReader { - return &syncedReader{ - w: w, - r: r, - news: make(chan bool), - } + s := &syncedReader{w: w, r: r} + s.cond = sync.NewCond(&s.mu) + return s } -func (s *syncedReader) Write(p []byte) (n int, err error) { - defer func() { - written := s.written.Add(uint64(n)) - read := s.read.Load() - if written > read { - s.wake() - } - }() +func (s *syncedReader) Write(p []byte) (int, error) { + n, err := s.w.Write(p) + + s.mu.Lock() + s.written += int64(n) + s.mu.Unlock() + s.cond.Broadcast() - n, err = s.w.Write(p) return n, err } -func (s *syncedReader) Read(p []byte) (n int, err error) { - defer func() { s.read.Add(uint64(n)) }() +// pull makes Read fetch more data from src, appending it to the file, when +// it has consumed everything written so far. +func (s *syncedReader) pull(src io.Reader) { + s.mu.Lock() + s.src = src + s.srcBuf = make([]byte, srcBufSize) + s.mu.Unlock() + s.cond.Broadcast() +} +func (s *syncedReader) Read(p []byte) (int, error) { for { - s.sleep() - n, err = s.r.Read(p) - if err == io.EOF && !s.isDone() && n == 0 { - continue + s.mu.Lock() + for s.read >= s.written && s.src == nil && !s.done { + s.cond.Wait() } + done := s.done + src, srcBuf, srcErr := s.src, s.srcBuf, s.srcErr + caughtUp := s.read >= s.written + s.mu.Unlock() + + if caughtUp && src != nil { + if srcErr != nil { + return 0, srcErr + } - break - } - - return n, err -} + // One read from the source per call: a git:// client sends + // nothing after the pack, so a read past its trailer would + // never return. + n, err := src.Read(srcBuf) + if n > 0 { + if _, werr := s.Write(srcBuf[:n]); werr != nil { + return 0, werr + } + } + if err != nil { + s.mu.Lock() + s.srcErr = err + s.mu.Unlock() + } + if n == 0 { + return 0, err + } + } -func (s *syncedReader) isDone() bool { - return s.done.Load() == 1 -} + n, err := s.r.Read(p) -func (s *syncedReader) isBlocked() bool { - return s.blocked.Load() == 1 -} + s.mu.Lock() + s.read += int64(n) + s.mu.Unlock() -func (s *syncedReader) wake() { - if s.isBlocked() { - s.blocked.Store(0) - s.news <- true - } -} + if err == io.EOF && !done && n == 0 { + continue + } -func (s *syncedReader) sleep() { - read := s.read.Load() - written := s.written.Load() - if read >= written { - s.blocked.Store(1) - <-s.news + return n, err } } @@ -359,17 +637,43 @@ func (s *syncedReader) Seek(offset int64, whence int) (int64, error) { } p, err := s.r.Seek(offset, whence) - s.read.Store(uint64(p)) + + s.mu.Lock() + s.read = p + s.mu.Unlock() return p, err } func (s *syncedReader) Close() error { - s.done.Store(1) - close(s.news) + s.mu.Lock() + s.done = true + s.mu.Unlock() + s.cond.Broadcast() + return nil } +// size returns the number of bytes written. +func (s *syncedReader) size() int64 { + s.mu.Lock() + defer s.mu.Unlock() + + return s.written +} + +// countingReader counts the bytes read through it. +type countingReader struct { + r io.Reader + n int64 +} + +func (c *countingReader) Read(p []byte) (int, error) { + n, err := c.r.Read(p) + c.n += int64(n) + return n, err +} + // ObjectWriter writes a single git object to the filesystem. type ObjectWriter struct { objfile.Writer diff --git a/vendor/github.com/go-git/go-git/v6/storage/filesystem/object.go b/vendor/github.com/go-git/go-git/v6/storage/filesystem/object.go index 36c1c69f3f..df9aca102f 100644 --- a/vendor/github.com/go-git/go-git/v6/storage/filesystem/object.go +++ b/vendor/github.com/go-git/go-git/v6/storage/filesystem/object.go @@ -8,6 +8,7 @@ import ( "io" "os" "runtime" + "slices" "sync" "sync/atomic" "time" @@ -578,23 +579,98 @@ func (s *ObjectStorage) HasEncodedObject(h plumbing.Hash) (err error) { } func (s *ObjectStorage) encodedObjectSizeFromUnpacked(h plumbing.Hash) (size int64, err error) { + _, size, err = s.unpackedHeader(h) + return size, err +} + +// unpackedHeader returns the type and size in the header of the loose object +// h, without reading its content. +func (s *ObjectStorage) unpackedHeader(h plumbing.Hash) (typ plumbing.ObjectType, size int64, err error) { f, err := s.dir.Object(h) if err != nil { if os.IsNotExist(err) { - return 0, plumbing.ErrObjectNotFound + return plumbing.InvalidObject, 0, plumbing.ErrObjectNotFound } - return 0, err + return plumbing.InvalidObject, 0, err } + // The objfile.Reader closes only its zlib stream. + defer ioutil.CheckClose(f, &err) r, err := objfile.NewReader(f, s.options.ObjectFormat) if err != nil { - return 0, err + return plumbing.InvalidObject, 0, err } defer ioutil.CheckClose(r, &err) - _, size, err = r.Header() - return size, err + return r.Header() +} + +// maxExternalBases bounds how many REF_DELTA bases outside their own packfile +// EncodedObjectType follows for one object, so that packfiles whose deltas +// name each other's objects in a cycle cannot make it loop. Each hop walks a +// chain of up to 4,096 headers in its packfile, so the bound is kept small: +// git completes a thin pack before storing it and the packfile writer here +// refuses one, so such bases only come from a packfile placed by other means. +const maxExternalBases = 8 + +// EncodedObjectType returns the type of the object with the given hash, +// reading only object headers: a packed delta's type is its base's, found +// without inflating either, wherever the base is stored. +func (s *ObjectStorage) EncodedObjectType(h plumbing.Hash) (plumbing.ObjectType, error) { + for range maxExternalBases + 1 { + typ, err := s.encodedObjectType(h) + var ext *packfile.ExternalBaseError + if !errors.As(err, &ext) { + return typ, err + } + h = ext.Base + } + return plumbing.InvalidObject, fmt.Errorf("%w: more than %d delta bases outside their packfile", + packfile.ErrMalformedPackfile, maxExternalBases) +} + +// encodedObjectType returns the type of the object h as EncodedObjectType +// does, or an [*packfile.ExternalBaseError] naming the base whose type it is +// when h is a packed delta of an object outside its packfile. +func (s *ObjectStorage) encodedObjectType(h plumbing.Hash) (typ plumbing.ObjectType, err error) { + // Routed as EncodedObjectSize is. + idxErr := s.requireIndex() + if idxErr == nil { + if pack, idx, offset := s.findObjectInPackfile(h); !pack.IsZero() { + if cached, ok := s.objectCache.Get(h); ok { + return cached.Type(), nil + } + p, perr := s.packfile(idx, pack) + if perr != nil { + return plumbing.InvalidObject, perr + } + // Each Packfile holds a reference to the pack until closed. + defer ioutil.CheckClose(p, &err) + typ, err = p.GetTypeByOffset(offset) + if !errors.Is(err, plumbing.ErrObjectNotFound) { + return typ, err + } + // Membership claimed the hash but the pack lost it: fall + // through to loose and alternates. + } + } + + typ, _, err = s.unpackedHeader(h) + if err == nil { + return typ, nil + } + if !errors.Is(err, plumbing.ErrObjectNotFound) { + return plumbing.InvalidObject, err + } + if idxErr != nil { + return plumbing.InvalidObject, idxErr + } + + // An alternate follows its own bases. + return findInAlternates(s, func(alt *ObjectStorage) (plumbing.ObjectType, error) { + return alt.EncodedObjectType(h) + }) } func (s *ObjectStorage) packfile(idx idxfile.Index, pack plumbing.Hash) (*packfile.Packfile, error) { @@ -627,6 +703,8 @@ func (s *ObjectStorage) EncodedObjectSize(h plumbing.Hash) (size int64, err erro if perr != nil { return 0, perr } + // Each Packfile holds a reference to the pack until closed. + defer ioutil.CheckClose(p, &err) size, err = p.GetSizeByOffset(offset) if err == nil { return size, nil @@ -1200,10 +1278,10 @@ func (s *ObjectStorage) ObjectPacks() ([]plumbing.Hash, error) { } // DeleteOldObjectPackAndIndex removes a pack and its index if older than t. -// Also drops the in-memory s.index map entry and the matching s.packs -// slice entry for the removed pack so subsequent routing decisions in -// findObjectInPackfile no longer claim membership for a hash that -// lives only in the now-deleted pack. If the MRU hint pointed at the +// Once the pack is gone from disk, also drops the in-memory s.index map +// entry and the matching s.packs slice entry so subsequent routing +// decisions in findObjectInPackfile no longer claim membership for a hash +// that lived only in the deleted pack. If the MRU hint pointed at the // deleted slot, invalidate it. func (s *ObjectStorage) DeleteOldObjectPackAndIndex(h plumbing.Hash, t time.Time) error { s.muIWriters.Lock() @@ -1212,6 +1290,16 @@ func (s *ObjectStorage) DeleteOldObjectPackAndIndex(h plumbing.Hash, t time.Time if err := s.dir.DeleteOldObjectPackAndIndex(h, t); err != nil { return err } + + // The pack outlives the call when it is too new to delete, or when it is + // also stored under a name other than pack-, which is left in place. + // When the listing fails, the entry is dropped as if the pack were gone, + // since keeping it for a deleted pack would route reads to missing files. + packs, err := s.dir.ObjectPacks() + if err == nil && slices.Contains(packs, h) { + return nil + } + s.muI.Lock() defer s.muI.Unlock() diff --git a/vendor/github.com/go-git/go-git/v6/storage/filesystem/shallow.go b/vendor/github.com/go-git/go-git/v6/storage/filesystem/shallow.go index c7bb8d4623..33b325fd08 100644 --- a/vendor/github.com/go-git/go-git/v6/storage/filesystem/shallow.go +++ b/vendor/github.com/go-git/go-git/v6/storage/filesystem/shallow.go @@ -5,6 +5,7 @@ import ( "fmt" "github.com/go-git/go-git/v6/plumbing" + formatcfg "github.com/go-git/go-git/v6/plumbing/format/config" "github.com/go-git/go-git/v6/storage/filesystem/dotgit" "github.com/go-git/go-git/v6/utils/ioutil" ) @@ -12,7 +13,8 @@ import ( // ShallowStorage where the shallow commits are stored, an internal to // manipulate the shallow file type ShallowStorage struct { - dir *dotgit.DotGit + dir *dotgit.DotGit + objectFormat formatcfg.ObjectFormat } // SetShallow save the shallows in the shallow file in the .git folder as one @@ -34,7 +36,12 @@ func (s *ShallowStorage) SetShallow(commits []plumbing.Hash) error { return err } -// Shallow returns the shallow commits reading from shallow file from .git +// Shallow returns the shallow commits reading from shallow file from .git. +// +// Each line must start with a full hash in the repository's object format. +// Anything after the hash is ignored, so CRLF line endings are accepted. A +// line that does not start with a full hash is an error, as in upstream's +// is_repository_shallow. func (s *ShallowStorage) Shallow() ([]plumbing.Hash, error) { f, err := s.dir.Shallow() if f == nil || err != nil { @@ -45,9 +52,18 @@ func (s *ShallowStorage) Shallow() ([]plumbing.Hash, error) { var hash []plumbing.Hash + hexSize := s.objectFormat.HexSize() scn := bufio.NewScanner(f) for scn.Scan() { - hash = append(hash, plumbing.NewHash(scn.Text())) + line := scn.Text() + if len(line) < hexSize { + return nil, fmt.Errorf("bad shallow line: %q", line) + } + h, ok := plumbing.FromHex(line[:hexSize]) + if !ok { + return nil, fmt.Errorf("bad shallow line: %q", line) + } + hash = append(hash, h) } return hash, scn.Err() diff --git a/vendor/github.com/go-git/go-git/v6/storage/filesystem/storage.go b/vendor/github.com/go-git/go-git/v6/storage/filesystem/storage.go index 0074edd954..0f11b5bedf 100644 --- a/vendor/github.com/go-git/go-git/v6/storage/filesystem/storage.go +++ b/vendor/github.com/go-git/go-git/v6/storage/filesystem/storage.go @@ -200,7 +200,7 @@ func NewStorageWithOptions(fs billy.Filesystem, c cache.Object, ops Options) *St ObjectStorage: NewObjectStorageWithOptions(dir, c, ops), ReferenceStorage: ReferenceStorage{dir: dir}, IndexStorage: IndexStorage{dir: dir, h: hasher.Hash, cache: ops.IndexCache, skipHash: skipHash}, - ShallowStorage: ShallowStorage{dir: dir}, + ShallowStorage: ShallowStorage{dir: dir, objectFormat: ops.ObjectFormat}, ConfigStorage: ConfigStorage{dir: dir, objectFormat: ops.ObjectFormat}, ModuleStorage: ModuleStorage{dir: dir, objectFormat: ops.ObjectFormat}, ReflogStorage: ReflogStorage{dir: dir}, @@ -250,6 +250,7 @@ func (s *Storage) SetObjectFormat(of formatcfg.ObjectFormat) error { s.ConfigStorage.objectFormat = of s.ModuleStorage.objectFormat = of + s.ShallowStorage.objectFormat = of s.options.ObjectFormat = of s.oh = plumbing.FromObjectFormat(of) s.hasher = plumbing.NewHasher(of, plumbing.AnyObject, 0) diff --git a/vendor/github.com/go-git/go-git/v6/storage/memory/storage.go b/vendor/github.com/go-git/go-git/v6/storage/memory/storage.go index 7e8b9fd3fa..3678559f8e 100644 --- a/vendor/github.com/go-git/go-git/v6/storage/memory/storage.go +++ b/vendor/github.com/go-git/go-git/v6/storage/memory/storage.go @@ -264,6 +264,16 @@ func (o *ObjectStorage) EncodedObjectSize(h plumbing.Hash) ( return obj.Size(), nil } +// EncodedObjectType returns the type of the object with the given hash. +func (o *ObjectStorage) EncodedObjectType(h plumbing.Hash) (plumbing.ObjectType, error) { + obj, ok := o.Objects[h] + if !ok { + return plumbing.InvalidObject, plumbing.ErrObjectNotFound + } + + return obj.Type(), nil +} + // EncodedObject returns the object with the given type and hash. func (o *ObjectStorage) EncodedObject(t plumbing.ObjectType, h plumbing.Hash) (plumbing.EncodedObject, error) { obj, ok := o.Objects[h] diff --git a/vendor/github.com/go-git/go-git/v6/submodule.go b/vendor/github.com/go-git/go-git/v6/submodule.go index 7280c05e04..bd20dc36dd 100644 --- a/vendor/github.com/go-git/go-git/v6/submodule.go +++ b/vendor/github.com/go-git/go-git/v6/submodule.go @@ -124,13 +124,13 @@ func (s *Submodule) Repository() (*Repository, error) { exists = true } - // s.c.Path is sourced from the worktree's .gitmodules and is - // therefore tree-controlled. Apply the strict tree-path validator - // before chroot — the wrapper's tolerant validPath would let a - // final-position .git component through (e.g. "submodule/.git"), - // which a malicious .gitmodules could use to chroot the submodule - // worktree into the repository's actual .git directory. - if err := pathutil.ValidTreePath(s.c.Path); err != nil { + // .gitmodules supplies the path. Apply the submodule policy before + // chroot; its alias checks remain active even with worktree + // protection disabled. The worktree wrapper independently checks + // every .git position, but accepts the NTFS and HFS+ spellings of "." + // and ".." because an ordinary worktree path may carry them, so the + // chroot base is validated here. + if err := pathutil.ValidSubmodulePath(s.c.Path); err != nil { return nil, err } diff --git a/vendor/github.com/go-git/go-git/v6/utils/convert/stat.go b/vendor/github.com/go-git/go-git/v6/utils/convert/stat.go index 4651716b32..66f1bb4f84 100644 --- a/vendor/github.com/go-git/go-git/v6/utils/convert/stat.go +++ b/vendor/github.com/go-git/go-git/v6/utils/convert/stat.go @@ -1,6 +1,10 @@ package convert -import "io" +import ( + "io" + + "github.com/go-git/go-git/v6/internal/sync" +) // Stat holds statistics about the content being analyzed. type Stat struct { @@ -8,79 +12,91 @@ type Stat struct { Printable, NonPrintable uint } -// IsBinary detects if data is binary based on: -// https://git.kernel.org/pub/scm/git/git.git/tree/convert.c?id=HEAD#n94 +// IsBinary reports whether the content the statistics describe is binary, +// as opposed to text that line-ending conversion applies to. +// +// Text has no NUL, no CR without an LF after it, and at most one +// non-printable byte for every 128 printable ones. func (s Stat) IsBinary() bool { - if s.NUL > 0 { - return true - } - if s.LoneCR > 0 { - return true - } - - mostlyPrintable := (s.Printable >> 7) >= s.NonPrintable - - return !mostlyPrintable + return s.NUL > 0 || s.LoneCR > 0 || s.NonPrintable > s.Printable/128 } -// GetStat returns [Stat] of the reader based on: -// https://git.kernel.org/pub/scm/git/git.git/tree/convert.c?id=HEAD#n45 +const ( + asciiDEL = 0x7f + // asciiSUB is Ctrl-Z, which DOS tools left at the end of text files. + asciiSUB = 0x1a +) + +// GetStat reads r to the end and returns the statistics of its content. +// +// A CR directly followed by an LF counts as one CRLF; any other CR or LF +// counts as a lone one. Every remaining byte is NUL, printable or +// non-printable. A Ctrl-Z that ends the content is not counted. func GetStat(r io.Reader) (stat Stat, err error) { - var hadCR bool + var ( + pendingCR bool + last byte + ) - buf := make([]byte, 1) + pooled := sync.GetByteSlice() + defer sync.PutByteSlice(pooled) + buf := *pooled for { - if _, err := r.Read(buf); err != nil { - if err == io.EOF { - break + n, readErr := r.Read(buf) + for _, b := range buf[:n] { + if pendingCR { + pendingCR = false + if b == '\n' { + stat.CRLF++ + continue + } + stat.LoneCR++ } - return Stat{}, err - } - - b := buf[0] - - if b != '\n' && hadCR { - // CR not followed by LF. Lone CR is considered binary. - stat.LoneCR++ - hadCR = false - } - switch { - case b == '\n': - if hadCR { - stat.CRLF++ - hadCR = false - } else { + switch { + case b == '\r': + pendingCR = true + case b == '\n': stat.LoneLF++ - } - case b == '\r': - hadCR = true - case b == 127: // DEL - stat.NonPrintable++ - case b < 32: - switch b { - case '\b', '\t', '\033', '\014': // BS, HT, ESC and FF - stat.Printable++ - case 0: + case b == 0: stat.NUL++ + case isPrintable(b): + stat.Printable++ default: stat.NonPrintable++ } - default: - stat.Printable++ + } + if n > 0 { + last = buf[n-1] + } + + if readErr == io.EOF { + break + } + if readErr != nil { + return Stat{}, readErr } } - if hadCR { - // Last byte is lone CR. + if pendingCR { stat.LoneCR++ } - - // If file ends with EOF then don't count this EOF as non-printable. - if buf[0] == '\032' { + if last == asciiSUB { stat.NonPrintable-- } return stat, nil } + +// isPrintable reports whether b counts towards the printable bytes of text +// content: everything from space up except DEL, which includes all bytes +// of multi-byte encodings, and the control characters backspace, tab, form +// feed and escape. +func isPrintable(b byte) bool { + switch b { + case '\b', '\t', '\f', '\x1b': + return true + } + return b >= ' ' && b != asciiDEL +} diff --git a/vendor/github.com/go-git/go-git/v6/utils/ioutil/context.go b/vendor/github.com/go-git/go-git/v6/utils/ioutil/context.go index fbc6b946e3..bc512dc119 100644 --- a/vendor/github.com/go-git/go-git/v6/utils/ioutil/context.go +++ b/vendor/github.com/go-git/go-git/v6/utils/ioutil/context.go @@ -2,11 +2,10 @@ package ioutil import ( "context" - "errors" "fmt" "io" - "github.com/go-git/go-git/v6/utils/sync" + "github.com/go-git/go-git/v6/internal/sync" ) type ioret struct { @@ -14,11 +13,6 @@ type ioret struct { n int } -// Writer is an interface for io.Writer. -type Writer interface { - io.Writer -} - type ctxWriter struct { w io.Writer ctx context.Context @@ -103,15 +97,9 @@ func (w *ctxWriter) Write(buf []byte) (int, error) { return total, nil } -// Reader is an io.Reader. -type Reader interface { - io.Reader -} - type ctxReader struct { - r io.Reader - ctx context.Context - closer io.Closer + r io.Reader + ctx context.Context } // NewContextReader wraps a reader to make it respect given Context. @@ -132,39 +120,6 @@ func NewContextReader(ctx context.Context, r io.Reader) io.Reader { return &ctxReader{ctx: ctx, r: r} } -// ReadFinished reports whether the reader wrapped by NewContextReader, -// NewContextReaderWithCloser or NewContextReadCloser has finished with the -// reader underneath it, so that reader — a network connection, typically — may -// be closed after a read returned err. -// -// It has not when this context's cancellation is what ended the read: the -// wrapper returns from its <-ctx.Done() branch while the goroutine it started -// can still be blocked in the underlying Read, and closing would race that -// goroutine. Nothing is leaked by leaving it, because a reader bound to the -// same context is torn down by that context anyway. Any other outcome, success -// included, means the last Read arrived over the result channel and the -// goroutine is finished, so the underlying reader must be closed or it and its -// connection are held for the life of the process. -// -// A cancellation error alone is not enough to answer no: a deadline belonging -// to something else — a storer, a wrapped inner operation — can surface as -// DeadlineExceeded while this context is still live, and treating that as -// unsafe leaks the reader. A cancelled context alone is not enough either: it -// can be cancelled an instant after a read that had already finished, and -// skipping the close there leaks it too. -// -// The two together are not exact. Once this context is done, a cancellation -// that came from somewhere else reads the same as its own, and the close is -// skipped for a read that had in fact finished. The reader that answer is -// wrong about is a reader bound to a context that is already done, which its -// own teardown closes; a reader bound to something else is leaked. -func ReadFinished(ctx context.Context, err error) bool { - if ctx.Err() == nil { - return true - } - return !errors.Is(err, context.Canceled) && !errors.Is(err, context.DeadlineExceeded) -} - func (r *ctxReader) Read(buf []byte) (int, error) { ret := make(chan ioret, 1) @@ -193,9 +148,6 @@ func (r *ctxReader) Read(buf []byte) (int, error) { select { case <-r.ctx.Done(): - if r.closer != nil { - _ = r.closer.Close() - } return 0, r.ctx.Err() case read := <-ret: if err := r.ctx.Err(); err != nil { @@ -205,9 +157,3 @@ func (r *ctxReader) Read(buf []byte) (int, error) { return read.n, read.err } } - -// NewContextReaderWithCloser wraps a reader to make it respect given Context, -// and closes the closer when the context is done. -func NewContextReaderWithCloser(ctx context.Context, r io.Reader, closer io.Closer) io.Reader { - return &ctxReader{ctx: ctx, r: r, closer: closer} -} diff --git a/vendor/github.com/go-git/go-git/v6/utils/ioutil/sync.go b/vendor/github.com/go-git/go-git/v6/utils/ioutil/sync.go index 9e38cd1ab4..2b17402fb5 100644 --- a/vendor/github.com/go-git/go-git/v6/utils/ioutil/sync.go +++ b/vendor/github.com/go-git/go-git/v6/utils/ioutil/sync.go @@ -3,7 +3,7 @@ package ioutil import ( "io" - "github.com/go-git/go-git/v6/utils/sync" + "github.com/go-git/go-git/v6/internal/sync" ) // CopyBufferPool calls io.CopyBuffer and uses a buffer from sync.GetByteSlice, diff --git a/vendor/github.com/go-git/go-git/v6/utils/merkletrie/doubleiter.go b/vendor/github.com/go-git/go-git/v6/utils/merkletrie/doubleiter.go index 2acac304ee..0fbe3ec961 100644 --- a/vendor/github.com/go-git/go-git/v6/utils/merkletrie/doubleiter.go +++ b/vendor/github.com/go-git/go-git/v6/utils/merkletrie/doubleiter.go @@ -42,17 +42,17 @@ func newDoubleIter(from, to noder.Noder, hashEqual noder.Equal) ( var err error if ii.from.iter, err = NewIter(from); err != nil { - return nil, fmt.Errorf("from: %s", err) + return nil, fmt.Errorf("from: %w", err) } if ii.from.current, err = ii.from.iter.Next(); turnEOFIntoNil(err) != nil { - return nil, fmt.Errorf("from: %s", err) + return nil, fmt.Errorf("from: %w", err) } if ii.to.iter, err = NewIter(to); err != nil { - return nil, fmt.Errorf("to: %s", err) + return nil, fmt.Errorf("to: %w", err) } if ii.to.current, err = ii.to.iter.Next(); turnEOFIntoNil(err) != nil { - return nil, fmt.Errorf("to: %s", err) + return nil, fmt.Errorf("to: %w", err) } ii.hashEqual = hashEqual @@ -147,20 +147,29 @@ func (d *doubleIter) compare() (s comparison, err error) { s.bothAreFiles = !fromIsDir && !toIsDir s.fileAndDir = !s.bothAreDirs && !s.bothAreFiles + // Only differing directories are descended into, so only they need their + // children. Leaving identical directories unread matches Git, which + // compares tree entries by hash and mode before reading them, and lets + // a diff cross a subtree that is identical on both sides but absent from + // storage. + if s.sameHash || !s.bothAreDirs { + return s, nil + } + fromNumChildren, err := d.from.current.NumChildren() if err != nil { - return comparison{}, fmt.Errorf("from: %s", err) + return comparison{}, fmt.Errorf("from: %w", err) } toNumChildren, err := d.to.current.NumChildren() if err != nil { - return comparison{}, fmt.Errorf("to: %s", err) + return comparison{}, fmt.Errorf("to: %w", err) } - s.fromIsEmptyDir = fromIsDir && fromNumChildren == 0 - s.toIsEmptyDir = toIsDir && toNumChildren == 0 + s.fromIsEmptyDir = fromNumChildren == 0 + s.toIsEmptyDir = toNumChildren == 0 - return s, err + return s, nil } // Answers to a lot of questions you can ask about how to noders are @@ -181,6 +190,9 @@ type comparison struct { fileAndDir bool // Are both nodes dirs? bothAreDirs bool + // the following are only set if both nodes are dirs with different + // hashes; identical dirs are not read + // Is the from node an empty dir? fromIsEmptyDir bool // Is the to Node an empty dir? diff --git a/vendor/github.com/go-git/go-git/v6/utils/merkletrie/filesystem/node.go b/vendor/github.com/go-git/go-git/v6/utils/merkletrie/filesystem/node.go index 3cb38d78ce..5c53dcbc81 100644 --- a/vendor/github.com/go-git/go-git/v6/utils/merkletrie/filesystem/node.go +++ b/vendor/github.com/go-git/go-git/v6/utils/merkletrie/filesystem/node.go @@ -11,6 +11,7 @@ import ( "github.com/go-git/go-billy/v6" + "github.com/go-git/go-git/v6/internal/sync" "github.com/go-git/go-git/v6/plumbing" "github.com/go-git/go-git/v6/plumbing/filemode" format "github.com/go-git/go-git/v6/plumbing/format/config" @@ -19,18 +20,18 @@ import ( "github.com/go-git/go-git/v6/utils/convert" "github.com/go-git/go-git/v6/utils/ioutil" "github.com/go-git/go-git/v6/utils/merkletrie/noder" - "github.com/go-git/go-git/v6/utils/sync" ) -var ignore = map[string]bool{ - ".git": true, -} - // Options contains configuration for the filesystem node. type Options struct { // AutoCRLF converts CRLF line endings in text files into LF line endings. AutoCRLF bool + // ObjectFormat is the object format the hashes of the files are + // computed in, which must be the index's for them to compare equal. + // SHA-1 is used when it is unset. + ObjectFormat format.ObjectFormat + // Index is used to enable the metadata-first comparison optimization while // correctly handling the "racy git" condition. If no index is provided, // the function works without the optimization. @@ -52,6 +53,13 @@ type Options struct { // Requires Index to be set: without an index there is no way to identify // tracked entries, so the scope is treated as a no-op. IgnoreScope *gitignore.Scope + + // IgnoreCase skips the repository directory in any case, such as + // .GIT, as Git does under core.ignorecase, where on a + // case-insensitive filesystem such a name may be that directory. + // Without it only .git is skipped, and a .GIT is walked like any + // other entry, as Git lists it. + IgnoreCase bool } // The node represents a file or a directory in a billy.Filesystem. It @@ -224,7 +232,9 @@ func (n *node) calculateChildren() error { } for _, file := range files { - if _, ok := ignore[file.Name()]; ok { + // The repository's own directory is skipped, compared as Git's + // fspathcmp does: in any case under core.ignorecase. + if n.isGitDir(file.Name()) { continue } @@ -251,6 +261,14 @@ func (n *node) calculateChildren() error { return nil } +// isGitDir reports whether a listed name is the repository's own directory. +func (n *node) isGitDir(name string) bool { + if n.options != nil && n.options.IgnoreCase { + return strings.EqualFold(name, ".git") + } + return name == ".git" +} + // resolveScope derives this directory's ignore scope from the listing just // taken for it. Deferring to this point is the whole benefit of the scoped // walk: whether a .gitignore exists is read off a listing the walk needed @@ -425,6 +443,14 @@ func (n *node) metadataMatches(entry *index.Entry) bool { return true } +// objectFormat returns the object format n's hash is computed in. +func (n *node) objectFormat() format.ObjectFormat { + if n.options == nil || n.options.ObjectFormat == format.UnsetObjectFormat { + return format.SHA1 + } + return n.options.ObjectFormat +} + func (n *node) doCalculateHashForRegular() plumbing.Hash { f, err := n.fs.Open(n.path) if err != nil { @@ -432,7 +458,7 @@ func (n *node) doCalculateHashForRegular() plumbing.Hash { } defer func() { _ = f.Close() }() - h := plumbing.NewHasher(format.SHA1, plumbing.BlobObject, n.size) + h := plumbing.NewHasher(n.objectFormat(), plumbing.BlobObject, n.size) var dst io.Writer = h if n.options != nil && n.options.AutoCRLF { @@ -467,7 +493,7 @@ func (n *node) doCalculateHashForSymlink() plumbing.Hash { return plumbing.ZeroHash } - h := plumbing.NewHasher(format.SHA1, plumbing.BlobObject, n.size) + h := plumbing.NewHasher(n.objectFormat(), plumbing.BlobObject, n.size) if _, err := h.Write([]byte(target)); err != nil { return plumbing.ZeroHash } diff --git a/vendor/github.com/go-git/go-git/v6/utils/merkletrie/iter.go b/vendor/github.com/go-git/go-git/v6/utils/merkletrie/iter.go index e87663cea4..51e54f4559 100644 --- a/vendor/github.com/go-git/go-git/v6/utils/merkletrie/iter.go +++ b/vendor/github.com/go-git/go-git/v6/utils/merkletrie/iter.go @@ -148,13 +148,18 @@ func (iter *Iter) advance(wantDescend bool) (noder.Path, error) { } // Advances means getting a next current node, either its first child or - // its next sibling, depending if we must descend or not. - numChildren, err := current.NumChildren() - if err != nil { - return nil, err + // its next sibling, depending if we must descend or not. The children are + // only read when descending, so Next can move past a node whose children + // cannot be read. + mustDescend := false + if wantDescend { + numChildren, err := current.NumChildren() + if err != nil { + return nil, err + } + mustDescend = numChildren != 0 } - mustDescend := numChildren != 0 && wantDescend if mustDescend { // descend: add a new frame with the current's children. frame, err := frame.New(current) diff --git a/vendor/github.com/go-git/go-git/v6/worktree.go b/vendor/github.com/go-git/go-git/v6/worktree.go index 81941e9e7e..d0a7ab4f62 100644 --- a/vendor/github.com/go-git/go-git/v6/worktree.go +++ b/vendor/github.com/go-git/go-git/v6/worktree.go @@ -17,6 +17,8 @@ import ( "github.com/go-git/go-billy/v6" "github.com/go-git/go-git/v6/config" + "github.com/go-git/go-git/v6/internal/pathutil" + "github.com/go-git/go-git/v6/internal/sync" giturl "github.com/go-git/go-git/v6/internal/url" "github.com/go-git/go-git/v6/plumbing" "github.com/go-git/go-git/v6/plumbing/filemode" @@ -27,7 +29,6 @@ import ( "github.com/go-git/go-git/v6/utils/convert" "github.com/go-git/go-git/v6/utils/ioutil" "github.com/go-git/go-git/v6/utils/merkletrie" - "github.com/go-git/go-git/v6/utils/sync" "github.com/go-git/go-git/v6/utils/trace" ) @@ -62,6 +63,15 @@ type Worktree struct { } // Filesystem returns the underlying filesystem for the worktree. +// It bypasses the worktree wrapper's reserved-path and leading-symlink checks. +// +// PlainInit and PlainOpen use a filesystem bound to the worktree root, but +// root containment does not protect an in-root .git directory from direct +// writes or writes through an in-root symlink. Caller-supplied filesystems +// provide their own containment guarantees, which may be none. +// +// Use Checkout or Reset to materialize tree contents with worktree path +// validation and blocking-symlink handling. func (w *Worktree) Filesystem() billy.Filesystem { return w.filesystem.Filesystem } @@ -150,17 +160,19 @@ func (w *Worktree) PullContext(ctx context.Context, o *PullOptions) error { return err } - if err := w.updateHEAD(ref.Hash()); err != nil { - return err - } - - if err := w.Reset(&ResetOptions{ + if err := w.reset(&ResetOptions{ Mode: MergeReset, Commit: ref.Hash(), }); err != nil { return err } + // Publish the fetched commit only after the reset succeeds. updateHEAD + // also creates the current branch when pulling into an unborn HEAD. + if err := w.updateHEAD(ref.Hash()); err != nil { + return err + } + if o.RecurseSubmodules != NoRecurseSubmodules { return w.updateSubmodules(ctx, &SubmoduleUpdateOptions{ RecurseSubmodules: o.RecurseSubmodules, @@ -194,7 +206,7 @@ func (w *Worktree) Checkout(opts *CheckoutOptions) error { } if opts.Create { - if err := w.createBranch(opts); err != nil { + if err := w.validateNewBranch(opts); err != nil { return err } } @@ -215,30 +227,30 @@ func (w *Worktree) Checkout(opts *CheckoutOptions) error { ro.Mode = SoftReset } - // For HardReset and KeepReset, capture the current tree BEFORE updating - // HEAD. This ensures resetWorktreeToTree correctly diffs from where we - // actually are, not from where HEAD will point after the update. - if ro.Mode == HardReset || ro.Mode == KeepReset { - ro.fromTree, err = w.headTree() - if err != nil { + if err := w.reset(ro); err != nil { + return err + } + + // A failed tree read must not switch HEAD or create a branch. Resetting + // through the current HEAD would also move the branch we are leaving. + if opts.Create { + // The reset can take long enough for another process to create the + // branch. There is no create-only write, so check once more to narrow + // the window before overwriting it. + if err := w.checkBranchAbsent(opts.Branch); err != nil { + return err + } + if err := w.r.Storer.SetReference(plumbing.NewHashReference(opts.Branch, c)); err != nil { return err } } - if !opts.Hash.IsZero() && !opts.Create { - err = w.setHEADToCommit(opts.Hash) - } else { - err = w.setHEADToBranch(opts.Branch, c) + return w.setHEADToCommit(c) } - - if err != nil { - return err - } - - return w.Reset(ro) + return w.setHEADToBranch(opts.Branch, c) } -func (w *Worktree) createBranch(opts *CheckoutOptions) error { +func (w *Worktree) validateNewBranch(opts *CheckoutOptions) error { // Git applies its branch-name rules to the shorthand a user types, so // recover the shorthand before checking a name that is one. A name that is // not under refs/heads/ gets the reference-name rules alone: handing it to @@ -255,12 +267,7 @@ func (w *Worktree) createBranch(opts *CheckoutOptions) error { return err } - _, err := w.r.Storer.Reference(opts.Branch) - if err == nil { - return fmt.Errorf("a branch named %q already exists", opts.Branch) - } - - if !errors.Is(err, plumbing.ErrReferenceNotFound) { + if err := w.checkBranchAbsent(opts.Branch); err != nil { return err } @@ -273,9 +280,18 @@ func (w *Worktree) createBranch(opts *CheckoutOptions) error { opts.Hash = ref.Hash() } - return w.r.Storer.SetReference( - plumbing.NewHashReference(opts.Branch, opts.Hash), - ) + return nil +} + +func (w *Worktree) checkBranchAbsent(name plumbing.ReferenceName) error { + _, err := w.r.Storer.Reference(name) + if err == nil { + return fmt.Errorf("a branch named %q already exists", name) + } + if !errors.Is(err, plumbing.ErrReferenceNotFound) { + return err + } + return nil } func (w *Worktree) getCommitFromCheckoutOptions(opts *CheckoutOptions) (plumbing.Hash, error) { @@ -331,6 +347,15 @@ func (w *Worktree) setHEADToBranch(branch plumbing.ReferenceName, commit plumbin // Reset the worktree to a specified state. func (w *Worktree) Reset(opts *ResetOptions) error { + if err := w.reset(opts); err != nil { + return err + } + return w.setHEADCommit(opts.Commit) +} + +// reset updates the index and worktree without changing references. Checkout +// switches HEAD afterward; Reset and Pull move the current branch afterward. +func (w *Worktree) reset(opts *ResetOptions) error { if trace.Performance.Enabled() { start := time.Now() defer func() { @@ -359,7 +384,7 @@ func (w *Worktree) Reset(opts *ResetOptions) error { } if opts.Mode == SoftReset { - return w.setHEADCommit(opts.Commit) + return nil } t, err := w.r.getTreeFromCommitHash(opts.Commit) @@ -373,57 +398,73 @@ func (w *Worktree) Reset(opts *ResetOptions) error { } } - // For HardReset and KeepReset, capture the current HEAD tree before - // resetting HEAD. resetWorktreeToTree will diff prevTree→t and apply only - // those changes to the worktree. Since the diff is tree-to-tree, untracked - // files are invisible and are never deleted — matching real git reset --hard. - // - // If opts.fromTree is set (by Checkout), use that instead of calling - // headTree(). This handles the case where HEAD was already updated before - // Reset was called (e.g., in Checkout), ensuring we diff from the actual - // previous state rather than the new HEAD. - var prevTree *object.Tree - if opts.Mode == HardReset || opts.Mode == KeepReset { - if opts.fromTree != nil { - prevTree = opts.fromTree - } else { - prevTree, err = w.headTree() - if err != nil { - return err - } + var trackedChanges merkletrie.Changes + if opts.Mode == HardReset { + // The index identifies tracked paths even when the old HEAD tree is + // unreadable. Capture its diff before resetIndex replaces it, including + // staged additions that must be removed when absent from the target. + trackedChanges, err = w.diffTreeWithStaging(t, true) + if err != nil { + return err } } if opts.Mode == KeepReset { + prevTree, err := w.headTree() + if err != nil { + return err + } if err := w.checkKeepResetConflicts(prevTree, t, opts.SparseDirs, opts.Files); err != nil { return err } + trackedChanges, err = diffTrees(prevTree, t) + if err != nil { + return err + } } - if err := w.setHEADCommit(opts.Commit); err != nil { + // Mixed resets only update the index. + if opts.Mode == MixedReset { + _, err := w.resetIndex(t, opts.SparseDirs, opts.Files, nil) return err } - var removedFiles []string - if opts.Mode == MixedReset || opts.Mode == MergeReset || opts.Mode == HardReset || opts.Mode == KeepReset { - if removedFiles, err = w.resetIndex(t, opts.SparseDirs, opts.Files); err != nil { + // Merge resets also check out the paths whose index entries changed. + // As for hard and keep resets below, the index is stored only once the + // worktree is updated. + if opts.Mode == MergeReset { + idx, changedFiles, err := w.buildResetIndex(t, opts.SparseDirs, opts.Files, nil) + if err != nil { return err } - } - - if opts.Mode == MergeReset && len(removedFiles) > 0 { - if err := w.resetWorktree(cfg, t, removedFiles); err != nil { - return err + if len(changedFiles) == 0 { + return w.r.Storer.SetIndex(idx) } + return w.resetWorktree(cfg, t, idx, changedFiles) } - if opts.Mode == HardReset || opts.Mode == KeepReset { - if err := w.resetWorktreeToTree(cfg, prevTree, t, opts.Files); err != nil { - return err - } + // Hard and keep resets update the worktree in Git's order: the target + // index is built first, which validates every path it adds or changes, + // then the tracked paths the target drops are removed, the files the + // target adds or changes are written, and only then is the index + // stored. A target with an invalid path therefore changes nothing, and + // a write that fails leaves the index and HEAD as they were, so a hard + // reset can be run again. The tracked deletions come from the old index + // or HEAD tree, which the stored index still describes until the end. + var stagingChanges merkletrie.Changes + if opts.Mode == HardReset { + // A hard reset's tracked changes are the staging diff the index + // is built from, so it is not computed twice. + stagingChanges = trackedChanges } - - return nil + idx, _, err := w.buildResetIndex(t, opts.SparseDirs, opts.Files, stagingChanges) + if err != nil { + return err + } + if err := w.removeTrackedDeletions(trackedChanges, opts.Files); err != nil { + return err + } + return w.resetWorktreeToTree(cfg, t, idx, opts.Files) } // treeContainsDirs checks if the given tree contains all the directories. @@ -481,17 +522,36 @@ func (w *Worktree) Restore(o *RestoreOptions) error { return ErrRestoreWorktreeOnlyNotSupported } -func (w *Worktree) resetIndex(t *object.Tree, dirs, files []string) ([]string, error) { - idx, err := w.r.Storer.Index() +// resetIndex resets the index to t. changes is the diff of t against the +// index, as diffTreeWithStaging(t, true) returns it, or nil to compute it. +func (w *Worktree) resetIndex(t *object.Tree, dirs, files []string, changes merkletrie.Changes) ([]string, error) { + idx, removedFiles, err := w.buildResetIndex(t, dirs, files, changes) if err != nil { return nil, err } + return removedFiles, w.r.Storer.SetIndex(idx) +} + +// buildResetIndex returns the index reset to t, without storing it, and the +// paths it changed. Every path it adds or changes is looked up in t, which +// validates it, so a target that names an invalid path fails here, before +// anything is written. +func (w *Worktree) buildResetIndex(t *object.Tree, dirs, files []string, changes merkletrie.Changes) (*index.Index, []string, error) { + stored, err := w.r.Storer.Index() + if err != nil { + return nil, nil, err + } + // Some storages hand out the index they store, so it is copied: a reset + // that fails before storing its index must leave the stored one as it + // was. + idx := copyIndex(stored) b := newIndexBuilder(idx) - changes, err := w.diffTreeWithStaging(t, true) - if err != nil { - return nil, err + if changes == nil { + if changes, err = w.diffTreeWithStaging(t, true); err != nil { + return nil, nil, err + } } removedFiles := make([]string, 0, len(changes)) @@ -499,7 +559,7 @@ func (w *Worktree) resetIndex(t *object.Tree, dirs, files []string) ([]string, e for _, ch := range changes { a, err := ch.Action() if err != nil { - return nil, err + return nil, nil, err } var name string @@ -510,7 +570,7 @@ func (w *Worktree) resetIndex(t *object.Tree, dirs, files []string) ([]string, e name = ch.To.String() e, err = t.FindEntry(name) if err != nil { - return nil, err + return nil, nil, err } case merkletrie.Delete: name = ch.From.String() @@ -542,7 +602,19 @@ func (w *Worktree) resetIndex(t *object.Tree, dirs, files []string) ([]string, e idx.SkipUnless(dirs) } - return removedFiles, w.r.Storer.SetIndex(idx) + return idx, removedFiles, nil +} + +// copyIndex returns a copy of idx whose entries can be changed without +// changing those of idx. +func copyIndex(idx *index.Index) *index.Index { + c := *idx + c.Entries = make([]*index.Entry, len(idx.Entries)) + for i, e := range idx.Entries { + ec := *e + c.Entries[i] = &ec + } + return &c } // inFiles checks if the given file is in the list of files. The incoming filepaths in files should be cleaned before calling this function. @@ -676,37 +748,30 @@ func (w *Worktree) checkKeepResetConflicts(fromTree, toTree *object.Tree, sparse return nil } -// resetWorktreeToTree updates the worktree to match toTree, mirroring -// real git reset --hard / checkout -f: -// -// 1. Tree-to-tree diff (fromTree→toTree): remove files that were tracked in -// fromTree but deleted in toTree. Because the diff is purely object-graph, -// untracked files never appear and are never deleted. -// -// 2. New-index-to-worktree diff: write files that are in the new index but -// absent or different on disk. For Delete actions (file on disk, but absent -// from the index): the file is truly untracked and is preserved. -// (SkipWorktree entries are invisible to the merkletrie diff; they are -// handled in step 3.) +// removeTrackedDeletions removes from the worktree the tracked paths that +// changes deletes, restricted to files when it is not empty. Each is removed +// as a single entry: a directory that is not empty is left in place. changes +// must be computed before resetting the index: HardReset compares the old +// index with the target tree; KeepReset compares the old HEAD tree with it. // -// 3. Remove SkipWorktree files from disk: diffStagingWithWorktree never -// surfaces SkipWorktree-flagged entries as Delete actions because the -// merkletrie marks them skip=true. Mirror git's behaviour: any tracked -// file with SkipWorktree=true must not exist in the worktree. +// The removal is selected by the mode of the entry being removed, as Git +// takes it from the index entry it unlinks[1]: the stored index's entry, which +// still describes the old state, or unknownMode for a path it lacks. For a +// conflict that is its lowest stage, the one Git's reset keeps when it drops +// an unmerged path to stage 0[2]. // -// files optionally restricts the operation to a specific subset of paths. -func (w *Worktree) resetWorktreeToTree(cfg *config.Config, fromTree, toTree *object.Tree, files []string) error { +// [1]: https://github.com/git/git/blob/v2.54.0/entry.c#L595-L613 +// [2]: https://github.com/git/git/blob/v2.54.0/read-cache.c#L3403-L3430 +func (w *Worktree) removeTrackedDeletions(changes merkletrie.Changes, files []string) error { filesMap := buildFilePathMap(files) fs, closeFS := w.reusableRootFS() defer closeFS() - // Step 1: delete files removed from the tracked tree. - treeChanges, err := diffTrees(fromTree, toTree) - if err != nil { - return err - } - for _, ch := range treeChanges { + // The stored index's entries, by name, read on the first deletion. A + // lookup per deletion in the index itself would scan its entries. + var entries map[string]*index.Entry + for _, ch := range changes { a, err := ch.Action() if err != nil { return err @@ -718,10 +783,52 @@ func (w *Worktree) resetWorktreeToTree(cfg *config.Config, fromTree, toTree *obj if len(files) > 0 && !inFiles(filesMap, name) { continue } - if err := rmFileAndDirsIfEmpty(fs, name); err != nil { + if entries == nil { + entries, err = w.storedEntries() + if err != nil { + return err + } + } + mode := unknownMode + if e, ok := entries[name]; ok { + mode = e.Mode + } + if err := rmEntryAndDirsIfEmpty(fs, name, mode); err != nil { return err } } + return nil +} + +// storedEntries returns the stored index's entries by name. A path with several +// stages maps to its lowest, the one Git keeps when it drops an unmerged path +// to stage 0. +func (w *Worktree) storedEntries() (map[string]*index.Entry, error) { + idx, err := w.r.Storer.Index() + if err != nil { + return nil, err + } + entries := make(map[string]*index.Entry, len(idx.Entries)) + for _, e := range idx.Entries { + if seen, ok := entries[e.Name]; !ok || e.Stage < seen.Stage { + entries[e.Name] = e + } + } + return entries, nil +} + +// resetWorktreeToTree writes the contents of idx, the index a reset built +// for toTree, to the worktree, after removeTrackedDeletions has removed what +// the target drops, and then stores idx. +// +// Untracked paths absent from the target are preserved. SkipWorktree entries +// are removed separately because they are excluded from the worktree diff. +// A nonempty files slice restricts updates to the selected paths. +func (w *Worktree) resetWorktreeToTree(cfg *config.Config, toTree *object.Tree, idx *index.Index, files []string) error { + filesMap := buildFilePathMap(files) + + fs, closeFS := w.reusableRootFS() + defer closeFS() // Step 2: write files that are in the new index but missing or stale // in the worktree. We use diffStagingWithWorktree(reverse=true) which @@ -736,15 +843,11 @@ func (w *Worktree) resetWorktreeToTree(cfg *config.Config, fromTree, toTree *obj // Delete actions. The observable result is unchanged because Delete // actions are skipped by the loop below; the matcher only avoids the // pointless lstat of every file under directories like node_modules. - worktreeChanges, err := w.diffStagingWithWorktree(cfg, true, true) + worktreeChanges, err := w.diffIndexWithWorktree(cfg, idx, true, true) if err != nil { return err } - idx, err := w.r.Storer.Index() - if err != nil { - return err - } b := newIndexBuilder(idx) for _, ch := range worktreeChanges { @@ -768,7 +871,7 @@ func (w *Worktree) resetWorktreeToTree(cfg *config.Config, fromTree, toTree *obj } } - if err := w.checkoutChange(cfg, fs, ch, toTree, b); err != nil { + if err := w.checkoutChange(cfg, fs, ch, toTree, b, unknownMode); err != nil { return err } } @@ -787,7 +890,7 @@ func (w *Worktree) resetWorktreeToTree(cfg *config.Config, fromTree, toTree *obj if _, statErr := fs.Lstat(e.Name); os.IsNotExist(statErr) { continue } - if err := rmFileAndDirsIfEmpty(fs, e.Name); err != nil { + if err := rmEntryAndDirsIfEmpty(fs, e.Name, e.Mode); err != nil { return err } } @@ -796,30 +899,28 @@ func (w *Worktree) resetWorktreeToTree(cfg *config.Config, fromTree, toTree *obj return w.r.Storer.SetIndex(idx) } -// resetWorktree updates the worktree to match the staging area. -// files restricts the operation to the named paths; nil means all files. +// resetWorktree updates the worktree to match idx, the index a merge reset +// built, and then stores idx. files restricts the operation to the named +// paths; nil means all files. // // excludeIgnoredChanges is intentionally false here. The caller is -// MergeReset, and files contains paths that were just removed from the -// index by resetIndex. A tracked-but-gitignored path that was removed +// MergeReset, and files contains paths that buildResetIndex just changed +// in idx. A tracked-but-gitignored path that was removed // from the index in this same Reset is no longer in idxMap, so the // noder's IgnoreScope would prune it from the walk and the Delete // action needed to remove it from disk would never be emitted. -func (w *Worktree) resetWorktree(cfg *config.Config, t *object.Tree, files []string) error { - changes, err := w.diffStagingWithWorktree(cfg, true, false) +func (w *Worktree) resetWorktree(cfg *config.Config, t *object.Tree, idx *index.Index, files []string) error { + changes, err := w.diffIndexWithWorktree(cfg, idx, true, false) if err != nil { return err } - idx, err := w.r.Storer.Index() - if err != nil { - return err - } b := newIndexBuilder(idx) fs, closeFS := w.reusableRootFS() defer closeFS() + var entries map[string]*index.Entry filesMap := buildFilePathMap(files) for _, ch := range changes { if len(files) > 0 { @@ -840,7 +941,20 @@ func (w *Worktree) resetWorktree(cfg *config.Config, t *object.Tree, files []str } } - if err := w.checkoutChange(cfg, fs, ch, t, b); err != nil { + removedMode := unknownMode + if a, err := ch.Action(); err == nil && a == merkletrie.Delete { + if entries == nil { + entries, err = w.storedEntries() + if err != nil { + return err + } + } + if e, ok := entries[ch.From.String()]; ok { + removedMode = e.Mode + } + } + + if err := w.checkoutChange(cfg, fs, ch, t, b, removedMode); err != nil { return err } } @@ -849,7 +963,7 @@ func (w *Worktree) resetWorktree(cfg *config.Config, t *object.Tree, files []str return w.r.Storer.SetIndex(idx) } -func (w *Worktree) checkoutChange(cfg *config.Config, fs *worktreeFilesystem, ch merkletrie.Change, t *object.Tree, idx *indexBuilder) error { +func (w *Worktree) checkoutChange(cfg *config.Config, fs *worktreeFilesystem, ch merkletrie.Change, t *object.Tree, idx *indexBuilder, removedMode filemode.FileMode) error { a, err := ch.Action() if err != nil { return err @@ -875,7 +989,12 @@ func (w *Worktree) checkoutChange(cfg *config.Config, fs *worktreeFilesystem, ch // These names come from the filesystem-vs-index diff. Apply the // configured worktree gate. Tree-derived deletes use the same // helper in resetWorktreeToTree. - return rmFileAndDirsIfEmpty(fs, ch.From.String()) + // + // resetWorktree is the only caller that reaches this, for a merge + // reset, and passes the stored index entry's mode. A file standing at + // an uninitialised submodule's gitlink hashes as the gitlink, so the + // reset is not refused for it and the mode keeps it. + return rmEntryAndDirsIfEmpty(fs, ch.From.String(), removedMode) } if isSubmodule { @@ -994,11 +1113,12 @@ func (w *Worktree) checkoutChangeRegularFile(cfg *config.Config, return err } - if err := w.checkoutFile(cfg, fs, f); err != nil { + fi, err := w.checkoutFile(cfg, fs, f) + if err != nil { return err } - return w.addIndexFromFile(fs, name, e.Hash, idx) + return w.addIndexFromFile(name, e.Hash, fi, idx) } return nil @@ -1045,18 +1165,18 @@ func (w *Worktree) clearBlockingSymlinks(fs *worktreeFilesystem, name string) er return nil } -func (w *Worktree) checkoutFile(cfg *config.Config, fs *worktreeFilesystem, f *object.File) (err error) { +func (w *Worktree) checkoutFile(cfg *config.Config, fs *worktreeFilesystem, f *object.File) (fi os.FileInfo, err error) { // checkoutFile is the materialisation boundary for tracked entries. // Remove any blocking symlink first so the subsequent OpenFile or // Symlink call writes the entry itself instead of following a planted // final-component link in the underlying filesystem. if err := w.clearBlockingSymlinks(fs, f.Name); err != nil { - return err + return nil, err } mode, err := f.Mode.ToOSFileMode() if err != nil { - return err + return nil, err } if mode&os.ModeSymlink != 0 { @@ -1065,11 +1185,16 @@ func (w *Worktree) checkoutFile(cfg *config.Config, fs *worktreeFilesystem, f *o dstFile, err := fs.OpenFile(f.Name, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, mode.Perm()) if err != nil { - return err + return nil, err } defer ioutil.CheckClose(dstFile, &err) - return w.copyObjectToWorktree(cfg, f, dstFile) + if err := w.copyObjectToWorktree(cfg, f, dstFile); err != nil { + return nil, err + } + + fi, err = dstFile.Stat() + return fi, err } func (w *Worktree) copyObjectToWorktree(cfg *config.Config, object *object.File, file billy.File) (err error) { @@ -1106,7 +1231,7 @@ func (w *Worktree) copyObjectToWorktree(cfg *config.Config, object *object.File, return err } -func (w *Worktree) checkoutFileSymlink(fs *worktreeFilesystem, f *object.File) (err error) { +func (w *Worktree) checkoutFileSymlink(fs *worktreeFilesystem, f *object.File) (fi os.FileInfo, err error) { // .gitmodules symlink rejection (and its NTFS / HFS variants) is // enforced by the worktreeFilesystem wrapper's Symlink method via // validSymlinkName. See https://github.com/git/git/commit/10ecfa7 @@ -1114,14 +1239,14 @@ func (w *Worktree) checkoutFileSymlink(fs *worktreeFilesystem, f *object.File) ( from, err := f.Reader() if err != nil { - return err + return nil, err } defer ioutil.CheckClose(from, &err) bytes, err := io.ReadAll(from) if err != nil { - return err + return nil, err } err = fs.Symlink(string(bytes), f.Name) @@ -1133,15 +1258,19 @@ func (w *Worktree) checkoutFileSymlink(fs *worktreeFilesystem, f *object.File) ( to, err := fs.OpenFile(f.Name, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, mode.Perm()) if err != nil { - return err + return nil, err } defer ioutil.CheckClose(to, &err) - _, err = to.Write(bytes) - return err + if _, err = to.Write(bytes); err != nil { + return nil, err + } + } else if err != nil { + return nil, err } - return err + + return fs.Lstat(f.Name) } func (w *Worktree) addIndexFromTreeEntry(name string, f *object.TreeEntry, idx *indexBuilder) error { @@ -1154,12 +1283,8 @@ func (w *Worktree) addIndexFromTreeEntry(name string, f *object.TreeEntry, idx * return nil } -func (w *Worktree) addIndexFromFile(fs *worktreeFilesystem, name string, h plumbing.Hash, idx *indexBuilder) error { +func (w *Worktree) addIndexFromFile(name string, h plumbing.Hash, fi os.FileInfo, idx *indexBuilder) error { idx.Remove(name) - fi, err := fs.Lstat(name) - if err != nil { - return err - } mode, err := filemode.NewFromOSFileMode(fi.Mode()) if err != nil { @@ -1337,18 +1462,121 @@ func (w *Worktree) Clean(opts *CleanOptions) error { if err != nil { return err } + cfg, err := w.r.Config() + if err != nil { + return err + } + // Like Status, Clean works on the names it lists, so it uses the + // worktree filesystem directly, and removes an untracked directory + // named like a .git alias, such as git~1, as Git does. Every removal + // still refuses a path through a symlink, as the worktree filesystem + // does, so a directory swapped for a link after it was listed is + // not followed. root := "" - files, err := w.filesystem.ReadDir(root) + files, err := w.filesystem.walkFilesystem().ReadDir(root) if err != nil { return err } - return w.doClean(s, opts, root, files) + + guard := cleanGuard{ignoreCase: cfg.Core.IgnoreCase, gitDirs: w.gitDirInfos(), fs: w.filesystem.walkFilesystem()} + return w.doClean(s, opts, guard, root, files) +} + +// cleanGuard decides which listed entries Clean leaves alone because they +// may be the repository's own Git directory. +// +// Git skips .git, and under core.ignorecase .git in any case [1]. With +// core.ignorecase false, Git lists an untracked .GIT and `git clean -fd` +// removes it, even where a case-insensitive filesystem makes it the +// repository's own directory. Clean diverges from Git in three ways so it +// can never remove that directory: +// +// - with core.ignorecase unset, it skips .git in any case. Git's init +// sets the key on a case-insensitive filesystem; go-git's does not, so +// unset says nothing about the filesystem. +// - it skips any directory that is the storer's Git directory or, for a +// linked worktree, its common directory, compared with os.SameFile, +// whatever its name and the setting say. This needs a storer that +// exposes an operating system filesystem; on others, such as memfs, +// only the name rules apply. +// - it skips a directory named like .git in another case, or as HFS+ +// folds it, when /.git resolves although the listing has no such +// entry: a case-insensitive filesystem's view of a nested repository +// spelled .GIT, which Git keeps. +// +// Status follows Git and lists such a directory's files as untracked. +// +// [1]: https://github.com/git/git/blob/v2.54.0/dir.c#L2439 +type cleanGuard struct { + ignoreCase config.OptBool + gitDirs []os.FileInfo + fs billy.Filesystem +} + +func (g cleanGuard) skip(dir string, e fs.DirEntry, siblings []fs.DirEntry) bool { + name := e.Name() + if isGitDirName(name, g.ignoreCase.IsTrue() || !g.ignoreCase.IsSet()) { + return true + } + if !e.IsDir() { + return false + } + fi, err := e.Info() + if err != nil { + return false + } + if isGitDirName(name, true) || pathutil.IsHFSDotGit(name) { + if g.foldsToLiteralGit(dir, siblings) { + return true + } + } + for _, d := range g.gitDirs { + if os.SameFile(fi, d) { + return true + } + } + return false } -func (w *Worktree) doClean(status Status, opts *CleanOptions, dir string, files []fs.DirEntry) error { +// foldsToLiteralGit reports whether /.git exists although the listing of +// dir has no entry of that exact name, which only a case-insensitive +// filesystem allows. The filesystem's file information cannot be compared +// with os.SameFile, as billy wraps it. +func (g cleanGuard) foldsToLiteralGit(dir string, siblings []fs.DirEntry) bool { + if slices.ContainsFunc(siblings, func(s fs.DirEntry) bool { return s.Name() == GitDirName }) { + return false + } + fi, err := g.fs.Lstat(filepath.Join(dir, GitDirName)) + return err == nil && fi.IsDir() +} + +// gitDirInfos returns the file information of the storer's Git directory +// and, for a linked worktree, of its common directory. It returns nothing +// for a storer that does not expose a filesystem, and leaves out a +// directory that cannot be read. +func (w *Worktree) gitDirInfos() []os.FileInfo { + s, ok := w.r.Storer.(interface{ Filesystem() billy.Filesystem }) + if !ok || s.Filesystem() == nil { + return nil + } + fss := []billy.Filesystem{s.Filesystem()} + if c, ok := s.Filesystem().(interface{ CommonFilesystem() billy.Filesystem }); ok && c.CommonFilesystem() != nil { + fss = append(fss, c.CommonFilesystem()) + } + var infos []os.FileInfo + for _, fs := range fss { + if fi, err := fs.Stat("."); err == nil { + infos = append(infos, fi) + } + } + return infos +} + +func (w *Worktree) doClean(status Status, opts *CleanOptions, guard cleanGuard, dir string, files []fs.DirEntry) error { + wfs := w.filesystem.walkFilesystem() for _, fi := range files { - if fi.Name() == GitDirName { + if guard.skip(dir, fi, files) { continue } @@ -1359,29 +1587,45 @@ func (w *Worktree) doClean(status Status, opts *CleanOptions, dir string, files continue } - subfiles, err := w.filesystem.ReadDir(path) + subfiles, err := wfs.ReadDir(path) if err != nil { return err } - err = w.doClean(status, opts, path, subfiles) + err = w.doClean(status, opts, guard, path, subfiles) if err != nil { return err } } else if status.IsUntracked(path) { - if err := w.filesystem.Remove(path); err != nil { + if err := w.filesystem.validNoLeadingSymlink(path); err != nil { + return err + } + if err := wfs.Remove(path); err != nil { return err } } } if opts.Dir && dir != "" { - _, err := removeDirIfEmpty(w.filesystem, dir) + if err := w.filesystem.validNoLeadingSymlink(dir); err != nil { + return err + } + _, err := removeDirIfEmpty(wfs, dir) return err } return nil } +// isGitDirName reports whether a listed name is the repository's own +// directory, which Status and Clean skip: .git, or under core.ignorecase +// .git in any case, as Git's fspathcmp compares it. +func isGitDirName(name string, ignoreCase bool) bool { + if ignoreCase { + return strings.EqualFold(name, GitDirName) + } + return name == GitDirName +} + // GrepResult is structure of a grep result. type GrepResult struct { // FileName is the name of file which contains match. @@ -1524,22 +1768,37 @@ func findMatchInFile(file *object.File, treeName string, opts *GrepOptions) ([]G return grepResults, nil } -// rmFileAndDirsIfEmpty removes name and its empty parent directories. -// It preserves nonempty directories and ignores removal errors for directories -// that remain in place. This keeps submodule worktrees and untracked files -// when a reset removes their index entries. +// unknownMode is the mode rmEntryAndDirsIfEmpty takes for an entry whose own +// mode the caller cannot read. It is filemode.Empty, which the filemode +// package defines as the mode of a tree element after its deletion. +const unknownMode = filemode.Empty + +// rmEntryAndDirsIfEmpty removes one tracked entry, name, and its empty parent +// directories. +// +// mode is the mode of the entry being removed, and selects the removal as +// Git's [remove_or_warn] does: rmdir for a gitlink, which takes an empty +// directory and nothing else, and unlink for every other mode, which takes +// anything that is not a directory. So a submodule worktree with contents of +// its own survives a reset that drops the gitlink, as does a file standing +// where a gitlink is tracked, and a directory standing where a file is +// tracked. With unknownMode only a nonempty directory is kept, the shape both +// removals refuse. // -// Removal is not recursive. Billy filesystems have no shared directory-not-empty -// error, so directories are checked before removal and again if removal fails. -// Where Git warns about a failed directory removal and continues, this returns nil. +// Where the removal does not apply, or fails on a directory that remains in +// place, the entry is kept and parent cleanup stops; Git warns and continues, +// and this returns nil. Removal is never recursive. Billy filesystems have no +// shared directory-not-empty error, so directories are checked before removal +// and again if removal fails. // // Paths rejected by the worktree filesystem because of a leading symlink are // left untouched, as in Git's [unlink_entry]. The symlink error stops parent // cleanup too, so the blocking symlink is preserved. // -// [unlink_entry]: https://github.com/git/git/blob/v2.54.0/entry.c -func rmFileAndDirsIfEmpty(fs billy.Filesystem, name string) error { - if nonemptyDir(fs, name) { +// [remove_or_warn]: https://github.com/git/git/blob/v2.54.0/entry.c#L610-L613 +// [unlink_entry]: https://github.com/git/git/blob/v2.54.0/entry.c#L595-L608 +func rmEntryAndDirsIfEmpty(fs billy.Filesystem, name string, mode filemode.FileMode) error { + if !canRemove(fs, name, mode) { return nil } @@ -1608,8 +1867,29 @@ func isDir(fs billy.Filesystem, name string) bool { return err == nil && fi.IsDir() } +// canRemove reports whether the removal rmEntryAndDirsIfEmpty selects for +// mode should be attempted on what stands at name. A name that cannot be +// inspected is attempted, so the removal reports the outcome. +func canRemove(fs billy.Filesystem, name string, mode filemode.FileMode) bool { + fi, err := fs.Lstat(name) + if err != nil { + return true + } + + if !fi.IsDir() { + // unlink takes any non-directory; rmdir takes none of them. + return mode != filemode.Submodule + } + + // A directory: unlink refuses it, and rmdir takes it only when empty. + if mode != filemode.Submodule && mode != unknownMode { + return false + } + return !nonemptyDir(fs, name) +} + // nonemptyDir reports whether name is a directory with entries in it, the -// shape rmFileAndDirsIfEmpty keeps without attempting a removal at all. +// shape rmEntryAndDirsIfEmpty keeps without attempting a removal at all. // // A directory whose entries cannot be read reports false. It reaches the // removal, which fails, and isDir keeps it from there. diff --git a/vendor/github.com/go-git/go-git/v6/worktree_commit.go b/vendor/github.com/go-git/go-git/v6/worktree_commit.go index 9d2916681c..6520033744 100644 --- a/vendor/github.com/go-git/go-git/v6/worktree_commit.go +++ b/vendor/github.com/go-git/go-git/v6/worktree_commit.go @@ -17,7 +17,6 @@ import ( "github.com/go-git/go-git/v6/plumbing/format/index" "github.com/go-git/go-git/v6/plumbing/object" "github.com/go-git/go-git/v6/storage" - "github.com/go-git/go-git/v6/utils/merkletrie" "github.com/go-git/go-git/v6/utils/trace" "github.com/go-git/go-git/v6/x/plugin" ) @@ -26,8 +25,6 @@ var ( // ErrEmptyCommit occurs when a commit is attempted using a clean // working tree, with no changes to be committed. ErrEmptyCommit = errors.New("cannot create empty commit: clean working tree") - // ErrCannotCherryPickWithoutCommitOptions happens when no commitOptions is not provided for cherry-picking commit - ErrCannotCherryPickWithoutCommitOptions = errors.New("cannot cherry-pick without commit options") // characters to be removed from user name and/or email before using them to build a commit object // See https://git-scm.com/docs/git-commit#_commit_information @@ -108,100 +105,6 @@ func (w *Worktree) Commit(msg string, opts *CommitOptions) (plumbing.Hash, error return commit, w.updateHEAD(commit) } -// CherryPick cherry picks commits and merge them into the worktree based on the selected -// merge strategy. Each commit sits on the top of worktree's current head. -// It resembles `git cherry-pick ... --strategy-option [theirs,ours]` -func (w *Worktree) CherryPick(commitOpts *CommitOptions, ortStrategyOption OrtMergeStrategyOption, commits ...*object.Commit) error { - if commitOpts == nil { - return ErrCannotCherryPickWithoutCommitOptions - } - - cfg, err := w.r.Config() - if err != nil { - return err - } - - // Materialise changes through the same validating filesystem and - // checkout path as reset/checkout, so cherry-pick shares their - // leading-symlink handling, mode awareness (symlinks, exec bits, - // CRLF) and root reuse instead of writing raw bytes via Create. - fs, closeFS := w.reusableRootFS() - defer closeFS() - - for _, commit := range commits { - var changes object.Changes - headRef, err := w.r.Head() - if err != nil { - return err - } - headCommit, err := w.r.CommitObject(headRef.Hash()) - if err != nil { - return err - } - currentTree, err := headCommit.Tree() - if err != nil { - return err - } - - commitTree, err := commit.Tree() - if err != nil { - return err - } - - switch ortStrategyOption { - case TheirsMergeStrategy: - changes, err = currentTree.Diff(commitTree) - case OursMergeStrategy: - changes, err = commitTree.Diff(currentTree) - } - - if err != nil { - return err - } - for _, change := range changes { - action, err := change.Action() - if err != nil { - return err - } - - switch action { - case merkletrie.Delete: - if _, err := w.Remove(change.From.Name); err != nil { - return err - } - case merkletrie.Insert, merkletrie.Modify: - _, to, err := change.Files() - if err != nil { - return err - } - if to == nil { - continue - } - // change.Files names the *File after the tree leaf. The - // worktree write needs the full path so it lands at the - // right location and is validated by the wrapper. - to.Name = change.To.Name - if err := w.checkoutFile(cfg, fs, to); err != nil { - return err - } - if _, err := w.Add(to.Name); err != nil { - return err - } - } - } - _, err = w.Commit(commit.Message, &CommitOptions{ - Author: &commit.Author, - Committer: commitOpts.Committer, - Signer: commitOpts.Signer, - AllowEmptyCommits: commitOpts.AllowEmptyCommits, - }) - if err != nil { - return err - } - } - return nil -} - func (w *Worktree) autoAddModifiedAndDeleted() error { cfg, err := w.r.Config() if err != nil { @@ -262,7 +165,7 @@ func (w *Worktree) buildCommitObject(msg string, opts *CommitOptions, tree plumb // Use Has before Get so the key is not frozen when no plugin is // registered, allowing callers to register one later. if !plugin.Has(plugin.ObjectSigner()) { - return plumbing.ZeroHash, fmt.Errorf("cannot auto-sign commit: disable commit.gpgSign or register an ObjectSigner plugin") + return plumbing.ZeroHash, fmt.Errorf("%w: commit.gpgSign is enabled, disable it, pass a Signer or register an ObjectSigner plugin", ErrNoObjectSigner) } signer, err = plugin.Get(plugin.ObjectSigner()) diff --git a/vendor/github.com/go-git/go-git/v6/worktree_fs.go b/vendor/github.com/go-git/go-git/v6/worktree_fs.go index 4ea547c077..715b7d7f7d 100644 --- a/vendor/github.com/go-git/go-git/v6/worktree_fs.go +++ b/vendor/github.com/go-git/go-git/v6/worktree_fs.go @@ -41,7 +41,10 @@ func defaultProtectNTFS() bool { // boundary. Two layers apply: // // - validPath rejects dangerous path *strings*: .git and its HFS+/NTFS -// variants, "..", control characters, volume names. +// variants at every position, dot/parent components and control bytes. +// Windows additionally rejects volume prefixes and, with +// core.protectNTFS, illegal characters, trailing spaces/periods and +// reserved device names. // - validNoLeadingSymlink rejects paths whose leading directories // already exist on disk as symlinks, so a write or delete cannot // follow a planted link out of the tree. @@ -59,10 +62,25 @@ type worktreeFilesystem struct { billy.Filesystem protectNTFS bool protectHFS bool + + // win32 enables the rules that describe the host's own path + // canonicalisation rather than a repository's contents: volume + // prefixes, and the character, trailing-space/period and device rules + // that Win32ValidPath applies under core.protectNTFS. Upstream Git + // compiles is_valid_win32_path only for MinGW and MSVC, so a POSIX + // host must keep checking out names such as aux.c. It is a field + // rather than a runtime.GOOS test so both hosts' policies are + // reachable from a test on either. + win32 bool } func newWorktreeFilesystem(fs billy.Filesystem, protectNTFS, protectHFS bool) *worktreeFilesystem { - return &worktreeFilesystem{Filesystem: fs, protectNTFS: protectNTFS, protectHFS: protectHFS} + return &worktreeFilesystem{ + Filesystem: fs, + protectNTFS: protectNTFS, + protectHFS: protectHFS, + win32: runtime.GOOS == "windows", + } } func (sfs *worktreeFilesystem) Create(filename string) (billy.File, error) { @@ -121,11 +139,14 @@ func (sfs *worktreeFilesystem) Lstat(filename string) (os.FileInfo, error) { return sfs.Filesystem.Lstat(filename) } +// Symlink checks .gitmodules names before the general path and filesystem +// rules. The checks are independent and can overlap; checking the symlink +// name first preserves ErrGitModulesSymlink for overlapping refusals. func (sfs *worktreeFilesystem) Symlink(target, link string) error { - if err := sfs.validWritePath(link); err != nil { + if err := sfs.validSymlinkName(link); err != nil { return fmt.Errorf("symlink: %w", err) } - if err := sfs.validSymlinkName(link); err != nil { + if err := sfs.validWritePath(link); err != nil { return fmt.Errorf("symlink: %w", err) } return sfs.Filesystem.Symlink(target, link) @@ -193,82 +214,95 @@ var errUnsupportedOperation = errors.New("unsupported operation") // errLeadingSymlink indicates that a path has a symlink in a leading component. var errLeadingSymlink = errors.New("leading component is a symlink") -// isDotGitVariant reports whether part is .git, git~1, or an HFS+ -// equivalent of .git (when protectHFS is true). NTFS variants of .git -// (e.g. ".git " with trailing space, ".git::$INDEX_ALLOCATION") are -// detected separately by windowsValidPath, which applies regardless -// of position in the path. Both validators reuse this helper. -func isDotGitVariant(part string, protectHFS bool) bool { - if pathutil.IsDotGitName(part) { - return true - } - if protectHFS && pathutil.IsHFSDotGit(part) { - return true - } - return false -} - -// validPath checks whether paths are valid for the worktree -// filesystem abstraction. It is intentionally tolerant of .git as -// the final path component of a multi-component path -// (e.g. "submodule/.git"), so that legitimate gitlink pointer files -// can still be Stat'd, Read, and Removed via the wrapper during -// submodule cleanup. Attacker-controlled tree-entry paths are -// validated separately by pathutil.ValidTreePath at the boundaries -// where data leaves the trusted store (Tree.FindEntry, the explicit -// callers in CherryPick and Submodule.Repository). +// validPath validates worktree paths, including the names a reset removes +// from the index, which do not pass through ValidTreePath. +// +// Tree paths have separate checks: FindEntry validates lookup paths, +// TreeEntryFile validates file names, and TreeWalker.Next validates entry names +// unless its internal skipPathValidation flag is set. Tree.Validate checks +// names when explicitly called. Submodule.Repository validates paths from +// .gitmodules, and index.Index.Add rejects unsafe names before tree creation. // -// For upstream rules: -// https://github.com/git/git/blob/v2.54.0/read-cache.c#L987 -// https://github.com/git/git/blob/v2.54.0/path.c#L1419 +// validWritePath and validReadPath also check for leading symlinks on disk; +// validPath alone cannot detect them. +// +// Literal `.` and `..` components and a case-insensitive `.git` are +// refused at every position whatever the configuration says; +// core.protectHFS and core.protectNTFS add the remaining `.git` aliases, +// `git~1` among them. A Win32 +// host additionally refuses volume prefixes, and with core.protectNTFS the +// illegal-character, trailing-space/period and reserved-device rules. +// +// ValidTreePath and this gate are not ordered by strictness. Tree +// validation refuses an alias such as sub/.git with both +// protections off, which this gate accepts; a Win32 host with +// core.protectNTFS refuses aux.c here, which tree validation accepts. A +// submodule .git pointer file cannot be reached through this wrapper. +// +// Reference: upstream Git verify_path_internal at read-cache.c#L987-L1048 +// and is_valid_win32_path at compat/mingw.c#L3347-L3469 in tag v2.54.0[1][2]. +// +// [1]: https://github.com/git/git/blob/v2.54.0/read-cache.c#L987-L1048 +// [2]: https://github.com/git/git/blob/v2.54.0/compat/mingw.c#L3347-L3469 func (sfs *worktreeFilesystem) validPath(paths ...string) error { for _, p := range paths { for i := 0; i < len(p); i++ { if p[i] < 0x20 || p[i] == 0x7f { - return fmt.Errorf("invalid path %q: contains control character", p) + return fmt.Errorf("%w %q: contains control character", pathutil.ErrInvalidPath, p) } } parts := strings.FieldsFunc(p, func(r rune) bool { return (r == '\\' || r == '/') }) if len(parts) == 0 { - return fmt.Errorf("invalid path: %q", p) + return fmt.Errorf("%w: %q", pathutil.ErrInvalidPath, p) } - if sfs.protectNTFS { - // Volume names are not supported, in both formats: \\ and :. - if vol := filepath.VolumeName(p); vol != "" { - return fmt.Errorf("invalid path: %q", p) - } + if sfs.win32 && pathutil.HasVolumeName(p) { + return fmt.Errorf("%w %q: contains a volume name", pathutil.ErrInvalidPath, p) } - for i, part := range parts { + for _, part := range parts { + // Always on, as Git's verify_dotfile refuses only these + // whatever core.protectNTFS and core.protectHFS say. if part == "." || part == ".." { - return fmt.Errorf("invalid path %q: cannot use %q", p, part) + return fmt.Errorf("%w %q: cannot use %q", pathutil.ErrInvalidPath, p, part) } - // Reject .git (and equivalents) as a path component when it is - // either the first component (root-level .git) or a non-final - // component (traversal into a .git directory, e.g. "a/.git/config"). - // A final non-first .git component (e.g. "submodule/.git") is - // allowed because submodule worktrees contain a .git pointer file. - if isDotGitVariant(part, sfs.protectHFS) && (i == 0 || i < len(parts)-1) { - return fmt.Errorf("invalid path component: %q", p) + // Check every position, including a final submodule .git pointer. + if sfs.isDotGitComponent(part) { + return fmt.Errorf("%w component: %q", pathutil.ErrInvalidPath, p) } - if sfs.protectNTFS && !pathutil.WindowsValidPath(part) { - return fmt.Errorf("invalid path: %q", p) + if sfs.win32 && sfs.protectNTFS && !pathutil.Win32ValidPath(part) { + return fmt.Errorf("%w %q: component %q is not a valid Windows path component (core.protectNTFS)", pathutil.ErrInvalidPath, p, part) } } } return nil } -// validWritePath validates paths for mutating operations. It layers the -// filesystem-state check validNoLeadingSymlink on top of the string-only -// checks in validPath, so a write can neither name a dangerous path nor -// reach one by traversing an existing symlink. Every mutating method on -// the wrapper funnels through here, so the leading-symlink invariant holds -// for all worktree writers without each call site having to remember it. +// isDotGitComponent reports whether a component names .git under this +// worktree's protection settings. `.git` is refused case-insensitively +// whatever the configuration says; core.protectHFS and core.protectNTFS +// add the HFS+ and NTFS spellings, the 8.3 short name `git~1` among them, +// as Git's verify_path_internal does. validPath checks every position. +// Status and Clean list the worktree directly and skip only .git, in any +// case under core.ignorecase, as Git does, so an untracked directory such +// as git~1 is reported and removed like any other. Clean also leaves the +// repository's own directory alone in cases Git would not; see cleanGuard. +// +// Reference: upstream Git verify_path_internal at read-cache.c#L987-L1048 +// in tag v2.54.0[1]. +// +// [1]: https://github.com/git/git/blob/v2.54.0/read-cache.c#L987-L1048 +func (sfs *worktreeFilesystem) isDotGitComponent(part string) bool { + return strings.EqualFold(part, ".git") || + (sfs.protectHFS && pathutil.IsHFSDotGit(part)) || + (sfs.protectNTFS && pathutil.IsNTFSDotGit(part)) +} + +// validWritePath combines string validation with a check for existing leading +// symlinks, so mutating operations cannot follow them outside the worktree. func (sfs *worktreeFilesystem) validWritePath(paths ...string) error { if err := sfs.validPath(paths...); err != nil { return err @@ -337,3 +371,46 @@ func (sfs *worktreeFilesystem) validSymlinkName(name string) error { } return nil } + +// symlinkGuardedFilesystem is the read side of the worktree filesystem +// without its path policy. Status and Clean walk names taken from listing +// the directory, which name real files, so a directory called git~1 is an +// ordinary one. A read still refuses a path through a symlink, so a +// directory replaced by a link after it was listed is not followed. +type symlinkGuardedFilesystem struct { + billy.Filesystem + guard *worktreeFilesystem +} + +// walkFilesystem returns the filesystem for walking the worktree. +func (sfs *worktreeFilesystem) walkFilesystem() billy.Filesystem { + return &symlinkGuardedFilesystem{Filesystem: sfs.Filesystem, guard: sfs} +} + +func (g *symlinkGuardedFilesystem) Open(filename string) (billy.File, error) { + if err := g.guard.validNoLeadingSymlink(filename); err != nil { + return nil, fmt.Errorf("open: %w", err) + } + return g.Filesystem.Open(filename) +} + +func (g *symlinkGuardedFilesystem) ReadDir(path string) ([]fs.DirEntry, error) { + if err := g.guard.validNoLeadingSymlink(path); err != nil { + return nil, fmt.Errorf("readdir: %w", err) + } + return g.Filesystem.ReadDir(path) +} + +func (g *symlinkGuardedFilesystem) Lstat(filename string) (os.FileInfo, error) { + if err := g.guard.validNoLeadingSymlink(filename); err != nil { + return nil, fmt.Errorf("lstat: %w", err) + } + return g.Filesystem.Lstat(filename) +} + +func (g *symlinkGuardedFilesystem) Readlink(link string) (string, error) { + if err := g.guard.validNoLeadingSymlink(link); err != nil { + return "", fmt.Errorf("readlink: %w", err) + } + return g.Filesystem.Readlink(link) +} diff --git a/vendor/github.com/go-git/go-git/v6/worktree_status.go b/vendor/github.com/go-git/go-git/v6/worktree_status.go index 3f9ce131af..4106dfa562 100644 --- a/vendor/github.com/go-git/go-git/v6/worktree_status.go +++ b/vendor/github.com/go-git/go-git/v6/worktree_status.go @@ -14,6 +14,7 @@ import ( "github.com/go-git/go-billy/v6/util" "github.com/go-git/go-git/v6/config" + "github.com/go-git/go-git/v6/internal/sync" "github.com/go-git/go-git/v6/plumbing" "github.com/go-git/go-git/v6/plumbing/filemode" "github.com/go-git/go-git/v6/plumbing/format/gitignore" @@ -25,7 +26,6 @@ import ( "github.com/go-git/go-git/v6/utils/merkletrie/filesystem" mindex "github.com/go-git/go-git/v6/utils/merkletrie/index" "github.com/go-git/go-git/v6/utils/merkletrie/noder" - "github.com/go-git/go-git/v6/utils/sync" "github.com/go-git/go-git/v6/utils/trace" ) @@ -146,7 +146,13 @@ func (w *Worktree) diffStagingWithWorktree(cfg *config.Config, reverse, excludeI if err != nil { return nil, err } + return w.diffIndexWithWorktree(cfg, idx, reverse, excludeIgnoredChanges) +} +// diffIndexWithWorktree is diffStagingWithWorktree for idx, which need not be +// the stored index: a reset compares the worktree with the index it is about +// to store. +func (w *Worktree) diffIndexWithWorktree(cfg *config.Config, idx *index.Index, reverse, excludeIgnoredChanges bool) (merkletrie.Changes, error) { from := mindex.NewRootNodeWithOptions(idx, mindex.RootNodeOptions{ UpholdExecutableBit: cfg.Core.FileMode, }) @@ -156,8 +162,10 @@ func (w *Worktree) diffStagingWithWorktree(cfg *config.Config, reverse, excludeI } fsOpts := filesystem.Options{ - AutoCRLF: cfg.Core.AutoCRLF == "true" || cfg.Core.AutoCRLF == "input", - Index: idx, + AutoCRLF: cfg.Core.AutoCRLF == "true" || cfg.Core.AutoCRLF == "input", + Index: idx, + ObjectFormat: cfg.Extensions.ObjectFormat, + IgnoreCase: cfg.Core.IgnoreCase.IsTrue(), } // When ignored changes are to be filtered out, hand the noder the ignore @@ -176,7 +184,12 @@ func (w *Worktree) diffStagingWithWorktree(cfg *config.Config, reverse, excludeI fsOpts.IgnoreScope = w.ignoreScope() } - to := filesystem.NewRootNodeWithOptions(w.filesystem, submodules, fsOpts) + // The walk skips the worktree filesystem's path policy: every name in it + // comes from listing its directory, so it names a real file, and Git + // reports an untracked directory named like a .git alias, such as + // git~1, as it does any other. That policy is for names taken from trees, + // the index and .gitmodules. Reads still refuse a leading symlink. + to := filesystem.NewRootNodeWithOptions(w.filesystem.walkFilesystem(), submodules, fsOpts) if reverse { return merkletrie.DiffTree(to, from, diffTreeIsEquals) diff --git a/vendor/github.com/go-git/go-git/v6/x/plugin/config/auto.go b/vendor/github.com/go-git/go-git/v6/x/plugin/config/auto.go index eae1910e64..ad3a975650 100644 --- a/vendor/github.com/go-git/go-git/v6/x/plugin/config/auto.go +++ b/vendor/github.com/go-git/go-git/v6/x/plugin/config/auto.go @@ -48,7 +48,7 @@ func WithFilesystem(fs billy.Basic) Option { // - GIT_CONFIG_NOSYSTEM, when truthy, skips system config entirely. // - GIT_CONFIG_SYSTEM, when set to a non-empty path, reads only that // file. When set to "", system config is disabled entirely. -func NewAuto(opts ...Option) *auto { //nolint:revive +func NewAuto(opts ...Option) *auto { a := &auto{fs: osfs.Default} for _, o := range opts { o(a) diff --git a/vendor/github.com/go-git/go-git/v6/x/plugin/config/empty.go b/vendor/github.com/go-git/go-git/v6/x/plugin/config/empty.go index d1dc26bd64..e0f836e804 100644 --- a/vendor/github.com/go-git/go-git/v6/x/plugin/config/empty.go +++ b/vendor/github.com/go-git/go-git/v6/x/plugin/config/empty.go @@ -8,6 +8,6 @@ import ( // NewEmpty returns a ConfigSource that yields empty configs for both scopes. // The returned configs carry the same initialized defaults as [config.NewConfig]. -func NewEmpty() *static { //nolint:revive +func NewEmpty() *static { return NewStatic(*config.NewConfig(), *config.NewConfig()) } diff --git a/vendor/github.com/go-git/go-git/v6/x/plugin/config/static.go b/vendor/github.com/go-git/go-git/v6/x/plugin/config/static.go index fc081c4342..e3143ef16c 100644 --- a/vendor/github.com/go-git/go-git/v6/x/plugin/config/static.go +++ b/vendor/github.com/go-git/go-git/v6/x/plugin/config/static.go @@ -9,7 +9,7 @@ import ( // NewStatic returns a ConfigSource that always returns read-only // ConfigStorers backed by copies of the provided global and system configs. -func NewStatic(global, system config.Config) *static { //nolint:revive +func NewStatic(global, system config.Config) *static { return &static{global: global, system: system} } diff --git a/vendor/github.com/go-git/go-git/v6/x/plugin/plugin_config.go b/vendor/github.com/go-git/go-git/v6/x/plugin/plugin_config.go index c12bca18fc..578c1a3181 100644 --- a/vendor/github.com/go-git/go-git/v6/x/plugin/plugin_config.go +++ b/vendor/github.com/go-git/go-git/v6/x/plugin/plugin_config.go @@ -32,6 +32,6 @@ type ConfigSource interface { // ConfigLoader returns the key used to register a ConfigLoader plugin. // When set, Repository.ConfigScoped uses this plugin to obtain global and // system configuration instead of reading from the host filesystem. -func ConfigLoader() key[ConfigSource] { //nolint:revive // intentional unexported return type +func ConfigLoader() key[ConfigSource] { return configLoader } diff --git a/vendor/github.com/go-git/go-git/v6/x/plugin/plugin_signer.go b/vendor/github.com/go-git/go-git/v6/x/plugin/plugin_signer.go index 4c186f9ad5..dd3520051e 100644 --- a/vendor/github.com/go-git/go-git/v6/x/plugin/plugin_signer.go +++ b/vendor/github.com/go-git/go-git/v6/x/plugin/plugin_signer.go @@ -19,6 +19,6 @@ type Signer interface { // ObjectSigner returns the key used to register an object-signing plugin. // When set, this plugin will set the default signer for new commits and // tags. -func ObjectSigner() key[Signer] { //nolint:revive // intentional unexported return type +func ObjectSigner() key[Signer] { return objectSigner } diff --git a/vendor/github.com/go-openapi/spec/CONTRIBUTORS.md b/vendor/github.com/go-openapi/spec/CONTRIBUTORS.md index 3e1620230b..c0477aa6b5 100644 --- a/vendor/github.com/go-openapi/spec/CONTRIBUTORS.md +++ b/vendor/github.com/go-openapi/spec/CONTRIBUTORS.md @@ -4,12 +4,12 @@ | Total Contributors | Total Contributions | | --- | --- | -| 39 | 439 | +| 39 | 440 | | Username | All Time Contribution Count | All Commits | | --- | --- | --- | | @casualjim | 191 | | -| @fredbi | 136 | | +| @fredbi | 137 | | | @pytlesk4 | 26 | | | @kul-amr | 10 | | | @keramix | 10 | | diff --git a/vendor/github.com/go-openapi/strfmt/CONTRIBUTORS.md b/vendor/github.com/go-openapi/strfmt/CONTRIBUTORS.md index fe4ed18f60..acff404169 100644 --- a/vendor/github.com/go-openapi/strfmt/CONTRIBUTORS.md +++ b/vendor/github.com/go-openapi/strfmt/CONTRIBUTORS.md @@ -4,7 +4,7 @@ | Total Contributors | Total Contributions | | --- | --- | -| 41 | 256 | +| 42 | 257 | | Username | All Time Contribution Count | All Commits | | --- | --- | --- | @@ -25,18 +25,19 @@ | @chakrit | 2 | | | @bg451 | 2 | | | @aleksandr-vin | 2 | | -| @ujjwalsh | 1 | | -| @patchwright | 1 | | -| @kenjones-cisco | 1 | | -| @jwalter1-quest | 1 | | -| @ccoVeille | 1 | | -| @tylerb | 1 | | -| @tzneal | 1 | | -| @tklauser | 1 | | -| @SuperQ | 1 | | -| @srizzling | 1 | | -| @shawnps | 1 | | | @prashantv | 1 | | +| @SashaMIT | 1 | | +| @shawnps | 1 | | +| @srizzling | 1 | | +| @SuperQ | 1 | | +| @tklauser | 1 | | +| @tzneal | 1 | | +| @tylerb | 1 | | +| @ccoVeille | 1 | | +| @jwalter1-quest | 1 | | +| @kenjones-cisco | 1 | | +| @patchwright | 1 | | +| @ujjwalsh | 1 | | | @krnkl | 1 | | | @mstoykov | 1 | | | @maxatome | 1 | | diff --git a/vendor/github.com/go-openapi/swag/CONTRIBUTORS.md b/vendor/github.com/go-openapi/swag/CONTRIBUTORS.md index 1ff92bc1c0..80b0565e44 100644 --- a/vendor/github.com/go-openapi/swag/CONTRIBUTORS.md +++ b/vendor/github.com/go-openapi/swag/CONTRIBUTORS.md @@ -4,11 +4,11 @@ | Total Contributors | Total Contributions | | --- | --- | -| 24 | 272 | +| 24 | 274 | | Username | All Time Contribution Count | All Commits | | --- | --- | --- | -| @fredbi | 142 | | +| @fredbi | 144 | | | @casualjim | 98 | | | @alexandear | 4 | | | @orisano | 3 | | diff --git a/vendor/github.com/pjbgf/sha1cd/Makefile b/vendor/github.com/pjbgf/sha1cd/Makefile index 711c5e4d4d..242ec6c467 100644 --- a/vendor/github.com/pjbgf/sha1cd/Makefile +++ b/vendor/github.com/pjbgf/sha1cd/Makefile @@ -17,6 +17,36 @@ test: bench: go test -benchmem -run=^$$ -bench ^Benchmark ./... +# bench-compare compares the hashing benchmarks of the working tree against +# BASE on the same machine. The two builds run in turns, so that any drift +# over the run affects both of them alike. BASE is extracted into a new +# temporary directory, which also holds the results. +BASE ?= origin/main +export BASE +BENCH_COUNT ?= 8 +BENCH_RANDOM = ^BenchmarkHashRandom$$/^(8|1024|8192)$$/^fragment(8|1024|8192)$$/^(sha1|sha1cd_native|sha1cd_generic)$$ +BENCH_COLLISION = ^BenchmarkHashWithCollision$$/^fragment640$$/^sha1cd_(native|generic)$$ +BENCHSTAT_VERSION = v0.0.0-20260709024250-82a0b07e230d + +.PHONY: bench-compare +bench-compare: + @set -e; base="$$(git rev-parse --verify --end-of-options "$$BASE^{commit}")"; \ + out="$$(mktemp -d)"; echo "comparing against $$base, results in $$out"; \ + mkdir "$$out/base"; \ + git archive "$$base" | tar -x -C "$$out/base"; \ + (cd "$$out/base" && go test -c -o "$$out/base.test" ./test/); \ + go test -c -o "$$out/head.test" ./test/; \ + for i in $$(seq $(BENCH_COUNT)); do \ + for v in base head; do \ + if [ "$$v" = base ]; then dir="$$out/base/test"; else dir=test; fi; \ + (cd "$$dir" && \ + "$$out/$$v.test" -test.run '^$$' -test.count 1 -test.bench '$(BENCH_RANDOM)' >> "$$out/$$v.txt" && \ + "$$out/$$v.test" -test.run '^$$' -test.count 1 -test.bench '$(BENCH_COLLISION)' >> "$$out/$$v.txt"); \ + done; \ + done; \ + go run golang.org/x/perf/cmd/benchstat@$(BENCHSTAT_VERSION) -filter '.unit:(sec/op OR B/s)' \ + base="$$out/base.txt" head="$$out/head.txt" + # go test only fuzzes a single target per invocation, so each one is run in # turn for FUZZ_TIME. .PHONY: fuzz diff --git a/vendor/github.com/pjbgf/sha1cd/recompress_amd64.s b/vendor/github.com/pjbgf/sha1cd/recompress_amd64.s new file mode 100644 index 0000000000..ecbbe14344 --- /dev/null +++ b/vendor/github.com/pjbgf/sha1cd/recompress_amd64.s @@ -0,0 +1,454 @@ +//go:build !noasm && gc && amd64 + +#include "textflag.h" + +// func recompressSHANI(m1, dm *[80]uint32, from uint32, at, h *[5]uint32) bool +// Requires: SHA, SSE2, SSE4.1 +// +// recompressSHANI reports whether the partner block m1 XOR dm, whose state +// before step from (60 or 64) is at, reaches the chaining value h from some +// input chaining value. That is the question hasCollided answers, asked +// forwards because the SHA instructions only go that way: out from at to step +// 80 gives the input value the partner would need, h minus that state, and in +// from that value must arrive back at at. The steps in between are a +// bijection, so the two questions have the same answer. +TEXT ·recompressSHANI(SB), NOSPLIT, $0-41 + MOVQ m1+0(FP), SI + MOVQ dm+8(FP), DI + MOVL from+16(FP), CX + MOVQ at+24(FP), R8 + MOVQ h+32(FP), R10 + CMPL CX, $60 + JEQ from60 + JMP from64 + +from60: + // Out from the partner's state at step 60 to step 80. + MOVOU (R8), X0 + PSHUFD $0x1b, X0, X0 + MOVL 16(R8), R9 + PXOR X5, X5 + PINSRD $3, R9, X5 + + // Rounds 60-63 + MOVOU 240(SI), X1 + MOVOU 240(DI), X2 + PXOR X2, X1 + PSHUFD $0x1b, X1, X1 + PADDD X1, X5 + MOVO X0, X6 + SHA1RNDS4 $3, X5, X0 + + // Rounds 64-67 + MOVOU 256(SI), X1 + MOVOU 256(DI), X2 + PXOR X2, X1 + PSHUFD $0x1b, X1, X1 + SHA1NEXTE X1, X6 + MOVO X0, X5 + SHA1RNDS4 $3, X6, X0 + + // Rounds 68-71 + MOVOU 272(SI), X1 + MOVOU 272(DI), X2 + PXOR X2, X1 + PSHUFD $0x1b, X1, X1 + SHA1NEXTE X1, X5 + MOVO X0, X6 + SHA1RNDS4 $3, X5, X0 + + // Rounds 72-75 + MOVOU 288(SI), X1 + MOVOU 288(DI), X2 + PXOR X2, X1 + PSHUFD $0x1b, X1, X1 + SHA1NEXTE X1, X6 + MOVO X0, X5 + SHA1RNDS4 $3, X6, X0 + + // Rounds 76-79 + MOVOU 304(SI), X1 + MOVOU 304(DI), X2 + PXOR X2, X1 + PSHUFD $0x1b, X1, X1 + SHA1NEXTE X1, X5 + MOVO X0, X6 + SHA1RNDS4 $3, X5, X0 + + PXOR X2, X2 + SHA1NEXTE X2, X6 + // The chaining value an attack would have to start from is the + // output minus the state at step 80. + MOVOU (R10), X3 + PSHUFD $0x1b, X3, X3 + PSUBL X0, X3 + PEXTRD $3, X6, R9 + MOVL 16(R10), R11 + SUBL R9, R11 + + // In from that value to step 60, which must arrive at the same state. + MOVO X3, X0 + PXOR X5, X5 + PINSRD $3, R11, X5 + + // Rounds 0-3 + MOVOU 0(SI), X1 + MOVOU 0(DI), X2 + PXOR X2, X1 + PSHUFD $0x1b, X1, X1 + PADDD X1, X5 + MOVO X0, X6 + SHA1RNDS4 $0, X5, X0 + + // Rounds 4-7 + MOVOU 16(SI), X1 + MOVOU 16(DI), X2 + PXOR X2, X1 + PSHUFD $0x1b, X1, X1 + SHA1NEXTE X1, X6 + MOVO X0, X5 + SHA1RNDS4 $0, X6, X0 + + // Rounds 8-11 + MOVOU 32(SI), X1 + MOVOU 32(DI), X2 + PXOR X2, X1 + PSHUFD $0x1b, X1, X1 + SHA1NEXTE X1, X5 + MOVO X0, X6 + SHA1RNDS4 $0, X5, X0 + + // Rounds 12-15 + MOVOU 48(SI), X1 + MOVOU 48(DI), X2 + PXOR X2, X1 + PSHUFD $0x1b, X1, X1 + SHA1NEXTE X1, X6 + MOVO X0, X5 + SHA1RNDS4 $0, X6, X0 + + // Rounds 16-19 + MOVOU 64(SI), X1 + MOVOU 64(DI), X2 + PXOR X2, X1 + PSHUFD $0x1b, X1, X1 + SHA1NEXTE X1, X5 + MOVO X0, X6 + SHA1RNDS4 $0, X5, X0 + + // Rounds 20-23 + MOVOU 80(SI), X1 + MOVOU 80(DI), X2 + PXOR X2, X1 + PSHUFD $0x1b, X1, X1 + SHA1NEXTE X1, X6 + MOVO X0, X5 + SHA1RNDS4 $1, X6, X0 + + // Rounds 24-27 + MOVOU 96(SI), X1 + MOVOU 96(DI), X2 + PXOR X2, X1 + PSHUFD $0x1b, X1, X1 + SHA1NEXTE X1, X5 + MOVO X0, X6 + SHA1RNDS4 $1, X5, X0 + + // Rounds 28-31 + MOVOU 112(SI), X1 + MOVOU 112(DI), X2 + PXOR X2, X1 + PSHUFD $0x1b, X1, X1 + SHA1NEXTE X1, X6 + MOVO X0, X5 + SHA1RNDS4 $1, X6, X0 + + // Rounds 32-35 + MOVOU 128(SI), X1 + MOVOU 128(DI), X2 + PXOR X2, X1 + PSHUFD $0x1b, X1, X1 + SHA1NEXTE X1, X5 + MOVO X0, X6 + SHA1RNDS4 $1, X5, X0 + + // Rounds 36-39 + MOVOU 144(SI), X1 + MOVOU 144(DI), X2 + PXOR X2, X1 + PSHUFD $0x1b, X1, X1 + SHA1NEXTE X1, X6 + MOVO X0, X5 + SHA1RNDS4 $1, X6, X0 + + // Rounds 40-43 + MOVOU 160(SI), X1 + MOVOU 160(DI), X2 + PXOR X2, X1 + PSHUFD $0x1b, X1, X1 + SHA1NEXTE X1, X5 + MOVO X0, X6 + SHA1RNDS4 $2, X5, X0 + + // Rounds 44-47 + MOVOU 176(SI), X1 + MOVOU 176(DI), X2 + PXOR X2, X1 + PSHUFD $0x1b, X1, X1 + SHA1NEXTE X1, X6 + MOVO X0, X5 + SHA1RNDS4 $2, X6, X0 + + // Rounds 48-51 + MOVOU 192(SI), X1 + MOVOU 192(DI), X2 + PXOR X2, X1 + PSHUFD $0x1b, X1, X1 + SHA1NEXTE X1, X5 + MOVO X0, X6 + SHA1RNDS4 $2, X5, X0 + + // Rounds 52-55 + MOVOU 208(SI), X1 + MOVOU 208(DI), X2 + PXOR X2, X1 + PSHUFD $0x1b, X1, X1 + SHA1NEXTE X1, X6 + MOVO X0, X5 + SHA1RNDS4 $2, X6, X0 + + // Rounds 56-59 + MOVOU 224(SI), X1 + MOVOU 224(DI), X2 + PXOR X2, X1 + PSHUFD $0x1b, X1, X1 + SHA1NEXTE X1, X5 + MOVO X0, X6 + SHA1RNDS4 $2, X5, X0 + + PXOR X2, X2 + SHA1NEXTE X2, X6 + PEXTRD $3, X6, R9 + JMP compare + +from64: + // Out from the partner's state at step 64 to step 80. + MOVOU (R8), X0 + PSHUFD $0x1b, X0, X0 + MOVL 16(R8), R9 + PXOR X5, X5 + PINSRD $3, R9, X5 + + // Rounds 64-67 + MOVOU 256(SI), X1 + MOVOU 256(DI), X2 + PXOR X2, X1 + PSHUFD $0x1b, X1, X1 + PADDD X1, X5 + MOVO X0, X6 + SHA1RNDS4 $3, X5, X0 + + // Rounds 68-71 + MOVOU 272(SI), X1 + MOVOU 272(DI), X2 + PXOR X2, X1 + PSHUFD $0x1b, X1, X1 + SHA1NEXTE X1, X6 + MOVO X0, X5 + SHA1RNDS4 $3, X6, X0 + + // Rounds 72-75 + MOVOU 288(SI), X1 + MOVOU 288(DI), X2 + PXOR X2, X1 + PSHUFD $0x1b, X1, X1 + SHA1NEXTE X1, X5 + MOVO X0, X6 + SHA1RNDS4 $3, X5, X0 + + // Rounds 76-79 + MOVOU 304(SI), X1 + MOVOU 304(DI), X2 + PXOR X2, X1 + PSHUFD $0x1b, X1, X1 + SHA1NEXTE X1, X6 + MOVO X0, X5 + SHA1RNDS4 $3, X6, X0 + + PXOR X2, X2 + SHA1NEXTE X2, X5 + // The chaining value an attack would have to start from is the + // output minus the state at step 80. + MOVOU (R10), X3 + PSHUFD $0x1b, X3, X3 + PSUBL X0, X3 + PEXTRD $3, X5, R9 + MOVL 16(R10), R11 + SUBL R9, R11 + + // In from that value to step 64, which must arrive at the same state. + MOVO X3, X0 + PXOR X5, X5 + PINSRD $3, R11, X5 + + // Rounds 0-3 + MOVOU 0(SI), X1 + MOVOU 0(DI), X2 + PXOR X2, X1 + PSHUFD $0x1b, X1, X1 + PADDD X1, X5 + MOVO X0, X6 + SHA1RNDS4 $0, X5, X0 + + // Rounds 4-7 + MOVOU 16(SI), X1 + MOVOU 16(DI), X2 + PXOR X2, X1 + PSHUFD $0x1b, X1, X1 + SHA1NEXTE X1, X6 + MOVO X0, X5 + SHA1RNDS4 $0, X6, X0 + + // Rounds 8-11 + MOVOU 32(SI), X1 + MOVOU 32(DI), X2 + PXOR X2, X1 + PSHUFD $0x1b, X1, X1 + SHA1NEXTE X1, X5 + MOVO X0, X6 + SHA1RNDS4 $0, X5, X0 + + // Rounds 12-15 + MOVOU 48(SI), X1 + MOVOU 48(DI), X2 + PXOR X2, X1 + PSHUFD $0x1b, X1, X1 + SHA1NEXTE X1, X6 + MOVO X0, X5 + SHA1RNDS4 $0, X6, X0 + + // Rounds 16-19 + MOVOU 64(SI), X1 + MOVOU 64(DI), X2 + PXOR X2, X1 + PSHUFD $0x1b, X1, X1 + SHA1NEXTE X1, X5 + MOVO X0, X6 + SHA1RNDS4 $0, X5, X0 + + // Rounds 20-23 + MOVOU 80(SI), X1 + MOVOU 80(DI), X2 + PXOR X2, X1 + PSHUFD $0x1b, X1, X1 + SHA1NEXTE X1, X6 + MOVO X0, X5 + SHA1RNDS4 $1, X6, X0 + + // Rounds 24-27 + MOVOU 96(SI), X1 + MOVOU 96(DI), X2 + PXOR X2, X1 + PSHUFD $0x1b, X1, X1 + SHA1NEXTE X1, X5 + MOVO X0, X6 + SHA1RNDS4 $1, X5, X0 + + // Rounds 28-31 + MOVOU 112(SI), X1 + MOVOU 112(DI), X2 + PXOR X2, X1 + PSHUFD $0x1b, X1, X1 + SHA1NEXTE X1, X6 + MOVO X0, X5 + SHA1RNDS4 $1, X6, X0 + + // Rounds 32-35 + MOVOU 128(SI), X1 + MOVOU 128(DI), X2 + PXOR X2, X1 + PSHUFD $0x1b, X1, X1 + SHA1NEXTE X1, X5 + MOVO X0, X6 + SHA1RNDS4 $1, X5, X0 + + // Rounds 36-39 + MOVOU 144(SI), X1 + MOVOU 144(DI), X2 + PXOR X2, X1 + PSHUFD $0x1b, X1, X1 + SHA1NEXTE X1, X6 + MOVO X0, X5 + SHA1RNDS4 $1, X6, X0 + + // Rounds 40-43 + MOVOU 160(SI), X1 + MOVOU 160(DI), X2 + PXOR X2, X1 + PSHUFD $0x1b, X1, X1 + SHA1NEXTE X1, X5 + MOVO X0, X6 + SHA1RNDS4 $2, X5, X0 + + // Rounds 44-47 + MOVOU 176(SI), X1 + MOVOU 176(DI), X2 + PXOR X2, X1 + PSHUFD $0x1b, X1, X1 + SHA1NEXTE X1, X6 + MOVO X0, X5 + SHA1RNDS4 $2, X6, X0 + + // Rounds 48-51 + MOVOU 192(SI), X1 + MOVOU 192(DI), X2 + PXOR X2, X1 + PSHUFD $0x1b, X1, X1 + SHA1NEXTE X1, X5 + MOVO X0, X6 + SHA1RNDS4 $2, X5, X0 + + // Rounds 52-55 + MOVOU 208(SI), X1 + MOVOU 208(DI), X2 + PXOR X2, X1 + PSHUFD $0x1b, X1, X1 + SHA1NEXTE X1, X6 + MOVO X0, X5 + SHA1RNDS4 $2, X6, X0 + + // Rounds 56-59 + MOVOU 224(SI), X1 + MOVOU 224(DI), X2 + PXOR X2, X1 + PSHUFD $0x1b, X1, X1 + SHA1NEXTE X1, X5 + MOVO X0, X6 + SHA1RNDS4 $2, X5, X0 + + // Rounds 60-63 + MOVOU 240(SI), X1 + MOVOU 240(DI), X2 + PXOR X2, X1 + PSHUFD $0x1b, X1, X1 + SHA1NEXTE X1, X6 + MOVO X0, X5 + SHA1RNDS4 $3, X6, X0 + + PXOR X2, X2 + SHA1NEXTE X2, X5 + PEXTRD $3, X5, R9 + JMP compare + +compare: + // X0 holds A to D and R9 holds E of the state reached. + MOVOU (R8), X3 + PSHUFD $0x1b, X3, X3 + PCMPEQL X0, X3 + PMOVMSKB X3, AX + XORL $0xffff, AX + MOVL 16(R8), R11 + XORL R9, R11 + ORL R11, AX + SETEQ ret+40(FP) + RET diff --git a/vendor/github.com/pjbgf/sha1cd/recompress_arm64.s b/vendor/github.com/pjbgf/sha1cd/recompress_arm64.s new file mode 100644 index 0000000000..9a37ed8f62 --- /dev/null +++ b/vendor/github.com/pjbgf/sha1cd/recompress_arm64.s @@ -0,0 +1,523 @@ +//go:build !noasm && gc && arm64 + +#include "textflag.h" + +// func recompressARMv8(m1, dm *[80]uint32, from uint32, at, h *[5]uint32) bool +// +// recompressARMv8 reports whether the partner block m1 XOR dm, whose state +// before step from (60 or 64) is at, reaches the chaining value h from some +// input chaining value. It asks what hasCollided asks, forwards, as the SHA-1 +// instructions only go that way: out from at to step 80 gives the input value +// the partner would need, h minus that state, and in from that value must +// arrive back at at. The steps in between are a bijection, so both questions +// have the same answer. It mirrors recompressSHANI. +// +// V2 holds A to D in lane order and V1 holds E, as in blockARM64. SHA1H turns +// the A saved in V3 before each group into the E four steps later. +TEXT ·recompressARMv8(SB), NOSPLIT, $0-41 + MOVD m1+0(FP), R0 + MOVD dm+8(FP), R1 + MOVWU from+16(FP), R2 + MOVD at+24(FP), R3 + MOVD h+32(FP), R4 + + MOVD $·sha1Ks(SB), R5 + VLD1 (R5), [V19.S4] + VDUP V19.S[0], V20.S4 + VDUP V19.S[1], V21.S4 + VDUP V19.S[2], V22.S4 + VDUP V19.S[3], V23.S4 + + CMPW $60, R2 + BEQ from60 + B from64 + +from60: + // Out from the partner's state at step 60 to step 80. + VLD1 (R3), [V2.S4] + FMOVS 16(R3), F1 + + // Rounds 60-63 + ADD $240, R0, R6 + VLD1 (R6), [V4.S4] + ADD $240, R1, R6 + VLD1 (R6), [V5.S4] + VEOR V5.B16, V4.B16, V4.B16 + VADD V23.S4, V4.S4, V16.S4 + VMOV V2.B16, V3.B16 + SHA1P V16.S4, V1, V2 + SHA1H V3, V1 + + // Rounds 64-67 + ADD $256, R0, R6 + VLD1 (R6), [V4.S4] + ADD $256, R1, R6 + VLD1 (R6), [V5.S4] + VEOR V5.B16, V4.B16, V4.B16 + VADD V23.S4, V4.S4, V16.S4 + VMOV V2.B16, V3.B16 + SHA1P V16.S4, V1, V2 + SHA1H V3, V1 + + // Rounds 68-71 + ADD $272, R0, R6 + VLD1 (R6), [V4.S4] + ADD $272, R1, R6 + VLD1 (R6), [V5.S4] + VEOR V5.B16, V4.B16, V4.B16 + VADD V23.S4, V4.S4, V16.S4 + VMOV V2.B16, V3.B16 + SHA1P V16.S4, V1, V2 + SHA1H V3, V1 + + // Rounds 72-75 + ADD $288, R0, R6 + VLD1 (R6), [V4.S4] + ADD $288, R1, R6 + VLD1 (R6), [V5.S4] + VEOR V5.B16, V4.B16, V4.B16 + VADD V23.S4, V4.S4, V16.S4 + VMOV V2.B16, V3.B16 + SHA1P V16.S4, V1, V2 + SHA1H V3, V1 + + // Rounds 76-79 + ADD $304, R0, R6 + VLD1 (R6), [V4.S4] + ADD $304, R1, R6 + VLD1 (R6), [V5.S4] + VEOR V5.B16, V4.B16, V4.B16 + VADD V23.S4, V4.S4, V16.S4 + VMOV V2.B16, V3.B16 + SHA1P V16.S4, V1, V2 + SHA1H V3, V1 + + // The chaining value an attack would have to start from is the + // output minus the state at step 80. + VLD1 (R4), [V6.S4] + VSUB V2.S4, V6.S4, V2.S4 + VMOV V1.S[0], R7 + MOVWU 16(R4), R8 + SUBW R7, R8, R8 + VMOV R8, V1.S[0] + + // In from that value to step 60, which must arrive at the same state. + // Rounds 0-3 + ADD $0, R0, R6 + VLD1 (R6), [V4.S4] + ADD $0, R1, R6 + VLD1 (R6), [V5.S4] + VEOR V5.B16, V4.B16, V4.B16 + VADD V20.S4, V4.S4, V16.S4 + VMOV V2.B16, V3.B16 + SHA1C V16.S4, V1, V2 + SHA1H V3, V1 + + // Rounds 4-7 + ADD $16, R0, R6 + VLD1 (R6), [V4.S4] + ADD $16, R1, R6 + VLD1 (R6), [V5.S4] + VEOR V5.B16, V4.B16, V4.B16 + VADD V20.S4, V4.S4, V16.S4 + VMOV V2.B16, V3.B16 + SHA1C V16.S4, V1, V2 + SHA1H V3, V1 + + // Rounds 8-11 + ADD $32, R0, R6 + VLD1 (R6), [V4.S4] + ADD $32, R1, R6 + VLD1 (R6), [V5.S4] + VEOR V5.B16, V4.B16, V4.B16 + VADD V20.S4, V4.S4, V16.S4 + VMOV V2.B16, V3.B16 + SHA1C V16.S4, V1, V2 + SHA1H V3, V1 + + // Rounds 12-15 + ADD $48, R0, R6 + VLD1 (R6), [V4.S4] + ADD $48, R1, R6 + VLD1 (R6), [V5.S4] + VEOR V5.B16, V4.B16, V4.B16 + VADD V20.S4, V4.S4, V16.S4 + VMOV V2.B16, V3.B16 + SHA1C V16.S4, V1, V2 + SHA1H V3, V1 + + // Rounds 16-19 + ADD $64, R0, R6 + VLD1 (R6), [V4.S4] + ADD $64, R1, R6 + VLD1 (R6), [V5.S4] + VEOR V5.B16, V4.B16, V4.B16 + VADD V20.S4, V4.S4, V16.S4 + VMOV V2.B16, V3.B16 + SHA1C V16.S4, V1, V2 + SHA1H V3, V1 + + // Rounds 20-23 + ADD $80, R0, R6 + VLD1 (R6), [V4.S4] + ADD $80, R1, R6 + VLD1 (R6), [V5.S4] + VEOR V5.B16, V4.B16, V4.B16 + VADD V21.S4, V4.S4, V16.S4 + VMOV V2.B16, V3.B16 + SHA1P V16.S4, V1, V2 + SHA1H V3, V1 + + // Rounds 24-27 + ADD $96, R0, R6 + VLD1 (R6), [V4.S4] + ADD $96, R1, R6 + VLD1 (R6), [V5.S4] + VEOR V5.B16, V4.B16, V4.B16 + VADD V21.S4, V4.S4, V16.S4 + VMOV V2.B16, V3.B16 + SHA1P V16.S4, V1, V2 + SHA1H V3, V1 + + // Rounds 28-31 + ADD $112, R0, R6 + VLD1 (R6), [V4.S4] + ADD $112, R1, R6 + VLD1 (R6), [V5.S4] + VEOR V5.B16, V4.B16, V4.B16 + VADD V21.S4, V4.S4, V16.S4 + VMOV V2.B16, V3.B16 + SHA1P V16.S4, V1, V2 + SHA1H V3, V1 + + // Rounds 32-35 + ADD $128, R0, R6 + VLD1 (R6), [V4.S4] + ADD $128, R1, R6 + VLD1 (R6), [V5.S4] + VEOR V5.B16, V4.B16, V4.B16 + VADD V21.S4, V4.S4, V16.S4 + VMOV V2.B16, V3.B16 + SHA1P V16.S4, V1, V2 + SHA1H V3, V1 + + // Rounds 36-39 + ADD $144, R0, R6 + VLD1 (R6), [V4.S4] + ADD $144, R1, R6 + VLD1 (R6), [V5.S4] + VEOR V5.B16, V4.B16, V4.B16 + VADD V21.S4, V4.S4, V16.S4 + VMOV V2.B16, V3.B16 + SHA1P V16.S4, V1, V2 + SHA1H V3, V1 + + // Rounds 40-43 + ADD $160, R0, R6 + VLD1 (R6), [V4.S4] + ADD $160, R1, R6 + VLD1 (R6), [V5.S4] + VEOR V5.B16, V4.B16, V4.B16 + VADD V22.S4, V4.S4, V16.S4 + VMOV V2.B16, V3.B16 + SHA1M V16.S4, V1, V2 + SHA1H V3, V1 + + // Rounds 44-47 + ADD $176, R0, R6 + VLD1 (R6), [V4.S4] + ADD $176, R1, R6 + VLD1 (R6), [V5.S4] + VEOR V5.B16, V4.B16, V4.B16 + VADD V22.S4, V4.S4, V16.S4 + VMOV V2.B16, V3.B16 + SHA1M V16.S4, V1, V2 + SHA1H V3, V1 + + // Rounds 48-51 + ADD $192, R0, R6 + VLD1 (R6), [V4.S4] + ADD $192, R1, R6 + VLD1 (R6), [V5.S4] + VEOR V5.B16, V4.B16, V4.B16 + VADD V22.S4, V4.S4, V16.S4 + VMOV V2.B16, V3.B16 + SHA1M V16.S4, V1, V2 + SHA1H V3, V1 + + // Rounds 52-55 + ADD $208, R0, R6 + VLD1 (R6), [V4.S4] + ADD $208, R1, R6 + VLD1 (R6), [V5.S4] + VEOR V5.B16, V4.B16, V4.B16 + VADD V22.S4, V4.S4, V16.S4 + VMOV V2.B16, V3.B16 + SHA1M V16.S4, V1, V2 + SHA1H V3, V1 + + // Rounds 56-59 + ADD $224, R0, R6 + VLD1 (R6), [V4.S4] + ADD $224, R1, R6 + VLD1 (R6), [V5.S4] + VEOR V5.B16, V4.B16, V4.B16 + VADD V22.S4, V4.S4, V16.S4 + VMOV V2.B16, V3.B16 + SHA1M V16.S4, V1, V2 + SHA1H V3, V1 + + B compare + +from64: + // Out from the partner's state at step 64 to step 80. + VLD1 (R3), [V2.S4] + FMOVS 16(R3), F1 + + // Rounds 64-67 + ADD $256, R0, R6 + VLD1 (R6), [V4.S4] + ADD $256, R1, R6 + VLD1 (R6), [V5.S4] + VEOR V5.B16, V4.B16, V4.B16 + VADD V23.S4, V4.S4, V16.S4 + VMOV V2.B16, V3.B16 + SHA1P V16.S4, V1, V2 + SHA1H V3, V1 + + // Rounds 68-71 + ADD $272, R0, R6 + VLD1 (R6), [V4.S4] + ADD $272, R1, R6 + VLD1 (R6), [V5.S4] + VEOR V5.B16, V4.B16, V4.B16 + VADD V23.S4, V4.S4, V16.S4 + VMOV V2.B16, V3.B16 + SHA1P V16.S4, V1, V2 + SHA1H V3, V1 + + // Rounds 72-75 + ADD $288, R0, R6 + VLD1 (R6), [V4.S4] + ADD $288, R1, R6 + VLD1 (R6), [V5.S4] + VEOR V5.B16, V4.B16, V4.B16 + VADD V23.S4, V4.S4, V16.S4 + VMOV V2.B16, V3.B16 + SHA1P V16.S4, V1, V2 + SHA1H V3, V1 + + // Rounds 76-79 + ADD $304, R0, R6 + VLD1 (R6), [V4.S4] + ADD $304, R1, R6 + VLD1 (R6), [V5.S4] + VEOR V5.B16, V4.B16, V4.B16 + VADD V23.S4, V4.S4, V16.S4 + VMOV V2.B16, V3.B16 + SHA1P V16.S4, V1, V2 + SHA1H V3, V1 + + // The chaining value an attack would have to start from is the + // output minus the state at step 80. + VLD1 (R4), [V6.S4] + VSUB V2.S4, V6.S4, V2.S4 + VMOV V1.S[0], R7 + MOVWU 16(R4), R8 + SUBW R7, R8, R8 + VMOV R8, V1.S[0] + + // In from that value to step 64, which must arrive at the same state. + // Rounds 0-3 + ADD $0, R0, R6 + VLD1 (R6), [V4.S4] + ADD $0, R1, R6 + VLD1 (R6), [V5.S4] + VEOR V5.B16, V4.B16, V4.B16 + VADD V20.S4, V4.S4, V16.S4 + VMOV V2.B16, V3.B16 + SHA1C V16.S4, V1, V2 + SHA1H V3, V1 + + // Rounds 4-7 + ADD $16, R0, R6 + VLD1 (R6), [V4.S4] + ADD $16, R1, R6 + VLD1 (R6), [V5.S4] + VEOR V5.B16, V4.B16, V4.B16 + VADD V20.S4, V4.S4, V16.S4 + VMOV V2.B16, V3.B16 + SHA1C V16.S4, V1, V2 + SHA1H V3, V1 + + // Rounds 8-11 + ADD $32, R0, R6 + VLD1 (R6), [V4.S4] + ADD $32, R1, R6 + VLD1 (R6), [V5.S4] + VEOR V5.B16, V4.B16, V4.B16 + VADD V20.S4, V4.S4, V16.S4 + VMOV V2.B16, V3.B16 + SHA1C V16.S4, V1, V2 + SHA1H V3, V1 + + // Rounds 12-15 + ADD $48, R0, R6 + VLD1 (R6), [V4.S4] + ADD $48, R1, R6 + VLD1 (R6), [V5.S4] + VEOR V5.B16, V4.B16, V4.B16 + VADD V20.S4, V4.S4, V16.S4 + VMOV V2.B16, V3.B16 + SHA1C V16.S4, V1, V2 + SHA1H V3, V1 + + // Rounds 16-19 + ADD $64, R0, R6 + VLD1 (R6), [V4.S4] + ADD $64, R1, R6 + VLD1 (R6), [V5.S4] + VEOR V5.B16, V4.B16, V4.B16 + VADD V20.S4, V4.S4, V16.S4 + VMOV V2.B16, V3.B16 + SHA1C V16.S4, V1, V2 + SHA1H V3, V1 + + // Rounds 20-23 + ADD $80, R0, R6 + VLD1 (R6), [V4.S4] + ADD $80, R1, R6 + VLD1 (R6), [V5.S4] + VEOR V5.B16, V4.B16, V4.B16 + VADD V21.S4, V4.S4, V16.S4 + VMOV V2.B16, V3.B16 + SHA1P V16.S4, V1, V2 + SHA1H V3, V1 + + // Rounds 24-27 + ADD $96, R0, R6 + VLD1 (R6), [V4.S4] + ADD $96, R1, R6 + VLD1 (R6), [V5.S4] + VEOR V5.B16, V4.B16, V4.B16 + VADD V21.S4, V4.S4, V16.S4 + VMOV V2.B16, V3.B16 + SHA1P V16.S4, V1, V2 + SHA1H V3, V1 + + // Rounds 28-31 + ADD $112, R0, R6 + VLD1 (R6), [V4.S4] + ADD $112, R1, R6 + VLD1 (R6), [V5.S4] + VEOR V5.B16, V4.B16, V4.B16 + VADD V21.S4, V4.S4, V16.S4 + VMOV V2.B16, V3.B16 + SHA1P V16.S4, V1, V2 + SHA1H V3, V1 + + // Rounds 32-35 + ADD $128, R0, R6 + VLD1 (R6), [V4.S4] + ADD $128, R1, R6 + VLD1 (R6), [V5.S4] + VEOR V5.B16, V4.B16, V4.B16 + VADD V21.S4, V4.S4, V16.S4 + VMOV V2.B16, V3.B16 + SHA1P V16.S4, V1, V2 + SHA1H V3, V1 + + // Rounds 36-39 + ADD $144, R0, R6 + VLD1 (R6), [V4.S4] + ADD $144, R1, R6 + VLD1 (R6), [V5.S4] + VEOR V5.B16, V4.B16, V4.B16 + VADD V21.S4, V4.S4, V16.S4 + VMOV V2.B16, V3.B16 + SHA1P V16.S4, V1, V2 + SHA1H V3, V1 + + // Rounds 40-43 + ADD $160, R0, R6 + VLD1 (R6), [V4.S4] + ADD $160, R1, R6 + VLD1 (R6), [V5.S4] + VEOR V5.B16, V4.B16, V4.B16 + VADD V22.S4, V4.S4, V16.S4 + VMOV V2.B16, V3.B16 + SHA1M V16.S4, V1, V2 + SHA1H V3, V1 + + // Rounds 44-47 + ADD $176, R0, R6 + VLD1 (R6), [V4.S4] + ADD $176, R1, R6 + VLD1 (R6), [V5.S4] + VEOR V5.B16, V4.B16, V4.B16 + VADD V22.S4, V4.S4, V16.S4 + VMOV V2.B16, V3.B16 + SHA1M V16.S4, V1, V2 + SHA1H V3, V1 + + // Rounds 48-51 + ADD $192, R0, R6 + VLD1 (R6), [V4.S4] + ADD $192, R1, R6 + VLD1 (R6), [V5.S4] + VEOR V5.B16, V4.B16, V4.B16 + VADD V22.S4, V4.S4, V16.S4 + VMOV V2.B16, V3.B16 + SHA1M V16.S4, V1, V2 + SHA1H V3, V1 + + // Rounds 52-55 + ADD $208, R0, R6 + VLD1 (R6), [V4.S4] + ADD $208, R1, R6 + VLD1 (R6), [V5.S4] + VEOR V5.B16, V4.B16, V4.B16 + VADD V22.S4, V4.S4, V16.S4 + VMOV V2.B16, V3.B16 + SHA1M V16.S4, V1, V2 + SHA1H V3, V1 + + // Rounds 56-59 + ADD $224, R0, R6 + VLD1 (R6), [V4.S4] + ADD $224, R1, R6 + VLD1 (R6), [V5.S4] + VEOR V5.B16, V4.B16, V4.B16 + VADD V22.S4, V4.S4, V16.S4 + VMOV V2.B16, V3.B16 + SHA1M V16.S4, V1, V2 + SHA1H V3, V1 + + // Rounds 60-63 + ADD $240, R0, R6 + VLD1 (R6), [V4.S4] + ADD $240, R1, R6 + VLD1 (R6), [V5.S4] + VEOR V5.B16, V4.B16, V4.B16 + VADD V23.S4, V4.S4, V16.S4 + VMOV V2.B16, V3.B16 + SHA1P V16.S4, V1, V2 + SHA1H V3, V1 + + B compare + +compare: + // V2 and V1 hold the state reached, which must equal at. + VLD1 (R3), [V6.S4] + VEOR V6.B16, V2.B16, V6.B16 + VMOV V6.D[0], R7 + VMOV V6.D[1], R8 + ORR R8, R7, R7 + VMOV V1.S[0], R8 + MOVWU 16(R3), R9 + EORW R9, R8, R8 + ORR R8, R7, R7 + CMP $0, R7 + CSET EQ, R7 + MOVB R7, ret+40(FP) + RET diff --git a/vendor/github.com/pjbgf/sha1cd/recompress_asm.go b/vendor/github.com/pjbgf/sha1cd/recompress_asm.go new file mode 100644 index 0000000000..031fe8c006 --- /dev/null +++ b/vendor/github.com/pjbgf/sha1cd/recompress_asm.go @@ -0,0 +1,73 @@ +//go:build !noasm && gc && (amd64 || arm64) + +package sha1cd + +import ( + "math/bits" + + shared "github.com/pjbgf/sha1cd/internal" + "github.com/pjbgf/sha1cd/ubc" +) + +// collidedHW reports whether one of the DVs in mask describes an attack that +// the block, compressed by the assembly block into h, belongs to. +// +// The assembly blocks store the states before steps 56 and 64, as the SHA-1 +// instructions run four steps at a time. The partner block shares the state +// before step 58 or 65 with this one, so its state at the nearest four step +// boundary is a step or two away, and recompressHW runs from there. +// +// recompressHW is called directly rather than passed in, so that its +// arguments are known not to escape and hashing stays free of allocations. +// +//go:noinline +func collidedHW(m1 *[shared.Rounds]uint32, cs *[shared.PreStepState][shared.WordBuffers]uint32, + h *[shared.WordBuffers]uint32, mask uint32) bool { + dvs := ubc.SHA1_dvs() + var at58 [shared.WordBuffers]uint32 + have58 := false + + for rest := mask; rest != 0; rest &= rest - 1 { + dv := &dvs[bits.TrailingZeros32(rest)] + var at [shared.WordBuffers]uint32 + var from uint32 + + switch dv.TestT { + case 58: + if !have58 { + at58 = cs[1] + for i := 56; i < 58; i++ { + stepMaj(&at58, m1[i]) + } + have58 = true + } + at = at58 + for i := 58; i < 60; i++ { + stepMaj(&at, m1[i]^dv.Dm[i]) + } + from = 60 + case 65: + // Undoing step 64 with the partner's word instead of this + // block's leaves A to D as they are and moves E by the + // difference between the two words. + at = cs[2] + at[4] += m1[64] - (m1[64] ^ dv.Dm[64]) + from = 64 + default: + panic("sha1cd: DV with an unsupported testT") + } + + if recompressHW(m1, &dv.Dm, from, &at, h) { + return true + } + } + return false +} + +// stepMaj runs one of steps 40 to 59 on the state s. +func stepMaj(s *[shared.WordBuffers]uint32, w uint32) { + a, b, c, d, e := s[0], s[1], s[2], s[3], s[4] + f := ((b | c) & d) | (b & c) + t := bits.RotateLeft32(a, 5) + f + e + w + shared.K2 + s[0], s[1], s[2], s[3], s[4] = t, a, bits.RotateLeft32(b, 30), c, d +} diff --git a/vendor/github.com/pjbgf/sha1cd/sha1cdblock_amd64.go b/vendor/github.com/pjbgf/sha1cd/sha1cdblock_amd64.go index 7642fc403e..07f5ea88ca 100644 --- a/vendor/github.com/pjbgf/sha1cd/sha1cdblock_amd64.go +++ b/vendor/github.com/pjbgf/sha1cd/sha1cdblock_amd64.go @@ -46,10 +46,8 @@ func blockSHANI(dig *digest, p []byte) { chunk := p[:shared.Chunk] blockAMD64(dig.h[:], chunk, m1[:], cs[:]) - // Assembly states need repair only when a disturbance vector survives. if mask := ubc.CalculateDvMask(&m1); mask != 0 { - rectifyCompressionState(&m1, &cs) - if checkCollision(&m1, &cs, &dig.h, mask) { + if collidedHW(&m1, &cs, &dig.h, mask) { dig.col = true blockAMD64(dig.h[:], chunk, m1[:], cs[:]) @@ -60,3 +58,16 @@ func blockSHANI(dig *digest, p []byte) { p = p[shared.Chunk:] } } + +// recompressSHANI reports whether the partner block m1 XOR dm, whose state +// before step from (60 or 64) is at, reaches the chaining value h. It runs +// on the SHA instructions, and answers what hasCollided answers. +// +//go:noescape +func recompressSHANI(m1, dm *[shared.Rounds]uint32, from uint32, at, h *[shared.WordBuffers]uint32) bool + +// recompressHW reports whether the partner block m1 XOR dm, whose state +// before step from (60 or 64) is at, reaches the chaining value h. +func recompressHW(m1, dm *[shared.Rounds]uint32, from uint32, at, h *[shared.WordBuffers]uint32) bool { + return recompressSHANI(m1, dm, from, at, h) +} diff --git a/vendor/github.com/pjbgf/sha1cd/sha1cdblock_arm64.go b/vendor/github.com/pjbgf/sha1cd/sha1cdblock_arm64.go index 98ac38c285..6454ee8aa3 100644 --- a/vendor/github.com/pjbgf/sha1cd/sha1cdblock_arm64.go +++ b/vendor/github.com/pjbgf/sha1cd/sha1cdblock_arm64.go @@ -35,11 +35,8 @@ func block(dig *digest, p []byte) { chunk := p[:shared.Chunk] blockARM64(dig.h[:], chunk, m1[:], cs[:]) - - // Assembly states need repair only when a disturbance vector survives. if mask := ubc.CalculateDvMask(&m1); mask != 0 { - rectifyCompressionState(&m1, &cs) - if checkCollision(&m1, &cs, &dig.h, mask) { + if collidedHW(&m1, &cs, &dig.h, mask) { dig.col = true blockARM64(dig.h[:], chunk, m1[:], cs[:]) @@ -50,3 +47,16 @@ func block(dig *digest, p []byte) { p = p[shared.Chunk:] } } + +// recompressARMv8 reports whether the partner block m1 XOR dm, whose state +// before step from (60 or 64) is at, reaches the chaining value h. It runs +// on the ARMv8 SHA-1 instructions, and answers what hasCollided answers. +// +//go:noescape +func recompressARMv8(m1, dm *[shared.Rounds]uint32, from uint32, at, h *[shared.WordBuffers]uint32) bool + +// recompressHW reports whether the partner block m1 XOR dm, whose state +// before step from (60 or 64) is at, reaches the chaining value h. +func recompressHW(m1, dm *[shared.Rounds]uint32, from uint32, at, h *[shared.WordBuffers]uint32) bool { + return recompressARMv8(m1, dm, from, at, h) +} diff --git a/vendor/github.com/pjbgf/sha1cd/sha1cdblock_generic.go b/vendor/github.com/pjbgf/sha1cd/sha1cdblock_generic.go index 6557410ee7..e1fc958ffa 100644 --- a/vendor/github.com/pjbgf/sha1cd/sha1cdblock_generic.go +++ b/vendor/github.com/pjbgf/sha1cd/sha1cdblock_generic.go @@ -135,164 +135,86 @@ func checkCollision( h *[shared.WordBuffers]uint32, mask uint32, ) bool { - if mask != 0 { - dvs := ubc.SHA1_dvs() - - for i := 0; dvs[i].DvType != 0; i++ { - if (mask & ((uint32)(1) << uint32(dvs[i].MaskB))) != 0 { - var csState *[shared.WordBuffers]uint32 - switch dvs[i].TestT { - case 58: - csState = &cs[1] - case 65: - csState = &cs[2] - case 0: - csState = &cs[0] - default: - panic(fmt.Sprintf("dvs data is trying to use a testT that isn't available: %d", dvs[i].TestT)) - } - - col := hasCollided( - dvs[i].TestT, // testT is the step number - // m2 is a secondary message created XORing with - // ubc's DM prior to the SHA recompression step. - m1, &dvs[i].Dm, - csState, - h) + dvs := ubc.SHA1_dvs() + + // Walk the set bits rather than the table, whose entries are indexed + // by their mask bit, so that only the candidates are read. + for rest := mask; rest != 0; rest &= rest - 1 { + dv := &dvs[bits.TrailingZeros32(rest)] + var csState *[shared.WordBuffers]uint32 + switch dv.TestT { + case 58: + csState = &cs[1] + case 65: + csState = &cs[2] + default: + panic(fmt.Sprintf("dvs data is trying to use a testT that isn't available: %d", dv.TestT)) + } - if col { - return true - } - } + // The partner block is m1 XOR the DV's message difference. + if hasCollided(dv.TestT, m1, &dv.Dm, csState, h) { + return true } } return false } +// hasCollided reports whether the partner block m1 XOR dm, whose state before +// step is state, reaches the chaining value h from some input chaining value. +// +// state holds A to E in order, as every block implementation stores them. +// The port of ubc_check.c's recompression this replaces read the state +// before step 58 in the rotated layout the C code stores it in, so it never +// confirmed an attack along the DVs that are tested from step 58. +// //go:nosplit func hasCollided(step uint32, m1, dm *[shared.Rounds]uint32, state *[shared.WordBuffers]uint32, h *[shared.WordBuffers]uint32) bool { - // Intermediary Hash Value. - ihv := [shared.WordBuffers]uint32{} - + // Walk back from the state before step to the partner's input chaining + // value. Undoing step i recovers B from C, and E from the A it produced. a, b, c, d, e := state[0], state[1], state[2], state[3], state[4] - - // Walk backwards from current step to undo previous compression. - // The existing collision detection does not have dvs higher than 65, - // start value of i accordingly. - for i := uint32(64); i >= 60; i-- { - a, b, c, d, e = b, c, d, e, a - if step > i { - b = bits.RotateLeft32(b, -30) - f := b ^ c ^ d - e -= bits.RotateLeft32(a, 5) + f + shared.K3 + (m1[i] ^ dm[i]) // m2 = m1 ^ dm. - } + i := int(step) - 1 + for ; i >= 60; i-- { + next := a + a, b, c, d = b, bits.RotateLeft32(c, 2), d, e + e = next - (bits.RotateLeft32(a, 5) + (b ^ c ^ d) + shared.K3 + (m1[i] ^ dm[i])) } - for i := uint32(59); i >= 40; i-- { - a, b, c, d, e = b, c, d, e, a - if step > i { - b = bits.RotateLeft32(b, -30) - f := ((b | c) & d) | (b & c) - e -= bits.RotateLeft32(a, 5) + f + shared.K2 + (m1[i] ^ dm[i]) - } + for ; i >= 40; i-- { + next := a + a, b, c, d = b, bits.RotateLeft32(c, 2), d, e + e = next - (bits.RotateLeft32(a, 5) + ((b|c)&d | b&c) + shared.K2 + (m1[i] ^ dm[i])) } - for i := uint32(39); i >= 20; i-- { - a, b, c, d, e = b, c, d, e, a - if step > i { - b = bits.RotateLeft32(b, -30) - f := b ^ c ^ d - e -= bits.RotateLeft32(a, 5) + f + shared.K1 + (m1[i] ^ dm[i]) - } + for ; i >= 20; i-- { + next := a + a, b, c, d = b, bits.RotateLeft32(c, 2), d, e + e = next - (bits.RotateLeft32(a, 5) + (b ^ c ^ d) + shared.K1 + (m1[i] ^ dm[i])) } - for i := uint32(20); i > 0; i-- { - j := i - 1 - a, b, c, d, e = b, c, d, e, a - if step > j { - b = bits.RotateLeft32(b, -30) // undo the rotate left - f := b&c | (^b)&d - // subtract from e - e -= bits.RotateLeft32(a, 5) + f + shared.K0 + (m1[j] ^ dm[j]) - } + for ; i >= 0; i-- { + next := a + a, b, c, d = b, bits.RotateLeft32(c, 2), d, e + e = next - (bits.RotateLeft32(a, 5) + (b&c | ^b&d) + shared.K0 + (m1[i] ^ dm[i])) } + ihv := [shared.WordBuffers]uint32{a, b, c, d, e} - ihv[0] = a - ihv[1] = b - ihv[2] = c - ihv[3] = d - ihv[4] = e - a = state[0] - b = state[1] - c = state[2] - d = state[3] - e = state[4] - - // Recompress blocks based on the current step. - // The existing collision detection does not have dvs below 58, so they have been removed - // from the source code. If new dvs are added which target rounds below 40, that logic - // will need to be readded here. - for i := uint32(40); i < 60; i++ { - if step <= i { - f := ((b | c) & d) | (b & c) - t := bits.RotateLeft32(a, 5) + f + e + shared.K2 + (m1[i] ^ dm[i]) - a, b, c, d, e = t, a, bits.RotateLeft32(b, 30), c, d - } - } - for i := uint32(60); i < 80; i++ { - if step <= i { - f := b ^ c ^ d - t := bits.RotateLeft32(a, 5) + f + e + shared.K3 + (m1[i] ^ dm[i]) - a, b, c, d, e = t, a, bits.RotateLeft32(b, 30), c, d - } + // Run forward from the same state to the end of the block. + a, b, c, d, e = state[0], state[1], state[2], state[3], state[4] + i = int(step) + for ; i < 20; i++ { + t := bits.RotateLeft32(a, 5) + (b&c | ^b&d) + e + shared.K0 + (m1[i] ^ dm[i]) + a, b, c, d, e = t, a, bits.RotateLeft32(b, 30), c, d } - - ihv[0] += a - ihv[1] += b - ihv[2] += c - ihv[3] += d - ihv[4] += e - - if ((ihv[0] ^ h[0]) | (ihv[1] ^ h[1]) | - (ihv[2] ^ h[2]) | (ihv[3] ^ h[3]) | (ihv[4] ^ h[4])) == 0 { - return true + for ; i < 40; i++ { + t := bits.RotateLeft32(a, 5) + (b ^ c ^ d) + e + shared.K1 + (m1[i] ^ dm[i]) + a, b, c, d, e = t, a, bits.RotateLeft32(b, 30), c, d } - - return false -} - -// rectifyCompressionState fixes the compression state when using the -// SIMD implementations. -// -// Due to the way that hardware acceleration works, the rounds -// are executed 4 at a time. Therefore, the state for cs58 and cs65 -// are not available directly through the assembly logic. The states -// returned are for cs56 and cs64. This function updates indexes 1 and 2 -// of cs to contain the respective CS values for rounds 58 and 65. -// -//go:nosplit -func rectifyCompressionState( - m1 *[shared.Rounds]uint32, - cs *[shared.PreStepState][shared.WordBuffers]uint32, -) { - if cs == nil { - return + for ; i < 60; i++ { + t := bits.RotateLeft32(a, 5) + ((b|c)&d | b&c) + e + shared.K2 + (m1[i] ^ dm[i]) + a, b, c, d, e = t, a, bits.RotateLeft32(b, 30), c, d } - - // The words are loaded and stored one at a time. Passing [5]uint32 values - // around made the compiler reload them with wider moves than they were - // stored with, which stalled on store forwarding each time. - - // Advance cs[1] from the state before step 56 to the one before step 58. - a, b, c, d, e := cs[1][0], cs[1][1], cs[1][2], cs[1][3], cs[1][4] - for i := 56; i < 58; i++ { - f := ((b | c) & d) | (b & c) - t := bits.RotateLeft32(a, 5) + f + e + m1[i] + shared.K2 + for ; i < 80; i++ { + t := bits.RotateLeft32(a, 5) + (b ^ c ^ d) + e + shared.K3 + (m1[i] ^ dm[i]) a, b, c, d, e = t, a, bits.RotateLeft32(b, 30), c, d } - cs[1][0], cs[1][1], cs[1][2], cs[1][3], cs[1][4] = a, b, c, d, e - // Advance cs[2] from the state before step 64 to the one before step 65. - a, b, c, d, e = cs[2][0], cs[2][1], cs[2][2], cs[2][3], cs[2][4] - f := b ^ c ^ d - t := bits.RotateLeft32(a, 5) + f + e + m1[64] + shared.K3 - cs[2][0], cs[2][1], cs[2][2], cs[2][3], cs[2][4] = t, a, bits.RotateLeft32(b, 30), c, d + return ((ihv[0]+a)^h[0])|((ihv[1]+b)^h[1])|((ihv[2]+c)^h[2])|((ihv[3]+d)^h[3])|((ihv[4]+e)^h[4]) == 0 } diff --git a/vendor/github.com/pjbgf/sha1cd/ubc/dvmask_amd64.go b/vendor/github.com/pjbgf/sha1cd/ubc/dvmask_amd64.go index ad76b64a06..749a4da9d9 100644 --- a/vendor/github.com/pjbgf/sha1cd/ubc/dvmask_amd64.go +++ b/vendor/github.com/pjbgf/sha1cd/ubc/dvmask_amd64.go @@ -3,38 +3,29 @@ package ubc import ( - "unsafe" - "github.com/pjbgf/sha1cd/internal/cpu" ) -// useAVX512 reports whether calculateDvMaskAVX512 can run. Its only -// instructions outside AVX-512F are VMOVD and VZEROUPPER, which need AVX. -// HasAVX512F is set only when the CPU reports AVX as well. -var useAVX512 = cpu.X86.HasAVX512F +// useAVX2 reports whether prefixAVX2 can run. +// +// There is no AVX-512 form. On a Zen 5 core with 256 bit datapaths, a 16 lane +// prefix ran a third slower than the 8 lane one. It has not been measured on a +// core with full width AVX-512. +var useAVX2 = cpu.X86.HasAVX2 +// prefixAVX2 runs the AVX2 prefix and returns the DVs it leaves standing. It +// is generated by internal/ubcgen. +// //go:noescape -func calculateDvMaskAVX512(W *[80]uint32, terms *uint32, groups int) uint32 - -// avx512Lanes is the number of terms a group of avx512Terms describes, and -// avx512Fields the vectors it holds for them. -const ( - avx512Lanes = 16 - avx512Fields = 6 -) - -// avx512Groups is how many passes of the kernel loop the table needs. -const avx512Groups = len(avx512Terms) / (avx512Fields * avx512Lanes) +func prefixAVX2(W *[80]uint32) uint32 -// alignedTerms is a copy of avx512Terms that starts on a cache line. The -// linker aligns data to 32 bytes at most, and a 64 byte load that straddles -// two cache lines costs about twice as much. -var alignedTerms = func() *uint32 { - buf := make([]uint32, len(avx512Terms)+16) - off := (64 - uintptr(unsafe.Pointer(&buf[0]))%64) % 64 / 4 - copy(buf[off:], avx512Terms[:]) - return &buf[off] -}() +func calculateDvMaskAVX2(W *[80]uint32) uint32 { + mask := prefixAVX2(W) + if mask == 0 { + return 0 + } + return tail(W, mask, tailChecksAVX2[:], &tailSpansAVX2) +} // CalculateDvMask takes as input an expanded message block and // verifies the unavoidable bitconditions for all listed DVs. It returns @@ -44,8 +35,8 @@ func CalculateDvMask(W *[80]uint32) uint32 { if W == nil { return 0 } - if useAVX512 { - return calculateDvMaskAVX512(W, alignedTerms, avx512Groups) + if useAVX2 { + return calculateDvMaskAVX2(W) } return calculateDvMaskGeneric(W) } diff --git a/vendor/github.com/pjbgf/sha1cd/ubc/dvmask_arm64.go b/vendor/github.com/pjbgf/sha1cd/ubc/dvmask_arm64.go new file mode 100644 index 0000000000..750bb6babb --- /dev/null +++ b/vendor/github.com/pjbgf/sha1cd/ubc/dvmask_arm64.go @@ -0,0 +1,29 @@ +//go:build !noasm && gc && arm64 + +package ubc + +// prefixNEON runs the NEON prefix and returns the DVs it leaves standing. It +// is generated by internal/ubcgen. NEON is part of the arm64 baseline, so it +// needs no feature check. +// +//go:noescape +func prefixNEON(W *[80]uint32) uint32 + +func calculateDvMaskNEON(W *[80]uint32) uint32 { + mask := prefixNEON(W) + if mask == 0 { + return 0 + } + return tail(W, mask, tailChecksNEON[:], &tailSpansNEON) +} + +// CalculateDvMask takes as input an expanded message block and +// verifies the unavoidable bitconditions for all listed DVs. It returns +// a dvmask where each bit belonging to a DV is set if all unavoidable +// bitconditions for that DV have been met. +func CalculateDvMask(W *[80]uint32) uint32 { + if W == nil { + return 0 + } + return calculateDvMaskNEON(W) +} diff --git a/vendor/github.com/pjbgf/sha1cd/ubc/dvmask_avx2_amd64.s b/vendor/github.com/pjbgf/sha1cd/ubc/dvmask_avx2_amd64.s new file mode 100644 index 0000000000..0db6d00a04 --- /dev/null +++ b/vendor/github.com/pjbgf/sha1cd/ubc/dvmask_avx2_amd64.s @@ -0,0 +1,369 @@ +// Code generated by internal/ubcgen. DO NOT EDIT. + +//go:build !noasm && gc && amd64 + +#include "textflag.h" + +DATA avx2Groups<>+0(SB)/4, $0x20000000 +DATA avx2Groups<>+4(SB)/4, $0x20000000 +DATA avx2Groups<>+8(SB)/4, $0x20000000 +DATA avx2Groups<>+12(SB)/4, $0x20000000 +DATA avx2Groups<>+16(SB)/4, $0x20000000 +DATA avx2Groups<>+20(SB)/4, $0x20000000 +DATA avx2Groups<>+24(SB)/4, $0x20000000 +DATA avx2Groups<>+28(SB)/4, $0x20000000 +DATA avx2Groups<>+32(SB)/4, $0x00000000 +DATA avx2Groups<>+36(SB)/4, $0x00000000 +DATA avx2Groups<>+40(SB)/4, $0x00000000 +DATA avx2Groups<>+44(SB)/4, $0x00000000 +DATA avx2Groups<>+48(SB)/4, $0x00000000 +DATA avx2Groups<>+52(SB)/4, $0x00000000 +DATA avx2Groups<>+56(SB)/4, $0x00000000 +DATA avx2Groups<>+60(SB)/4, $0x00000000 +DATA avx2Groups<>+64(SB)/4, $0x00300a08 +DATA avx2Groups<>+68(SB)/4, $0x00a12820 +DATA avx2Groups<>+72(SB)/4, $0x0283a080 +DATA avx2Groups<>+76(SB)/4, $0x0a0a8200 +DATA avx2Groups<>+80(SB)/4, $0x18180801 +DATA avx2Groups<>+84(SB)/4, $0x30302002 +DATA avx2Groups<>+88(SB)/4, $0x60a08004 +DATA avx2Groups<>+92(SB)/4, $0xc2810008 +DATA avx2Groups<>+96(SB)/4, $0x00000010 +DATA avx2Groups<>+100(SB)/4, $0x00000002 +DATA avx2Groups<>+104(SB)/4, $0x00000002 +DATA avx2Groups<>+108(SB)/4, $0x00000002 +DATA avx2Groups<>+112(SB)/4, $0x00000040 +DATA avx2Groups<>+116(SB)/4, $0x00000040 +DATA avx2Groups<>+120(SB)/4, $0x00000040 +DATA avx2Groups<>+124(SB)/4, $0x00000040 +DATA avx2Groups<>+128(SB)/4, $0x00000010 +DATA avx2Groups<>+132(SB)/4, $0x00000002 +DATA avx2Groups<>+136(SB)/4, $0x00000002 +DATA avx2Groups<>+140(SB)/4, $0x00000002 +DATA avx2Groups<>+144(SB)/4, $0x00000000 +DATA avx2Groups<>+148(SB)/4, $0x00000000 +DATA avx2Groups<>+152(SB)/4, $0x00000000 +DATA avx2Groups<>+156(SB)/4, $0x00000000 +DATA avx2Groups<>+160(SB)/4, $0xa0000002 +DATA avx2Groups<>+164(SB)/4, $0x00401000 +DATA avx2Groups<>+168(SB)/4, $0x01004000 +DATA avx2Groups<>+172(SB)/4, $0x04040000 +DATA avx2Groups<>+176(SB)/4, $0x00000110 +DATA avx2Groups<>+180(SB)/4, $0x00000440 +DATA avx2Groups<>+184(SB)/4, $0x00001110 +DATA avx2Groups<>+188(SB)/4, $0x00004440 +DATA avx2Groups<>+192(SB)/4, $0x00000010 +DATA avx2Groups<>+196(SB)/4, $0x00000010 +DATA avx2Groups<>+200(SB)/4, $0x00000010 +DATA avx2Groups<>+204(SB)/4, $0x00000010 +DATA avx2Groups<>+208(SB)/4, $0x00000010 +DATA avx2Groups<>+212(SB)/4, $0x00000010 +DATA avx2Groups<>+216(SB)/4, $0x00000010 +DATA avx2Groups<>+220(SB)/4, $0x00000010 +DATA avx2Groups<>+224(SB)/4, $0x00000000 +DATA avx2Groups<>+228(SB)/4, $0x00000000 +DATA avx2Groups<>+232(SB)/4, $0x00000000 +DATA avx2Groups<>+236(SB)/4, $0x00000000 +DATA avx2Groups<>+240(SB)/4, $0x00000000 +DATA avx2Groups<>+244(SB)/4, $0x00000000 +DATA avx2Groups<>+248(SB)/4, $0x00000000 +DATA avx2Groups<>+252(SB)/4, $0x00000000 +DATA avx2Groups<>+256(SB)/4, $0x50020021 +DATA avx2Groups<>+260(SB)/4, $0xa0080082 +DATA avx2Groups<>+264(SB)/4, $0x40100205 +DATA avx2Groups<>+268(SB)/4, $0x8020080a +DATA avx2Groups<>+272(SB)/4, $0x00812025 +DATA avx2Groups<>+276(SB)/4, $0x0202808a +DATA avx2Groups<>+280(SB)/4, $0x08080225 +DATA avx2Groups<>+284(SB)/4, $0x1010088a +DATA avx2Groups<>+288(SB)/4, $0x00000002 +DATA avx2Groups<>+292(SB)/4, $0x00000002 +DATA avx2Groups<>+296(SB)/4, $0x00000001 +DATA avx2Groups<>+300(SB)/4, $0x00000001 +DATA avx2Groups<>+304(SB)/4, $0x00000002 +DATA avx2Groups<>+308(SB)/4, $0x00000002 +DATA avx2Groups<>+312(SB)/4, $0x00000002 +DATA avx2Groups<>+316(SB)/4, $0x00000002 +DATA avx2Groups<>+320(SB)/4, $0x00000002 +DATA avx2Groups<>+324(SB)/4, $0x00000002 +DATA avx2Groups<>+328(SB)/4, $0x00000001 +DATA avx2Groups<>+332(SB)/4, $0x00000001 +DATA avx2Groups<>+336(SB)/4, $0x00000002 +DATA avx2Groups<>+340(SB)/4, $0x00000002 +DATA avx2Groups<>+344(SB)/4, $0x00000002 +DATA avx2Groups<>+348(SB)/4, $0x00000002 +DATA avx2Groups<>+352(SB)/4, $0x00000410 +DATA avx2Groups<>+356(SB)/4, $0x00041040 +DATA avx2Groups<>+360(SB)/4, $0x01000000 +DATA avx2Groups<>+364(SB)/4, $0x04000000 +DATA avx2Groups<>+368(SB)/4, $0x00401010 +DATA avx2Groups<>+372(SB)/4, $0x01004040 +DATA avx2Groups<>+376(SB)/4, $0x04040100 +DATA avx2Groups<>+380(SB)/4, $0x00000400 +DATA avx2Groups<>+384(SB)/4, $0x00000010 +DATA avx2Groups<>+388(SB)/4, $0x00000010 +DATA avx2Groups<>+392(SB)/4, $0x00000010 +DATA avx2Groups<>+396(SB)/4, $0x00000010 +DATA avx2Groups<>+400(SB)/4, $0x00000010 +DATA avx2Groups<>+404(SB)/4, $0x00000010 +DATA avx2Groups<>+408(SB)/4, $0x00000010 +DATA avx2Groups<>+412(SB)/4, $0x00000010 +DATA avx2Groups<>+416(SB)/4, $0x00000000 +DATA avx2Groups<>+420(SB)/4, $0x00000000 +DATA avx2Groups<>+424(SB)/4, $0x00000000 +DATA avx2Groups<>+428(SB)/4, $0x00000000 +DATA avx2Groups<>+432(SB)/4, $0x00000000 +DATA avx2Groups<>+436(SB)/4, $0x00000000 +DATA avx2Groups<>+440(SB)/4, $0x00000000 +DATA avx2Groups<>+444(SB)/4, $0x00000000 +DATA avx2Groups<>+448(SB)/4, $0x20202224 +DATA avx2Groups<>+452(SB)/4, $0x40808888 +DATA avx2Groups<>+456(SB)/4, $0x82012220 +DATA avx2Groups<>+460(SB)/4, $0x08028880 +DATA avx2Groups<>+464(SB)/4, $0x10092200 +DATA avx2Groups<>+468(SB)/4, $0x20128800 +DATA avx2Groups<>+472(SB)/4, $0x40282000 +DATA avx2Groups<>+476(SB)/4, $0x80908000 +DATA avx2Groups<>+480(SB)/4, $0x00000002 +DATA avx2Groups<>+484(SB)/4, $0x00000002 +DATA avx2Groups<>+488(SB)/4, $0x00000040 +DATA avx2Groups<>+492(SB)/4, $0x00000040 +DATA avx2Groups<>+496(SB)/4, $0x00000040 +DATA avx2Groups<>+500(SB)/4, $0x00000040 +DATA avx2Groups<>+504(SB)/4, $0x20000000 +DATA avx2Groups<>+508(SB)/4, $0x00000040 +DATA avx2Groups<>+512(SB)/4, $0x00000002 +DATA avx2Groups<>+516(SB)/4, $0x00000002 +DATA avx2Groups<>+520(SB)/4, $0x00000000 +DATA avx2Groups<>+524(SB)/4, $0x00000000 +DATA avx2Groups<>+528(SB)/4, $0x00000000 +DATA avx2Groups<>+532(SB)/4, $0x00000000 +DATA avx2Groups<>+536(SB)/4, $0x00000000 +DATA avx2Groups<>+540(SB)/4, $0x00000000 +DATA avx2Groups<>+544(SB)/4, $0x00400000 +DATA avx2Groups<>+548(SB)/4, $0x01000000 +DATA avx2Groups<>+552(SB)/4, $0x00001100 +DATA avx2Groups<>+556(SB)/4, $0x00004400 +DATA avx2Groups<>+560(SB)/4, $0x00041000 +DATA avx2Groups<>+564(SB)/4, $0x00004000 +DATA avx2Groups<>+568(SB)/4, $0x08000000 +DATA avx2Groups<>+572(SB)/4, $0x00400000 +DATA avx2Groups<>+576(SB)/4, $0x00000000 +DATA avx2Groups<>+580(SB)/4, $0x00000002 +DATA avx2Groups<>+584(SB)/4, $0x00000002 +DATA avx2Groups<>+588(SB)/4, $0x00000002 +DATA avx2Groups<>+592(SB)/4, $0x00000002 +DATA avx2Groups<>+596(SB)/4, $0x00000002 +DATA avx2Groups<>+600(SB)/4, $0x00000002 +DATA avx2Groups<>+604(SB)/4, $0x00000002 +DATA avx2Groups<>+608(SB)/4, $0x00000000 +DATA avx2Groups<>+612(SB)/4, $0x00000000 +DATA avx2Groups<>+616(SB)/4, $0x00000000 +DATA avx2Groups<>+620(SB)/4, $0x00000000 +DATA avx2Groups<>+624(SB)/4, $0x00000000 +DATA avx2Groups<>+628(SB)/4, $0x00000000 +DATA avx2Groups<>+632(SB)/4, $0x00000000 +DATA avx2Groups<>+636(SB)/4, $0x00000000 +DATA avx2Groups<>+640(SB)/4, $0x00000000 +DATA avx2Groups<>+644(SB)/4, $0x00400000 +DATA avx2Groups<>+648(SB)/4, $0x01000010 +DATA avx2Groups<>+652(SB)/4, $0x04000040 +DATA avx2Groups<>+656(SB)/4, $0x00000100 +DATA avx2Groups<>+660(SB)/4, $0x00000400 +DATA avx2Groups<>+664(SB)/4, $0x00041000 +DATA avx2Groups<>+668(SB)/4, $0x00004000 +DATA avx2Groups<>+672(SB)/4, $0x20000000 +DATA avx2Groups<>+676(SB)/4, $0x20000000 +DATA avx2Groups<>+680(SB)/4, $0x20000000 +DATA avx2Groups<>+684(SB)/4, $0x20000000 +DATA avx2Groups<>+688(SB)/4, $0x20000000 +DATA avx2Groups<>+692(SB)/4, $0x20000000 +DATA avx2Groups<>+696(SB)/4, $0x20000000 +DATA avx2Groups<>+700(SB)/4, $0x20000000 +DATA avx2Groups<>+704(SB)/4, $0x00000000 +DATA avx2Groups<>+708(SB)/4, $0x00000000 +DATA avx2Groups<>+712(SB)/4, $0x00000000 +DATA avx2Groups<>+716(SB)/4, $0x00000000 +DATA avx2Groups<>+720(SB)/4, $0x00000000 +DATA avx2Groups<>+724(SB)/4, $0x00000000 +DATA avx2Groups<>+728(SB)/4, $0x00000000 +DATA avx2Groups<>+732(SB)/4, $0x00000000 +DATA avx2Groups<>+736(SB)/4, $0x8a020020 +DATA avx2Groups<>+740(SB)/4, $0x18080080 +DATA avx2Groups<>+744(SB)/4, $0x30110200 +DATA avx2Groups<>+748(SB)/4, $0x60220800 +DATA avx2Groups<>+752(SB)/4, $0xc0882000 +DATA avx2Groups<>+756(SB)/4, $0x82108000 +DATA avx2Groups<>+760(SB)/4, $0x08200000 +DATA avx2Groups<>+764(SB)/4, $0x10800000 +DATA avx2Groups<>+768(SB)/4, $0x00000010 +DATA avx2Groups<>+772(SB)/4, $0x00000010 +DATA avx2Groups<>+776(SB)/4, $0x00000010 +DATA avx2Groups<>+780(SB)/4, $0x00000010 +DATA avx2Groups<>+784(SB)/4, $0x00000010 +DATA avx2Groups<>+788(SB)/4, $0x00000010 +DATA avx2Groups<>+792(SB)/4, $0x00000010 +DATA avx2Groups<>+796(SB)/4, $0x00000002 +DATA avx2Groups<>+800(SB)/4, $0x00000010 +DATA avx2Groups<>+804(SB)/4, $0x00000010 +DATA avx2Groups<>+808(SB)/4, $0x00000010 +DATA avx2Groups<>+812(SB)/4, $0x00000010 +DATA avx2Groups<>+816(SB)/4, $0x00000010 +DATA avx2Groups<>+820(SB)/4, $0x00000010 +DATA avx2Groups<>+824(SB)/4, $0x00000010 +DATA avx2Groups<>+828(SB)/4, $0x00000002 +DATA avx2Groups<>+832(SB)/4, $0x40000005 +DATA avx2Groups<>+836(SB)/4, $0x8000000a +DATA avx2Groups<>+840(SB)/4, $0x00000025 +DATA avx2Groups<>+844(SB)/4, $0x0000008a +DATA avx2Groups<>+848(SB)/4, $0x00000224 +DATA avx2Groups<>+852(SB)/4, $0x00000888 +DATA avx2Groups<>+856(SB)/4, $0x00002220 +DATA avx2Groups<>+860(SB)/4, $0x04000000 +DATA avx2Groups<>+864(SB)/4, $0x00000000 +DATA avx2Groups<>+868(SB)/4, $0x00000000 +DATA avx2Groups<>+872(SB)/4, $0x00000001 +DATA avx2Groups<>+876(SB)/4, $0x00000001 +DATA avx2Groups<>+880(SB)/4, $0x00000001 +DATA avx2Groups<>+884(SB)/4, $0x00000004 +DATA avx2Groups<>+888(SB)/4, $0x00000004 +DATA avx2Groups<>+892(SB)/4, $0x00000004 +DATA avx2Groups<>+896(SB)/4, $0x00000000 +DATA avx2Groups<>+900(SB)/4, $0x00000000 +DATA avx2Groups<>+904(SB)/4, $0x00000001 +DATA avx2Groups<>+908(SB)/4, $0x00000001 +DATA avx2Groups<>+912(SB)/4, $0x00000001 +DATA avx2Groups<>+916(SB)/4, $0x00000004 +DATA avx2Groups<>+920(SB)/4, $0x00000004 +DATA avx2Groups<>+924(SB)/4, $0x00000004 +DATA avx2Groups<>+928(SB)/4, $0x00000000 +DATA avx2Groups<>+932(SB)/4, $0x00000000 +DATA avx2Groups<>+936(SB)/4, $0x00000001 +DATA avx2Groups<>+940(SB)/4, $0x00000002 +DATA avx2Groups<>+944(SB)/4, $0x00010004 +DATA avx2Groups<>+948(SB)/4, $0x00040010 +DATA avx2Groups<>+952(SB)/4, $0x00000040 +DATA avx2Groups<>+956(SB)/4, $0x00000100 +GLOBL avx2Groups<>(SB), RODATA|NOPTR, $960 + +// func prefixAVX2(W *[80]uint32) uint32 +// Requires: AVX, AVX2 +// +// Runs 10 groups of 8 lanes, which leave 0.2568 DVs standing on average. +TEXT ·prefixAVX2(SB), NOSPLIT, $0-12 + MOVQ W+0(FP), AX + VPXOR Y8, Y8, Y8 + VPXOR Y9, Y9, Y9 + VPXOR Y10, Y10, Y10 + VPXOR Y15, Y15, Y15 + + // group 0: W[42+k] vs W[43+k] >> 0 + VMOVDQU 168(AX), Y0 + VMOVDQU 172(AX), Y1 + VPXOR Y1, Y0, Y0 + VPAND avx2Groups<>+0(SB), Y0, Y0 + VPCMPEQD Y15, Y0, Y0 + VPANDN avx2Groups<>+64(SB), Y0, Y0 + VPOR Y0, Y8, Y8 + + // group 1: W[38+k] vs W[40+k] >> 0 + VMOVDQU 152(AX), Y2 + VMOVDQU 160(AX), Y3 + VPXOR Y3, Y2, Y2 + VPAND avx2Groups<>+96(SB), Y2, Y2 + VPCMPEQD avx2Groups<>+128(SB), Y2, Y2 + VPANDN avx2Groups<>+160(SB), Y2, Y2 + VPOR Y2, Y9, Y9 + + // group 2: W[37+k] vs W[40+k] >> 25 + VMOVDQU 148(AX), Y4 + VMOVDQU 160(AX), Y5 + VPSRLD $25, Y5, Y5 + VPXOR Y5, Y4, Y4 + VPAND avx2Groups<>+192(SB), Y4, Y4 + VPCMPEQD Y15, Y4, Y4 + VPANDN avx2Groups<>+256(SB), Y4, Y4 + VPOR Y4, Y10, Y10 + + // group 3: W[35+k] vs W[36+k] >> 5 + VMOVDQU 140(AX), Y6 + VMOVDQU 144(AX), Y7 + VPSRLD $5, Y7, Y7 + VPXOR Y7, Y6, Y6 + VPAND avx2Groups<>+288(SB), Y6, Y6 + VPCMPEQD avx2Groups<>+320(SB), Y6, Y6 + VPANDN avx2Groups<>+352(SB), Y6, Y6 + VPOR Y6, Y8, Y8 + + // group 4: W[45+k] vs W[48+k] >> 25 + VMOVDQU 180(AX), Y0 + VMOVDQU 192(AX), Y1 + VPSRLD $25, Y1, Y1 + VPXOR Y1, Y0, Y0 + VPAND avx2Groups<>+384(SB), Y0, Y0 + VPCMPEQD Y15, Y0, Y0 + VPANDN avx2Groups<>+448(SB), Y0, Y0 + VPOR Y0, Y9, Y9 + + // group 5: W[44+k] vs W[46+k] >> 0 + VMOVDQU 176(AX), Y2 + VMOVDQU 184(AX), Y3 + VPXOR Y3, Y2, Y2 + VPAND avx2Groups<>+480(SB), Y2, Y2 + VPCMPEQD avx2Groups<>+512(SB), Y2, Y2 + VPANDN avx2Groups<>+544(SB), Y2, Y2 + VPOR Y2, Y10, Y10 + + // group 6: W[44+k] vs W[45+k] >> -5 + VMOVDQU 176(AX), Y4 + VMOVDQU 180(AX), Y5 + VPSRLD $5, Y4, Y4 + VPXOR Y5, Y4, Y4 + VPAND avx2Groups<>+576(SB), Y4, Y4 + VPCMPEQD Y15, Y4, Y4 + VPANDN avx2Groups<>+640(SB), Y4, Y4 + VPOR Y4, Y8, Y8 + + // group 7: W[50+k] vs W[51+k] >> 0 + VMOVDQU 200(AX), Y6 + VMOVDQU 204(AX), Y7 + VPXOR Y7, Y6, Y6 + VPAND avx2Groups<>+672(SB), Y6, Y6 + VPCMPEQD Y15, Y6, Y6 + VPANDN avx2Groups<>+736(SB), Y6, Y6 + VPOR Y6, Y9, Y9 + + // group 8: W[39+k] vs W[41+k] >> 0 + VMOVDQU 156(AX), Y0 + VMOVDQU 164(AX), Y1 + VPXOR Y1, Y0, Y0 + VPAND avx2Groups<>+768(SB), Y0, Y0 + VPCMPEQD avx2Groups<>+800(SB), Y0, Y0 + VPANDN avx2Groups<>+832(SB), Y0, Y0 + VPOR Y0, Y10, Y10 + + // group 9: W[56+k] vs W[57+k] >> 5 + VMOVDQU 224(AX), Y2 + VMOVDQU 228(AX), Y3 + VPSRLD $5, Y3, Y3 + VPXOR Y3, Y2, Y2 + VPAND avx2Groups<>+864(SB), Y2, Y2 + VPCMPEQD avx2Groups<>+896(SB), Y2, Y2 + VPANDN avx2Groups<>+928(SB), Y2, Y2 + VPOR Y2, Y8, Y8 + + // OR the accumulators and their lanes together, and the DVs that are + // left are the ones no lane ruled out. + VPOR Y9, Y8, Y8 + VPOR Y10, Y8, Y8 + VEXTRACTI128 $1, Y8, X1 + VPOR X1, X8, X8 + VPSHUFD $0x4e, X8, X1 + VPOR X1, X8, X8 + VPSHUFD $0xb1, X8, X1 + VPOR X1, X8, X8 + VMOVD X8, AX + NOTL AX + VZEROUPPER + MOVL AX, ret+8(FP) + RET diff --git a/vendor/github.com/pjbgf/sha1cd/ubc/dvmask_avx512_amd64.s b/vendor/github.com/pjbgf/sha1cd/ubc/dvmask_avx512_amd64.s deleted file mode 100644 index ef3953243e..0000000000 --- a/vendor/github.com/pjbgf/sha1cd/ubc/dvmask_avx512_amd64.s +++ /dev/null @@ -1,52 +0,0 @@ -//go:build !noasm && gc && amd64 - -#include "textflag.h" - -// func calculateDvMaskAVX512(W *[80]uint32, terms *uint32, groups int) uint32 -// Requires: AVX, AVX512F -// -// Each group of avx512Terms describes 16 of the bit tests of CalculateDvMask, -// as vectors of word indices, shift counts, expected parities and the masks -// that clear the DVs of a failing test. One pass of the loop runs a group. -// -// terms only has to be 64 byte aligned for speed, as otherwise every load of -// it straddles two cache lines. The word indices are biased by 34, matching -// the two vectors of W loaded below. -TEXT ·calculateDvMaskAVX512(SB), NOSPLIT, $0-28 - MOVQ W+0(FP), AX - MOVQ terms+8(FP), BX - MOVQ groups+16(FP), CX - VMOVDQU32 136(AX), Z0 // W[34..49] - VMOVDQU32 200(AX), Z1 // W[50..65] - VPTERNLOGD $0xff, Z2, Z2, Z2 // mask = all ones - MOVL $1, DX - VPBROADCASTD DX, Z3 - -loop: - VMOVDQU32 0(BX), Z4 - VMOVDQU32 64(BX), Z5 - VPERMI2D Z1, Z0, Z4 // W[a] - VPERMI2D Z1, Z0, Z5 // W[b] - VPSRLVD 128(BX), Z4, Z4 // >> ka - VPSRLVD 192(BX), Z5, Z5 // >> kb - VPTERNLOGD $0x96, 256(BX), Z5, Z4 // ^ e - VPTESTMD Z3, Z4, K1 // the terms whose bit test fails - VPANDD 320(BX), Z2, K1, Z2 // clear their DVs - ADDQ $384, BX - DECQ CX - JNZ loop - - // AND the 16 lanes together, first the 128 bit lanes and then the - // words within them. - VSHUFI64X2 $0x4e, Z2, Z2, Z4 - VPANDD Z4, Z2, Z2 - VSHUFI64X2 $0xb1, Z2, Z2, Z4 - VPANDD Z4, Z2, Z2 - VPSHUFD $0x4e, Z2, Z4 - VPANDD Z4, Z2, Z2 - VPSHUFD $0xb1, Z2, Z4 - VPANDD Z4, Z2, Z2 - VMOVD X2, AX - VZEROUPPER - MOVL AX, ret+24(FP) - RET diff --git a/vendor/github.com/pjbgf/sha1cd/ubc/dvmask_avx512_table_amd64.go b/vendor/github.com/pjbgf/sha1cd/ubc/dvmask_avx512_table_amd64.go deleted file mode 100644 index ffa0b0d020..0000000000 --- a/vendor/github.com/pjbgf/sha1cd/ubc/dvmask_avx512_table_amd64.go +++ /dev/null @@ -1,111 +0,0 @@ -//go:build !noasm && gc && amd64 - -package ubc - -// avx512Terms holds the bit tests of CalculateDvMask in the layout the -// AVX-512 kernel consumes, 16 terms per group. Each term says that a set of -// DVs survives only if bit ka of W[a] XOR bit kb of W[b] equals e, and names -// the mask that clears those DVs when it does not. -// -// The six vectors of a group are, in order: a-34, b-34, ka, kb, e, and the -// clear mask. Word indices are biased by 34 because the kernel keeps W[34..65] -// in two registers. A group is 384 bytes, and the kernel runs one per pass. -// -// The terms are those of calculateDvMaskGeneric, which is a port of -// ubc_check.c and has not changed since the collision detection was published -// in 2017. TestAVX512MatchesGeneric holds the two implementations to the same -// results over inputs that reach every DV, so a mistake here is a test -// failure rather than a missed collision. The comment above each group names -// its terms as a.ka^b.kb=e. -var avx512Terms = [960]uint32{ - // terms 0-15 - // 44.29^45.29=0 49.29^50.29=0 48.29^49.29=0 47.4^50.29=0 47.29^48.29=0 46.4^49.29=0 46.29^47.29=0 45.4^48.29=0 - // 45.29^46.29=0 44.4^47.29=0 43.4^46.29=0 43.29^44.29=0 42.4^45.29=0 41.4^44.29=0 40.29^41.29=0 54.29^55.29=0 - 0x0000000a, 0x0000000f, 0x0000000e, 0x0000000d, 0x0000000d, 0x0000000c, 0x0000000c, 0x0000000b, 0x0000000b, 0x0000000a, 0x00000009, 0x00000009, 0x00000008, 0x00000007, 0x00000006, 0x00000014, - 0x0000000b, 0x00000010, 0x0000000f, 0x00000010, 0x0000000e, 0x0000000f, 0x0000000d, 0x0000000e, 0x0000000c, 0x0000000d, 0x0000000c, 0x0000000a, 0x0000000b, 0x0000000a, 0x00000007, 0x00000015, - 0x0000001d, 0x0000001d, 0x0000001d, 0x00000004, 0x0000001d, 0x00000004, 0x0000001d, 0x00000004, 0x0000001d, 0x00000004, 0x00000004, 0x0000001d, 0x00000004, 0x00000004, 0x0000001d, 0x0000001d, - 0x0000001d, 0x0000001d, 0x0000001d, 0x0000001d, 0x0000001d, 0x0000001d, 0x0000001d, 0x0000001d, 0x0000001d, 0x0000001d, 0x0000001d, 0x0000001d, 0x0000001d, 0x0000001d, 0x0000001d, 0x0000001d, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0xfd7c5f7f, 0x3d7efff7, 0x9f5f7ffb, 0x7dfedddf, 0xcfcfdffd, 0xbf7f7777, 0xe7e7f7fe, 0xdfdfdddb, 0xf5f57dff, 0xefeff775, 0xf7f7fdda, 0xff5ed7df, 0xfdfd7f75, 0xff7edfda, 0x7ff5ff5d, 0x3f77dfff, - // terms 16-31 - // 53.29^54.29=0 52.29^53.29=0 50.4^53.29=0 50.29^51.29=0 49.4^52.29=0 48.4^51.29=0 42.29^43.29=0 41.29^42.29=0 - // 40.4^43.29=0 39.4^42.29=0 38.4^41.29=0 37.4^40.29=0 55.29^56.29=0 52.4^55.29=0 51.4^54.29=0 51.29^52.29=0 - 0x00000013, 0x00000012, 0x00000010, 0x00000010, 0x0000000f, 0x0000000e, 0x00000008, 0x00000007, 0x00000006, 0x00000005, 0x00000004, 0x00000003, 0x00000015, 0x00000012, 0x00000011, 0x00000011, - 0x00000014, 0x00000013, 0x00000013, 0x00000011, 0x00000012, 0x00000011, 0x00000009, 0x00000008, 0x00000009, 0x00000008, 0x00000007, 0x00000006, 0x00000016, 0x00000015, 0x00000014, 0x00000012, - 0x0000001d, 0x0000001d, 0x00000004, 0x0000001d, 0x00000004, 0x00000004, 0x0000001d, 0x0000001d, 0x00000004, 0x00000004, 0x00000004, 0x00000004, 0x0000001d, 0x00000004, 0x00000004, 0x0000001d, - 0x0000001d, 0x0000001d, 0x0000001d, 0x0000001d, 0x0000001d, 0x0000001d, 0x0000001d, 0x0000001d, 0x0000001d, 0x0000001d, 0x0000001d, 0x0000001d, 0x0000001d, 0x0000001d, 0x0000001d, 0x0000001d, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x9fddf7ff, 0xcfeefdff, 0xdfed77ff, 0x75fdffdf, 0xeff6ddff, 0xf7fd777f, 0xffcff5f7, 0xffe7fd7b, 0x7fdff7f5, 0xbfeffdfa, 0x5ff7ff7d, 0xaffdffde, 0x7def7fff, 0x7f6f7fff, 0xbfd7dfff, 0xe7f7ff7f, - // terms 32-47 - // 36.4^40.29=0 53.29^56.29=1 51.29^54.29=1 50.29^52.29=1 49.29^51.29=1 48.29^50.29=1 47.29^49.29=1 46.29^48.29=1 - // 45.6^47.6=0 45.29^47.29=1 44.6^46.6=0 44.29^46.29=1 41.1^42.6=1 40.1^41.6=1 40.4^42.4=1 39.1^40.6=1 - 0x00000002, 0x00000013, 0x00000011, 0x00000010, 0x0000000f, 0x0000000e, 0x0000000d, 0x0000000c, 0x0000000b, 0x0000000b, 0x0000000a, 0x0000000a, 0x00000007, 0x00000006, 0x00000006, 0x00000005, - 0x00000006, 0x00000016, 0x00000014, 0x00000012, 0x00000011, 0x00000010, 0x0000000f, 0x0000000e, 0x0000000d, 0x0000000d, 0x0000000c, 0x0000000c, 0x00000008, 0x00000007, 0x00000008, 0x00000006, - 0x00000004, 0x0000001d, 0x0000001d, 0x0000001d, 0x0000001d, 0x0000001d, 0x0000001d, 0x0000001d, 0x00000006, 0x0000001d, 0x00000006, 0x0000001d, 0x00000001, 0x00000001, 0x00000004, 0x00000001, - 0x0000001d, 0x0000001d, 0x0000001d, 0x0000001d, 0x0000001d, 0x0000001d, 0x0000001d, 0x0000001d, 0x00000006, 0x0000001d, 0x00000006, 0x0000001d, 0x00000006, 0x00000006, 0x00000004, 0x00000006, - 0x00000000, 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00000000, 0x00000001, 0x00000000, 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00000001, - 0xffeefdf7, 0xffcf7fff, 0xfff5f7ff, 0xfffeddff, 0xffff777f, 0xffffdddf, 0xfffff777, 0xfffffddb, 0xffffbbbf, 0xffffff75, 0xffffeeef, 0xffffffda, 0xfbfbfeff, 0xfeffbfbf, 0x7ffffff5, 0xffbfefef, - // terms 48-63 - // 39.4^41.4=1 38.4^40.4=1 37.4^39.4=1 36.1^37.6=1 35.4^39.29=0 63.0^64.5=1 63.1^64.6=1 62.0^63.5=1 - // 61.0^62.5=1 61.2^62.7=1 60.0^61.5=1 58.29^59.29=0 57.29^58.29=0 56.4^59.29=0 56.29^59.29=1 56.29^57.29=0 - 0x00000005, 0x00000004, 0x00000003, 0x00000002, 0x00000001, 0x0000001d, 0x0000001d, 0x0000001c, 0x0000001b, 0x0000001b, 0x0000001a, 0x00000018, 0x00000017, 0x00000016, 0x00000016, 0x00000016, - 0x00000007, 0x00000006, 0x00000005, 0x00000003, 0x00000005, 0x0000001e, 0x0000001e, 0x0000001d, 0x0000001c, 0x0000001c, 0x0000001b, 0x00000019, 0x00000018, 0x00000019, 0x00000019, 0x00000017, - 0x00000004, 0x00000004, 0x00000004, 0x00000001, 0x00000004, 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000002, 0x00000000, 0x0000001d, 0x0000001d, 0x00000004, 0x0000001d, 0x0000001d, - 0x00000004, 0x00000004, 0x00000004, 0x00000006, 0x0000001d, 0x00000005, 0x00000006, 0x00000005, 0x00000005, 0x00000007, 0x00000005, 0x0000001d, 0x0000001d, 0x0000001d, 0x0000001d, 0x0000001d, - 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00000000, 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, - 0xbffffffa, 0x5ffffffd, 0xaffffffe, 0xfffbefbf, 0xfff7ff7b, 0xffefff7f, 0xfffefffb, 0xfff7ffdf, 0xfffdfff7, 0xfffbffef, 0xfffefffb, 0xddffffff, 0xef7fffff, 0xd7ffffff, 0xf5ffffff, 0xf7dfffff, - // terms 64-79 - // 55.4^58.29=0 54.4^57.29=0 53.4^56.29=0 50.6^51.1=0 48.6^50.6=0 48.29^55.29=1 47.6^49.6=0 47.6^48.1=0 - // 46.6^48.6=0 46.6^47.1=0 44.1^45.6=1 43.6^45.6=0 42.6^44.6=0 42.6^43.1=0 41.6^42.1=0 40.6^41.1=0 - 0x00000015, 0x00000014, 0x00000013, 0x00000010, 0x0000000e, 0x0000000e, 0x0000000d, 0x0000000d, 0x0000000c, 0x0000000c, 0x0000000a, 0x00000009, 0x00000008, 0x00000008, 0x00000007, 0x00000006, - 0x00000018, 0x00000017, 0x00000016, 0x00000011, 0x00000010, 0x00000015, 0x0000000f, 0x0000000e, 0x0000000e, 0x0000000d, 0x0000000b, 0x0000000b, 0x0000000a, 0x00000009, 0x00000008, 0x00000007, - 0x00000004, 0x00000004, 0x00000004, 0x00000006, 0x00000006, 0x0000001d, 0x00000006, 0x00000006, 0x00000006, 0x00000006, 0x00000001, 0x00000006, 0x00000006, 0x00000006, 0x00000006, 0x00000006, - 0x0000001d, 0x0000001d, 0x0000001d, 0x00000001, 0x00000006, 0x0000001d, 0x00000006, 0x00000001, 0x00000006, 0x00000001, 0x00000006, 0x00000006, 0x00000006, 0x00000001, 0x00000001, 0x00000001, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0xedffffff, 0xf77fffff, 0xfddfffff, 0xfffbefff, 0xfffbefff, 0xffff5fff, 0xffffbbff, 0xfbffffbf, 0xffffeeff, 0xfeffffef, 0xffbfbfff, 0xfffffbbf, 0xfffffeef, 0xfbfbffff, 0xfeffbfff, 0xffbfefff, - // terms 80-95 - // 39.4^43.29=0 38.4^42.29=0 37.1^38.6=1 37.4^41.29=0 36.4^38.4=1 35.1^36.6=1 35.3^39.28=0 61.1^62.6=1 - // 59.5^63.30=0 58.0^63.30=1 62.1^63.6=1 60.5^64.30=0 59.0^64.30=1 40.6^42.6=0 62.2^63.7=1 41.6^43.6=0 - 0x00000005, 0x00000004, 0x00000003, 0x00000003, 0x00000002, 0x00000001, 0x00000001, 0x0000001b, 0x00000019, 0x00000018, 0x0000001c, 0x0000001a, 0x00000019, 0x00000006, 0x0000001c, 0x00000007, - 0x00000009, 0x00000008, 0x00000004, 0x00000007, 0x00000004, 0x00000002, 0x00000005, 0x0000001c, 0x0000001d, 0x0000001d, 0x0000001d, 0x0000001e, 0x0000001e, 0x00000008, 0x0000001d, 0x00000009, - 0x00000004, 0x00000004, 0x00000001, 0x00000004, 0x00000004, 0x00000001, 0x00000003, 0x00000001, 0x00000005, 0x00000000, 0x00000001, 0x00000005, 0x00000000, 0x00000006, 0x00000002, 0x00000006, - 0x0000001d, 0x0000001d, 0x00000006, 0x0000001d, 0x00000004, 0x00000006, 0x0000001c, 0x00000006, 0x0000001e, 0x0000001e, 0x00000006, 0x0000001e, 0x0000001e, 0x00000006, 0x00000007, 0x00000006, - 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000001, 0x00000001, 0x00000000, 0x00000001, 0x00000000, 0x00000001, 0x00000001, 0x00000000, 0x00000001, 0x00000000, 0x00000001, 0x00000000, - 0xfdff7fff, 0xff7fdfff, 0xffffbeff, 0xffdff7ff, 0xd7ffffff, 0xfffffbef, 0xfff7dfff, 0xfffffffe, 0xfffffffe, 0xfffffffe, 0xfffffffd, 0xfffffffd, 0xfffffffd, 0xffffffef, 0xffffffbf, 0xffffffbf, - // terms 96-111 - // 63.2^64.7=1 48.6^49.1=0 49.6^50.1=0 42.1^50.1=1 39.6^40.1=0 38.1^40.1=1 36.4^37.4=1 43.1^51.1=1 - // 37.4^38.4=1 51.6^52.1=0 49.6^51.6=0 37.1^37.6=0 35.5^39.30=0 38.4^39.4=1 47.1^51.1=1 36.3^40.28=0 - 0x0000001d, 0x0000000e, 0x0000000f, 0x00000008, 0x00000005, 0x00000004, 0x00000002, 0x00000009, 0x00000003, 0x00000011, 0x0000000f, 0x00000003, 0x00000001, 0x00000004, 0x0000000d, 0x00000002, - 0x0000001e, 0x0000000f, 0x00000010, 0x00000010, 0x00000006, 0x00000006, 0x00000003, 0x00000011, 0x00000004, 0x00000012, 0x00000011, 0x00000003, 0x00000005, 0x00000005, 0x00000011, 0x00000006, - 0x00000002, 0x00000006, 0x00000006, 0x00000001, 0x00000006, 0x00000001, 0x00000004, 0x00000001, 0x00000004, 0x00000006, 0x00000006, 0x00000001, 0x00000005, 0x00000004, 0x00000001, 0x00000003, - 0x00000007, 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00000004, 0x00000001, 0x00000004, 0x00000001, 0x00000006, 0x00000006, 0x0000001e, 0x00000004, 0x00000001, 0x0000001c, - 0x00000001, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x00000000, - 0xfffffeff, 0xfffffeff, 0xfffffbff, 0xfffffbff, 0xfffffbff, 0xfffffbff, 0xfffff7ff, 0xffffefff, 0xffffdfff, 0xffffbfff, 0xffffbfff, 0xffffbfff, 0xffffbfff, 0xffff7fff, 0xfffbffff, 0xffefffff, - // terms 112-127 - // 35.30^40.28=1 37.3^41.28=0 36.30^41.28=1 53.6^54.1=0 51.6^53.6=0 50.1^54.1=1 45.6^46.1=0 37.5^41.30=0 - // 36.0^41.30=1 55.29^58.29=1 38.3^42.28=0 37.30^42.28=1 54.6^55.1=0 52.6^54.6=0 51.1^55.1=1 45.1^47.1=1 - 0x00000001, 0x00000003, 0x00000002, 0x00000013, 0x00000011, 0x00000010, 0x0000000b, 0x00000003, 0x00000002, 0x00000015, 0x00000004, 0x00000003, 0x00000014, 0x00000012, 0x00000011, 0x0000000b, - 0x00000006, 0x00000007, 0x00000007, 0x00000014, 0x00000013, 0x00000014, 0x0000000c, 0x00000007, 0x00000007, 0x00000018, 0x00000008, 0x00000008, 0x00000015, 0x00000014, 0x00000015, 0x0000000d, - 0x0000001e, 0x00000003, 0x0000001e, 0x00000006, 0x00000006, 0x00000001, 0x00000006, 0x00000005, 0x00000000, 0x0000001d, 0x00000003, 0x0000001e, 0x00000006, 0x00000006, 0x00000001, 0x00000001, - 0x0000001c, 0x0000001c, 0x0000001c, 0x00000001, 0x00000006, 0x00000001, 0x00000001, 0x0000001e, 0x0000001e, 0x0000001d, 0x0000001c, 0x0000001c, 0x00000001, 0x00000006, 0x00000001, 0x00000001, - 0x00000001, 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000001, 0x00000001, - 0xffefffff, 0xffdfffff, 0xffdfffff, 0xffbfffff, 0xffbfffff, 0xffbfffff, 0xffbfffff, 0xffbfffff, 0xffbfffff, 0xff7fffff, 0xff7fffff, 0xff7fffff, 0xfeffffff, 0xfeffffff, 0xfeffffff, 0xfeffffff, - // terms 128-143 - // 38.5^42.30=0 37.0^42.30=1 39.3^43.28=0 38.30^43.28=1 55.6^56.1=0 53.6^55.6=0 52.1^56.1=1 46.1^48.1=1 - // 39.5^43.30=0 38.0^43.30=1 59.29^60.29=0 40.3^44.28=0 40.4^44.29=0 39.30^44.28=1 58.29^61.29=1 57.4^61.29=0 - 0x00000004, 0x00000003, 0x00000005, 0x00000004, 0x00000015, 0x00000013, 0x00000012, 0x0000000c, 0x00000005, 0x00000004, 0x00000019, 0x00000006, 0x00000006, 0x00000005, 0x00000018, 0x00000017, - 0x00000008, 0x00000008, 0x00000009, 0x00000009, 0x00000016, 0x00000015, 0x00000016, 0x0000000e, 0x00000009, 0x00000009, 0x0000001a, 0x0000000a, 0x0000000a, 0x0000000a, 0x0000001b, 0x0000001b, - 0x00000005, 0x00000000, 0x00000003, 0x0000001e, 0x00000006, 0x00000006, 0x00000001, 0x00000001, 0x00000005, 0x00000000, 0x0000001d, 0x00000003, 0x00000004, 0x0000001e, 0x0000001d, 0x00000004, - 0x0000001e, 0x0000001e, 0x0000001c, 0x0000001c, 0x00000001, 0x00000006, 0x00000001, 0x00000001, 0x0000001e, 0x0000001e, 0x0000001d, 0x0000001c, 0x0000001d, 0x0000001c, 0x0000001d, 0x0000001d, - 0x00000000, 0x00000001, 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x00000000, - 0xfeffffff, 0xfeffffff, 0xfdffffff, 0xfdffffff, 0xfbffffff, 0xfbffffff, 0xfbffffff, 0xfbffffff, 0xfbffffff, 0xfbffffff, 0xf7ffffff, 0xf7ffffff, 0xf7ffffff, 0xf7ffffff, 0xefffffff, 0xefffffff, - // terms 144-159 - // 41.3^45.28=0 41.4^45.29=0 58.4^62.29=0 42.3^46.28=0 42.4^46.29=0 59.4^63.29=0 57.4^59.29=0 43.3^47.28=0 - // 43.4^47.29=0 60.4^64.29=0 44.3^48.28=0 44.4^48.29=0 35.0^35.0=0 35.0^35.0=0 35.0^35.0=0 35.0^35.0=0 - 0x00000007, 0x00000007, 0x00000018, 0x00000008, 0x00000008, 0x00000019, 0x00000017, 0x00000009, 0x00000009, 0x0000001a, 0x0000000a, 0x0000000a, 0x00000001, 0x00000001, 0x00000001, 0x00000001, - 0x0000000b, 0x0000000b, 0x0000001c, 0x0000000c, 0x0000000c, 0x0000001d, 0x00000019, 0x0000000d, 0x0000000d, 0x0000001e, 0x0000000e, 0x0000000e, 0x00000001, 0x00000001, 0x00000001, 0x00000001, - 0x00000003, 0x00000004, 0x00000004, 0x00000003, 0x00000004, 0x00000004, 0x00000004, 0x00000003, 0x00000004, 0x00000004, 0x00000003, 0x00000004, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x0000001c, 0x0000001d, 0x0000001d, 0x0000001c, 0x0000001d, 0x0000001d, 0x0000001d, 0x0000001c, 0x0000001d, 0x0000001d, 0x0000001c, 0x0000001d, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0xefffffff, 0xefffffff, 0xdfffffff, 0xdfffffff, 0xdfffffff, 0xbfffffff, 0xbfffffff, 0xbfffffff, 0xbfffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, -} diff --git a/vendor/github.com/pjbgf/sha1cd/ubc/dvmask_neon_arm64.s b/vendor/github.com/pjbgf/sha1cd/ubc/dvmask_neon_arm64.s new file mode 100644 index 0000000000..382ed2e8db --- /dev/null +++ b/vendor/github.com/pjbgf/sha1cd/ubc/dvmask_neon_arm64.s @@ -0,0 +1,365 @@ +// Code generated by internal/ubcgen. DO NOT EDIT. + +//go:build !noasm && gc && arm64 + +#include "textflag.h" + +DATA neonGroups<>+0(SB)/4, $0x20000000 +DATA neonGroups<>+4(SB)/4, $0x20000000 +DATA neonGroups<>+8(SB)/4, $0x20000000 +DATA neonGroups<>+12(SB)/4, $0x20000000 +DATA neonGroups<>+16(SB)/4, $0x00000000 +DATA neonGroups<>+20(SB)/4, $0x00000000 +DATA neonGroups<>+24(SB)/4, $0x00000000 +DATA neonGroups<>+28(SB)/4, $0x00000000 +DATA neonGroups<>+32(SB)/4, $0x0283a080 +DATA neonGroups<>+36(SB)/4, $0x0a0a8200 +DATA neonGroups<>+40(SB)/4, $0x18180801 +DATA neonGroups<>+44(SB)/4, $0x30302002 +DATA neonGroups<>+48(SB)/4, $0x00000010 +DATA neonGroups<>+52(SB)/4, $0x00000010 +DATA neonGroups<>+56(SB)/4, $0x00000010 +DATA neonGroups<>+60(SB)/4, $0x00000010 +DATA neonGroups<>+64(SB)/4, $0x00000000 +DATA neonGroups<>+68(SB)/4, $0x00000000 +DATA neonGroups<>+72(SB)/4, $0x00000000 +DATA neonGroups<>+76(SB)/4, $0x00000000 +DATA neonGroups<>+80(SB)/4, $0x1010088a +DATA neonGroups<>+84(SB)/4, $0x20202224 +DATA neonGroups<>+88(SB)/4, $0x40808888 +DATA neonGroups<>+92(SB)/4, $0x82012220 +DATA neonGroups<>+96(SB)/4, $0x00000002 +DATA neonGroups<>+100(SB)/4, $0x00000002 +DATA neonGroups<>+104(SB)/4, $0x00000002 +DATA neonGroups<>+108(SB)/4, $0x00000002 +DATA neonGroups<>+112(SB)/4, $0x00000002 +DATA neonGroups<>+116(SB)/4, $0x00000002 +DATA neonGroups<>+120(SB)/4, $0x00000002 +DATA neonGroups<>+124(SB)/4, $0x00000002 +DATA neonGroups<>+128(SB)/4, $0x00401010 +DATA neonGroups<>+132(SB)/4, $0x01004040 +DATA neonGroups<>+136(SB)/4, $0x04040100 +DATA neonGroups<>+140(SB)/4, $0x00000400 +DATA neonGroups<>+144(SB)/4, $0x00000010 +DATA neonGroups<>+148(SB)/4, $0x00000010 +DATA neonGroups<>+152(SB)/4, $0x00000010 +DATA neonGroups<>+156(SB)/4, $0x00000010 +DATA neonGroups<>+160(SB)/4, $0x00000000 +DATA neonGroups<>+164(SB)/4, $0x00000000 +DATA neonGroups<>+168(SB)/4, $0x00000000 +DATA neonGroups<>+172(SB)/4, $0x00000000 +DATA neonGroups<>+176(SB)/4, $0xa0080082 +DATA neonGroups<>+180(SB)/4, $0x40100205 +DATA neonGroups<>+184(SB)/4, $0x8020080a +DATA neonGroups<>+188(SB)/4, $0x00812025 +DATA neonGroups<>+192(SB)/4, $0x00000002 +DATA neonGroups<>+196(SB)/4, $0x00000002 +DATA neonGroups<>+200(SB)/4, $0x00000002 +DATA neonGroups<>+204(SB)/4, $0x00000001 +DATA neonGroups<>+208(SB)/4, $0x00000002 +DATA neonGroups<>+212(SB)/4, $0x00000002 +DATA neonGroups<>+216(SB)/4, $0x00000002 +DATA neonGroups<>+220(SB)/4, $0x00000001 +DATA neonGroups<>+224(SB)/4, $0x00000410 +DATA neonGroups<>+228(SB)/4, $0x00041040 +DATA neonGroups<>+232(SB)/4, $0x00004100 +DATA neonGroups<>+236(SB)/4, $0x04000000 +DATA neonGroups<>+240(SB)/4, $0x20000000 +DATA neonGroups<>+244(SB)/4, $0x20000000 +DATA neonGroups<>+248(SB)/4, $0x20000000 +DATA neonGroups<>+252(SB)/4, $0x20000000 +DATA neonGroups<>+256(SB)/4, $0x00000000 +DATA neonGroups<>+260(SB)/4, $0x00000000 +DATA neonGroups<>+264(SB)/4, $0x00000000 +DATA neonGroups<>+268(SB)/4, $0x00000000 +DATA neonGroups<>+272(SB)/4, $0x60a08004 +DATA neonGroups<>+276(SB)/4, $0xc2810008 +DATA neonGroups<>+280(SB)/4, $0x8a020020 +DATA neonGroups<>+284(SB)/4, $0x18080080 +DATA neonGroups<>+288(SB)/4, $0x00000002 +DATA neonGroups<>+292(SB)/4, $0x00000002 +DATA neonGroups<>+296(SB)/4, $0x00000002 +DATA neonGroups<>+300(SB)/4, $0x00000040 +DATA neonGroups<>+304(SB)/4, $0x00000002 +DATA neonGroups<>+308(SB)/4, $0x00000002 +DATA neonGroups<>+312(SB)/4, $0x00000002 +DATA neonGroups<>+316(SB)/4, $0x00000000 +DATA neonGroups<>+320(SB)/4, $0x00401000 +DATA neonGroups<>+324(SB)/4, $0x01004000 +DATA neonGroups<>+328(SB)/4, $0x04040000 +DATA neonGroups<>+332(SB)/4, $0x00000110 +DATA neonGroups<>+336(SB)/4, $0x20000000 +DATA neonGroups<>+340(SB)/4, $0x00000040 +DATA neonGroups<>+344(SB)/4, $0x00000040 +DATA neonGroups<>+348(SB)/4, $0x00000040 +DATA neonGroups<>+352(SB)/4, $0x20000000 +DATA neonGroups<>+356(SB)/4, $0x00000000 +DATA neonGroups<>+360(SB)/4, $0x00000000 +DATA neonGroups<>+364(SB)/4, $0x00000000 +DATA neonGroups<>+368(SB)/4, $0x00000005 +DATA neonGroups<>+372(SB)/4, $0x00000440 +DATA neonGroups<>+376(SB)/4, $0x00001110 +DATA neonGroups<>+380(SB)/4, $0x00004440 +DATA neonGroups<>+384(SB)/4, $0x20000000 +DATA neonGroups<>+388(SB)/4, $0x20000000 +DATA neonGroups<>+392(SB)/4, $0x20000000 +DATA neonGroups<>+396(SB)/4, $0x20000000 +DATA neonGroups<>+400(SB)/4, $0x00000000 +DATA neonGroups<>+404(SB)/4, $0x00000000 +DATA neonGroups<>+408(SB)/4, $0x00000000 +DATA neonGroups<>+412(SB)/4, $0x00000000 +DATA neonGroups<>+416(SB)/4, $0x800a00a2 +DATA neonGroups<>+420(SB)/4, $0x00180284 +DATA neonGroups<>+424(SB)/4, $0x00300a08 +DATA neonGroups<>+428(SB)/4, $0x00a12820 +DATA neonGroups<>+432(SB)/4, $0x00000002 +DATA neonGroups<>+436(SB)/4, $0x00000002 +DATA neonGroups<>+440(SB)/4, $0x00000002 +DATA neonGroups<>+444(SB)/4, $0x00000002 +DATA neonGroups<>+448(SB)/4, $0x00000000 +DATA neonGroups<>+452(SB)/4, $0x00000000 +DATA neonGroups<>+456(SB)/4, $0x00000000 +DATA neonGroups<>+460(SB)/4, $0x00000000 +DATA neonGroups<>+464(SB)/4, $0x00400000 +DATA neonGroups<>+468(SB)/4, $0x01000010 +DATA neonGroups<>+472(SB)/4, $0x04000040 +DATA neonGroups<>+476(SB)/4, $0x00000100 +DATA neonGroups<>+480(SB)/4, $0x00000010 +DATA neonGroups<>+484(SB)/4, $0x00000010 +DATA neonGroups<>+488(SB)/4, $0x00000010 +DATA neonGroups<>+492(SB)/4, $0x00000010 +DATA neonGroups<>+496(SB)/4, $0x00000000 +DATA neonGroups<>+500(SB)/4, $0x00000000 +DATA neonGroups<>+504(SB)/4, $0x00000000 +DATA neonGroups<>+508(SB)/4, $0x00000000 +DATA neonGroups<>+512(SB)/4, $0x08028880 +DATA neonGroups<>+516(SB)/4, $0x10092200 +DATA neonGroups<>+520(SB)/4, $0x20128800 +DATA neonGroups<>+524(SB)/4, $0x40282000 +DATA neonGroups<>+528(SB)/4, $0x00000002 +DATA neonGroups<>+532(SB)/4, $0x00000002 +DATA neonGroups<>+536(SB)/4, $0x00000002 +DATA neonGroups<>+540(SB)/4, $0x00000002 +DATA neonGroups<>+544(SB)/4, $0x00000002 +DATA neonGroups<>+548(SB)/4, $0x00000002 +DATA neonGroups<>+552(SB)/4, $0x00000002 +DATA neonGroups<>+556(SB)/4, $0x00000002 +DATA neonGroups<>+560(SB)/4, $0x00404000 +DATA neonGroups<>+564(SB)/4, $0x01000000 +DATA neonGroups<>+568(SB)/4, $0x04000000 +DATA neonGroups<>+572(SB)/4, $0x00040000 +DATA neonGroups<>+576(SB)/4, $0x20000000 +DATA neonGroups<>+580(SB)/4, $0x20000000 +DATA neonGroups<>+584(SB)/4, $0x00000040 +DATA neonGroups<>+588(SB)/4, $0x00000040 +DATA neonGroups<>+592(SB)/4, $0x20000000 +DATA neonGroups<>+596(SB)/4, $0x20000000 +DATA neonGroups<>+600(SB)/4, $0x00000000 +DATA neonGroups<>+604(SB)/4, $0x00000000 +DATA neonGroups<>+608(SB)/4, $0x00000025 +DATA neonGroups<>+612(SB)/4, $0x0000008a +DATA neonGroups<>+616(SB)/4, $0x00001100 +DATA neonGroups<>+620(SB)/4, $0x00004400 +DATA neonGroups<>+624(SB)/4, $0x20000000 +DATA neonGroups<>+628(SB)/4, $0x20000000 +DATA neonGroups<>+632(SB)/4, $0x20000000 +DATA neonGroups<>+636(SB)/4, $0x20000000 +DATA neonGroups<>+640(SB)/4, $0x00000000 +DATA neonGroups<>+644(SB)/4, $0x00000000 +DATA neonGroups<>+648(SB)/4, $0x00000000 +DATA neonGroups<>+652(SB)/4, $0x00000000 +DATA neonGroups<>+656(SB)/4, $0x30110200 +DATA neonGroups<>+660(SB)/4, $0x60220800 +DATA neonGroups<>+664(SB)/4, $0xc0882000 +DATA neonGroups<>+668(SB)/4, $0x82108000 +GLOBL neonGroups<>(SB), RODATA|NOPTR, $672 + +// func prefixNEON(W *[80]uint32) uint32 +// +// Runs 14 groups of 4 lanes, which leave 0.5840 DVs standing on average. +TEXT ·prefixNEON(SB), NOSPLIT, $0-12 + MOVD W+0(FP), R0 + MOVD $neonGroups<>(SB), R2 + VEOR V8.B16, V8.B16, V8.B16 + VEOR V9.B16, V9.B16, V9.B16 + VEOR V10.B16, V10.B16, V10.B16 + + // group 0: W[44+k] vs W[45+k] >> 0 + VLD1.P 48(R2), [V2.S4, V3.S4, V4.S4] + ADD $176, R0, R3 + VLD1 (R3), [V0.S4] + ADD $180, R0, R3 + VLD1 (R3), [V1.S4] + VEOR V1.B16, V0.B16, V0.B16 + VCMTST V2.S4, V0.S4, V0.S4 + VAND V4.B16, V0.B16, V0.B16 + VORR V0.B16, V8.B16, V8.B16 + + // group 1: W[44+k] vs W[47+k] >> 25 + VLD1.P 48(R2), [V2.S4, V3.S4, V4.S4] + ADD $176, R0, R3 + VLD1 (R3), [V0.S4] + ADD $188, R0, R3 + VLD1 (R3), [V1.S4] + VUSHR $25, V1.S4, V1.S4 + VEOR V1.B16, V0.B16, V0.B16 + VCMTST V2.S4, V0.S4, V0.S4 + VAND V4.B16, V0.B16, V0.B16 + VORR V0.B16, V9.B16, V9.B16 + + // group 2: W[39+k] vs W[40+k] >> 5 + VLD1.P 48(R2), [V2.S4, V3.S4, V4.S4] + ADD $156, R0, R3 + VLD1 (R3), [V0.S4] + ADD $160, R0, R3 + VLD1 (R3), [V1.S4] + VUSHR $5, V1.S4, V1.S4 + VEOR V1.B16, V0.B16, V0.B16 + VEOR V3.B16, V0.B16, V0.B16 + VCMTST V2.S4, V0.S4, V0.S4 + VAND V4.B16, V0.B16, V0.B16 + VORR V0.B16, V10.B16, V10.B16 + + // group 3: W[38+k] vs W[41+k] >> 25 + VLD1.P 48(R2), [V2.S4, V3.S4, V4.S4] + ADD $152, R0, R3 + VLD1 (R3), [V0.S4] + ADD $164, R0, R3 + VLD1 (R3), [V1.S4] + VUSHR $25, V1.S4, V1.S4 + VEOR V1.B16, V0.B16, V0.B16 + VCMTST V2.S4, V0.S4, V0.S4 + VAND V4.B16, V0.B16, V0.B16 + VORR V0.B16, V8.B16, V8.B16 + + // group 4: W[35+k] vs W[36+k] >> 5 + VLD1.P 48(R2), [V2.S4, V3.S4, V4.S4] + ADD $140, R0, R3 + VLD1 (R3), [V0.S4] + ADD $144, R0, R3 + VLD1 (R3), [V1.S4] + VUSHR $5, V1.S4, V1.S4 + VEOR V1.B16, V0.B16, V0.B16 + VEOR V3.B16, V0.B16, V0.B16 + VCMTST V2.S4, V0.S4, V0.S4 + VAND V4.B16, V0.B16, V0.B16 + VORR V0.B16, V9.B16, V9.B16 + + // group 5: W[48+k] vs W[49+k] >> 0 + VLD1.P 48(R2), [V2.S4, V3.S4, V4.S4] + ADD $192, R0, R3 + VLD1 (R3), [V0.S4] + ADD $196, R0, R3 + VLD1 (R3), [V1.S4] + VEOR V1.B16, V0.B16, V0.B16 + VCMTST V2.S4, V0.S4, V0.S4 + VAND V4.B16, V0.B16, V0.B16 + VORR V0.B16, V10.B16, V10.B16 + + // group 6: W[39+k] vs W[41+k] >> 0 + VLD1.P 48(R2), [V2.S4, V3.S4, V4.S4] + ADD $156, R0, R3 + VLD1 (R3), [V0.S4] + ADD $164, R0, R3 + VLD1 (R3), [V1.S4] + VEOR V1.B16, V0.B16, V0.B16 + VEOR V3.B16, V0.B16, V0.B16 + VCMTST V2.S4, V0.S4, V0.S4 + VAND V4.B16, V0.B16, V0.B16 + VORR V0.B16, V8.B16, V8.B16 + + // group 7: W[42+k] vs W[44+k] >> 0 + VLD1.P 48(R2), [V2.S4, V3.S4, V4.S4] + ADD $168, R0, R3 + VLD1 (R3), [V0.S4] + ADD $176, R0, R3 + VLD1 (R3), [V1.S4] + VEOR V1.B16, V0.B16, V0.B16 + VEOR V3.B16, V0.B16, V0.B16 + VCMTST V2.S4, V0.S4, V0.S4 + VAND V4.B16, V0.B16, V0.B16 + VORR V0.B16, V9.B16, V9.B16 + + // group 8: W[40+k] vs W[41+k] >> 0 + VLD1.P 48(R2), [V2.S4, V3.S4, V4.S4] + ADD $160, R0, R3 + VLD1 (R3), [V0.S4] + ADD $164, R0, R3 + VLD1 (R3), [V1.S4] + VEOR V1.B16, V0.B16, V0.B16 + VCMTST V2.S4, V0.S4, V0.S4 + VAND V4.B16, V0.B16, V0.B16 + VORR V0.B16, V10.B16, V10.B16 + + // group 9: W[45+k] vs W[46+k] >> -5 + VLD1.P 48(R2), [V2.S4, V3.S4, V4.S4] + ADD $180, R0, R3 + VLD1 (R3), [V0.S4] + ADD $184, R0, R3 + VLD1 (R3), [V1.S4] + VUSHR $5, V0.S4, V0.S4 + VEOR V1.B16, V0.B16, V0.B16 + VCMTST V2.S4, V0.S4, V0.S4 + VAND V4.B16, V0.B16, V0.B16 + VORR V0.B16, V8.B16, V8.B16 + + // group 10: W[48+k] vs W[51+k] >> 25 + VLD1.P 48(R2), [V2.S4, V3.S4, V4.S4] + ADD $192, R0, R3 + VLD1 (R3), [V0.S4] + ADD $204, R0, R3 + VLD1 (R3), [V1.S4] + VUSHR $25, V1.S4, V1.S4 + VEOR V1.B16, V0.B16, V0.B16 + VCMTST V2.S4, V0.S4, V0.S4 + VAND V4.B16, V0.B16, V0.B16 + VORR V0.B16, V9.B16, V9.B16 + + // group 11: W[44+k] vs W[45+k] >> 5 + VLD1.P 48(R2), [V2.S4, V3.S4, V4.S4] + ADD $176, R0, R3 + VLD1 (R3), [V0.S4] + ADD $180, R0, R3 + VLD1 (R3), [V1.S4] + VUSHR $5, V1.S4, V1.S4 + VEOR V1.B16, V0.B16, V0.B16 + VEOR V3.B16, V0.B16, V0.B16 + VCMTST V2.S4, V0.S4, V0.S4 + VAND V4.B16, V0.B16, V0.B16 + VORR V0.B16, V10.B16, V10.B16 + + // group 12: W[44+k] vs W[46+k] >> 0 + VLD1.P 48(R2), [V2.S4, V3.S4, V4.S4] + ADD $176, R0, R3 + VLD1 (R3), [V0.S4] + ADD $184, R0, R3 + VLD1 (R3), [V1.S4] + VEOR V1.B16, V0.B16, V0.B16 + VEOR V3.B16, V0.B16, V0.B16 + VCMTST V2.S4, V0.S4, V0.S4 + VAND V4.B16, V0.B16, V0.B16 + VORR V0.B16, V8.B16, V8.B16 + + // group 13: W[52+k] vs W[53+k] >> 0 + VLD1.P 48(R2), [V2.S4, V3.S4, V4.S4] + ADD $208, R0, R3 + VLD1 (R3), [V0.S4] + ADD $212, R0, R3 + VLD1 (R3), [V1.S4] + VEOR V1.B16, V0.B16, V0.B16 + VCMTST V2.S4, V0.S4, V0.S4 + VAND V4.B16, V0.B16, V0.B16 + VORR V0.B16, V9.B16, V9.B16 + + // OR the accumulators and their lanes together, and the DVs that are + // left are the ones no lane ruled out. + VORR V9.B16, V8.B16, V8.B16 + VORR V10.B16, V8.B16, V8.B16 + VMOV V8.D[0], R4 + VMOV V8.D[1], R5 + ORR R5, R4, R4 + LSR $32, R4, R5 + ORRW R5, R4, R4 + MVNW R4, R4 + MOVW R4, ret+8(FP) + RET diff --git a/vendor/github.com/pjbgf/sha1cd/ubc/dvmask_other.go b/vendor/github.com/pjbgf/sha1cd/ubc/dvmask_other.go index b76282b245..d5fc61f6c2 100644 --- a/vendor/github.com/pjbgf/sha1cd/ubc/dvmask_other.go +++ b/vendor/github.com/pjbgf/sha1cd/ubc/dvmask_other.go @@ -1,4 +1,4 @@ -//go:build noasm || !gc || !amd64 +//go:build noasm || !gc || !(amd64 || arm64) package ubc diff --git a/vendor/github.com/pjbgf/sha1cd/ubc/tail.go b/vendor/github.com/pjbgf/sha1cd/ubc/tail.go new file mode 100644 index 0000000000..413d40198e --- /dev/null +++ b/vendor/github.com/pjbgf/sha1cd/ubc/tail.go @@ -0,0 +1,45 @@ +package ubc + +import "math/bits" + +//go:generate go run ../internal/ubcgen -out . + +// tailCheck says that bit a of W[i] XOR bit b of W[j] must equal c. +type tailCheck struct { + i, a, j, b, c uint8 +} + +// tailSpan locates the checks of one DV in a tailChecks table. +type tailSpan struct { + start uint16 + n uint8 +} + +// tail rules out, among the DVs in mask, those for which one of their checks +// fails. Each form's prefix leaves few DVs standing, so the tail visits only +// the checks that belong to them. Together with the prefix the checks span +// each DV's unavoidable bit conditions, so the result is exactly the mask the +// full set of conditions gives. +func tail(W *[80]uint32, mask uint32, checks []tailCheck, spans *[32]tailSpan) uint32 { + out := mask + for rest := mask; rest != 0; rest &= rest - 1 { + dv := bits.TrailingZeros32(rest) + s := spans[dv] + for _, c := range checks[s.start : int(s.start)+int(s.n)] { + if (W[c.i]>>c.a^W[c.j]>>c.b)&1 != uint32(c.c) { + out &^= 1 << dv + break + } + } + } + return out +} + +// calculateDvMaskGeneric is the portable implementation of CalculateDvMask. +func calculateDvMaskGeneric(W *[80]uint32) uint32 { + mask := prefixScalar(W) + if mask == 0 { + return 0 + } + return tail(W, mask, tailChecksScalar[:], &tailSpansScalar) +} diff --git a/vendor/github.com/pjbgf/sha1cd/ubc/ubc.go b/vendor/github.com/pjbgf/sha1cd/ubc/ubc.go index 40447b0e48..5c95eaae70 100644 --- a/vendor/github.com/pjbgf/sha1cd/ubc/ubc.go +++ b/vendor/github.com/pjbgf/sha1cd/ubc/ubc.go @@ -23,349 +23,6 @@ type DvInfo struct { Dm [80]uint32 } -// calculateDvMaskGeneric is the portable implementation of CalculateDvMask. -// The AVX-512 kernel runs the same bit tests from avx512Terms, and -// TestAVX512MatchesGeneric holds the two to the same results. -// -//go:nosplit -func calculateDvMaskGeneric(W *[80]uint32) uint32 { - mask := uint32(0xFFFFFFFF) - mask &= (((((W[44] ^ W[45]) >> 29) & 1) - 1) | ^(DV_I_48_0_bit | DV_I_51_0_bit | DV_I_52_0_bit | DV_II_45_0_bit | DV_II_46_0_bit | DV_II_50_0_bit | DV_II_51_0_bit)) - mask &= (((((W[49] ^ W[50]) >> 29) & 1) - 1) | ^(DV_I_46_0_bit | DV_II_45_0_bit | DV_II_50_0_bit | DV_II_51_0_bit | DV_II_55_0_bit | DV_II_56_0_bit)) - mask &= (((((W[48] ^ W[49]) >> 29) & 1) - 1) | ^(DV_I_45_0_bit | DV_I_52_0_bit | DV_II_49_0_bit | DV_II_50_0_bit | DV_II_54_0_bit | DV_II_55_0_bit)) - mask &= ((((W[47] ^ (W[50] >> 25)) & (1 << 4)) - (1 << 4)) | ^(DV_I_47_0_bit | DV_I_49_0_bit | DV_I_51_0_bit | DV_II_45_0_bit | DV_II_51_0_bit | DV_II_56_0_bit)) - mask &= (((((W[47] ^ W[48]) >> 29) & 1) - 1) | ^(DV_I_44_0_bit | DV_I_51_0_bit | DV_II_48_0_bit | DV_II_49_0_bit | DV_II_53_0_bit | DV_II_54_0_bit)) - mask &= (((((W[46] >> 4) ^ (W[49] >> 29)) & 1) - 1) | ^(DV_I_46_0_bit | DV_I_48_0_bit | DV_I_50_0_bit | DV_I_52_0_bit | DV_II_50_0_bit | DV_II_55_0_bit)) - mask &= (((((W[46] ^ W[47]) >> 29) & 1) - 1) | ^(DV_I_43_0_bit | DV_I_50_0_bit | DV_II_47_0_bit | DV_II_48_0_bit | DV_II_52_0_bit | DV_II_53_0_bit)) - mask &= (((((W[45] >> 4) ^ (W[48] >> 29)) & 1) - 1) | ^(DV_I_45_0_bit | DV_I_47_0_bit | DV_I_49_0_bit | DV_I_51_0_bit | DV_II_49_0_bit | DV_II_54_0_bit)) - mask &= (((((W[45] ^ W[46]) >> 29) & 1) - 1) | ^(DV_I_49_0_bit | DV_I_52_0_bit | DV_II_46_0_bit | DV_II_47_0_bit | DV_II_51_0_bit | DV_II_52_0_bit)) - mask &= (((((W[44] >> 4) ^ (W[47] >> 29)) & 1) - 1) | ^(DV_I_44_0_bit | DV_I_46_0_bit | DV_I_48_0_bit | DV_I_50_0_bit | DV_II_48_0_bit | DV_II_53_0_bit)) - mask &= (((((W[43] >> 4) ^ (W[46] >> 29)) & 1) - 1) | ^(DV_I_43_0_bit | DV_I_45_0_bit | DV_I_47_0_bit | DV_I_49_0_bit | DV_II_47_0_bit | DV_II_52_0_bit)) - mask &= (((((W[43] ^ W[44]) >> 29) & 1) - 1) | ^(DV_I_47_0_bit | DV_I_50_0_bit | DV_I_51_0_bit | DV_II_45_0_bit | DV_II_49_0_bit | DV_II_50_0_bit)) - mask &= (((((W[42] >> 4) ^ (W[45] >> 29)) & 1) - 1) | ^(DV_I_44_0_bit | DV_I_46_0_bit | DV_I_48_0_bit | DV_I_52_0_bit | DV_II_46_0_bit | DV_II_51_0_bit)) - mask &= (((((W[41] >> 4) ^ (W[44] >> 29)) & 1) - 1) | ^(DV_I_43_0_bit | DV_I_45_0_bit | DV_I_47_0_bit | DV_I_51_0_bit | DV_II_45_0_bit | DV_II_50_0_bit)) - mask &= (((((W[40] ^ W[41]) >> 29) & 1) - 1) | ^(DV_I_44_0_bit | DV_I_47_0_bit | DV_I_48_0_bit | DV_II_46_0_bit | DV_II_47_0_bit | DV_II_56_0_bit)) - mask &= (((((W[54] ^ W[55]) >> 29) & 1) - 1) | ^(DV_I_51_0_bit | DV_II_47_0_bit | DV_II_50_0_bit | DV_II_55_0_bit | DV_II_56_0_bit)) - mask &= (((((W[53] ^ W[54]) >> 29) & 1) - 1) | ^(DV_I_50_0_bit | DV_II_46_0_bit | DV_II_49_0_bit | DV_II_54_0_bit | DV_II_55_0_bit)) - mask &= (((((W[52] ^ W[53]) >> 29) & 1) - 1) | ^(DV_I_49_0_bit | DV_II_45_0_bit | DV_II_48_0_bit | DV_II_53_0_bit | DV_II_54_0_bit)) - mask &= ((((W[50] ^ (W[53] >> 25)) & (1 << 4)) - (1 << 4)) | ^(DV_I_50_0_bit | DV_I_52_0_bit | DV_II_46_0_bit | DV_II_48_0_bit | DV_II_54_0_bit)) - mask &= (((((W[50] ^ W[51]) >> 29) & 1) - 1) | ^(DV_I_47_0_bit | DV_II_46_0_bit | DV_II_51_0_bit | DV_II_52_0_bit | DV_II_56_0_bit)) - mask &= ((((W[49] ^ (W[52] >> 25)) & (1 << 4)) - (1 << 4)) | ^(DV_I_49_0_bit | DV_I_51_0_bit | DV_II_45_0_bit | DV_II_47_0_bit | DV_II_53_0_bit)) - mask &= ((((W[48] ^ (W[51] >> 25)) & (1 << 4)) - (1 << 4)) | ^(DV_I_48_0_bit | DV_I_50_0_bit | DV_I_52_0_bit | DV_II_46_0_bit | DV_II_52_0_bit)) - mask &= (((((W[42] ^ W[43]) >> 29) & 1) - 1) | ^(DV_I_46_0_bit | DV_I_49_0_bit | DV_I_50_0_bit | DV_II_48_0_bit | DV_II_49_0_bit)) - mask &= (((((W[41] ^ W[42]) >> 29) & 1) - 1) | ^(DV_I_45_0_bit | DV_I_48_0_bit | DV_I_49_0_bit | DV_II_47_0_bit | DV_II_48_0_bit)) - mask &= (((((W[40] >> 4) ^ (W[43] >> 29)) & 1) - 1) | ^(DV_I_44_0_bit | DV_I_46_0_bit | DV_I_50_0_bit | DV_II_49_0_bit | DV_II_56_0_bit)) - mask &= (((((W[39] >> 4) ^ (W[42] >> 29)) & 1) - 1) | ^(DV_I_43_0_bit | DV_I_45_0_bit | DV_I_49_0_bit | DV_II_48_0_bit | DV_II_55_0_bit)) - - if (mask & (DV_I_44_0_bit | DV_I_48_0_bit | DV_II_47_0_bit | DV_II_54_0_bit | DV_II_56_0_bit)) != 0 { - mask &= (((((W[38] >> 4) ^ (W[41] >> 29)) & 1) - 1) | ^(DV_I_44_0_bit | DV_I_48_0_bit | DV_II_47_0_bit | DV_II_54_0_bit | DV_II_56_0_bit)) - } - mask &= (((((W[37] >> 4) ^ (W[40] >> 29)) & 1) - 1) | ^(DV_I_43_0_bit | DV_I_47_0_bit | DV_II_46_0_bit | DV_II_53_0_bit | DV_II_55_0_bit)) - if (mask & (DV_I_52_0_bit | DV_II_48_0_bit | DV_II_51_0_bit | DV_II_56_0_bit)) != 0 { - mask &= (((((W[55] ^ W[56]) >> 29) & 1) - 1) | ^(DV_I_52_0_bit | DV_II_48_0_bit | DV_II_51_0_bit | DV_II_56_0_bit)) - } - if (mask & (DV_I_52_0_bit | DV_II_48_0_bit | DV_II_50_0_bit | DV_II_56_0_bit)) != 0 { - mask &= ((((W[52] ^ (W[55] >> 25)) & (1 << 4)) - (1 << 4)) | ^(DV_I_52_0_bit | DV_II_48_0_bit | DV_II_50_0_bit | DV_II_56_0_bit)) - } - if (mask & (DV_I_51_0_bit | DV_II_47_0_bit | DV_II_49_0_bit | DV_II_55_0_bit)) != 0 { - mask &= ((((W[51] ^ (W[54] >> 25)) & (1 << 4)) - (1 << 4)) | ^(DV_I_51_0_bit | DV_II_47_0_bit | DV_II_49_0_bit | DV_II_55_0_bit)) - } - if (mask & (DV_I_48_0_bit | DV_II_47_0_bit | DV_II_52_0_bit | DV_II_53_0_bit)) != 0 { - mask &= (((((W[51] ^ W[52]) >> 29) & 1) - 1) | ^(DV_I_48_0_bit | DV_II_47_0_bit | DV_II_52_0_bit | DV_II_53_0_bit)) - } - if (mask & (DV_I_46_0_bit | DV_I_49_0_bit | DV_II_45_0_bit | DV_II_48_0_bit)) != 0 { - mask &= (((((W[36] >> 4) ^ (W[40] >> 29)) & 1) - 1) | ^(DV_I_46_0_bit | DV_I_49_0_bit | DV_II_45_0_bit | DV_II_48_0_bit)) - } - if (mask & (DV_I_52_0_bit | DV_II_48_0_bit | DV_II_49_0_bit)) != 0 { - mask &= ((0 - (((W[53] ^ W[56]) >> 29) & 1)) | ^(DV_I_52_0_bit | DV_II_48_0_bit | DV_II_49_0_bit)) - } - if (mask & (DV_I_50_0_bit | DV_II_46_0_bit | DV_II_47_0_bit)) != 0 { - mask &= ((0 - (((W[51] ^ W[54]) >> 29) & 1)) | ^(DV_I_50_0_bit | DV_II_46_0_bit | DV_II_47_0_bit)) - } - if (mask & (DV_I_49_0_bit | DV_I_51_0_bit | DV_II_45_0_bit)) != 0 { - mask &= ((0 - (((W[50] ^ W[52]) >> 29) & 1)) | ^(DV_I_49_0_bit | DV_I_51_0_bit | DV_II_45_0_bit)) - } - if (mask & (DV_I_48_0_bit | DV_I_50_0_bit | DV_I_52_0_bit)) != 0 { - mask &= ((0 - (((W[49] ^ W[51]) >> 29) & 1)) | ^(DV_I_48_0_bit | DV_I_50_0_bit | DV_I_52_0_bit)) - } - if (mask & (DV_I_47_0_bit | DV_I_49_0_bit | DV_I_51_0_bit)) != 0 { - mask &= ((0 - (((W[48] ^ W[50]) >> 29) & 1)) | ^(DV_I_47_0_bit | DV_I_49_0_bit | DV_I_51_0_bit)) - } - if (mask & (DV_I_46_0_bit | DV_I_48_0_bit | DV_I_50_0_bit)) != 0 { - mask &= ((0 - (((W[47] ^ W[49]) >> 29) & 1)) | ^(DV_I_46_0_bit | DV_I_48_0_bit | DV_I_50_0_bit)) - } - if (mask & (DV_I_45_0_bit | DV_I_47_0_bit | DV_I_49_0_bit)) != 0 { - mask &= ((0 - (((W[46] ^ W[48]) >> 29) & 1)) | ^(DV_I_45_0_bit | DV_I_47_0_bit | DV_I_49_0_bit)) - } - mask &= ((((W[45] ^ W[47]) & (1 << 6)) - (1 << 6)) | ^(DV_I_47_2_bit | DV_I_49_2_bit | DV_I_51_2_bit)) - if (mask & (DV_I_44_0_bit | DV_I_46_0_bit | DV_I_48_0_bit)) != 0 { - mask &= ((0 - (((W[45] ^ W[47]) >> 29) & 1)) | ^(DV_I_44_0_bit | DV_I_46_0_bit | DV_I_48_0_bit)) - } - mask &= (((((W[44] ^ W[46]) >> 6) & 1) - 1) | ^(DV_I_46_2_bit | DV_I_48_2_bit | DV_I_50_2_bit)) - if (mask & (DV_I_43_0_bit | DV_I_45_0_bit | DV_I_47_0_bit)) != 0 { - mask &= ((0 - (((W[44] ^ W[46]) >> 29) & 1)) | ^(DV_I_43_0_bit | DV_I_45_0_bit | DV_I_47_0_bit)) - } - mask &= ((0 - ((W[41] ^ (W[42] >> 5)) & (1 << 1))) | ^(DV_I_48_2_bit | DV_II_46_2_bit | DV_II_51_2_bit)) - mask &= ((0 - ((W[40] ^ (W[41] >> 5)) & (1 << 1))) | ^(DV_I_47_2_bit | DV_I_51_2_bit | DV_II_50_2_bit)) - if (mask & (DV_I_44_0_bit | DV_I_46_0_bit | DV_II_56_0_bit)) != 0 { - mask &= ((0 - (((W[40] ^ W[42]) >> 4) & 1)) | ^(DV_I_44_0_bit | DV_I_46_0_bit | DV_II_56_0_bit)) - } - mask &= ((0 - ((W[39] ^ (W[40] >> 5)) & (1 << 1))) | ^(DV_I_46_2_bit | DV_I_50_2_bit | DV_II_49_2_bit)) - if (mask & (DV_I_43_0_bit | DV_I_45_0_bit | DV_II_55_0_bit)) != 0 { - mask &= ((0 - (((W[39] ^ W[41]) >> 4) & 1)) | ^(DV_I_43_0_bit | DV_I_45_0_bit | DV_II_55_0_bit)) - } - if (mask & (DV_I_44_0_bit | DV_II_54_0_bit | DV_II_56_0_bit)) != 0 { - mask &= ((0 - (((W[38] ^ W[40]) >> 4) & 1)) | ^(DV_I_44_0_bit | DV_II_54_0_bit | DV_II_56_0_bit)) - } - if (mask & (DV_I_43_0_bit | DV_II_53_0_bit | DV_II_55_0_bit)) != 0 { - mask &= ((0 - (((W[37] ^ W[39]) >> 4) & 1)) | ^(DV_I_43_0_bit | DV_II_53_0_bit | DV_II_55_0_bit)) - } - mask &= ((0 - ((W[36] ^ (W[37] >> 5)) & (1 << 1))) | ^(DV_I_47_2_bit | DV_I_50_2_bit | DV_II_46_2_bit)) - if (mask & (DV_I_45_0_bit | DV_I_48_0_bit | DV_II_47_0_bit)) != 0 { - mask &= (((((W[35] >> 4) ^ (W[39] >> 29)) & 1) - 1) | ^(DV_I_45_0_bit | DV_I_48_0_bit | DV_II_47_0_bit)) - } - if (mask & (DV_I_48_0_bit | DV_II_48_0_bit)) != 0 { - mask &= ((0 - ((W[63] ^ (W[64] >> 5)) & (1 << 0))) | ^(DV_I_48_0_bit | DV_II_48_0_bit)) - } - if (mask & (DV_I_45_0_bit | DV_II_45_0_bit)) != 0 { - mask &= ((0 - ((W[63] ^ (W[64] >> 5)) & (1 << 1))) | ^(DV_I_45_0_bit | DV_II_45_0_bit)) - } - if (mask & (DV_I_47_0_bit | DV_II_47_0_bit)) != 0 { - mask &= ((0 - ((W[62] ^ (W[63] >> 5)) & (1 << 0))) | ^(DV_I_47_0_bit | DV_II_47_0_bit)) - } - if (mask & (DV_I_46_0_bit | DV_II_46_0_bit)) != 0 { - mask &= ((0 - ((W[61] ^ (W[62] >> 5)) & (1 << 0))) | ^(DV_I_46_0_bit | DV_II_46_0_bit)) - } - mask &= ((0 - ((W[61] ^ (W[62] >> 5)) & (1 << 2))) | ^(DV_I_46_2_bit | DV_II_46_2_bit)) - if (mask & (DV_I_45_0_bit | DV_II_45_0_bit)) != 0 { - mask &= ((0 - ((W[60] ^ (W[61] >> 5)) & (1 << 0))) | ^(DV_I_45_0_bit | DV_II_45_0_bit)) - } - if (mask & (DV_II_51_0_bit | DV_II_54_0_bit)) != 0 { - mask &= (((((W[58] ^ W[59]) >> 29) & 1) - 1) | ^(DV_II_51_0_bit | DV_II_54_0_bit)) - } - if (mask & (DV_II_50_0_bit | DV_II_53_0_bit)) != 0 { - mask &= (((((W[57] ^ W[58]) >> 29) & 1) - 1) | ^(DV_II_50_0_bit | DV_II_53_0_bit)) - } - if (mask & (DV_II_52_0_bit | DV_II_54_0_bit)) != 0 { - mask &= ((((W[56] ^ (W[59] >> 25)) & (1 << 4)) - (1 << 4)) | ^(DV_II_52_0_bit | DV_II_54_0_bit)) - } - if (mask & (DV_II_51_0_bit | DV_II_52_0_bit)) != 0 { - mask &= ((0 - (((W[56] ^ W[59]) >> 29) & 1)) | ^(DV_II_51_0_bit | DV_II_52_0_bit)) - } - if (mask & (DV_II_49_0_bit | DV_II_52_0_bit)) != 0 { - mask &= (((((W[56] ^ W[57]) >> 29) & 1) - 1) | ^(DV_II_49_0_bit | DV_II_52_0_bit)) - } - if (mask & (DV_II_51_0_bit | DV_II_53_0_bit)) != 0 { - mask &= ((((W[55] ^ (W[58] >> 25)) & (1 << 4)) - (1 << 4)) | ^(DV_II_51_0_bit | DV_II_53_0_bit)) - } - if (mask & (DV_II_50_0_bit | DV_II_52_0_bit)) != 0 { - mask &= ((((W[54] ^ (W[57] >> 25)) & (1 << 4)) - (1 << 4)) | ^(DV_II_50_0_bit | DV_II_52_0_bit)) - } - if (mask & (DV_II_49_0_bit | DV_II_51_0_bit)) != 0 { - mask &= ((((W[53] ^ (W[56] >> 25)) & (1 << 4)) - (1 << 4)) | ^(DV_II_49_0_bit | DV_II_51_0_bit)) - } - mask &= ((((W[51] ^ (W[50] >> 5)) & (1 << 1)) - (1 << 1)) | ^(DV_I_50_2_bit | DV_II_46_2_bit)) - mask &= ((((W[48] ^ W[50]) & (1 << 6)) - (1 << 6)) | ^(DV_I_50_2_bit | DV_II_46_2_bit)) - if (mask & (DV_I_51_0_bit | DV_I_52_0_bit)) != 0 { - mask &= ((0 - (((W[48] ^ W[55]) >> 29) & 1)) | ^(DV_I_51_0_bit | DV_I_52_0_bit)) - } - mask &= ((((W[47] ^ W[49]) & (1 << 6)) - (1 << 6)) | ^(DV_I_49_2_bit | DV_I_51_2_bit)) - mask &= ((((W[48] ^ (W[47] >> 5)) & (1 << 1)) - (1 << 1)) | ^(DV_I_47_2_bit | DV_II_51_2_bit)) - mask &= ((((W[46] ^ W[48]) & (1 << 6)) - (1 << 6)) | ^(DV_I_48_2_bit | DV_I_50_2_bit)) - mask &= ((((W[47] ^ (W[46] >> 5)) & (1 << 1)) - (1 << 1)) | ^(DV_I_46_2_bit | DV_II_50_2_bit)) - mask &= ((0 - ((W[44] ^ (W[45] >> 5)) & (1 << 1))) | ^(DV_I_51_2_bit | DV_II_49_2_bit)) - mask &= ((((W[43] ^ W[45]) & (1 << 6)) - (1 << 6)) | ^(DV_I_47_2_bit | DV_I_49_2_bit)) - mask &= (((((W[42] ^ W[44]) >> 6) & 1) - 1) | ^(DV_I_46_2_bit | DV_I_48_2_bit)) - mask &= ((((W[43] ^ (W[42] >> 5)) & (1 << 1)) - (1 << 1)) | ^(DV_II_46_2_bit | DV_II_51_2_bit)) - mask &= ((((W[42] ^ (W[41] >> 5)) & (1 << 1)) - (1 << 1)) | ^(DV_I_51_2_bit | DV_II_50_2_bit)) - mask &= ((((W[41] ^ (W[40] >> 5)) & (1 << 1)) - (1 << 1)) | ^(DV_I_50_2_bit | DV_II_49_2_bit)) - if (mask & (DV_I_52_0_bit | DV_II_51_0_bit)) != 0 { - mask &= ((((W[39] ^ (W[43] >> 25)) & (1 << 4)) - (1 << 4)) | ^(DV_I_52_0_bit | DV_II_51_0_bit)) - } - if (mask & (DV_I_51_0_bit | DV_II_50_0_bit)) != 0 { - mask &= ((((W[38] ^ (W[42] >> 25)) & (1 << 4)) - (1 << 4)) | ^(DV_I_51_0_bit | DV_II_50_0_bit)) - } - if (mask & (DV_I_48_2_bit | DV_I_51_2_bit)) != 0 { - mask &= ((0 - ((W[37] ^ (W[38] >> 5)) & (1 << 1))) | ^(DV_I_48_2_bit | DV_I_51_2_bit)) - } - if (mask & (DV_I_50_0_bit | DV_II_49_0_bit)) != 0 { - mask &= ((((W[37] ^ (W[41] >> 25)) & (1 << 4)) - (1 << 4)) | ^(DV_I_50_0_bit | DV_II_49_0_bit)) - } - if (mask & (DV_II_52_0_bit | DV_II_54_0_bit)) != 0 { - mask &= ((0 - ((W[36] ^ W[38]) & (1 << 4))) | ^(DV_II_52_0_bit | DV_II_54_0_bit)) - } - mask &= ((0 - ((W[35] ^ (W[36] >> 5)) & (1 << 1))) | ^(DV_I_46_2_bit | DV_I_49_2_bit)) - if (mask & (DV_I_51_0_bit | DV_II_47_0_bit)) != 0 { - mask &= ((((W[35] ^ (W[39] >> 25)) & (1 << 3)) - (1 << 3)) | ^(DV_I_51_0_bit | DV_II_47_0_bit)) - } - - if mask != 0 { - if (mask & DV_I_43_0_bit) != 0 { - if not((W[61]^(W[62]>>5))&(1<<1)) != 0 || - not(not((W[59]^(W[63]>>25))&(1<<5))) != 0 || - not((W[58]^(W[63]>>30))&(1<<0)) != 0 { - mask &= ^DV_I_43_0_bit - } - } - if (mask & DV_I_44_0_bit) != 0 { - if not((W[62]^(W[63]>>5))&(1<<1)) != 0 || - not(not((W[60]^(W[64]>>25))&(1<<5))) != 0 || - not((W[59]^(W[64]>>30))&(1<<0)) != 0 { - mask &= ^DV_I_44_0_bit - } - } - if (mask & DV_I_46_2_bit) != 0 { - mask &= ((^((W[40] ^ W[42]) >> 2)) | ^DV_I_46_2_bit) - } - if (mask & DV_I_47_2_bit) != 0 { - if not((W[62]^(W[63]>>5))&(1<<2)) != 0 || - not(not((W[41]^W[43])&(1<<6))) != 0 { - mask &= ^DV_I_47_2_bit - } - } - if (mask & DV_I_48_2_bit) != 0 { - if not((W[63]^(W[64]>>5))&(1<<2)) != 0 || - not(not((W[48]^(W[49]<<5))&(1<<6))) != 0 { - mask &= ^DV_I_48_2_bit - } - } - if (mask & DV_I_49_2_bit) != 0 { - if not(not((W[49]^(W[50]<<5))&(1<<6))) != 0 || - not((W[42]^W[50])&(1<<1)) != 0 || - not(not((W[39]^(W[40]<<5))&(1<<6))) != 0 || - not((W[38]^W[40])&(1<<1)) != 0 { - mask &= ^DV_I_49_2_bit - } - } - if (mask & DV_I_50_0_bit) != 0 { - mask &= (((W[36] ^ W[37]) << 7) | ^DV_I_50_0_bit) - } - if (mask & DV_I_50_2_bit) != 0 { - mask &= (((W[43] ^ W[51]) << 11) | ^DV_I_50_2_bit) - } - if (mask & DV_I_51_0_bit) != 0 { - mask &= (((W[37] ^ W[38]) << 9) | ^DV_I_51_0_bit) - } - if (mask & DV_I_51_2_bit) != 0 { - if not(not((W[51]^(W[52]<<5))&(1<<6))) != 0 || - not(not((W[49]^W[51])&(1<<6))) != 0 || - not(not((W[37]^(W[37]>>5))&(1<<1))) != 0 || - not(not((W[35]^(W[39]>>25))&(1<<5))) != 0 { - mask &= ^DV_I_51_2_bit - } - } - if (mask & DV_I_52_0_bit) != 0 { - mask &= (((W[38] ^ W[39]) << 11) | ^DV_I_52_0_bit) - } - if (mask & DV_II_46_2_bit) != 0 { - mask &= (((W[47] ^ W[51]) << 17) | ^DV_II_46_2_bit) - } - if (mask & DV_II_48_0_bit) != 0 { - if not(not((W[36]^(W[40]>>25))&(1<<3))) != 0 || - not((W[35]^(W[40]<<2))&(1<<30)) != 0 { - mask &= ^DV_II_48_0_bit - } - } - if (mask & DV_II_49_0_bit) != 0 { - if not(not((W[37]^(W[41]>>25))&(1<<3))) != 0 || - not((W[36]^(W[41]<<2))&(1<<30)) != 0 { - mask &= ^DV_II_49_0_bit - } - } - if (mask & DV_II_49_2_bit) != 0 { - if not(not((W[53]^(W[54]<<5))&(1<<6))) != 0 || - not(not((W[51]^W[53])&(1<<6))) != 0 || - not((W[50]^W[54])&(1<<1)) != 0 || - not(not((W[45]^(W[46]<<5))&(1<<6))) != 0 || - not(not((W[37]^(W[41]>>25))&(1<<5))) != 0 || - not((W[36]^(W[41]>>30))&(1<<0)) != 0 { - mask &= ^DV_II_49_2_bit - } - } - if (mask & DV_II_50_0_bit) != 0 { - if not((W[55]^W[58])&(1<<29)) != 0 || - not(not((W[38]^(W[42]>>25))&(1<<3))) != 0 || - not((W[37]^(W[42]<<2))&(1<<30)) != 0 { - mask &= ^DV_II_50_0_bit - } - } - if (mask & DV_II_50_2_bit) != 0 { - if not(not((W[54]^(W[55]<<5))&(1<<6))) != 0 || - not(not((W[52]^W[54])&(1<<6))) != 0 || - not((W[51]^W[55])&(1<<1)) != 0 || - not((W[45]^W[47])&(1<<1)) != 0 || - not(not((W[38]^(W[42]>>25))&(1<<5))) != 0 || - not((W[37]^(W[42]>>30))&(1<<0)) != 0 { - mask &= ^DV_II_50_2_bit - } - } - if (mask & DV_II_51_0_bit) != 0 { - if not(not((W[39]^(W[43]>>25))&(1<<3))) != 0 || - not((W[38]^(W[43]<<2))&(1<<30)) != 0 { - mask &= ^DV_II_51_0_bit - } - } - if (mask & DV_II_51_2_bit) != 0 { - if not(not((W[55]^(W[56]<<5))&(1<<6))) != 0 || - not(not((W[53]^W[55])&(1<<6))) != 0 || - not((W[52]^W[56])&(1<<1)) != 0 || - not((W[46]^W[48])&(1<<1)) != 0 || - not(not((W[39]^(W[43]>>25))&(1<<5))) != 0 || - not((W[38]^(W[43]>>30))&(1<<0)) != 0 { - mask &= ^DV_II_51_2_bit - } - } - if (mask & DV_II_52_0_bit) != 0 { - if not(not((W[59]^W[60])&(1<<29))) != 0 || - not(not((W[40]^(W[44]>>25))&(1<<3))) != 0 || - not(not((W[40]^(W[44]>>25))&(1<<4))) != 0 || - not((W[39]^(W[44]<<2))&(1<<30)) != 0 { - mask &= ^DV_II_52_0_bit - } - } - if (mask & DV_II_53_0_bit) != 0 { - if not((W[58]^W[61])&(1<<29)) != 0 || - not(not((W[57]^(W[61]>>25))&(1<<4))) != 0 || - not(not((W[41]^(W[45]>>25))&(1<<3))) != 0 || - not(not((W[41]^(W[45]>>25))&(1<<4))) != 0 { - mask &= ^DV_II_53_0_bit - } - } - if (mask & DV_II_54_0_bit) != 0 { - if not(not((W[58]^(W[62]>>25))&(1<<4))) != 0 || - not(not((W[42]^(W[46]>>25))&(1<<3))) != 0 || - not(not((W[42]^(W[46]>>25))&(1<<4))) != 0 { - mask &= ^DV_II_54_0_bit - } - } - if (mask & DV_II_55_0_bit) != 0 { - if not(not((W[59]^(W[63]>>25))&(1<<4))) != 0 || - not(not((W[57]^(W[59]>>25))&(1<<4))) != 0 || - not(not((W[43]^(W[47]>>25))&(1<<3))) != 0 || - not(not((W[43]^(W[47]>>25))&(1<<4))) != 0 { - mask &= ^DV_II_55_0_bit - } - } - if (mask & DV_II_56_0_bit) != 0 { - if not(not((W[60]^(W[64]>>25))&(1<<4))) != 0 || - not(not((W[44]^(W[48]>>25))&(1<<3))) != 0 || - not(not((W[44]^(W[48]>>25))&(1<<4))) != 0 { - mask &= ^DV_II_56_0_bit - } - } - } - - return mask -} - -func not(x uint32) uint32 { - if x == 0 { - return 1 - } - - return 0 -} - //go:nosplit func SHA1_dvs() []DvInfo { return sha1_dvs diff --git a/vendor/github.com/pjbgf/sha1cd/ubc/ubc_generated.go b/vendor/github.com/pjbgf/sha1cd/ubc/ubc_generated.go new file mode 100644 index 0000000000..ef7ce34d1f --- /dev/null +++ b/vendor/github.com/pjbgf/sha1cd/ubc/ubc_generated.go @@ -0,0 +1,686 @@ +// Code generated by internal/ubcgen. DO NOT EDIT. + +package ubc + +// prefixScalar runs the scalar prefix, which leaves 1.9844 DVs standing on +// average for a random block. +func prefixScalar(W *[80]uint32) uint32 { + mask := ^uint32(0) + mask &= ((W[44]>>29^W[45]>>29^0)&1 - 1) | 0xfd7c5f7f + mask &= ((W[46]>>29^W[47]>>29^0)&1 - 1) | 0xe7e7f7fe + mask &= ((W[45]>>4^W[48]>>29^0)&1 - 1) | 0xdfdfdddb + mask &= ((W[49]>>29^W[50]>>29^0)&1 - 1) | 0x3d7efff7 + mask &= ((W[40]>>29^W[41]>>29^0)&1 - 1) | 0x7ff5ff5d + mask &= ((W[36]>>1^W[37]>>6^1)&1 - 1) | 0xfffbefbf + mask &= ((W[47]>>29^W[48]>>29^0)&1 - 1) | 0xcfcfdffd + mask &= ((W[39]>>1^W[40]>>6^1)&1 - 1) | 0xffbfefef + mask &= ((W[40]>>1^W[41]>>6^1)&1 - 1) | 0xfeffbfbf + mask &= ((W[41]>>1^W[42]>>6^1)&1 - 1) | 0xfbfbfeff + mask &= ((W[43]>>4^W[46]>>29^0)&1 - 1) | 0xf7f7fdda + mask &= ((W[46]>>4^W[49]>>29^0)&1 - 1) | 0xbf7f7777 + mask &= ((W[45]>>6^W[47]>>6^0)&1 - 1) | 0xffffbbbf + mask &= ((W[45]>>29^W[46]>>29^0)&1 - 1) | 0xf5f57dff + mask &= ((W[44]>>4^W[47]>>29^0)&1 - 1) | 0xefeff775 + mask &= ((W[48]>>29^W[49]>>29^0)&1 - 1) | 0x9f5f7ffb + mask &= ((W[44]>>6^W[46]>>6^0)&1 - 1) | 0xffffeeef + mask &= ((W[47]>>4^W[50]>>29^0)&1 - 1) | 0x7dfedddf + mask &= ((W[41]>>6^W[42]>>1^0)&1 - 1) | 0xfeffbfff + mask &= ((W[42]>>6^W[43]>>1^0)&1 - 1) | 0xfbfbffff + mask &= ((W[35]>>1^W[36]>>6^1)&1 - 1) | 0xfffffbef + mask &= ((W[37]>>4^W[40]>>29^0)&1 - 1) | 0xaffdffde + mask &= ((W[40]>>6^W[41]>>1^0)&1 - 1) | 0xffbfefff + mask &= ((W[40]>>4^W[43]>>29^0)&1 - 1) | 0x7fdff7f5 + mask &= ((W[41]>>4^W[44]>>29^0)&1 - 1) | 0xff7edfda + mask &= ((W[52]>>29^W[53]>>29^0)&1 - 1) | 0xcfeefdff + mask &= ((W[46]>>6^W[47]>>1^0)&1 - 1) | 0xfeffffef + mask &= ((W[47]>>6^W[48]>>1^0)&1 - 1) | 0xfbffffbf + mask &= ((W[37]>>1^W[38]>>6^1)&1 - 1) | 0xffffbeff + mask &= ((W[42]>>4^W[45]>>29^0)&1 - 1) | 0xfdfd7f75 + mask &= ((W[44]>>1^W[45]>>6^1)&1 - 1) | 0xffbfbfff + mask &= ((W[43]>>6^W[45]>>6^0)&1 - 1) | 0xfffffbbf + return mask +} + +// tailChecksScalar completes, per DV, the span the Scalar prefix covers. +var tailChecksScalar = [...]tailCheck{ + {39, 4, 42, 29, 0}, + {44, 29, 46, 29, 1}, + {39, 4, 41, 4, 1}, + {37, 4, 39, 4, 1}, + {61, 1, 62, 6, 1}, + {59, 5, 63, 30, 0}, + {58, 0, 63, 30, 1}, + {38, 4, 41, 29, 0}, + {45, 29, 47, 29, 1}, + {40, 4, 42, 4, 1}, + {38, 4, 40, 4, 1}, + {62, 1, 63, 6, 1}, + {60, 5, 64, 30, 0}, + {59, 0, 64, 30, 1}, + {41, 29, 42, 29, 0}, + {39, 4, 42, 29, 0}, + {46, 29, 48, 29, 1}, + {44, 29, 46, 29, 1}, + {39, 4, 41, 4, 1}, + {35, 4, 39, 29, 0}, + {63, 1, 64, 6, 1}, + {60, 0, 61, 5, 1}, + {42, 29, 43, 29, 0}, + {36, 4, 40, 29, 0}, + {47, 29, 49, 29, 1}, + {45, 29, 47, 29, 1}, + {40, 4, 42, 4, 1}, + {61, 0, 62, 5, 1}, + {61, 2, 62, 7, 1}, + {42, 6, 44, 6, 0}, + {40, 6, 42, 6, 0}, + {43, 29, 44, 29, 0}, + {50, 29, 51, 29, 0}, + {48, 29, 50, 29, 1}, + {46, 29, 48, 29, 1}, + {44, 29, 46, 29, 1}, + {62, 0, 63, 5, 1}, + {62, 2, 63, 7, 1}, + {41, 6, 43, 6, 0}, + {48, 4, 51, 29, 0}, + {41, 29, 42, 29, 0}, + {38, 4, 41, 29, 0}, + {51, 29, 52, 29, 0}, + {49, 29, 51, 29, 1}, + {47, 29, 49, 29, 1}, + {45, 29, 47, 29, 1}, + {35, 4, 39, 29, 0}, + {63, 0, 64, 5, 1}, + {46, 6, 48, 6, 0}, + {42, 6, 44, 6, 0}, + {63, 2, 64, 7, 1}, + {48, 6, 49, 1, 0}, + {49, 4, 52, 29, 0}, + {42, 29, 43, 29, 0}, + {41, 29, 42, 29, 0}, + {39, 4, 42, 29, 0}, + {36, 4, 40, 29, 0}, + {50, 29, 52, 29, 1}, + {48, 29, 50, 29, 1}, + {46, 29, 48, 29, 1}, + {47, 6, 49, 6, 0}, + {49, 6, 50, 1, 0}, + {42, 1, 50, 1, 1}, + {39, 6, 40, 1, 0}, + {38, 1, 40, 1, 1}, + {43, 29, 44, 29, 0}, + {53, 29, 54, 29, 0}, + {50, 4, 53, 29, 0}, + {48, 4, 51, 29, 0}, + {42, 29, 43, 29, 0}, + {51, 29, 54, 29, 1}, + {49, 29, 51, 29, 1}, + {47, 29, 49, 29, 1}, + {37, 4, 41, 29, 0}, + {36, 4, 37, 4, 1}, + {50, 6, 51, 1, 0}, + {48, 6, 50, 6, 0}, + {46, 6, 48, 6, 0}, + {43, 1, 51, 1, 1}, + {43, 29, 44, 29, 0}, + {54, 29, 55, 29, 0}, + {49, 4, 52, 29, 0}, + {51, 4, 54, 29, 0}, + {50, 29, 52, 29, 1}, + {48, 29, 50, 29, 1}, + {48, 29, 55, 29, 1}, + {38, 4, 42, 29, 0}, + {35, 3, 39, 28, 0}, + {37, 4, 38, 4, 1}, + {47, 6, 49, 6, 0}, + {51, 6, 52, 1, 0}, + {49, 6, 51, 6, 0}, + {37, 1, 37, 6, 0}, + {35, 5, 39, 30, 0}, + {50, 4, 53, 29, 0}, + {48, 4, 51, 29, 0}, + {55, 29, 56, 29, 0}, + {52, 4, 55, 29, 0}, + {53, 29, 56, 29, 1}, + {49, 29, 51, 29, 1}, + {48, 29, 55, 29, 1}, + {39, 4, 43, 29, 0}, + {38, 4, 39, 4, 1}, + {43, 29, 44, 29, 0}, + {49, 4, 52, 29, 0}, + {36, 4, 40, 29, 0}, + {50, 29, 52, 29, 1}, + {63, 1, 64, 6, 1}, + {60, 0, 61, 5, 1}, + {53, 29, 54, 29, 0}, + {50, 4, 53, 29, 0}, + {50, 29, 51, 29, 0}, + {48, 4, 51, 29, 0}, + {51, 29, 54, 29, 1}, + {61, 0, 62, 5, 1}, + {61, 2, 62, 7, 1}, + {50, 6, 51, 1, 0}, + {48, 6, 50, 6, 0}, + {47, 1, 51, 1, 1}, + {54, 29, 55, 29, 0}, + {49, 4, 52, 29, 0}, + {41, 29, 42, 29, 0}, + {38, 4, 41, 29, 0}, + {51, 4, 54, 29, 0}, + {51, 29, 52, 29, 0}, + {51, 29, 54, 29, 1}, + {35, 4, 39, 29, 0}, + {62, 0, 63, 5, 1}, + {35, 3, 39, 28, 0}, + {50, 4, 53, 29, 0}, + {42, 29, 43, 29, 0}, + {41, 29, 42, 29, 0}, + {39, 4, 42, 29, 0}, + {55, 29, 56, 29, 0}, + {52, 4, 55, 29, 0}, + {36, 4, 40, 29, 0}, + {53, 29, 56, 29, 1}, + {63, 0, 64, 5, 1}, + {36, 3, 40, 28, 0}, + {35, 30, 40, 28, 1}, + {43, 29, 44, 29, 0}, + {53, 29, 54, 29, 0}, + {42, 29, 43, 29, 0}, + {51, 4, 54, 29, 0}, + {53, 29, 56, 29, 1}, + {56, 29, 57, 29, 0}, + {53, 4, 56, 29, 0}, + {37, 4, 41, 29, 0}, + {37, 3, 41, 28, 0}, + {36, 30, 41, 28, 1}, + {53, 6, 54, 1, 0}, + {51, 6, 53, 6, 0}, + {50, 1, 54, 1, 1}, + {45, 6, 46, 1, 0}, + {37, 5, 41, 30, 0}, + {36, 0, 41, 30, 1}, + {43, 29, 44, 29, 0}, + {54, 29, 55, 29, 0}, + {52, 4, 55, 29, 0}, + {57, 29, 58, 29, 0}, + {54, 4, 57, 29, 0}, + {38, 4, 42, 29, 0}, + {55, 29, 58, 29, 1}, + {38, 3, 42, 28, 0}, + {37, 30, 42, 28, 1}, + {54, 6, 55, 1, 0}, + {52, 6, 54, 6, 0}, + {51, 1, 55, 1, 1}, + {45, 1, 47, 1, 1}, + {38, 5, 42, 30, 0}, + {37, 0, 42, 30, 1}, + {50, 29, 51, 29, 0}, + {55, 29, 56, 29, 0}, + {58, 29, 59, 29, 0}, + {56, 29, 59, 29, 1}, + {55, 4, 58, 29, 0}, + {53, 4, 56, 29, 0}, + {39, 4, 43, 29, 0}, + {39, 3, 43, 28, 0}, + {38, 30, 43, 28, 1}, + {55, 6, 56, 1, 0}, + {53, 6, 55, 6, 0}, + {52, 1, 56, 1, 1}, + {46, 1, 48, 1, 1}, + {39, 5, 43, 30, 0}, + {38, 0, 43, 30, 1}, + {50, 29, 51, 29, 0}, + {48, 4, 51, 29, 0}, + {51, 29, 52, 29, 0}, + {56, 4, 59, 29, 0}, + {56, 29, 59, 29, 1}, + {56, 29, 57, 29, 0}, + {54, 4, 57, 29, 0}, + {36, 4, 38, 4, 1}, + {59, 29, 60, 29, 0}, + {40, 3, 44, 28, 0}, + {40, 4, 44, 29, 0}, + {39, 30, 44, 28, 1}, + {49, 4, 52, 29, 0}, + {51, 29, 52, 29, 0}, + {37, 4, 39, 4, 1}, + {57, 29, 58, 29, 0}, + {55, 4, 58, 29, 0}, + {58, 29, 61, 29, 1}, + {57, 4, 61, 29, 0}, + {41, 3, 45, 28, 0}, + {41, 4, 45, 29, 0}, + {53, 29, 54, 29, 0}, + {50, 4, 53, 29, 0}, + {38, 4, 41, 29, 0}, + {38, 4, 40, 4, 1}, + {58, 29, 59, 29, 0}, + {56, 4, 59, 29, 0}, + {36, 4, 38, 4, 1}, + {58, 4, 62, 29, 0}, + {42, 3, 46, 28, 0}, + {42, 4, 46, 29, 0}, + {54, 29, 55, 29, 0}, + {53, 29, 54, 29, 0}, + {39, 4, 42, 29, 0}, + {51, 4, 54, 29, 0}, + {39, 4, 41, 4, 1}, + {37, 4, 39, 4, 1}, + {59, 4, 63, 29, 0}, + {57, 4, 59, 29, 0}, + {43, 3, 47, 28, 0}, + {43, 4, 47, 29, 0}, + {54, 29, 55, 29, 0}, + {50, 29, 51, 29, 0}, + {38, 4, 41, 29, 0}, + {55, 29, 56, 29, 0}, + {52, 4, 55, 29, 0}, + {40, 4, 42, 4, 1}, + {38, 4, 40, 4, 1}, + {60, 4, 64, 29, 0}, + {44, 3, 48, 28, 0}, + {44, 4, 48, 29, 0}, +} + +// tailSpansScalar locates each DV's checks in tailChecksScalar. +var tailSpansScalar = [32]tailSpan{ + {0, 7}, + {7, 7}, + {14, 8}, + {22, 6}, + {28, 3}, + {31, 6}, + {37, 2}, + {39, 9}, + {48, 4}, + {52, 8}, + {60, 5}, + {65, 10}, + {75, 4}, + {79, 10}, + {89, 5}, + {94, 9}, + {103, 6}, + {109, 6}, + {115, 4}, + {119, 10}, + {129, 11}, + {140, 10}, + {150, 6}, + {156, 9}, + {165, 6}, + {171, 9}, + {180, 6}, + {186, 12}, + {198, 9}, + {207, 10}, + {217, 10}, + {227, 10}, +} + +// tailChecksAVX2 completes, per DV, the span the AVX2 prefix covers. +var tailChecksAVX2 = [...]tailCheck{ + {37, 4, 39, 4, 1}, + {61, 1, 62, 6, 1}, + {59, 5, 63, 30, 0}, + {40, 29, 41, 29, 0}, + {62, 1, 63, 6, 1}, + {60, 5, 64, 30, 0}, + {41, 29, 42, 29, 0}, + {35, 4, 39, 29, 0}, + {63, 1, 64, 6, 1}, + {36, 4, 40, 29, 0}, + {61, 0, 62, 5, 1}, + {40, 6, 42, 6, 0}, + {40, 29, 41, 29, 0}, + {62, 0, 63, 5, 1}, + {41, 6, 43, 6, 0}, + {40, 29, 41, 29, 0}, + {41, 29, 42, 29, 0}, + {49, 29, 51, 29, 1}, + {35, 4, 39, 29, 0}, + {63, 0, 64, 5, 1}, + {37, 1, 38, 6, 1}, + {41, 29, 42, 29, 0}, + {36, 4, 40, 29, 0}, + {50, 29, 52, 29, 1}, + {39, 6, 40, 1, 0}, + {38, 1, 40, 1, 1}, + {51, 29, 54, 29, 1}, + {49, 29, 51, 29, 1}, + {37, 4, 41, 29, 0}, + {36, 4, 37, 4, 1}, + {43, 1, 51, 1, 1}, + {50, 29, 52, 29, 1}, + {48, 29, 55, 29, 1}, + {38, 4, 42, 29, 0}, + {35, 3, 39, 28, 0}, + {37, 4, 38, 4, 1}, + {44, 1, 45, 6, 1}, + {37, 1, 38, 6, 1}, + {37, 1, 37, 6, 0}, + {35, 5, 39, 30, 0}, + {53, 29, 56, 29, 1}, + {49, 29, 51, 29, 1}, + {48, 29, 55, 29, 1}, + {39, 4, 43, 29, 0}, + {38, 4, 39, 4, 1}, + {36, 4, 40, 29, 0}, + {50, 29, 52, 29, 1}, + {63, 1, 64, 6, 1}, + {40, 29, 41, 29, 0}, + {51, 29, 54, 29, 1}, + {61, 0, 62, 5, 1}, + {47, 1, 51, 1, 1}, + {40, 29, 41, 29, 0}, + {41, 29, 42, 29, 0}, + {51, 29, 54, 29, 1}, + {35, 4, 39, 29, 0}, + {62, 0, 63, 5, 1}, + {35, 3, 39, 28, 0}, + {41, 29, 42, 29, 0}, + {36, 4, 40, 29, 0}, + {53, 29, 56, 29, 1}, + {63, 0, 64, 5, 1}, + {36, 3, 40, 28, 0}, + {35, 30, 40, 28, 1}, + {53, 29, 56, 29, 1}, + {53, 4, 56, 29, 0}, + {37, 4, 41, 29, 0}, + {37, 3, 41, 28, 0}, + {36, 30, 41, 28, 1}, + {53, 6, 54, 1, 0}, + {50, 1, 54, 1, 1}, + {37, 5, 41, 30, 0}, + {36, 0, 41, 30, 1}, + {54, 4, 57, 29, 0}, + {38, 4, 42, 29, 0}, + {55, 29, 58, 29, 1}, + {38, 3, 42, 28, 0}, + {37, 30, 42, 28, 1}, + {54, 6, 55, 1, 0}, + {52, 6, 54, 6, 0}, + {51, 1, 55, 1, 1}, + {38, 5, 42, 30, 0}, + {58, 29, 59, 29, 0}, + {56, 29, 59, 29, 1}, + {55, 4, 58, 29, 0}, + {53, 4, 56, 29, 0}, + {39, 4, 43, 29, 0}, + {39, 3, 43, 28, 0}, + {38, 30, 43, 28, 1}, + {55, 6, 56, 1, 0}, + {53, 6, 55, 6, 0}, + {52, 1, 56, 1, 1}, + {39, 5, 43, 30, 0}, + {56, 4, 59, 29, 0}, + {56, 29, 59, 29, 1}, + {54, 4, 57, 29, 0}, + {36, 4, 38, 4, 1}, + {59, 29, 60, 29, 0}, + {40, 3, 44, 28, 0}, + {40, 4, 44, 29, 0}, + {39, 30, 44, 28, 1}, + {37, 4, 39, 4, 1}, + {55, 4, 58, 29, 0}, + {58, 29, 61, 29, 1}, + {57, 4, 61, 29, 0}, + {41, 3, 45, 28, 0}, + {41, 4, 45, 29, 0}, + {58, 29, 59, 29, 0}, + {56, 4, 59, 29, 0}, + {36, 4, 38, 4, 1}, + {58, 4, 62, 29, 0}, + {42, 3, 46, 28, 0}, + {42, 4, 46, 29, 0}, + {37, 4, 39, 4, 1}, + {59, 4, 63, 29, 0}, + {57, 4, 59, 29, 0}, + {43, 3, 47, 28, 0}, + {43, 4, 47, 29, 0}, + {40, 29, 41, 29, 0}, + {60, 4, 64, 29, 0}, + {44, 3, 48, 28, 0}, + {44, 4, 48, 29, 0}, +} + +// tailSpansAVX2 locates each DV's checks in tailChecksAVX2. +var tailSpansAVX2 = [32]tailSpan{ + {0, 3}, + {3, 3}, + {6, 3}, + {9, 2}, + {11, 1}, + {12, 2}, + {14, 1}, + {15, 5}, + {20, 1}, + {21, 3}, + {24, 2}, + {26, 4}, + {30, 1}, + {31, 5}, + {36, 4}, + {40, 5}, + {45, 3}, + {48, 3}, + {51, 1}, + {52, 6}, + {58, 6}, + {64, 5}, + {69, 4}, + {73, 5}, + {78, 4}, + {82, 7}, + {89, 4}, + {93, 8}, + {101, 6}, + {107, 6}, + {113, 5}, + {118, 4}, +} + +// tailChecksNEON completes, per DV, the span the NEON prefix covers. +var tailChecksNEON = [...]tailCheck{ + {43, 4, 46, 29, 0}, + {37, 4, 40, 29, 0}, + {37, 4, 39, 4, 1}, + {61, 1, 62, 6, 1}, + {59, 5, 63, 30, 0}, + {58, 0, 63, 30, 1}, + {42, 4, 45, 29, 0}, + {40, 4, 42, 4, 1}, + {38, 4, 40, 4, 1}, + {62, 1, 63, 6, 1}, + {60, 5, 64, 30, 0}, + {59, 0, 64, 30, 1}, + {43, 4, 46, 29, 0}, + {46, 29, 48, 29, 1}, + {35, 4, 39, 29, 0}, + {63, 1, 64, 6, 1}, + {60, 0, 61, 5, 1}, + {42, 4, 45, 29, 0}, + {36, 4, 40, 29, 0}, + {47, 29, 49, 29, 1}, + {40, 4, 42, 4, 1}, + {61, 0, 62, 5, 1}, + {61, 2, 62, 7, 1}, + {40, 6, 42, 6, 0}, + {43, 4, 46, 29, 0}, + {37, 4, 40, 29, 0}, + {48, 29, 50, 29, 1}, + {46, 29, 48, 29, 1}, + {62, 0, 63, 5, 1}, + {62, 2, 63, 7, 1}, + {41, 6, 43, 6, 0}, + {42, 4, 45, 29, 0}, + {49, 29, 51, 29, 1}, + {47, 29, 49, 29, 1}, + {35, 4, 39, 29, 0}, + {63, 0, 64, 5, 1}, + {63, 2, 64, 7, 1}, + {43, 4, 46, 29, 0}, + {36, 4, 40, 29, 0}, + {50, 29, 52, 29, 1}, + {48, 29, 50, 29, 1}, + {46, 29, 48, 29, 1}, + {49, 6, 50, 1, 0}, + {39, 6, 40, 1, 0}, + {38, 1, 40, 1, 1}, + {51, 29, 54, 29, 1}, + {49, 29, 51, 29, 1}, + {47, 29, 49, 29, 1}, + {37, 4, 41, 29, 0}, + {36, 4, 37, 4, 1}, + {50, 6, 51, 1, 0}, + {48, 6, 50, 6, 0}, + {43, 1, 51, 1, 1}, + {50, 29, 52, 29, 1}, + {48, 29, 50, 29, 1}, + {48, 29, 55, 29, 1}, + {38, 4, 42, 29, 0}, + {35, 3, 39, 28, 0}, + {37, 4, 38, 4, 1}, + {51, 6, 52, 1, 0}, + {49, 6, 51, 6, 0}, + {37, 1, 37, 6, 0}, + {35, 5, 39, 30, 0}, + {42, 4, 45, 29, 0}, + {52, 4, 55, 29, 0}, + {53, 29, 56, 29, 1}, + {49, 29, 51, 29, 1}, + {48, 29, 55, 29, 1}, + {39, 4, 43, 29, 0}, + {38, 4, 39, 4, 1}, + {36, 4, 40, 29, 0}, + {50, 29, 52, 29, 1}, + {63, 1, 64, 6, 1}, + {60, 0, 61, 5, 1}, + {42, 4, 45, 29, 0}, + {37, 4, 40, 29, 0}, + {51, 29, 54, 29, 1}, + {61, 0, 62, 5, 1}, + {61, 2, 62, 7, 1}, + {50, 6, 51, 1, 0}, + {48, 6, 50, 6, 0}, + {43, 4, 46, 29, 0}, + {51, 29, 54, 29, 1}, + {35, 4, 39, 29, 0}, + {62, 0, 63, 5, 1}, + {35, 3, 39, 28, 0}, + {52, 4, 55, 29, 0}, + {36, 4, 40, 29, 0}, + {53, 29, 56, 29, 1}, + {63, 0, 64, 5, 1}, + {36, 3, 40, 28, 0}, + {35, 30, 40, 28, 1}, + {53, 29, 56, 29, 1}, + {56, 29, 57, 29, 0}, + {53, 4, 56, 29, 0}, + {37, 4, 41, 29, 0}, + {37, 3, 41, 28, 0}, + {36, 30, 41, 28, 1}, + {53, 6, 54, 1, 0}, + {51, 6, 53, 6, 0}, + {50, 1, 54, 1, 1}, + {37, 5, 41, 30, 0}, + {36, 0, 41, 30, 1}, + {52, 4, 55, 29, 0}, + {57, 29, 58, 29, 0}, + {54, 4, 57, 29, 0}, + {38, 4, 42, 29, 0}, + {55, 29, 58, 29, 1}, + {38, 3, 42, 28, 0}, + {37, 30, 42, 28, 1}, + {54, 6, 55, 1, 0}, + {52, 6, 54, 6, 0}, + {51, 1, 55, 1, 1}, + {38, 5, 42, 30, 0}, + {37, 0, 42, 30, 1}, + {42, 4, 45, 29, 0}, + {58, 29, 59, 29, 0}, + {56, 29, 59, 29, 1}, + {55, 4, 58, 29, 0}, + {53, 4, 56, 29, 0}, + {39, 4, 43, 29, 0}, + {39, 3, 43, 28, 0}, + {38, 30, 43, 28, 1}, + {55, 6, 56, 1, 0}, + {53, 6, 55, 6, 0}, + {52, 1, 56, 1, 1}, + {39, 5, 43, 30, 0}, + {43, 4, 46, 29, 0}, + {56, 4, 59, 29, 0}, + {56, 29, 59, 29, 1}, + {56, 29, 57, 29, 0}, + {54, 4, 57, 29, 0}, + {36, 4, 38, 4, 1}, + {59, 29, 60, 29, 0}, + {40, 3, 44, 28, 0}, + {40, 4, 44, 29, 0}, + {39, 30, 44, 28, 1}, + {37, 4, 40, 29, 0}, + {37, 4, 39, 4, 1}, + {57, 29, 58, 29, 0}, + {55, 4, 58, 29, 0}, + {58, 29, 61, 29, 1}, + {57, 4, 61, 29, 0}, + {41, 3, 45, 28, 0}, + {41, 4, 45, 29, 0}, + {38, 4, 40, 4, 1}, + {58, 29, 59, 29, 0}, + {56, 4, 59, 29, 0}, + {36, 4, 38, 4, 1}, + {58, 4, 62, 29, 0}, + {42, 3, 46, 28, 0}, + {42, 4, 46, 29, 0}, + {37, 4, 40, 29, 0}, + {39, 4, 41, 4, 1}, + {37, 4, 39, 4, 1}, + {59, 4, 63, 29, 0}, + {57, 4, 59, 29, 0}, + {43, 3, 47, 28, 0}, + {43, 4, 47, 29, 0}, + {52, 4, 55, 29, 0}, + {40, 4, 42, 4, 1}, + {38, 4, 40, 4, 1}, + {60, 4, 64, 29, 0}, + {44, 3, 48, 28, 0}, + {44, 4, 48, 29, 0}, +} + +// tailSpansNEON locates each DV's checks in tailChecksNEON. +var tailSpansNEON = [32]tailSpan{ + {0, 6}, + {6, 6}, + {12, 5}, + {17, 5}, + {22, 2}, + {24, 5}, + {29, 2}, + {31, 5}, + {36, 1}, + {37, 5}, + {42, 3}, + {45, 5}, + {50, 3}, + {53, 6}, + {59, 4}, + {63, 7}, + {70, 4}, + {74, 4}, + {78, 3}, + {81, 5}, + {86, 6}, + {92, 6}, + {98, 5}, + {103, 7}, + {110, 5}, + {115, 8}, + {123, 4}, + {127, 10}, + {137, 8}, + {145, 7}, + {152, 7}, + {159, 6}, +} diff --git a/vendor/google.golang.org/api/internal/version.go b/vendor/google.golang.org/api/internal/version.go index 34b9fea722..86a2bddf25 100644 --- a/vendor/google.golang.org/api/internal/version.go +++ b/vendor/google.golang.org/api/internal/version.go @@ -5,4 +5,4 @@ package internal // Version is the current tagged release of the library. -const Version = "0.316.0" +const Version = "0.317.0" diff --git a/vendor/google.golang.org/api/option/internaloption/unsaferesolver.go b/vendor/google.golang.org/api/option/internaloption/unsaferesolver.go index 7c5012772b..87e884aa20 100644 --- a/vendor/google.golang.org/api/option/internaloption/unsaferesolver.go +++ b/vendor/google.golang.org/api/option/internaloption/unsaferesolver.go @@ -113,3 +113,15 @@ func (ur *UnsafeResolver) ResolvedEnableDirectPathXdsOverInterconnect() bool { func (ur *UnsafeResolver) ResolvedWithoutAuthentication() bool { return ur.ds.NoAuth } + +// ResolvedUniverseDomain returns the resolved universe domain with the +// following precedence: +// +// 1. A non-empty option.WithUniverseDomain. +// 2. A non-empty environment variable GOOGLE_CLOUD_UNIVERSE_DOMAIN. +// 3. The default value "googleapis.com". +// +// This is an EXPERIMENTAL API and may be changed or removed in the future. +func (ur *UnsafeResolver) ResolvedUniverseDomain() string { + return ur.ds.GetUniverseDomain() +} diff --git a/vendor/k8s.io/apimachinery/third_party/forked/golang/reflect/deep_equal.go b/vendor/k8s.io/apimachinery/third_party/forked/golang/reflect/deep_equal.go index bb0fa55f21..58a23b00bb 100644 --- a/vendor/k8s.io/apimachinery/third_party/forked/golang/reflect/deep_equal.go +++ b/vendor/k8s.io/apimachinery/third_party/forked/golang/reflect/deep_equal.go @@ -199,7 +199,7 @@ func (e Equalities) deepValueEqual(v1, v2 reflect.Value, visited map[visit]bool, return v1.IsNil() == v2.IsNil() } return e.deepValueEqual(v1.Elem(), v2.Elem(), visited, equateNilAndEmpty, depth+1) - case reflect.Ptr: + case reflect.Pointer: return e.deepValueEqual(v1.Elem(), v2.Elem(), visited, equateNilAndEmpty, depth+1) case reflect.Struct: for i, n := 0, v1.NumField(); i < n; i++ { diff --git a/vendor/k8s.io/client-go/tools/clientcmd/api/helpers.go b/vendor/k8s.io/client-go/tools/clientcmd/api/helpers.go index 261dcacb5b..d97a3d835a 100644 --- a/vendor/k8s.io/client-go/tools/clientcmd/api/helpers.go +++ b/vendor/k8s.io/client-go/tools/clientcmd/api/helpers.go @@ -202,7 +202,7 @@ func redactSecrets(curr reflect.Value, redact bool) error { } actualCurrValue := curr - if curr.Kind() == reflect.Ptr { + if curr.Kind() == reflect.Pointer { actualCurrValue = curr.Elem() } diff --git a/vendor/modules.txt b/vendor/modules.txt index e8b794336d..983b2b4209 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,4 +1,4 @@ -# cloud.google.com/go/auth v0.24.4 +# cloud.google.com/go/auth v0.24.5 ## explicit; go 1.26.0 cloud.google.com/go/auth cloud.google.com/go/auth/credentials @@ -77,7 +77,7 @@ github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources/v4 # github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armsubscriptions/v2 v2.0.0 ## explicit; go 1.25.0 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armsubscriptions/v2 -# github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.8.3 +# github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.8.4 ## explicit; go 1.25.0 github.com/Azure/azure-sdk-for-go/sdk/storage/azblob github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/appendblob @@ -294,7 +294,7 @@ github.com/aws/amazon-ec2-instance-selector/v3/pkg/instancetypes github.com/aws/amazon-ec2-instance-selector/v3/pkg/selector github.com/aws/amazon-ec2-instance-selector/v3/pkg/selector/outputs github.com/aws/amazon-ec2-instance-selector/v3/pkg/sorter -# github.com/aws/aws-sdk-go-v2 v1.48.0 +# github.com/aws/aws-sdk-go-v2 v1.49.0 ## explicit; go 1.24 github.com/aws/aws-sdk-go-v2/aws github.com/aws/aws-sdk-go-v2/aws/arn @@ -321,15 +321,15 @@ github.com/aws/aws-sdk-go-v2/internal/strings github.com/aws/aws-sdk-go-v2/internal/sync/singleflight github.com/aws/aws-sdk-go-v2/internal/timeconv github.com/aws/aws-sdk-go-v2/internal/timeouts -# github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.27 +# github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.29 ## explicit; go 1.24 github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream/eventstreamapi -# github.com/aws/aws-sdk-go-v2/config v1.33.21 +# github.com/aws/aws-sdk-go-v2/config v1.33.25 ## explicit; go 1.24 github.com/aws/aws-sdk-go-v2/config github.com/aws/aws-sdk-go-v2/config/internal/ini -# github.com/aws/aws-sdk-go-v2/credentials v1.21.3 +# github.com/aws/aws-sdk-go-v2/credentials v1.21.7 ## explicit; go 1.24 github.com/aws/aws-sdk-go-v2/credentials github.com/aws/aws-sdk-go-v2/credentials/ec2rolecreds @@ -339,17 +339,17 @@ github.com/aws/aws-sdk-go-v2/credentials/logincreds github.com/aws/aws-sdk-go-v2/credentials/processcreds github.com/aws/aws-sdk-go-v2/credentials/ssocreds github.com/aws/aws-sdk-go-v2/credentials/stscreds -# github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.20.9 +# github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.20.12 ## explicit; go 1.24 github.com/aws/aws-sdk-go-v2/feature/ec2/imds github.com/aws/aws-sdk-go-v2/feature/ec2/imds/internal/config -# github.com/aws/aws-sdk-go-v2/internal/configsources v1.5.12 +# github.com/aws/aws-sdk-go-v2/internal/configsources v1.5.15 ## explicit; go 1.24 github.com/aws/aws-sdk-go-v2/internal/configsources -# github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.8.12 +# github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.8.15 ## explicit; go 1.24 github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 -# github.com/aws/aws-sdk-go-v2/internal/v4a v1.5.12 +# github.com/aws/aws-sdk-go-v2/internal/v4a v1.5.15 ## explicit; go 1.24 github.com/aws/aws-sdk-go-v2/internal/v4a github.com/aws/aws-sdk-go-v2/internal/v4a/internal/crypto @@ -359,7 +359,7 @@ github.com/aws/aws-sdk-go-v2/internal/v4a/internal/v4 github.com/aws/aws-sdk-go-v2/service/ec2 github.com/aws/aws-sdk-go-v2/service/ec2/internal/endpoints github.com/aws/aws-sdk-go-v2/service/ec2/types -# github.com/aws/aws-sdk-go-v2/service/ecs v1.106.0 +# github.com/aws/aws-sdk-go-v2/service/ecs v1.106.3 ## explicit; go 1.24 github.com/aws/aws-sdk-go-v2/service/ecs github.com/aws/aws-sdk-go-v2/service/ecs/document @@ -373,13 +373,13 @@ github.com/aws/aws-sdk-go-v2/service/eks github.com/aws/aws-sdk-go-v2/service/eks/internal/endpoints github.com/aws/aws-sdk-go-v2/service/eks/schemas github.com/aws/aws-sdk-go-v2/service/eks/types -# github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing v1.42.0 +# github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing v1.42.3 ## explicit; go 1.24 github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing/internal/endpoints github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing/schemas github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing/types -# github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2 v1.65.0 +# github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2 v1.65.3 ## explicit; go 1.24 github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2 github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2/internal/endpoints @@ -391,21 +391,21 @@ github.com/aws/aws-sdk-go-v2/service/iam github.com/aws/aws-sdk-go-v2/service/iam/internal/endpoints github.com/aws/aws-sdk-go-v2/service/iam/schemas github.com/aws/aws-sdk-go-v2/service/iam/types -# github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.25 +# github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.27 ## explicit; go 1.24 github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding -# github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.11.13 +# github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.11.16 ## explicit; go 1.24 github.com/aws/aws-sdk-go-v2/service/internal/checksum -# github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.14.12 +# github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.14.15 ## explicit; go 1.24 github.com/aws/aws-sdk-go-v2/service/internal/presigned-url -# github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.20.12 +# github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.20.15 ## explicit; go 1.24 github.com/aws/aws-sdk-go-v2/service/internal/s3shared github.com/aws/aws-sdk-go-v2/service/internal/s3shared/arn github.com/aws/aws-sdk-go-v2/service/internal/s3shared/config -# github.com/aws/aws-sdk-go-v2/service/pricing v1.51.6 +# github.com/aws/aws-sdk-go-v2/service/pricing v1.51.9 ## explicit; go 1.24 github.com/aws/aws-sdk-go-v2/service/pricing github.com/aws/aws-sdk-go-v2/service/pricing/internal/endpoints @@ -418,31 +418,31 @@ github.com/aws/aws-sdk-go-v2/service/s3/internal/arn github.com/aws/aws-sdk-go-v2/service/s3/internal/customizations github.com/aws/aws-sdk-go-v2/service/s3/internal/endpoints github.com/aws/aws-sdk-go-v2/service/s3/types -# github.com/aws/aws-sdk-go-v2/service/signin v1.14.0 +# github.com/aws/aws-sdk-go-v2/service/signin v1.14.3 ## explicit; go 1.24 github.com/aws/aws-sdk-go-v2/service/signin github.com/aws/aws-sdk-go-v2/service/signin/internal/endpoints github.com/aws/aws-sdk-go-v2/service/signin/schemas github.com/aws/aws-sdk-go-v2/service/signin/types -# github.com/aws/aws-sdk-go-v2/service/sso v1.39.5 +# github.com/aws/aws-sdk-go-v2/service/sso v1.39.8 ## explicit; go 1.24 github.com/aws/aws-sdk-go-v2/service/sso github.com/aws/aws-sdk-go-v2/service/sso/internal/endpoints github.com/aws/aws-sdk-go-v2/service/sso/schemas github.com/aws/aws-sdk-go-v2/service/sso/types -# github.com/aws/aws-sdk-go-v2/service/ssooidc v1.44.5 +# github.com/aws/aws-sdk-go-v2/service/ssooidc v1.44.8 ## explicit; go 1.24 github.com/aws/aws-sdk-go-v2/service/ssooidc github.com/aws/aws-sdk-go-v2/service/ssooidc/internal/endpoints github.com/aws/aws-sdk-go-v2/service/ssooidc/schemas github.com/aws/aws-sdk-go-v2/service/ssooidc/types -# github.com/aws/aws-sdk-go-v2/service/sts v1.53.0 +# github.com/aws/aws-sdk-go-v2/service/sts v1.54.0 ## explicit; go 1.24 github.com/aws/aws-sdk-go-v2/service/sts github.com/aws/aws-sdk-go-v2/service/sts/internal/endpoints github.com/aws/aws-sdk-go-v2/service/sts/schemas github.com/aws/aws-sdk-go-v2/service/sts/types -# github.com/aws/smithy-go v1.28.9 +# github.com/aws/smithy-go v1.28.13 ## explicit; go 1.24 github.com/aws/smithy-go github.com/aws/smithy-go/auth @@ -645,7 +645,7 @@ github.com/go-git/go-billy/v6/helper/polyfill github.com/go-git/go-billy/v6/memfs github.com/go-git/go-billy/v6/osfs github.com/go-git/go-billy/v6/util -# github.com/go-git/go-git/v6 v6.0.0-beta.1 +# github.com/go-git/go-git/v6 v6.0.0-beta.2 ## explicit; go 1.26.0 github.com/go-git/go-git/v6 github.com/go-git/go-git/v6/config @@ -656,6 +656,7 @@ github.com/go-git/go-git/v6/internal/reference github.com/go-git/go-git/v6/internal/repository github.com/go-git/go-git/v6/internal/revision github.com/go-git/go-git/v6/internal/sharedfile +github.com/go-git/go-git/v6/internal/sync github.com/go-git/go-git/v6/internal/transport github.com/go-git/go-git/v6/internal/url github.com/go-git/go-git/v6/plumbing @@ -702,7 +703,6 @@ github.com/go-git/go-git/v6/utils/merkletrie/filesystem github.com/go-git/go-git/v6/utils/merkletrie/index github.com/go-git/go-git/v6/utils/merkletrie/internal/frame github.com/go-git/go-git/v6/utils/merkletrie/noder -github.com/go-git/go-git/v6/utils/sync github.com/go-git/go-git/v6/utils/trace github.com/go-git/go-git/v6/x/fdpool github.com/go-git/go-git/v6/x/plugin @@ -761,51 +761,51 @@ github.com/go-openapi/runtime/server-middleware/docui github.com/go-openapi/runtime/server-middleware/mediatype github.com/go-openapi/runtime/server-middleware/negotiate github.com/go-openapi/runtime/server-middleware/negotiate/header -# github.com/go-openapi/spec v1.0.1 +# github.com/go-openapi/spec v1.0.2 ## explicit; go 1.26.0 github.com/go-openapi/spec -# github.com/go-openapi/strfmt v0.27.4 +# github.com/go-openapi/strfmt v0.27.5 ## explicit; go 1.26.0 github.com/go-openapi/strfmt github.com/go-openapi/strfmt/internal/bsonlite github.com/go-openapi/strfmt/internal/countries -# github.com/go-openapi/swag v0.29.2 +# github.com/go-openapi/swag v0.29.3 ## explicit; go 1.26.0 github.com/go-openapi/swag -# github.com/go-openapi/swag/cmdutils v0.29.2 +# github.com/go-openapi/swag/cmdutils v0.29.3 ## explicit; go 1.26.0 github.com/go-openapi/swag/cmdutils -# github.com/go-openapi/swag/conv v0.29.2 +# github.com/go-openapi/swag/conv v0.29.3 ## explicit; go 1.26.0 github.com/go-openapi/swag/conv -# github.com/go-openapi/swag/fileutils v0.29.2 +# github.com/go-openapi/swag/fileutils v0.29.3 ## explicit; go 1.26.0 github.com/go-openapi/swag/fileutils -# github.com/go-openapi/swag/jsonutils v0.29.2 +# github.com/go-openapi/swag/jsonutils v0.29.3 ## explicit; go 1.26.0 github.com/go-openapi/swag/jsonutils github.com/go-openapi/swag/jsonutils/adapters github.com/go-openapi/swag/jsonutils/adapters/ifaces github.com/go-openapi/swag/jsonutils/adapters/stdlib/json -# github.com/go-openapi/swag/loading v0.29.2 +# github.com/go-openapi/swag/loading v0.29.3 ## explicit; go 1.26.0 github.com/go-openapi/swag/loading -# github.com/go-openapi/swag/mangling v0.29.2 +# github.com/go-openapi/swag/mangling v0.29.3 ## explicit; go 1.26.0 github.com/go-openapi/swag/mangling -# github.com/go-openapi/swag/netutils v0.29.2 +# github.com/go-openapi/swag/netutils v0.29.3 ## explicit; go 1.26.0 github.com/go-openapi/swag/netutils -# github.com/go-openapi/swag/pools v0.29.2 +# github.com/go-openapi/swag/pools v0.29.3 ## explicit; go 1.26.0 github.com/go-openapi/swag/pools -# github.com/go-openapi/swag/stringutils v0.29.2 +# github.com/go-openapi/swag/stringutils v0.29.3 ## explicit; go 1.26.0 github.com/go-openapi/swag/stringutils -# github.com/go-openapi/swag/typeutils v0.29.2 +# github.com/go-openapi/swag/typeutils v0.29.3 ## explicit; go 1.26.0 github.com/go-openapi/swag/typeutils -# github.com/go-openapi/swag/yamlutils v0.29.2 +# github.com/go-openapi/swag/yamlutils v0.29.3 ## explicit; go 1.26.0 github.com/go-openapi/swag/yamlutils # github.com/go-openapi/validate v1.0.3 @@ -899,7 +899,7 @@ github.com/google/s2a-go/stream # github.com/google/uuid v1.6.0 ## explicit github.com/google/uuid -# github.com/googleapis/enterprise-certificate-proxy v0.3.25 +# github.com/googleapis/enterprise-certificate-proxy v0.3.26 ## explicit; go 1.25.0 github.com/googleapis/enterprise-certificate-proxy/client github.com/googleapis/enterprise-certificate-proxy/client/util @@ -1064,7 +1064,7 @@ github.com/pierrec/lz4/v4/internal/lz4block github.com/pierrec/lz4/v4/internal/lz4errors github.com/pierrec/lz4/v4/internal/lz4stream github.com/pierrec/lz4/v4/internal/xxh32 -# github.com/pjbgf/sha1cd v0.7.0 +# github.com/pjbgf/sha1cd v0.8.0 ## explicit; go 1.24.0 github.com/pjbgf/sha1cd github.com/pjbgf/sha1cd/internal @@ -1745,7 +1745,7 @@ golang.org/x/tools/internal/pkgbits golang.org/x/tools/internal/stdlib golang.org/x/tools/internal/typesinternal golang.org/x/tools/internal/versions -# google.golang.org/api v0.316.0 +# google.golang.org/api v0.317.0 ## explicit; go 1.26.0 google.golang.org/api/compute/v0.beta google.golang.org/api/compute/v1 @@ -1763,7 +1763,7 @@ google.golang.org/api/transport/http # google.golang.org/genproto/googleapis/api v0.0.0-20261116203732-fd2c7689a808 ## explicit; go 1.26.0 google.golang.org/genproto/googleapis/api/httpbody -# google.golang.org/genproto/googleapis/rpc v0.0.0-20261116203732-fd2c7689a808 +# google.golang.org/genproto/googleapis/rpc v0.0.0-20261118221215-c8830f628b3f ## explicit; go 1.26.0 google.golang.org/genproto/googleapis/rpc/code google.golang.org/genproto/googleapis/rpc/errdetails @@ -1893,7 +1893,7 @@ gopkg.in/tomb.v1 # gopkg.in/yaml.v3 v3.0.1 ## explicit gopkg.in/yaml.v3 -# k8s.io/apimachinery v0.37.2 +# k8s.io/apimachinery v0.37.3 ## explicit; go 1.26.0 k8s.io/apimachinery/pkg/api/errors k8s.io/apimachinery/pkg/api/meta @@ -1936,7 +1936,7 @@ k8s.io/apimachinery/pkg/util/yaml k8s.io/apimachinery/pkg/version k8s.io/apimachinery/pkg/watch k8s.io/apimachinery/third_party/forked/golang/reflect -# k8s.io/client-go v0.37.2 +# k8s.io/client-go v0.37.3 ## explicit; go 1.26.0 k8s.io/client-go/dynamic k8s.io/client-go/features