From bc4285dc801e1aaa5b1184c169b4ff85e757aadd Mon Sep 17 00:00:00 2001 From: Gabriel Adrian Samfira Date: Sat, 3 Aug 2024 16:07:21 +0000 Subject: [PATCH] Update garm-provider-common Use the websocket reader from within garm-provider-common. Signed-off-by: Gabriel Adrian Samfira --- cmd/garm-cli/cmd/events.go | 2 +- cmd/garm-cli/cmd/log.go | 2 +- database/common/mocks/Store.go | 54 +++++++++---------- go.mod | 14 ++--- go.sum | 20 +++---- .../execution/execution.go | 4 ++ .../garm-provider-common/params/github.go | 14 +++++ .../util/websocket/reader.go | 26 ++++++++- .../util/websocket/util.go | 37 +++++++++++++ vendor/github.com/minio/sio/.golangci.yml | 21 +++++--- vendor/github.com/minio/sio/dare.go | 4 +- vendor/golang.org/x/crypto/bcrypt/bcrypt.go | 2 +- vendor/golang.org/x/crypto/blowfish/cipher.go | 2 +- .../chacha20poly1305/chacha20poly1305.go | 2 +- vendor/golang.org/x/crypto/hkdf/hkdf.go | 2 +- vendor/golang.org/x/sys/unix/mremap.go | 5 ++ .../golang.org/x/sys/unix/syscall_darwin.go | 12 +++++ vendor/golang.org/x/sys/unix/syscall_unix.go | 9 ++++ .../x/sys/unix/zsyscall_darwin_amd64.go | 33 ++++++++++++ .../x/sys/unix/zsyscall_darwin_amd64.s | 10 ++++ .../x/sys/unix/zsyscall_darwin_arm64.go | 33 ++++++++++++ .../x/sys/unix/zsyscall_darwin_arm64.s | 10 ++++ .../x/sys/windows/security_windows.go | 24 ++++++++- .../x/sys/windows/zsyscall_windows.go | 9 ++++ vendor/modules.txt | 15 +++--- 25 files changed, 297 insertions(+), 69 deletions(-) rename websocket/util.go => vendor/github.com/cloudbase/garm-provider-common/util/websocket/reader.go (78%) create mode 100644 vendor/github.com/cloudbase/garm-provider-common/util/websocket/util.go diff --git a/cmd/garm-cli/cmd/events.go b/cmd/garm-cli/cmd/events.go index 9698f633..f38e9ea6 100644 --- a/cmd/garm-cli/cmd/events.go +++ b/cmd/garm-cli/cmd/events.go @@ -9,8 +9,8 @@ import ( "github.com/gorilla/websocket" "github.com/spf13/cobra" + garmWs "github.com/cloudbase/garm-provider-common/util/websocket" "github.com/cloudbase/garm/cmd/garm-cli/common" - garmWs "github.com/cloudbase/garm/websocket" ) var signals = []os.Signal{ diff --git a/cmd/garm-cli/cmd/log.go b/cmd/garm-cli/cmd/log.go index 99a64944..901e8e0f 100644 --- a/cmd/garm-cli/cmd/log.go +++ b/cmd/garm-cli/cmd/log.go @@ -6,8 +6,8 @@ import ( "github.com/spf13/cobra" + garmWs "github.com/cloudbase/garm-provider-common/util/websocket" "github.com/cloudbase/garm/cmd/garm-cli/common" - garmWs "github.com/cloudbase/garm/websocket" ) var eventsFilters string diff --git a/database/common/mocks/Store.go b/database/common/mocks/Store.go index 4af6f403..0791ff36 100644 --- a/database/common/mocks/Store.go +++ b/database/common/mocks/Store.go @@ -568,9 +568,9 @@ func (_m *Store) GetAdminUser(ctx context.Context) (params.User, error) { return r0, r1 } -// GetEnterprise provides a mock function with given fields: ctx, name -func (_m *Store) GetEnterprise(ctx context.Context, name string) (params.Enterprise, error) { - ret := _m.Called(ctx, name) +// GetEnterprise provides a mock function with given fields: ctx, name, endpointName +func (_m *Store) GetEnterprise(ctx context.Context, name string, endpointName string) (params.Enterprise, error) { + ret := _m.Called(ctx, name, endpointName) if len(ret) == 0 { panic("no return value specified for GetEnterprise") @@ -578,17 +578,17 @@ func (_m *Store) GetEnterprise(ctx context.Context, name string) (params.Enterpr var r0 params.Enterprise var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string) (params.Enterprise, error)); ok { - return rf(ctx, name) + if rf, ok := ret.Get(0).(func(context.Context, string, string) (params.Enterprise, error)); ok { + return rf(ctx, name, endpointName) } - if rf, ok := ret.Get(0).(func(context.Context, string) params.Enterprise); ok { - r0 = rf(ctx, name) + if rf, ok := ret.Get(0).(func(context.Context, string, string) params.Enterprise); ok { + r0 = rf(ctx, name, endpointName) } else { r0 = ret.Get(0).(params.Enterprise) } - if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { - r1 = rf(ctx, name) + if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok { + r1 = rf(ctx, name, endpointName) } else { r1 = ret.Error(1) } @@ -792,9 +792,9 @@ func (_m *Store) GetJobByID(ctx context.Context, jobID int64) (params.Job, error return r0, r1 } -// GetOrganization provides a mock function with given fields: ctx, name -func (_m *Store) GetOrganization(ctx context.Context, name string) (params.Organization, error) { - ret := _m.Called(ctx, name) +// GetOrganization provides a mock function with given fields: ctx, name, endpointName +func (_m *Store) GetOrganization(ctx context.Context, name string, endpointName string) (params.Organization, error) { + ret := _m.Called(ctx, name, endpointName) if len(ret) == 0 { panic("no return value specified for GetOrganization") @@ -802,17 +802,17 @@ func (_m *Store) GetOrganization(ctx context.Context, name string) (params.Organ var r0 params.Organization var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string) (params.Organization, error)); ok { - return rf(ctx, name) + if rf, ok := ret.Get(0).(func(context.Context, string, string) (params.Organization, error)); ok { + return rf(ctx, name, endpointName) } - if rf, ok := ret.Get(0).(func(context.Context, string) params.Organization); ok { - r0 = rf(ctx, name) + if rf, ok := ret.Get(0).(func(context.Context, string, string) params.Organization); ok { + r0 = rf(ctx, name, endpointName) } else { r0 = ret.Get(0).(params.Organization) } - if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { - r1 = rf(ctx, name) + if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok { + r1 = rf(ctx, name, endpointName) } else { r1 = ret.Error(1) } @@ -904,9 +904,9 @@ func (_m *Store) GetPoolInstanceByName(ctx context.Context, poolID string, insta return r0, r1 } -// GetRepository provides a mock function with given fields: ctx, owner, name -func (_m *Store) GetRepository(ctx context.Context, owner string, name string) (params.Repository, error) { - ret := _m.Called(ctx, owner, name) +// GetRepository provides a mock function with given fields: ctx, owner, name, endpointName +func (_m *Store) GetRepository(ctx context.Context, owner string, name string, endpointName string) (params.Repository, error) { + ret := _m.Called(ctx, owner, name, endpointName) if len(ret) == 0 { panic("no return value specified for GetRepository") @@ -914,17 +914,17 @@ func (_m *Store) GetRepository(ctx context.Context, owner string, name string) ( var r0 params.Repository var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, string) (params.Repository, error)); ok { - return rf(ctx, owner, name) + if rf, ok := ret.Get(0).(func(context.Context, string, string, string) (params.Repository, error)); ok { + return rf(ctx, owner, name, endpointName) } - if rf, ok := ret.Get(0).(func(context.Context, string, string) params.Repository); ok { - r0 = rf(ctx, owner, name) + if rf, ok := ret.Get(0).(func(context.Context, string, string, string) params.Repository); ok { + r0 = rf(ctx, owner, name, endpointName) } else { r0 = ret.Get(0).(params.Repository) } - if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok { - r1 = rf(ctx, owner, name) + if rf, ok := ret.Get(1).(func(context.Context, string, string, string) error); ok { + r1 = rf(ctx, owner, name, endpointName) } else { r1 = ret.Error(1) } diff --git a/go.mod b/go.mod index b9774978..4057e225 100644 --- a/go.mod +++ b/go.mod @@ -1,11 +1,13 @@ module github.com/cloudbase/garm -go 1.21 +go 1.22 + +toolchain go1.22.3 require ( github.com/BurntSushi/toml v1.3.2 github.com/bradleyfalzon/ghinstallation/v2 v2.10.0 - github.com/cloudbase/garm-provider-common v0.1.1 + github.com/cloudbase/garm-provider-common v0.1.3 github.com/felixge/httpsnoop v1.0.4 github.com/go-openapi/errors v0.22.0 github.com/go-openapi/runtime v0.28.0 @@ -26,7 +28,7 @@ require ( github.com/prometheus/client_golang v1.19.0 github.com/spf13/cobra v1.8.0 github.com/stretchr/testify v1.9.0 - golang.org/x/crypto v0.24.0 + golang.org/x/crypto v0.25.0 golang.org/x/oauth2 v0.19.0 golang.org/x/sync v0.7.0 gopkg.in/DATA-DOG/go-sqlmock.v1 v1.3.0 @@ -67,7 +69,7 @@ require ( github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-runewidth v0.0.15 // indirect github.com/mattn/go-sqlite3 v1.14.22 // indirect - github.com/minio/sio v0.3.1 // indirect + github.com/minio/sio v0.4.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/oklog/ulid v1.3.1 // indirect github.com/opentracing/opentracing-go v1.2.0 // indirect @@ -83,8 +85,8 @@ require ( go.opentelemetry.io/otel v1.25.0 // indirect go.opentelemetry.io/otel/metric v1.25.0 // indirect go.opentelemetry.io/otel/trace v1.25.0 // indirect - golang.org/x/net v0.26.0 // indirect - golang.org/x/sys v0.21.0 // indirect + golang.org/x/net v0.27.0 // indirect + golang.org/x/sys v0.22.0 // indirect google.golang.org/protobuf v1.33.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index edee640a..f4939954 100644 --- a/go.sum +++ b/go.sum @@ -19,8 +19,8 @@ github.com/chzyer/readline v1.5.1/go.mod h1:Eh+b79XXUwfKfcPLepksvw2tcLE/Ct21YObk github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/chzyer/test v1.0.0 h1:p3BQDXSxOhOG0P9z6/hGnII4LGiEPOYBhs8asl/fC04= github.com/chzyer/test v1.0.0/go.mod h1:2JlltgoNkt4TW/z9V/IzDdFaMTM2JPIi26O1pF38GC8= -github.com/cloudbase/garm-provider-common v0.1.1 h1:9SbkEevpycI/P3J7jEmjJf6VzdrxAIHkLppnjqaKAWU= -github.com/cloudbase/garm-provider-common v0.1.1/go.mod h1:igxJRT3OlykERYc6ssdRQXcb+BCaeSfnucg6I0OSoDc= +github.com/cloudbase/garm-provider-common v0.1.3 h1:8pHSRs2ljwLHgtDrge68dZ7ILUW97VF5h2ZA2fQubGQ= +github.com/cloudbase/garm-provider-common v0.1.3/go.mod h1:VIJzbcg5iwyD4ac99tnnwcActfwibn/VOt2MYOFjf2c= github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= 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= @@ -128,8 +128,8 @@ github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= github.com/microsoft/go-mssqldb v0.17.0 h1:Fto83dMZPnYv1Zwx5vHHxpNraeEaUlQ/hhHLgZiaenE= github.com/microsoft/go-mssqldb v0.17.0/go.mod h1:OkoNGhGEs8EZqchVTtochlXruEhEOaO4S0d2sB5aeGQ= -github.com/minio/sio v0.3.1 h1:d59r5RTHb1OsQaSl1EaTWurzMMDRLA5fgNmjzD4eVu4= -github.com/minio/sio v0.3.1/go.mod h1:S0ovgVgc+sTlQyhiXA1ppBLv7REM7TYi5yyq2qL/Y6o= +github.com/minio/sio v0.4.0 h1:u4SWVEm5lXSqU42ZWawV0D9I5AZ5YMmo2RXpEQ/kRhc= +github.com/minio/sio v0.4.0/go.mod h1:oBSjJeGbBdRMZZwna07sX9EFzZy+ywu5aofRiV1g79I= 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/nbutton23/zxcvbn-go v0.0.0-20210217022336-fa2cb2858354 h1:4kuARK6Y6FxaNu/BnU2OAaLF86eTVhP2hjTB6iMvItA= @@ -180,10 +180,10 @@ go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucg go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg= go.opentelemetry.io/otel/trace v1.25.0 h1:tqukZGLwQYRIFtSQM2u2+yfMVTgGVeqRLPUYx1Dq6RM= go.opentelemetry.io/otel/trace v1.25.0/go.mod h1:hCCs70XM/ljO+BeQkyFnbK28SBIJ/Emuha+ccrCRT7I= -golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= -golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= -golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= -golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= +golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= +golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= +golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= +golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= golang.org/x/oauth2 v0.19.0 h1:9+E/EZBCbTLNrbN35fHv/a/d/mOBatymz1zbtQrXpIg= golang.org/x/oauth2 v0.19.0/go.mod h1:vYi7skDa1x015PmRRYZ7+s1cWyPgrPiSYRe4rnsexc8= golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= @@ -191,8 +191,8 @@ golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= -golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= +golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/vendor/github.com/cloudbase/garm-provider-common/execution/execution.go b/vendor/github.com/cloudbase/garm-provider-common/execution/execution.go index 4d47a1f0..948fe3a7 100644 --- a/vendor/github.com/cloudbase/garm-provider-common/execution/execution.go +++ b/vendor/github.com/cloudbase/garm-provider-common/execution/execution.go @@ -77,6 +77,10 @@ func GetEnvironment() (Environment, error) { if err := json.Unmarshal(data.Bytes(), &bootstrapParams); err != nil { return Environment{}, fmt.Errorf("failed to decode instance params: %w", err) } + if bootstrapParams.ExtraSpecs == nil { + // Initialize ExtraSpecs as an empty JSON object + bootstrapParams.ExtraSpecs = json.RawMessage([]byte("{}")) + } env.BootstrapParams = bootstrapParams } diff --git a/vendor/github.com/cloudbase/garm-provider-common/params/github.go b/vendor/github.com/cloudbase/garm-provider-common/params/github.go index 9f64de9d..c3e9a0a4 100644 --- a/vendor/github.com/cloudbase/garm-provider-common/params/github.go +++ b/vendor/github.com/cloudbase/garm-provider-common/params/github.go @@ -1,3 +1,17 @@ +// Copyright 2023 Cloudbase Solutions SRL +// +// 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 params // RunnerApplicationDownload represents a binary for the self-hosted runner application that can be downloaded. diff --git a/websocket/util.go b/vendor/github.com/cloudbase/garm-provider-common/util/websocket/reader.go similarity index 78% rename from websocket/util.go rename to vendor/github.com/cloudbase/garm-provider-common/util/websocket/reader.go index e0dc256d..92ed2edf 100644 --- a/websocket/util.go +++ b/vendor/github.com/cloudbase/garm-provider-common/util/websocket/reader.go @@ -11,12 +11,32 @@ import ( "time" "github.com/gorilla/websocket" +) + +const ( + // Time allowed to write a message to the peer. + writeWait = 10 * time.Second + + // Time allowed to read the next pong message from the peer. + pongWait = 60 * time.Second - apiParams "github.com/cloudbase/garm/apiserver/params" + // Send pings to peer with this period. Must be less than pongWait. + pingPeriod = (pongWait * 9) / 10 + + // Maximum message size allowed from peer. + maxMessageSize = 16384 // 16 KB ) +// MessageHandler is a function that processes a message received from a websocket connection. type MessageHandler func(msgType int, msg []byte) error +type APIErrorResponse struct { + Error string `json:"error"` + Details string `json:"details"` +} + +// NewReader creates a new websocket reader. The reader will pass on any message it receives to the +// handler function. The handler function should return an error if it fails to process the message. func NewReader(ctx context.Context, baseURL, pth, token string, handler MessageHandler) (*Reader, error) { parsedURL, err := url.Parse(baseURL) if err != nil { @@ -95,7 +115,7 @@ func (w *Reader) Start() error { c, response, err := websocket.DefaultDialer.Dial(w.url.String(), w.header) if err != nil { - var resp apiParams.APIErrorResponse + var resp APIErrorResponse var msg string var status string if response != nil { @@ -126,6 +146,8 @@ func (w *Reader) handlerReader() { msgType, message, err := w.conn.ReadMessage() if err != nil { if IsErrorOfInterest(err) { + // TODO(gabriel-samfira): we should allow for an error channel that can be used to signal + // the caller that the connection has been closed. slog.With(slog.Any("error", err)).Error("reading log message") } return diff --git a/vendor/github.com/cloudbase/garm-provider-common/util/websocket/util.go b/vendor/github.com/cloudbase/garm-provider-common/util/websocket/util.go new file mode 100644 index 00000000..88c02fa5 --- /dev/null +++ b/vendor/github.com/cloudbase/garm-provider-common/util/websocket/util.go @@ -0,0 +1,37 @@ +package websocket + +import ( + "errors" + "net" + + "github.com/gorilla/websocket" +) + +func IsErrorOfInterest(err error) bool { + if err == nil { + return false + } + + if errors.Is(err, websocket.ErrCloseSent) { + return false + } + + if errors.Is(err, websocket.ErrBadHandshake) { + return false + } + + if errors.Is(err, net.ErrClosed) { + return false + } + + asCloseErr, ok := err.(*websocket.CloseError) + if ok { + switch asCloseErr.Code { + case websocket.CloseNormalClosure, websocket.CloseGoingAway, + websocket.CloseNoStatusReceived, websocket.CloseAbnormalClosure: + return false + } + } + + return true +} diff --git a/vendor/github.com/minio/sio/.golangci.yml b/vendor/github.com/minio/sio/.golangci.yml index 7c282948..dd2cc77f 100644 --- a/vendor/github.com/minio/sio/.golangci.yml +++ b/vendor/github.com/minio/sio/.golangci.yml @@ -5,19 +5,26 @@ linters-settings: misspell: locale: US + staticcheck: + checks: ['all', '-SA6002'] + linters: disable-all: true enable: - - typecheck + - durationcheck + - gocritic + - gofumpt - goimports - - misspell + - gomodguard - govet - ineffassign - - gosimple - - unused - - prealloc - - unconvert + - misspell - revive + - staticcheck + - tenv + - typecheck + - unconvert + - unused issues: exclude-use-default: false @@ -25,5 +32,3 @@ issues: - should have a package comment - error strings should not be capitalized or end with punctuation or a newline - don't use ALL_CAPS in Go names -service: - golangci-lint-version: 1.33.0 # use the fixed version to not introduce new linters unexpectedly diff --git a/vendor/github.com/minio/sio/dare.go b/vendor/github.com/minio/sio/dare.go index cf785e06..8d8fe0cb 100644 --- a/vendor/github.com/minio/sio/dare.go +++ b/vendor/github.com/minio/sio/dare.go @@ -31,7 +31,7 @@ func (h headerV10) SetVersion() { h[0] = Version10 } func (h headerV10) SetCipher(suite byte) { h[1] = suite } func (h headerV10) SetLen(length int) { binary.LittleEndian.PutUint16(h[2:], uint16(length-1)) } func (h headerV10) SetSequenceNumber(num uint32) { binary.LittleEndian.PutUint32(h[4:], num) } -func (h headerV10) SetRand(randVal []byte) { copy(h[8:headerSize], randVal[:]) } +func (h headerV10) SetRand(randVal []byte) { copy(h[8:headerSize], randVal) } func (h headerV10) Nonce() []byte { return h[4:headerSize] } func (h headerV10) AddData() []byte { return h[:4] } @@ -256,7 +256,7 @@ func (ad *authDecV20) Open(dst, src []byte) error { ad.finalized = true refNonce[0] |= 0x80 // set final flag } - if subtle.ConstantTimeCompare(header.Nonce(), refNonce[:]) != 1 { + if subtle.ConstantTimeCompare(header.Nonce(), refNonce) != 1 { return errNonceMismatch } diff --git a/vendor/golang.org/x/crypto/bcrypt/bcrypt.go b/vendor/golang.org/x/crypto/bcrypt/bcrypt.go index 5577c0f9..dc931187 100644 --- a/vendor/golang.org/x/crypto/bcrypt/bcrypt.go +++ b/vendor/golang.org/x/crypto/bcrypt/bcrypt.go @@ -4,7 +4,7 @@ // Package bcrypt implements Provos and Mazières's bcrypt adaptive hashing // algorithm. See http://www.usenix.org/event/usenix99/provos/provos.pdf -package bcrypt // import "golang.org/x/crypto/bcrypt" +package bcrypt // The code is a port of Provos and Mazières's C implementation. import ( diff --git a/vendor/golang.org/x/crypto/blowfish/cipher.go b/vendor/golang.org/x/crypto/blowfish/cipher.go index 213bf204..08989568 100644 --- a/vendor/golang.org/x/crypto/blowfish/cipher.go +++ b/vendor/golang.org/x/crypto/blowfish/cipher.go @@ -11,7 +11,7 @@ // Deprecated: any new system should use AES (from crypto/aes, if necessary in // an AEAD mode like crypto/cipher.NewGCM) or XChaCha20-Poly1305 (from // golang.org/x/crypto/chacha20poly1305). -package blowfish // import "golang.org/x/crypto/blowfish" +package blowfish // The code is a port of Bruce Schneier's C implementation. // See https://www.schneier.com/blowfish.html. diff --git a/vendor/golang.org/x/crypto/chacha20poly1305/chacha20poly1305.go b/vendor/golang.org/x/crypto/chacha20poly1305/chacha20poly1305.go index 93da7322..8cf5d811 100644 --- a/vendor/golang.org/x/crypto/chacha20poly1305/chacha20poly1305.go +++ b/vendor/golang.org/x/crypto/chacha20poly1305/chacha20poly1305.go @@ -5,7 +5,7 @@ // Package chacha20poly1305 implements the ChaCha20-Poly1305 AEAD and its // extended nonce variant XChaCha20-Poly1305, as specified in RFC 8439 and // draft-irtf-cfrg-xchacha-01. -package chacha20poly1305 // import "golang.org/x/crypto/chacha20poly1305" +package chacha20poly1305 import ( "crypto/cipher" diff --git a/vendor/golang.org/x/crypto/hkdf/hkdf.go b/vendor/golang.org/x/crypto/hkdf/hkdf.go index f4ded5fe..3bee6629 100644 --- a/vendor/golang.org/x/crypto/hkdf/hkdf.go +++ b/vendor/golang.org/x/crypto/hkdf/hkdf.go @@ -8,7 +8,7 @@ // HKDF is a cryptographic key derivation function (KDF) with the goal of // expanding limited input keying material into one or more cryptographically // strong secret keys. -package hkdf // import "golang.org/x/crypto/hkdf" +package hkdf import ( "crypto/hmac" diff --git a/vendor/golang.org/x/sys/unix/mremap.go b/vendor/golang.org/x/sys/unix/mremap.go index fd45fe52..3a5e776f 100644 --- a/vendor/golang.org/x/sys/unix/mremap.go +++ b/vendor/golang.org/x/sys/unix/mremap.go @@ -50,3 +50,8 @@ func (m *mremapMmapper) Mremap(oldData []byte, newLength int, flags int) (data [ func Mremap(oldData []byte, newLength int, flags int) (data []byte, err error) { return mapper.Mremap(oldData, newLength, flags) } + +func MremapPtr(oldAddr unsafe.Pointer, oldSize uintptr, newAddr unsafe.Pointer, newSize uintptr, flags int) (ret unsafe.Pointer, err error) { + xaddr, err := mapper.mremap(uintptr(oldAddr), oldSize, newSize, flags, uintptr(newAddr)) + return unsafe.Pointer(xaddr), err +} diff --git a/vendor/golang.org/x/sys/unix/syscall_darwin.go b/vendor/golang.org/x/sys/unix/syscall_darwin.go index 59542a89..4cc7b005 100644 --- a/vendor/golang.org/x/sys/unix/syscall_darwin.go +++ b/vendor/golang.org/x/sys/unix/syscall_darwin.go @@ -542,6 +542,18 @@ func SysctlKinfoProcSlice(name string, args ...int) ([]KinfoProc, error) { } } +//sys pthread_chdir_np(path string) (err error) + +func PthreadChdir(path string) (err error) { + return pthread_chdir_np(path) +} + +//sys pthread_fchdir_np(fd int) (err error) + +func PthreadFchdir(fd int) (err error) { + return pthread_fchdir_np(fd) +} + //sys sendfile(infd int, outfd int, offset int64, len *int64, hdtr unsafe.Pointer, flags int) (err error) //sys shmat(id int, addr uintptr, flag int) (ret uintptr, err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_unix.go b/vendor/golang.org/x/sys/unix/syscall_unix.go index 77081de8..4e92e5aa 100644 --- a/vendor/golang.org/x/sys/unix/syscall_unix.go +++ b/vendor/golang.org/x/sys/unix/syscall_unix.go @@ -154,6 +154,15 @@ func Munmap(b []byte) (err error) { return mapper.Munmap(b) } +func MmapPtr(fd int, offset int64, addr unsafe.Pointer, length uintptr, prot int, flags int) (ret unsafe.Pointer, err error) { + xaddr, err := mapper.mmap(uintptr(addr), length, prot, flags, fd, offset) + return unsafe.Pointer(xaddr), err +} + +func MunmapPtr(addr unsafe.Pointer, length uintptr) (err error) { + return mapper.munmap(uintptr(addr), length) +} + func Read(fd int, p []byte) (n int, err error) { n, err = read(fd, p) if raceenabled { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go index ccb02f24..07642c30 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go @@ -760,6 +760,39 @@ var libc_sysctl_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func pthread_chdir_np(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_pthread_chdir_np_trampoline_addr, uintptr(unsafe.Pointer(_p0)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_pthread_chdir_np_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_pthread_chdir_np pthread_chdir_np "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pthread_fchdir_np(fd int) (err error) { + _, _, e1 := syscall_syscall(libc_pthread_fchdir_np_trampoline_addr, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_pthread_fchdir_np_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_pthread_fchdir_np pthread_fchdir_np "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func sendfile(infd int, outfd int, offset int64, len *int64, hdtr unsafe.Pointer, flags int) (err error) { _, _, e1 := syscall_syscall6(libc_sendfile_trampoline_addr, uintptr(infd), uintptr(outfd), uintptr(offset), uintptr(unsafe.Pointer(len)), uintptr(hdtr), uintptr(flags)) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s index 8b8bb284..923e08cb 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s @@ -228,6 +228,16 @@ TEXT libc_sysctl_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_sysctl_trampoline_addr(SB), RODATA, $8 DATA ·libc_sysctl_trampoline_addr(SB)/8, $libc_sysctl_trampoline<>(SB) +TEXT libc_pthread_chdir_np_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_pthread_chdir_np(SB) +GLOBL ·libc_pthread_chdir_np_trampoline_addr(SB), RODATA, $8 +DATA ·libc_pthread_chdir_np_trampoline_addr(SB)/8, $libc_pthread_chdir_np_trampoline<>(SB) + +TEXT libc_pthread_fchdir_np_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_pthread_fchdir_np(SB) +GLOBL ·libc_pthread_fchdir_np_trampoline_addr(SB), RODATA, $8 +DATA ·libc_pthread_fchdir_np_trampoline_addr(SB)/8, $libc_pthread_fchdir_np_trampoline<>(SB) + TEXT libc_sendfile_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_sendfile(SB) GLOBL ·libc_sendfile_trampoline_addr(SB), RODATA, $8 diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go index 1b40b997..7d73dda6 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go @@ -760,6 +760,39 @@ var libc_sysctl_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func pthread_chdir_np(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_pthread_chdir_np_trampoline_addr, uintptr(unsafe.Pointer(_p0)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_pthread_chdir_np_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_pthread_chdir_np pthread_chdir_np "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pthread_fchdir_np(fd int) (err error) { + _, _, e1 := syscall_syscall(libc_pthread_fchdir_np_trampoline_addr, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_pthread_fchdir_np_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_pthread_fchdir_np pthread_fchdir_np "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func sendfile(infd int, outfd int, offset int64, len *int64, hdtr unsafe.Pointer, flags int) (err error) { _, _, e1 := syscall_syscall6(libc_sendfile_trampoline_addr, uintptr(infd), uintptr(outfd), uintptr(offset), uintptr(unsafe.Pointer(len)), uintptr(hdtr), uintptr(flags)) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s index 08362c1a..05770011 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s @@ -228,6 +228,16 @@ TEXT libc_sysctl_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_sysctl_trampoline_addr(SB), RODATA, $8 DATA ·libc_sysctl_trampoline_addr(SB)/8, $libc_sysctl_trampoline<>(SB) +TEXT libc_pthread_chdir_np_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_pthread_chdir_np(SB) +GLOBL ·libc_pthread_chdir_np_trampoline_addr(SB), RODATA, $8 +DATA ·libc_pthread_chdir_np_trampoline_addr(SB)/8, $libc_pthread_chdir_np_trampoline<>(SB) + +TEXT libc_pthread_fchdir_np_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_pthread_fchdir_np(SB) +GLOBL ·libc_pthread_fchdir_np_trampoline_addr(SB), RODATA, $8 +DATA ·libc_pthread_fchdir_np_trampoline_addr(SB)/8, $libc_pthread_fchdir_np_trampoline<>(SB) + TEXT libc_sendfile_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_sendfile(SB) GLOBL ·libc_sendfile_trampoline_addr(SB), RODATA, $8 diff --git a/vendor/golang.org/x/sys/windows/security_windows.go b/vendor/golang.org/x/sys/windows/security_windows.go index 6f7d2ac7..97651b5b 100644 --- a/vendor/golang.org/x/sys/windows/security_windows.go +++ b/vendor/golang.org/x/sys/windows/security_windows.go @@ -894,7 +894,7 @@ type ACL struct { aclRevision byte sbz1 byte aclSize uint16 - aceCount uint16 + AceCount uint16 sbz2 uint16 } @@ -1087,6 +1087,27 @@ type EXPLICIT_ACCESS struct { Trustee TRUSTEE } +// https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-ace_header +type ACE_HEADER struct { + AceType uint8 + AceFlags uint8 + AceSize uint16 +} + +// https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-access_allowed_ace +type ACCESS_ALLOWED_ACE struct { + Header ACE_HEADER + Mask ACCESS_MASK + SidStart uint32 +} + +const ( + // Constants for AceType + // https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-ace_header + ACCESS_ALLOWED_ACE_TYPE = 0 + ACCESS_DENIED_ACE_TYPE = 1 +) + // This type is the union inside of TRUSTEE and must be created using one of the TrusteeValueFrom* functions. type TrusteeValue uintptr @@ -1158,6 +1179,7 @@ type OBJECTS_AND_NAME struct { //sys makeSelfRelativeSD(absoluteSD *SECURITY_DESCRIPTOR, selfRelativeSD *SECURITY_DESCRIPTOR, selfRelativeSDSize *uint32) (err error) = advapi32.MakeSelfRelativeSD //sys setEntriesInAcl(countExplicitEntries uint32, explicitEntries *EXPLICIT_ACCESS, oldACL *ACL, newACL **ACL) (ret error) = advapi32.SetEntriesInAclW +//sys GetAce(acl *ACL, aceIndex uint32, pAce **ACCESS_ALLOWED_ACE) (ret error) = advapi32.GetAce // Control returns the security descriptor control bits. func (sd *SECURITY_DESCRIPTOR) Control() (control SECURITY_DESCRIPTOR_CONTROL, revision uint32, err error) { diff --git a/vendor/golang.org/x/sys/windows/zsyscall_windows.go b/vendor/golang.org/x/sys/windows/zsyscall_windows.go index 9f73df75..eba76101 100644 --- a/vendor/golang.org/x/sys/windows/zsyscall_windows.go +++ b/vendor/golang.org/x/sys/windows/zsyscall_windows.go @@ -91,6 +91,7 @@ var ( procEnumServicesStatusExW = modadvapi32.NewProc("EnumServicesStatusExW") procEqualSid = modadvapi32.NewProc("EqualSid") procFreeSid = modadvapi32.NewProc("FreeSid") + procGetAce = modadvapi32.NewProc("GetAce") procGetLengthSid = modadvapi32.NewProc("GetLengthSid") procGetNamedSecurityInfoW = modadvapi32.NewProc("GetNamedSecurityInfoW") procGetSecurityDescriptorControl = modadvapi32.NewProc("GetSecurityDescriptorControl") @@ -1224,6 +1225,14 @@ func setEntriesInAcl(countExplicitEntries uint32, explicitEntries *EXPLICIT_ACCE return } +func GetAce(acl *ACL, aceIndex uint32, pAce **ACCESS_ALLOWED_ACE) (ret error) { + r0, _, _ := syscall.Syscall(procGetAce.Addr(), 3, uintptr(unsafe.Pointer(acl)), uintptr(aceIndex), uintptr(unsafe.Pointer(pAce))) + if r0 == 0 { + ret = GetLastError() + } + return +} + func SetKernelObjectSecurity(handle Handle, securityInformation SECURITY_INFORMATION, securityDescriptor *SECURITY_DESCRIPTOR) (err error) { r1, _, e1 := syscall.Syscall(procSetKernelObjectSecurity.Addr(), 3, uintptr(handle), uintptr(securityInformation), uintptr(unsafe.Pointer(securityDescriptor))) if r1 == 0 { diff --git a/vendor/modules.txt b/vendor/modules.txt index fd9a1f56..8380b1d6 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -21,14 +21,15 @@ github.com/cespare/xxhash/v2 # github.com/chzyer/readline v1.5.1 ## explicit; go 1.15 github.com/chzyer/readline -# github.com/cloudbase/garm-provider-common v0.1.1 -## explicit; go 1.20 +# github.com/cloudbase/garm-provider-common v0.1.3 +## explicit; go 1.22 github.com/cloudbase/garm-provider-common/defaults github.com/cloudbase/garm-provider-common/errors github.com/cloudbase/garm-provider-common/execution github.com/cloudbase/garm-provider-common/params github.com/cloudbase/garm-provider-common/util github.com/cloudbase/garm-provider-common/util/exec +github.com/cloudbase/garm-provider-common/util/websocket # github.com/davecgh/go-spew v1.1.1 ## explicit github.com/davecgh/go-spew/spew @@ -165,7 +166,7 @@ github.com/mattn/go-runewidth # github.com/mattn/go-sqlite3 v1.14.22 ## explicit; go 1.19 github.com/mattn/go-sqlite3 -# github.com/minio/sio v0.3.1 +# github.com/minio/sio v0.4.0 ## explicit; go 1.18 github.com/minio/sio # github.com/mitchellh/mapstructure v1.5.0 @@ -266,8 +267,8 @@ go.opentelemetry.io/otel/metric/embedded ## explicit; go 1.21 go.opentelemetry.io/otel/trace go.opentelemetry.io/otel/trace/embedded -# golang.org/x/crypto v0.24.0 -## explicit; go 1.18 +# golang.org/x/crypto v0.25.0 +## explicit; go 1.20 golang.org/x/crypto/bcrypt golang.org/x/crypto/blowfish golang.org/x/crypto/chacha20 @@ -275,7 +276,7 @@ golang.org/x/crypto/chacha20poly1305 golang.org/x/crypto/hkdf golang.org/x/crypto/internal/alias golang.org/x/crypto/internal/poly1305 -# golang.org/x/net v0.26.0 +# golang.org/x/net v0.27.0 ## explicit; go 1.18 golang.org/x/net/internal/socks golang.org/x/net/proxy @@ -286,7 +287,7 @@ golang.org/x/oauth2/internal # golang.org/x/sync v0.7.0 ## explicit; go 1.18 golang.org/x/sync/errgroup -# golang.org/x/sys v0.21.0 +# golang.org/x/sys v0.22.0 ## explicit; go 1.18 golang.org/x/sys/cpu golang.org/x/sys/unix