mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-05-18 00:47:48 +08:00
vendor: update buildkit to master@d5c1d785b042
Signed-off-by: Justin Chadwell <me@jedevc.com>
This commit is contained in:
parent
7838ade9f3
commit
adc839aa40
@ -15,7 +15,7 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/containerd/containerd/log"
|
"github.com/containerd/log"
|
||||||
"github.com/docker/buildx/build"
|
"github.com/docker/buildx/build"
|
||||||
cbuild "github.com/docker/buildx/controller/build"
|
cbuild "github.com/docker/buildx/controller/build"
|
||||||
"github.com/docker/buildx/controller/control"
|
"github.com/docker/buildx/controller/control"
|
||||||
|
23
go.mod
23
go.mod
@ -7,8 +7,9 @@ require (
|
|||||||
github.com/aws/aws-sdk-go-v2/config v1.18.16
|
github.com/aws/aws-sdk-go-v2/config v1.18.16
|
||||||
github.com/compose-spec/compose-go v1.20.0
|
github.com/compose-spec/compose-go v1.20.0
|
||||||
github.com/containerd/console v1.0.3
|
github.com/containerd/console v1.0.3
|
||||||
github.com/containerd/containerd v1.7.2
|
github.com/containerd/containerd v1.7.7
|
||||||
github.com/containerd/continuity v0.4.1
|
github.com/containerd/continuity v0.4.2
|
||||||
|
github.com/containerd/log v0.1.0
|
||||||
github.com/containerd/typeurl/v2 v2.1.1
|
github.com/containerd/typeurl/v2 v2.1.1
|
||||||
github.com/creack/pty v1.1.18
|
github.com/creack/pty v1.1.18
|
||||||
github.com/distribution/reference v0.5.0
|
github.com/distribution/reference v0.5.0
|
||||||
@ -23,12 +24,12 @@ require (
|
|||||||
github.com/google/uuid v1.3.0
|
github.com/google/uuid v1.3.0
|
||||||
github.com/hashicorp/go-cty-funcs v0.0.0-20230405223818-a090f58aa992
|
github.com/hashicorp/go-cty-funcs v0.0.0-20230405223818-a090f58aa992
|
||||||
github.com/hashicorp/hcl/v2 v2.19.1
|
github.com/hashicorp/hcl/v2 v2.19.1
|
||||||
github.com/moby/buildkit v0.12.1-0.20230927072102-4c89091c5d9e
|
github.com/moby/buildkit v0.13.0-beta1.0.20231023114302-d5c1d785b042
|
||||||
github.com/moby/sys/mountinfo v0.6.2
|
github.com/moby/sys/mountinfo v0.6.2
|
||||||
github.com/moby/sys/signal v0.7.0
|
github.com/moby/sys/signal v0.7.0
|
||||||
github.com/morikuni/aec v1.0.0
|
github.com/morikuni/aec v1.0.0
|
||||||
github.com/opencontainers/go-digest v1.0.0
|
github.com/opencontainers/go-digest v1.0.0
|
||||||
github.com/opencontainers/image-spec v1.1.0-rc3
|
github.com/opencontainers/image-spec v1.1.0-rc5
|
||||||
github.com/pelletier/go-toml v1.9.5
|
github.com/pelletier/go-toml v1.9.5
|
||||||
github.com/pkg/errors v0.9.1
|
github.com/pkg/errors v0.9.1
|
||||||
github.com/serialx/hashring v0.0.0-20190422032157-8b2912629002
|
github.com/serialx/hashring v0.0.0-20190422032157-8b2912629002
|
||||||
@ -41,7 +42,7 @@ require (
|
|||||||
go.opentelemetry.io/otel/trace v1.14.0
|
go.opentelemetry.io/otel/trace v1.14.0
|
||||||
golang.org/x/mod v0.11.0
|
golang.org/x/mod v0.11.0
|
||||||
golang.org/x/sync v0.3.0
|
golang.org/x/sync v0.3.0
|
||||||
golang.org/x/term v0.8.0
|
golang.org/x/term v0.13.0
|
||||||
google.golang.org/grpc v1.53.0
|
google.golang.org/grpc v1.53.0
|
||||||
gopkg.in/yaml.v3 v3.0.1
|
gopkg.in/yaml.v3 v3.0.1
|
||||||
k8s.io/api v0.26.7
|
k8s.io/api v0.26.7
|
||||||
@ -51,9 +52,10 @@ require (
|
|||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230106234847-43070de90fa1 // indirect
|
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 // indirect
|
||||||
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
|
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
|
||||||
github.com/Microsoft/go-winio v0.6.1 // indirect
|
github.com/Microsoft/go-winio v0.6.1 // indirect
|
||||||
|
github.com/Microsoft/hcsshim v0.11.1 // indirect
|
||||||
github.com/Shopify/logrus-bugsnag v0.0.0-20171204204709-577dee27f20d // indirect
|
github.com/Shopify/logrus-bugsnag v0.0.0-20171204204709-577dee27f20d // indirect
|
||||||
github.com/agext/levenshtein v1.2.3 // indirect
|
github.com/agext/levenshtein v1.2.3 // indirect
|
||||||
github.com/apparentlymart/go-cidr v1.0.1 // indirect
|
github.com/apparentlymart/go-cidr v1.0.1 // indirect
|
||||||
@ -73,7 +75,6 @@ require (
|
|||||||
github.com/cenkalti/backoff/v4 v4.2.0 // indirect
|
github.com/cenkalti/backoff/v4 v4.2.0 // indirect
|
||||||
github.com/cespare/xxhash/v2 v2.2.0 // indirect
|
github.com/cespare/xxhash/v2 v2.2.0 // indirect
|
||||||
github.com/containerd/ttrpc v1.2.2 // indirect
|
github.com/containerd/ttrpc v1.2.2 // indirect
|
||||||
github.com/cyphar/filepath-securejoin v0.2.3 // indirect
|
|
||||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
github.com/docker/distribution v2.8.2+incompatible // indirect
|
github.com/docker/distribution v2.8.2+incompatible // indirect
|
||||||
github.com/docker/docker-credential-helpers v0.7.0 // indirect
|
github.com/docker/docker-credential-helpers v0.7.0 // indirect
|
||||||
@ -141,12 +142,12 @@ require (
|
|||||||
go.opentelemetry.io/otel/metric v0.37.0 // indirect
|
go.opentelemetry.io/otel/metric v0.37.0 // indirect
|
||||||
go.opentelemetry.io/otel/sdk v1.14.0 // indirect
|
go.opentelemetry.io/otel/sdk v1.14.0 // indirect
|
||||||
go.opentelemetry.io/proto/otlp v0.19.0 // indirect
|
go.opentelemetry.io/proto/otlp v0.19.0 // indirect
|
||||||
golang.org/x/crypto v0.2.0 // indirect
|
golang.org/x/crypto v0.14.0 // indirect
|
||||||
golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1 // indirect
|
golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1 // indirect
|
||||||
golang.org/x/net v0.10.0 // indirect
|
golang.org/x/net v0.17.0 // indirect
|
||||||
golang.org/x/oauth2 v0.5.0 // indirect
|
golang.org/x/oauth2 v0.5.0 // indirect
|
||||||
golang.org/x/sys v0.8.0 // indirect
|
golang.org/x/sys v0.13.0 // indirect
|
||||||
golang.org/x/text v0.11.0 // indirect
|
golang.org/x/text v0.13.0 // indirect
|
||||||
golang.org/x/time v0.3.0 // indirect
|
golang.org/x/time v0.3.0 // indirect
|
||||||
golang.org/x/tools v0.7.0 // indirect
|
golang.org/x/tools v0.7.0 // indirect
|
||||||
google.golang.org/appengine v1.6.7 // indirect
|
google.golang.org/appengine v1.6.7 // indirect
|
||||||
|
49
go.sum
49
go.sum
@ -34,9 +34,9 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl
|
|||||||
cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
|
cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
|
||||||
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
|
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
|
||||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||||
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230106234847-43070de90fa1 h1:EKPd1INOIyr5hWOWhvpmQpY6tKjeG0hT1s3AMC/9fic=
|
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 h1:bvDV9vkmnHYOMsOr4WLk+Vo07yKIzd94sVoIqshQ4bU=
|
||||||
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230106234847-43070de90fa1/go.mod h1:VzwV+t+dZ9j/H867F1M2ziD+yLHtB46oM35FxxMJ4d0=
|
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24/go.mod h1:8o94RPi1/7XTJvwPpRSzSUedZrtlirdB3r9Z20bi2f8=
|
||||||
github.com/AdamKorcz/go-118-fuzz-build v0.0.0-20221215162035-5330a85ea652 h1:+vTEFqeoeur6XSq06bs+roX3YiT49gUniJK7Zky7Xjg=
|
github.com/AdamKorcz/go-118-fuzz-build v0.0.0-20230306123547-8075edf89bb0 h1:59MxjQVfjXsBpLy+dbd2/ELV5ofnUkUZBvWSC85sheA=
|
||||||
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8=
|
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8=
|
||||||
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E=
|
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E=
|
||||||
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
|
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
|
||||||
@ -46,7 +46,8 @@ github.com/Masterminds/semver/v3 v3.2.1 h1:RN9w6+7QoMeJVGyfmbcgs28Br8cvmnucEXnY0
|
|||||||
github.com/Masterminds/semver/v3 v3.2.1/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ=
|
github.com/Masterminds/semver/v3 v3.2.1/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ=
|
||||||
github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow=
|
github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow=
|
||||||
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
|
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
|
||||||
github.com/Microsoft/hcsshim v0.10.0-rc.8 h1:YSZVvlIIDD1UxQpJp0h+dnpLUw+TrY0cx8obKsp3bek=
|
github.com/Microsoft/hcsshim v0.11.1 h1:hJ3s7GbWlGK4YVV92sO88BQSyF4ZLVy7/awqOlPxFbA=
|
||||||
|
github.com/Microsoft/hcsshim v0.11.1/go.mod h1:nFJmaO4Zr5Y7eADdFOpYswDDlNVbvcIJJNJLECr5JQg=
|
||||||
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
|
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
|
||||||
github.com/Shopify/logrus-bugsnag v0.0.0-20170309145241-6dbc35f2c30d/go.mod h1:HI8ITrYtUY+O+ZhtlqUnD8+KwNPOyugEhfP9fdUIaEQ=
|
github.com/Shopify/logrus-bugsnag v0.0.0-20170309145241-6dbc35f2c30d/go.mod h1:HI8ITrYtUY+O+ZhtlqUnD8+KwNPOyugEhfP9fdUIaEQ=
|
||||||
github.com/Shopify/logrus-bugsnag v0.0.0-20171204204709-577dee27f20d h1:UrqY+r/OJnIp5u0s1SbQ8dVfLCZJsnvazdBP5hS4iRs=
|
github.com/Shopify/logrus-bugsnag v0.0.0-20171204204709-577dee27f20d h1:UrqY+r/OJnIp5u0s1SbQ8dVfLCZJsnvazdBP5hS4iRs=
|
||||||
@ -128,11 +129,13 @@ github.com/compose-spec/compose-go v1.20.0/go.mod h1:+MdqXV4RA7wdFsahh/Kb8U0pAJq
|
|||||||
github.com/containerd/cgroups v1.1.0 h1:v8rEWFl6EoqHB+swVNjVoCJE8o3jX7e8nqBGPLaDFBM=
|
github.com/containerd/cgroups v1.1.0 h1:v8rEWFl6EoqHB+swVNjVoCJE8o3jX7e8nqBGPLaDFBM=
|
||||||
github.com/containerd/console v1.0.3 h1:lIr7SlA5PxZyMV30bDW0MGbiOPXwc63yRuCP0ARubLw=
|
github.com/containerd/console v1.0.3 h1:lIr7SlA5PxZyMV30bDW0MGbiOPXwc63yRuCP0ARubLw=
|
||||||
github.com/containerd/console v1.0.3/go.mod h1:7LqA/THxQ86k76b8c/EMSiaJ3h1eZkMkXar0TQ1gf3U=
|
github.com/containerd/console v1.0.3/go.mod h1:7LqA/THxQ86k76b8c/EMSiaJ3h1eZkMkXar0TQ1gf3U=
|
||||||
github.com/containerd/containerd v1.7.2 h1:UF2gdONnxO8I6byZXDi5sXWiWvlW3D/sci7dTQimEJo=
|
github.com/containerd/containerd v1.7.7 h1:QOC2K4A42RQpcrZyptP6z9EJZnlHfHJUfZrAAHe15q4=
|
||||||
github.com/containerd/containerd v1.7.2/go.mod h1:afcz74+K10M/+cjGHIVQrCt3RAQhUSCAjJ9iMYhhkuI=
|
github.com/containerd/containerd v1.7.7/go.mod h1:3c4XZv6VeT9qgf9GMTxNTMFxGJrGpI2vz1yk4ye+YY8=
|
||||||
github.com/containerd/continuity v0.4.1 h1:wQnVrjIyQ8vhU2sgOiL5T07jo+ouqc2bnKsv5/EqGhU=
|
github.com/containerd/continuity v0.4.2 h1:v3y/4Yz5jwnvqPKJJ+7Wf93fyWoCB3F5EclWG023MDM=
|
||||||
github.com/containerd/continuity v0.4.1/go.mod h1:F6PTNCKepoxEaXLQp3wDAjygEnImnZ/7o4JzpodfroQ=
|
github.com/containerd/continuity v0.4.2/go.mod h1:F6PTNCKepoxEaXLQp3wDAjygEnImnZ/7o4JzpodfroQ=
|
||||||
github.com/containerd/fifo v1.1.0 h1:4I2mbh5stb1u6ycIABlBw9zgtlK8viPI9QkQNRQEEmY=
|
github.com/containerd/fifo v1.1.0 h1:4I2mbh5stb1u6ycIABlBw9zgtlK8viPI9QkQNRQEEmY=
|
||||||
|
github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I=
|
||||||
|
github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo=
|
||||||
github.com/containerd/nydus-snapshotter v0.8.2 h1:7SOrMU2YmLzfbsr5J7liMZJlNi5WT6vtIOxLGv+iz7E=
|
github.com/containerd/nydus-snapshotter v0.8.2 h1:7SOrMU2YmLzfbsr5J7liMZJlNi5WT6vtIOxLGv+iz7E=
|
||||||
github.com/containerd/stargz-snapshotter v0.14.3 h1:OTUVZoPSPs8mGgmQUE1dqw3WX/3nrsmsurW7UPLWl1U=
|
github.com/containerd/stargz-snapshotter v0.14.3 h1:OTUVZoPSPs8mGgmQUE1dqw3WX/3nrsmsurW7UPLWl1U=
|
||||||
github.com/containerd/stargz-snapshotter/estargz v0.14.3 h1:OqlDCK3ZVUO6C3B/5FSkDwbkEETK84kQgEeFwDC+62k=
|
github.com/containerd/stargz-snapshotter/estargz v0.14.3 h1:OqlDCK3ZVUO6C3B/5FSkDwbkEETK84kQgEeFwDC+62k=
|
||||||
@ -144,8 +147,6 @@ github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46t
|
|||||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||||
github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY=
|
github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY=
|
||||||
github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
|
github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
|
||||||
github.com/cyphar/filepath-securejoin v0.2.3 h1:YX6ebbZCZP7VkM3scTTokDgBL2TY741X51MTk3ycuNI=
|
|
||||||
github.com/cyphar/filepath-securejoin v0.2.3/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4=
|
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
@ -384,8 +385,8 @@ github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZX
|
|||||||
github.com/mitchellh/mapstructure v0.0.0-20150613213606-2caf8efc9366/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
github.com/mitchellh/mapstructure v0.0.0-20150613213606-2caf8efc9366/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||||
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
|
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
|
||||||
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||||
github.com/moby/buildkit v0.12.1-0.20230927072102-4c89091c5d9e h1:ExWnVOk8e5qONwLuPAJ3f04zsg1iqGgKSXbKTl/bEOE=
|
github.com/moby/buildkit v0.13.0-beta1.0.20231023114302-d5c1d785b042 h1:1J+fRIucIeyl1gvSYOlTcN0gmsZ8SMlLdkwB01PEn94=
|
||||||
github.com/moby/buildkit v0.12.1-0.20230927072102-4c89091c5d9e/go.mod h1:oSHnUZH7sNtAFLyeN1syf46SuzMThKsCQaioNEqJVUk=
|
github.com/moby/buildkit v0.13.0-beta1.0.20231023114302-d5c1d785b042/go.mod h1:3sbzGMUHhpx+6++efVlHhvcarzusX1+QbGTR/S4y9gI=
|
||||||
github.com/moby/locker v1.0.1 h1:fOXqR41zeveg4fFODix+1Ch4mj/gT0NE1XJbp/epuBg=
|
github.com/moby/locker v1.0.1 h1:fOXqR41zeveg4fFODix+1Ch4mj/gT0NE1XJbp/epuBg=
|
||||||
github.com/moby/locker v1.0.1/go.mod h1:S7SDdo5zpBK84bzzVlKr2V0hz+7x9hWbYC/kq7oQppc=
|
github.com/moby/locker v1.0.1/go.mod h1:S7SDdo5zpBK84bzzVlKr2V0hz+7x9hWbYC/kq7oQppc=
|
||||||
github.com/moby/patternmatcher v0.6.0 h1:GmP9lR19aU5GqSSFko+5pRqHi+Ohk1O69aFiKkVGiPk=
|
github.com/moby/patternmatcher v0.6.0 h1:GmP9lR19aU5GqSSFko+5pRqHi+Ohk1O69aFiKkVGiPk=
|
||||||
@ -424,8 +425,8 @@ github.com/opencontainers/go-digest v0.0.0-20170106003457-a6d0ee40d420/go.mod h1
|
|||||||
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
|
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
|
||||||
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
|
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
|
||||||
github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0=
|
github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0=
|
||||||
github.com/opencontainers/image-spec v1.1.0-rc3 h1:fzg1mXZFj8YdPeNkRXMg+zb88BFV0Ys52cJydRwBkb8=
|
github.com/opencontainers/image-spec v1.1.0-rc5 h1:Ygwkfw9bpDvs+c9E34SdgGOj41dX/cbdlwvlWt0pnFI=
|
||||||
github.com/opencontainers/image-spec v1.1.0-rc3/go.mod h1:X4pATf0uXsnn3g5aiGIsVnJBR4mxhKzfwmvK/B2NTm8=
|
github.com/opencontainers/image-spec v1.1.0-rc5/go.mod h1:X4pATf0uXsnn3g5aiGIsVnJBR4mxhKzfwmvK/B2NTm8=
|
||||||
github.com/opencontainers/runc v1.1.9 h1:XR0VIHTGce5eWPkaPesqTBrhW2yAcaraWfsEalNwQLM=
|
github.com/opencontainers/runc v1.1.9 h1:XR0VIHTGce5eWPkaPesqTBrhW2yAcaraWfsEalNwQLM=
|
||||||
github.com/opencontainers/runc v1.1.9/go.mod h1:CbUumNnWCuTGFukNXahoo/RFBZvDAgRh/smNYNOhA50=
|
github.com/opencontainers/runc v1.1.9/go.mod h1:CbUumNnWCuTGFukNXahoo/RFBZvDAgRh/smNYNOhA50=
|
||||||
github.com/opencontainers/runtime-spec v1.1.0-rc.2 h1:ucBtEms2tamYYW/SvGpvq9yUN0NEVL6oyLEwDcTSrk8=
|
github.com/opencontainers/runtime-spec v1.1.0-rc.2 h1:ucBtEms2tamYYW/SvGpvq9yUN0NEVL6oyLEwDcTSrk8=
|
||||||
@ -576,8 +577,8 @@ golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPh
|
|||||||
golang.org/x/crypto v0.0.0-20200422194213-44a606286825/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20200422194213-44a606286825/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/crypto v0.0.0-20201117144127-c1f2f97bffc9/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
golang.org/x/crypto v0.0.0-20201117144127-c1f2f97bffc9/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
||||||
golang.org/x/crypto v0.2.0 h1:BRXPfhNivWL5Yq0BGQ39a2sW6t44aODpfxkWjYdzewE=
|
golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
|
||||||
golang.org/x/crypto v0.2.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
|
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
|
||||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||||
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||||
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
|
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
|
||||||
@ -643,8 +644,8 @@ golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81R
|
|||||||
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||||
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
||||||
golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M=
|
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
|
||||||
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
|
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
|
||||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||||
@ -707,20 +708,20 @@ golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBc
|
|||||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
|
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
|
||||||
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
golang.org/x/term v0.8.0 h1:n5xxQn2i3PC0yLAbjTpNT85q/Kgzcr2gIoX9OrJUols=
|
golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek=
|
||||||
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
|
golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U=
|
||||||
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4=
|
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
|
||||||
golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||||
|
@ -8,9 +8,9 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/containerd/containerd/log"
|
|
||||||
"github.com/containerd/containerd/remotes"
|
"github.com/containerd/containerd/remotes"
|
||||||
"github.com/containerd/containerd/remotes/docker"
|
"github.com/containerd/containerd/remotes/docker"
|
||||||
|
"github.com/containerd/log"
|
||||||
"github.com/distribution/reference"
|
"github.com/distribution/reference"
|
||||||
"github.com/docker/buildx/util/resolver"
|
"github.com/docker/buildx/util/resolver"
|
||||||
clitypes "github.com/docker/cli/cli/config/types"
|
clitypes "github.com/docker/cli/cli/config/types"
|
||||||
|
247
vendor/github.com/AdaLogics/go-fuzz-headers/consumer.go
generated
vendored
247
vendor/github.com/AdaLogics/go-fuzz-headers/consumer.go
generated
vendored
@ -25,11 +25,10 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
securejoin "github.com/cyphar/filepath-securejoin"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -389,11 +388,11 @@ func (f *ConsumeFuzzer) GetUint16() (uint16, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (f *ConsumeFuzzer) GetUint32() (uint32, error) {
|
func (f *ConsumeFuzzer) GetUint32() (uint32, error) {
|
||||||
i, err := f.GetInt()
|
u32, err := f.GetNBytes(4)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return uint32(0), err
|
return 0, err
|
||||||
}
|
}
|
||||||
return uint32(i), nil
|
return binary.BigEndian.Uint32(u32), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *ConsumeFuzzer) GetUint64() (uint64, error) {
|
func (f *ConsumeFuzzer) GetUint64() (uint64, error) {
|
||||||
@ -412,26 +411,27 @@ func (f *ConsumeFuzzer) GetUint64() (uint64, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (f *ConsumeFuzzer) GetBytes() ([]byte, error) {
|
func (f *ConsumeFuzzer) GetBytes() ([]byte, error) {
|
||||||
if f.position >= f.dataTotal {
|
var length uint32
|
||||||
return nil, errors.New("not enough bytes to create byte array")
|
var err error
|
||||||
}
|
length, err = f.GetUint32()
|
||||||
length, err := f.GetUint32()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.New("not enough bytes to create byte array")
|
return nil, errors.New("not enough bytes to create byte array")
|
||||||
}
|
}
|
||||||
if f.position+length > MaxTotalLen {
|
|
||||||
return nil, errors.New("created too large a string")
|
|
||||||
}
|
|
||||||
byteBegin := f.position - 1
|
|
||||||
if byteBegin >= f.dataTotal {
|
|
||||||
return nil, errors.New("not enough bytes to create byte array")
|
|
||||||
}
|
|
||||||
if length == 0 {
|
if length == 0 {
|
||||||
return nil, errors.New("zero-length is not supported")
|
length = 30
|
||||||
}
|
}
|
||||||
if byteBegin+length >= f.dataTotal {
|
bytesLeft := f.dataTotal - f.position
|
||||||
|
if bytesLeft <= 0 {
|
||||||
return nil, errors.New("not enough bytes to create byte array")
|
return nil, errors.New("not enough bytes to create byte array")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the length is the same as bytes left, we will not overflow
|
||||||
|
// the remaining bytes.
|
||||||
|
if length != bytesLeft {
|
||||||
|
length = length % bytesLeft
|
||||||
|
}
|
||||||
|
byteBegin := f.position
|
||||||
if byteBegin+length < byteBegin {
|
if byteBegin+length < byteBegin {
|
||||||
return nil, errors.New("numbers overflow")
|
return nil, errors.New("numbers overflow")
|
||||||
}
|
}
|
||||||
@ -482,6 +482,7 @@ func (f *ConsumeFuzzer) FuzzMap(m interface{}) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func returnTarBytes(buf []byte) ([]byte, error) {
|
func returnTarBytes(buf []byte) ([]byte, error) {
|
||||||
|
return buf, nil
|
||||||
// Count files
|
// Count files
|
||||||
var fileCounter int
|
var fileCounter int
|
||||||
tr := tar.NewReader(bytes.NewReader(buf))
|
tr := tar.NewReader(bytes.NewReader(buf))
|
||||||
@ -504,7 +505,8 @@ func returnTarBytes(buf []byte) ([]byte, error) {
|
|||||||
func setTarHeaderFormat(hdr *tar.Header, f *ConsumeFuzzer) error {
|
func setTarHeaderFormat(hdr *tar.Header, f *ConsumeFuzzer) error {
|
||||||
ind, err := f.GetInt()
|
ind, err := f.GetInt()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
hdr.Format = tar.FormatGNU
|
||||||
|
//return nil
|
||||||
}
|
}
|
||||||
switch ind % 4 {
|
switch ind % 4 {
|
||||||
case 0:
|
case 0:
|
||||||
@ -565,71 +567,17 @@ func setTarHeaderTypeflag(hdr *tar.Header, f *ConsumeFuzzer) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func tooSmallFileBody(length uint32) bool {
|
|
||||||
if length < 2 {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
if length < 4 {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
if length < 10 {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
if length < 100 {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
if length < 500 {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
if length < 1000 {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
if length < 2000 {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
if length < 4000 {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
if length < 8000 {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
if length < 16000 {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
if length < 32000 {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
if length < 64000 {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
if length < 128000 {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
if length < 264000 {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (f *ConsumeFuzzer) createTarFileBody() ([]byte, error) {
|
func (f *ConsumeFuzzer) createTarFileBody() ([]byte, error) {
|
||||||
length, err := f.GetUint32()
|
return f.GetBytes()
|
||||||
|
/*length, err := f.GetUint32()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.New("not enough bytes to create byte array")
|
return nil, errors.New("not enough bytes to create byte array")
|
||||||
}
|
}
|
||||||
|
|
||||||
shouldUseLargeFileBody, err := f.GetBool()
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.New("not enough bytes to check long file body")
|
|
||||||
}
|
|
||||||
|
|
||||||
if shouldUseLargeFileBody && tooSmallFileBody(length) {
|
|
||||||
return nil, errors.New("File body was too small")
|
|
||||||
}
|
|
||||||
|
|
||||||
// A bit of optimization to attempt to create a file body
|
// A bit of optimization to attempt to create a file body
|
||||||
// when we don't have as many bytes left as "length"
|
// when we don't have as many bytes left as "length"
|
||||||
remainingBytes := f.dataTotal - f.position
|
remainingBytes := f.dataTotal - f.position
|
||||||
if remainingBytes == 0 {
|
if remainingBytes <= 0 {
|
||||||
return nil, errors.New("created too large a string")
|
return nil, errors.New("created too large a string")
|
||||||
}
|
}
|
||||||
if f.position+length > MaxTotalLen {
|
if f.position+length > MaxTotalLen {
|
||||||
@ -649,14 +597,15 @@ func (f *ConsumeFuzzer) createTarFileBody() ([]byte, error) {
|
|||||||
return nil, errors.New("numbers overflow")
|
return nil, errors.New("numbers overflow")
|
||||||
}
|
}
|
||||||
f.position = byteBegin + length
|
f.position = byteBegin + length
|
||||||
return f.data[byteBegin:f.position], nil
|
return f.data[byteBegin:f.position], nil*/
|
||||||
}
|
}
|
||||||
|
|
||||||
// getTarFileName is similar to GetString(), but creates string based
|
// getTarFileName is similar to GetString(), but creates string based
|
||||||
// on the length of f.data to reduce the likelihood of overflowing
|
// on the length of f.data to reduce the likelihood of overflowing
|
||||||
// f.data.
|
// f.data.
|
||||||
func (f *ConsumeFuzzer) getTarFilename() (string, error) {
|
func (f *ConsumeFuzzer) getTarFilename() (string, error) {
|
||||||
length, err := f.GetUint32()
|
return f.GetString()
|
||||||
|
/*length, err := f.GetUint32()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "nil", errors.New("not enough bytes to create string")
|
return "nil", errors.New("not enough bytes to create string")
|
||||||
}
|
}
|
||||||
@ -664,14 +613,9 @@ func (f *ConsumeFuzzer) getTarFilename() (string, error) {
|
|||||||
// A bit of optimization to attempt to create a file name
|
// A bit of optimization to attempt to create a file name
|
||||||
// when we don't have as many bytes left as "length"
|
// when we don't have as many bytes left as "length"
|
||||||
remainingBytes := f.dataTotal - f.position
|
remainingBytes := f.dataTotal - f.position
|
||||||
if remainingBytes == 0 {
|
if remainingBytes <= 0 {
|
||||||
return "nil", errors.New("created too large a string")
|
return "nil", errors.New("created too large a string")
|
||||||
}
|
}
|
||||||
if remainingBytes < 50 {
|
|
||||||
length = length % remainingBytes
|
|
||||||
} else if f.dataTotal < 500 {
|
|
||||||
length = length % f.dataTotal
|
|
||||||
}
|
|
||||||
if f.position > MaxTotalLen {
|
if f.position > MaxTotalLen {
|
||||||
return "nil", errors.New("created too large a string")
|
return "nil", errors.New("created too large a string")
|
||||||
}
|
}
|
||||||
@ -686,7 +630,12 @@ func (f *ConsumeFuzzer) getTarFilename() (string, error) {
|
|||||||
return "nil", errors.New("numbers overflow")
|
return "nil", errors.New("numbers overflow")
|
||||||
}
|
}
|
||||||
f.position = byteBegin + length
|
f.position = byteBegin + length
|
||||||
return string(f.data[byteBegin:f.position]), nil
|
return string(f.data[byteBegin:f.position]), nil*/
|
||||||
|
}
|
||||||
|
|
||||||
|
type TarFile struct {
|
||||||
|
Hdr *tar.Header
|
||||||
|
Body []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
// TarBytes returns valid bytes for a tar archive
|
// TarBytes returns valid bytes for a tar archive
|
||||||
@ -695,28 +644,38 @@ func (f *ConsumeFuzzer) TarBytes() ([]byte, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
var tarFiles []*TarFile
|
||||||
|
tarFiles = make([]*TarFile, 0)
|
||||||
|
|
||||||
var buf bytes.Buffer
|
const maxNoOfFiles = 100
|
||||||
tw := tar.NewWriter(&buf)
|
|
||||||
defer tw.Close()
|
|
||||||
|
|
||||||
const maxNoOfFiles = 1000
|
|
||||||
for i := 0; i < numberOfFiles%maxNoOfFiles; i++ {
|
for i := 0; i < numberOfFiles%maxNoOfFiles; i++ {
|
||||||
filename, err := f.getTarFilename()
|
var filename string
|
||||||
|
var filebody []byte
|
||||||
|
var sec, nsec int
|
||||||
|
var err error
|
||||||
|
|
||||||
|
filename, err = f.getTarFilename()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return returnTarBytes(buf.Bytes())
|
var sb strings.Builder
|
||||||
|
sb.WriteString("file-")
|
||||||
|
sb.WriteString(strconv.Itoa(i))
|
||||||
|
filename = sb.String()
|
||||||
}
|
}
|
||||||
filebody, err := f.createTarFileBody()
|
filebody, err = f.createTarFileBody()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return returnTarBytes(buf.Bytes())
|
var sb strings.Builder
|
||||||
|
sb.WriteString("filebody-")
|
||||||
|
sb.WriteString(strconv.Itoa(i))
|
||||||
|
filebody = []byte(sb.String())
|
||||||
}
|
}
|
||||||
sec, err := f.GetInt()
|
|
||||||
|
sec, err = f.GetInt()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return returnTarBytes(buf.Bytes())
|
sec = 1672531200 // beginning of 2023
|
||||||
}
|
}
|
||||||
nsec, err := f.GetInt()
|
nsec, err = f.GetInt()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return returnTarBytes(buf.Bytes())
|
nsec = 1703980800 // end of 2023
|
||||||
}
|
}
|
||||||
|
|
||||||
hdr := &tar.Header{
|
hdr := &tar.Header{
|
||||||
@ -726,21 +685,83 @@ func (f *ConsumeFuzzer) TarBytes() ([]byte, error) {
|
|||||||
ModTime: time.Unix(int64(sec), int64(nsec)),
|
ModTime: time.Unix(int64(sec), int64(nsec)),
|
||||||
}
|
}
|
||||||
if err := setTarHeaderTypeflag(hdr, f); err != nil {
|
if err := setTarHeaderTypeflag(hdr, f); err != nil {
|
||||||
return returnTarBytes(buf.Bytes())
|
return []byte(""), err
|
||||||
}
|
}
|
||||||
if err := setTarHeaderFormat(hdr, f); err != nil {
|
if err := setTarHeaderFormat(hdr, f); err != nil {
|
||||||
return returnTarBytes(buf.Bytes())
|
return []byte(""), err
|
||||||
}
|
}
|
||||||
if err := tw.WriteHeader(hdr); err != nil {
|
tf := &TarFile{
|
||||||
return returnTarBytes(buf.Bytes())
|
Hdr: hdr,
|
||||||
}
|
Body: filebody,
|
||||||
if _, err := tw.Write(filebody); err != nil {
|
|
||||||
return returnTarBytes(buf.Bytes())
|
|
||||||
}
|
}
|
||||||
|
tarFiles = append(tarFiles, tf)
|
||||||
|
}
|
||||||
|
|
||||||
|
var buf bytes.Buffer
|
||||||
|
tw := tar.NewWriter(&buf)
|
||||||
|
defer tw.Close()
|
||||||
|
|
||||||
|
for _, tf := range tarFiles {
|
||||||
|
tw.WriteHeader(tf.Hdr)
|
||||||
|
tw.Write(tf.Body)
|
||||||
}
|
}
|
||||||
return buf.Bytes(), nil
|
return buf.Bytes(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is similar to TarBytes, but it returns a series of
|
||||||
|
// files instead of raw tar bytes. The advantage of this
|
||||||
|
// api is that it is cheaper in terms of cpu power to
|
||||||
|
// modify or check the files in the fuzzer with TarFiles()
|
||||||
|
// because it avoids creating a tar reader.
|
||||||
|
func (f *ConsumeFuzzer) TarFiles() ([]*TarFile, error) {
|
||||||
|
numberOfFiles, err := f.GetInt()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
var tarFiles []*TarFile
|
||||||
|
tarFiles = make([]*TarFile, 0)
|
||||||
|
|
||||||
|
const maxNoOfFiles = 100
|
||||||
|
for i := 0; i < numberOfFiles%maxNoOfFiles; i++ {
|
||||||
|
filename, err := f.getTarFilename()
|
||||||
|
if err != nil {
|
||||||
|
return tarFiles, err
|
||||||
|
}
|
||||||
|
filebody, err := f.createTarFileBody()
|
||||||
|
if err != nil {
|
||||||
|
return tarFiles, err
|
||||||
|
}
|
||||||
|
|
||||||
|
sec, err := f.GetInt()
|
||||||
|
if err != nil {
|
||||||
|
return tarFiles, err
|
||||||
|
}
|
||||||
|
nsec, err := f.GetInt()
|
||||||
|
if err != nil {
|
||||||
|
return tarFiles, err
|
||||||
|
}
|
||||||
|
|
||||||
|
hdr := &tar.Header{
|
||||||
|
Name: filename,
|
||||||
|
Size: int64(len(filebody)),
|
||||||
|
Mode: 0o600,
|
||||||
|
ModTime: time.Unix(int64(sec), int64(nsec)),
|
||||||
|
}
|
||||||
|
if err := setTarHeaderTypeflag(hdr, f); err != nil {
|
||||||
|
hdr.Typeflag = tar.TypeReg
|
||||||
|
}
|
||||||
|
if err := setTarHeaderFormat(hdr, f); err != nil {
|
||||||
|
return tarFiles, err // should not happend
|
||||||
|
}
|
||||||
|
tf := &TarFile{
|
||||||
|
Hdr: hdr,
|
||||||
|
Body: filebody,
|
||||||
|
}
|
||||||
|
tarFiles = append(tarFiles, tf)
|
||||||
|
}
|
||||||
|
return tarFiles, nil
|
||||||
|
}
|
||||||
|
|
||||||
// CreateFiles creates pseudo-random files in rootDir.
|
// CreateFiles creates pseudo-random files in rootDir.
|
||||||
// It creates subdirs and places the files there.
|
// It creates subdirs and places the files there.
|
||||||
// It is the callers responsibility to ensure that
|
// It is the callers responsibility to ensure that
|
||||||
@ -767,10 +788,10 @@ func (f *ConsumeFuzzer) CreateFiles(rootDir string) error {
|
|||||||
return errors.New("could not get fileName")
|
return errors.New("could not get fileName")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fullFilePath, err := securejoin.SecureJoin(rootDir, fileName)
|
if strings.Contains(fileName, "..") || (len(fileName) > 0 && fileName[0] == 47) || strings.Contains(fileName, "\\") {
|
||||||
if err != nil {
|
continue
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
fullFilePath := filepath.Join(rootDir, fileName)
|
||||||
|
|
||||||
// Find the subdirectory of the file
|
// Find the subdirectory of the file
|
||||||
if subDir := filepath.Dir(fileName); subDir != "" && subDir != "." {
|
if subDir := filepath.Dir(fileName); subDir != "" && subDir != "." {
|
||||||
@ -778,20 +799,14 @@ func (f *ConsumeFuzzer) CreateFiles(rootDir string) error {
|
|||||||
if strings.Contains(subDir, "../") || (len(subDir) > 0 && subDir[0] == 47) || strings.Contains(subDir, "\\") {
|
if strings.Contains(subDir, "../") || (len(subDir) > 0 && subDir[0] == 47) || strings.Contains(subDir, "\\") {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
dirPath, err := securejoin.SecureJoin(rootDir, subDir)
|
dirPath := filepath.Join(rootDir, subDir)
|
||||||
if err != nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if _, err := os.Stat(dirPath); os.IsNotExist(err) {
|
if _, err := os.Stat(dirPath); os.IsNotExist(err) {
|
||||||
err2 := os.MkdirAll(dirPath, 0o777)
|
err2 := os.MkdirAll(dirPath, 0o777)
|
||||||
if err2 != nil {
|
if err2 != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fullFilePath, err = securejoin.SecureJoin(dirPath, fileName)
|
fullFilePath = filepath.Join(dirPath, fileName)
|
||||||
if err != nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// Create symlink
|
// Create symlink
|
||||||
createSymlink, err := f.GetBool()
|
createSymlink, err := f.GetBool()
|
||||||
|
21
vendor/github.com/Microsoft/hcsshim/LICENSE
generated
vendored
Normal file
21
vendor/github.com/Microsoft/hcsshim/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2015 Microsoft
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
59
vendor/github.com/Microsoft/hcsshim/osversion/osversion_windows.go
generated
vendored
Normal file
59
vendor/github.com/Microsoft/hcsshim/osversion/osversion_windows.go
generated
vendored
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
package osversion
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"sync"
|
||||||
|
|
||||||
|
"golang.org/x/sys/windows"
|
||||||
|
)
|
||||||
|
|
||||||
|
// OSVersion is a wrapper for Windows version information
|
||||||
|
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms724439(v=vs.85).aspx
|
||||||
|
type OSVersion struct {
|
||||||
|
Version uint32
|
||||||
|
MajorVersion uint8
|
||||||
|
MinorVersion uint8
|
||||||
|
Build uint16
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
osv OSVersion
|
||||||
|
once sync.Once
|
||||||
|
)
|
||||||
|
|
||||||
|
// Get gets the operating system version on Windows.
|
||||||
|
// The calling application must be manifested to get the correct version information.
|
||||||
|
func Get() OSVersion {
|
||||||
|
once.Do(func() {
|
||||||
|
var err error
|
||||||
|
osv = OSVersion{}
|
||||||
|
osv.Version, err = windows.GetVersion()
|
||||||
|
if err != nil {
|
||||||
|
// GetVersion never fails.
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
osv.MajorVersion = uint8(osv.Version & 0xFF)
|
||||||
|
osv.MinorVersion = uint8(osv.Version >> 8 & 0xFF)
|
||||||
|
osv.Build = uint16(osv.Version >> 16)
|
||||||
|
})
|
||||||
|
return osv
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build gets the build-number on Windows
|
||||||
|
// The calling application must be manifested to get the correct version information.
|
||||||
|
func Build() uint16 {
|
||||||
|
return Get().Build
|
||||||
|
}
|
||||||
|
|
||||||
|
// String returns the OSVersion formatted as a string. It implements the
|
||||||
|
// [fmt.Stringer] interface.
|
||||||
|
func (osv OSVersion) String() string {
|
||||||
|
return fmt.Sprintf("%d.%d.%d", osv.MajorVersion, osv.MinorVersion, osv.Build)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ToString returns the OSVersion formatted as a string.
|
||||||
|
//
|
||||||
|
// Deprecated: use [OSVersion.String].
|
||||||
|
func (osv OSVersion) ToString() string {
|
||||||
|
return osv.String()
|
||||||
|
}
|
35
vendor/github.com/Microsoft/hcsshim/osversion/platform_compat_windows.go
generated
vendored
Normal file
35
vendor/github.com/Microsoft/hcsshim/osversion/platform_compat_windows.go
generated
vendored
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
package osversion
|
||||||
|
|
||||||
|
// List of stable ABI compliant ltsc releases
|
||||||
|
// Note: List must be sorted in ascending order
|
||||||
|
var compatLTSCReleases = []uint16{
|
||||||
|
V21H2Server,
|
||||||
|
}
|
||||||
|
|
||||||
|
// CheckHostAndContainerCompat checks if given host and container
|
||||||
|
// OS versions are compatible.
|
||||||
|
// It includes support for stable ABI compliant versions as well.
|
||||||
|
// Every release after WS 2022 will support the previous ltsc
|
||||||
|
// container image. Stable ABI is in preview mode for windows 11 client.
|
||||||
|
// Refer: https://learn.microsoft.com/en-us/virtualization/windowscontainers/deploy-containers/version-compatibility?tabs=windows-server-2022%2Cwindows-10#windows-server-host-os-compatibility
|
||||||
|
func CheckHostAndContainerCompat(host, ctr OSVersion) bool {
|
||||||
|
// check major minor versions of host and guest
|
||||||
|
if host.MajorVersion != ctr.MajorVersion ||
|
||||||
|
host.MinorVersion != ctr.MinorVersion {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// If host is < WS 2022, exact version match is required
|
||||||
|
if host.Build < V21H2Server {
|
||||||
|
return host.Build == ctr.Build
|
||||||
|
}
|
||||||
|
|
||||||
|
var supportedLtscRelease uint16
|
||||||
|
for i := len(compatLTSCReleases) - 1; i >= 0; i-- {
|
||||||
|
if host.Build >= compatLTSCReleases[i] {
|
||||||
|
supportedLtscRelease = compatLTSCReleases[i]
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ctr.Build >= supportedLtscRelease && ctr.Build <= host.Build
|
||||||
|
}
|
84
vendor/github.com/Microsoft/hcsshim/osversion/windowsbuilds.go
generated
vendored
Normal file
84
vendor/github.com/Microsoft/hcsshim/osversion/windowsbuilds.go
generated
vendored
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
package osversion
|
||||||
|
|
||||||
|
// Windows Client and Server build numbers.
|
||||||
|
//
|
||||||
|
// See:
|
||||||
|
// https://learn.microsoft.com/en-us/windows/release-health/release-information
|
||||||
|
// https://learn.microsoft.com/en-us/windows/release-health/windows-server-release-info
|
||||||
|
// https://learn.microsoft.com/en-us/windows/release-health/windows11-release-information
|
||||||
|
const (
|
||||||
|
// RS1 (version 1607, codename "Redstone 1") corresponds to Windows Server
|
||||||
|
// 2016 (ltsc2016) and Windows 10 (Anniversary Update).
|
||||||
|
RS1 = 14393
|
||||||
|
// V1607 (version 1607, codename "Redstone 1") is an alias for [RS1].
|
||||||
|
V1607 = RS1
|
||||||
|
// LTSC2016 (Windows Server 2016) is an alias for [RS1].
|
||||||
|
LTSC2016 = RS1
|
||||||
|
|
||||||
|
// RS2 (version 1703, codename "Redstone 2") was a client-only update, and
|
||||||
|
// corresponds to Windows 10 (Creators Update).
|
||||||
|
RS2 = 15063
|
||||||
|
// V1703 (version 1703, codename "Redstone 2") is an alias for [RS2].
|
||||||
|
V1703 = RS2
|
||||||
|
|
||||||
|
// RS3 (version 1709, codename "Redstone 3") corresponds to Windows Server
|
||||||
|
// 1709 (Semi-Annual Channel (SAC)), and Windows 10 (Fall Creators Update).
|
||||||
|
RS3 = 16299
|
||||||
|
// V1709 (version 1709, codename "Redstone 3") is an alias for [RS3].
|
||||||
|
V1709 = RS3
|
||||||
|
|
||||||
|
// RS4 (version 1803, codename "Redstone 4") corresponds to Windows Server
|
||||||
|
// 1803 (Semi-Annual Channel (SAC)), and Windows 10 (April 2018 Update).
|
||||||
|
RS4 = 17134
|
||||||
|
// V1803 (version 1803, codename "Redstone 4") is an alias for [RS4].
|
||||||
|
V1803 = RS4
|
||||||
|
|
||||||
|
// RS5 (version 1809, codename "Redstone 5") corresponds to Windows Server
|
||||||
|
// 2019 (ltsc2019), and Windows 10 (October 2018 Update).
|
||||||
|
RS5 = 17763
|
||||||
|
// V1809 (version 1809, codename "Redstone 5") is an alias for [RS5].
|
||||||
|
V1809 = RS5
|
||||||
|
// LTSC2019 (Windows Server 2019) is an alias for [RS5].
|
||||||
|
LTSC2019 = RS5
|
||||||
|
|
||||||
|
// V19H1 (version 1903, codename 19H1) corresponds to Windows Server 1903 (semi-annual
|
||||||
|
// channel).
|
||||||
|
V19H1 = 18362
|
||||||
|
// V1903 (version 1903) is an alias for [V19H1].
|
||||||
|
V1903 = V19H1
|
||||||
|
|
||||||
|
// V19H2 (version 1909, codename 19H2) corresponds to Windows Server 1909 (semi-annual
|
||||||
|
// channel).
|
||||||
|
V19H2 = 18363
|
||||||
|
// V1909 (version 1909) is an alias for [V19H2].
|
||||||
|
V1909 = V19H2
|
||||||
|
|
||||||
|
// V20H1 (version 2004, codename 20H1) corresponds to Windows Server 2004 (semi-annual
|
||||||
|
// channel).
|
||||||
|
V20H1 = 19041
|
||||||
|
// V2004 (version 2004) is an alias for [V20H1].
|
||||||
|
V2004 = V20H1
|
||||||
|
|
||||||
|
// V20H2 corresponds to Windows Server 20H2 (semi-annual channel).
|
||||||
|
V20H2 = 19042
|
||||||
|
|
||||||
|
// V21H1 corresponds to Windows Server 21H1 (semi-annual channel).
|
||||||
|
V21H1 = 19043
|
||||||
|
|
||||||
|
// V21H2Win10 corresponds to Windows 10 (November 2021 Update).
|
||||||
|
V21H2Win10 = 19044
|
||||||
|
|
||||||
|
// V21H2Server corresponds to Windows Server 2022 (ltsc2022).
|
||||||
|
V21H2Server = 20348
|
||||||
|
// LTSC2022 (Windows Server 2022) is an alias for [V21H2Server]
|
||||||
|
LTSC2022 = V21H2Server
|
||||||
|
|
||||||
|
// V21H2Win11 corresponds to Windows 11 (original release).
|
||||||
|
V21H2Win11 = 22000
|
||||||
|
|
||||||
|
// V22H2Win10 corresponds to Windows 10 (2022 Update).
|
||||||
|
V22H2Win10 = 19045
|
||||||
|
|
||||||
|
// V22H2Win11 corresponds to Windows 11 (2022 Update).
|
||||||
|
V22H2Win11 = 22621
|
||||||
|
)
|
12
vendor/github.com/containerd/containerd/content/content.go
generated
vendored
12
vendor/github.com/containerd/containerd/content/content.go
generated
vendored
@ -87,9 +87,6 @@ type IngestManager interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Info holds content specific information
|
// Info holds content specific information
|
||||||
//
|
|
||||||
// TODO(stevvooe): Consider a very different name for this struct. Info is way
|
|
||||||
// to general. It also reads very weird in certain context, like pluralization.
|
|
||||||
type Info struct {
|
type Info struct {
|
||||||
Digest digest.Digest
|
Digest digest.Digest
|
||||||
Size int64
|
Size int64
|
||||||
@ -111,12 +108,17 @@ type Status struct {
|
|||||||
// WalkFunc defines the callback for a blob walk.
|
// WalkFunc defines the callback for a blob walk.
|
||||||
type WalkFunc func(Info) error
|
type WalkFunc func(Info) error
|
||||||
|
|
||||||
// Manager provides methods for inspecting, listing and removing content.
|
// InfoProvider provides info for content inspection.
|
||||||
type Manager interface {
|
type InfoProvider interface {
|
||||||
// Info will return metadata about content available in the content store.
|
// Info will return metadata about content available in the content store.
|
||||||
//
|
//
|
||||||
// If the content is not present, ErrNotFound will be returned.
|
// If the content is not present, ErrNotFound will be returned.
|
||||||
Info(ctx context.Context, dgst digest.Digest) (Info, error)
|
Info(ctx context.Context, dgst digest.Digest) (Info, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Manager provides methods for inspecting, listing and removing content.
|
||||||
|
type Manager interface {
|
||||||
|
InfoProvider
|
||||||
|
|
||||||
// Update updates mutable information related to content.
|
// Update updates mutable information related to content.
|
||||||
// If one or more fieldpaths are provided, only those
|
// If one or more fieldpaths are provided, only those
|
||||||
|
72
vendor/github.com/containerd/containerd/log/context.go
generated
vendored
72
vendor/github.com/containerd/containerd/log/context.go
generated
vendored
@ -1,72 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright The containerd Authors.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package log
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
|
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
// G is an alias for GetLogger.
|
|
||||||
//
|
|
||||||
// We may want to define this locally to a package to get package tagged log
|
|
||||||
// messages.
|
|
||||||
G = GetLogger
|
|
||||||
|
|
||||||
// L is an alias for the standard logger.
|
|
||||||
L = logrus.NewEntry(logrus.StandardLogger())
|
|
||||||
)
|
|
||||||
|
|
||||||
type (
|
|
||||||
loggerKey struct{}
|
|
||||||
|
|
||||||
// Fields type to pass to `WithFields`, alias from `logrus`.
|
|
||||||
Fields = logrus.Fields
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
// RFC3339NanoFixed is time.RFC3339Nano with nanoseconds padded using zeros to
|
|
||||||
// ensure the formatted time is always the same number of characters.
|
|
||||||
RFC3339NanoFixed = "2006-01-02T15:04:05.000000000Z07:00"
|
|
||||||
|
|
||||||
// TextFormat represents the text logging format
|
|
||||||
TextFormat = "text"
|
|
||||||
|
|
||||||
// JSONFormat represents the JSON logging format
|
|
||||||
JSONFormat = "json"
|
|
||||||
)
|
|
||||||
|
|
||||||
// WithLogger returns a new context with the provided logger. Use in
|
|
||||||
// combination with logger.WithField(s) for great effect.
|
|
||||||
func WithLogger(ctx context.Context, logger *logrus.Entry) context.Context {
|
|
||||||
e := logger.WithContext(ctx)
|
|
||||||
return context.WithValue(ctx, loggerKey{}, e)
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetLogger retrieves the current logger from the context. If no logger is
|
|
||||||
// available, the default logger is returned.
|
|
||||||
func GetLogger(ctx context.Context) *logrus.Entry {
|
|
||||||
logger := ctx.Value(loggerKey{})
|
|
||||||
|
|
||||||
if logger == nil {
|
|
||||||
return L.WithContext(ctx)
|
|
||||||
}
|
|
||||||
|
|
||||||
return logger.(*logrus.Entry)
|
|
||||||
}
|
|
149
vendor/github.com/containerd/containerd/log/context_deprecated.go
generated
vendored
Normal file
149
vendor/github.com/containerd/containerd/log/context_deprecated.go
generated
vendored
Normal file
@ -0,0 +1,149 @@
|
|||||||
|
/*
|
||||||
|
Copyright The containerd Authors.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package log
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/containerd/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
// G is a shorthand for [GetLogger].
|
||||||
|
//
|
||||||
|
// Deprecated: use [log.G].
|
||||||
|
var G = log.G
|
||||||
|
|
||||||
|
// L is an alias for the standard logger.
|
||||||
|
//
|
||||||
|
// Deprecated: use [log.L].
|
||||||
|
var L = log.L
|
||||||
|
|
||||||
|
// Fields type to pass to "WithFields".
|
||||||
|
//
|
||||||
|
// Deprecated: use [log.Fields].
|
||||||
|
type Fields = log.Fields
|
||||||
|
|
||||||
|
// Entry is a logging entry.
|
||||||
|
//
|
||||||
|
// Deprecated: use [log.Entry].
|
||||||
|
type Entry = log.Entry
|
||||||
|
|
||||||
|
// RFC3339NanoFixed is [time.RFC3339Nano] with nanoseconds padded using
|
||||||
|
// zeros to ensure the formatted time is always the same number of
|
||||||
|
// characters.
|
||||||
|
//
|
||||||
|
// Deprecated: use [log.RFC3339NanoFixed].
|
||||||
|
const RFC3339NanoFixed = log.RFC3339NanoFixed
|
||||||
|
|
||||||
|
// Level is a logging level.
|
||||||
|
//
|
||||||
|
// Deprecated: use [log.Level].
|
||||||
|
type Level = log.Level
|
||||||
|
|
||||||
|
// Supported log levels.
|
||||||
|
const (
|
||||||
|
// TraceLevel level.
|
||||||
|
//
|
||||||
|
// Deprecated: use [log.TraceLevel].
|
||||||
|
TraceLevel Level = log.TraceLevel
|
||||||
|
|
||||||
|
// DebugLevel level.
|
||||||
|
//
|
||||||
|
// Deprecated: use [log.DebugLevel].
|
||||||
|
DebugLevel Level = log.DebugLevel
|
||||||
|
|
||||||
|
// InfoLevel level.
|
||||||
|
//
|
||||||
|
// Deprecated: use [log.InfoLevel].
|
||||||
|
InfoLevel Level = log.InfoLevel
|
||||||
|
|
||||||
|
// WarnLevel level.
|
||||||
|
//
|
||||||
|
// Deprecated: use [log.WarnLevel].
|
||||||
|
WarnLevel Level = log.WarnLevel
|
||||||
|
|
||||||
|
// ErrorLevel level
|
||||||
|
//
|
||||||
|
// Deprecated: use [log.ErrorLevel].
|
||||||
|
ErrorLevel Level = log.ErrorLevel
|
||||||
|
|
||||||
|
// FatalLevel level.
|
||||||
|
//
|
||||||
|
// Deprecated: use [log.FatalLevel].
|
||||||
|
FatalLevel Level = log.FatalLevel
|
||||||
|
|
||||||
|
// PanicLevel level.
|
||||||
|
//
|
||||||
|
// Deprecated: use [log.PanicLevel].
|
||||||
|
PanicLevel Level = log.PanicLevel
|
||||||
|
)
|
||||||
|
|
||||||
|
// SetLevel sets log level globally. It returns an error if the given
|
||||||
|
// level is not supported.
|
||||||
|
//
|
||||||
|
// Deprecated: use [log.SetLevel].
|
||||||
|
func SetLevel(level string) error {
|
||||||
|
return log.SetLevel(level)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetLevel returns the current log level.
|
||||||
|
//
|
||||||
|
// Deprecated: use [log.GetLevel].
|
||||||
|
func GetLevel() log.Level {
|
||||||
|
return log.GetLevel()
|
||||||
|
}
|
||||||
|
|
||||||
|
// OutputFormat specifies a log output format.
|
||||||
|
//
|
||||||
|
// Deprecated: use [log.OutputFormat].
|
||||||
|
type OutputFormat = log.OutputFormat
|
||||||
|
|
||||||
|
// Supported log output formats.
|
||||||
|
const (
|
||||||
|
// TextFormat represents the text logging format.
|
||||||
|
//
|
||||||
|
// Deprecated: use [log.TextFormat].
|
||||||
|
TextFormat log.OutputFormat = "text"
|
||||||
|
|
||||||
|
// JSONFormat represents the JSON logging format.
|
||||||
|
//
|
||||||
|
// Deprecated: use [log.JSONFormat].
|
||||||
|
JSONFormat log.OutputFormat = "json"
|
||||||
|
)
|
||||||
|
|
||||||
|
// SetFormat sets the log output format.
|
||||||
|
//
|
||||||
|
// Deprecated: use [log.SetFormat].
|
||||||
|
func SetFormat(format OutputFormat) error {
|
||||||
|
return log.SetFormat(format)
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithLogger returns a new context with the provided logger. Use in
|
||||||
|
// combination with logger.WithField(s) for great effect.
|
||||||
|
//
|
||||||
|
// Deprecated: use [log.WithLogger].
|
||||||
|
func WithLogger(ctx context.Context, logger *log.Entry) context.Context {
|
||||||
|
return log.WithLogger(ctx, logger)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetLogger retrieves the current logger from the context. If no logger is
|
||||||
|
// available, the default logger is returned.
|
||||||
|
//
|
||||||
|
// Deprecated: use [log.GetLogger].
|
||||||
|
func GetLogger(ctx context.Context) *log.Entry {
|
||||||
|
return log.GetLogger(ctx)
|
||||||
|
}
|
26
vendor/github.com/containerd/containerd/platforms/defaults_windows.go
generated
vendored
26
vendor/github.com/containerd/containerd/platforms/defaults_windows.go
generated
vendored
@ -22,6 +22,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/Microsoft/hcsshim/osversion"
|
||||||
specs "github.com/opencontainers/image-spec/specs-go/v1"
|
specs "github.com/opencontainers/image-spec/specs-go/v1"
|
||||||
"golang.org/x/sys/windows"
|
"golang.org/x/sys/windows"
|
||||||
)
|
)
|
||||||
@ -50,15 +51,36 @@ func (m windowsmatcher) Match(p specs.Platform) bool {
|
|||||||
match := m.defaultMatcher.Match(p)
|
match := m.defaultMatcher.Match(p)
|
||||||
|
|
||||||
if match && m.OS == "windows" {
|
if match && m.OS == "windows" {
|
||||||
if strings.HasPrefix(p.OSVersion, m.osVersionPrefix) {
|
// HPC containers do not have OS version filled
|
||||||
|
if p.OSVersion == "" {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return p.OSVersion == ""
|
|
||||||
|
hostOsVersion := GetOsVersion(m.osVersionPrefix)
|
||||||
|
ctrOsVersion := GetOsVersion(p.OSVersion)
|
||||||
|
return osversion.CheckHostAndContainerCompat(hostOsVersion, ctrOsVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
return match
|
return match
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetOsVersion(osVersionPrefix string) osversion.OSVersion {
|
||||||
|
parts := strings.Split(osVersionPrefix, ".")
|
||||||
|
if len(parts) < 3 {
|
||||||
|
return osversion.OSVersion{}
|
||||||
|
}
|
||||||
|
|
||||||
|
majorVersion, _ := strconv.Atoi(parts[0])
|
||||||
|
minorVersion, _ := strconv.Atoi(parts[1])
|
||||||
|
buildNumber, _ := strconv.Atoi(parts[2])
|
||||||
|
|
||||||
|
return osversion.OSVersion{
|
||||||
|
MajorVersion: uint8(majorVersion),
|
||||||
|
MinorVersion: uint8(minorVersion),
|
||||||
|
Build: uint16(buildNumber),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Less sorts matched platforms in front of other platforms.
|
// Less sorts matched platforms in front of other platforms.
|
||||||
// For matched platforms, it puts platforms with larger revision
|
// For matched platforms, it puts platforms with larger revision
|
||||||
// number in front.
|
// number in front.
|
||||||
|
12
vendor/github.com/containerd/containerd/platforms/platforms.go
generated
vendored
12
vendor/github.com/containerd/containerd/platforms/platforms.go
generated
vendored
@ -196,6 +196,10 @@ func Parse(specifier string) (specs.Platform, error) {
|
|||||||
p.Variant = cpuVariant()
|
p.Variant = cpuVariant()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if p.OS == "windows" {
|
||||||
|
p.OSVersion = GetWindowsOsVersion()
|
||||||
|
}
|
||||||
|
|
||||||
return p, nil
|
return p, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,6 +222,10 @@ func Parse(specifier string) (specs.Platform, error) {
|
|||||||
p.Variant = ""
|
p.Variant = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if p.OS == "windows" {
|
||||||
|
p.OSVersion = GetWindowsOsVersion()
|
||||||
|
}
|
||||||
|
|
||||||
return p, nil
|
return p, nil
|
||||||
case 3:
|
case 3:
|
||||||
// we have a fully specified variant, this is rare
|
// we have a fully specified variant, this is rare
|
||||||
@ -227,6 +235,10 @@ func Parse(specifier string) (specs.Platform, error) {
|
|||||||
p.Variant = "v8"
|
p.Variant = "v8"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if p.OS == "windows" {
|
||||||
|
p.OSVersion = GetWindowsOsVersion()
|
||||||
|
}
|
||||||
|
|
||||||
return p, nil
|
return p, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
vendor/github.com/containerd/containerd/platforms/platforms_other.go
generated
vendored
4
vendor/github.com/containerd/containerd/platforms/platforms_other.go
generated
vendored
@ -28,3 +28,7 @@ func newDefaultMatcher(platform specs.Platform) Matcher {
|
|||||||
Platform: Normalize(platform),
|
Platform: Normalize(platform),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetWindowsOsVersion() string {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
8
vendor/github.com/containerd/containerd/platforms/platforms_windows.go
generated
vendored
8
vendor/github.com/containerd/containerd/platforms/platforms_windows.go
generated
vendored
@ -17,7 +17,10 @@
|
|||||||
package platforms
|
package platforms
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
specs "github.com/opencontainers/image-spec/specs-go/v1"
|
specs "github.com/opencontainers/image-spec/specs-go/v1"
|
||||||
|
"golang.org/x/sys/windows"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewMatcher returns a Windows matcher that will match on osVersionPrefix if
|
// NewMatcher returns a Windows matcher that will match on osVersionPrefix if
|
||||||
@ -32,3 +35,8 @@ func newDefaultMatcher(platform specs.Platform) Matcher {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetWindowsOsVersion() string {
|
||||||
|
major, minor, build := windows.RtlGetNtVersionNumbers()
|
||||||
|
return fmt.Sprintf("%d.%d.%d", major, minor, build)
|
||||||
|
}
|
||||||
|
13
vendor/github.com/containerd/containerd/remotes/docker/pusher.go
generated
vendored
13
vendor/github.com/containerd/containerd/remotes/docker/pusher.go
generated
vendored
@ -23,6 +23,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
@ -137,6 +138,9 @@ func (p dockerPusher) push(ctx context.Context, desc ocispec.Descriptor, ref str
|
|||||||
if exists {
|
if exists {
|
||||||
p.tracker.SetStatus(ref, Status{
|
p.tracker.SetStatus(ref, Status{
|
||||||
Committed: true,
|
Committed: true,
|
||||||
|
PushStatus: PushStatus{
|
||||||
|
Exists: true,
|
||||||
|
},
|
||||||
Status: content.Status{
|
Status: content.Status{
|
||||||
Ref: ref,
|
Ref: ref,
|
||||||
Total: desc.Size,
|
Total: desc.Size,
|
||||||
@ -164,6 +168,7 @@ func (p dockerPusher) push(ctx context.Context, desc ocispec.Descriptor, ref str
|
|||||||
// Start upload request
|
// Start upload request
|
||||||
req = p.request(host, http.MethodPost, "blobs", "uploads/")
|
req = p.request(host, http.MethodPost, "blobs", "uploads/")
|
||||||
|
|
||||||
|
mountedFrom := ""
|
||||||
var resp *http.Response
|
var resp *http.Response
|
||||||
if fromRepo := selectRepositoryMountCandidate(p.refspec, desc.Annotations); fromRepo != "" {
|
if fromRepo := selectRepositoryMountCandidate(p.refspec, desc.Annotations); fromRepo != "" {
|
||||||
preq := requestWithMountFrom(req, desc.Digest.String(), fromRepo)
|
preq := requestWithMountFrom(req, desc.Digest.String(), fromRepo)
|
||||||
@ -180,11 +185,14 @@ func (p dockerPusher) push(ctx context.Context, desc ocispec.Descriptor, ref str
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if resp.StatusCode == http.StatusUnauthorized {
|
switch resp.StatusCode {
|
||||||
|
case http.StatusUnauthorized:
|
||||||
log.G(ctx).Debugf("failed to mount from repository %s", fromRepo)
|
log.G(ctx).Debugf("failed to mount from repository %s", fromRepo)
|
||||||
|
|
||||||
resp.Body.Close()
|
resp.Body.Close()
|
||||||
resp = nil
|
resp = nil
|
||||||
|
case http.StatusCreated:
|
||||||
|
mountedFrom = path.Join(p.refspec.Hostname(), fromRepo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,6 +212,9 @@ func (p dockerPusher) push(ctx context.Context, desc ocispec.Descriptor, ref str
|
|||||||
case http.StatusCreated:
|
case http.StatusCreated:
|
||||||
p.tracker.SetStatus(ref, Status{
|
p.tracker.SetStatus(ref, Status{
|
||||||
Committed: true,
|
Committed: true,
|
||||||
|
PushStatus: PushStatus{
|
||||||
|
MountedFrom: mountedFrom,
|
||||||
|
},
|
||||||
Status: content.Status{
|
Status: content.Status{
|
||||||
Ref: ref,
|
Ref: ref,
|
||||||
Total: desc.Size,
|
Total: desc.Size,
|
||||||
|
39
vendor/github.com/containerd/containerd/remotes/docker/resolver.go
generated
vendored
39
vendor/github.com/containerd/containerd/remotes/docker/resolver.go
generated
vendored
@ -18,6 +18,7 @@ package docker
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"crypto/tls"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
@ -148,6 +149,9 @@ func NewResolver(options ResolverOptions) remotes.Resolver {
|
|||||||
|
|
||||||
if options.Headers == nil {
|
if options.Headers == nil {
|
||||||
options.Headers = make(http.Header)
|
options.Headers = make(http.Header)
|
||||||
|
} else {
|
||||||
|
// make a copy of the headers to avoid race due to concurrent map write
|
||||||
|
options.Headers = options.Headers.Clone()
|
||||||
}
|
}
|
||||||
if _, ok := options.Headers["User-Agent"]; !ok {
|
if _, ok := options.Headers["User-Agent"]; !ok {
|
||||||
options.Headers.Set("User-Agent", "containerd/"+version.Version)
|
options.Headers.Set("User-Agent", "containerd/"+version.Version)
|
||||||
@ -543,9 +547,10 @@ func (r *request) do(ctx context.Context) (*http.Response, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
req.Header = http.Header{} // headers need to be copied to avoid concurrent map access
|
if r.header == nil {
|
||||||
for k, v := range r.header {
|
req.Header = http.Header{}
|
||||||
req.Header[k] = v
|
} else {
|
||||||
|
req.Header = r.header.Clone() // headers need to be copied to avoid concurrent map access
|
||||||
}
|
}
|
||||||
if r.body != nil {
|
if r.body != nil {
|
||||||
body, err := r.body()
|
body, err := r.body()
|
||||||
@ -669,7 +674,7 @@ func requestFields(req *http.Request) log.Fields {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return log.Fields(fields)
|
return fields
|
||||||
}
|
}
|
||||||
|
|
||||||
func responseFields(resp *http.Response) log.Fields {
|
func responseFields(resp *http.Response) log.Fields {
|
||||||
@ -687,7 +692,7 @@ func responseFields(resp *http.Response) log.Fields {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return log.Fields(fields)
|
return fields
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsLocalhost checks if the registry host is local.
|
// IsLocalhost checks if the registry host is local.
|
||||||
@ -703,3 +708,27 @@ func IsLocalhost(host string) bool {
|
|||||||
ip := net.ParseIP(host)
|
ip := net.ParseIP(host)
|
||||||
return ip.IsLoopback()
|
return ip.IsLoopback()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HTTPFallback is an http.RoundTripper which allows fallback from https to http
|
||||||
|
// for registry endpoints with configurations for both http and TLS, such as
|
||||||
|
// defaulted localhost endpoints.
|
||||||
|
type HTTPFallback struct {
|
||||||
|
http.RoundTripper
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f HTTPFallback) RoundTrip(r *http.Request) (*http.Response, error) {
|
||||||
|
resp, err := f.RoundTripper.RoundTrip(r)
|
||||||
|
var tlsErr tls.RecordHeaderError
|
||||||
|
if errors.As(err, &tlsErr) && string(tlsErr.RecordHeader[:]) == "HTTP/" {
|
||||||
|
// server gave HTTP response to HTTPS client
|
||||||
|
plainHTTPUrl := *r.URL
|
||||||
|
plainHTTPUrl.Scheme = "http"
|
||||||
|
|
||||||
|
plainHTTPRequest := *r
|
||||||
|
plainHTTPRequest.URL = &plainHTTPUrl
|
||||||
|
|
||||||
|
return f.RoundTripper.RoundTrip(&plainHTTPRequest)
|
||||||
|
}
|
||||||
|
|
||||||
|
return resp, err
|
||||||
|
}
|
||||||
|
11
vendor/github.com/containerd/containerd/remotes/docker/status.go
generated
vendored
11
vendor/github.com/containerd/containerd/remotes/docker/status.go
generated
vendored
@ -36,6 +36,17 @@ type Status struct {
|
|||||||
|
|
||||||
// UploadUUID is used by the Docker registry to reference blob uploads
|
// UploadUUID is used by the Docker registry to reference blob uploads
|
||||||
UploadUUID string
|
UploadUUID string
|
||||||
|
|
||||||
|
// PushStatus contains status related to push.
|
||||||
|
PushStatus
|
||||||
|
}
|
||||||
|
|
||||||
|
type PushStatus struct {
|
||||||
|
// MountedFrom is the source content was cross-repo mounted from (empty if no cross-repo mount was performed).
|
||||||
|
MountedFrom string
|
||||||
|
|
||||||
|
// Exists indicates whether content already exists in the repository and wasn't uploaded.
|
||||||
|
Exists bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// StatusTracker to track status of operations
|
// StatusTracker to track status of operations
|
||||||
|
32
vendor/github.com/containerd/containerd/remotes/handlers.go
generated
vendored
32
vendor/github.com/containerd/containerd/remotes/handlers.go
generated
vendored
@ -204,8 +204,9 @@ func push(ctx context.Context, provider content.Provider, pusher Pusher, desc oc
|
|||||||
// Base handlers can be provided which will be called before any push specific
|
// Base handlers can be provided which will be called before any push specific
|
||||||
// handlers.
|
// handlers.
|
||||||
//
|
//
|
||||||
// If the passed in content.Provider is also a content.Manager then this will
|
// If the passed in content.Provider is also a content.InfoProvider (such as
|
||||||
// also annotate the distribution sources in the manager.
|
// content.Manager) then this will also annotate the distribution sources using
|
||||||
|
// labels prefixed with "containerd.io/distribution.source".
|
||||||
func PushContent(ctx context.Context, pusher Pusher, desc ocispec.Descriptor, store content.Provider, limiter *semaphore.Weighted, platform platforms.MatchComparer, wrapper func(h images.Handler) images.Handler) error {
|
func PushContent(ctx context.Context, pusher Pusher, desc ocispec.Descriptor, store content.Provider, limiter *semaphore.Weighted, platform platforms.MatchComparer, wrapper func(h images.Handler) images.Handler) error {
|
||||||
|
|
||||||
var m sync.Mutex
|
var m sync.Mutex
|
||||||
@ -234,7 +235,7 @@ func PushContent(ctx context.Context, pusher Pusher, desc ocispec.Descriptor, st
|
|||||||
platformFilterhandler := images.FilterPlatforms(images.ChildrenHandler(store), platform)
|
platformFilterhandler := images.FilterPlatforms(images.ChildrenHandler(store), platform)
|
||||||
|
|
||||||
var handler images.Handler
|
var handler images.Handler
|
||||||
if m, ok := store.(content.Manager); ok {
|
if m, ok := store.(content.InfoProvider); ok {
|
||||||
annotateHandler := annotateDistributionSourceHandler(platformFilterhandler, m)
|
annotateHandler := annotateDistributionSourceHandler(platformFilterhandler, m)
|
||||||
handler = images.Handlers(annotateHandler, filterHandler, pushHandler)
|
handler = images.Handlers(annotateHandler, filterHandler, pushHandler)
|
||||||
} else {
|
} else {
|
||||||
@ -344,14 +345,15 @@ func FilterManifestByPlatformHandler(f images.HandlerFunc, m platforms.Matcher)
|
|||||||
|
|
||||||
// annotateDistributionSourceHandler add distribution source label into
|
// annotateDistributionSourceHandler add distribution source label into
|
||||||
// annotation of config or blob descriptor.
|
// annotation of config or blob descriptor.
|
||||||
func annotateDistributionSourceHandler(f images.HandlerFunc, manager content.Manager) images.HandlerFunc {
|
func annotateDistributionSourceHandler(f images.HandlerFunc, provider content.InfoProvider) images.HandlerFunc {
|
||||||
return func(ctx context.Context, desc ocispec.Descriptor) ([]ocispec.Descriptor, error) {
|
return func(ctx context.Context, desc ocispec.Descriptor) ([]ocispec.Descriptor, error) {
|
||||||
children, err := f(ctx, desc)
|
children, err := f(ctx, desc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// only add distribution source for the config or blob data descriptor
|
// Distribution source is only used for config or blob but may be inherited from
|
||||||
|
// a manifest or manifest list
|
||||||
switch desc.MediaType {
|
switch desc.MediaType {
|
||||||
case images.MediaTypeDockerSchema2Manifest, ocispec.MediaTypeImageManifest,
|
case images.MediaTypeDockerSchema2Manifest, ocispec.MediaTypeImageManifest,
|
||||||
images.MediaTypeDockerSchema2ManifestList, ocispec.MediaTypeImageIndex:
|
images.MediaTypeDockerSchema2ManifestList, ocispec.MediaTypeImageIndex:
|
||||||
@ -359,12 +361,28 @@ func annotateDistributionSourceHandler(f images.HandlerFunc, manager content.Man
|
|||||||
return children, nil
|
return children, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// parentInfo can be used to inherit info for non-existent blobs
|
||||||
|
var parentInfo *content.Info
|
||||||
|
|
||||||
for i := range children {
|
for i := range children {
|
||||||
child := children[i]
|
child := children[i]
|
||||||
|
|
||||||
info, err := manager.Info(ctx, child.Digest)
|
info, err := provider.Info(ctx, child.Digest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
if !errdefs.IsNotFound(err) {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if parentInfo == nil {
|
||||||
|
pi, err := provider.Info(ctx, desc.Digest)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
parentInfo = &pi
|
||||||
|
}
|
||||||
|
// Blob may not exist locally, annotate with parent labels for cross repo
|
||||||
|
// mount or fetch. Parent sources may apply to all children since most
|
||||||
|
// registries enforce that children exist before the manifests.
|
||||||
|
info = *parentInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
for k, v := range info.Labels {
|
for k, v := range info.Labels {
|
||||||
|
2
vendor/github.com/containerd/containerd/version/version.go
generated
vendored
2
vendor/github.com/containerd/containerd/version/version.go
generated
vendored
@ -23,7 +23,7 @@ var (
|
|||||||
Package = "github.com/containerd/containerd"
|
Package = "github.com/containerd/containerd"
|
||||||
|
|
||||||
// Version holds the complete version number. Filled in at linking time.
|
// Version holds the complete version number. Filled in at linking time.
|
||||||
Version = "1.7.2+unknown"
|
Version = "1.7.7+unknown"
|
||||||
|
|
||||||
// Revision is filled with the VCS (e.g. git) revision being used to build
|
// Revision is filled with the VCS (e.g. git) revision being used to build
|
||||||
// the program at linking time.
|
// the program at linking time.
|
||||||
|
4
vendor/github.com/containerd/continuity/devices/mknod_freebsd.go
generated
vendored
4
vendor/github.com/containerd/continuity/devices/mknod_freebsd.go
generated
vendored
@ -1,5 +1,5 @@
|
|||||||
//go:build freebsd
|
//go:build freebsd || dragonfly
|
||||||
// +build freebsd
|
// +build freebsd dragonfly
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright The containerd Authors.
|
Copyright The containerd Authors.
|
||||||
|
4
vendor/github.com/containerd/continuity/driver/lchmod_unix.go
generated
vendored
4
vendor/github.com/containerd/continuity/driver/lchmod_unix.go
generated
vendored
@ -1,5 +1,5 @@
|
|||||||
//go:build darwin || freebsd || netbsd || openbsd || solaris
|
//go:build darwin || freebsd || netbsd || openbsd || dragonfly || solaris
|
||||||
// +build darwin freebsd netbsd openbsd solaris
|
// +build darwin freebsd netbsd openbsd dragonfly solaris
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright The containerd Authors.
|
Copyright The containerd Authors.
|
||||||
|
12
vendor/github.com/containerd/continuity/fs/copy.go
generated
vendored
12
vendor/github.com/containerd/continuity/fs/copy.go
generated
vendored
@ -18,20 +18,13 @@ package fs
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sync"
|
|
||||||
|
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
var bufferPool = &sync.Pool{
|
|
||||||
New: func() interface{} {
|
|
||||||
buffer := make([]byte, 32*1024)
|
|
||||||
return &buffer
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
// XAttrErrorHandler transform a non-nil xattr error.
|
// XAttrErrorHandler transform a non-nil xattr error.
|
||||||
// Return nil to ignore an error.
|
// Return nil to ignore an error.
|
||||||
// xattrKey can be empty for listxattr operation.
|
// xattrKey can be empty for listxattr operation.
|
||||||
@ -199,5 +192,6 @@ func openAndCopyFile(target, source string) error {
|
|||||||
}
|
}
|
||||||
defer tgt.Close()
|
defer tgt.Close()
|
||||||
|
|
||||||
return copyFileContent(tgt, src)
|
_, err = io.Copy(tgt, src)
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
46
vendor/github.com/containerd/continuity/fs/copy_linux.go
generated
vendored
46
vendor/github.com/containerd/continuity/fs/copy_linux.go
generated
vendored
@ -18,7 +18,6 @@ package fs
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
|
||||||
"os"
|
"os"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
@ -62,51 +61,6 @@ func copyFileInfo(fi os.FileInfo, src, name string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
const maxSSizeT = int64(^uint(0) >> 1)
|
|
||||||
|
|
||||||
func copyFileContent(dst, src *os.File) error {
|
|
||||||
st, err := src.Stat()
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("unable to stat source: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
size := st.Size()
|
|
||||||
first := true
|
|
||||||
srcFd := int(src.Fd())
|
|
||||||
dstFd := int(dst.Fd())
|
|
||||||
|
|
||||||
for size > 0 {
|
|
||||||
// Ensure that we are never trying to copy more than SSIZE_MAX at a
|
|
||||||
// time and at the same time avoids overflows when the file is larger
|
|
||||||
// than 4GB on 32-bit systems.
|
|
||||||
var copySize int
|
|
||||||
if size > maxSSizeT {
|
|
||||||
copySize = int(maxSSizeT)
|
|
||||||
} else {
|
|
||||||
copySize = int(size)
|
|
||||||
}
|
|
||||||
n, err := unix.CopyFileRange(srcFd, nil, dstFd, nil, copySize, 0)
|
|
||||||
if err != nil {
|
|
||||||
if (err != unix.ENOSYS && err != unix.EXDEV) || !first {
|
|
||||||
return fmt.Errorf("copy file range failed: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
buf := bufferPool.Get().(*[]byte)
|
|
||||||
_, err = io.CopyBuffer(dst, src, *buf)
|
|
||||||
bufferPool.Put(buf)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("userspace copy failed: %w", err)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
first = false
|
|
||||||
size -= int64(n)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func copyXAttrs(dst, src string, excludes map[string]struct{}, errorHandler XAttrErrorHandler) error {
|
func copyXAttrs(dst, src string, excludes map[string]struct{}, errorHandler XAttrErrorHandler) error {
|
||||||
xattrKeys, err := sysx.LListxattr(src)
|
xattrKeys, err := sysx.LListxattr(src)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
13
vendor/github.com/containerd/continuity/fs/copy_unix.go
generated
vendored
13
vendor/github.com/containerd/continuity/fs/copy_unix.go
generated
vendored
@ -1,5 +1,5 @@
|
|||||||
//go:build darwin || freebsd || openbsd || netbsd || solaris
|
//go:build darwin || freebsd || openbsd || netbsd || dragonfly || solaris
|
||||||
// +build darwin freebsd openbsd netbsd solaris
|
// +build darwin freebsd openbsd netbsd dragonfly solaris
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright The containerd Authors.
|
Copyright The containerd Authors.
|
||||||
@ -21,7 +21,6 @@ package fs
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
"syscall"
|
"syscall"
|
||||||
@ -61,14 +60,6 @@ func copyFileInfo(fi os.FileInfo, src, name string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func copyFileContent(dst, src *os.File) error {
|
|
||||||
buf := bufferPool.Get().(*[]byte)
|
|
||||||
_, err := io.CopyBuffer(dst, src, *buf)
|
|
||||||
bufferPool.Put(buf)
|
|
||||||
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func copyXAttrs(dst, src string, excludes map[string]struct{}, errorHandler XAttrErrorHandler) error {
|
func copyXAttrs(dst, src string, excludes map[string]struct{}, errorHandler XAttrErrorHandler) error {
|
||||||
xattrKeys, err := sysx.LListxattr(src)
|
xattrKeys, err := sysx.LListxattr(src)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
8
vendor/github.com/containerd/continuity/fs/copy_windows.go
generated
vendored
8
vendor/github.com/containerd/continuity/fs/copy_windows.go
generated
vendored
@ -19,7 +19,6 @@ package fs
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
winio "github.com/Microsoft/go-winio"
|
winio "github.com/Microsoft/go-winio"
|
||||||
@ -72,13 +71,6 @@ func copyFileInfo(fi os.FileInfo, src, name string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func copyFileContent(dst, src *os.File) error {
|
|
||||||
buf := bufferPool.Get().(*[]byte)
|
|
||||||
_, err := io.CopyBuffer(dst, src, *buf)
|
|
||||||
bufferPool.Put(buf)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func copyXAttrs(dst, src string, excludes map[string]struct{}, errorHandler XAttrErrorHandler) error {
|
func copyXAttrs(dst, src string, excludes map[string]struct{}, errorHandler XAttrErrorHandler) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
7
vendor/github.com/containerd/continuity/fs/fstest/file.go
generated
vendored
7
vendor/github.com/containerd/continuity/fs/fstest/file.go
generated
vendored
@ -65,7 +65,12 @@ func writeFileStream(name string, stream func() io.Reader, perm os.FileMode) App
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
err := f.Close()
|
err := f.Sync()
|
||||||
|
if err != nil && retErr == nil {
|
||||||
|
retErr = err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = f.Close()
|
||||||
if err != nil && retErr == nil {
|
if err != nil && retErr == nil {
|
||||||
retErr = err
|
retErr = err
|
||||||
}
|
}
|
||||||
|
4
vendor/github.com/containerd/continuity/fs/stat_atim.go
generated
vendored
4
vendor/github.com/containerd/continuity/fs/stat_atim.go
generated
vendored
@ -1,5 +1,5 @@
|
|||||||
//go:build linux || openbsd || solaris
|
//go:build linux || openbsd || dragonfly || solaris
|
||||||
// +build linux openbsd solaris
|
// +build linux openbsd dragonfly solaris
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright The containerd Authors.
|
Copyright The containerd Authors.
|
||||||
|
30
vendor/github.com/containerd/log/.golangci.yml
generated
vendored
Normal file
30
vendor/github.com/containerd/log/.golangci.yml
generated
vendored
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
linters:
|
||||||
|
enable:
|
||||||
|
- exportloopref # Checks for pointers to enclosing loop variables
|
||||||
|
- gofmt
|
||||||
|
- goimports
|
||||||
|
- gosec
|
||||||
|
- ineffassign
|
||||||
|
- misspell
|
||||||
|
- nolintlint
|
||||||
|
- revive
|
||||||
|
- staticcheck
|
||||||
|
- tenv # Detects using os.Setenv instead of t.Setenv since Go 1.17
|
||||||
|
- unconvert
|
||||||
|
- unused
|
||||||
|
- vet
|
||||||
|
- dupword # Checks for duplicate words in the source code
|
||||||
|
disable:
|
||||||
|
- errcheck
|
||||||
|
|
||||||
|
run:
|
||||||
|
timeout: 5m
|
||||||
|
skip-dirs:
|
||||||
|
- api
|
||||||
|
- cluster
|
||||||
|
- design
|
||||||
|
- docs
|
||||||
|
- docs/man
|
||||||
|
- releases
|
||||||
|
- reports
|
||||||
|
- test # e2e scripts
|
191
vendor/github.com/containerd/log/LICENSE
generated
vendored
Normal file
191
vendor/github.com/containerd/log/LICENSE
generated
vendored
Normal file
@ -0,0 +1,191 @@
|
|||||||
|
|
||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
https://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
Copyright The containerd Authors
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
17
vendor/github.com/containerd/log/README.md
generated
vendored
Normal file
17
vendor/github.com/containerd/log/README.md
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# log
|
||||||
|
|
||||||
|
A Go package providing a common logging interface across containerd repositories and a way for clients to use and configure logging in containerd packages.
|
||||||
|
|
||||||
|
This package is not intended to be used as a standalone logging package outside of the containerd ecosystem and is intended as an interface wrapper around a logging implementation.
|
||||||
|
In the future this package may be replaced with a common go logging interface.
|
||||||
|
|
||||||
|
## Project details
|
||||||
|
|
||||||
|
**log** is a containerd sub-project, licensed under the [Apache 2.0 license](./LICENSE).
|
||||||
|
As a containerd sub-project, you will find the:
|
||||||
|
* [Project governance](https://github.com/containerd/project/blob/main/GOVERNANCE.md),
|
||||||
|
* [Maintainers](https://github.com/containerd/project/blob/main/MAINTAINERS),
|
||||||
|
* and [Contributing guidelines](https://github.com/containerd/project/blob/main/CONTRIBUTING.md)
|
||||||
|
|
||||||
|
information in our [`containerd/project`](https://github.com/containerd/project) repository.
|
||||||
|
|
182
vendor/github.com/containerd/log/context.go
generated
vendored
Normal file
182
vendor/github.com/containerd/log/context.go
generated
vendored
Normal file
@ -0,0 +1,182 @@
|
|||||||
|
/*
|
||||||
|
Copyright The containerd Authors.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Package log provides types and functions related to logging, passing
|
||||||
|
// loggers through a context, and attaching context to the logger.
|
||||||
|
//
|
||||||
|
// # Transitional types
|
||||||
|
//
|
||||||
|
// This package contains various types that are aliases for types in [logrus].
|
||||||
|
// These aliases are intended for transitioning away from hard-coding logrus
|
||||||
|
// as logging implementation. Consumers of this package are encouraged to use
|
||||||
|
// the type-aliases from this package instead of directly using their logrus
|
||||||
|
// equivalent.
|
||||||
|
//
|
||||||
|
// The intent is to replace these aliases with locally defined types and
|
||||||
|
// interfaces once all consumers are no longer directly importing logrus
|
||||||
|
// types.
|
||||||
|
//
|
||||||
|
// IMPORTANT: due to the transitional purpose of this package, it is not
|
||||||
|
// guaranteed for the full logrus API to be provided in the future. As
|
||||||
|
// outlined, these aliases are provided as a step to transition away from
|
||||||
|
// a specific implementation which, as a result, exposes the full logrus API.
|
||||||
|
// While no decisions have been made on the ultimate design and interface
|
||||||
|
// provided by this package, we do not expect carrying "less common" features.
|
||||||
|
package log
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
|
)
|
||||||
|
|
||||||
|
// G is a shorthand for [GetLogger].
|
||||||
|
//
|
||||||
|
// We may want to define this locally to a package to get package tagged log
|
||||||
|
// messages.
|
||||||
|
var G = GetLogger
|
||||||
|
|
||||||
|
// L is an alias for the standard logger.
|
||||||
|
var L = &Entry{
|
||||||
|
Logger: logrus.StandardLogger(),
|
||||||
|
// Default is three fields plus a little extra room.
|
||||||
|
Data: make(Fields, 6),
|
||||||
|
}
|
||||||
|
|
||||||
|
type loggerKey struct{}
|
||||||
|
|
||||||
|
// Fields type to pass to "WithFields".
|
||||||
|
type Fields = map[string]any
|
||||||
|
|
||||||
|
// Entry is a logging entry. It contains all the fields passed with
|
||||||
|
// [Entry.WithFields]. It's finally logged when Trace, Debug, Info, Warn,
|
||||||
|
// Error, Fatal or Panic is called on it. These objects can be reused and
|
||||||
|
// passed around as much as you wish to avoid field duplication.
|
||||||
|
//
|
||||||
|
// Entry is a transitional type, and currently an alias for [logrus.Entry].
|
||||||
|
type Entry = logrus.Entry
|
||||||
|
|
||||||
|
// RFC3339NanoFixed is [time.RFC3339Nano] with nanoseconds padded using
|
||||||
|
// zeros to ensure the formatted time is always the same number of
|
||||||
|
// characters.
|
||||||
|
const RFC3339NanoFixed = "2006-01-02T15:04:05.000000000Z07:00"
|
||||||
|
|
||||||
|
// Level is a logging level.
|
||||||
|
type Level = logrus.Level
|
||||||
|
|
||||||
|
// Supported log levels.
|
||||||
|
const (
|
||||||
|
// TraceLevel level. Designates finer-grained informational events
|
||||||
|
// than [DebugLevel].
|
||||||
|
TraceLevel Level = logrus.TraceLevel
|
||||||
|
|
||||||
|
// DebugLevel level. Usually only enabled when debugging. Very verbose
|
||||||
|
// logging.
|
||||||
|
DebugLevel Level = logrus.DebugLevel
|
||||||
|
|
||||||
|
// InfoLevel level. General operational entries about what's going on
|
||||||
|
// inside the application.
|
||||||
|
InfoLevel Level = logrus.InfoLevel
|
||||||
|
|
||||||
|
// WarnLevel level. Non-critical entries that deserve eyes.
|
||||||
|
WarnLevel Level = logrus.WarnLevel
|
||||||
|
|
||||||
|
// ErrorLevel level. Logs errors that should definitely be noted.
|
||||||
|
// Commonly used for hooks to send errors to an error tracking service.
|
||||||
|
ErrorLevel Level = logrus.ErrorLevel
|
||||||
|
|
||||||
|
// FatalLevel level. Logs and then calls "logger.Exit(1)". It exits
|
||||||
|
// even if the logging level is set to Panic.
|
||||||
|
FatalLevel Level = logrus.FatalLevel
|
||||||
|
|
||||||
|
// PanicLevel level. This is the highest level of severity. Logs and
|
||||||
|
// then calls panic with the message passed to Debug, Info, ...
|
||||||
|
PanicLevel Level = logrus.PanicLevel
|
||||||
|
)
|
||||||
|
|
||||||
|
// SetLevel sets log level globally. It returns an error if the given
|
||||||
|
// level is not supported.
|
||||||
|
//
|
||||||
|
// level can be one of:
|
||||||
|
//
|
||||||
|
// - "trace" ([TraceLevel])
|
||||||
|
// - "debug" ([DebugLevel])
|
||||||
|
// - "info" ([InfoLevel])
|
||||||
|
// - "warn" ([WarnLevel])
|
||||||
|
// - "error" ([ErrorLevel])
|
||||||
|
// - "fatal" ([FatalLevel])
|
||||||
|
// - "panic" ([PanicLevel])
|
||||||
|
func SetLevel(level string) error {
|
||||||
|
lvl, err := logrus.ParseLevel(level)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
L.Logger.SetLevel(lvl)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetLevel returns the current log level.
|
||||||
|
func GetLevel() Level {
|
||||||
|
return L.Logger.GetLevel()
|
||||||
|
}
|
||||||
|
|
||||||
|
// OutputFormat specifies a log output format.
|
||||||
|
type OutputFormat string
|
||||||
|
|
||||||
|
// Supported log output formats.
|
||||||
|
const (
|
||||||
|
// TextFormat represents the text logging format.
|
||||||
|
TextFormat OutputFormat = "text"
|
||||||
|
|
||||||
|
// JSONFormat represents the JSON logging format.
|
||||||
|
JSONFormat OutputFormat = "json"
|
||||||
|
)
|
||||||
|
|
||||||
|
// SetFormat sets the log output format ([TextFormat] or [JSONFormat]).
|
||||||
|
func SetFormat(format OutputFormat) error {
|
||||||
|
switch format {
|
||||||
|
case TextFormat:
|
||||||
|
L.Logger.SetFormatter(&logrus.TextFormatter{
|
||||||
|
TimestampFormat: RFC3339NanoFixed,
|
||||||
|
FullTimestamp: true,
|
||||||
|
})
|
||||||
|
return nil
|
||||||
|
case JSONFormat:
|
||||||
|
L.Logger.SetFormatter(&logrus.JSONFormatter{
|
||||||
|
TimestampFormat: RFC3339NanoFixed,
|
||||||
|
})
|
||||||
|
return nil
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("unknown log format: %s", format)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithLogger returns a new context with the provided logger. Use in
|
||||||
|
// combination with logger.WithField(s) for great effect.
|
||||||
|
func WithLogger(ctx context.Context, logger *Entry) context.Context {
|
||||||
|
return context.WithValue(ctx, loggerKey{}, logger.WithContext(ctx))
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetLogger retrieves the current logger from the context. If no logger is
|
||||||
|
// available, the default logger is returned.
|
||||||
|
func GetLogger(ctx context.Context) *Entry {
|
||||||
|
if logger := ctx.Value(loggerKey{}); logger != nil {
|
||||||
|
return logger.(*Entry)
|
||||||
|
}
|
||||||
|
return L.WithContext(ctx)
|
||||||
|
}
|
21
vendor/github.com/cyphar/filepath-securejoin/.travis.yml
generated
vendored
21
vendor/github.com/cyphar/filepath-securejoin/.travis.yml
generated
vendored
@ -1,21 +0,0 @@
|
|||||||
# Copyright (C) 2017 SUSE LLC. All rights reserved.
|
|
||||||
# Use of this source code is governed by a BSD-style
|
|
||||||
# license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
language: go
|
|
||||||
go:
|
|
||||||
- 1.13.x
|
|
||||||
- 1.16.x
|
|
||||||
- tip
|
|
||||||
arch:
|
|
||||||
- AMD64
|
|
||||||
- ppc64le
|
|
||||||
os:
|
|
||||||
- linux
|
|
||||||
- osx
|
|
||||||
|
|
||||||
script:
|
|
||||||
- go test -cover -v ./...
|
|
||||||
|
|
||||||
notifications:
|
|
||||||
email: false
|
|
28
vendor/github.com/cyphar/filepath-securejoin/LICENSE
generated
vendored
28
vendor/github.com/cyphar/filepath-securejoin/LICENSE
generated
vendored
@ -1,28 +0,0 @@
|
|||||||
Copyright (C) 2014-2015 Docker Inc & Go Authors. All rights reserved.
|
|
||||||
Copyright (C) 2017 SUSE LLC. All rights reserved.
|
|
||||||
|
|
||||||
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 Inc. 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.
|
|
79
vendor/github.com/cyphar/filepath-securejoin/README.md
generated
vendored
79
vendor/github.com/cyphar/filepath-securejoin/README.md
generated
vendored
@ -1,79 +0,0 @@
|
|||||||
## `filepath-securejoin` ##
|
|
||||||
|
|
||||||
[](https://travis-ci.org/cyphar/filepath-securejoin)
|
|
||||||
|
|
||||||
An implementation of `SecureJoin`, a [candidate for inclusion in the Go
|
|
||||||
standard library][go#20126]. The purpose of this function is to be a "secure"
|
|
||||||
alternative to `filepath.Join`, and in particular it provides certain
|
|
||||||
guarantees that are not provided by `filepath.Join`.
|
|
||||||
|
|
||||||
> **NOTE**: This code is *only* safe if you are not at risk of other processes
|
|
||||||
> modifying path components after you've used `SecureJoin`. If it is possible
|
|
||||||
> for a malicious process to modify path components of the resolved path, then
|
|
||||||
> you will be vulnerable to some fairly trivial TOCTOU race conditions. [There
|
|
||||||
> are some Linux kernel patches I'm working on which might allow for a better
|
|
||||||
> solution.][lwn-obeneath]
|
|
||||||
>
|
|
||||||
> In addition, with a slightly modified API it might be possible to use
|
|
||||||
> `O_PATH` and verify that the opened path is actually the resolved one -- but
|
|
||||||
> I have not done that yet. I might add it in the future as a helper function
|
|
||||||
> to help users verify the path (we can't just return `/proc/self/fd/<foo>`
|
|
||||||
> because that doesn't always work transparently for all users).
|
|
||||||
|
|
||||||
This is the function prototype:
|
|
||||||
|
|
||||||
```go
|
|
||||||
func SecureJoin(root, unsafePath string) (string, error)
|
|
||||||
```
|
|
||||||
|
|
||||||
This library **guarantees** the following:
|
|
||||||
|
|
||||||
* If no error is set, the resulting string **must** be a child path of
|
|
||||||
`root` and will not contain any symlink path components (they will all be
|
|
||||||
expanded).
|
|
||||||
|
|
||||||
* When expanding symlinks, all symlink path components **must** be resolved
|
|
||||||
relative to the provided root. In particular, this can be considered a
|
|
||||||
userspace implementation of how `chroot(2)` operates on file paths. Note that
|
|
||||||
these symlinks will **not** be expanded lexically (`filepath.Clean` is not
|
|
||||||
called on the input before processing).
|
|
||||||
|
|
||||||
* Non-existent path components are unaffected by `SecureJoin` (similar to
|
|
||||||
`filepath.EvalSymlinks`'s semantics).
|
|
||||||
|
|
||||||
* The returned path will always be `filepath.Clean`ed and thus not contain any
|
|
||||||
`..` components.
|
|
||||||
|
|
||||||
A (trivial) implementation of this function on GNU/Linux systems could be done
|
|
||||||
with the following (note that this requires root privileges and is far more
|
|
||||||
opaque than the implementation in this library, and also requires that
|
|
||||||
`readlink` is inside the `root` path):
|
|
||||||
|
|
||||||
```go
|
|
||||||
package securejoin
|
|
||||||
|
|
||||||
import (
|
|
||||||
"os/exec"
|
|
||||||
"path/filepath"
|
|
||||||
)
|
|
||||||
|
|
||||||
func SecureJoin(root, unsafePath string) (string, error) {
|
|
||||||
unsafePath = string(filepath.Separator) + unsafePath
|
|
||||||
cmd := exec.Command("chroot", root,
|
|
||||||
"readlink", "--canonicalize-missing", "--no-newline", unsafePath)
|
|
||||||
output, err := cmd.CombinedOutput()
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
expanded := string(output)
|
|
||||||
return filepath.Join(root, expanded), nil
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
[lwn-obeneath]: https://lwn.net/Articles/767547/
|
|
||||||
[go#20126]: https://github.com/golang/go/issues/20126
|
|
||||||
|
|
||||||
### License ###
|
|
||||||
|
|
||||||
The license of this project is the same as Go, which is a BSD 3-clause license
|
|
||||||
available in the `LICENSE` file.
|
|
1
vendor/github.com/cyphar/filepath-securejoin/VERSION
generated
vendored
1
vendor/github.com/cyphar/filepath-securejoin/VERSION
generated
vendored
@ -1 +0,0 @@
|
|||||||
0.2.3
|
|
115
vendor/github.com/cyphar/filepath-securejoin/join.go
generated
vendored
115
vendor/github.com/cyphar/filepath-securejoin/join.go
generated
vendored
@ -1,115 +0,0 @@
|
|||||||
// Copyright (C) 2014-2015 Docker Inc & Go Authors. All rights reserved.
|
|
||||||
// Copyright (C) 2017 SUSE LLC. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// Package securejoin is an implementation of the hopefully-soon-to-be-included
|
|
||||||
// SecureJoin helper that is meant to be part of the "path/filepath" package.
|
|
||||||
// The purpose of this project is to provide a PoC implementation to make the
|
|
||||||
// SecureJoin proposal (https://github.com/golang/go/issues/20126) more
|
|
||||||
// tangible.
|
|
||||||
package securejoin
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"errors"
|
|
||||||
"os"
|
|
||||||
"path/filepath"
|
|
||||||
"strings"
|
|
||||||
"syscall"
|
|
||||||
)
|
|
||||||
|
|
||||||
// IsNotExist tells you if err is an error that implies that either the path
|
|
||||||
// accessed does not exist (or path components don't exist). This is
|
|
||||||
// effectively a more broad version of os.IsNotExist.
|
|
||||||
func IsNotExist(err error) bool {
|
|
||||||
// Check that it's not actually an ENOTDIR, which in some cases is a more
|
|
||||||
// convoluted case of ENOENT (usually involving weird paths).
|
|
||||||
return errors.Is(err, os.ErrNotExist) || errors.Is(err, syscall.ENOTDIR) || errors.Is(err, syscall.ENOENT)
|
|
||||||
}
|
|
||||||
|
|
||||||
// SecureJoinVFS joins the two given path components (similar to Join) except
|
|
||||||
// that the returned path is guaranteed to be scoped inside the provided root
|
|
||||||
// path (when evaluated). Any symbolic links in the path are evaluated with the
|
|
||||||
// given root treated as the root of the filesystem, similar to a chroot. The
|
|
||||||
// filesystem state is evaluated through the given VFS interface (if nil, the
|
|
||||||
// standard os.* family of functions are used).
|
|
||||||
//
|
|
||||||
// Note that the guarantees provided by this function only apply if the path
|
|
||||||
// components in the returned string are not modified (in other words are not
|
|
||||||
// replaced with symlinks on the filesystem) after this function has returned.
|
|
||||||
// Such a symlink race is necessarily out-of-scope of SecureJoin.
|
|
||||||
func SecureJoinVFS(root, unsafePath string, vfs VFS) (string, error) {
|
|
||||||
// Use the os.* VFS implementation if none was specified.
|
|
||||||
if vfs == nil {
|
|
||||||
vfs = osVFS{}
|
|
||||||
}
|
|
||||||
|
|
||||||
var path bytes.Buffer
|
|
||||||
n := 0
|
|
||||||
for unsafePath != "" {
|
|
||||||
if n > 255 {
|
|
||||||
return "", &os.PathError{Op: "SecureJoin", Path: root + "/" + unsafePath, Err: syscall.ELOOP}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Next path component, p.
|
|
||||||
i := strings.IndexRune(unsafePath, filepath.Separator)
|
|
||||||
var p string
|
|
||||||
if i == -1 {
|
|
||||||
p, unsafePath = unsafePath, ""
|
|
||||||
} else {
|
|
||||||
p, unsafePath = unsafePath[:i], unsafePath[i+1:]
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a cleaned path, using the lexical semantics of /../a, to
|
|
||||||
// create a "scoped" path component which can safely be joined to fullP
|
|
||||||
// for evaluation. At this point, path.String() doesn't contain any
|
|
||||||
// symlink components.
|
|
||||||
cleanP := filepath.Clean(string(filepath.Separator) + path.String() + p)
|
|
||||||
if cleanP == string(filepath.Separator) {
|
|
||||||
path.Reset()
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
fullP := filepath.Clean(root + cleanP)
|
|
||||||
|
|
||||||
// Figure out whether the path is a symlink.
|
|
||||||
fi, err := vfs.Lstat(fullP)
|
|
||||||
if err != nil && !IsNotExist(err) {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
// Treat non-existent path components the same as non-symlinks (we
|
|
||||||
// can't do any better here).
|
|
||||||
if IsNotExist(err) || fi.Mode()&os.ModeSymlink == 0 {
|
|
||||||
path.WriteString(p)
|
|
||||||
path.WriteRune(filepath.Separator)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
// Only increment when we actually dereference a link.
|
|
||||||
n++
|
|
||||||
|
|
||||||
// It's a symlink, expand it by prepending it to the yet-unparsed path.
|
|
||||||
dest, err := vfs.Readlink(fullP)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
// Absolute symlinks reset any work we've already done.
|
|
||||||
if filepath.IsAbs(dest) {
|
|
||||||
path.Reset()
|
|
||||||
}
|
|
||||||
unsafePath = dest + string(filepath.Separator) + unsafePath
|
|
||||||
}
|
|
||||||
|
|
||||||
// We have to clean path.String() here because it may contain '..'
|
|
||||||
// components that are entirely lexical, but would be misleading otherwise.
|
|
||||||
// And finally do a final clean to ensure that root is also lexically
|
|
||||||
// clean.
|
|
||||||
fullP := filepath.Clean(string(filepath.Separator) + path.String())
|
|
||||||
return filepath.Clean(root + fullP), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// SecureJoin is a wrapper around SecureJoinVFS that just uses the os.* library
|
|
||||||
// of functions as the VFS. If in doubt, use this function over SecureJoinVFS.
|
|
||||||
func SecureJoin(root, unsafePath string) (string, error) {
|
|
||||||
return SecureJoinVFS(root, unsafePath, nil)
|
|
||||||
}
|
|
41
vendor/github.com/cyphar/filepath-securejoin/vfs.go
generated
vendored
41
vendor/github.com/cyphar/filepath-securejoin/vfs.go
generated
vendored
@ -1,41 +0,0 @@
|
|||||||
// Copyright (C) 2017 SUSE LLC. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package securejoin
|
|
||||||
|
|
||||||
import "os"
|
|
||||||
|
|
||||||
// In future this should be moved into a separate package, because now there
|
|
||||||
// are several projects (umoci and go-mtree) that are using this sort of
|
|
||||||
// interface.
|
|
||||||
|
|
||||||
// VFS is the minimal interface necessary to use SecureJoinVFS. A nil VFS is
|
|
||||||
// equivalent to using the standard os.* family of functions. This is mainly
|
|
||||||
// used for the purposes of mock testing, but also can be used to otherwise use
|
|
||||||
// SecureJoin with VFS-like system.
|
|
||||||
type VFS interface {
|
|
||||||
// Lstat returns a FileInfo describing the named file. If the file is a
|
|
||||||
// symbolic link, the returned FileInfo describes the symbolic link. Lstat
|
|
||||||
// makes no attempt to follow the link. These semantics are identical to
|
|
||||||
// os.Lstat.
|
|
||||||
Lstat(name string) (os.FileInfo, error)
|
|
||||||
|
|
||||||
// Readlink returns the destination of the named symbolic link. These
|
|
||||||
// semantics are identical to os.Readlink.
|
|
||||||
Readlink(name string) (string, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
// osVFS is the "nil" VFS, in that it just passes everything through to the os
|
|
||||||
// module.
|
|
||||||
type osVFS struct{}
|
|
||||||
|
|
||||||
// Lstat returns a FileInfo describing the named file. If the file is a
|
|
||||||
// symbolic link, the returned FileInfo describes the symbolic link. Lstat
|
|
||||||
// makes no attempt to follow the link. These semantics are identical to
|
|
||||||
// os.Lstat.
|
|
||||||
func (o osVFS) Lstat(name string) (os.FileInfo, error) { return os.Lstat(name) }
|
|
||||||
|
|
||||||
// Readlink returns the destination of the named symbolic link. These
|
|
||||||
// semantics are identical to os.Readlink.
|
|
||||||
func (o osVFS) Readlink(name string) (string, error) { return os.Readlink(name) }
|
|
3
vendor/github.com/moby/buildkit/client/llb/source.go
generated
vendored
3
vendor/github.com/moby/buildkit/client/llb/source.go
generated
vendored
@ -245,8 +245,7 @@ func Git(url, ref string, opts ...GitOption) State {
|
|||||||
remote, err = gitutil.ParseURL(url)
|
remote, err = gitutil.ParseURL(url)
|
||||||
}
|
}
|
||||||
if remote != nil {
|
if remote != nil {
|
||||||
remote.Fragment = ""
|
url = remote.Remote
|
||||||
url = remote.String()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var id string
|
var id string
|
||||||
|
5
vendor/github.com/moby/buildkit/client/ociindex/ociindex.go
generated
vendored
5
vendor/github.com/moby/buildkit/client/ociindex/ociindex.go
generated
vendored
@ -12,9 +12,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// indexFile is the name of the index file
|
|
||||||
indexFile = "index.json"
|
|
||||||
|
|
||||||
// lockFileSuffix is the suffix of the lock file
|
// lockFileSuffix is the suffix of the lock file
|
||||||
lockFileSuffix = ".lock"
|
lockFileSuffix = ".lock"
|
||||||
)
|
)
|
||||||
@ -26,7 +23,7 @@ type StoreIndex struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewStoreIndex(storePath string) StoreIndex {
|
func NewStoreIndex(storePath string) StoreIndex {
|
||||||
indexPath := path.Join(storePath, indexFile)
|
indexPath := path.Join(storePath, ocispecs.ImageIndexFile)
|
||||||
layoutPath := path.Join(storePath, ocispecs.ImageLayoutFile)
|
layoutPath := path.Join(storePath, ocispecs.ImageLayoutFile)
|
||||||
return StoreIndex{
|
return StoreIndex{
|
||||||
indexPath: indexPath,
|
indexPath: indexPath,
|
||||||
|
2
vendor/github.com/moby/buildkit/util/bklog/log.go
generated
vendored
2
vendor/github.com/moby/buildkit/util/bklog/log.go
generated
vendored
@ -4,7 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
|
|
||||||
"github.com/containerd/containerd/log"
|
"github.com/containerd/log"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"go.opentelemetry.io/otel/trace"
|
"go.opentelemetry.io/otel/trace"
|
||||||
)
|
)
|
||||||
|
14
vendor/github.com/moby/buildkit/util/gitutil/git_ref.go
generated
vendored
14
vendor/github.com/moby/buildkit/util/gitutil/git_ref.go
generated
vendored
@ -53,17 +53,17 @@ func ParseGitRef(ref string) (*GitRef, error) {
|
|||||||
res := &GitRef{}
|
res := &GitRef{}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
remote *url.URL
|
remote *GitURL
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
|
||||||
if strings.HasPrefix(ref, "github.com/") {
|
if strings.HasPrefix(ref, "github.com/") {
|
||||||
res.IndistinguishableFromLocal = true // Deprecated
|
res.IndistinguishableFromLocal = true // Deprecated
|
||||||
remote = &url.URL{
|
remote = fromURL(&url.URL{
|
||||||
Scheme: "https",
|
Scheme: "https",
|
||||||
Host: "github.com",
|
Host: "github.com",
|
||||||
Path: strings.TrimPrefix(ref, "github.com/"),
|
Path: strings.TrimPrefix(ref, "github.com/"),
|
||||||
}
|
})
|
||||||
} else {
|
} else {
|
||||||
remote, err = ParseURL(ref)
|
remote, err = ParseURL(ref)
|
||||||
if errors.Is(err, ErrUnknownProtocol) {
|
if errors.Is(err, ErrUnknownProtocol) {
|
||||||
@ -87,13 +87,13 @@ func ParseGitRef(ref string) (*GitRef, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
res.Commit, res.SubDir = SplitGitFragment(remote.Fragment)
|
res.Remote = remote.Remote
|
||||||
remote.Fragment = ""
|
|
||||||
|
|
||||||
res.Remote = remote.String()
|
|
||||||
if res.IndistinguishableFromLocal {
|
if res.IndistinguishableFromLocal {
|
||||||
_, res.Remote, _ = strings.Cut(res.Remote, "://")
|
_, res.Remote, _ = strings.Cut(res.Remote, "://")
|
||||||
}
|
}
|
||||||
|
if remote.Fragment != nil {
|
||||||
|
res.Commit, res.SubDir = remote.Fragment.Ref, remote.Fragment.Subdir
|
||||||
|
}
|
||||||
|
|
||||||
repoSplitBySlash := strings.Split(res.Remote, "/")
|
repoSplitBySlash := strings.Split(res.Remote, "/")
|
||||||
res.ShortName = strings.TrimSuffix(repoSplitBySlash[len(repoSplitBySlash)-1], ".git")
|
res.ShortName = strings.TrimSuffix(repoSplitBySlash[len(repoSplitBySlash)-1], ".git")
|
||||||
|
102
vendor/github.com/moby/buildkit/util/gitutil/git_url.go
generated
vendored
102
vendor/github.com/moby/buildkit/util/gitutil/git_url.go
generated
vendored
@ -30,42 +30,94 @@ var supportedProtos = map[string]struct{}{
|
|||||||
|
|
||||||
var protoRegexp = regexp.MustCompile(`^[a-zA-Z0-9]+://`)
|
var protoRegexp = regexp.MustCompile(`^[a-zA-Z0-9]+://`)
|
||||||
|
|
||||||
// ParseURL parses a git URL and returns a parsed URL object.
|
// URL is a custom URL type that points to a remote Git repository.
|
||||||
//
|
//
|
||||||
// ParseURL understands implicit ssh URLs such as "git@host:repo", and
|
// URLs can be parsed from both standard URLs (e.g.
|
||||||
// returns the same response as if the URL were "ssh://git@host/repo".
|
// "https://github.com/moby/buildkit.git"), as well as SCP-like URLs (e.g.
|
||||||
func ParseURL(remote string) (*url.URL, error) {
|
// "git@github.com:moby/buildkit.git").
|
||||||
|
//
|
||||||
|
// See https://git-scm.com/book/en/v2/Git-on-the-Server-The-Protocols
|
||||||
|
type GitURL struct {
|
||||||
|
// Scheme is the protocol over which the git repo can be accessed
|
||||||
|
Scheme string
|
||||||
|
|
||||||
|
// Host is the remote host that hosts the git repo
|
||||||
|
Host string
|
||||||
|
// Path is the path on the host to access the repo
|
||||||
|
Path string
|
||||||
|
// User is the username/password to access the host
|
||||||
|
User *url.Userinfo
|
||||||
|
// Fragment can contain additional metadata
|
||||||
|
Fragment *GitURLFragment
|
||||||
|
|
||||||
|
// Remote is a valid URL remote to pass into the Git CLI tooling (i.e.
|
||||||
|
// without the fragment metadata)
|
||||||
|
Remote string
|
||||||
|
}
|
||||||
|
|
||||||
|
// GitURLFragment is the buildkit-specific metadata extracted from the fragment
|
||||||
|
// of a remote URL.
|
||||||
|
type GitURLFragment struct {
|
||||||
|
// Ref is the git reference
|
||||||
|
Ref string
|
||||||
|
// Subdir is the sub-directory inside the git repository to use
|
||||||
|
Subdir string
|
||||||
|
}
|
||||||
|
|
||||||
|
// splitGitFragment splits a git URL fragment into its respective git
|
||||||
|
// reference and subdirectory components.
|
||||||
|
func splitGitFragment(fragment string) *GitURLFragment {
|
||||||
|
if fragment == "" {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
ref, subdir, _ := strings.Cut(fragment, ":")
|
||||||
|
return &GitURLFragment{Ref: ref, Subdir: subdir}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ParseURL parses a BuildKit-style Git URL (that may contain additional
|
||||||
|
// fragment metadata) and returns a parsed GitURL object.
|
||||||
|
func ParseURL(remote string) (*GitURL, error) {
|
||||||
if proto := protoRegexp.FindString(remote); proto != "" {
|
if proto := protoRegexp.FindString(remote); proto != "" {
|
||||||
proto = strings.ToLower(strings.TrimSuffix(proto, "://"))
|
proto = strings.ToLower(strings.TrimSuffix(proto, "://"))
|
||||||
if _, ok := supportedProtos[proto]; !ok {
|
if _, ok := supportedProtos[proto]; !ok {
|
||||||
return nil, errors.Wrap(ErrInvalidProtocol, proto)
|
return nil, errors.Wrap(ErrInvalidProtocol, proto)
|
||||||
}
|
}
|
||||||
|
url, err := url.Parse(remote)
|
||||||
return url.Parse(remote)
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return fromURL(url), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if sshutil.IsImplicitSSHTransport(remote) {
|
if url, err := sshutil.ParseSCPStyleURL(remote); err == nil {
|
||||||
remote, fragment, _ := strings.Cut(remote, "#")
|
return fromSCPStyleURL(url), nil
|
||||||
remote, path, _ := strings.Cut(remote, ":")
|
|
||||||
user, host, _ := strings.Cut(remote, "@")
|
|
||||||
if !strings.HasPrefix(path, "/") {
|
|
||||||
path = "/" + path
|
|
||||||
}
|
|
||||||
return &url.URL{
|
|
||||||
Scheme: SSHProtocol,
|
|
||||||
User: url.User(user),
|
|
||||||
Host: host,
|
|
||||||
Path: path,
|
|
||||||
Fragment: fragment,
|
|
||||||
}, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, ErrUnknownProtocol
|
return nil, ErrUnknownProtocol
|
||||||
}
|
}
|
||||||
|
|
||||||
// SplitGitFragments splits a git URL fragment into its respective git
|
func fromURL(url *url.URL) *GitURL {
|
||||||
// reference and subdirectory components.
|
withoutFragment := *url
|
||||||
func SplitGitFragment(fragment string) (ref string, subdir string) {
|
withoutFragment.Fragment = ""
|
||||||
ref, subdir, _ = strings.Cut(fragment, ":")
|
return &GitURL{
|
||||||
return ref, subdir
|
Scheme: url.Scheme,
|
||||||
|
User: url.User,
|
||||||
|
Host: url.Host,
|
||||||
|
Path: url.Path,
|
||||||
|
Fragment: splitGitFragment(url.Fragment),
|
||||||
|
Remote: withoutFragment.String(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func fromSCPStyleURL(url *sshutil.SCPStyleURL) *GitURL {
|
||||||
|
withoutFragment := *url
|
||||||
|
withoutFragment.Fragment = ""
|
||||||
|
return &GitURL{
|
||||||
|
Scheme: SSHProtocol,
|
||||||
|
User: url.User,
|
||||||
|
Host: url.Host,
|
||||||
|
Path: url.Path,
|
||||||
|
Fragment: splitGitFragment(url.Fragment),
|
||||||
|
Remote: withoutFragment.String(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
1
vendor/github.com/moby/buildkit/util/imageutil/config.go
generated
vendored
1
vendor/github.com/moby/buildkit/util/imageutil/config.go
generated
vendored
@ -156,6 +156,7 @@ func Config(ctx context.Context, str string, resolver remotes.Resolver, cache Co
|
|||||||
}
|
}
|
||||||
|
|
||||||
children := childrenConfigHandler(cache, platform)
|
children := childrenConfigHandler(cache, platform)
|
||||||
|
children = images.LimitManifests(children, platform, 1)
|
||||||
|
|
||||||
dslHandler, err := docker.AppendDistributionSourceLabel(cache, ref.String())
|
dslHandler, err := docker.AppendDistributionSourceLabel(cache, ref.String())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
1
vendor/github.com/moby/buildkit/util/progress/progressui/display.go
generated
vendored
1
vendor/github.com/moby/buildkit/util/progress/progressui/display.go
generated
vendored
@ -310,7 +310,6 @@ func (d *rawJSONDisplay) done() {
|
|||||||
// No actions needed.
|
// No actions needed.
|
||||||
}
|
}
|
||||||
|
|
||||||
const termHeight = 6
|
|
||||||
const termPad = 10
|
const termPad = 10
|
||||||
|
|
||||||
type displayInfo struct {
|
type displayInfo struct {
|
||||||
|
12
vendor/github.com/moby/buildkit/util/progress/progressui/init.go
generated
vendored
12
vendor/github.com/moby/buildkit/util/progress/progressui/init.go
generated
vendored
@ -3,6 +3,7 @@ package progressui
|
|||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/morikuni/aec"
|
"github.com/morikuni/aec"
|
||||||
)
|
)
|
||||||
@ -12,6 +13,8 @@ var colorCancel aec.ANSI
|
|||||||
var colorWarning aec.ANSI
|
var colorWarning aec.ANSI
|
||||||
var colorError aec.ANSI
|
var colorError aec.ANSI
|
||||||
|
|
||||||
|
var termHeight = 6
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
// As recommended on https://no-color.org/
|
// As recommended on https://no-color.org/
|
||||||
if v := os.Getenv("NO_COLOR"); v != "" {
|
if v := os.Getenv("NO_COLOR"); v != "" {
|
||||||
@ -34,4 +37,13 @@ func init() {
|
|||||||
envColorString := os.Getenv("BUILDKIT_COLORS")
|
envColorString := os.Getenv("BUILDKIT_COLORS")
|
||||||
setUserDefinedTermColors(envColorString)
|
setUserDefinedTermColors(envColorString)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Make the terminal height configurable at runtime.
|
||||||
|
termHeightStr := os.Getenv("BUILDKIT_TTY_LOG_LINES")
|
||||||
|
if termHeightStr != "" {
|
||||||
|
termHeightVal, err := strconv.Atoi(termHeightStr)
|
||||||
|
if err == nil && termHeightVal > 0 {
|
||||||
|
termHeight = termHeightVal
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
43
vendor/github.com/moby/buildkit/util/sshutil/scpurl.go
generated
vendored
Normal file
43
vendor/github.com/moby/buildkit/util/sshutil/scpurl.go
generated
vendored
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
package sshutil
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"net/url"
|
||||||
|
"regexp"
|
||||||
|
)
|
||||||
|
|
||||||
|
var gitSSHRegex = regexp.MustCompile("^([a-zA-Z0-9-_]+)@([a-zA-Z0-9-.]+):(.*?)(?:#(.*))?$")
|
||||||
|
|
||||||
|
func IsImplicitSSHTransport(s string) bool {
|
||||||
|
return gitSSHRegex.MatchString(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
type SCPStyleURL struct {
|
||||||
|
User *url.Userinfo
|
||||||
|
Host string
|
||||||
|
|
||||||
|
Path string
|
||||||
|
Fragment string
|
||||||
|
}
|
||||||
|
|
||||||
|
func ParseSCPStyleURL(raw string) (*SCPStyleURL, error) {
|
||||||
|
matches := gitSSHRegex.FindStringSubmatch(raw)
|
||||||
|
if matches == nil {
|
||||||
|
return nil, errors.New("invalid scp-style url")
|
||||||
|
}
|
||||||
|
return &SCPStyleURL{
|
||||||
|
User: url.User(matches[1]),
|
||||||
|
Host: matches[2],
|
||||||
|
Path: matches[3],
|
||||||
|
Fragment: matches[4],
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (url *SCPStyleURL) String() string {
|
||||||
|
base := fmt.Sprintf("%s@%s:%s", url.User.String(), url.Host, url.Path)
|
||||||
|
if url.Fragment == "" {
|
||||||
|
return base
|
||||||
|
}
|
||||||
|
return base + "#" + url.Fragment
|
||||||
|
}
|
11
vendor/github.com/moby/buildkit/util/sshutil/transport_validation.go
generated
vendored
11
vendor/github.com/moby/buildkit/util/sshutil/transport_validation.go
generated
vendored
@ -1,11 +0,0 @@
|
|||||||
package sshutil
|
|
||||||
|
|
||||||
import (
|
|
||||||
"regexp"
|
|
||||||
)
|
|
||||||
|
|
||||||
var gitSSHRegex = regexp.MustCompile("^[a-zA-Z0-9-_]+@[a-zA-Z0-9-.]+:.*$")
|
|
||||||
|
|
||||||
func IsImplicitSSHTransport(s string) bool {
|
|
||||||
return gitSSHRegex.MatchString(s)
|
|
||||||
}
|
|
6
vendor/github.com/opencontainers/image-spec/specs-go/v1/annotations.go
generated
vendored
6
vendor/github.com/opencontainers/image-spec/specs-go/v1/annotations.go
generated
vendored
@ -59,10 +59,4 @@ const (
|
|||||||
|
|
||||||
// AnnotationBaseImageName is the annotation key for the image reference of the image's base image.
|
// AnnotationBaseImageName is the annotation key for the image reference of the image's base image.
|
||||||
AnnotationBaseImageName = "org.opencontainers.image.base.name"
|
AnnotationBaseImageName = "org.opencontainers.image.base.name"
|
||||||
|
|
||||||
// AnnotationArtifactCreated is the annotation key for the date and time on which the artifact was built, conforming to RFC 3339.
|
|
||||||
AnnotationArtifactCreated = "org.opencontainers.artifact.created"
|
|
||||||
|
|
||||||
// AnnotationArtifactDescription is the annotation key for the human readable description for the artifact.
|
|
||||||
AnnotationArtifactDescription = "org.opencontainers.artifact.description"
|
|
||||||
)
|
)
|
||||||
|
12
vendor/github.com/opencontainers/image-spec/specs-go/v1/descriptor.go
generated
vendored
12
vendor/github.com/opencontainers/image-spec/specs-go/v1/descriptor.go
generated
vendored
@ -21,7 +21,7 @@ import digest "github.com/opencontainers/go-digest"
|
|||||||
// when marshalled to JSON.
|
// when marshalled to JSON.
|
||||||
type Descriptor struct {
|
type Descriptor struct {
|
||||||
// MediaType is the media type of the object this schema refers to.
|
// MediaType is the media type of the object this schema refers to.
|
||||||
MediaType string `json:"mediaType,omitempty"`
|
MediaType string `json:"mediaType"`
|
||||||
|
|
||||||
// Digest is the digest of the targeted content.
|
// Digest is the digest of the targeted content.
|
||||||
Digest digest.Digest `json:"digest"`
|
Digest digest.Digest `json:"digest"`
|
||||||
@ -52,7 +52,7 @@ type Descriptor struct {
|
|||||||
// Platform describes the platform which the image in the manifest runs on.
|
// Platform describes the platform which the image in the manifest runs on.
|
||||||
type Platform struct {
|
type Platform struct {
|
||||||
// Architecture field specifies the CPU architecture, for example
|
// Architecture field specifies the CPU architecture, for example
|
||||||
// `amd64` or `ppc64`.
|
// `amd64` or `ppc64le`.
|
||||||
Architecture string `json:"architecture"`
|
Architecture string `json:"architecture"`
|
||||||
|
|
||||||
// OS specifies the operating system, for example `linux` or `windows`.
|
// OS specifies the operating system, for example `linux` or `windows`.
|
||||||
@ -70,3 +70,11 @@ type Platform struct {
|
|||||||
// example `v7` to specify ARMv7 when architecture is `arm`.
|
// example `v7` to specify ARMv7 when architecture is `arm`.
|
||||||
Variant string `json:"variant,omitempty"`
|
Variant string `json:"variant,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DescriptorEmptyJSON is the descriptor of a blob with content of `{}`.
|
||||||
|
var DescriptorEmptyJSON = Descriptor{
|
||||||
|
MediaType: MediaTypeEmptyJSON,
|
||||||
|
Digest: `sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a`,
|
||||||
|
Size: 2,
|
||||||
|
Data: []byte(`{}`),
|
||||||
|
}
|
||||||
|
6
vendor/github.com/opencontainers/image-spec/specs-go/v1/index.go
generated
vendored
6
vendor/github.com/opencontainers/image-spec/specs-go/v1/index.go
generated
vendored
@ -24,9 +24,15 @@ type Index struct {
|
|||||||
// MediaType specifies the type of this document data structure e.g. `application/vnd.oci.image.index.v1+json`
|
// MediaType specifies the type of this document data structure e.g. `application/vnd.oci.image.index.v1+json`
|
||||||
MediaType string `json:"mediaType,omitempty"`
|
MediaType string `json:"mediaType,omitempty"`
|
||||||
|
|
||||||
|
// ArtifactType specifies the IANA media type of artifact when the manifest is used for an artifact.
|
||||||
|
ArtifactType string `json:"artifactType,omitempty"`
|
||||||
|
|
||||||
// Manifests references platform specific manifests.
|
// Manifests references platform specific manifests.
|
||||||
Manifests []Descriptor `json:"manifests"`
|
Manifests []Descriptor `json:"manifests"`
|
||||||
|
|
||||||
|
// Subject is an optional link from the image manifest to another manifest forming an association between the image manifest and the other manifest.
|
||||||
|
Subject *Descriptor `json:"subject,omitempty"`
|
||||||
|
|
||||||
// Annotations contains arbitrary metadata for the image index.
|
// Annotations contains arbitrary metadata for the image index.
|
||||||
Annotations map[string]string `json:"annotations,omitempty"`
|
Annotations map[string]string `json:"annotations,omitempty"`
|
||||||
}
|
}
|
||||||
|
6
vendor/github.com/opencontainers/image-spec/specs-go/v1/layout.go
generated
vendored
6
vendor/github.com/opencontainers/image-spec/specs-go/v1/layout.go
generated
vendored
@ -15,10 +15,14 @@
|
|||||||
package v1
|
package v1
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// ImageLayoutFile is the file name of oci image layout file
|
// ImageLayoutFile is the file name containing ImageLayout in an OCI Image Layout
|
||||||
ImageLayoutFile = "oci-layout"
|
ImageLayoutFile = "oci-layout"
|
||||||
// ImageLayoutVersion is the version of ImageLayout
|
// ImageLayoutVersion is the version of ImageLayout
|
||||||
ImageLayoutVersion = "1.0.0"
|
ImageLayoutVersion = "1.0.0"
|
||||||
|
// ImageIndexFile is the file name of the entry point for references and descriptors in an OCI Image Layout
|
||||||
|
ImageIndexFile = "index.json"
|
||||||
|
// ImageBlobsDir is the directory name containing content addressable blobs in an OCI Image Layout
|
||||||
|
ImageBlobsDir = "blobs"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ImageLayout is the structure in the "oci-layout" file, found in the root
|
// ImageLayout is the structure in the "oci-layout" file, found in the root
|
||||||
|
8
vendor/github.com/opencontainers/image-spec/specs-go/v1/manifest.go
generated
vendored
8
vendor/github.com/opencontainers/image-spec/specs-go/v1/manifest.go
generated
vendored
@ -39,11 +39,3 @@ type Manifest struct {
|
|||||||
// Annotations contains arbitrary metadata for the image manifest.
|
// Annotations contains arbitrary metadata for the image manifest.
|
||||||
Annotations map[string]string `json:"annotations,omitempty"`
|
Annotations map[string]string `json:"annotations,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ScratchDescriptor is the descriptor of a blob with content of `{}`.
|
|
||||||
var ScratchDescriptor = Descriptor{
|
|
||||||
MediaType: MediaTypeScratch,
|
|
||||||
Digest: `sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a`,
|
|
||||||
Size: 2,
|
|
||||||
Data: []byte(`{}`),
|
|
||||||
}
|
|
||||||
|
4
vendor/github.com/opencontainers/image-spec/specs-go/v1/mediatype.go
generated
vendored
4
vendor/github.com/opencontainers/image-spec/specs-go/v1/mediatype.go
generated
vendored
@ -70,6 +70,6 @@ const (
|
|||||||
// MediaTypeImageConfig specifies the media type for the image configuration.
|
// MediaTypeImageConfig specifies the media type for the image configuration.
|
||||||
MediaTypeImageConfig = "application/vnd.oci.image.config.v1+json"
|
MediaTypeImageConfig = "application/vnd.oci.image.config.v1+json"
|
||||||
|
|
||||||
// MediaTypeScratch specifies the media type for an unused blob containing the value `{}`
|
// MediaTypeEmptyJSON specifies the media type for an unused blob containing the value `{}`
|
||||||
MediaTypeScratch = "application/vnd.oci.scratch.v1+json"
|
MediaTypeEmptyJSON = "application/vnd.oci.empty.v1+json"
|
||||||
)
|
)
|
||||||
|
2
vendor/github.com/opencontainers/image-spec/specs-go/version.go
generated
vendored
2
vendor/github.com/opencontainers/image-spec/specs-go/version.go
generated
vendored
@ -25,7 +25,7 @@ const (
|
|||||||
VersionPatch = 0
|
VersionPatch = 0
|
||||||
|
|
||||||
// VersionDev indicates development branch. Releases will be empty string.
|
// VersionDev indicates development branch. Releases will be empty string.
|
||||||
VersionDev = "-rc.3"
|
VersionDev = "-rc.5"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Version is the specification version that the package types support.
|
// Version is the specification version that the package types support.
|
||||||
|
11
vendor/golang.org/x/crypto/bcrypt/bcrypt.go
generated
vendored
11
vendor/golang.org/x/crypto/bcrypt/bcrypt.go
generated
vendored
@ -50,7 +50,7 @@ func (ih InvalidHashPrefixError) Error() string {
|
|||||||
type InvalidCostError int
|
type InvalidCostError int
|
||||||
|
|
||||||
func (ic InvalidCostError) Error() string {
|
func (ic InvalidCostError) Error() string {
|
||||||
return fmt.Sprintf("crypto/bcrypt: cost %d is outside allowed range (%d,%d)", int(ic), int(MinCost), int(MaxCost))
|
return fmt.Sprintf("crypto/bcrypt: cost %d is outside allowed range (%d,%d)", int(ic), MinCost, MaxCost)
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -82,11 +82,20 @@ type hashed struct {
|
|||||||
minor byte
|
minor byte
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ErrPasswordTooLong is returned when the password passed to
|
||||||
|
// GenerateFromPassword is too long (i.e. > 72 bytes).
|
||||||
|
var ErrPasswordTooLong = errors.New("bcrypt: password length exceeds 72 bytes")
|
||||||
|
|
||||||
// GenerateFromPassword returns the bcrypt hash of the password at the given
|
// GenerateFromPassword returns the bcrypt hash of the password at the given
|
||||||
// cost. If the cost given is less than MinCost, the cost will be set to
|
// cost. If the cost given is less than MinCost, the cost will be set to
|
||||||
// DefaultCost, instead. Use CompareHashAndPassword, as defined in this package,
|
// DefaultCost, instead. Use CompareHashAndPassword, as defined in this package,
|
||||||
// to compare the returned hashed password with its cleartext version.
|
// to compare the returned hashed password with its cleartext version.
|
||||||
|
// GenerateFromPassword does not accept passwords longer than 72 bytes, which
|
||||||
|
// is the longest password bcrypt will operate on.
|
||||||
func GenerateFromPassword(password []byte, cost int) ([]byte, error) {
|
func GenerateFromPassword(password []byte, cost int) ([]byte, error) {
|
||||||
|
if len(password) > 72 {
|
||||||
|
return nil, ErrPasswordTooLong
|
||||||
|
}
|
||||||
p, err := newFromPassword(password, cost)
|
p, err := newFromPassword(password, cost)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
4
vendor/golang.org/x/crypto/chacha20/chacha_arm64.go
generated
vendored
4
vendor/golang.org/x/crypto/chacha20/chacha_arm64.go
generated
vendored
@ -2,8 +2,8 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build go1.11 && gc && !purego
|
//go:build gc && !purego
|
||||||
// +build go1.11,gc,!purego
|
// +build gc,!purego
|
||||||
|
|
||||||
package chacha20
|
package chacha20
|
||||||
|
|
||||||
|
4
vendor/golang.org/x/crypto/chacha20/chacha_arm64.s
generated
vendored
4
vendor/golang.org/x/crypto/chacha20/chacha_arm64.s
generated
vendored
@ -2,8 +2,8 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build go1.11 && gc && !purego
|
//go:build gc && !purego
|
||||||
// +build go1.11,gc,!purego
|
// +build gc,!purego
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
|
4
vendor/golang.org/x/crypto/chacha20/chacha_noasm.go
generated
vendored
4
vendor/golang.org/x/crypto/chacha20/chacha_noasm.go
generated
vendored
@ -2,8 +2,8 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build (!arm64 && !s390x && !ppc64le) || (arm64 && !go1.11) || !gc || purego
|
//go:build (!arm64 && !s390x && !ppc64le) || !gc || purego
|
||||||
// +build !arm64,!s390x,!ppc64le arm64,!go1.11 !gc purego
|
// +build !arm64,!s390x,!ppc64le !gc purego
|
||||||
|
|
||||||
package chacha20
|
package chacha20
|
||||||
|
|
||||||
|
99
vendor/golang.org/x/crypto/curve25519/curve25519.go
generated
vendored
99
vendor/golang.org/x/crypto/curve25519/curve25519.go
generated
vendored
@ -5,71 +5,18 @@
|
|||||||
// Package curve25519 provides an implementation of the X25519 function, which
|
// Package curve25519 provides an implementation of the X25519 function, which
|
||||||
// performs scalar multiplication on the elliptic curve known as Curve25519.
|
// performs scalar multiplication on the elliptic curve known as Curve25519.
|
||||||
// See RFC 7748.
|
// See RFC 7748.
|
||||||
|
//
|
||||||
|
// Starting in Go 1.20, this package is a wrapper for the X25519 implementation
|
||||||
|
// in the crypto/ecdh package.
|
||||||
package curve25519 // import "golang.org/x/crypto/curve25519"
|
package curve25519 // import "golang.org/x/crypto/curve25519"
|
||||||
|
|
||||||
import (
|
|
||||||
"crypto/subtle"
|
|
||||||
"errors"
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"golang.org/x/crypto/curve25519/internal/field"
|
|
||||||
)
|
|
||||||
|
|
||||||
// ScalarMult sets dst to the product scalar * point.
|
// ScalarMult sets dst to the product scalar * point.
|
||||||
//
|
//
|
||||||
// Deprecated: when provided a low-order point, ScalarMult will set dst to all
|
// Deprecated: when provided a low-order point, ScalarMult will set dst to all
|
||||||
// zeroes, irrespective of the scalar. Instead, use the X25519 function, which
|
// zeroes, irrespective of the scalar. Instead, use the X25519 function, which
|
||||||
// will return an error.
|
// will return an error.
|
||||||
func ScalarMult(dst, scalar, point *[32]byte) {
|
func ScalarMult(dst, scalar, point *[32]byte) {
|
||||||
var e [32]byte
|
scalarMult(dst, scalar, point)
|
||||||
|
|
||||||
copy(e[:], scalar[:])
|
|
||||||
e[0] &= 248
|
|
||||||
e[31] &= 127
|
|
||||||
e[31] |= 64
|
|
||||||
|
|
||||||
var x1, x2, z2, x3, z3, tmp0, tmp1 field.Element
|
|
||||||
x1.SetBytes(point[:])
|
|
||||||
x2.One()
|
|
||||||
x3.Set(&x1)
|
|
||||||
z3.One()
|
|
||||||
|
|
||||||
swap := 0
|
|
||||||
for pos := 254; pos >= 0; pos-- {
|
|
||||||
b := e[pos/8] >> uint(pos&7)
|
|
||||||
b &= 1
|
|
||||||
swap ^= int(b)
|
|
||||||
x2.Swap(&x3, swap)
|
|
||||||
z2.Swap(&z3, swap)
|
|
||||||
swap = int(b)
|
|
||||||
|
|
||||||
tmp0.Subtract(&x3, &z3)
|
|
||||||
tmp1.Subtract(&x2, &z2)
|
|
||||||
x2.Add(&x2, &z2)
|
|
||||||
z2.Add(&x3, &z3)
|
|
||||||
z3.Multiply(&tmp0, &x2)
|
|
||||||
z2.Multiply(&z2, &tmp1)
|
|
||||||
tmp0.Square(&tmp1)
|
|
||||||
tmp1.Square(&x2)
|
|
||||||
x3.Add(&z3, &z2)
|
|
||||||
z2.Subtract(&z3, &z2)
|
|
||||||
x2.Multiply(&tmp1, &tmp0)
|
|
||||||
tmp1.Subtract(&tmp1, &tmp0)
|
|
||||||
z2.Square(&z2)
|
|
||||||
|
|
||||||
z3.Mult32(&tmp1, 121666)
|
|
||||||
x3.Square(&x3)
|
|
||||||
tmp0.Add(&tmp0, &z3)
|
|
||||||
z3.Multiply(&x1, &z2)
|
|
||||||
z2.Multiply(&tmp1, &tmp0)
|
|
||||||
}
|
|
||||||
|
|
||||||
x2.Swap(&x3, swap)
|
|
||||||
z2.Swap(&z3, swap)
|
|
||||||
|
|
||||||
z2.Invert(&z2)
|
|
||||||
x2.Multiply(&x2, &z2)
|
|
||||||
copy(dst[:], x2.Bytes())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ScalarBaseMult sets dst to the product scalar * base where base is the
|
// ScalarBaseMult sets dst to the product scalar * base where base is the
|
||||||
@ -78,7 +25,7 @@ func ScalarMult(dst, scalar, point *[32]byte) {
|
|||||||
// It is recommended to use the X25519 function with Basepoint instead, as
|
// It is recommended to use the X25519 function with Basepoint instead, as
|
||||||
// copying into fixed size arrays can lead to unexpected bugs.
|
// copying into fixed size arrays can lead to unexpected bugs.
|
||||||
func ScalarBaseMult(dst, scalar *[32]byte) {
|
func ScalarBaseMult(dst, scalar *[32]byte) {
|
||||||
ScalarMult(dst, scalar, &basePoint)
|
scalarBaseMult(dst, scalar)
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -91,21 +38,10 @@ const (
|
|||||||
// Basepoint is the canonical Curve25519 generator.
|
// Basepoint is the canonical Curve25519 generator.
|
||||||
var Basepoint []byte
|
var Basepoint []byte
|
||||||
|
|
||||||
var basePoint = [32]byte{9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
var basePoint = [32]byte{9}
|
||||||
|
|
||||||
func init() { Basepoint = basePoint[:] }
|
func init() { Basepoint = basePoint[:] }
|
||||||
|
|
||||||
func checkBasepoint() {
|
|
||||||
if subtle.ConstantTimeCompare(Basepoint, []byte{
|
|
||||||
0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
}) != 1 {
|
|
||||||
panic("curve25519: global Basepoint value was modified")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// X25519 returns the result of the scalar multiplication (scalar * point),
|
// X25519 returns the result of the scalar multiplication (scalar * point),
|
||||||
// according to RFC 7748, Section 5. scalar, point and the return value are
|
// according to RFC 7748, Section 5. scalar, point and the return value are
|
||||||
// slices of 32 bytes.
|
// slices of 32 bytes.
|
||||||
@ -121,26 +57,3 @@ func X25519(scalar, point []byte) ([]byte, error) {
|
|||||||
var dst [32]byte
|
var dst [32]byte
|
||||||
return x25519(&dst, scalar, point)
|
return x25519(&dst, scalar, point)
|
||||||
}
|
}
|
||||||
|
|
||||||
func x25519(dst *[32]byte, scalar, point []byte) ([]byte, error) {
|
|
||||||
var in [32]byte
|
|
||||||
if l := len(scalar); l != 32 {
|
|
||||||
return nil, errors.New("bad scalar length: " + strconv.Itoa(l) + ", expected 32")
|
|
||||||
}
|
|
||||||
if l := len(point); l != 32 {
|
|
||||||
return nil, errors.New("bad point length: " + strconv.Itoa(l) + ", expected 32")
|
|
||||||
}
|
|
||||||
copy(in[:], scalar)
|
|
||||||
if &point[0] == &Basepoint[0] {
|
|
||||||
checkBasepoint()
|
|
||||||
ScalarBaseMult(dst, &in)
|
|
||||||
} else {
|
|
||||||
var base, zero [32]byte
|
|
||||||
copy(base[:], point)
|
|
||||||
ScalarMult(dst, &in, &base)
|
|
||||||
if subtle.ConstantTimeCompare(dst[:], zero[:]) == 1 {
|
|
||||||
return nil, errors.New("bad input point: low order point")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return dst[:], nil
|
|
||||||
}
|
|
||||||
|
105
vendor/golang.org/x/crypto/curve25519/curve25519_compat.go
generated
vendored
Normal file
105
vendor/golang.org/x/crypto/curve25519/curve25519_compat.go
generated
vendored
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
// Copyright 2019 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
//go:build !go1.20
|
||||||
|
|
||||||
|
package curve25519
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto/subtle"
|
||||||
|
"errors"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"golang.org/x/crypto/curve25519/internal/field"
|
||||||
|
)
|
||||||
|
|
||||||
|
func scalarMult(dst, scalar, point *[32]byte) {
|
||||||
|
var e [32]byte
|
||||||
|
|
||||||
|
copy(e[:], scalar[:])
|
||||||
|
e[0] &= 248
|
||||||
|
e[31] &= 127
|
||||||
|
e[31] |= 64
|
||||||
|
|
||||||
|
var x1, x2, z2, x3, z3, tmp0, tmp1 field.Element
|
||||||
|
x1.SetBytes(point[:])
|
||||||
|
x2.One()
|
||||||
|
x3.Set(&x1)
|
||||||
|
z3.One()
|
||||||
|
|
||||||
|
swap := 0
|
||||||
|
for pos := 254; pos >= 0; pos-- {
|
||||||
|
b := e[pos/8] >> uint(pos&7)
|
||||||
|
b &= 1
|
||||||
|
swap ^= int(b)
|
||||||
|
x2.Swap(&x3, swap)
|
||||||
|
z2.Swap(&z3, swap)
|
||||||
|
swap = int(b)
|
||||||
|
|
||||||
|
tmp0.Subtract(&x3, &z3)
|
||||||
|
tmp1.Subtract(&x2, &z2)
|
||||||
|
x2.Add(&x2, &z2)
|
||||||
|
z2.Add(&x3, &z3)
|
||||||
|
z3.Multiply(&tmp0, &x2)
|
||||||
|
z2.Multiply(&z2, &tmp1)
|
||||||
|
tmp0.Square(&tmp1)
|
||||||
|
tmp1.Square(&x2)
|
||||||
|
x3.Add(&z3, &z2)
|
||||||
|
z2.Subtract(&z3, &z2)
|
||||||
|
x2.Multiply(&tmp1, &tmp0)
|
||||||
|
tmp1.Subtract(&tmp1, &tmp0)
|
||||||
|
z2.Square(&z2)
|
||||||
|
|
||||||
|
z3.Mult32(&tmp1, 121666)
|
||||||
|
x3.Square(&x3)
|
||||||
|
tmp0.Add(&tmp0, &z3)
|
||||||
|
z3.Multiply(&x1, &z2)
|
||||||
|
z2.Multiply(&tmp1, &tmp0)
|
||||||
|
}
|
||||||
|
|
||||||
|
x2.Swap(&x3, swap)
|
||||||
|
z2.Swap(&z3, swap)
|
||||||
|
|
||||||
|
z2.Invert(&z2)
|
||||||
|
x2.Multiply(&x2, &z2)
|
||||||
|
copy(dst[:], x2.Bytes())
|
||||||
|
}
|
||||||
|
|
||||||
|
func scalarBaseMult(dst, scalar *[32]byte) {
|
||||||
|
checkBasepoint()
|
||||||
|
scalarMult(dst, scalar, &basePoint)
|
||||||
|
}
|
||||||
|
|
||||||
|
func x25519(dst *[32]byte, scalar, point []byte) ([]byte, error) {
|
||||||
|
var in [32]byte
|
||||||
|
if l := len(scalar); l != 32 {
|
||||||
|
return nil, errors.New("bad scalar length: " + strconv.Itoa(l) + ", expected 32")
|
||||||
|
}
|
||||||
|
if l := len(point); l != 32 {
|
||||||
|
return nil, errors.New("bad point length: " + strconv.Itoa(l) + ", expected 32")
|
||||||
|
}
|
||||||
|
copy(in[:], scalar)
|
||||||
|
if &point[0] == &Basepoint[0] {
|
||||||
|
scalarBaseMult(dst, &in)
|
||||||
|
} else {
|
||||||
|
var base, zero [32]byte
|
||||||
|
copy(base[:], point)
|
||||||
|
scalarMult(dst, &in, &base)
|
||||||
|
if subtle.ConstantTimeCompare(dst[:], zero[:]) == 1 {
|
||||||
|
return nil, errors.New("bad input point: low order point")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dst[:], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func checkBasepoint() {
|
||||||
|
if subtle.ConstantTimeCompare(Basepoint, []byte{
|
||||||
|
0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
}) != 1 {
|
||||||
|
panic("curve25519: global Basepoint value was modified")
|
||||||
|
}
|
||||||
|
}
|
46
vendor/golang.org/x/crypto/curve25519/curve25519_go120.go
generated
vendored
Normal file
46
vendor/golang.org/x/crypto/curve25519/curve25519_go120.go
generated
vendored
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
// Copyright 2022 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
//go:build go1.20
|
||||||
|
|
||||||
|
package curve25519
|
||||||
|
|
||||||
|
import "crypto/ecdh"
|
||||||
|
|
||||||
|
func x25519(dst *[32]byte, scalar, point []byte) ([]byte, error) {
|
||||||
|
curve := ecdh.X25519()
|
||||||
|
pub, err := curve.NewPublicKey(point)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
priv, err := curve.NewPrivateKey(scalar)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
out, err := priv.ECDH(pub)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
copy(dst[:], out)
|
||||||
|
return dst[:], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func scalarMult(dst, scalar, point *[32]byte) {
|
||||||
|
if _, err := x25519(dst, scalar[:], point[:]); err != nil {
|
||||||
|
// The only error condition for x25519 when the inputs are 32 bytes long
|
||||||
|
// is if the output would have been the all-zero value.
|
||||||
|
for i := range dst {
|
||||||
|
dst[i] = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func scalarBaseMult(dst, scalar *[32]byte) {
|
||||||
|
curve := ecdh.X25519()
|
||||||
|
priv, err := curve.NewPrivateKey(scalar[:])
|
||||||
|
if err != nil {
|
||||||
|
panic("curve25519: internal error: scalarBaseMult was not 32 bytes")
|
||||||
|
}
|
||||||
|
copy(dst[:], priv.PublicKey().Bytes())
|
||||||
|
}
|
2
vendor/golang.org/x/crypto/curve25519/internal/field/fe_generic.go
generated
vendored
2
vendor/golang.org/x/crypto/curve25519/internal/field/fe_generic.go
generated
vendored
@ -245,7 +245,7 @@ func feSquareGeneric(v, a *Element) {
|
|||||||
v.carryPropagate()
|
v.carryPropagate()
|
||||||
}
|
}
|
||||||
|
|
||||||
// carryPropagate brings the limbs below 52 bits by applying the reduction
|
// carryPropagateGeneric brings the limbs below 52 bits by applying the reduction
|
||||||
// identity (a * 2²⁵⁵ + b = a * 19 + b) to the l4 carry. TODO inline
|
// identity (a * 2²⁵⁵ + b = a * 19 + b) to the l4 carry. TODO inline
|
||||||
func (v *Element) carryPropagateGeneric() *Element {
|
func (v *Element) carryPropagateGeneric() *Element {
|
||||||
c0 := v.l0 >> 51
|
c0 := v.l0 >> 51
|
||||||
|
2
vendor/golang.org/x/crypto/nacl/sign/sign.go
generated
vendored
2
vendor/golang.org/x/crypto/nacl/sign/sign.go
generated
vendored
@ -21,9 +21,9 @@
|
|||||||
package sign
|
package sign
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/ed25519"
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
"golang.org/x/crypto/ed25519"
|
|
||||||
"golang.org/x/crypto/internal/alias"
|
"golang.org/x/crypto/internal/alias"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/crypto/ssh/agent/client.go
generated
vendored
2
vendor/golang.org/x/crypto/ssh/agent/client.go
generated
vendored
@ -16,6 +16,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"crypto/dsa"
|
"crypto/dsa"
|
||||||
"crypto/ecdsa"
|
"crypto/ecdsa"
|
||||||
|
"crypto/ed25519"
|
||||||
"crypto/elliptic"
|
"crypto/elliptic"
|
||||||
"crypto/rsa"
|
"crypto/rsa"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
@ -26,7 +27,6 @@ import (
|
|||||||
"math/big"
|
"math/big"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"golang.org/x/crypto/ed25519"
|
|
||||||
"golang.org/x/crypto/ssh"
|
"golang.org/x/crypto/ssh"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
4
vendor/golang.org/x/crypto/ssh/agent/server.go
generated
vendored
4
vendor/golang.org/x/crypto/ssh/agent/server.go
generated
vendored
@ -7,6 +7,7 @@ package agent
|
|||||||
import (
|
import (
|
||||||
"crypto/dsa"
|
"crypto/dsa"
|
||||||
"crypto/ecdsa"
|
"crypto/ecdsa"
|
||||||
|
"crypto/ed25519"
|
||||||
"crypto/elliptic"
|
"crypto/elliptic"
|
||||||
"crypto/rsa"
|
"crypto/rsa"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
@ -16,11 +17,10 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
"golang.org/x/crypto/ed25519"
|
|
||||||
"golang.org/x/crypto/ssh"
|
"golang.org/x/crypto/ssh"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Server wraps an Agent and uses it to implement the agent side of
|
// server wraps an Agent and uses it to implement the agent side of
|
||||||
// the SSH-agent, wire protocol.
|
// the SSH-agent, wire protocol.
|
||||||
type server struct {
|
type server struct {
|
||||||
agent Agent
|
agent Agent
|
||||||
|
38
vendor/golang.org/x/crypto/ssh/certs.go
generated
vendored
38
vendor/golang.org/x/crypto/ssh/certs.go
generated
vendored
@ -16,8 +16,9 @@ import (
|
|||||||
|
|
||||||
// Certificate algorithm names from [PROTOCOL.certkeys]. These values can appear
|
// Certificate algorithm names from [PROTOCOL.certkeys]. These values can appear
|
||||||
// in Certificate.Type, PublicKey.Type, and ClientConfig.HostKeyAlgorithms.
|
// in Certificate.Type, PublicKey.Type, and ClientConfig.HostKeyAlgorithms.
|
||||||
// Unlike key algorithm names, these are not passed to AlgorithmSigner and don't
|
// Unlike key algorithm names, these are not passed to AlgorithmSigner nor
|
||||||
// appear in the Signature.Format field.
|
// returned by MultiAlgorithmSigner and don't appear in the Signature.Format
|
||||||
|
// field.
|
||||||
const (
|
const (
|
||||||
CertAlgoRSAv01 = "ssh-rsa-cert-v01@openssh.com"
|
CertAlgoRSAv01 = "ssh-rsa-cert-v01@openssh.com"
|
||||||
CertAlgoDSAv01 = "ssh-dss-cert-v01@openssh.com"
|
CertAlgoDSAv01 = "ssh-dss-cert-v01@openssh.com"
|
||||||
@ -255,10 +256,17 @@ func NewCertSigner(cert *Certificate, signer Signer) (Signer, error) {
|
|||||||
return nil, errors.New("ssh: signer and cert have different public key")
|
return nil, errors.New("ssh: signer and cert have different public key")
|
||||||
}
|
}
|
||||||
|
|
||||||
if algorithmSigner, ok := signer.(AlgorithmSigner); ok {
|
switch s := signer.(type) {
|
||||||
|
case MultiAlgorithmSigner:
|
||||||
|
return &multiAlgorithmSigner{
|
||||||
|
AlgorithmSigner: &algorithmOpenSSHCertSigner{
|
||||||
|
&openSSHCertSigner{cert, signer}, s},
|
||||||
|
supportedAlgorithms: s.Algorithms(),
|
||||||
|
}, nil
|
||||||
|
case AlgorithmSigner:
|
||||||
return &algorithmOpenSSHCertSigner{
|
return &algorithmOpenSSHCertSigner{
|
||||||
&openSSHCertSigner{cert, signer}, algorithmSigner}, nil
|
&openSSHCertSigner{cert, signer}, s}, nil
|
||||||
} else {
|
default:
|
||||||
return &openSSHCertSigner{cert, signer}, nil
|
return &openSSHCertSigner{cert, signer}, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -432,7 +440,9 @@ func (c *CertChecker) CheckCert(principal string, cert *Certificate) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SignCert signs the certificate with an authority, setting the Nonce,
|
// SignCert signs the certificate with an authority, setting the Nonce,
|
||||||
// SignatureKey, and Signature fields.
|
// SignatureKey, and Signature fields. If the authority implements the
|
||||||
|
// MultiAlgorithmSigner interface the first algorithm in the list is used. This
|
||||||
|
// is useful if you want to sign with a specific algorithm.
|
||||||
func (c *Certificate) SignCert(rand io.Reader, authority Signer) error {
|
func (c *Certificate) SignCert(rand io.Reader, authority Signer) error {
|
||||||
c.Nonce = make([]byte, 32)
|
c.Nonce = make([]byte, 32)
|
||||||
if _, err := io.ReadFull(rand, c.Nonce); err != nil {
|
if _, err := io.ReadFull(rand, c.Nonce); err != nil {
|
||||||
@ -440,8 +450,20 @@ func (c *Certificate) SignCert(rand io.Reader, authority Signer) error {
|
|||||||
}
|
}
|
||||||
c.SignatureKey = authority.PublicKey()
|
c.SignatureKey = authority.PublicKey()
|
||||||
|
|
||||||
// Default to KeyAlgoRSASHA512 for ssh-rsa signers.
|
if v, ok := authority.(MultiAlgorithmSigner); ok {
|
||||||
if v, ok := authority.(AlgorithmSigner); ok && v.PublicKey().Type() == KeyAlgoRSA {
|
if len(v.Algorithms()) == 0 {
|
||||||
|
return errors.New("the provided authority has no signature algorithm")
|
||||||
|
}
|
||||||
|
// Use the first algorithm in the list.
|
||||||
|
sig, err := v.SignWithAlgorithm(rand, c.bytesForSigning(), v.Algorithms()[0])
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
c.Signature = sig
|
||||||
|
return nil
|
||||||
|
} else if v, ok := authority.(AlgorithmSigner); ok && v.PublicKey().Type() == KeyAlgoRSA {
|
||||||
|
// Default to KeyAlgoRSASHA512 for ssh-rsa signers.
|
||||||
|
// TODO: consider using KeyAlgoRSASHA256 as default.
|
||||||
sig, err := v.SignWithAlgorithm(rand, c.bytesForSigning(), KeyAlgoRSASHA512)
|
sig, err := v.SignWithAlgorithm(rand, c.bytesForSigning(), KeyAlgoRSASHA512)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
3
vendor/golang.org/x/crypto/ssh/cipher.go
generated
vendored
3
vendor/golang.org/x/crypto/ssh/cipher.go
generated
vendored
@ -114,7 +114,8 @@ var cipherModes = map[string]*cipherMode{
|
|||||||
"arcfour": {16, 0, streamCipherMode(0, newRC4)},
|
"arcfour": {16, 0, streamCipherMode(0, newRC4)},
|
||||||
|
|
||||||
// AEAD ciphers
|
// AEAD ciphers
|
||||||
gcmCipherID: {16, 12, newGCMCipher},
|
gcm128CipherID: {16, 12, newGCMCipher},
|
||||||
|
gcm256CipherID: {32, 12, newGCMCipher},
|
||||||
chacha20Poly1305ID: {64, 0, newChaCha20Cipher},
|
chacha20Poly1305ID: {64, 0, newChaCha20Cipher},
|
||||||
|
|
||||||
// CBC mode is insecure and so is not included in the default config.
|
// CBC mode is insecure and so is not included in the default config.
|
||||||
|
96
vendor/golang.org/x/crypto/ssh/client_auth.go
generated
vendored
96
vendor/golang.org/x/crypto/ssh/client_auth.go
generated
vendored
@ -71,7 +71,9 @@ func (c *connection) clientAuthenticate(config *ClientConfig) error {
|
|||||||
for auth := AuthMethod(new(noneAuth)); auth != nil; {
|
for auth := AuthMethod(new(noneAuth)); auth != nil; {
|
||||||
ok, methods, err := auth.auth(sessionID, config.User, c.transport, config.Rand, extensions)
|
ok, methods, err := auth.auth(sessionID, config.User, c.transport, config.Rand, extensions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
// We return the error later if there is no other method left to
|
||||||
|
// try.
|
||||||
|
ok = authFailure
|
||||||
}
|
}
|
||||||
if ok == authSuccess {
|
if ok == authSuccess {
|
||||||
// success
|
// success
|
||||||
@ -101,6 +103,12 @@ func (c *connection) clientAuthenticate(config *ClientConfig) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if auth == nil && err != nil {
|
||||||
|
// We have an error and there are no other authentication methods to
|
||||||
|
// try, so we return it.
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return fmt.Errorf("ssh: unable to authenticate, attempted methods %v, no supported methods remain", tried)
|
return fmt.Errorf("ssh: unable to authenticate, attempted methods %v, no supported methods remain", tried)
|
||||||
}
|
}
|
||||||
@ -217,21 +225,45 @@ func (cb publicKeyCallback) method() string {
|
|||||||
return "publickey"
|
return "publickey"
|
||||||
}
|
}
|
||||||
|
|
||||||
func pickSignatureAlgorithm(signer Signer, extensions map[string][]byte) (as AlgorithmSigner, algo string) {
|
func pickSignatureAlgorithm(signer Signer, extensions map[string][]byte) (MultiAlgorithmSigner, string, error) {
|
||||||
|
var as MultiAlgorithmSigner
|
||||||
keyFormat := signer.PublicKey().Type()
|
keyFormat := signer.PublicKey().Type()
|
||||||
|
|
||||||
// Like in sendKexInit, if the public key implements AlgorithmSigner we
|
// If the signer implements MultiAlgorithmSigner we use the algorithms it
|
||||||
// assume it supports all algorithms, otherwise only the key format one.
|
// support, if it implements AlgorithmSigner we assume it supports all
|
||||||
as, ok := signer.(AlgorithmSigner)
|
// algorithms, otherwise only the key format one.
|
||||||
if !ok {
|
switch s := signer.(type) {
|
||||||
return algorithmSignerWrapper{signer}, keyFormat
|
case MultiAlgorithmSigner:
|
||||||
|
as = s
|
||||||
|
case AlgorithmSigner:
|
||||||
|
as = &multiAlgorithmSigner{
|
||||||
|
AlgorithmSigner: s,
|
||||||
|
supportedAlgorithms: algorithmsForKeyFormat(underlyingAlgo(keyFormat)),
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
as = &multiAlgorithmSigner{
|
||||||
|
AlgorithmSigner: algorithmSignerWrapper{signer},
|
||||||
|
supportedAlgorithms: []string{underlyingAlgo(keyFormat)},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getFallbackAlgo := func() (string, error) {
|
||||||
|
// Fallback to use if there is no "server-sig-algs" extension or a
|
||||||
|
// common algorithm cannot be found. We use the public key format if the
|
||||||
|
// MultiAlgorithmSigner supports it, otherwise we return an error.
|
||||||
|
if !contains(as.Algorithms(), underlyingAlgo(keyFormat)) {
|
||||||
|
return "", fmt.Errorf("ssh: no common public key signature algorithm, server only supports %q for key type %q, signer only supports %v",
|
||||||
|
underlyingAlgo(keyFormat), keyFormat, as.Algorithms())
|
||||||
|
}
|
||||||
|
return keyFormat, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
extPayload, ok := extensions["server-sig-algs"]
|
extPayload, ok := extensions["server-sig-algs"]
|
||||||
if !ok {
|
if !ok {
|
||||||
// If there is no "server-sig-algs" extension, fall back to the key
|
// If there is no "server-sig-algs" extension use the fallback
|
||||||
// format algorithm.
|
// algorithm.
|
||||||
return as, keyFormat
|
algo, err := getFallbackAlgo()
|
||||||
|
return as, algo, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// The server-sig-algs extension only carries underlying signature
|
// The server-sig-algs extension only carries underlying signature
|
||||||
@ -245,15 +277,22 @@ func pickSignatureAlgorithm(signer Signer, extensions map[string][]byte) (as Alg
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
keyAlgos := algorithmsForKeyFormat(keyFormat)
|
// Filter algorithms based on those supported by MultiAlgorithmSigner.
|
||||||
|
var keyAlgos []string
|
||||||
|
for _, algo := range algorithmsForKeyFormat(keyFormat) {
|
||||||
|
if contains(as.Algorithms(), underlyingAlgo(algo)) {
|
||||||
|
keyAlgos = append(keyAlgos, algo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
algo, err := findCommon("public key signature algorithm", keyAlgos, serverAlgos)
|
algo, err := findCommon("public key signature algorithm", keyAlgos, serverAlgos)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// If there is no overlap, try the key anyway with the key format
|
// If there is no overlap, return the fallback algorithm to support
|
||||||
// algorithm, to support servers that fail to list all supported
|
// servers that fail to list all supported algorithms.
|
||||||
// algorithms.
|
algo, err := getFallbackAlgo()
|
||||||
return as, keyFormat
|
return as, algo, err
|
||||||
}
|
}
|
||||||
return as, algo
|
return as, algo, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cb publicKeyCallback) auth(session []byte, user string, c packetConn, rand io.Reader, extensions map[string][]byte) (authResult, []string, error) {
|
func (cb publicKeyCallback) auth(session []byte, user string, c packetConn, rand io.Reader, extensions map[string][]byte) (authResult, []string, error) {
|
||||||
@ -267,10 +306,17 @@ func (cb publicKeyCallback) auth(session []byte, user string, c packetConn, rand
|
|||||||
return authFailure, nil, err
|
return authFailure, nil, err
|
||||||
}
|
}
|
||||||
var methods []string
|
var methods []string
|
||||||
|
var errSigAlgo error
|
||||||
for _, signer := range signers {
|
for _, signer := range signers {
|
||||||
pub := signer.PublicKey()
|
pub := signer.PublicKey()
|
||||||
as, algo := pickSignatureAlgorithm(signer, extensions)
|
as, algo, err := pickSignatureAlgorithm(signer, extensions)
|
||||||
|
if err != nil && errSigAlgo == nil {
|
||||||
|
// If we cannot negotiate a signature algorithm store the first
|
||||||
|
// error so we can return it to provide a more meaningful message if
|
||||||
|
// no other signers work.
|
||||||
|
errSigAlgo = err
|
||||||
|
continue
|
||||||
|
}
|
||||||
ok, err := validateKey(pub, algo, user, c)
|
ok, err := validateKey(pub, algo, user, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return authFailure, nil, err
|
return authFailure, nil, err
|
||||||
@ -317,22 +363,12 @@ func (cb publicKeyCallback) auth(session []byte, user string, c packetConn, rand
|
|||||||
// contain the "publickey" method, do not attempt to authenticate with any
|
// contain the "publickey" method, do not attempt to authenticate with any
|
||||||
// other keys. According to RFC 4252 Section 7, the latter can occur when
|
// other keys. According to RFC 4252 Section 7, the latter can occur when
|
||||||
// additional authentication methods are required.
|
// additional authentication methods are required.
|
||||||
if success == authSuccess || !containsMethod(methods, cb.method()) {
|
if success == authSuccess || !contains(methods, cb.method()) {
|
||||||
return success, methods, err
|
return success, methods, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return authFailure, methods, nil
|
return authFailure, methods, errSigAlgo
|
||||||
}
|
|
||||||
|
|
||||||
func containsMethod(methods []string, method string) bool {
|
|
||||||
for _, m := range methods {
|
|
||||||
if m == method {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// validateKey validates the key provided is acceptable to the server.
|
// validateKey validates the key provided is acceptable to the server.
|
||||||
|
75
vendor/golang.org/x/crypto/ssh/common.go
generated
vendored
75
vendor/golang.org/x/crypto/ssh/common.go
generated
vendored
@ -10,6 +10,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"math"
|
"math"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
_ "crypto/sha1"
|
_ "crypto/sha1"
|
||||||
@ -27,7 +28,7 @@ const (
|
|||||||
// supportedCiphers lists ciphers we support but might not recommend.
|
// supportedCiphers lists ciphers we support but might not recommend.
|
||||||
var supportedCiphers = []string{
|
var supportedCiphers = []string{
|
||||||
"aes128-ctr", "aes192-ctr", "aes256-ctr",
|
"aes128-ctr", "aes192-ctr", "aes256-ctr",
|
||||||
"aes128-gcm@openssh.com",
|
"aes128-gcm@openssh.com", gcm256CipherID,
|
||||||
chacha20Poly1305ID,
|
chacha20Poly1305ID,
|
||||||
"arcfour256", "arcfour128", "arcfour",
|
"arcfour256", "arcfour128", "arcfour",
|
||||||
aes128cbcID,
|
aes128cbcID,
|
||||||
@ -36,7 +37,7 @@ var supportedCiphers = []string{
|
|||||||
|
|
||||||
// preferredCiphers specifies the default preference for ciphers.
|
// preferredCiphers specifies the default preference for ciphers.
|
||||||
var preferredCiphers = []string{
|
var preferredCiphers = []string{
|
||||||
"aes128-gcm@openssh.com",
|
"aes128-gcm@openssh.com", gcm256CipherID,
|
||||||
chacha20Poly1305ID,
|
chacha20Poly1305ID,
|
||||||
"aes128-ctr", "aes192-ctr", "aes256-ctr",
|
"aes128-ctr", "aes192-ctr", "aes256-ctr",
|
||||||
}
|
}
|
||||||
@ -48,7 +49,8 @@ var supportedKexAlgos = []string{
|
|||||||
// P384 and P521 are not constant-time yet, but since we don't
|
// P384 and P521 are not constant-time yet, but since we don't
|
||||||
// reuse ephemeral keys, using them for ECDH should be OK.
|
// reuse ephemeral keys, using them for ECDH should be OK.
|
||||||
kexAlgoECDH256, kexAlgoECDH384, kexAlgoECDH521,
|
kexAlgoECDH256, kexAlgoECDH384, kexAlgoECDH521,
|
||||||
kexAlgoDH14SHA256, kexAlgoDH14SHA1, kexAlgoDH1SHA1,
|
kexAlgoDH14SHA256, kexAlgoDH16SHA512, kexAlgoDH14SHA1,
|
||||||
|
kexAlgoDH1SHA1,
|
||||||
}
|
}
|
||||||
|
|
||||||
// serverForbiddenKexAlgos contains key exchange algorithms, that are forbidden
|
// serverForbiddenKexAlgos contains key exchange algorithms, that are forbidden
|
||||||
@ -58,8 +60,9 @@ var serverForbiddenKexAlgos = map[string]struct{}{
|
|||||||
kexAlgoDHGEXSHA256: {}, // server half implementation is only minimal to satisfy the automated tests
|
kexAlgoDHGEXSHA256: {}, // server half implementation is only minimal to satisfy the automated tests
|
||||||
}
|
}
|
||||||
|
|
||||||
// preferredKexAlgos specifies the default preference for key-exchange algorithms
|
// preferredKexAlgos specifies the default preference for key-exchange
|
||||||
// in preference order.
|
// algorithms in preference order. The diffie-hellman-group16-sha512 algorithm
|
||||||
|
// is disabled by default because it is a bit slower than the others.
|
||||||
var preferredKexAlgos = []string{
|
var preferredKexAlgos = []string{
|
||||||
kexAlgoCurve25519SHA256, kexAlgoCurve25519SHA256LibSSH,
|
kexAlgoCurve25519SHA256, kexAlgoCurve25519SHA256LibSSH,
|
||||||
kexAlgoECDH256, kexAlgoECDH384, kexAlgoECDH521,
|
kexAlgoECDH256, kexAlgoECDH384, kexAlgoECDH521,
|
||||||
@ -69,12 +72,12 @@ var preferredKexAlgos = []string{
|
|||||||
// supportedHostKeyAlgos specifies the supported host-key algorithms (i.e. methods
|
// supportedHostKeyAlgos specifies the supported host-key algorithms (i.e. methods
|
||||||
// of authenticating servers) in preference order.
|
// of authenticating servers) in preference order.
|
||||||
var supportedHostKeyAlgos = []string{
|
var supportedHostKeyAlgos = []string{
|
||||||
CertAlgoRSASHA512v01, CertAlgoRSASHA256v01,
|
CertAlgoRSASHA256v01, CertAlgoRSASHA512v01,
|
||||||
CertAlgoRSAv01, CertAlgoDSAv01, CertAlgoECDSA256v01,
|
CertAlgoRSAv01, CertAlgoDSAv01, CertAlgoECDSA256v01,
|
||||||
CertAlgoECDSA384v01, CertAlgoECDSA521v01, CertAlgoED25519v01,
|
CertAlgoECDSA384v01, CertAlgoECDSA521v01, CertAlgoED25519v01,
|
||||||
|
|
||||||
KeyAlgoECDSA256, KeyAlgoECDSA384, KeyAlgoECDSA521,
|
KeyAlgoECDSA256, KeyAlgoECDSA384, KeyAlgoECDSA521,
|
||||||
KeyAlgoRSASHA512, KeyAlgoRSASHA256,
|
KeyAlgoRSASHA256, KeyAlgoRSASHA512,
|
||||||
KeyAlgoRSA, KeyAlgoDSA,
|
KeyAlgoRSA, KeyAlgoDSA,
|
||||||
|
|
||||||
KeyAlgoED25519,
|
KeyAlgoED25519,
|
||||||
@ -84,7 +87,7 @@ var supportedHostKeyAlgos = []string{
|
|||||||
// This is based on RFC 4253, section 6.4, but with hmac-md5 variants removed
|
// This is based on RFC 4253, section 6.4, but with hmac-md5 variants removed
|
||||||
// because they have reached the end of their useful life.
|
// because they have reached the end of their useful life.
|
||||||
var supportedMACs = []string{
|
var supportedMACs = []string{
|
||||||
"hmac-sha2-256-etm@openssh.com", "hmac-sha2-256", "hmac-sha1", "hmac-sha1-96",
|
"hmac-sha2-256-etm@openssh.com", "hmac-sha2-512-etm@openssh.com", "hmac-sha2-256", "hmac-sha2-512", "hmac-sha1", "hmac-sha1-96",
|
||||||
}
|
}
|
||||||
|
|
||||||
var supportedCompressions = []string{compressionNone}
|
var supportedCompressions = []string{compressionNone}
|
||||||
@ -118,6 +121,27 @@ func algorithmsForKeyFormat(keyFormat string) []string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// isRSA returns whether algo is a supported RSA algorithm, including certificate
|
||||||
|
// algorithms.
|
||||||
|
func isRSA(algo string) bool {
|
||||||
|
algos := algorithmsForKeyFormat(KeyAlgoRSA)
|
||||||
|
return contains(algos, underlyingAlgo(algo))
|
||||||
|
}
|
||||||
|
|
||||||
|
// supportedPubKeyAuthAlgos specifies the supported client public key
|
||||||
|
// authentication algorithms. Note that this doesn't include certificate types
|
||||||
|
// since those use the underlying algorithm. This list is sent to the client if
|
||||||
|
// it supports the server-sig-algs extension. Order is irrelevant.
|
||||||
|
var supportedPubKeyAuthAlgos = []string{
|
||||||
|
KeyAlgoED25519,
|
||||||
|
KeyAlgoSKED25519, KeyAlgoSKECDSA256,
|
||||||
|
KeyAlgoECDSA256, KeyAlgoECDSA384, KeyAlgoECDSA521,
|
||||||
|
KeyAlgoRSASHA256, KeyAlgoRSASHA512, KeyAlgoRSA,
|
||||||
|
KeyAlgoDSA,
|
||||||
|
}
|
||||||
|
|
||||||
|
var supportedPubKeyAuthAlgosList = strings.Join(supportedPubKeyAuthAlgos, ",")
|
||||||
|
|
||||||
// unexpectedMessageError results when the SSH message that we received didn't
|
// unexpectedMessageError results when the SSH message that we received didn't
|
||||||
// match what we wanted.
|
// match what we wanted.
|
||||||
func unexpectedMessageError(expected, got uint8) error {
|
func unexpectedMessageError(expected, got uint8) error {
|
||||||
@ -153,7 +177,7 @@ func (a *directionAlgorithms) rekeyBytes() int64 {
|
|||||||
// 2^(BLOCKSIZE/4) blocks. For all AES flavors BLOCKSIZE is
|
// 2^(BLOCKSIZE/4) blocks. For all AES flavors BLOCKSIZE is
|
||||||
// 128.
|
// 128.
|
||||||
switch a.Cipher {
|
switch a.Cipher {
|
||||||
case "aes128-ctr", "aes192-ctr", "aes256-ctr", gcmCipherID, aes128cbcID:
|
case "aes128-ctr", "aes192-ctr", "aes256-ctr", gcm128CipherID, gcm256CipherID, aes128cbcID:
|
||||||
return 16 * (1 << 32)
|
return 16 * (1 << 32)
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -163,7 +187,8 @@ func (a *directionAlgorithms) rekeyBytes() int64 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var aeadCiphers = map[string]bool{
|
var aeadCiphers = map[string]bool{
|
||||||
gcmCipherID: true,
|
gcm128CipherID: true,
|
||||||
|
gcm256CipherID: true,
|
||||||
chacha20Poly1305ID: true,
|
chacha20Poly1305ID: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -246,16 +271,16 @@ type Config struct {
|
|||||||
// unspecified, a size suitable for the chosen cipher is used.
|
// unspecified, a size suitable for the chosen cipher is used.
|
||||||
RekeyThreshold uint64
|
RekeyThreshold uint64
|
||||||
|
|
||||||
// The allowed key exchanges algorithms. If unspecified then a
|
// The allowed key exchanges algorithms. If unspecified then a default set
|
||||||
// default set of algorithms is used.
|
// of algorithms is used. Unsupported values are silently ignored.
|
||||||
KeyExchanges []string
|
KeyExchanges []string
|
||||||
|
|
||||||
// The allowed cipher algorithms. If unspecified then a sensible
|
// The allowed cipher algorithms. If unspecified then a sensible default is
|
||||||
// default is used.
|
// used. Unsupported values are silently ignored.
|
||||||
Ciphers []string
|
Ciphers []string
|
||||||
|
|
||||||
// The allowed MAC algorithms. If unspecified then a sensible default
|
// The allowed MAC algorithms. If unspecified then a sensible default is
|
||||||
// is used.
|
// used. Unsupported values are silently ignored.
|
||||||
MACs []string
|
MACs []string
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,7 +297,7 @@ func (c *Config) SetDefaults() {
|
|||||||
var ciphers []string
|
var ciphers []string
|
||||||
for _, c := range c.Ciphers {
|
for _, c := range c.Ciphers {
|
||||||
if cipherModes[c] != nil {
|
if cipherModes[c] != nil {
|
||||||
// reject the cipher if we have no cipherModes definition
|
// Ignore the cipher if we have no cipherModes definition.
|
||||||
ciphers = append(ciphers, c)
|
ciphers = append(ciphers, c)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -281,10 +306,26 @@ func (c *Config) SetDefaults() {
|
|||||||
if c.KeyExchanges == nil {
|
if c.KeyExchanges == nil {
|
||||||
c.KeyExchanges = preferredKexAlgos
|
c.KeyExchanges = preferredKexAlgos
|
||||||
}
|
}
|
||||||
|
var kexs []string
|
||||||
|
for _, k := range c.KeyExchanges {
|
||||||
|
if kexAlgoMap[k] != nil {
|
||||||
|
// Ignore the KEX if we have no kexAlgoMap definition.
|
||||||
|
kexs = append(kexs, k)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
c.KeyExchanges = kexs
|
||||||
|
|
||||||
if c.MACs == nil {
|
if c.MACs == nil {
|
||||||
c.MACs = supportedMACs
|
c.MACs = supportedMACs
|
||||||
}
|
}
|
||||||
|
var macs []string
|
||||||
|
for _, m := range c.MACs {
|
||||||
|
if macModes[m] != nil {
|
||||||
|
// Ignore the MAC if we have no macModes definition.
|
||||||
|
macs = append(macs, m)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
c.MACs = macs
|
||||||
|
|
||||||
if c.RekeyThreshold == 0 {
|
if c.RekeyThreshold == 0 {
|
||||||
// cipher specific default
|
// cipher specific default
|
||||||
|
2
vendor/golang.org/x/crypto/ssh/connection.go
generated
vendored
2
vendor/golang.org/x/crypto/ssh/connection.go
generated
vendored
@ -97,7 +97,7 @@ func (c *connection) Close() error {
|
|||||||
return c.sshConn.conn.Close()
|
return c.sshConn.conn.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
// sshconn provides net.Conn metadata, but disallows direct reads and
|
// sshConn provides net.Conn metadata, but disallows direct reads and
|
||||||
// writes.
|
// writes.
|
||||||
type sshConn struct {
|
type sshConn struct {
|
||||||
conn net.Conn
|
conn net.Conn
|
||||||
|
1
vendor/golang.org/x/crypto/ssh/doc.go
generated
vendored
1
vendor/golang.org/x/crypto/ssh/doc.go
generated
vendored
@ -13,6 +13,7 @@ others.
|
|||||||
|
|
||||||
References:
|
References:
|
||||||
|
|
||||||
|
[PROTOCOL]: https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/ssh/PROTOCOL?rev=HEAD
|
||||||
[PROTOCOL.certkeys]: http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/ssh/PROTOCOL.certkeys?rev=HEAD
|
[PROTOCOL.certkeys]: http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/ssh/PROTOCOL.certkeys?rev=HEAD
|
||||||
[SSH-PARAMETERS]: http://www.iana.org/assignments/ssh-parameters/ssh-parameters.xml#ssh-parameters-1
|
[SSH-PARAMETERS]: http://www.iana.org/assignments/ssh-parameters/ssh-parameters.xml#ssh-parameters-1
|
||||||
|
|
||||||
|
109
vendor/golang.org/x/crypto/ssh/handshake.go
generated
vendored
109
vendor/golang.org/x/crypto/ssh/handshake.go
generated
vendored
@ -58,11 +58,13 @@ type handshakeTransport struct {
|
|||||||
incoming chan []byte
|
incoming chan []byte
|
||||||
readError error
|
readError error
|
||||||
|
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
writeError error
|
writeError error
|
||||||
sentInitPacket []byte
|
sentInitPacket []byte
|
||||||
sentInitMsg *kexInitMsg
|
sentInitMsg *kexInitMsg
|
||||||
pendingPackets [][]byte // Used when a key exchange is in progress.
|
pendingPackets [][]byte // Used when a key exchange is in progress.
|
||||||
|
writePacketsLeft uint32
|
||||||
|
writeBytesLeft int64
|
||||||
|
|
||||||
// If the read loop wants to schedule a kex, it pings this
|
// If the read loop wants to schedule a kex, it pings this
|
||||||
// channel, and the write loop will send out a kex
|
// channel, and the write loop will send out a kex
|
||||||
@ -71,7 +73,8 @@ type handshakeTransport struct {
|
|||||||
|
|
||||||
// If the other side requests or confirms a kex, its kexInit
|
// If the other side requests or confirms a kex, its kexInit
|
||||||
// packet is sent here for the write loop to find it.
|
// packet is sent here for the write loop to find it.
|
||||||
startKex chan *pendingKex
|
startKex chan *pendingKex
|
||||||
|
kexLoopDone chan struct{} // closed (with writeError non-nil) when kexLoop exits
|
||||||
|
|
||||||
// data for host key checking
|
// data for host key checking
|
||||||
hostKeyCallback HostKeyCallback
|
hostKeyCallback HostKeyCallback
|
||||||
@ -86,12 +89,10 @@ type handshakeTransport struct {
|
|||||||
// Algorithms agreed in the last key exchange.
|
// Algorithms agreed in the last key exchange.
|
||||||
algorithms *algorithms
|
algorithms *algorithms
|
||||||
|
|
||||||
|
// Counters exclusively owned by readLoop.
|
||||||
readPacketsLeft uint32
|
readPacketsLeft uint32
|
||||||
readBytesLeft int64
|
readBytesLeft int64
|
||||||
|
|
||||||
writePacketsLeft uint32
|
|
||||||
writeBytesLeft int64
|
|
||||||
|
|
||||||
// The session ID or nil if first kex did not complete yet.
|
// The session ID or nil if first kex did not complete yet.
|
||||||
sessionID []byte
|
sessionID []byte
|
||||||
}
|
}
|
||||||
@ -108,7 +109,8 @@ func newHandshakeTransport(conn keyingTransport, config *Config, clientVersion,
|
|||||||
clientVersion: clientVersion,
|
clientVersion: clientVersion,
|
||||||
incoming: make(chan []byte, chanSize),
|
incoming: make(chan []byte, chanSize),
|
||||||
requestKex: make(chan struct{}, 1),
|
requestKex: make(chan struct{}, 1),
|
||||||
startKex: make(chan *pendingKex, 1),
|
startKex: make(chan *pendingKex),
|
||||||
|
kexLoopDone: make(chan struct{}),
|
||||||
|
|
||||||
config: config,
|
config: config,
|
||||||
}
|
}
|
||||||
@ -340,16 +342,17 @@ write:
|
|||||||
t.mu.Unlock()
|
t.mu.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
// drain startKex channel. We don't service t.requestKex
|
|
||||||
// because nobody does blocking sends there.
|
|
||||||
go func() {
|
|
||||||
for init := range t.startKex {
|
|
||||||
init.done <- t.writeError
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
// Unblock reader.
|
// Unblock reader.
|
||||||
t.conn.Close()
|
t.conn.Close()
|
||||||
|
|
||||||
|
// drain startKex channel. We don't service t.requestKex
|
||||||
|
// because nobody does blocking sends there.
|
||||||
|
for request := range t.startKex {
|
||||||
|
request.done <- t.getWriteError()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mark that the loop is done so that Close can return.
|
||||||
|
close(t.kexLoopDone)
|
||||||
}
|
}
|
||||||
|
|
||||||
// The protocol uses uint32 for packet counters, so we can't let them
|
// The protocol uses uint32 for packet counters, so we can't let them
|
||||||
@ -458,19 +461,24 @@ func (t *handshakeTransport) sendKexInit() error {
|
|||||||
isServer := len(t.hostKeys) > 0
|
isServer := len(t.hostKeys) > 0
|
||||||
if isServer {
|
if isServer {
|
||||||
for _, k := range t.hostKeys {
|
for _, k := range t.hostKeys {
|
||||||
// If k is an AlgorithmSigner, presume it supports all signature algorithms
|
// If k is a MultiAlgorithmSigner, we restrict the signature
|
||||||
// associated with the key format. (Ideally AlgorithmSigner would have a
|
// algorithms. If k is a AlgorithmSigner, presume it supports all
|
||||||
// method to advertise supported algorithms, but it doesn't. This means that
|
// signature algorithms associated with the key format. If k is not
|
||||||
// adding support for a new algorithm is a breaking change, as we will
|
// an AlgorithmSigner, we can only assume it only supports the
|
||||||
// immediately negotiate it even if existing implementations don't support
|
// algorithms that matches the key format. (This means that Sign
|
||||||
// it. If that ever happens, we'll have to figure something out.)
|
// can't pick a different default).
|
||||||
// If k is not an AlgorithmSigner, we can only assume it only supports the
|
|
||||||
// algorithms that matches the key format. (This means that Sign can't pick
|
|
||||||
// a different default.)
|
|
||||||
keyFormat := k.PublicKey().Type()
|
keyFormat := k.PublicKey().Type()
|
||||||
if _, ok := k.(AlgorithmSigner); ok {
|
|
||||||
|
switch s := k.(type) {
|
||||||
|
case MultiAlgorithmSigner:
|
||||||
|
for _, algo := range algorithmsForKeyFormat(keyFormat) {
|
||||||
|
if contains(s.Algorithms(), underlyingAlgo(algo)) {
|
||||||
|
msg.ServerHostKeyAlgos = append(msg.ServerHostKeyAlgos, algo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case AlgorithmSigner:
|
||||||
msg.ServerHostKeyAlgos = append(msg.ServerHostKeyAlgos, algorithmsForKeyFormat(keyFormat)...)
|
msg.ServerHostKeyAlgos = append(msg.ServerHostKeyAlgos, algorithmsForKeyFormat(keyFormat)...)
|
||||||
} else {
|
default:
|
||||||
msg.ServerHostKeyAlgos = append(msg.ServerHostKeyAlgos, keyFormat)
|
msg.ServerHostKeyAlgos = append(msg.ServerHostKeyAlgos, keyFormat)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -545,7 +553,16 @@ func (t *handshakeTransport) writePacket(p []byte) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *handshakeTransport) Close() error {
|
func (t *handshakeTransport) Close() error {
|
||||||
return t.conn.Close()
|
// Close the connection. This should cause the readLoop goroutine to wake up
|
||||||
|
// and close t.startKex, which will shut down kexLoop if running.
|
||||||
|
err := t.conn.Close()
|
||||||
|
|
||||||
|
// Wait for the kexLoop goroutine to complete.
|
||||||
|
// At that point we know that the readLoop goroutine is complete too,
|
||||||
|
// because kexLoop itself waits for readLoop to close the startKex channel.
|
||||||
|
<-t.kexLoopDone
|
||||||
|
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *handshakeTransport) enterKeyExchange(otherInitPacket []byte) error {
|
func (t *handshakeTransport) enterKeyExchange(otherInitPacket []byte) error {
|
||||||
@ -615,7 +632,8 @@ func (t *handshakeTransport) enterKeyExchange(otherInitPacket []byte) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if t.sessionID == nil {
|
firstKeyExchange := t.sessionID == nil
|
||||||
|
if firstKeyExchange {
|
||||||
t.sessionID = result.H
|
t.sessionID = result.H
|
||||||
}
|
}
|
||||||
result.SessionID = t.sessionID
|
result.SessionID = t.sessionID
|
||||||
@ -626,6 +644,28 @@ func (t *handshakeTransport) enterKeyExchange(otherInitPacket []byte) error {
|
|||||||
if err = t.conn.writePacket([]byte{msgNewKeys}); err != nil {
|
if err = t.conn.writePacket([]byte{msgNewKeys}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// On the server side, after the first SSH_MSG_NEWKEYS, send a SSH_MSG_EXT_INFO
|
||||||
|
// message with the server-sig-algs extension if the client supports it. See
|
||||||
|
// RFC 8308, Sections 2.4 and 3.1, and [PROTOCOL], Section 1.9.
|
||||||
|
if !isClient && firstKeyExchange && contains(clientInit.KexAlgos, "ext-info-c") {
|
||||||
|
extInfo := &extInfoMsg{
|
||||||
|
NumExtensions: 2,
|
||||||
|
Payload: make([]byte, 0, 4+15+4+len(supportedPubKeyAuthAlgosList)+4+16+4+1),
|
||||||
|
}
|
||||||
|
extInfo.Payload = appendInt(extInfo.Payload, len("server-sig-algs"))
|
||||||
|
extInfo.Payload = append(extInfo.Payload, "server-sig-algs"...)
|
||||||
|
extInfo.Payload = appendInt(extInfo.Payload, len(supportedPubKeyAuthAlgosList))
|
||||||
|
extInfo.Payload = append(extInfo.Payload, supportedPubKeyAuthAlgosList...)
|
||||||
|
extInfo.Payload = appendInt(extInfo.Payload, len("ping@openssh.com"))
|
||||||
|
extInfo.Payload = append(extInfo.Payload, "ping@openssh.com"...)
|
||||||
|
extInfo.Payload = appendInt(extInfo.Payload, 1)
|
||||||
|
extInfo.Payload = append(extInfo.Payload, "0"...)
|
||||||
|
if err := t.conn.writePacket(Marshal(extInfo)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if packet, err := t.conn.readPacket(); err != nil {
|
if packet, err := t.conn.readPacket(); err != nil {
|
||||||
return err
|
return err
|
||||||
} else if packet[0] != msgNewKeys {
|
} else if packet[0] != msgNewKeys {
|
||||||
@ -654,9 +694,16 @@ func (a algorithmSignerWrapper) SignWithAlgorithm(rand io.Reader, data []byte, a
|
|||||||
|
|
||||||
func pickHostKey(hostKeys []Signer, algo string) AlgorithmSigner {
|
func pickHostKey(hostKeys []Signer, algo string) AlgorithmSigner {
|
||||||
for _, k := range hostKeys {
|
for _, k := range hostKeys {
|
||||||
|
if s, ok := k.(MultiAlgorithmSigner); ok {
|
||||||
|
if !contains(s.Algorithms(), underlyingAlgo(algo)) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if algo == k.PublicKey().Type() {
|
if algo == k.PublicKey().Type() {
|
||||||
return algorithmSignerWrapper{k}
|
return algorithmSignerWrapper{k}
|
||||||
}
|
}
|
||||||
|
|
||||||
k, ok := k.(AlgorithmSigner)
|
k, ok := k.(AlgorithmSigner)
|
||||||
if !ok {
|
if !ok {
|
||||||
continue
|
continue
|
||||||
|
12
vendor/golang.org/x/crypto/ssh/kex.go
generated
vendored
12
vendor/golang.org/x/crypto/ssh/kex.go
generated
vendored
@ -23,6 +23,7 @@ const (
|
|||||||
kexAlgoDH1SHA1 = "diffie-hellman-group1-sha1"
|
kexAlgoDH1SHA1 = "diffie-hellman-group1-sha1"
|
||||||
kexAlgoDH14SHA1 = "diffie-hellman-group14-sha1"
|
kexAlgoDH14SHA1 = "diffie-hellman-group14-sha1"
|
||||||
kexAlgoDH14SHA256 = "diffie-hellman-group14-sha256"
|
kexAlgoDH14SHA256 = "diffie-hellman-group14-sha256"
|
||||||
|
kexAlgoDH16SHA512 = "diffie-hellman-group16-sha512"
|
||||||
kexAlgoECDH256 = "ecdh-sha2-nistp256"
|
kexAlgoECDH256 = "ecdh-sha2-nistp256"
|
||||||
kexAlgoECDH384 = "ecdh-sha2-nistp384"
|
kexAlgoECDH384 = "ecdh-sha2-nistp384"
|
||||||
kexAlgoECDH521 = "ecdh-sha2-nistp521"
|
kexAlgoECDH521 = "ecdh-sha2-nistp521"
|
||||||
@ -430,6 +431,17 @@ func init() {
|
|||||||
hashFunc: crypto.SHA256,
|
hashFunc: crypto.SHA256,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is the group called diffie-hellman-group16-sha512 in RFC
|
||||||
|
// 8268 and Oakley Group 16 in RFC 3526.
|
||||||
|
p, _ = new(big.Int).SetString("FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3BE39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF6955817183995497CEA956AE515D2261898FA051015728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6BF12FFA06D98A0864D87602733EC86A64521F2B18177B200CBBE117577A615D6C770988C0BAD946E208E24FA074E5AB3143DB5BFCE0FD108E4B82D120A92108011A723C12A787E6D788719A10BDBA5B2699C327186AF4E23C1A946834B6150BDA2583E9CA2AD44CE8DBBBC2DB04DE8EF92E8EFC141FBECAA6287C59474E6BC05D99B2964FA090C3A2233BA186515BE7ED1F612970CEE2D7AFB81BDD762170481CD0069127D5B05AA993B4EA988D8FDDC186FFB7DC90A6C08F4DF435C934063199FFFFFFFFFFFFFFFF", 16)
|
||||||
|
|
||||||
|
kexAlgoMap[kexAlgoDH16SHA512] = &dhGroup{
|
||||||
|
g: new(big.Int).SetInt64(2),
|
||||||
|
p: p,
|
||||||
|
pMinus1: new(big.Int).Sub(p, bigOne),
|
||||||
|
hashFunc: crypto.SHA512,
|
||||||
|
}
|
||||||
|
|
||||||
kexAlgoMap[kexAlgoECDH521] = &ecdh{elliptic.P521()}
|
kexAlgoMap[kexAlgoECDH521] = &ecdh{elliptic.P521()}
|
||||||
kexAlgoMap[kexAlgoECDH384] = &ecdh{elliptic.P384()}
|
kexAlgoMap[kexAlgoECDH384] = &ecdh{elliptic.P384()}
|
||||||
kexAlgoMap[kexAlgoECDH256] = &ecdh{elliptic.P256()}
|
kexAlgoMap[kexAlgoECDH256] = &ecdh{elliptic.P256()}
|
||||||
|
382
vendor/golang.org/x/crypto/ssh/keys.go
generated
vendored
382
vendor/golang.org/x/crypto/ssh/keys.go
generated
vendored
@ -11,13 +11,16 @@ import (
|
|||||||
"crypto/cipher"
|
"crypto/cipher"
|
||||||
"crypto/dsa"
|
"crypto/dsa"
|
||||||
"crypto/ecdsa"
|
"crypto/ecdsa"
|
||||||
|
"crypto/ed25519"
|
||||||
"crypto/elliptic"
|
"crypto/elliptic"
|
||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
|
"crypto/rand"
|
||||||
"crypto/rsa"
|
"crypto/rsa"
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"encoding/asn1"
|
"encoding/asn1"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
|
"encoding/binary"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/pem"
|
"encoding/pem"
|
||||||
"errors"
|
"errors"
|
||||||
@ -26,7 +29,6 @@ import (
|
|||||||
"math/big"
|
"math/big"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"golang.org/x/crypto/ed25519"
|
|
||||||
"golang.org/x/crypto/ssh/internal/bcrypt_pbkdf"
|
"golang.org/x/crypto/ssh/internal/bcrypt_pbkdf"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -295,6 +297,18 @@ func MarshalAuthorizedKey(key PublicKey) []byte {
|
|||||||
return b.Bytes()
|
return b.Bytes()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MarshalPrivateKey returns a PEM block with the private key serialized in the
|
||||||
|
// OpenSSH format.
|
||||||
|
func MarshalPrivateKey(key crypto.PrivateKey, comment string) (*pem.Block, error) {
|
||||||
|
return marshalOpenSSHPrivateKey(key, comment, unencryptedOpenSSHMarshaler)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalPrivateKeyWithPassphrase returns a PEM block holding the encrypted
|
||||||
|
// private key serialized in the OpenSSH format.
|
||||||
|
func MarshalPrivateKeyWithPassphrase(key crypto.PrivateKey, comment string, passphrase []byte) (*pem.Block, error) {
|
||||||
|
return marshalOpenSSHPrivateKey(key, comment, passphraseProtectedOpenSSHMarshaler(passphrase))
|
||||||
|
}
|
||||||
|
|
||||||
// PublicKey represents a public key using an unspecified algorithm.
|
// PublicKey represents a public key using an unspecified algorithm.
|
||||||
//
|
//
|
||||||
// Some PublicKeys provided by this package also implement CryptoPublicKey.
|
// Some PublicKeys provided by this package also implement CryptoPublicKey.
|
||||||
@ -321,7 +335,7 @@ type CryptoPublicKey interface {
|
|||||||
|
|
||||||
// A Signer can create signatures that verify against a public key.
|
// A Signer can create signatures that verify against a public key.
|
||||||
//
|
//
|
||||||
// Some Signers provided by this package also implement AlgorithmSigner.
|
// Some Signers provided by this package also implement MultiAlgorithmSigner.
|
||||||
type Signer interface {
|
type Signer interface {
|
||||||
// PublicKey returns the associated PublicKey.
|
// PublicKey returns the associated PublicKey.
|
||||||
PublicKey() PublicKey
|
PublicKey() PublicKey
|
||||||
@ -336,9 +350,9 @@ type Signer interface {
|
|||||||
// An AlgorithmSigner is a Signer that also supports specifying an algorithm to
|
// An AlgorithmSigner is a Signer that also supports specifying an algorithm to
|
||||||
// use for signing.
|
// use for signing.
|
||||||
//
|
//
|
||||||
// An AlgorithmSigner can't advertise the algorithms it supports, so it should
|
// An AlgorithmSigner can't advertise the algorithms it supports, unless it also
|
||||||
// be prepared to be invoked with every algorithm supported by the public key
|
// implements MultiAlgorithmSigner, so it should be prepared to be invoked with
|
||||||
// format.
|
// every algorithm supported by the public key format.
|
||||||
type AlgorithmSigner interface {
|
type AlgorithmSigner interface {
|
||||||
Signer
|
Signer
|
||||||
|
|
||||||
@ -349,6 +363,75 @@ type AlgorithmSigner interface {
|
|||||||
SignWithAlgorithm(rand io.Reader, data []byte, algorithm string) (*Signature, error)
|
SignWithAlgorithm(rand io.Reader, data []byte, algorithm string) (*Signature, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MultiAlgorithmSigner is an AlgorithmSigner that also reports the algorithms
|
||||||
|
// supported by that signer.
|
||||||
|
type MultiAlgorithmSigner interface {
|
||||||
|
AlgorithmSigner
|
||||||
|
|
||||||
|
// Algorithms returns the available algorithms in preference order. The list
|
||||||
|
// must not be empty, and it must not include certificate types.
|
||||||
|
Algorithms() []string
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewSignerWithAlgorithms returns a signer restricted to the specified
|
||||||
|
// algorithms. The algorithms must be set in preference order. The list must not
|
||||||
|
// be empty, and it must not include certificate types. An error is returned if
|
||||||
|
// the specified algorithms are incompatible with the public key type.
|
||||||
|
func NewSignerWithAlgorithms(signer AlgorithmSigner, algorithms []string) (MultiAlgorithmSigner, error) {
|
||||||
|
if len(algorithms) == 0 {
|
||||||
|
return nil, errors.New("ssh: please specify at least one valid signing algorithm")
|
||||||
|
}
|
||||||
|
var signerAlgos []string
|
||||||
|
supportedAlgos := algorithmsForKeyFormat(underlyingAlgo(signer.PublicKey().Type()))
|
||||||
|
if s, ok := signer.(*multiAlgorithmSigner); ok {
|
||||||
|
signerAlgos = s.Algorithms()
|
||||||
|
} else {
|
||||||
|
signerAlgos = supportedAlgos
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, algo := range algorithms {
|
||||||
|
if !contains(supportedAlgos, algo) {
|
||||||
|
return nil, fmt.Errorf("ssh: algorithm %q is not supported for key type %q",
|
||||||
|
algo, signer.PublicKey().Type())
|
||||||
|
}
|
||||||
|
if !contains(signerAlgos, algo) {
|
||||||
|
return nil, fmt.Errorf("ssh: algorithm %q is restricted for the provided signer", algo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return &multiAlgorithmSigner{
|
||||||
|
AlgorithmSigner: signer,
|
||||||
|
supportedAlgorithms: algorithms,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type multiAlgorithmSigner struct {
|
||||||
|
AlgorithmSigner
|
||||||
|
supportedAlgorithms []string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *multiAlgorithmSigner) Algorithms() []string {
|
||||||
|
return s.supportedAlgorithms
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *multiAlgorithmSigner) isAlgorithmSupported(algorithm string) bool {
|
||||||
|
if algorithm == "" {
|
||||||
|
algorithm = underlyingAlgo(s.PublicKey().Type())
|
||||||
|
}
|
||||||
|
for _, algo := range s.supportedAlgorithms {
|
||||||
|
if algorithm == algo {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *multiAlgorithmSigner) SignWithAlgorithm(rand io.Reader, data []byte, algorithm string) (*Signature, error) {
|
||||||
|
if !s.isAlgorithmSupported(algorithm) {
|
||||||
|
return nil, fmt.Errorf("ssh: algorithm %q is not supported: %v", algorithm, s.supportedAlgorithms)
|
||||||
|
}
|
||||||
|
return s.AlgorithmSigner.SignWithAlgorithm(rand, data, algorithm)
|
||||||
|
}
|
||||||
|
|
||||||
type rsaPublicKey rsa.PublicKey
|
type rsaPublicKey rsa.PublicKey
|
||||||
|
|
||||||
func (r *rsaPublicKey) Type() string {
|
func (r *rsaPublicKey) Type() string {
|
||||||
@ -512,6 +595,10 @@ func (k *dsaPrivateKey) Sign(rand io.Reader, data []byte) (*Signature, error) {
|
|||||||
return k.SignWithAlgorithm(rand, data, k.PublicKey().Type())
|
return k.SignWithAlgorithm(rand, data, k.PublicKey().Type())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (k *dsaPrivateKey) Algorithms() []string {
|
||||||
|
return []string{k.PublicKey().Type()}
|
||||||
|
}
|
||||||
|
|
||||||
func (k *dsaPrivateKey) SignWithAlgorithm(rand io.Reader, data []byte, algorithm string) (*Signature, error) {
|
func (k *dsaPrivateKey) SignWithAlgorithm(rand io.Reader, data []byte, algorithm string) (*Signature, error) {
|
||||||
if algorithm != "" && algorithm != k.PublicKey().Type() {
|
if algorithm != "" && algorithm != k.PublicKey().Type() {
|
||||||
return nil, fmt.Errorf("ssh: unsupported signature algorithm %s", algorithm)
|
return nil, fmt.Errorf("ssh: unsupported signature algorithm %s", algorithm)
|
||||||
@ -961,13 +1048,16 @@ func (s *wrappedSigner) Sign(rand io.Reader, data []byte) (*Signature, error) {
|
|||||||
return s.SignWithAlgorithm(rand, data, s.pubKey.Type())
|
return s.SignWithAlgorithm(rand, data, s.pubKey.Type())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *wrappedSigner) Algorithms() []string {
|
||||||
|
return algorithmsForKeyFormat(s.pubKey.Type())
|
||||||
|
}
|
||||||
|
|
||||||
func (s *wrappedSigner) SignWithAlgorithm(rand io.Reader, data []byte, algorithm string) (*Signature, error) {
|
func (s *wrappedSigner) SignWithAlgorithm(rand io.Reader, data []byte, algorithm string) (*Signature, error) {
|
||||||
if algorithm == "" {
|
if algorithm == "" {
|
||||||
algorithm = s.pubKey.Type()
|
algorithm = s.pubKey.Type()
|
||||||
}
|
}
|
||||||
|
|
||||||
supportedAlgos := algorithmsForKeyFormat(s.pubKey.Type())
|
if !contains(s.Algorithms(), algorithm) {
|
||||||
if !contains(supportedAlgos, algorithm) {
|
|
||||||
return nil, fmt.Errorf("ssh: unsupported signature algorithm %q for key format %q", algorithm, s.pubKey.Type())
|
return nil, fmt.Errorf("ssh: unsupported signature algorithm %q for key format %q", algorithm, s.pubKey.Type())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1087,9 +1177,9 @@ func (*PassphraseMissingError) Error() string {
|
|||||||
return "ssh: this private key is passphrase protected"
|
return "ssh: this private key is passphrase protected"
|
||||||
}
|
}
|
||||||
|
|
||||||
// ParseRawPrivateKey returns a private key from a PEM encoded private key. It
|
// ParseRawPrivateKey returns a private key from a PEM encoded private key. It supports
|
||||||
// supports RSA (PKCS#1), PKCS#8, DSA (OpenSSL), and ECDSA private keys. If the
|
// RSA, DSA, ECDSA, and Ed25519 private keys in PKCS#1, PKCS#8, OpenSSL, and OpenSSH
|
||||||
// private key is encrypted, it will return a PassphraseMissingError.
|
// formats. If the private key is encrypted, it will return a PassphraseMissingError.
|
||||||
func ParseRawPrivateKey(pemBytes []byte) (interface{}, error) {
|
func ParseRawPrivateKey(pemBytes []byte) (interface{}, error) {
|
||||||
block, _ := pem.Decode(pemBytes)
|
block, _ := pem.Decode(pemBytes)
|
||||||
if block == nil {
|
if block == nil {
|
||||||
@ -1241,28 +1331,106 @@ func passphraseProtectedOpenSSHKey(passphrase []byte) openSSHDecryptFunc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func unencryptedOpenSSHMarshaler(privKeyBlock []byte) ([]byte, string, string, string, error) {
|
||||||
|
key := generateOpenSSHPadding(privKeyBlock, 8)
|
||||||
|
return key, "none", "none", "", nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func passphraseProtectedOpenSSHMarshaler(passphrase []byte) openSSHEncryptFunc {
|
||||||
|
return func(privKeyBlock []byte) ([]byte, string, string, string, error) {
|
||||||
|
salt := make([]byte, 16)
|
||||||
|
if _, err := rand.Read(salt); err != nil {
|
||||||
|
return nil, "", "", "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
opts := struct {
|
||||||
|
Salt []byte
|
||||||
|
Rounds uint32
|
||||||
|
}{salt, 16}
|
||||||
|
|
||||||
|
// Derive key to encrypt the private key block.
|
||||||
|
k, err := bcrypt_pbkdf.Key(passphrase, salt, int(opts.Rounds), 32+aes.BlockSize)
|
||||||
|
if err != nil {
|
||||||
|
return nil, "", "", "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add padding matching the block size of AES.
|
||||||
|
keyBlock := generateOpenSSHPadding(privKeyBlock, aes.BlockSize)
|
||||||
|
|
||||||
|
// Encrypt the private key using the derived secret.
|
||||||
|
|
||||||
|
dst := make([]byte, len(keyBlock))
|
||||||
|
key, iv := k[:32], k[32:]
|
||||||
|
block, err := aes.NewCipher(key)
|
||||||
|
if err != nil {
|
||||||
|
return nil, "", "", "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
stream := cipher.NewCTR(block, iv)
|
||||||
|
stream.XORKeyStream(dst, keyBlock)
|
||||||
|
|
||||||
|
return dst, "aes256-ctr", "bcrypt", string(Marshal(opts)), nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const privateKeyAuthMagic = "openssh-key-v1\x00"
|
||||||
|
|
||||||
type openSSHDecryptFunc func(CipherName, KdfName, KdfOpts string, PrivKeyBlock []byte) ([]byte, error)
|
type openSSHDecryptFunc func(CipherName, KdfName, KdfOpts string, PrivKeyBlock []byte) ([]byte, error)
|
||||||
|
type openSSHEncryptFunc func(PrivKeyBlock []byte) (ProtectedKeyBlock []byte, cipherName, kdfName, kdfOptions string, err error)
|
||||||
|
|
||||||
|
type openSSHEncryptedPrivateKey struct {
|
||||||
|
CipherName string
|
||||||
|
KdfName string
|
||||||
|
KdfOpts string
|
||||||
|
NumKeys uint32
|
||||||
|
PubKey []byte
|
||||||
|
PrivKeyBlock []byte
|
||||||
|
}
|
||||||
|
|
||||||
|
type openSSHPrivateKey struct {
|
||||||
|
Check1 uint32
|
||||||
|
Check2 uint32
|
||||||
|
Keytype string
|
||||||
|
Rest []byte `ssh:"rest"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type openSSHRSAPrivateKey struct {
|
||||||
|
N *big.Int
|
||||||
|
E *big.Int
|
||||||
|
D *big.Int
|
||||||
|
Iqmp *big.Int
|
||||||
|
P *big.Int
|
||||||
|
Q *big.Int
|
||||||
|
Comment string
|
||||||
|
Pad []byte `ssh:"rest"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type openSSHEd25519PrivateKey struct {
|
||||||
|
Pub []byte
|
||||||
|
Priv []byte
|
||||||
|
Comment string
|
||||||
|
Pad []byte `ssh:"rest"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type openSSHECDSAPrivateKey struct {
|
||||||
|
Curve string
|
||||||
|
Pub []byte
|
||||||
|
D *big.Int
|
||||||
|
Comment string
|
||||||
|
Pad []byte `ssh:"rest"`
|
||||||
|
}
|
||||||
|
|
||||||
// parseOpenSSHPrivateKey parses an OpenSSH private key, using the decrypt
|
// parseOpenSSHPrivateKey parses an OpenSSH private key, using the decrypt
|
||||||
// function to unwrap the encrypted portion. unencryptedOpenSSHKey can be used
|
// function to unwrap the encrypted portion. unencryptedOpenSSHKey can be used
|
||||||
// as the decrypt function to parse an unencrypted private key. See
|
// as the decrypt function to parse an unencrypted private key. See
|
||||||
// https://github.com/openssh/openssh-portable/blob/master/PROTOCOL.key.
|
// https://github.com/openssh/openssh-portable/blob/master/PROTOCOL.key.
|
||||||
func parseOpenSSHPrivateKey(key []byte, decrypt openSSHDecryptFunc) (crypto.PrivateKey, error) {
|
func parseOpenSSHPrivateKey(key []byte, decrypt openSSHDecryptFunc) (crypto.PrivateKey, error) {
|
||||||
const magic = "openssh-key-v1\x00"
|
if len(key) < len(privateKeyAuthMagic) || string(key[:len(privateKeyAuthMagic)]) != privateKeyAuthMagic {
|
||||||
if len(key) < len(magic) || string(key[:len(magic)]) != magic {
|
|
||||||
return nil, errors.New("ssh: invalid openssh private key format")
|
return nil, errors.New("ssh: invalid openssh private key format")
|
||||||
}
|
}
|
||||||
remaining := key[len(magic):]
|
remaining := key[len(privateKeyAuthMagic):]
|
||||||
|
|
||||||
var w struct {
|
|
||||||
CipherName string
|
|
||||||
KdfName string
|
|
||||||
KdfOpts string
|
|
||||||
NumKeys uint32
|
|
||||||
PubKey []byte
|
|
||||||
PrivKeyBlock []byte
|
|
||||||
}
|
|
||||||
|
|
||||||
|
var w openSSHEncryptedPrivateKey
|
||||||
if err := Unmarshal(remaining, &w); err != nil {
|
if err := Unmarshal(remaining, &w); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -1284,13 +1452,7 @@ func parseOpenSSHPrivateKey(key []byte, decrypt openSSHDecryptFunc) (crypto.Priv
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
pk1 := struct {
|
var pk1 openSSHPrivateKey
|
||||||
Check1 uint32
|
|
||||||
Check2 uint32
|
|
||||||
Keytype string
|
|
||||||
Rest []byte `ssh:"rest"`
|
|
||||||
}{}
|
|
||||||
|
|
||||||
if err := Unmarshal(privKeyBlock, &pk1); err != nil || pk1.Check1 != pk1.Check2 {
|
if err := Unmarshal(privKeyBlock, &pk1); err != nil || pk1.Check1 != pk1.Check2 {
|
||||||
if w.CipherName != "none" {
|
if w.CipherName != "none" {
|
||||||
return nil, x509.IncorrectPasswordError
|
return nil, x509.IncorrectPasswordError
|
||||||
@ -1300,18 +1462,7 @@ func parseOpenSSHPrivateKey(key []byte, decrypt openSSHDecryptFunc) (crypto.Priv
|
|||||||
|
|
||||||
switch pk1.Keytype {
|
switch pk1.Keytype {
|
||||||
case KeyAlgoRSA:
|
case KeyAlgoRSA:
|
||||||
// https://github.com/openssh/openssh-portable/blob/master/sshkey.c#L2760-L2773
|
var key openSSHRSAPrivateKey
|
||||||
key := struct {
|
|
||||||
N *big.Int
|
|
||||||
E *big.Int
|
|
||||||
D *big.Int
|
|
||||||
Iqmp *big.Int
|
|
||||||
P *big.Int
|
|
||||||
Q *big.Int
|
|
||||||
Comment string
|
|
||||||
Pad []byte `ssh:"rest"`
|
|
||||||
}{}
|
|
||||||
|
|
||||||
if err := Unmarshal(pk1.Rest, &key); err != nil {
|
if err := Unmarshal(pk1.Rest, &key); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -1337,13 +1488,7 @@ func parseOpenSSHPrivateKey(key []byte, decrypt openSSHDecryptFunc) (crypto.Priv
|
|||||||
|
|
||||||
return pk, nil
|
return pk, nil
|
||||||
case KeyAlgoED25519:
|
case KeyAlgoED25519:
|
||||||
key := struct {
|
var key openSSHEd25519PrivateKey
|
||||||
Pub []byte
|
|
||||||
Priv []byte
|
|
||||||
Comment string
|
|
||||||
Pad []byte `ssh:"rest"`
|
|
||||||
}{}
|
|
||||||
|
|
||||||
if err := Unmarshal(pk1.Rest, &key); err != nil {
|
if err := Unmarshal(pk1.Rest, &key); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -1360,14 +1505,7 @@ func parseOpenSSHPrivateKey(key []byte, decrypt openSSHDecryptFunc) (crypto.Priv
|
|||||||
copy(pk, key.Priv)
|
copy(pk, key.Priv)
|
||||||
return &pk, nil
|
return &pk, nil
|
||||||
case KeyAlgoECDSA256, KeyAlgoECDSA384, KeyAlgoECDSA521:
|
case KeyAlgoECDSA256, KeyAlgoECDSA384, KeyAlgoECDSA521:
|
||||||
key := struct {
|
var key openSSHECDSAPrivateKey
|
||||||
Curve string
|
|
||||||
Pub []byte
|
|
||||||
D *big.Int
|
|
||||||
Comment string
|
|
||||||
Pad []byte `ssh:"rest"`
|
|
||||||
}{}
|
|
||||||
|
|
||||||
if err := Unmarshal(pk1.Rest, &key); err != nil {
|
if err := Unmarshal(pk1.Rest, &key); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -1415,6 +1553,131 @@ func parseOpenSSHPrivateKey(key []byte, decrypt openSSHDecryptFunc) (crypto.Priv
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func marshalOpenSSHPrivateKey(key crypto.PrivateKey, comment string, encrypt openSSHEncryptFunc) (*pem.Block, error) {
|
||||||
|
var w openSSHEncryptedPrivateKey
|
||||||
|
var pk1 openSSHPrivateKey
|
||||||
|
|
||||||
|
// Random check bytes.
|
||||||
|
var check uint32
|
||||||
|
if err := binary.Read(rand.Reader, binary.BigEndian, &check); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
pk1.Check1 = check
|
||||||
|
pk1.Check2 = check
|
||||||
|
w.NumKeys = 1
|
||||||
|
|
||||||
|
// Use a []byte directly on ed25519 keys.
|
||||||
|
if k, ok := key.(*ed25519.PrivateKey); ok {
|
||||||
|
key = *k
|
||||||
|
}
|
||||||
|
|
||||||
|
switch k := key.(type) {
|
||||||
|
case *rsa.PrivateKey:
|
||||||
|
E := new(big.Int).SetInt64(int64(k.PublicKey.E))
|
||||||
|
// Marshal public key:
|
||||||
|
// E and N are in reversed order in the public and private key.
|
||||||
|
pubKey := struct {
|
||||||
|
KeyType string
|
||||||
|
E *big.Int
|
||||||
|
N *big.Int
|
||||||
|
}{
|
||||||
|
KeyAlgoRSA,
|
||||||
|
E, k.PublicKey.N,
|
||||||
|
}
|
||||||
|
w.PubKey = Marshal(pubKey)
|
||||||
|
|
||||||
|
// Marshal private key.
|
||||||
|
key := openSSHRSAPrivateKey{
|
||||||
|
N: k.PublicKey.N,
|
||||||
|
E: E,
|
||||||
|
D: k.D,
|
||||||
|
Iqmp: k.Precomputed.Qinv,
|
||||||
|
P: k.Primes[0],
|
||||||
|
Q: k.Primes[1],
|
||||||
|
Comment: comment,
|
||||||
|
}
|
||||||
|
pk1.Keytype = KeyAlgoRSA
|
||||||
|
pk1.Rest = Marshal(key)
|
||||||
|
case ed25519.PrivateKey:
|
||||||
|
pub := make([]byte, ed25519.PublicKeySize)
|
||||||
|
priv := make([]byte, ed25519.PrivateKeySize)
|
||||||
|
copy(pub, k[32:])
|
||||||
|
copy(priv, k)
|
||||||
|
|
||||||
|
// Marshal public key.
|
||||||
|
pubKey := struct {
|
||||||
|
KeyType string
|
||||||
|
Pub []byte
|
||||||
|
}{
|
||||||
|
KeyAlgoED25519, pub,
|
||||||
|
}
|
||||||
|
w.PubKey = Marshal(pubKey)
|
||||||
|
|
||||||
|
// Marshal private key.
|
||||||
|
key := openSSHEd25519PrivateKey{
|
||||||
|
Pub: pub,
|
||||||
|
Priv: priv,
|
||||||
|
Comment: comment,
|
||||||
|
}
|
||||||
|
pk1.Keytype = KeyAlgoED25519
|
||||||
|
pk1.Rest = Marshal(key)
|
||||||
|
case *ecdsa.PrivateKey:
|
||||||
|
var curve, keyType string
|
||||||
|
switch name := k.Curve.Params().Name; name {
|
||||||
|
case "P-256":
|
||||||
|
curve = "nistp256"
|
||||||
|
keyType = KeyAlgoECDSA256
|
||||||
|
case "P-384":
|
||||||
|
curve = "nistp384"
|
||||||
|
keyType = KeyAlgoECDSA384
|
||||||
|
case "P-521":
|
||||||
|
curve = "nistp521"
|
||||||
|
keyType = KeyAlgoECDSA521
|
||||||
|
default:
|
||||||
|
return nil, errors.New("ssh: unhandled elliptic curve " + name)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub := elliptic.Marshal(k.Curve, k.PublicKey.X, k.PublicKey.Y)
|
||||||
|
|
||||||
|
// Marshal public key.
|
||||||
|
pubKey := struct {
|
||||||
|
KeyType string
|
||||||
|
Curve string
|
||||||
|
Pub []byte
|
||||||
|
}{
|
||||||
|
keyType, curve, pub,
|
||||||
|
}
|
||||||
|
w.PubKey = Marshal(pubKey)
|
||||||
|
|
||||||
|
// Marshal private key.
|
||||||
|
key := openSSHECDSAPrivateKey{
|
||||||
|
Curve: curve,
|
||||||
|
Pub: pub,
|
||||||
|
D: k.D,
|
||||||
|
Comment: comment,
|
||||||
|
}
|
||||||
|
pk1.Keytype = keyType
|
||||||
|
pk1.Rest = Marshal(key)
|
||||||
|
default:
|
||||||
|
return nil, fmt.Errorf("ssh: unsupported key type %T", k)
|
||||||
|
}
|
||||||
|
|
||||||
|
var err error
|
||||||
|
// Add padding and encrypt the key if necessary.
|
||||||
|
w.PrivKeyBlock, w.CipherName, w.KdfName, w.KdfOpts, err = encrypt(Marshal(pk1))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
b := Marshal(w)
|
||||||
|
block := &pem.Block{
|
||||||
|
Type: "OPENSSH PRIVATE KEY",
|
||||||
|
Bytes: append([]byte(privateKeyAuthMagic), b...),
|
||||||
|
}
|
||||||
|
return block, nil
|
||||||
|
}
|
||||||
|
|
||||||
func checkOpenSSHKeyPadding(pad []byte) error {
|
func checkOpenSSHKeyPadding(pad []byte) error {
|
||||||
for i, b := range pad {
|
for i, b := range pad {
|
||||||
if int(b) != i+1 {
|
if int(b) != i+1 {
|
||||||
@ -1424,6 +1687,13 @@ func checkOpenSSHKeyPadding(pad []byte) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func generateOpenSSHPadding(block []byte, blockSize int) []byte {
|
||||||
|
for i, l := 0, len(block); (l+i)%blockSize != 0; i++ {
|
||||||
|
block = append(block, byte(i+1))
|
||||||
|
}
|
||||||
|
return block
|
||||||
|
}
|
||||||
|
|
||||||
// FingerprintLegacyMD5 returns the user presentation of the key's
|
// FingerprintLegacyMD5 returns the user presentation of the key's
|
||||||
// fingerprint as described by RFC 4716 section 4.
|
// fingerprint as described by RFC 4716 section 4.
|
||||||
func FingerprintLegacyMD5(pubKey PublicKey) string {
|
func FingerprintLegacyMD5(pubKey PublicKey) string {
|
||||||
|
7
vendor/golang.org/x/crypto/ssh/mac.go
generated
vendored
7
vendor/golang.org/x/crypto/ssh/mac.go
generated
vendored
@ -10,6 +10,7 @@ import (
|
|||||||
"crypto/hmac"
|
"crypto/hmac"
|
||||||
"crypto/sha1"
|
"crypto/sha1"
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
|
"crypto/sha512"
|
||||||
"hash"
|
"hash"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -46,9 +47,15 @@ func (t truncatingMAC) Size() int {
|
|||||||
func (t truncatingMAC) BlockSize() int { return t.hmac.BlockSize() }
|
func (t truncatingMAC) BlockSize() int { return t.hmac.BlockSize() }
|
||||||
|
|
||||||
var macModes = map[string]*macMode{
|
var macModes = map[string]*macMode{
|
||||||
|
"hmac-sha2-512-etm@openssh.com": {64, true, func(key []byte) hash.Hash {
|
||||||
|
return hmac.New(sha512.New, key)
|
||||||
|
}},
|
||||||
"hmac-sha2-256-etm@openssh.com": {32, true, func(key []byte) hash.Hash {
|
"hmac-sha2-256-etm@openssh.com": {32, true, func(key []byte) hash.Hash {
|
||||||
return hmac.New(sha256.New, key)
|
return hmac.New(sha256.New, key)
|
||||||
}},
|
}},
|
||||||
|
"hmac-sha2-512": {64, false, func(key []byte) hash.Hash {
|
||||||
|
return hmac.New(sha512.New, key)
|
||||||
|
}},
|
||||||
"hmac-sha2-256": {32, false, func(key []byte) hash.Hash {
|
"hmac-sha2-256": {32, false, func(key []byte) hash.Hash {
|
||||||
return hmac.New(sha256.New, key)
|
return hmac.New(sha256.New, key)
|
||||||
}},
|
}},
|
||||||
|
14
vendor/golang.org/x/crypto/ssh/messages.go
generated
vendored
14
vendor/golang.org/x/crypto/ssh/messages.go
generated
vendored
@ -349,6 +349,20 @@ type userAuthGSSAPIError struct {
|
|||||||
LanguageTag string
|
LanguageTag string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Transport layer OpenSSH extension. See [PROTOCOL], section 1.9
|
||||||
|
const msgPing = 192
|
||||||
|
|
||||||
|
type pingMsg struct {
|
||||||
|
Data string `sshtype:"192"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transport layer OpenSSH extension. See [PROTOCOL], section 1.9
|
||||||
|
const msgPong = 193
|
||||||
|
|
||||||
|
type pongMsg struct {
|
||||||
|
Data string `sshtype:"193"`
|
||||||
|
}
|
||||||
|
|
||||||
// typeTags returns the possible type bytes for the given reflect.Type, which
|
// typeTags returns the possible type bytes for the given reflect.Type, which
|
||||||
// should be a struct. The possible values are separated by a '|' character.
|
// should be a struct. The possible values are separated by a '|' character.
|
||||||
func typeTags(structType reflect.Type) (tags []byte) {
|
func typeTags(structType reflect.Type) (tags []byte) {
|
||||||
|
6
vendor/golang.org/x/crypto/ssh/mux.go
generated
vendored
6
vendor/golang.org/x/crypto/ssh/mux.go
generated
vendored
@ -231,6 +231,12 @@ func (m *mux) onePacket() error {
|
|||||||
return m.handleChannelOpen(packet)
|
return m.handleChannelOpen(packet)
|
||||||
case msgGlobalRequest, msgRequestSuccess, msgRequestFailure:
|
case msgGlobalRequest, msgRequestSuccess, msgRequestFailure:
|
||||||
return m.handleGlobalPacket(packet)
|
return m.handleGlobalPacket(packet)
|
||||||
|
case msgPing:
|
||||||
|
var msg pingMsg
|
||||||
|
if err := Unmarshal(packet, &msg); err != nil {
|
||||||
|
return fmt.Errorf("failed to unmarshal ping@openssh.com message: %w", err)
|
||||||
|
}
|
||||||
|
return m.sendMessage(pongMsg(msg))
|
||||||
}
|
}
|
||||||
|
|
||||||
// assume a channel packet.
|
// assume a channel packet.
|
||||||
|
45
vendor/golang.org/x/crypto/ssh/server.go
generated
vendored
45
vendor/golang.org/x/crypto/ssh/server.go
generated
vendored
@ -291,15 +291,6 @@ func (s *connection) serverHandshake(config *ServerConfig) (*Permissions, error)
|
|||||||
return perms, err
|
return perms, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func isAcceptableAlgo(algo string) bool {
|
|
||||||
switch algo {
|
|
||||||
case KeyAlgoRSA, KeyAlgoRSASHA256, KeyAlgoRSASHA512, KeyAlgoDSA, KeyAlgoECDSA256, KeyAlgoECDSA384, KeyAlgoECDSA521, KeyAlgoSKECDSA256, KeyAlgoED25519, KeyAlgoSKED25519,
|
|
||||||
CertAlgoRSAv01, CertAlgoDSAv01, CertAlgoECDSA256v01, CertAlgoECDSA384v01, CertAlgoECDSA521v01, CertAlgoSKECDSA256v01, CertAlgoED25519v01, CertAlgoSKED25519v01:
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func checkSourceAddress(addr net.Addr, sourceAddrs string) error {
|
func checkSourceAddress(addr net.Addr, sourceAddrs string) error {
|
||||||
if addr == nil {
|
if addr == nil {
|
||||||
return errors.New("ssh: no address known for client, but source-address match required")
|
return errors.New("ssh: no address known for client, but source-address match required")
|
||||||
@ -379,6 +370,25 @@ func gssExchangeToken(gssapiConfig *GSSAPIWithMICConfig, firstToken []byte, s *c
|
|||||||
return authErr, perms, nil
|
return authErr, perms, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// isAlgoCompatible checks if the signature format is compatible with the
|
||||||
|
// selected algorithm taking into account edge cases that occur with old
|
||||||
|
// clients.
|
||||||
|
func isAlgoCompatible(algo, sigFormat string) bool {
|
||||||
|
// Compatibility for old clients.
|
||||||
|
//
|
||||||
|
// For certificate authentication with OpenSSH 7.2-7.7 signature format can
|
||||||
|
// be rsa-sha2-256 or rsa-sha2-512 for the algorithm
|
||||||
|
// ssh-rsa-cert-v01@openssh.com.
|
||||||
|
//
|
||||||
|
// With gpg-agent < 2.2.6 the algorithm can be rsa-sha2-256 or rsa-sha2-512
|
||||||
|
// for signature format ssh-rsa.
|
||||||
|
if isRSA(algo) && isRSA(sigFormat) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
// Standard case: the underlying algorithm must match the signature format.
|
||||||
|
return underlyingAlgo(algo) == sigFormat
|
||||||
|
}
|
||||||
|
|
||||||
// ServerAuthError represents server authentication errors and is
|
// ServerAuthError represents server authentication errors and is
|
||||||
// sometimes returned by NewServerConn. It appends any authentication
|
// sometimes returned by NewServerConn. It appends any authentication
|
||||||
// errors that may occur, and is returned if all of the authentication
|
// errors that may occur, and is returned if all of the authentication
|
||||||
@ -514,7 +524,7 @@ userAuthLoop:
|
|||||||
return nil, parseError(msgUserAuthRequest)
|
return nil, parseError(msgUserAuthRequest)
|
||||||
}
|
}
|
||||||
algo := string(algoBytes)
|
algo := string(algoBytes)
|
||||||
if !isAcceptableAlgo(algo) {
|
if !contains(supportedPubKeyAuthAlgos, underlyingAlgo(algo)) {
|
||||||
authErr = fmt.Errorf("ssh: algorithm %q not accepted", algo)
|
authErr = fmt.Errorf("ssh: algorithm %q not accepted", algo)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -566,17 +576,26 @@ userAuthLoop:
|
|||||||
if !ok || len(payload) > 0 {
|
if !ok || len(payload) > 0 {
|
||||||
return nil, parseError(msgUserAuthRequest)
|
return nil, parseError(msgUserAuthRequest)
|
||||||
}
|
}
|
||||||
|
// Ensure the declared public key algo is compatible with the
|
||||||
|
// decoded one. This check will ensure we don't accept e.g.
|
||||||
|
// ssh-rsa-cert-v01@openssh.com algorithm with ssh-rsa public
|
||||||
|
// key type. The algorithm and public key type must be
|
||||||
|
// consistent: both must be certificate algorithms, or neither.
|
||||||
|
if !contains(algorithmsForKeyFormat(pubKey.Type()), algo) {
|
||||||
|
authErr = fmt.Errorf("ssh: public key type %q not compatible with selected algorithm %q",
|
||||||
|
pubKey.Type(), algo)
|
||||||
|
break
|
||||||
|
}
|
||||||
// Ensure the public key algo and signature algo
|
// Ensure the public key algo and signature algo
|
||||||
// are supported. Compare the private key
|
// are supported. Compare the private key
|
||||||
// algorithm name that corresponds to algo with
|
// algorithm name that corresponds to algo with
|
||||||
// sig.Format. This is usually the same, but
|
// sig.Format. This is usually the same, but
|
||||||
// for certs, the names differ.
|
// for certs, the names differ.
|
||||||
if !isAcceptableAlgo(sig.Format) {
|
if !contains(supportedPubKeyAuthAlgos, sig.Format) {
|
||||||
authErr = fmt.Errorf("ssh: algorithm %q not accepted", sig.Format)
|
authErr = fmt.Errorf("ssh: algorithm %q not accepted", sig.Format)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if underlyingAlgo(algo) != sig.Format {
|
if !isAlgoCompatible(algo, sig.Format) {
|
||||||
authErr = fmt.Errorf("ssh: signature %q not compatible with selected algorithm %q", sig.Format, algo)
|
authErr = fmt.Errorf("ssh: signature %q not compatible with selected algorithm %q", sig.Format, algo)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
3
vendor/golang.org/x/crypto/ssh/transport.go
generated
vendored
3
vendor/golang.org/x/crypto/ssh/transport.go
generated
vendored
@ -17,7 +17,8 @@ import (
|
|||||||
const debugTransport = false
|
const debugTransport = false
|
||||||
|
|
||||||
const (
|
const (
|
||||||
gcmCipherID = "aes128-gcm@openssh.com"
|
gcm128CipherID = "aes128-gcm@openssh.com"
|
||||||
|
gcm256CipherID = "aes256-gcm@openssh.com"
|
||||||
aes128cbcID = "aes128-cbc"
|
aes128cbcID = "aes128-cbc"
|
||||||
tripledescbcID = "3des-cbc"
|
tripledescbcID = "3des-cbc"
|
||||||
)
|
)
|
||||||
|
51
vendor/golang.org/x/net/http2/Dockerfile
generated
vendored
51
vendor/golang.org/x/net/http2/Dockerfile
generated
vendored
@ -1,51 +0,0 @@
|
|||||||
#
|
|
||||||
# This Dockerfile builds a recent curl with HTTP/2 client support, using
|
|
||||||
# a recent nghttp2 build.
|
|
||||||
#
|
|
||||||
# See the Makefile for how to tag it. If Docker and that image is found, the
|
|
||||||
# Go tests use this curl binary for integration tests.
|
|
||||||
#
|
|
||||||
|
|
||||||
FROM ubuntu:trusty
|
|
||||||
|
|
||||||
RUN apt-get update && \
|
|
||||||
apt-get upgrade -y && \
|
|
||||||
apt-get install -y git-core build-essential wget
|
|
||||||
|
|
||||||
RUN apt-get install -y --no-install-recommends \
|
|
||||||
autotools-dev libtool pkg-config zlib1g-dev \
|
|
||||||
libcunit1-dev libssl-dev libxml2-dev libevent-dev \
|
|
||||||
automake autoconf
|
|
||||||
|
|
||||||
# The list of packages nghttp2 recommends for h2load:
|
|
||||||
RUN apt-get install -y --no-install-recommends make binutils \
|
|
||||||
autoconf automake autotools-dev \
|
|
||||||
libtool pkg-config zlib1g-dev libcunit1-dev libssl-dev libxml2-dev \
|
|
||||||
libev-dev libevent-dev libjansson-dev libjemalloc-dev \
|
|
||||||
cython python3.4-dev python-setuptools
|
|
||||||
|
|
||||||
# Note: setting NGHTTP2_VER before the git clone, so an old git clone isn't cached:
|
|
||||||
ENV NGHTTP2_VER 895da9a
|
|
||||||
RUN cd /root && git clone https://github.com/tatsuhiro-t/nghttp2.git
|
|
||||||
|
|
||||||
WORKDIR /root/nghttp2
|
|
||||||
RUN git reset --hard $NGHTTP2_VER
|
|
||||||
RUN autoreconf -i
|
|
||||||
RUN automake
|
|
||||||
RUN autoconf
|
|
||||||
RUN ./configure
|
|
||||||
RUN make
|
|
||||||
RUN make install
|
|
||||||
|
|
||||||
WORKDIR /root
|
|
||||||
RUN wget https://curl.se/download/curl-7.45.0.tar.gz
|
|
||||||
RUN tar -zxvf curl-7.45.0.tar.gz
|
|
||||||
WORKDIR /root/curl-7.45.0
|
|
||||||
RUN ./configure --with-ssl --with-nghttp2=/usr/local
|
|
||||||
RUN make
|
|
||||||
RUN make install
|
|
||||||
RUN ldconfig
|
|
||||||
|
|
||||||
CMD ["-h"]
|
|
||||||
ENTRYPOINT ["/usr/local/bin/curl"]
|
|
||||||
|
|
3
vendor/golang.org/x/net/http2/Makefile
generated
vendored
3
vendor/golang.org/x/net/http2/Makefile
generated
vendored
@ -1,3 +0,0 @@
|
|||||||
curlimage:
|
|
||||||
docker build -t gohttp2/curl .
|
|
||||||
|
|
95
vendor/golang.org/x/net/http2/server.go
generated
vendored
95
vendor/golang.org/x/net/http2/server.go
generated
vendored
@ -441,7 +441,7 @@ func (s *Server) ServeConn(c net.Conn, opts *ServeConnOpts) {
|
|||||||
if s.NewWriteScheduler != nil {
|
if s.NewWriteScheduler != nil {
|
||||||
sc.writeSched = s.NewWriteScheduler()
|
sc.writeSched = s.NewWriteScheduler()
|
||||||
} else {
|
} else {
|
||||||
sc.writeSched = NewPriorityWriteScheduler(nil)
|
sc.writeSched = newRoundRobinWriteScheduler()
|
||||||
}
|
}
|
||||||
|
|
||||||
// These start at the RFC-specified defaults. If there is a higher
|
// These start at the RFC-specified defaults. If there is a higher
|
||||||
@ -581,9 +581,11 @@ type serverConn struct {
|
|||||||
advMaxStreams uint32 // our SETTINGS_MAX_CONCURRENT_STREAMS advertised the client
|
advMaxStreams uint32 // our SETTINGS_MAX_CONCURRENT_STREAMS advertised the client
|
||||||
curClientStreams uint32 // number of open streams initiated by the client
|
curClientStreams uint32 // number of open streams initiated by the client
|
||||||
curPushedStreams uint32 // number of open streams initiated by server push
|
curPushedStreams uint32 // number of open streams initiated by server push
|
||||||
|
curHandlers uint32 // number of running handler goroutines
|
||||||
maxClientStreamID uint32 // max ever seen from client (odd), or 0 if there have been no client requests
|
maxClientStreamID uint32 // max ever seen from client (odd), or 0 if there have been no client requests
|
||||||
maxPushPromiseID uint32 // ID of the last push promise (even), or 0 if there have been no pushes
|
maxPushPromiseID uint32 // ID of the last push promise (even), or 0 if there have been no pushes
|
||||||
streams map[uint32]*stream
|
streams map[uint32]*stream
|
||||||
|
unstartedHandlers []unstartedHandler
|
||||||
initialStreamSendWindowSize int32
|
initialStreamSendWindowSize int32
|
||||||
maxFrameSize int32
|
maxFrameSize int32
|
||||||
peerMaxHeaderListSize uint32 // zero means unknown (default)
|
peerMaxHeaderListSize uint32 // zero means unknown (default)
|
||||||
@ -981,6 +983,8 @@ func (sc *serverConn) serve() {
|
|||||||
return
|
return
|
||||||
case gracefulShutdownMsg:
|
case gracefulShutdownMsg:
|
||||||
sc.startGracefulShutdownInternal()
|
sc.startGracefulShutdownInternal()
|
||||||
|
case handlerDoneMsg:
|
||||||
|
sc.handlerDone()
|
||||||
default:
|
default:
|
||||||
panic("unknown timer")
|
panic("unknown timer")
|
||||||
}
|
}
|
||||||
@ -1012,14 +1016,6 @@ func (sc *serverConn) serve() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sc *serverConn) awaitGracefulShutdown(sharedCh <-chan struct{}, privateCh chan struct{}) {
|
|
||||||
select {
|
|
||||||
case <-sc.doneServing:
|
|
||||||
case <-sharedCh:
|
|
||||||
close(privateCh)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type serverMessage int
|
type serverMessage int
|
||||||
|
|
||||||
// Message values sent to serveMsgCh.
|
// Message values sent to serveMsgCh.
|
||||||
@ -1028,6 +1024,7 @@ var (
|
|||||||
idleTimerMsg = new(serverMessage)
|
idleTimerMsg = new(serverMessage)
|
||||||
shutdownTimerMsg = new(serverMessage)
|
shutdownTimerMsg = new(serverMessage)
|
||||||
gracefulShutdownMsg = new(serverMessage)
|
gracefulShutdownMsg = new(serverMessage)
|
||||||
|
handlerDoneMsg = new(serverMessage)
|
||||||
)
|
)
|
||||||
|
|
||||||
func (sc *serverConn) onSettingsTimer() { sc.sendServeMsg(settingsTimerMsg) }
|
func (sc *serverConn) onSettingsTimer() { sc.sendServeMsg(settingsTimerMsg) }
|
||||||
@ -1900,9 +1897,11 @@ func (st *stream) copyTrailersToHandlerRequest() {
|
|||||||
// onReadTimeout is run on its own goroutine (from time.AfterFunc)
|
// onReadTimeout is run on its own goroutine (from time.AfterFunc)
|
||||||
// when the stream's ReadTimeout has fired.
|
// when the stream's ReadTimeout has fired.
|
||||||
func (st *stream) onReadTimeout() {
|
func (st *stream) onReadTimeout() {
|
||||||
// Wrap the ErrDeadlineExceeded to avoid callers depending on us
|
if st.body != nil {
|
||||||
// returning the bare error.
|
// Wrap the ErrDeadlineExceeded to avoid callers depending on us
|
||||||
st.body.CloseWithError(fmt.Errorf("%w", os.ErrDeadlineExceeded))
|
// returning the bare error.
|
||||||
|
st.body.CloseWithError(fmt.Errorf("%w", os.ErrDeadlineExceeded))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// onWriteTimeout is run on its own goroutine (from time.AfterFunc)
|
// onWriteTimeout is run on its own goroutine (from time.AfterFunc)
|
||||||
@ -2020,13 +2019,10 @@ func (sc *serverConn) processHeaders(f *MetaHeadersFrame) error {
|
|||||||
// (in Go 1.8), though. That's a more sane option anyway.
|
// (in Go 1.8), though. That's a more sane option anyway.
|
||||||
if sc.hs.ReadTimeout != 0 {
|
if sc.hs.ReadTimeout != 0 {
|
||||||
sc.conn.SetReadDeadline(time.Time{})
|
sc.conn.SetReadDeadline(time.Time{})
|
||||||
if st.body != nil {
|
st.readDeadline = time.AfterFunc(sc.hs.ReadTimeout, st.onReadTimeout)
|
||||||
st.readDeadline = time.AfterFunc(sc.hs.ReadTimeout, st.onReadTimeout)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
go sc.runHandler(rw, req, handler)
|
return sc.scheduleHandler(id, rw, req, handler)
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sc *serverConn) upgradeRequest(req *http.Request) {
|
func (sc *serverConn) upgradeRequest(req *http.Request) {
|
||||||
@ -2046,6 +2042,10 @@ func (sc *serverConn) upgradeRequest(req *http.Request) {
|
|||||||
sc.conn.SetReadDeadline(time.Time{})
|
sc.conn.SetReadDeadline(time.Time{})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is the first request on the connection,
|
||||||
|
// so start the handler directly rather than going
|
||||||
|
// through scheduleHandler.
|
||||||
|
sc.curHandlers++
|
||||||
go sc.runHandler(rw, req, sc.handler.ServeHTTP)
|
go sc.runHandler(rw, req, sc.handler.ServeHTTP)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2286,8 +2286,62 @@ func (sc *serverConn) newResponseWriter(st *stream, req *http.Request) *response
|
|||||||
return &responseWriter{rws: rws}
|
return &responseWriter{rws: rws}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type unstartedHandler struct {
|
||||||
|
streamID uint32
|
||||||
|
rw *responseWriter
|
||||||
|
req *http.Request
|
||||||
|
handler func(http.ResponseWriter, *http.Request)
|
||||||
|
}
|
||||||
|
|
||||||
|
// scheduleHandler starts a handler goroutine,
|
||||||
|
// or schedules one to start as soon as an existing handler finishes.
|
||||||
|
func (sc *serverConn) scheduleHandler(streamID uint32, rw *responseWriter, req *http.Request, handler func(http.ResponseWriter, *http.Request)) error {
|
||||||
|
sc.serveG.check()
|
||||||
|
maxHandlers := sc.advMaxStreams
|
||||||
|
if sc.curHandlers < maxHandlers {
|
||||||
|
sc.curHandlers++
|
||||||
|
go sc.runHandler(rw, req, handler)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if len(sc.unstartedHandlers) > int(4*sc.advMaxStreams) {
|
||||||
|
return sc.countError("too_many_early_resets", ConnectionError(ErrCodeEnhanceYourCalm))
|
||||||
|
}
|
||||||
|
sc.unstartedHandlers = append(sc.unstartedHandlers, unstartedHandler{
|
||||||
|
streamID: streamID,
|
||||||
|
rw: rw,
|
||||||
|
req: req,
|
||||||
|
handler: handler,
|
||||||
|
})
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sc *serverConn) handlerDone() {
|
||||||
|
sc.serveG.check()
|
||||||
|
sc.curHandlers--
|
||||||
|
i := 0
|
||||||
|
maxHandlers := sc.advMaxStreams
|
||||||
|
for ; i < len(sc.unstartedHandlers); i++ {
|
||||||
|
u := sc.unstartedHandlers[i]
|
||||||
|
if sc.streams[u.streamID] == nil {
|
||||||
|
// This stream was reset before its goroutine had a chance to start.
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if sc.curHandlers >= maxHandlers {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
sc.curHandlers++
|
||||||
|
go sc.runHandler(u.rw, u.req, u.handler)
|
||||||
|
sc.unstartedHandlers[i] = unstartedHandler{} // don't retain references
|
||||||
|
}
|
||||||
|
sc.unstartedHandlers = sc.unstartedHandlers[i:]
|
||||||
|
if len(sc.unstartedHandlers) == 0 {
|
||||||
|
sc.unstartedHandlers = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Run on its own goroutine.
|
// Run on its own goroutine.
|
||||||
func (sc *serverConn) runHandler(rw *responseWriter, req *http.Request, handler func(http.ResponseWriter, *http.Request)) {
|
func (sc *serverConn) runHandler(rw *responseWriter, req *http.Request, handler func(http.ResponseWriter, *http.Request)) {
|
||||||
|
defer sc.sendServeMsg(handlerDoneMsg)
|
||||||
didPanic := true
|
didPanic := true
|
||||||
defer func() {
|
defer func() {
|
||||||
rw.rws.stream.cancelCtx()
|
rw.rws.stream.cancelCtx()
|
||||||
@ -2429,7 +2483,7 @@ type requestBody struct {
|
|||||||
conn *serverConn
|
conn *serverConn
|
||||||
closeOnce sync.Once // for use by Close only
|
closeOnce sync.Once // for use by Close only
|
||||||
sawEOF bool // for use by Read only
|
sawEOF bool // for use by Read only
|
||||||
pipe *pipe // non-nil if we have a HTTP entity message body
|
pipe *pipe // non-nil if we have an HTTP entity message body
|
||||||
needsContinue bool // need to send a 100-continue
|
needsContinue bool // need to send a 100-continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2569,7 +2623,8 @@ func (rws *responseWriterState) writeChunk(p []byte) (n int, err error) {
|
|||||||
clen = ""
|
clen = ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if clen == "" && rws.handlerDone && bodyAllowedForStatus(rws.status) && (len(p) > 0 || !isHeadResp) {
|
_, hasContentLength := rws.snapHeader["Content-Length"]
|
||||||
|
if !hasContentLength && clen == "" && rws.handlerDone && bodyAllowedForStatus(rws.status) && (len(p) > 0 || !isHeadResp) {
|
||||||
clen = strconv.Itoa(len(p))
|
clen = strconv.Itoa(len(p))
|
||||||
}
|
}
|
||||||
_, hasContentType := rws.snapHeader["Content-Type"]
|
_, hasContentType := rws.snapHeader["Content-Type"]
|
||||||
@ -2774,7 +2829,7 @@ func (w *responseWriter) FlushError() error {
|
|||||||
err = rws.bw.Flush()
|
err = rws.bw.Flush()
|
||||||
} else {
|
} else {
|
||||||
// The bufio.Writer won't call chunkWriter.Write
|
// The bufio.Writer won't call chunkWriter.Write
|
||||||
// (writeChunk with zero bytes, so we have to do it
|
// (writeChunk with zero bytes), so we have to do it
|
||||||
// ourselves to force the HTTP response header and/or
|
// ourselves to force the HTTP response header and/or
|
||||||
// final DATA frame (with END_STREAM) to be sent.
|
// final DATA frame (with END_STREAM) to be sent.
|
||||||
_, err = chunkWriter{rws}.Write(nil)
|
_, err = chunkWriter{rws}.Write(nil)
|
||||||
|
82
vendor/golang.org/x/net/http2/transport.go
generated
vendored
82
vendor/golang.org/x/net/http2/transport.go
generated
vendored
@ -19,6 +19,7 @@ import (
|
|||||||
"io/fs"
|
"io/fs"
|
||||||
"log"
|
"log"
|
||||||
"math"
|
"math"
|
||||||
|
"math/bits"
|
||||||
mathrand "math/rand"
|
mathrand "math/rand"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -290,8 +291,7 @@ func (t *Transport) initConnPool() {
|
|||||||
// HTTP/2 server.
|
// HTTP/2 server.
|
||||||
type ClientConn struct {
|
type ClientConn struct {
|
||||||
t *Transport
|
t *Transport
|
||||||
tconn net.Conn // usually *tls.Conn, except specialized impls
|
tconn net.Conn // usually *tls.Conn, except specialized impls
|
||||||
tconnClosed bool
|
|
||||||
tlsState *tls.ConnectionState // nil only for specialized impls
|
tlsState *tls.ConnectionState // nil only for specialized impls
|
||||||
reused uint32 // whether conn is being reused; atomic
|
reused uint32 // whether conn is being reused; atomic
|
||||||
singleUse bool // whether being used for a single http.Request
|
singleUse bool // whether being used for a single http.Request
|
||||||
@ -518,11 +518,14 @@ func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error) {
|
|||||||
func authorityAddr(scheme string, authority string) (addr string) {
|
func authorityAddr(scheme string, authority string) (addr string) {
|
||||||
host, port, err := net.SplitHostPort(authority)
|
host, port, err := net.SplitHostPort(authority)
|
||||||
if err != nil { // authority didn't have a port
|
if err != nil { // authority didn't have a port
|
||||||
|
host = authority
|
||||||
|
port = ""
|
||||||
|
}
|
||||||
|
if port == "" { // authority's port was empty
|
||||||
port = "443"
|
port = "443"
|
||||||
if scheme == "http" {
|
if scheme == "http" {
|
||||||
port = "80"
|
port = "80"
|
||||||
}
|
}
|
||||||
host = authority
|
|
||||||
}
|
}
|
||||||
if a, err := idna.ToASCII(host); err == nil {
|
if a, err := idna.ToASCII(host); err == nil {
|
||||||
host = a
|
host = a
|
||||||
@ -1268,21 +1271,23 @@ func (cc *ClientConn) RoundTrip(req *http.Request) (*http.Response, error) {
|
|||||||
|
|
||||||
cancelRequest := func(cs *clientStream, err error) error {
|
cancelRequest := func(cs *clientStream, err error) error {
|
||||||
cs.cc.mu.Lock()
|
cs.cc.mu.Lock()
|
||||||
defer cs.cc.mu.Unlock()
|
bodyClosed := cs.reqBodyClosed
|
||||||
cs.abortStreamLocked(err)
|
cs.cc.mu.Unlock()
|
||||||
if cs.ID != 0 {
|
// Wait for the request body to be closed.
|
||||||
// This request may have failed because of a problem with the connection,
|
//
|
||||||
// or for some unrelated reason. (For example, the user might have canceled
|
// If nothing closed the body before now, abortStreamLocked
|
||||||
// the request without waiting for a response.) Mark the connection as
|
// will have started a goroutine to close it.
|
||||||
// not reusable, since trying to reuse a dead connection is worse than
|
//
|
||||||
// unnecessarily creating a new one.
|
// Closing the body before returning avoids a race condition
|
||||||
//
|
// with net/http checking its readTrackingBody to see if the
|
||||||
// If cs.ID is 0, then the request was never allocated a stream ID and
|
// body was read from or closed. See golang/go#60041.
|
||||||
// whatever went wrong was unrelated to the connection. We might have
|
//
|
||||||
// timed out waiting for a stream slot when StrictMaxConcurrentStreams
|
// The body is closed in a separate goroutine without the
|
||||||
// is set, for example, in which case retrying on a different connection
|
// connection mutex held, but dropping the mutex before waiting
|
||||||
// will not help.
|
// will keep us from holding it indefinitely if the body
|
||||||
cs.cc.doNotReuse = true
|
// close is slow for some reason.
|
||||||
|
if bodyClosed != nil {
|
||||||
|
<-bodyClosed
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -1301,11 +1306,14 @@ func (cc *ClientConn) RoundTrip(req *http.Request) (*http.Response, error) {
|
|||||||
return handleResponseHeaders()
|
return handleResponseHeaders()
|
||||||
default:
|
default:
|
||||||
waitDone()
|
waitDone()
|
||||||
return nil, cancelRequest(cs, cs.abortErr)
|
return nil, cs.abortErr
|
||||||
}
|
}
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return nil, cancelRequest(cs, ctx.Err())
|
err := ctx.Err()
|
||||||
|
cs.abortStream(err)
|
||||||
|
return nil, cancelRequest(cs, err)
|
||||||
case <-cs.reqCancel:
|
case <-cs.reqCancel:
|
||||||
|
cs.abortStream(errRequestCanceled)
|
||||||
return nil, cancelRequest(cs, errRequestCanceled)
|
return nil, cancelRequest(cs, errRequestCanceled)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1672,7 +1680,27 @@ func (cs *clientStream) frameScratchBufferLen(maxFrameSize int) int {
|
|||||||
return int(n) // doesn't truncate; max is 512K
|
return int(n) // doesn't truncate; max is 512K
|
||||||
}
|
}
|
||||||
|
|
||||||
var bufPool sync.Pool // of *[]byte
|
// Seven bufPools manage different frame sizes. This helps to avoid scenarios where long-running
|
||||||
|
// streaming requests using small frame sizes occupy large buffers initially allocated for prior
|
||||||
|
// requests needing big buffers. The size ranges are as follows:
|
||||||
|
// {0 KB, 16 KB], {16 KB, 32 KB], {32 KB, 64 KB], {64 KB, 128 KB], {128 KB, 256 KB],
|
||||||
|
// {256 KB, 512 KB], {512 KB, infinity}
|
||||||
|
// In practice, the maximum scratch buffer size should not exceed 512 KB due to
|
||||||
|
// frameScratchBufferLen(maxFrameSize), thus the "infinity pool" should never be used.
|
||||||
|
// It exists mainly as a safety measure, for potential future increases in max buffer size.
|
||||||
|
var bufPools [7]sync.Pool // of *[]byte
|
||||||
|
func bufPoolIndex(size int) int {
|
||||||
|
if size <= 16384 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
size -= 1
|
||||||
|
bits := bits.Len(uint(size))
|
||||||
|
index := bits - 14
|
||||||
|
if index >= len(bufPools) {
|
||||||
|
return len(bufPools) - 1
|
||||||
|
}
|
||||||
|
return index
|
||||||
|
}
|
||||||
|
|
||||||
func (cs *clientStream) writeRequestBody(req *http.Request) (err error) {
|
func (cs *clientStream) writeRequestBody(req *http.Request) (err error) {
|
||||||
cc := cs.cc
|
cc := cs.cc
|
||||||
@ -1690,12 +1718,13 @@ func (cs *clientStream) writeRequestBody(req *http.Request) (err error) {
|
|||||||
// Scratch buffer for reading into & writing from.
|
// Scratch buffer for reading into & writing from.
|
||||||
scratchLen := cs.frameScratchBufferLen(maxFrameSize)
|
scratchLen := cs.frameScratchBufferLen(maxFrameSize)
|
||||||
var buf []byte
|
var buf []byte
|
||||||
if bp, ok := bufPool.Get().(*[]byte); ok && len(*bp) >= scratchLen {
|
index := bufPoolIndex(scratchLen)
|
||||||
defer bufPool.Put(bp)
|
if bp, ok := bufPools[index].Get().(*[]byte); ok && len(*bp) >= scratchLen {
|
||||||
|
defer bufPools[index].Put(bp)
|
||||||
buf = *bp
|
buf = *bp
|
||||||
} else {
|
} else {
|
||||||
buf = make([]byte, scratchLen)
|
buf = make([]byte, scratchLen)
|
||||||
defer bufPool.Put(&buf)
|
defer bufPools[index].Put(&buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
var sawEOF bool
|
var sawEOF bool
|
||||||
@ -1863,6 +1892,9 @@ func (cc *ClientConn) encodeHeaders(req *http.Request, addGzipHeader bool, trail
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if !httpguts.ValidHostHeader(host) {
|
||||||
|
return nil, errors.New("http2: invalid Host header")
|
||||||
|
}
|
||||||
|
|
||||||
var path string
|
var path string
|
||||||
if req.Method != "CONNECT" {
|
if req.Method != "CONNECT" {
|
||||||
@ -1899,7 +1931,7 @@ func (cc *ClientConn) encodeHeaders(req *http.Request, addGzipHeader bool, trail
|
|||||||
// 8.1.2.3 Request Pseudo-Header Fields
|
// 8.1.2.3 Request Pseudo-Header Fields
|
||||||
// The :path pseudo-header field includes the path and query parts of the
|
// The :path pseudo-header field includes the path and query parts of the
|
||||||
// target URI (the path-absolute production and optionally a '?' character
|
// target URI (the path-absolute production and optionally a '?' character
|
||||||
// followed by the query production (see Sections 3.3 and 3.4 of
|
// followed by the query production, see Sections 3.3 and 3.4 of
|
||||||
// [RFC3986]).
|
// [RFC3986]).
|
||||||
f(":authority", host)
|
f(":authority", host)
|
||||||
m := req.Method
|
m := req.Method
|
||||||
|
3
vendor/golang.org/x/net/http2/writesched.go
generated
vendored
3
vendor/golang.org/x/net/http2/writesched.go
generated
vendored
@ -184,7 +184,8 @@ func (wr *FrameWriteRequest) replyToWriter(err error) {
|
|||||||
|
|
||||||
// writeQueue is used by implementations of WriteScheduler.
|
// writeQueue is used by implementations of WriteScheduler.
|
||||||
type writeQueue struct {
|
type writeQueue struct {
|
||||||
s []FrameWriteRequest
|
s []FrameWriteRequest
|
||||||
|
prev, next *writeQueue
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *writeQueue) empty() bool { return len(q.s) == 0 }
|
func (q *writeQueue) empty() bool { return len(q.s) == 0 }
|
||||||
|
119
vendor/golang.org/x/net/http2/writesched_roundrobin.go
generated
vendored
Normal file
119
vendor/golang.org/x/net/http2/writesched_roundrobin.go
generated
vendored
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
// Copyright 2023 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package http2
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"math"
|
||||||
|
)
|
||||||
|
|
||||||
|
type roundRobinWriteScheduler struct {
|
||||||
|
// control contains control frames (SETTINGS, PING, etc.).
|
||||||
|
control writeQueue
|
||||||
|
|
||||||
|
// streams maps stream ID to a queue.
|
||||||
|
streams map[uint32]*writeQueue
|
||||||
|
|
||||||
|
// stream queues are stored in a circular linked list.
|
||||||
|
// head is the next stream to write, or nil if there are no streams open.
|
||||||
|
head *writeQueue
|
||||||
|
|
||||||
|
// pool of empty queues for reuse.
|
||||||
|
queuePool writeQueuePool
|
||||||
|
}
|
||||||
|
|
||||||
|
// newRoundRobinWriteScheduler constructs a new write scheduler.
|
||||||
|
// The round robin scheduler priorizes control frames
|
||||||
|
// like SETTINGS and PING over DATA frames.
|
||||||
|
// When there are no control frames to send, it performs a round-robin
|
||||||
|
// selection from the ready streams.
|
||||||
|
func newRoundRobinWriteScheduler() WriteScheduler {
|
||||||
|
ws := &roundRobinWriteScheduler{
|
||||||
|
streams: make(map[uint32]*writeQueue),
|
||||||
|
}
|
||||||
|
return ws
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ws *roundRobinWriteScheduler) OpenStream(streamID uint32, options OpenStreamOptions) {
|
||||||
|
if ws.streams[streamID] != nil {
|
||||||
|
panic(fmt.Errorf("stream %d already opened", streamID))
|
||||||
|
}
|
||||||
|
q := ws.queuePool.get()
|
||||||
|
ws.streams[streamID] = q
|
||||||
|
if ws.head == nil {
|
||||||
|
ws.head = q
|
||||||
|
q.next = q
|
||||||
|
q.prev = q
|
||||||
|
} else {
|
||||||
|
// Queues are stored in a ring.
|
||||||
|
// Insert the new stream before ws.head, putting it at the end of the list.
|
||||||
|
q.prev = ws.head.prev
|
||||||
|
q.next = ws.head
|
||||||
|
q.prev.next = q
|
||||||
|
q.next.prev = q
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ws *roundRobinWriteScheduler) CloseStream(streamID uint32) {
|
||||||
|
q := ws.streams[streamID]
|
||||||
|
if q == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if q.next == q {
|
||||||
|
// This was the only open stream.
|
||||||
|
ws.head = nil
|
||||||
|
} else {
|
||||||
|
q.prev.next = q.next
|
||||||
|
q.next.prev = q.prev
|
||||||
|
if ws.head == q {
|
||||||
|
ws.head = q.next
|
||||||
|
}
|
||||||
|
}
|
||||||
|
delete(ws.streams, streamID)
|
||||||
|
ws.queuePool.put(q)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ws *roundRobinWriteScheduler) AdjustStream(streamID uint32, priority PriorityParam) {}
|
||||||
|
|
||||||
|
func (ws *roundRobinWriteScheduler) Push(wr FrameWriteRequest) {
|
||||||
|
if wr.isControl() {
|
||||||
|
ws.control.push(wr)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
q := ws.streams[wr.StreamID()]
|
||||||
|
if q == nil {
|
||||||
|
// This is a closed stream.
|
||||||
|
// wr should not be a HEADERS or DATA frame.
|
||||||
|
// We push the request onto the control queue.
|
||||||
|
if wr.DataSize() > 0 {
|
||||||
|
panic("add DATA on non-open stream")
|
||||||
|
}
|
||||||
|
ws.control.push(wr)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
q.push(wr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ws *roundRobinWriteScheduler) Pop() (FrameWriteRequest, bool) {
|
||||||
|
// Control and RST_STREAM frames first.
|
||||||
|
if !ws.control.empty() {
|
||||||
|
return ws.control.shift(), true
|
||||||
|
}
|
||||||
|
if ws.head == nil {
|
||||||
|
return FrameWriteRequest{}, false
|
||||||
|
}
|
||||||
|
q := ws.head
|
||||||
|
for {
|
||||||
|
if wr, ok := q.consume(math.MaxInt32); ok {
|
||||||
|
ws.head = q.next
|
||||||
|
return wr, true
|
||||||
|
}
|
||||||
|
q = q.next
|
||||||
|
if q == ws.head {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return FrameWriteRequest{}, false
|
||||||
|
}
|
2
vendor/golang.org/x/net/idna/idna9.0.0.go
generated
vendored
2
vendor/golang.org/x/net/idna/idna9.0.0.go
generated
vendored
@ -121,7 +121,7 @@ func CheckJoiners(enable bool) Option {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// StrictDomainName limits the set of permissable ASCII characters to those
|
// StrictDomainName limits the set of permissible ASCII characters to those
|
||||||
// allowed in domain names as defined in RFC 1034 (A-Z, a-z, 0-9 and the
|
// allowed in domain names as defined in RFC 1034 (A-Z, a-z, 0-9 and the
|
||||||
// hyphen). This is set by default for MapForLookup and ValidateForRegistration,
|
// hyphen). This is set by default for MapForLookup and ValidateForRegistration,
|
||||||
// but is only useful if ValidateLabels is set.
|
// but is only useful if ValidateLabels is set.
|
||||||
|
2988
vendor/golang.org/x/net/idna/tables13.0.0.go
generated
vendored
2988
vendor/golang.org/x/net/idna/tables13.0.0.go
generated
vendored
File diff suppressed because it is too large
Load Diff
5145
vendor/golang.org/x/net/idna/tables15.0.0.go
generated
vendored
Normal file
5145
vendor/golang.org/x/net/idna/tables15.0.0.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
21
vendor/golang.org/x/net/idna/trie.go
generated
vendored
21
vendor/golang.org/x/net/idna/trie.go
generated
vendored
@ -6,27 +6,6 @@
|
|||||||
|
|
||||||
package idna
|
package idna
|
||||||
|
|
||||||
// appendMapping appends the mapping for the respective rune. isMapped must be
|
|
||||||
// true. A mapping is a categorization of a rune as defined in UTS #46.
|
|
||||||
func (c info) appendMapping(b []byte, s string) []byte {
|
|
||||||
index := int(c >> indexShift)
|
|
||||||
if c&xorBit == 0 {
|
|
||||||
s := mappings[index:]
|
|
||||||
return append(b, s[1:s[0]+1]...)
|
|
||||||
}
|
|
||||||
b = append(b, s...)
|
|
||||||
if c&inlineXOR == inlineXOR {
|
|
||||||
// TODO: support and handle two-byte inline masks
|
|
||||||
b[len(b)-1] ^= byte(index)
|
|
||||||
} else {
|
|
||||||
for p := len(b) - int(xorData[index]); p < len(b); p++ {
|
|
||||||
index++
|
|
||||||
b[p] ^= xorData[index]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return b
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sparse block handling code.
|
// Sparse block handling code.
|
||||||
|
|
||||||
type valueRange struct {
|
type valueRange struct {
|
||||||
|
31
vendor/golang.org/x/net/idna/trie12.0.0.go
generated
vendored
Normal file
31
vendor/golang.org/x/net/idna/trie12.0.0.go
generated
vendored
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
|
||||||
|
|
||||||
|
// Copyright 2016 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
//go:build !go1.16
|
||||||
|
// +build !go1.16
|
||||||
|
|
||||||
|
package idna
|
||||||
|
|
||||||
|
// appendMapping appends the mapping for the respective rune. isMapped must be
|
||||||
|
// true. A mapping is a categorization of a rune as defined in UTS #46.
|
||||||
|
func (c info) appendMapping(b []byte, s string) []byte {
|
||||||
|
index := int(c >> indexShift)
|
||||||
|
if c&xorBit == 0 {
|
||||||
|
s := mappings[index:]
|
||||||
|
return append(b, s[1:s[0]+1]...)
|
||||||
|
}
|
||||||
|
b = append(b, s...)
|
||||||
|
if c&inlineXOR == inlineXOR {
|
||||||
|
// TODO: support and handle two-byte inline masks
|
||||||
|
b[len(b)-1] ^= byte(index)
|
||||||
|
} else {
|
||||||
|
for p := len(b) - int(xorData[index]); p < len(b); p++ {
|
||||||
|
index++
|
||||||
|
b[p] ^= xorData[index]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return b
|
||||||
|
}
|
31
vendor/golang.org/x/net/idna/trie13.0.0.go
generated
vendored
Normal file
31
vendor/golang.org/x/net/idna/trie13.0.0.go
generated
vendored
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
|
||||||
|
|
||||||
|
// Copyright 2016 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
//go:build go1.16
|
||||||
|
// +build go1.16
|
||||||
|
|
||||||
|
package idna
|
||||||
|
|
||||||
|
// appendMapping appends the mapping for the respective rune. isMapped must be
|
||||||
|
// true. A mapping is a categorization of a rune as defined in UTS #46.
|
||||||
|
func (c info) appendMapping(b []byte, s string) []byte {
|
||||||
|
index := int(c >> indexShift)
|
||||||
|
if c&xorBit == 0 {
|
||||||
|
p := index
|
||||||
|
return append(b, mappings[mappingIndex[p]:mappingIndex[p+1]]...)
|
||||||
|
}
|
||||||
|
b = append(b, s...)
|
||||||
|
if c&inlineXOR == inlineXOR {
|
||||||
|
// TODO: support and handle two-byte inline masks
|
||||||
|
b[len(b)-1] ^= byte(index)
|
||||||
|
} else {
|
||||||
|
for p := len(b) - int(xorData[index]); p < len(b); p++ {
|
||||||
|
index++
|
||||||
|
b[p] ^= xorData[index]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return b
|
||||||
|
}
|
5
vendor/golang.org/x/sys/cpu/cpu.go
generated
vendored
5
vendor/golang.org/x/sys/cpu/cpu.go
generated
vendored
@ -38,7 +38,7 @@ var X86 struct {
|
|||||||
HasAVX512F bool // Advanced vector extension 512 Foundation Instructions
|
HasAVX512F bool // Advanced vector extension 512 Foundation Instructions
|
||||||
HasAVX512CD bool // Advanced vector extension 512 Conflict Detection Instructions
|
HasAVX512CD bool // Advanced vector extension 512 Conflict Detection Instructions
|
||||||
HasAVX512ER bool // Advanced vector extension 512 Exponential and Reciprocal Instructions
|
HasAVX512ER bool // Advanced vector extension 512 Exponential and Reciprocal Instructions
|
||||||
HasAVX512PF bool // Advanced vector extension 512 Prefetch Instructions Instructions
|
HasAVX512PF bool // Advanced vector extension 512 Prefetch Instructions
|
||||||
HasAVX512VL bool // Advanced vector extension 512 Vector Length Extensions
|
HasAVX512VL bool // Advanced vector extension 512 Vector Length Extensions
|
||||||
HasAVX512BW bool // Advanced vector extension 512 Byte and Word Instructions
|
HasAVX512BW bool // Advanced vector extension 512 Byte and Word Instructions
|
||||||
HasAVX512DQ bool // Advanced vector extension 512 Doubleword and Quadword Instructions
|
HasAVX512DQ bool // Advanced vector extension 512 Doubleword and Quadword Instructions
|
||||||
@ -54,6 +54,9 @@ var X86 struct {
|
|||||||
HasAVX512VBMI2 bool // Advanced vector extension 512 Vector Byte Manipulation Instructions 2
|
HasAVX512VBMI2 bool // Advanced vector extension 512 Vector Byte Manipulation Instructions 2
|
||||||
HasAVX512BITALG bool // Advanced vector extension 512 Bit Algorithms
|
HasAVX512BITALG bool // Advanced vector extension 512 Bit Algorithms
|
||||||
HasAVX512BF16 bool // Advanced vector extension 512 BFloat16 Instructions
|
HasAVX512BF16 bool // Advanced vector extension 512 BFloat16 Instructions
|
||||||
|
HasAMXTile bool // Advanced Matrix Extension Tile instructions
|
||||||
|
HasAMXInt8 bool // Advanced Matrix Extension Int8 instructions
|
||||||
|
HasAMXBF16 bool // Advanced Matrix Extension BFloat16 instructions
|
||||||
HasBMI1 bool // Bit manipulation instruction set 1
|
HasBMI1 bool // Bit manipulation instruction set 1
|
||||||
HasBMI2 bool // Bit manipulation instruction set 2
|
HasBMI2 bool // Bit manipulation instruction set 2
|
||||||
HasCX16 bool // Compare and exchange 16 Bytes
|
HasCX16 bool // Compare and exchange 16 Bytes
|
||||||
|
2
vendor/golang.org/x/sys/cpu/cpu_riscv64.go
generated
vendored
2
vendor/golang.org/x/sys/cpu/cpu_riscv64.go
generated
vendored
@ -7,6 +7,6 @@
|
|||||||
|
|
||||||
package cpu
|
package cpu
|
||||||
|
|
||||||
const cacheLineSize = 32
|
const cacheLineSize = 64
|
||||||
|
|
||||||
func initOptions() {}
|
func initOptions() {}
|
||||||
|
7
vendor/golang.org/x/sys/cpu/cpu_x86.go
generated
vendored
7
vendor/golang.org/x/sys/cpu/cpu_x86.go
generated
vendored
@ -37,6 +37,9 @@ func initOptions() {
|
|||||||
{Name: "avx512vbmi2", Feature: &X86.HasAVX512VBMI2},
|
{Name: "avx512vbmi2", Feature: &X86.HasAVX512VBMI2},
|
||||||
{Name: "avx512bitalg", Feature: &X86.HasAVX512BITALG},
|
{Name: "avx512bitalg", Feature: &X86.HasAVX512BITALG},
|
||||||
{Name: "avx512bf16", Feature: &X86.HasAVX512BF16},
|
{Name: "avx512bf16", Feature: &X86.HasAVX512BF16},
|
||||||
|
{Name: "amxtile", Feature: &X86.HasAMXTile},
|
||||||
|
{Name: "amxint8", Feature: &X86.HasAMXInt8},
|
||||||
|
{Name: "amxbf16", Feature: &X86.HasAMXBF16},
|
||||||
{Name: "bmi1", Feature: &X86.HasBMI1},
|
{Name: "bmi1", Feature: &X86.HasBMI1},
|
||||||
{Name: "bmi2", Feature: &X86.HasBMI2},
|
{Name: "bmi2", Feature: &X86.HasBMI2},
|
||||||
{Name: "cx16", Feature: &X86.HasCX16},
|
{Name: "cx16", Feature: &X86.HasCX16},
|
||||||
@ -138,6 +141,10 @@ func archInit() {
|
|||||||
eax71, _, _, _ := cpuid(7, 1)
|
eax71, _, _, _ := cpuid(7, 1)
|
||||||
X86.HasAVX512BF16 = isSet(5, eax71)
|
X86.HasAVX512BF16 = isSet(5, eax71)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
X86.HasAMXTile = isSet(24, edx7)
|
||||||
|
X86.HasAMXInt8 = isSet(25, edx7)
|
||||||
|
X86.HasAMXBF16 = isSet(22, edx7)
|
||||||
}
|
}
|
||||||
|
|
||||||
func isSet(bitpos uint, value uint32) bool {
|
func isSet(bitpos uint, value uint32) bool {
|
||||||
|
4
vendor/golang.org/x/sys/cpu/endian_little.go
generated
vendored
4
vendor/golang.org/x/sys/cpu/endian_little.go
generated
vendored
@ -2,8 +2,8 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build 386 || amd64 || amd64p32 || alpha || arm || arm64 || loong64 || mipsle || mips64le || mips64p32le || nios2 || ppc64le || riscv || riscv64 || sh
|
//go:build 386 || amd64 || amd64p32 || alpha || arm || arm64 || loong64 || mipsle || mips64le || mips64p32le || nios2 || ppc64le || riscv || riscv64 || sh || wasm
|
||||||
// +build 386 amd64 amd64p32 alpha arm arm64 loong64 mipsle mips64le mips64p32le nios2 ppc64le riscv riscv64 sh
|
// +build 386 amd64 amd64p32 alpha arm arm64 loong64 mipsle mips64le mips64p32le nios2 ppc64le riscv riscv64 sh wasm
|
||||||
|
|
||||||
package cpu
|
package cpu
|
||||||
|
|
||||||
|
4
vendor/golang.org/x/sys/cpu/hwcap_linux.go
generated
vendored
4
vendor/golang.org/x/sys/cpu/hwcap_linux.go
generated
vendored
@ -5,7 +5,7 @@
|
|||||||
package cpu
|
package cpu
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -39,7 +39,7 @@ func readHWCAP() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
buf, err := ioutil.ReadFile(procAuxv)
|
buf, err := os.ReadFile(procAuxv)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// e.g. on android /proc/self/auxv is not accessible, so silently
|
// e.g. on android /proc/self/auxv is not accessible, so silently
|
||||||
// ignore the error and leave Initialized = false. On some
|
// ignore the error and leave Initialized = false. On some
|
||||||
|
30
vendor/golang.org/x/sys/internal/unsafeheader/unsafeheader.go
generated
vendored
30
vendor/golang.org/x/sys/internal/unsafeheader/unsafeheader.go
generated
vendored
@ -1,30 +0,0 @@
|
|||||||
// Copyright 2020 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// Package unsafeheader contains header declarations for the Go runtime's
|
|
||||||
// slice and string implementations.
|
|
||||||
//
|
|
||||||
// This package allows x/sys to use types equivalent to
|
|
||||||
// reflect.SliceHeader and reflect.StringHeader without introducing
|
|
||||||
// a dependency on the (relatively heavy) "reflect" package.
|
|
||||||
package unsafeheader
|
|
||||||
|
|
||||||
import (
|
|
||||||
"unsafe"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Slice is the runtime representation of a slice.
|
|
||||||
// It cannot be used safely or portably and its representation may change in a later release.
|
|
||||||
type Slice struct {
|
|
||||||
Data unsafe.Pointer
|
|
||||||
Len int
|
|
||||||
Cap int
|
|
||||||
}
|
|
||||||
|
|
||||||
// String is the runtime representation of a string.
|
|
||||||
// It cannot be used safely or portably and its representation may change in a later release.
|
|
||||||
type String struct {
|
|
||||||
Data unsafe.Pointer
|
|
||||||
Len int
|
|
||||||
}
|
|
2
vendor/golang.org/x/sys/unix/mkall.sh
generated
vendored
2
vendor/golang.org/x/sys/unix/mkall.sh
generated
vendored
@ -50,7 +50,7 @@ if [[ "$GOOS" = "linux" ]]; then
|
|||||||
# Use the Docker-based build system
|
# Use the Docker-based build system
|
||||||
# Files generated through docker (use $cmd so you can Ctl-C the build or run)
|
# Files generated through docker (use $cmd so you can Ctl-C the build or run)
|
||||||
$cmd docker build --tag generate:$GOOS $GOOS
|
$cmd docker build --tag generate:$GOOS $GOOS
|
||||||
$cmd docker run --interactive --tty --volume $(cd -- "$(dirname -- "$0")/.." && /bin/pwd):/build generate:$GOOS
|
$cmd docker run --interactive --tty --volume $(cd -- "$(dirname -- "$0")/.." && pwd):/build generate:$GOOS
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user