diff --git a/go.mod b/go.mod index 42566a1508..3ed06e7a6f 100644 --- a/go.mod +++ b/go.mod @@ -53,7 +53,7 @@ require ( github.com/stretchr/testify v1.9.0 github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 github.com/yusufpapurcu/wmi v1.2.4 - github.com/zalando/go-keyring v0.2.5 + github.com/zalando/go-keyring v0.2.6 golang.org/x/crypto v0.28.0 golang.org/x/net v0.30.0 golang.org/x/sync v0.8.0 @@ -69,11 +69,11 @@ require ( ) require ( + al.essio.dev/pkg/shellescape v1.5.1 // indirect github.com/BurntSushi/toml v1.4.0 // indirect github.com/RangelReale/osincli v0.0.0-20160924135400-fababb0555f2 // indirect github.com/VividCortex/ewma v1.2.0 // indirect github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d // indirect - github.com/alessio/shellescape v1.4.2 // indirect github.com/apparentlymart/go-cidr v1.1.0 // indirect github.com/areYouLazy/libhosty v1.1.0 // indirect github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 // indirect @@ -85,7 +85,7 @@ require ( github.com/cucumber/gherkin/go/v26 v26.2.0 // indirect github.com/cucumber/messages/go/v21 v21.0.1 // indirect github.com/cyberphone/json-canonicalization v0.0.0-20231217050601-ba74d44ecf5f // indirect - github.com/danieljoos/wincred v1.2.1 // indirect + github.com/danieljoos/wincred v1.2.2 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/distribution/reference v0.6.0 // indirect github.com/docker/distribution v2.8.3+incompatible // indirect diff --git a/go.sum b/go.sum index 5a4022756a..e23eba40e3 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,5 @@ +al.essio.dev/pkg/shellescape v1.5.1 h1:86HrALUujYS/h+GtqoB26SBEdkWfmMI6FubjXlsXyho= +al.essio.dev/pkg/shellescape v1.5.1/go.mod h1:6sIqp7X2P6mThCQ7twERpZTuigpr6KbZWtls1U8I890= dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= github.com/AlecAivazis/survey/v2 v2.3.7 h1:6I/u8FvytdGsgonrYsVn2t8t4QiRnh6QSTqkkhIiSjQ= @@ -20,8 +22,6 @@ github.com/YourFin/binappend v0.0.0-20181105185800-0add4bf0b9ad h1:OUogh+sUEo6yR github.com/YourFin/binappend v0.0.0-20181105185800-0add4bf0b9ad/go.mod h1:QhzJSct0NZ/q7HOtQrw867061u93HYPWa4KTotzdzls= github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d h1:licZJFw2RwpHMqeKTCYkitsPqHNxTmd4SNR5r94FGM8= github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d/go.mod h1:asat636LX7Bqt5lYEZ27JNDcqxfjdBQuJ/MM4CN/Lzo= -github.com/alessio/shellescape v1.4.2 h1:MHPfaU+ddJ0/bYWpgIeUnQUqKrlJ1S7BfEYPM4uEoM0= -github.com/alessio/shellescape v1.4.2/go.mod h1:PZAiSCk0LJaZkiCSkPv8qIobYglO3FPpyFjDCtHLS30= github.com/apparentlymart/go-cidr v1.1.0 h1:2mAhrMoF+nhXqxTzSZMUzDHkLjmIHC+Zzn4tdgBZjnU= github.com/apparentlymart/go-cidr v1.1.0/go.mod h1:EBcsNrHc3zQeuaeCeCtQruQm+n9/YjEn/vI25Lg7Gwc= github.com/areYouLazy/libhosty v1.1.0 h1:kO6UTk9z72cHW28A/V1kKi7C8iKQGqINiVGXp+05Eao= @@ -82,8 +82,8 @@ github.com/cucumber/messages/go/v21 v21.0.1/go.mod h1:zheH/2HS9JLVFukdrsPWoPdmUt github.com/cucumber/messages/go/v22 v22.0.0/go.mod h1:aZipXTKc0JnjCsXrJnuZpWhtay93k7Rn3Dee7iyPJjs= github.com/cyberphone/json-canonicalization v0.0.0-20231217050601-ba74d44ecf5f h1:eHnXnuK47UlSTOQexbzxAZfekVz6i+LKRdj1CU5DPaM= github.com/cyberphone/json-canonicalization v0.0.0-20231217050601-ba74d44ecf5f/go.mod h1:uzvlm1mxhHkdfqitSA92i7Se+S9ksOn3a3qmv/kyOCw= -github.com/danieljoos/wincred v1.2.1 h1:dl9cBrupW8+r5250DYkYxocLeZ1Y4vB1kxgtjxw8GQs= -github.com/danieljoos/wincred v1.2.1/go.mod h1:uGaFL9fDn3OLTvzCGulzE+SzjEe5NGlh5FdCcyfPwps= +github.com/danieljoos/wincred v1.2.2 h1:774zMFJrqaeYCK2W57BgAem/MLi6mtSE47MB6BOJ0i0= +github.com/danieljoos/wincred v1.2.2/go.mod h1:w7w4Utbrz8lqeMbDAK0lkNJUv5sAOkFi7nd/ogr0Uh8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= @@ -178,6 +178,8 @@ github.com/google/gopacket v1.1.19 h1:ves8RnFZPGiFnTS0uPQStjwru6uO6h+nlr9j6fL7kF github.com/google/gopacket v1.1.19/go.mod h1:iJ8V8n6KS+z2U1A8pUwu8bW5SyEMkXJB8Yo/Vo+TKTo= github.com/google/pprof v0.0.0-20240827171923-fa2c70bbbfe5 h1:5iH8iuqE5apketRbSFBy+X1V0o+l+8NF1avt4HWl7cA= github.com/google/pprof v0.0.0-20240827171923-fa2c70bbbfe5/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= +github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= +github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -439,8 +441,8 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0= github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= -github.com/zalando/go-keyring v0.2.5 h1:Bc2HHpjALryKD62ppdEzaFG6VxL6Bc+5v0LYpN8Lba8= -github.com/zalando/go-keyring v0.2.5/go.mod h1:HL4k+OXQfJUWaMnqyuSOc0drfGPX2b51Du6K+MRgZMk= +github.com/zalando/go-keyring v0.2.6 h1:r7Yc3+H+Ux0+M72zacZoItR3UDxeWfKTcabvkI8ua9s= +github.com/zalando/go-keyring v0.2.6/go.mod h1:2TCrxYrbUNYfNS/Kgy/LSrkSQzZ5UPVH85RwfczwvcI= go.mongodb.org/mongo-driver v1.14.0 h1:P98w8egYRjYe3XDjxhYJagTokP/H6HzlsnojRgZRd80= go.mongodb.org/mongo-driver v1.14.0/go.mod h1:Vzb0Mk/pa7e6cWw85R4F/endUC3u0U9jGcNU603k65c= go.mozilla.org/pkcs7 v0.0.0-20210826202110-33d05740a352 h1:CCriYyAfq1Br1aIYettdHZTy8mBTIPo7We18TuO/bak= diff --git a/vendor/github.com/alessio/shellescape/.gitignore b/vendor/al.essio.dev/pkg/shellescape/.gitignore similarity index 92% rename from vendor/github.com/alessio/shellescape/.gitignore rename to vendor/al.essio.dev/pkg/shellescape/.gitignore index 4ba7c2d137..657fca3f9f 100644 --- a/vendor/github.com/alessio/shellescape/.gitignore +++ b/vendor/al.essio.dev/pkg/shellescape/.gitignore @@ -26,3 +26,7 @@ _testmain.go .idea/ escargs + +config.hcl + +.DS_Store diff --git a/vendor/github.com/alessio/shellescape/.golangci.yml b/vendor/al.essio.dev/pkg/shellescape/.golangci.yml similarity index 100% rename from vendor/github.com/alessio/shellescape/.golangci.yml rename to vendor/al.essio.dev/pkg/shellescape/.golangci.yml diff --git a/vendor/github.com/alessio/shellescape/.goreleaser.yml b/vendor/al.essio.dev/pkg/shellescape/.goreleaser.yml similarity index 100% rename from vendor/github.com/alessio/shellescape/.goreleaser.yml rename to vendor/al.essio.dev/pkg/shellescape/.goreleaser.yml diff --git a/vendor/github.com/alessio/shellescape/AUTHORS b/vendor/al.essio.dev/pkg/shellescape/AUTHORS similarity index 100% rename from vendor/github.com/alessio/shellescape/AUTHORS rename to vendor/al.essio.dev/pkg/shellescape/AUTHORS diff --git a/vendor/github.com/alessio/shellescape/CODE_OF_CONDUCT.md b/vendor/al.essio.dev/pkg/shellescape/CODE_OF_CONDUCT.md similarity index 100% rename from vendor/github.com/alessio/shellescape/CODE_OF_CONDUCT.md rename to vendor/al.essio.dev/pkg/shellescape/CODE_OF_CONDUCT.md diff --git a/vendor/github.com/alessio/shellescape/LICENSE b/vendor/al.essio.dev/pkg/shellescape/LICENSE similarity index 100% rename from vendor/github.com/alessio/shellescape/LICENSE rename to vendor/al.essio.dev/pkg/shellescape/LICENSE diff --git a/vendor/al.essio.dev/pkg/shellescape/Makefile b/vendor/al.essio.dev/pkg/shellescape/Makefile new file mode 100644 index 0000000000..f92895c0f0 --- /dev/null +++ b/vendor/al.essio.dev/pkg/shellescape/Makefile @@ -0,0 +1,25 @@ + +#!/usr/bin/make -f + +VERSION := $(shell git describe) + +all: build + +build: + go build -a -v + +install: + go install ./cmd/escargs + +escargs: build + go build -v \ + -ldflags="-X 'main.version=$(VERSION)'" \ + ./cmd/escargs + +clean: + rm -rfv escargs + +uninstall: + rm -v $(shell go env GOPATH)/bin/escargs + +.PHONY: build clean install uninstall diff --git a/vendor/github.com/alessio/shellescape/README.md b/vendor/al.essio.dev/pkg/shellescape/README.md similarity index 95% rename from vendor/github.com/alessio/shellescape/README.md rename to vendor/al.essio.dev/pkg/shellescape/README.md index 910bb253b9..f83dd5b16c 100644 --- a/vendor/github.com/alessio/shellescape/README.md +++ b/vendor/al.essio.dev/pkg/shellescape/README.md @@ -48,14 +48,14 @@ import ( "fmt" "os" - "gopkg.in/alessio/shellescape.v1" + "al.essio.dev/pkg/shellescape" ) func main() { fmt.Printf("ls -l %s\n", shellescape.Quote(os.Args[1])) } ``` -_[See in Go Playground](https://play.golang.org/p/HJ_CXgSrmp)_ +_[See in Go Playground](https://go.dev/play/p/GeguukpSUTk)_ ## The escargs utility __escargs__ reads lines from the standard input and prints shell-escaped versions. Unlinke __xargs__, blank lines on the standard input are not discarded. diff --git a/vendor/github.com/alessio/shellescape/shellescape.go b/vendor/al.essio.dev/pkg/shellescape/shellescape.go similarity index 96% rename from vendor/github.com/alessio/shellescape/shellescape.go rename to vendor/al.essio.dev/pkg/shellescape/shellescape.go index dc34a556ae..f3d0d9c0a2 100644 --- a/vendor/github.com/alessio/shellescape/shellescape.go +++ b/vendor/al.essio.dev/pkg/shellescape/shellescape.go @@ -6,7 +6,7 @@ POSIX shells. The original Python package which this work was inspired by can be found at https://pypi.python.org/pypi/shellescape. */ -package shellescape // "import gopkg.in/alessio/shellescape.v1" +package shellescape // "import al.essio.dev/pkg/shellescape" /* The functionality provided by shellescape.Quote could be helpful diff --git a/vendor/github.com/danieljoos/wincred/sys_unsupported.go b/vendor/github.com/danieljoos/wincred/sys_unsupported.go index b47bccf8a0..746639ad82 100644 --- a/vendor/github.com/danieljoos/wincred/sys_unsupported.go +++ b/vendor/github.com/danieljoos/wincred/sys_unsupported.go @@ -1,3 +1,4 @@ +//go:build !windows // +build !windows package wincred @@ -17,6 +18,7 @@ const ( sysERROR_NOT_FOUND = syscall.Errno(1) sysERROR_INVALID_PARAMETER = syscall.Errno(1) + sysERROR_BAD_USERNAME = syscall.Errno(1) ) func sysCredRead(...interface{}) (*Credential, error) { diff --git a/vendor/github.com/zalando/go-keyring/keyring.go b/vendor/github.com/zalando/go-keyring/keyring.go index 75ab6d2ea7..921b51594b 100644 --- a/vendor/github.com/zalando/go-keyring/keyring.go +++ b/vendor/github.com/zalando/go-keyring/keyring.go @@ -25,6 +25,8 @@ type Keyring interface { Get(service, user string) (string, error) // Delete secret from keyring. Delete(service, user string) error + // DeleteAll deletes all secrets for a given service + DeleteAll(service string) error } // Set password in keyring for user. @@ -41,3 +43,8 @@ func Get(service, user string) (string, error) { func Delete(service, user string) error { return provider.Delete(service, user) } + +// DeleteAll deletes all secrets for a given service +func DeleteAll(service string) error { + return provider.DeleteAll(service) +} diff --git a/vendor/github.com/zalando/go-keyring/keyring_darwin.go b/vendor/github.com/zalando/go-keyring/keyring_darwin.go index 26e8aa15dd..63104b07eb 100644 --- a/vendor/github.com/zalando/go-keyring/keyring_darwin.go +++ b/vendor/github.com/zalando/go-keyring/keyring_darwin.go @@ -22,7 +22,7 @@ import ( "os/exec" "strings" - "github.com/alessio/shellescape" + "al.essio.dev/pkg/shellescape" ) const ( @@ -113,6 +113,28 @@ func (k macOSXKeychain) Delete(service, username string) error { return err } +// DeleteAll deletes all secrets for a given service +func (k macOSXKeychain) DeleteAll(service string) error { + // if service is empty, do nothing otherwise it might accidentally delete all secrets + if service == "" { + return ErrNotFound + } + // Delete each secret in a while loop until there is no more left + // under the service + for { + out, err := exec.Command( + execPathKeychain, + "delete-generic-password", + "-s", service).CombinedOutput() + if strings.Contains(string(out), "could not be found") { + return nil + } else if err != nil { + return err + } + } + +} + func init() { provider = macOSXKeychain{} } diff --git a/vendor/github.com/zalando/go-keyring/keyring_fallback.go b/vendor/github.com/zalando/go-keyring/keyring_fallback.go index a2de1a250b..75c61ff1cc 100644 --- a/vendor/github.com/zalando/go-keyring/keyring_fallback.go +++ b/vendor/github.com/zalando/go-keyring/keyring_fallback.go @@ -21,3 +21,7 @@ func (fallbackServiceProvider) Get(service, user string) (string, error) { func (fallbackServiceProvider) Delete(service, user string) error { return ErrUnsupportedPlatform } + +func (fallbackServiceProvider) DeleteAll(service string) error { + return ErrUnsupportedPlatform +} diff --git a/vendor/github.com/zalando/go-keyring/keyring_mock.go b/vendor/github.com/zalando/go-keyring/keyring_mock.go index 0e514eadeb..e46b2e538e 100644 --- a/vendor/github.com/zalando/go-keyring/keyring_mock.go +++ b/vendor/github.com/zalando/go-keyring/keyring_mock.go @@ -50,6 +50,15 @@ func (m *mockProvider) Delete(service, user string) error { return ErrNotFound } +// DeleteAll deletes all secrets for a given service +func (m *mockProvider) DeleteAll(service string) error { + if m.mockError != nil { + return m.mockError + } + delete(m.mockStore, service) + return nil +} + // MockInit sets the provider to a mocked memory store func MockInit() { provider = &mockProvider{} diff --git a/vendor/github.com/zalando/go-keyring/keyring_unix.go b/vendor/github.com/zalando/go-keyring/keyring_unix.go index 523f6a3b7f..31f2acc439 100644 --- a/vendor/github.com/zalando/go-keyring/keyring_unix.go +++ b/vendor/github.com/zalando/go-keyring/keyring_unix.go @@ -76,6 +76,31 @@ func (s secretServiceProvider) findItem(svc *ss.SecretService, service, user str return results[0], nil } +// findServiceItems looksup all items by service. +func (s secretServiceProvider) findServiceItems(svc *ss.SecretService, service string) ([]dbus.ObjectPath, error) { + collection := svc.GetLoginCollection() + + search := map[string]string{ + "service": service, + } + + err := svc.Unlock(collection.Path()) + if err != nil { + return []dbus.ObjectPath{}, err + } + + results, err := svc.SearchItems(collection, search) + if err != nil { + return []dbus.ObjectPath{}, err + } + + if len(results) == 0 { + return []dbus.ObjectPath{}, ErrNotFound + } + + return results, nil +} + // Get gets a secret from the keyring given a service name and a user. func (s secretServiceProvider) Get(service, user string) (string, error) { svc, err := ss.NewSecretService() @@ -124,6 +149,34 @@ func (s secretServiceProvider) Delete(service, user string) error { return svc.Delete(item) } +// DeleteAll deletes all secrets for a given service +func (s secretServiceProvider) DeleteAll(service string) error { + // if service is empty, do nothing otherwise it might accidentally delete all secrets + if service == "" { + return ErrNotFound + } + + svc, err := ss.NewSecretService() + if err != nil { + return err + } + // find all items for the service + items, err := s.findServiceItems(svc, service) + if err != nil { + if err == ErrNotFound { + return nil + } + return err + } + for _, item := range items { + err = svc.Delete(item) + if err != nil { + return err + } + } + return nil +} + func init() { provider = secretServiceProvider{} } diff --git a/vendor/github.com/zalando/go-keyring/keyring_windows.go b/vendor/github.com/zalando/go-keyring/keyring_windows.go index 738dac4b20..8519221ce0 100644 --- a/vendor/github.com/zalando/go-keyring/keyring_windows.go +++ b/vendor/github.com/zalando/go-keyring/keyring_windows.go @@ -1,6 +1,7 @@ package keyring import ( + "strings" "syscall" "github.com/danieljoos/wincred" @@ -59,6 +60,39 @@ func (k windowsKeychain) Delete(service, username string) error { return cred.Delete() } +func (k windowsKeychain) DeleteAll(service string) error { + // if service is empty, do nothing otherwise it might accidentally delete all secrets + if service == "" { + return ErrNotFound + } + + creds, err := wincred.List() + if err != nil { + return err + } + + prefix := k.credName(service, "") + deletedCount := 0 + + for _, cred := range creds { + if strings.HasPrefix(cred.TargetName, prefix) { + genericCred, err := wincred.GetGenericCredential(cred.TargetName) + if err != nil { + if err != syscall.ERROR_NOT_FOUND { + return err + } + } else { + err := genericCred.Delete() + if err != nil { + return err + } + deletedCount++ + } + } + } + return nil +} + // credName combines service and username to a single string. func (k windowsKeychain) credName(service, username string) string { return service + ":" + username diff --git a/vendor/modules.txt b/vendor/modules.txt index 474921a698..f68406656a 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,3 +1,6 @@ +# al.essio.dev/pkg/shellescape v1.5.1 +## explicit; go 1.18 +al.essio.dev/pkg/shellescape # github.com/AlecAivazis/survey/v2 v2.3.7 ## explicit; go 1.13 github.com/AlecAivazis/survey/v2 @@ -56,9 +59,6 @@ github.com/YourFin/binappend # github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d ## explicit github.com/acarl005/stripansi -# github.com/alessio/shellescape v1.4.2 -## explicit; go 1.14 -github.com/alessio/shellescape # github.com/apparentlymart/go-cidr v1.1.0 ## explicit github.com/apparentlymart/go-cidr/cidr @@ -252,7 +252,7 @@ github.com/cucumber/messages/go/v21 # github.com/cyberphone/json-canonicalization v0.0.0-20231217050601-ba74d44ecf5f ## explicit github.com/cyberphone/json-canonicalization/go/src/webpki.org/jsoncanonicalizer -# github.com/danieljoos/wincred v1.2.1 +# github.com/danieljoos/wincred v1.2.2 ## explicit; go 1.18 github.com/danieljoos/wincred # github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc @@ -782,7 +782,7 @@ github.com/xi2/xz # github.com/yusufpapurcu/wmi v1.2.4 ## explicit; go 1.16 github.com/yusufpapurcu/wmi -# github.com/zalando/go-keyring v0.2.5 +# github.com/zalando/go-keyring v0.2.6 ## explicit; go 1.18 github.com/zalando/go-keyring github.com/zalando/go-keyring/secret_service