diff --git a/api/client.go b/api/client.go index e5c48e1321..c9e1661e84 100644 --- a/api/client.go +++ b/api/client.go @@ -19,12 +19,12 @@ import ( "time" "unicode" - "github.com/hashicorp/boundary/sdk/parseutil" "github.com/hashicorp/boundary/sdk/recovery" cleanhttp "github.com/hashicorp/go-cleanhttp" wrapping "github.com/hashicorp/go-kms-wrapping" retryablehttp "github.com/hashicorp/go-retryablehttp" rootcerts "github.com/hashicorp/go-rootcerts" + "github.com/hashicorp/shared-secure-libs/parseutil" "golang.org/x/time/rate" ) diff --git a/api/go.mod b/api/go.mod index e4bf9a39ba..539f470bee 100644 --- a/api/go.mod +++ b/api/go.mod @@ -11,6 +11,7 @@ require ( github.com/hashicorp/go-kms-wrapping v0.6.1 github.com/hashicorp/go-retryablehttp v0.6.8 github.com/hashicorp/go-rootcerts v1.0.2 + github.com/hashicorp/shared-secure-libs/parseutil v0.1.0 github.com/stretchr/testify v1.7.0 golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e google.golang.org/grpc v1.35.0 diff --git a/api/go.sum b/api/go.sum index 8b5a4aaa05..f21ae7c390 100644 --- a/api/go.sum +++ b/api/go.sum @@ -225,7 +225,6 @@ github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE= github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= -github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= @@ -275,7 +274,12 @@ github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= +github.com/hashicorp/shared-secure-libs v0.0.4 h1:aRm7/wnJ70z5hSX8cLdyupwI8QNKklfViRstg/ZtUdw= github.com/hashicorp/shared-secure-libs v0.0.4/go.mod h1:xhtA0FH6AYYFOy0sir7u0O0zzdLi7ofU6oWxy+gjnuc= +github.com/hashicorp/shared-secure-libs/parseutil v0.1.0 h1:R5IyN4zkqbxkPLhR7WSvF7Jhoc7AtlvlVK8QZKs8N9c= +github.com/hashicorp/shared-secure-libs/parseutil v0.1.0/go.mod h1:VeS21zHAo7PicmcAptMd/ZdckVlHtdI4xA0GOOpssVI= +github.com/hashicorp/shared-secure-libs/strutil v0.1.0 h1:mzQjO/tqNZAmdcZ5gecvzs7z/tAKy2Ry1SO6j7IxjQU= +github.com/hashicorp/shared-secure-libs/strutil v0.1.0/go.mod h1:YsAf1vJYtE4AhRdGD+X/96cFK7j8oosgnYLilKGzSTw= github.com/hashicorp/vault/api v1.0.5-0.20200514164214-89b1987e38c2/go.mod h1:P8A7gn1a6j/7qQ4zOaWI6FC/Q9jQWEBRTOwZH33tC9o= github.com/hashicorp/vault/api v1.0.5-0.20200519221902-385fac77e20f/go.mod h1:euTFbi2YJgwcju3imEt919lhJKF68nN1cQPq3aA+kBE= github.com/hashicorp/vault/api v1.0.5-0.20200805123347-1ef507638af6/go.mod h1:R3Umvhlxi2TN7Ex2hzOowyeNb+SfbVWI973N+ctaFMk= diff --git a/go.mod b/go.mod index 79165a27ff..e671d220ab 100644 --- a/go.mod +++ b/go.mod @@ -22,11 +22,10 @@ require ( github.com/hashicorp/cap v0.1.1 github.com/hashicorp/dawdle v0.4.0 github.com/hashicorp/dbassert v0.0.0-20200930125617-6218396928df - github.com/hashicorp/errwrap v1.1.0 github.com/hashicorp/eventlogger v0.0.0-20210523164657-c216620e1746 github.com/hashicorp/go-bexpr v0.1.8 github.com/hashicorp/go-cleanhttp v0.5.2 - github.com/hashicorp/go-hclog v0.16.1 + github.com/hashicorp/go-hclog v0.16.2 github.com/hashicorp/go-kms-wrapping v0.6.2 github.com/hashicorp/go-multierror v1.1.1 github.com/hashicorp/go-retryablehttp v0.7.0 @@ -34,8 +33,14 @@ require ( github.com/hashicorp/go-uuid v1.0.2 github.com/hashicorp/hcl v1.0.0 github.com/hashicorp/shared-secure-libs v0.0.7 + github.com/hashicorp/shared-secure-libs/base62 v0.1.0 + github.com/hashicorp/shared-secure-libs/logging v0.1.0 + github.com/hashicorp/shared-secure-libs/mlock v0.1.0 + github.com/hashicorp/shared-secure-libs/parseutil v0.1.0 + github.com/hashicorp/shared-secure-libs/password v0.1.0 + github.com/hashicorp/shared-secure-libs/strutil v0.1.0 github.com/hashicorp/vault/api v1.1.0 - github.com/hashicorp/vault/sdk v0.2.0 + github.com/hashicorp/vault/sdk v0.2.0 // indirect github.com/iancoleman/strcase v0.1.3 github.com/jefferai/keyring v1.1.7-0.20210105022822-8749b3d9ce79 github.com/jinzhu/gorm v1.9.16 @@ -60,8 +65,8 @@ require ( github.com/stretchr/testify v1.7.0 github.com/zalando/go-keyring v0.1.1 go.uber.org/atomic v1.8.0 - golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a - golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 + golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 + golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c golang.org/x/term v0.0.0-20210503060354-a79de5458b56 golang.org/x/tools v0.1.3 google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6 diff --git a/go.sum b/go.sum index fa510a992c..b9ecfab9e6 100644 --- a/go.sum +++ b/go.sum @@ -468,8 +468,9 @@ github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrj github.com/hashicorp/go-hclog v0.12.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= github.com/hashicorp/go-hclog v0.13.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= github.com/hashicorp/go-hclog v0.14.1/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= -github.com/hashicorp/go-hclog v0.16.1 h1:IVQwpTGNRRIHafnTs2dQLIk4ENtneRIEEJWOVDqz99o= github.com/hashicorp/go-hclog v0.16.1/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= +github.com/hashicorp/go-hclog v0.16.2 h1:K4ev2ib4LdQETX5cSZBG0DVLk1jwGqSPXBjdah3veNs= +github.com/hashicorp/go-hclog v0.16.2/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-immutable-radix v1.1.0 h1:vN9wG1D6KG6YHRTWr8512cxGOVgTMEfgEdSj/hr8MPc= github.com/hashicorp/go-immutable-radix v1.1.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= @@ -521,6 +522,18 @@ github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/J github.com/hashicorp/shared-secure-libs v0.0.4/go.mod h1:xhtA0FH6AYYFOy0sir7u0O0zzdLi7ofU6oWxy+gjnuc= github.com/hashicorp/shared-secure-libs v0.0.7 h1:vdoIg+ahLPlwTELM7eA4OWws54Hf0en2QaFKsY8NqeM= github.com/hashicorp/shared-secure-libs v0.0.7/go.mod h1:PH51kNtHA6kYV5Z8E3TOJM634iyp7IIxAMfLh0Dp35o= +github.com/hashicorp/shared-secure-libs/base62 v0.1.0 h1:MZpHgL9yms0DVhYJ+cVpQ5tp8IbyoVufyMvCi6stJnU= +github.com/hashicorp/shared-secure-libs/base62 v0.1.0/go.mod h1:yQ1EUBxJZ654Ivhjmr1pq2wt6YCoeTCuZgX2Ysc4IMg= +github.com/hashicorp/shared-secure-libs/logging v0.1.0 h1:a2FchfFIKU+jo0xWIjBGSA8n80af16CbvQAAcOlMejU= +github.com/hashicorp/shared-secure-libs/logging v0.1.0/go.mod h1:ogsWOAtBzEu0YYDWKgdahFkmjnu8cKzQ+ejg5Ibm8L8= +github.com/hashicorp/shared-secure-libs/mlock v0.1.0 h1:7xw1ZVNW41PGRiRysdA8SBaRN2bNE+Bf+Uce/+JWsu4= +github.com/hashicorp/shared-secure-libs/mlock v0.1.0/go.mod h1:lOpv9YZPgTDtfSdhetd25YVO3uxRrD8KD0erct1PdP0= +github.com/hashicorp/shared-secure-libs/parseutil v0.1.0 h1:R5IyN4zkqbxkPLhR7WSvF7Jhoc7AtlvlVK8QZKs8N9c= +github.com/hashicorp/shared-secure-libs/parseutil v0.1.0/go.mod h1:VeS21zHAo7PicmcAptMd/ZdckVlHtdI4xA0GOOpssVI= +github.com/hashicorp/shared-secure-libs/password v0.1.0 h1:Q8SHs8TKPsBwgyoPz72TeND0DCXe6bxnj2T5lYN3Fvs= +github.com/hashicorp/shared-secure-libs/password v0.1.0/go.mod h1:sJoCP2kkdw8CXwlftfj7NRkbXYvEapn3ZiL4LZfDVbI= +github.com/hashicorp/shared-secure-libs/strutil v0.1.0 h1:mzQjO/tqNZAmdcZ5gecvzs7z/tAKy2Ry1SO6j7IxjQU= +github.com/hashicorp/shared-secure-libs/strutil v0.1.0/go.mod h1:YsAf1vJYtE4AhRdGD+X/96cFK7j8oosgnYLilKGzSTw= github.com/hashicorp/vault/api v1.0.5-0.20200514164214-89b1987e38c2/go.mod h1:P8A7gn1a6j/7qQ4zOaWI6FC/Q9jQWEBRTOwZH33tC9o= github.com/hashicorp/vault/api v1.0.5-0.20200519221902-385fac77e20f/go.mod h1:euTFbi2YJgwcju3imEt919lhJKF68nN1cQPq3aA+kBE= github.com/hashicorp/vault/api v1.0.5-0.20200805123347-1ef507638af6/go.mod h1:R3Umvhlxi2TN7Ex2hzOowyeNb+SfbVWI973N+ctaFMk= @@ -1032,8 +1045,9 @@ golang.org/x/crypto v0.0.0-20200604202706-70a84ac30bf9/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a h1:kr2P4QFmQr29mSLA43kwrOcgcReGTfbE9N577tCTuBc= golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8= +golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 h1:/UOmuWzQfxxo9UtlXMwuQU8CMgg1eZXqTRwkSQJWKOI= +golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= 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-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -1202,8 +1216,9 @@ golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 h1:SrN+KX8Art/Sf4HNj6Zcz06G7VEz+7w9tdXTPOZ7+l4= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210503060354-a79de5458b56 h1:b8jxX3zqjpqb2LklXPzKSGJhzyxCOZSz8ncv8Nv+y7w= golang.org/x/term v0.0.0-20210503060354-a79de5458b56/go.mod h1:tfny5GFUkzUvx4ps4ajbZsCe5lw1metzhBm9T3x7oIY= diff --git a/internal/api/genapi/parse.go b/internal/api/genapi/parse.go index c1a4f0d4c4..c4d9f37544 100644 --- a/internal/api/genapi/parse.go +++ b/internal/api/genapi/parse.go @@ -11,7 +11,7 @@ import ( "google.golang.org/protobuf/types/known/wrapperspb" "github.com/hashicorp/boundary/internal/gen/controller/protooptions" - "github.com/hashicorp/boundary/sdk/strutil" + "github.com/hashicorp/shared-secure-libs/strutil" "github.com/iancoleman/strcase" ) diff --git a/internal/auth/authorized_actions.go b/internal/auth/authorized_actions.go index 3ffe8ea2cb..4a391c8bf9 100644 --- a/internal/auth/authorized_actions.go +++ b/internal/auth/authorized_actions.go @@ -6,7 +6,7 @@ import ( "github.com/hashicorp/boundary/internal/perms" "github.com/hashicorp/boundary/internal/types/action" "github.com/hashicorp/boundary/internal/types/resource" - "github.com/hashicorp/boundary/sdk/strutil" + "github.com/hashicorp/shared-secure-libs/strutil" "google.golang.org/protobuf/types/known/structpb" ) diff --git a/internal/auth/oidc/repository_auth_method_update.go b/internal/auth/oidc/repository_auth_method_update.go index b514a55d50..80378f3362 100644 --- a/internal/auth/oidc/repository_auth_method_update.go +++ b/internal/auth/oidc/repository_auth_method_update.go @@ -11,8 +11,8 @@ import ( "github.com/hashicorp/boundary/internal/errors" "github.com/hashicorp/boundary/internal/kms" "github.com/hashicorp/boundary/internal/oplog" - "github.com/hashicorp/boundary/sdk/strutil" "github.com/hashicorp/go-multierror" + "github.com/hashicorp/shared-secure-libs/strutil" ) const ( diff --git a/internal/auth/oidc/service_callback_test.go b/internal/auth/oidc/service_callback_test.go index 8be589e1b7..8da27035a4 100644 --- a/internal/auth/oidc/service_callback_test.go +++ b/internal/auth/oidc/service_callback_test.go @@ -17,7 +17,7 @@ import ( "github.com/hashicorp/boundary/internal/errors" "github.com/hashicorp/boundary/internal/iam" iamStore "github.com/hashicorp/boundary/internal/iam/store" - "github.com/hashicorp/boundary/sdk/strutil" + "github.com/hashicorp/shared-secure-libs/strutil" "github.com/hashicorp/boundary/internal/kms" "github.com/hashicorp/boundary/internal/oplog" diff --git a/internal/authtoken/authtoken.go b/internal/authtoken/authtoken.go index dd7013f060..a104534be5 100644 --- a/internal/authtoken/authtoken.go +++ b/internal/authtoken/authtoken.go @@ -14,7 +14,7 @@ import ( "github.com/hashicorp/boundary/internal/kms" wrapping "github.com/hashicorp/go-kms-wrapping" "github.com/hashicorp/go-kms-wrapping/structwrapping" - "github.com/hashicorp/vault/sdk/helper/base62" + "github.com/hashicorp/shared-secure-libs/base62" "github.com/mr-tron/base58" "google.golang.org/protobuf/proto" ) diff --git a/internal/cmd/base/event_flags_test.go b/internal/cmd/base/event_flags_test.go index 850e4d652e..45e4f9d880 100644 --- a/internal/cmd/base/event_flags_test.go +++ b/internal/cmd/base/event_flags_test.go @@ -56,5 +56,4 @@ func TestEventFlags_Validate(t *testing.T) { require.NoError(err) }) } - } diff --git a/internal/cmd/base/initial_resources.go b/internal/cmd/base/initial_resources.go index 4959586bc3..85fc646d10 100644 --- a/internal/cmd/base/initial_resources.go +++ b/internal/cmd/base/initial_resources.go @@ -13,7 +13,7 @@ import ( "github.com/hashicorp/boundary/internal/kms" "github.com/hashicorp/boundary/internal/target" "github.com/hashicorp/boundary/internal/types/scope" - "github.com/hashicorp/vault/sdk/helper/base62" + "github.com/hashicorp/shared-secure-libs/base62" ) func (b *Server) CreateInitialLoginRole(ctx context.Context) (*iam.Role, error) { diff --git a/internal/cmd/base/logging.go b/internal/cmd/base/logging.go index df400e676d..5c987fe07e 100644 --- a/internal/cmd/base/logging.go +++ b/internal/cmd/base/logging.go @@ -6,7 +6,7 @@ import ( "strings" "github.com/hashicorp/go-hclog" - "github.com/hashicorp/vault/sdk/helper/logging" + "github.com/hashicorp/shared-secure-libs/logging" ) func ProcessLogLevelAndFormat(flagLogLevel, flagLogFormat, configLogLevel, configLogFormat string) (hclog.Level, logging.LogFormat, error) { diff --git a/internal/cmd/base/servers.go b/internal/cmd/base/servers.go index aacd737165..3e376c0ee9 100644 --- a/internal/cmd/base/servers.go +++ b/internal/cmd/base/servers.go @@ -25,18 +25,16 @@ import ( "github.com/hashicorp/boundary/internal/kms" "github.com/hashicorp/boundary/internal/observability/event" "github.com/hashicorp/boundary/internal/types/scope" - "github.com/hashicorp/boundary/sdk/strutil" "github.com/hashicorp/boundary/version" - "github.com/hashicorp/errwrap" "github.com/hashicorp/go-hclog" wrapping "github.com/hashicorp/go-kms-wrapping" "github.com/hashicorp/go-multierror" "github.com/hashicorp/shared-secure-libs/configutil" "github.com/hashicorp/shared-secure-libs/gatedwriter" + "github.com/hashicorp/shared-secure-libs/logging" + "github.com/hashicorp/shared-secure-libs/mlock" "github.com/hashicorp/shared-secure-libs/reloadutil" - "github.com/hashicorp/vault/sdk/helper/logging" - "github.com/hashicorp/vault/sdk/helper/mlock" - "github.com/hashicorp/vault/sdk/logical" + "github.com/hashicorp/shared-secure-libs/strutil" "github.com/jinzhu/gorm" "github.com/mitchellh/cli" "google.golang.org/grpc/grpclog" @@ -465,10 +463,8 @@ func (b *Server) SetupKMSes(ui cli.Ui, config *config.Config) error { wrapper, wrapperConfigError := configutil.ConfigureWrapper(kms, &b.InfoKeys, &b.Info, kmsLogger) kms.Purpose = origPurpose if wrapperConfigError != nil { - if !errwrap.ContainsType(wrapperConfigError, new(logical.KeyNotFoundError)) { - return fmt.Errorf( - "Error parsing KMS configuration: %s", wrapperConfigError) - } + return fmt.Errorf( + "Error parsing KMS configuration: %s", wrapperConfigError) } if wrapper == nil { return fmt.Errorf( diff --git a/internal/cmd/commands/accountscmd/accounts.gen.go b/internal/cmd/commands/accountscmd/accounts.gen.go index c7e1a1269b..d0ed51ddfd 100644 --- a/internal/cmd/commands/accountscmd/accounts.gen.go +++ b/internal/cmd/commands/accountscmd/accounts.gen.go @@ -10,7 +10,7 @@ import ( "github.com/hashicorp/boundary/api/accounts" "github.com/hashicorp/boundary/internal/cmd/base" "github.com/hashicorp/boundary/internal/cmd/common" - "github.com/hashicorp/boundary/sdk/strutil" + "github.com/hashicorp/shared-secure-libs/strutil" "github.com/mitchellh/cli" "github.com/posener/complete" ) diff --git a/internal/cmd/commands/accountscmd/funcs.go b/internal/cmd/commands/accountscmd/funcs.go index ea53057d2b..c2b58bb7fb 100644 --- a/internal/cmd/commands/accountscmd/funcs.go +++ b/internal/cmd/commands/accountscmd/funcs.go @@ -9,8 +9,8 @@ import ( "github.com/hashicorp/boundary/api" "github.com/hashicorp/boundary/api/accounts" "github.com/hashicorp/boundary/internal/cmd/base" - "github.com/hashicorp/boundary/sdk/strutil" - "github.com/hashicorp/vault/sdk/helper/password" + "github.com/hashicorp/shared-secure-libs/password" + "github.com/hashicorp/shared-secure-libs/strutil" ) func init() { diff --git a/internal/cmd/commands/accountscmd/oidc_accounts.gen.go b/internal/cmd/commands/accountscmd/oidc_accounts.gen.go index dbb6b95fd6..5f76b18e5e 100644 --- a/internal/cmd/commands/accountscmd/oidc_accounts.gen.go +++ b/internal/cmd/commands/accountscmd/oidc_accounts.gen.go @@ -9,7 +9,7 @@ import ( "github.com/hashicorp/boundary/api/accounts" "github.com/hashicorp/boundary/internal/cmd/base" "github.com/hashicorp/boundary/internal/cmd/common" - "github.com/hashicorp/boundary/sdk/strutil" + "github.com/hashicorp/shared-secure-libs/strutil" "github.com/mitchellh/cli" "github.com/posener/complete" ) diff --git a/internal/cmd/commands/accountscmd/password_accounts.gen.go b/internal/cmd/commands/accountscmd/password_accounts.gen.go index 3b71d47a96..3c997da1e0 100644 --- a/internal/cmd/commands/accountscmd/password_accounts.gen.go +++ b/internal/cmd/commands/accountscmd/password_accounts.gen.go @@ -9,7 +9,7 @@ import ( "github.com/hashicorp/boundary/api/accounts" "github.com/hashicorp/boundary/internal/cmd/base" "github.com/hashicorp/boundary/internal/cmd/common" - "github.com/hashicorp/boundary/sdk/strutil" + "github.com/hashicorp/shared-secure-libs/strutil" "github.com/mitchellh/cli" "github.com/posener/complete" ) diff --git a/internal/cmd/commands/accountscmd/password_funcs.go b/internal/cmd/commands/accountscmd/password_funcs.go index 521c66f955..20251b729e 100644 --- a/internal/cmd/commands/accountscmd/password_funcs.go +++ b/internal/cmd/commands/accountscmd/password_funcs.go @@ -7,8 +7,8 @@ import ( "github.com/hashicorp/boundary/api/accounts" "github.com/hashicorp/boundary/internal/cmd/base" - "github.com/hashicorp/boundary/sdk/strutil" - "github.com/hashicorp/vault/sdk/helper/password" + "github.com/hashicorp/shared-secure-libs/password" + "github.com/hashicorp/shared-secure-libs/strutil" ) func init() { diff --git a/internal/cmd/commands/authenticate/password.go b/internal/cmd/commands/authenticate/password.go index 4af7f36eb2..e4c0258875 100644 --- a/internal/cmd/commands/authenticate/password.go +++ b/internal/cmd/commands/authenticate/password.go @@ -9,7 +9,7 @@ import ( "github.com/hashicorp/boundary/api" "github.com/hashicorp/boundary/api/authmethods" "github.com/hashicorp/boundary/internal/cmd/base" - "github.com/hashicorp/vault/sdk/helper/password" + "github.com/hashicorp/shared-secure-libs/password" "github.com/mitchellh/cli" "github.com/mitchellh/go-wordwrap" "github.com/posener/complete" diff --git a/internal/cmd/commands/authmethodscmd/authmethods.gen.go b/internal/cmd/commands/authmethodscmd/authmethods.gen.go index bac8cbf27c..02c06e4326 100644 --- a/internal/cmd/commands/authmethodscmd/authmethods.gen.go +++ b/internal/cmd/commands/authmethodscmd/authmethods.gen.go @@ -10,7 +10,7 @@ import ( "github.com/hashicorp/boundary/api/authmethods" "github.com/hashicorp/boundary/internal/cmd/base" "github.com/hashicorp/boundary/internal/cmd/common" - "github.com/hashicorp/boundary/sdk/strutil" + "github.com/hashicorp/shared-secure-libs/strutil" "github.com/mitchellh/cli" "github.com/posener/complete" ) diff --git a/internal/cmd/commands/authmethodscmd/oidc_authmethods.gen.go b/internal/cmd/commands/authmethodscmd/oidc_authmethods.gen.go index 5e9a31fcba..1ca1d5df8c 100644 --- a/internal/cmd/commands/authmethodscmd/oidc_authmethods.gen.go +++ b/internal/cmd/commands/authmethodscmd/oidc_authmethods.gen.go @@ -9,7 +9,7 @@ import ( "github.com/hashicorp/boundary/api/authmethods" "github.com/hashicorp/boundary/internal/cmd/base" "github.com/hashicorp/boundary/internal/cmd/common" - "github.com/hashicorp/boundary/sdk/strutil" + "github.com/hashicorp/shared-secure-libs/strutil" "github.com/mitchellh/cli" "github.com/posener/complete" ) diff --git a/internal/cmd/commands/authmethodscmd/password_authmethods.gen.go b/internal/cmd/commands/authmethodscmd/password_authmethods.gen.go index 9c8b78e160..353d094bc1 100644 --- a/internal/cmd/commands/authmethodscmd/password_authmethods.gen.go +++ b/internal/cmd/commands/authmethodscmd/password_authmethods.gen.go @@ -9,7 +9,7 @@ import ( "github.com/hashicorp/boundary/api/authmethods" "github.com/hashicorp/boundary/internal/cmd/base" "github.com/hashicorp/boundary/internal/cmd/common" - "github.com/hashicorp/boundary/sdk/strutil" + "github.com/hashicorp/shared-secure-libs/strutil" "github.com/mitchellh/cli" "github.com/posener/complete" ) diff --git a/internal/cmd/commands/authtokenscmd/authtokens.gen.go b/internal/cmd/commands/authtokenscmd/authtokens.gen.go index 09dc136294..213c90554a 100644 --- a/internal/cmd/commands/authtokenscmd/authtokens.gen.go +++ b/internal/cmd/commands/authtokenscmd/authtokens.gen.go @@ -10,7 +10,7 @@ import ( "github.com/hashicorp/boundary/api/authtokens" "github.com/hashicorp/boundary/internal/cmd/base" "github.com/hashicorp/boundary/internal/cmd/common" - "github.com/hashicorp/boundary/sdk/strutil" + "github.com/hashicorp/shared-secure-libs/strutil" "github.com/mitchellh/cli" "github.com/posener/complete" ) diff --git a/internal/cmd/commands/authtokenscmd/funcs.go b/internal/cmd/commands/authtokenscmd/funcs.go index cba50379b8..3cc5085d07 100644 --- a/internal/cmd/commands/authtokenscmd/funcs.go +++ b/internal/cmd/commands/authtokenscmd/funcs.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/boundary/api" "github.com/hashicorp/boundary/api/authtokens" "github.com/hashicorp/boundary/internal/cmd/base" - "github.com/hashicorp/boundary/sdk/strutil" + "github.com/hashicorp/shared-secure-libs/strutil" ) const selfFlag = "self" diff --git a/internal/cmd/commands/connect/connect.go b/internal/cmd/commands/connect/connect.go index 5d9c0a9c89..8422f5515c 100644 --- a/internal/cmd/commands/connect/connect.go +++ b/internal/cmd/commands/connect/connect.go @@ -26,7 +26,7 @@ import ( targetspb "github.com/hashicorp/boundary/internal/gen/controller/api/resources/targets" "github.com/hashicorp/boundary/internal/proxy" "github.com/hashicorp/go-cleanhttp" - "github.com/hashicorp/vault/sdk/helper/base62" + "github.com/hashicorp/shared-secure-libs/base62" "github.com/mitchellh/cli" "github.com/mr-tron/base58" "github.com/posener/complete" diff --git a/internal/cmd/commands/credentiallibrariescmd/credentiallibraries.gen.go b/internal/cmd/commands/credentiallibrariescmd/credentiallibraries.gen.go index ed0f4f5b41..f04ea87877 100644 --- a/internal/cmd/commands/credentiallibrariescmd/credentiallibraries.gen.go +++ b/internal/cmd/commands/credentiallibrariescmd/credentiallibraries.gen.go @@ -10,7 +10,7 @@ import ( "github.com/hashicorp/boundary/api/credentiallibraries" "github.com/hashicorp/boundary/internal/cmd/base" "github.com/hashicorp/boundary/internal/cmd/common" - "github.com/hashicorp/boundary/sdk/strutil" + "github.com/hashicorp/shared-secure-libs/strutil" "github.com/mitchellh/cli" "github.com/posener/complete" ) diff --git a/internal/cmd/commands/credentiallibrariescmd/vault_credentiallibraries.gen.go b/internal/cmd/commands/credentiallibrariescmd/vault_credentiallibraries.gen.go index c87725a88a..46effd8031 100644 --- a/internal/cmd/commands/credentiallibrariescmd/vault_credentiallibraries.gen.go +++ b/internal/cmd/commands/credentiallibrariescmd/vault_credentiallibraries.gen.go @@ -9,7 +9,7 @@ import ( "github.com/hashicorp/boundary/api/credentiallibraries" "github.com/hashicorp/boundary/internal/cmd/base" "github.com/hashicorp/boundary/internal/cmd/common" - "github.com/hashicorp/boundary/sdk/strutil" + "github.com/hashicorp/shared-secure-libs/strutil" "github.com/mitchellh/cli" "github.com/posener/complete" ) diff --git a/internal/cmd/commands/credentialstorescmd/credentialstores.gen.go b/internal/cmd/commands/credentialstorescmd/credentialstores.gen.go index f21f91c1f6..0d60fc66b5 100644 --- a/internal/cmd/commands/credentialstorescmd/credentialstores.gen.go +++ b/internal/cmd/commands/credentialstorescmd/credentialstores.gen.go @@ -10,7 +10,7 @@ import ( "github.com/hashicorp/boundary/api/credentialstores" "github.com/hashicorp/boundary/internal/cmd/base" "github.com/hashicorp/boundary/internal/cmd/common" - "github.com/hashicorp/boundary/sdk/strutil" + "github.com/hashicorp/shared-secure-libs/strutil" "github.com/mitchellh/cli" "github.com/posener/complete" ) diff --git a/internal/cmd/commands/credentialstorescmd/vault_credentialstores.gen.go b/internal/cmd/commands/credentialstorescmd/vault_credentialstores.gen.go index 07d7bd1d2d..e55562469c 100644 --- a/internal/cmd/commands/credentialstorescmd/vault_credentialstores.gen.go +++ b/internal/cmd/commands/credentialstorescmd/vault_credentialstores.gen.go @@ -9,7 +9,7 @@ import ( "github.com/hashicorp/boundary/api/credentialstores" "github.com/hashicorp/boundary/internal/cmd/base" "github.com/hashicorp/boundary/internal/cmd/common" - "github.com/hashicorp/boundary/sdk/strutil" + "github.com/hashicorp/shared-secure-libs/strutil" "github.com/mitchellh/cli" "github.com/posener/complete" ) diff --git a/internal/cmd/commands/database/init.go b/internal/cmd/commands/database/init.go index 69ad70fb11..02cc9f7d44 100644 --- a/internal/cmd/commands/database/init.go +++ b/internal/cmd/commands/database/init.go @@ -10,7 +10,7 @@ import ( "github.com/hashicorp/boundary/sdk/wrapper" wrapping "github.com/hashicorp/go-kms-wrapping" "github.com/hashicorp/shared-secure-libs/configutil" - "github.com/hashicorp/vault/sdk/helper/mlock" + "github.com/hashicorp/shared-secure-libs/mlock" "github.com/mitchellh/cli" "github.com/posener/complete" ) diff --git a/internal/cmd/commands/database/migrate.go b/internal/cmd/commands/database/migrate.go index 2d04dab764..ab28b131f0 100644 --- a/internal/cmd/commands/database/migrate.go +++ b/internal/cmd/commands/database/migrate.go @@ -9,7 +9,7 @@ import ( "github.com/hashicorp/boundary/sdk/wrapper" wrapping "github.com/hashicorp/go-kms-wrapping" "github.com/hashicorp/shared-secure-libs/configutil" - "github.com/hashicorp/vault/sdk/helper/mlock" + "github.com/hashicorp/shared-secure-libs/mlock" "github.com/mitchellh/cli" "github.com/posener/complete" ) diff --git a/internal/cmd/commands/dev/dev.go b/internal/cmd/commands/dev/dev.go index 955b5de1d9..eaecebe511 100644 --- a/internal/cmd/commands/dev/dev.go +++ b/internal/cmd/commands/dev/dev.go @@ -19,8 +19,8 @@ import ( "github.com/hashicorp/boundary/internal/servers/worker" "github.com/hashicorp/boundary/internal/target" "github.com/hashicorp/boundary/internal/types/scope" - "github.com/hashicorp/boundary/sdk/strutil" "github.com/hashicorp/shared-secure-libs/configutil" + "github.com/hashicorp/shared-secure-libs/strutil" "github.com/mitchellh/cli" "github.com/posener/complete" ) diff --git a/internal/cmd/commands/groupscmd/groups.gen.go b/internal/cmd/commands/groupscmd/groups.gen.go index 30ef3804e1..227997a31b 100644 --- a/internal/cmd/commands/groupscmd/groups.gen.go +++ b/internal/cmd/commands/groupscmd/groups.gen.go @@ -10,7 +10,7 @@ import ( "github.com/hashicorp/boundary/api/groups" "github.com/hashicorp/boundary/internal/cmd/base" "github.com/hashicorp/boundary/internal/cmd/common" - "github.com/hashicorp/boundary/sdk/strutil" + "github.com/hashicorp/shared-secure-libs/strutil" "github.com/mitchellh/cli" "github.com/posener/complete" ) diff --git a/internal/cmd/commands/hostcatalogscmd/hostcatalogs.gen.go b/internal/cmd/commands/hostcatalogscmd/hostcatalogs.gen.go index 4f2911507e..72bf8681e3 100644 --- a/internal/cmd/commands/hostcatalogscmd/hostcatalogs.gen.go +++ b/internal/cmd/commands/hostcatalogscmd/hostcatalogs.gen.go @@ -10,7 +10,7 @@ import ( "github.com/hashicorp/boundary/api/hostcatalogs" "github.com/hashicorp/boundary/internal/cmd/base" "github.com/hashicorp/boundary/internal/cmd/common" - "github.com/hashicorp/boundary/sdk/strutil" + "github.com/hashicorp/shared-secure-libs/strutil" "github.com/mitchellh/cli" "github.com/posener/complete" ) diff --git a/internal/cmd/commands/hostcatalogscmd/static_hostcatalogs.gen.go b/internal/cmd/commands/hostcatalogscmd/static_hostcatalogs.gen.go index 77a81a3e0a..1f68f8bfc0 100644 --- a/internal/cmd/commands/hostcatalogscmd/static_hostcatalogs.gen.go +++ b/internal/cmd/commands/hostcatalogscmd/static_hostcatalogs.gen.go @@ -9,7 +9,7 @@ import ( "github.com/hashicorp/boundary/api/hostcatalogs" "github.com/hashicorp/boundary/internal/cmd/base" "github.com/hashicorp/boundary/internal/cmd/common" - "github.com/hashicorp/boundary/sdk/strutil" + "github.com/hashicorp/shared-secure-libs/strutil" "github.com/mitchellh/cli" "github.com/posener/complete" ) diff --git a/internal/cmd/commands/hostscmd/hosts.gen.go b/internal/cmd/commands/hostscmd/hosts.gen.go index 0035a0aee6..52e3476c52 100644 --- a/internal/cmd/commands/hostscmd/hosts.gen.go +++ b/internal/cmd/commands/hostscmd/hosts.gen.go @@ -10,7 +10,7 @@ import ( "github.com/hashicorp/boundary/api/hosts" "github.com/hashicorp/boundary/internal/cmd/base" "github.com/hashicorp/boundary/internal/cmd/common" - "github.com/hashicorp/boundary/sdk/strutil" + "github.com/hashicorp/shared-secure-libs/strutil" "github.com/mitchellh/cli" "github.com/posener/complete" ) diff --git a/internal/cmd/commands/hostscmd/static_hosts.gen.go b/internal/cmd/commands/hostscmd/static_hosts.gen.go index f5d1dfc357..8f3c247b37 100644 --- a/internal/cmd/commands/hostscmd/static_hosts.gen.go +++ b/internal/cmd/commands/hostscmd/static_hosts.gen.go @@ -9,7 +9,7 @@ import ( "github.com/hashicorp/boundary/api/hosts" "github.com/hashicorp/boundary/internal/cmd/base" "github.com/hashicorp/boundary/internal/cmd/common" - "github.com/hashicorp/boundary/sdk/strutil" + "github.com/hashicorp/shared-secure-libs/strutil" "github.com/mitchellh/cli" "github.com/posener/complete" ) diff --git a/internal/cmd/commands/hostsetscmd/hostsets.gen.go b/internal/cmd/commands/hostsetscmd/hostsets.gen.go index 71fc1b6158..82e3f456ec 100644 --- a/internal/cmd/commands/hostsetscmd/hostsets.gen.go +++ b/internal/cmd/commands/hostsetscmd/hostsets.gen.go @@ -10,7 +10,7 @@ import ( "github.com/hashicorp/boundary/api/hostsets" "github.com/hashicorp/boundary/internal/cmd/base" "github.com/hashicorp/boundary/internal/cmd/common" - "github.com/hashicorp/boundary/sdk/strutil" + "github.com/hashicorp/shared-secure-libs/strutil" "github.com/mitchellh/cli" "github.com/posener/complete" ) diff --git a/internal/cmd/commands/hostsetscmd/static_hostsets.gen.go b/internal/cmd/commands/hostsetscmd/static_hostsets.gen.go index b55e097e4b..157b9f5efa 100644 --- a/internal/cmd/commands/hostsetscmd/static_hostsets.gen.go +++ b/internal/cmd/commands/hostsetscmd/static_hostsets.gen.go @@ -9,7 +9,7 @@ import ( "github.com/hashicorp/boundary/api/hostsets" "github.com/hashicorp/boundary/internal/cmd/base" "github.com/hashicorp/boundary/internal/cmd/common" - "github.com/hashicorp/boundary/sdk/strutil" + "github.com/hashicorp/shared-secure-libs/strutil" "github.com/mitchellh/cli" "github.com/posener/complete" ) diff --git a/internal/cmd/commands/managedgroupscmd/managedgroups.gen.go b/internal/cmd/commands/managedgroupscmd/managedgroups.gen.go index 20e4febd6b..5883056936 100644 --- a/internal/cmd/commands/managedgroupscmd/managedgroups.gen.go +++ b/internal/cmd/commands/managedgroupscmd/managedgroups.gen.go @@ -10,7 +10,7 @@ import ( "github.com/hashicorp/boundary/api/managedgroups" "github.com/hashicorp/boundary/internal/cmd/base" "github.com/hashicorp/boundary/internal/cmd/common" - "github.com/hashicorp/boundary/sdk/strutil" + "github.com/hashicorp/shared-secure-libs/strutil" "github.com/mitchellh/cli" "github.com/posener/complete" ) diff --git a/internal/cmd/commands/managedgroupscmd/oidc_managedgroups.gen.go b/internal/cmd/commands/managedgroupscmd/oidc_managedgroups.gen.go index 9f0f61f548..332dc45089 100644 --- a/internal/cmd/commands/managedgroupscmd/oidc_managedgroups.gen.go +++ b/internal/cmd/commands/managedgroupscmd/oidc_managedgroups.gen.go @@ -9,7 +9,7 @@ import ( "github.com/hashicorp/boundary/api/managedgroups" "github.com/hashicorp/boundary/internal/cmd/base" "github.com/hashicorp/boundary/internal/cmd/common" - "github.com/hashicorp/boundary/sdk/strutil" + "github.com/hashicorp/shared-secure-libs/strutil" "github.com/mitchellh/cli" "github.com/posener/complete" ) diff --git a/internal/cmd/commands/rolescmd/roles.gen.go b/internal/cmd/commands/rolescmd/roles.gen.go index 3fac0b168e..00a8a3515c 100644 --- a/internal/cmd/commands/rolescmd/roles.gen.go +++ b/internal/cmd/commands/rolescmd/roles.gen.go @@ -10,7 +10,7 @@ import ( "github.com/hashicorp/boundary/api/roles" "github.com/hashicorp/boundary/internal/cmd/base" "github.com/hashicorp/boundary/internal/cmd/common" - "github.com/hashicorp/boundary/sdk/strutil" + "github.com/hashicorp/shared-secure-libs/strutil" "github.com/mitchellh/cli" "github.com/posener/complete" ) diff --git a/internal/cmd/commands/scopescmd/scopes.gen.go b/internal/cmd/commands/scopescmd/scopes.gen.go index 53572047ea..e0a02c54d6 100644 --- a/internal/cmd/commands/scopescmd/scopes.gen.go +++ b/internal/cmd/commands/scopescmd/scopes.gen.go @@ -10,7 +10,7 @@ import ( "github.com/hashicorp/boundary/api/scopes" "github.com/hashicorp/boundary/internal/cmd/base" "github.com/hashicorp/boundary/internal/cmd/common" - "github.com/hashicorp/boundary/sdk/strutil" + "github.com/hashicorp/shared-secure-libs/strutil" "github.com/mitchellh/cli" "github.com/posener/complete" ) diff --git a/internal/cmd/commands/server/server.go b/internal/cmd/commands/server/server.go index 880accdb8c..f663a609fc 100644 --- a/internal/cmd/commands/server/server.go +++ b/internal/cmd/commands/server/server.go @@ -23,7 +23,7 @@ import ( wrapping "github.com/hashicorp/go-kms-wrapping" "github.com/hashicorp/go-multierror" "github.com/hashicorp/shared-secure-libs/configutil" - "github.com/hashicorp/vault/sdk/helper/mlock" + "github.com/hashicorp/shared-secure-libs/mlock" "github.com/mitchellh/cli" "github.com/posener/complete" "go.uber.org/atomic" diff --git a/internal/cmd/commands/sessionscmd/sessions.gen.go b/internal/cmd/commands/sessionscmd/sessions.gen.go index 26a07bab19..9bcdb988bd 100644 --- a/internal/cmd/commands/sessionscmd/sessions.gen.go +++ b/internal/cmd/commands/sessionscmd/sessions.gen.go @@ -10,7 +10,7 @@ import ( "github.com/hashicorp/boundary/api/sessions" "github.com/hashicorp/boundary/internal/cmd/base" "github.com/hashicorp/boundary/internal/cmd/common" - "github.com/hashicorp/boundary/sdk/strutil" + "github.com/hashicorp/shared-secure-libs/strutil" "github.com/mitchellh/cli" "github.com/posener/complete" ) diff --git a/internal/cmd/commands/targetscmd/funcs.go b/internal/cmd/commands/targetscmd/funcs.go index f3b4e33bb1..353b06b4e4 100644 --- a/internal/cmd/commands/targetscmd/funcs.go +++ b/internal/cmd/commands/targetscmd/funcs.go @@ -14,7 +14,7 @@ import ( "github.com/hashicorp/boundary/globals" "github.com/hashicorp/boundary/internal/cmd/base" "github.com/hashicorp/boundary/internal/credential" - "github.com/hashicorp/boundary/sdk/strutil" + "github.com/hashicorp/shared-secure-libs/strutil" "github.com/mitchellh/go-wordwrap" "github.com/posener/complete" ) diff --git a/internal/cmd/commands/targetscmd/targets.gen.go b/internal/cmd/commands/targetscmd/targets.gen.go index 63f2ebe22d..2d1aae5ccf 100644 --- a/internal/cmd/commands/targetscmd/targets.gen.go +++ b/internal/cmd/commands/targetscmd/targets.gen.go @@ -11,7 +11,7 @@ import ( "github.com/hashicorp/boundary/api/targets" "github.com/hashicorp/boundary/internal/cmd/base" "github.com/hashicorp/boundary/internal/cmd/common" - "github.com/hashicorp/boundary/sdk/strutil" + "github.com/hashicorp/shared-secure-libs/strutil" "github.com/mitchellh/cli" "github.com/posener/complete" ) diff --git a/internal/cmd/commands/targetscmd/tcp_targets.gen.go b/internal/cmd/commands/targetscmd/tcp_targets.gen.go index 7c644cbe3f..b7f7939a3b 100644 --- a/internal/cmd/commands/targetscmd/tcp_targets.gen.go +++ b/internal/cmd/commands/targetscmd/tcp_targets.gen.go @@ -9,7 +9,7 @@ import ( "github.com/hashicorp/boundary/api/targets" "github.com/hashicorp/boundary/internal/cmd/base" "github.com/hashicorp/boundary/internal/cmd/common" - "github.com/hashicorp/boundary/sdk/strutil" + "github.com/hashicorp/shared-secure-libs/strutil" "github.com/mitchellh/cli" "github.com/posener/complete" ) diff --git a/internal/cmd/commands/userscmd/users.gen.go b/internal/cmd/commands/userscmd/users.gen.go index d57f4faf21..1b921ba5f4 100644 --- a/internal/cmd/commands/userscmd/users.gen.go +++ b/internal/cmd/commands/userscmd/users.gen.go @@ -10,7 +10,7 @@ import ( "github.com/hashicorp/boundary/api/users" "github.com/hashicorp/boundary/internal/cmd/base" "github.com/hashicorp/boundary/internal/cmd/common" - "github.com/hashicorp/boundary/sdk/strutil" + "github.com/hashicorp/shared-secure-libs/strutil" "github.com/mitchellh/cli" "github.com/posener/complete" ) diff --git a/internal/cmd/config/config.go b/internal/cmd/config/config.go index 0cf5698392..b51bbb7558 100644 --- a/internal/cmd/config/config.go +++ b/internal/cmd/config/config.go @@ -12,11 +12,11 @@ import ( "time" "github.com/hashicorp/boundary/internal/observability/event" - "github.com/hashicorp/boundary/sdk/strutil" wrapping "github.com/hashicorp/go-kms-wrapping" "github.com/hashicorp/hcl" "github.com/hashicorp/shared-secure-libs/configutil" - "github.com/hashicorp/vault/sdk/helper/parseutil" + "github.com/hashicorp/shared-secure-libs/parseutil" + "github.com/hashicorp/shared-secure-libs/strutil" "github.com/mitchellh/mapstructure" ) diff --git a/internal/cmd/config/config_test.go b/internal/cmd/config/config_test.go index dd75e61c1c..41cb89dad7 100644 --- a/internal/cmd/config/config_test.go +++ b/internal/cmd/config/config_test.go @@ -421,6 +421,5 @@ func TestController_EventingConfig(t *testing.T) { assert.NotEmpty(c) assert.Equal(tt.wantEventerConfig, c.Eventing) }) - } } diff --git a/internal/cmd/gencli/templates.go b/internal/cmd/gencli/templates.go index 7bbbcc44c9..bbb6cccc67 100644 --- a/internal/cmd/gencli/templates.go +++ b/internal/cmd/gencli/templates.go @@ -8,7 +8,7 @@ import ( "path/filepath" "text/template" - "github.com/hashicorp/boundary/sdk/strutil" + "github.com/hashicorp/shared-secure-libs/strutil" "github.com/iancoleman/strcase" ) @@ -90,7 +90,7 @@ import ( "github.com/hashicorp/boundary/api/{{ .Pkg }}" "github.com/hashicorp/boundary/internal/cmd/base" "github.com/hashicorp/boundary/internal/cmd/common" - "github.com/hashicorp/boundary/sdk/strutil" + "github.com/hashicorp/shared-secure-libs/strutil" "github.com/mitchellh/cli" "github.com/posener/complete" ) diff --git a/internal/credential/vault/repository_credential_library.go b/internal/credential/vault/repository_credential_library.go index 23f2b3a4aa..f15861cda4 100644 --- a/internal/credential/vault/repository_credential_library.go +++ b/internal/credential/vault/repository_credential_library.go @@ -10,7 +10,7 @@ import ( "github.com/hashicorp/boundary/internal/errors" "github.com/hashicorp/boundary/internal/kms" "github.com/hashicorp/boundary/internal/oplog" - "github.com/hashicorp/boundary/sdk/strutil" + "github.com/hashicorp/shared-secure-libs/strutil" ) // CreateCredentialLibrary inserts l into the repository and returns a new diff --git a/internal/credential/vault/repository_credential_store.go b/internal/credential/vault/repository_credential_store.go index 7e18f9be47..e6bd8d7ba1 100644 --- a/internal/credential/vault/repository_credential_store.go +++ b/internal/credential/vault/repository_credential_store.go @@ -11,7 +11,7 @@ import ( "github.com/hashicorp/boundary/internal/errors" "github.com/hashicorp/boundary/internal/kms" "github.com/hashicorp/boundary/internal/oplog" - "github.com/hashicorp/boundary/sdk/parseutil" + "github.com/hashicorp/shared-secure-libs/parseutil" vault "github.com/hashicorp/vault/api" ) diff --git a/internal/credential/vault/testing_test.go b/internal/credential/vault/testing_test.go index 3a23f47ca1..0a4b92f111 100644 --- a/internal/credential/vault/testing_test.go +++ b/internal/credential/vault/testing_test.go @@ -13,7 +13,7 @@ import ( "github.com/hashicorp/boundary/internal/db" "github.com/hashicorp/boundary/internal/iam" - "github.com/hashicorp/boundary/sdk/parseutil" + "github.com/hashicorp/shared-secure-libs/parseutil" vault "github.com/hashicorp/vault/api" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/internal/db/common/update_test.go b/internal/db/common/update_test.go index 4135062305..d4536578ea 100644 --- a/internal/db/common/update_test.go +++ b/internal/db/common/update_test.go @@ -5,7 +5,7 @@ import ( "github.com/hashicorp/boundary/internal/db/db_test" "github.com/hashicorp/go-uuid" - "github.com/hashicorp/vault/sdk/helper/base62" + "github.com/hashicorp/shared-secure-libs/base62" "github.com/jinzhu/gorm" "github.com/stretchr/testify/assert" ) diff --git a/internal/db/db_test/db.go b/internal/db/db_test/db.go index a7aa7e8820..48d56d6229 100644 --- a/internal/db/db_test/db.go +++ b/internal/db/db_test/db.go @@ -2,7 +2,7 @@ package db_test import ( - "github.com/hashicorp/vault/sdk/helper/base62" + "github.com/hashicorp/shared-secure-libs/base62" "google.golang.org/protobuf/proto" ) diff --git a/internal/db/id.go b/internal/db/id.go index 2c40e20f82..6029327a7a 100644 --- a/internal/db/id.go +++ b/internal/db/id.go @@ -6,7 +6,7 @@ import ( "strings" "github.com/hashicorp/boundary/internal/errors" - "github.com/hashicorp/vault/sdk/helper/base62" + "github.com/hashicorp/shared-secure-libs/base62" "golang.org/x/crypto/blake2b" ) diff --git a/internal/db/read_writer_test.go b/internal/db/read_writer_test.go index eccbe2735e..f822f326ee 100644 --- a/internal/db/read_writer_test.go +++ b/internal/db/read_writer_test.go @@ -17,7 +17,7 @@ import ( "github.com/hashicorp/boundary/internal/oplog/store" wrapping "github.com/hashicorp/go-kms-wrapping" "github.com/hashicorp/go-uuid" - "github.com/hashicorp/vault/sdk/helper/base62" + "github.com/hashicorp/shared-secure-libs/base62" "github.com/jinzhu/gorm" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/internal/db/schema/migrations/postgres/0/01_domain_types.up.sql b/internal/db/schema/migrations/postgres/0/01_domain_types.up.sql index 9fa5ba7d0a..e204f6680d 100644 --- a/internal/db/schema/migrations/postgres/0/01_domain_types.up.sql +++ b/internal/db/schema/migrations/postgres/0/01_domain_types.up.sql @@ -5,7 +5,7 @@ check( length(trim(value)) > 10 ); comment on domain wt_public_id is -'Random ID generated with github.com/hashicorp/vault/sdk/helper/base62'; +'Random ID generated with github.com/hashicorp/shared-secure-libs/base62'; create domain wt_private_id as text not null @@ -13,14 +13,14 @@ check( length(trim(value)) > 10 ); comment on domain wt_private_id is -'Random ID generated with github.com/hashicorp/vault/sdk/helper/base62'; +'Random ID generated with github.com/hashicorp/shared-secure-libs/base62'; create domain wt_scope_id as text check( length(trim(value)) > 10 or value = 'global' ); comment on domain wt_scope_id is -'"global" or random ID generated with github.com/hashicorp/vault/sdk/helper/base62'; +'"global" or random ID generated with github.com/hashicorp/shared-secure-libs/base62'; create domain wt_user_id as text not null @@ -28,7 +28,7 @@ check( length(trim(value)) > 10 or value = 'u_anon' or value = 'u_auth' or value = 'u_recovery' ); comment on domain wt_scope_id is -'"u_anon", "u_auth", or random ID generated with github.com/hashicorp/vault/sdk/helper/base62'; +'"u_anon", "u_auth", or random ID generated with github.com/hashicorp/shared-secure-libs/base62'; create domain wt_role_id as text not null @@ -36,7 +36,7 @@ check( length(trim(value)) > 10 ); comment on domain wt_scope_id is -'Random ID generated with github.com/hashicorp/vault/sdk/helper/base62'; +'Random ID generated with github.com/hashicorp/shared-secure-libs/base62'; create domain wt_timestamp as timestamp with time zone diff --git a/internal/db/schema/migrations/postgres/7/02_plugin.up.sql b/internal/db/schema/migrations/postgres/7/02_plugin.up.sql index e52995ed09..f460f119e1 100644 --- a/internal/db/schema/migrations/postgres/7/02_plugin.up.sql +++ b/internal/db/schema/migrations/postgres/7/02_plugin.up.sql @@ -6,7 +6,7 @@ begin; length(trim(value)) > 10 or value = 'pi_system' ); comment on domain wt_plugin_id is - '"pi_system", or random ID generated with github.com/hashicorp/vault/sdk/helper/base62'; + '"pi_system", or random ID generated with github.com/hashicorp/shared-secure-libs/base62'; create table plugin ( public_id wt_plugin_id primary key diff --git a/internal/db/schema/postgres_migration.gen.go b/internal/db/schema/postgres_migration.gen.go index 522016df98..d31e3d11ae 100644 --- a/internal/db/schema/postgres_migration.gen.go +++ b/internal/db/schema/postgres_migration.gen.go @@ -12,7 +12,7 @@ check( length(trim(value)) > 10 ); comment on domain wt_public_id is -'Random ID generated with github.com/hashicorp/vault/sdk/helper/base62'; +'Random ID generated with github.com/hashicorp/shared-secure-libs/base62'; create domain wt_private_id as text not null @@ -20,14 +20,14 @@ check( length(trim(value)) > 10 ); comment on domain wt_private_id is -'Random ID generated with github.com/hashicorp/vault/sdk/helper/base62'; +'Random ID generated with github.com/hashicorp/shared-secure-libs/base62'; create domain wt_scope_id as text check( length(trim(value)) > 10 or value = 'global' ); comment on domain wt_scope_id is -'"global" or random ID generated with github.com/hashicorp/vault/sdk/helper/base62'; +'"global" or random ID generated with github.com/hashicorp/shared-secure-libs/base62'; create domain wt_user_id as text not null @@ -35,7 +35,7 @@ check( length(trim(value)) > 10 or value = 'u_anon' or value = 'u_auth' or value = 'u_recovery' ); comment on domain wt_scope_id is -'"u_anon", "u_auth", or random ID generated with github.com/hashicorp/vault/sdk/helper/base62'; +'"u_anon", "u_auth", or random ID generated with github.com/hashicorp/shared-secure-libs/base62'; create domain wt_role_id as text not null @@ -43,7 +43,7 @@ check( length(trim(value)) > 10 ); comment on domain wt_scope_id is -'Random ID generated with github.com/hashicorp/vault/sdk/helper/base62'; +'Random ID generated with github.com/hashicorp/shared-secure-libs/base62'; create domain wt_timestamp as timestamp with time zone @@ -7321,7 +7321,7 @@ create domain wt_plugin_id as text length(trim(value)) > 10 or value = 'pi_system' ); comment on domain wt_plugin_id is - '"pi_system", or random ID generated with github.com/hashicorp/vault/sdk/helper/base62'; + '"pi_system", or random ID generated with github.com/hashicorp/shared-secure-libs/base62'; create table plugin ( public_id wt_plugin_id primary key diff --git a/internal/iam/repository_user_test.go b/internal/iam/repository_user_test.go index 1b19e5b1a9..338cebc167 100644 --- a/internal/iam/repository_user_test.go +++ b/internal/iam/repository_user_test.go @@ -17,8 +17,8 @@ import ( "github.com/hashicorp/boundary/internal/iam" "github.com/hashicorp/boundary/internal/kms" "github.com/hashicorp/boundary/internal/oplog" - "github.com/hashicorp/boundary/sdk/strutil" "github.com/hashicorp/go-uuid" + "github.com/hashicorp/shared-secure-libs/strutil" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "google.golang.org/protobuf/proto" diff --git a/internal/observability/event/event_observation.go b/internal/observability/event/event_observation.go index 8eb64d08c2..1e38c7d0dc 100644 --- a/internal/observability/event/event_observation.go +++ b/internal/observability/event/event_observation.go @@ -4,7 +4,7 @@ import ( "fmt" "github.com/hashicorp/eventlogger" - "github.com/hashicorp/vault/sdk/helper/strutil" + "github.com/hashicorp/shared-secure-libs/strutil" ) // observationVersion defines the version of observation events diff --git a/internal/observability/event/id.go b/internal/observability/event/id.go index 69272738c4..abb0150a1a 100644 --- a/internal/observability/event/id.go +++ b/internal/observability/event/id.go @@ -3,7 +3,7 @@ package event import ( "fmt" - "github.com/hashicorp/vault/sdk/helper/base62" + "github.com/hashicorp/shared-secure-libs/base62" ) // This modified newId has been done to stop a circular diff --git a/internal/observability/event/serialized_writer_test.go b/internal/observability/event/serialized_writer_test.go index 77de833aee..094e4e3f19 100644 --- a/internal/observability/event/serialized_writer_test.go +++ b/internal/observability/event/serialized_writer_test.go @@ -18,7 +18,6 @@ func (b *testBadWriter) Write(p []byte) (int, error) { } func TestSerializedWriter_Write(t *testing.T) { - tests := []struct { name string s *serializedWriter @@ -74,5 +73,4 @@ func TestSerializedWriter_Write(t *testing.T) { assert.NotEmpty(n) }) } - } diff --git a/internal/servers/common/handler.go b/internal/servers/common/handler.go index 66a937b9f5..4313cae020 100644 --- a/internal/servers/common/handler.go +++ b/internal/servers/common/handler.go @@ -11,7 +11,7 @@ import ( "github.com/hashicorp/boundary/internal/kms" "github.com/hashicorp/boundary/internal/observability/event" "github.com/hashicorp/go-hclog" - "github.com/hashicorp/vault/sdk/helper/base62" + "github.com/hashicorp/shared-secure-libs/base62" ) // generatedTraceId returns a boundary generated TraceId or "" if an error occurs when generating diff --git a/internal/servers/common/handler_test.go b/internal/servers/common/handler_test.go index f002508ad6..b92082f59b 100644 --- a/internal/servers/common/handler_test.go +++ b/internal/servers/common/handler_test.go @@ -353,7 +353,6 @@ func Test_WrapWithEventsHandler(t *testing.T) { } }) } - } func Test_startGatedEvents(t *testing.T) { diff --git a/internal/servers/controller/controller.go b/internal/servers/controller/controller.go index c21f21e44c..f4366ba004 100644 --- a/internal/servers/controller/controller.go +++ b/internal/servers/controller/controller.go @@ -22,8 +22,8 @@ import ( "github.com/hashicorp/boundary/internal/session" "github.com/hashicorp/boundary/internal/target" "github.com/hashicorp/go-hclog" - "github.com/hashicorp/vault/sdk/helper/base62" - "github.com/hashicorp/vault/sdk/helper/mlock" + "github.com/hashicorp/shared-secure-libs/base62" + "github.com/hashicorp/shared-secure-libs/mlock" "github.com/patrickmn/go-cache" ua "go.uber.org/atomic" ) diff --git a/internal/servers/controller/handler.go b/internal/servers/controller/handler.go index e23784c992..e8a075706b 100644 --- a/internal/servers/controller/handler.go +++ b/internal/servers/controller/handler.go @@ -27,9 +27,9 @@ import ( "github.com/hashicorp/boundary/internal/servers/controller/handlers/managed_groups" "github.com/hashicorp/boundary/internal/servers/controller/handlers/sessions" "github.com/hashicorp/boundary/internal/servers/controller/handlers/targets" - "github.com/hashicorp/boundary/sdk/strutil" "github.com/hashicorp/go-cleanhttp" "github.com/hashicorp/shared-secure-libs/configutil" + "github.com/hashicorp/shared-secure-libs/strutil" "google.golang.org/grpc/codes" "github.com/hashicorp/boundary/internal/servers/controller/handlers" diff --git a/internal/servers/controller/handlers/authmethods/authmethod_service.go b/internal/servers/controller/handlers/authmethods/authmethod_service.go index 69affed460..0b68cfe10a 100644 --- a/internal/servers/controller/handlers/authmethods/authmethod_service.go +++ b/internal/servers/controller/handlers/authmethods/authmethod_service.go @@ -27,8 +27,8 @@ import ( "github.com/hashicorp/boundary/internal/types/action" "github.com/hashicorp/boundary/internal/types/resource" "github.com/hashicorp/boundary/internal/types/scope" - "github.com/hashicorp/boundary/sdk/strutil" "github.com/hashicorp/go-hclog" + "github.com/hashicorp/shared-secure-libs/strutil" "google.golang.org/grpc/codes" "google.golang.org/protobuf/types/known/structpb" "google.golang.org/protobuf/types/known/wrapperspb" diff --git a/internal/servers/controller/handlers/credentiallibraries/credentiallibrary_service.go b/internal/servers/controller/handlers/credentiallibraries/credentiallibrary_service.go index e2a0a1c5d0..4dffcbbd11 100644 --- a/internal/servers/controller/handlers/credentiallibraries/credentiallibrary_service.go +++ b/internal/servers/controller/handlers/credentiallibraries/credentiallibrary_service.go @@ -19,7 +19,7 @@ import ( "github.com/hashicorp/boundary/internal/servers/controller/handlers" "github.com/hashicorp/boundary/internal/types/action" "github.com/hashicorp/boundary/internal/types/resource" - "github.com/hashicorp/boundary/sdk/strutil" + "github.com/hashicorp/shared-secure-libs/strutil" "google.golang.org/grpc/codes" "google.golang.org/protobuf/types/known/wrapperspb" ) diff --git a/internal/servers/controller/handlers/groups/group_service.go b/internal/servers/controller/handlers/groups/group_service.go index 3cc23019c6..1dfff002af 100644 --- a/internal/servers/controller/handlers/groups/group_service.go +++ b/internal/servers/controller/handlers/groups/group_service.go @@ -19,7 +19,7 @@ import ( "github.com/hashicorp/boundary/internal/types/action" "github.com/hashicorp/boundary/internal/types/resource" "github.com/hashicorp/boundary/internal/types/scope" - "github.com/hashicorp/boundary/sdk/strutil" + "github.com/hashicorp/shared-secure-libs/strutil" "google.golang.org/grpc/codes" "google.golang.org/protobuf/types/known/wrapperspb" ) diff --git a/internal/servers/controller/handlers/host_sets/host_set_service.go b/internal/servers/controller/handlers/host_sets/host_set_service.go index 636f6debfa..fdc867bcec 100644 --- a/internal/servers/controller/handlers/host_sets/host_set_service.go +++ b/internal/servers/controller/handlers/host_sets/host_set_service.go @@ -18,7 +18,7 @@ import ( "github.com/hashicorp/boundary/internal/servers/controller/handlers" "github.com/hashicorp/boundary/internal/types/action" "github.com/hashicorp/boundary/internal/types/resource" - "github.com/hashicorp/boundary/sdk/strutil" + "github.com/hashicorp/shared-secure-libs/strutil" "google.golang.org/grpc/codes" "google.golang.org/protobuf/types/known/wrapperspb" ) diff --git a/internal/servers/controller/handlers/roles/role_service.go b/internal/servers/controller/handlers/roles/role_service.go index 0b3e3604e5..b495f8bfa1 100644 --- a/internal/servers/controller/handlers/roles/role_service.go +++ b/internal/servers/controller/handlers/roles/role_service.go @@ -20,7 +20,7 @@ import ( "github.com/hashicorp/boundary/internal/types/action" "github.com/hashicorp/boundary/internal/types/resource" "github.com/hashicorp/boundary/internal/types/scope" - "github.com/hashicorp/boundary/sdk/strutil" + "github.com/hashicorp/shared-secure-libs/strutil" "google.golang.org/grpc/codes" "google.golang.org/protobuf/types/known/wrapperspb" ) diff --git a/internal/servers/controller/handlers/targets/target_service.go b/internal/servers/controller/handlers/targets/target_service.go index 53ee8e9a4f..a355ac8800 100644 --- a/internal/servers/controller/handlers/targets/target_service.go +++ b/internal/servers/controller/handlers/targets/target_service.go @@ -34,8 +34,8 @@ import ( "github.com/hashicorp/boundary/internal/types/action" "github.com/hashicorp/boundary/internal/types/resource" "github.com/hashicorp/boundary/internal/types/scope" - "github.com/hashicorp/boundary/sdk/strutil" "github.com/hashicorp/go-bexpr" + "github.com/hashicorp/shared-secure-libs/strutil" "github.com/mitchellh/pointerstructure" "github.com/mr-tron/base58" "google.golang.org/grpc/codes" diff --git a/internal/servers/controller/handlers/users/user_service.go b/internal/servers/controller/handlers/users/user_service.go index 7ad2997347..d21ae57684 100644 --- a/internal/servers/controller/handlers/users/user_service.go +++ b/internal/servers/controller/handlers/users/user_service.go @@ -21,7 +21,7 @@ import ( "github.com/hashicorp/boundary/internal/types/action" "github.com/hashicorp/boundary/internal/types/resource" "github.com/hashicorp/boundary/internal/types/scope" - "github.com/hashicorp/boundary/sdk/strutil" + "github.com/hashicorp/shared-secure-libs/strutil" "google.golang.org/grpc/codes" "google.golang.org/protobuf/types/known/wrapperspb" ) diff --git a/internal/servers/controller/testing.go b/internal/servers/controller/testing.go index cd191f206a..620dccfae5 100644 --- a/internal/servers/controller/testing.go +++ b/internal/servers/controller/testing.go @@ -20,10 +20,10 @@ import ( "github.com/hashicorp/boundary/internal/intglobals" "github.com/hashicorp/boundary/internal/kms" "github.com/hashicorp/boundary/internal/servers" - "github.com/hashicorp/boundary/sdk/strutil" "github.com/hashicorp/go-hclog" wrapping "github.com/hashicorp/go-kms-wrapping" - "github.com/hashicorp/vault/sdk/helper/base62" + "github.com/hashicorp/shared-secure-libs/base62" + "github.com/hashicorp/shared-secure-libs/strutil" "github.com/jinzhu/gorm" ) diff --git a/internal/servers/worker/controller_connection.go b/internal/servers/worker/controller_connection.go index 287f97d102..df70ac5d4e 100644 --- a/internal/servers/worker/controller_connection.go +++ b/internal/servers/worker/controller_connection.go @@ -19,7 +19,7 @@ import ( "github.com/hashicorp/boundary/internal/cmd/base" pbs "github.com/hashicorp/boundary/internal/gen/controller/servers/services" - "github.com/hashicorp/vault/sdk/helper/base62" + "github.com/hashicorp/shared-secure-libs/base62" "google.golang.org/grpc" "google.golang.org/grpc/resolver" "google.golang.org/protobuf/proto" diff --git a/internal/servers/worker/testing.go b/internal/servers/worker/testing.go index c41b4d4b4b..ddd2bc1952 100644 --- a/internal/servers/worker/testing.go +++ b/internal/servers/worker/testing.go @@ -12,7 +12,7 @@ import ( pbs "github.com/hashicorp/boundary/internal/gen/controller/servers/services" "github.com/hashicorp/go-hclog" wrapping "github.com/hashicorp/go-kms-wrapping" - "github.com/hashicorp/vault/sdk/helper/base62" + "github.com/hashicorp/shared-secure-libs/base62" ) // TestWorker wraps a base.Server and Worker to provide a diff --git a/internal/servers/worker/worker.go b/internal/servers/worker/worker.go index b72100ab3e..dd62e74d4a 100644 --- a/internal/servers/worker/worker.go +++ b/internal/servers/worker/worker.go @@ -12,8 +12,8 @@ import ( "github.com/hashicorp/boundary/internal/cmd/config" "github.com/hashicorp/boundary/internal/servers" "github.com/hashicorp/go-hclog" - "github.com/hashicorp/vault/sdk/helper/base62" - "github.com/hashicorp/vault/sdk/helper/mlock" + "github.com/hashicorp/shared-secure-libs/base62" + "github.com/hashicorp/shared-secure-libs/mlock" ua "go.uber.org/atomic" "google.golang.org/grpc/resolver" "google.golang.org/grpc/resolver/manual" diff --git a/internal/session/repository_connection_test.go b/internal/session/repository_connection_test.go index 3a4636090f..18454793a5 100644 --- a/internal/session/repository_connection_test.go +++ b/internal/session/repository_connection_test.go @@ -10,7 +10,7 @@ import ( "github.com/hashicorp/boundary/internal/iam" "github.com/hashicorp/boundary/internal/kms" "github.com/hashicorp/boundary/internal/oplog" - "github.com/hashicorp/boundary/sdk/strutil" + "github.com/hashicorp/shared-secure-libs/strutil" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/session/testing.go b/internal/session/testing.go index dd90fb8737..0656d1aad7 100644 --- a/internal/session/testing.go +++ b/internal/session/testing.go @@ -17,7 +17,7 @@ import ( "github.com/hashicorp/boundary/internal/target" wrapping "github.com/hashicorp/go-kms-wrapping" "github.com/hashicorp/go-uuid" - "github.com/hashicorp/vault/sdk/helper/base62" + "github.com/hashicorp/shared-secure-libs/base62" "github.com/jinzhu/gorm" "github.com/stretchr/testify/require" "google.golang.org/protobuf/types/known/timestamppb" diff --git a/internal/tests/cluster/session_cleanup_test.go b/internal/tests/cluster/session_cleanup_test.go index aa81c0a980..ab506a2df1 100644 --- a/internal/tests/cluster/session_cleanup_test.go +++ b/internal/tests/cluster/session_cleanup_test.go @@ -27,7 +27,7 @@ import ( "github.com/hashicorp/dawdle" "github.com/hashicorp/go-cleanhttp" "github.com/hashicorp/go-hclog" - "github.com/hashicorp/vault/sdk/helper/base62" + "github.com/hashicorp/shared-secure-libs/base62" "github.com/mr-tron/base58" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/sdk/go.mod b/sdk/go.mod index 337846134c..8eff391ba3 100644 --- a/sdk/go.mod +++ b/sdk/go.mod @@ -3,14 +3,13 @@ module github.com/hashicorp/boundary/sdk go 1.15 require ( - github.com/hashicorp/errwrap v1.1.0 + github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-kms-wrapping v0.6.1 - github.com/hashicorp/go-sockaddr v1.0.2 github.com/hashicorp/go-uuid v1.0.2 github.com/hashicorp/shared-secure-libs v0.0.4 - github.com/mitchellh/mapstructure v1.4.1 + github.com/hashicorp/shared-secure-libs/strutil v0.1.0 + github.com/mitchellh/mapstructure v1.4.1 // indirect github.com/mr-tron/base58 v1.2.0 - github.com/ryanuber/go-glob v1.0.0 github.com/stretchr/testify v1.7.0 google.golang.org/protobuf v1.25.0 ) diff --git a/sdk/go.sum b/sdk/go.sum index ed54d9bc85..715c476758 100644 --- a/sdk/go.sum +++ b/sdk/go.sum @@ -309,6 +309,8 @@ github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2p github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= github.com/hashicorp/shared-secure-libs v0.0.4 h1:aRm7/wnJ70z5hSX8cLdyupwI8QNKklfViRstg/ZtUdw= github.com/hashicorp/shared-secure-libs v0.0.4/go.mod h1:xhtA0FH6AYYFOy0sir7u0O0zzdLi7ofU6oWxy+gjnuc= +github.com/hashicorp/shared-secure-libs/strutil v0.1.0 h1:mzQjO/tqNZAmdcZ5gecvzs7z/tAKy2Ry1SO6j7IxjQU= +github.com/hashicorp/shared-secure-libs/strutil v0.1.0/go.mod h1:YsAf1vJYtE4AhRdGD+X/96cFK7j8oosgnYLilKGzSTw= github.com/hashicorp/vault/api v1.0.5-0.20200514164214-89b1987e38c2/go.mod h1:P8A7gn1a6j/7qQ4zOaWI6FC/Q9jQWEBRTOwZH33tC9o= github.com/hashicorp/vault/api v1.0.5-0.20200519221902-385fac77e20f/go.mod h1:euTFbi2YJgwcju3imEt919lhJKF68nN1cQPq3aA+kBE= github.com/hashicorp/vault/api v1.0.5-0.20200805123347-1ef507638af6 h1:ChHpobQse3kjVX7GmbpUFVqaMTf4lb1gcLrJltsUmS4= @@ -395,7 +397,6 @@ github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0Qu github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.3.2/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/mitchellh/mapstructure v1.3.3 h1:SzB1nHZ2Xi+17FP0zVQBHIZqvwRN9408fJO8h+eeNA8= github.com/mitchellh/mapstructure v1.3.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/mapstructure v1.4.1 h1:CpVNEelQCZBooIPDn+AR3NpivK/TIKU8bDxdASFVQag= github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= @@ -537,7 +538,6 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= -github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= diff --git a/sdk/parseutil/parseutil.go b/sdk/parseutil/parseutil.go deleted file mode 100644 index 2d5b089948..0000000000 --- a/sdk/parseutil/parseutil.go +++ /dev/null @@ -1,174 +0,0 @@ -package parseutil - -import ( - "encoding/json" - "errors" - "fmt" - "strconv" - "strings" - "time" - - "github.com/hashicorp/boundary/sdk/strutil" - "github.com/hashicorp/errwrap" - sockaddr "github.com/hashicorp/go-sockaddr" - "github.com/mitchellh/mapstructure" -) - -func ParseDurationSecond(in interface{}) (time.Duration, error) { - var dur time.Duration - jsonIn, ok := in.(json.Number) - if ok { - in = jsonIn.String() - } - switch inp := in.(type) { - case nil: - // return default of zero - case string: - if inp == "" { - return dur, nil - } - var err error - // Look for a suffix otherwise its a plain second value - if strings.HasSuffix(inp, "s") || strings.HasSuffix(inp, "m") || strings.HasSuffix(inp, "h") || strings.HasSuffix(inp, "ms") { - dur, err = time.ParseDuration(inp) - if err != nil { - return dur, err - } - } else { - // Plain integer - secs, err := strconv.ParseInt(inp, 10, 64) - if err != nil { - return dur, err - } - dur = time.Duration(secs) * time.Second - } - case int: - dur = time.Duration(inp) * time.Second - case int32: - dur = time.Duration(inp) * time.Second - case int64: - dur = time.Duration(inp) * time.Second - case uint: - dur = time.Duration(inp) * time.Second - case uint32: - dur = time.Duration(inp) * time.Second - case uint64: - dur = time.Duration(inp) * time.Second - case float32: - dur = time.Duration(inp) * time.Second - case float64: - dur = time.Duration(inp) * time.Second - case time.Duration: - dur = inp - default: - return 0, errors.New("could not parse duration from input") - } - - return dur, nil -} - -func ParseInt(in interface{}) (int64, error) { - var ret int64 - jsonIn, ok := in.(json.Number) - if ok { - in = jsonIn.String() - } - switch in.(type) { - case string: - inp := in.(string) - if inp == "" { - return 0, nil - } - var err error - left, err := strconv.ParseInt(inp, 10, 64) - if err != nil { - return ret, err - } - ret = left - case int: - ret = int64(in.(int)) - case int32: - ret = int64(in.(int32)) - case int64: - ret = in.(int64) - case uint: - ret = int64(in.(uint)) - case uint32: - ret = int64(in.(uint32)) - case uint64: - ret = int64(in.(uint64)) - default: - return 0, errors.New("could not parse value from input") - } - - return ret, nil -} - -func ParseBool(in interface{}) (bool, error) { - var result bool - if err := mapstructure.WeakDecode(in, &result); err != nil { - return false, err - } - return result, nil -} - -func ParseCommaStringSlice(in interface{}) ([]string, error) { - rawString, ok := in.(string) - if ok && rawString == "" { - return []string{}, nil - } - var result []string - config := &mapstructure.DecoderConfig{ - Result: &result, - WeaklyTypedInput: true, - DecodeHook: mapstructure.StringToSliceHookFunc(","), - } - decoder, err := mapstructure.NewDecoder(config) - if err != nil { - return nil, err - } - if err := decoder.Decode(in); err != nil { - return nil, err - } - return strutil.TrimStrings(result), nil -} - -func ParseAddrs(addrs interface{}) ([]*sockaddr.SockAddrMarshaler, error) { - out := make([]*sockaddr.SockAddrMarshaler, 0) - stringAddrs := make([]string, 0) - - switch addrs.(type) { - case string: - stringAddrs = strutil.ParseArbitraryStringSlice(addrs.(string), ",") - if len(stringAddrs) == 0 { - return nil, fmt.Errorf("unable to parse addresses from %v", addrs) - } - - case []string: - stringAddrs = addrs.([]string) - - case []interface{}: - for _, v := range addrs.([]interface{}) { - stringAddr, ok := v.(string) - if !ok { - return nil, fmt.Errorf("error parsing %v as string", v) - } - stringAddrs = append(stringAddrs, stringAddr) - } - - default: - return nil, fmt.Errorf("unknown address input type %T", addrs) - } - - for _, addr := range stringAddrs { - sa, err := sockaddr.NewSockAddr(addr) - if err != nil { - return nil, errwrap.Wrapf(fmt.Sprintf("error parsing address %q: {{err}}", addr), err) - } - out = append(out, &sockaddr.SockAddrMarshaler{ - SockAddr: sa, - }) - } - - return out, nil -} diff --git a/sdk/strutil/strutil.go b/sdk/strutil/strutil.go deleted file mode 100644 index 2186680b6b..0000000000 --- a/sdk/strutil/strutil.go +++ /dev/null @@ -1,476 +0,0 @@ -package strutil - -import ( - "encoding/base64" - "encoding/json" - "fmt" - "sort" - "strings" - "unicode" - - "github.com/hashicorp/errwrap" - glob "github.com/ryanuber/go-glob" -) - -// StrListContainsGlob looks for a string in a list of strings and allows -// globs. -func StrListContainsGlob(haystack []string, needle string) bool { - for _, item := range haystack { - if glob.Glob(item, needle) { - return true - } - } - return false -} - -// StrListContains looks for a string in a list of strings. -func StrListContains(haystack []string, needle string) bool { - for _, item := range haystack { - if item == needle { - return true - } - } - return false -} - -// StrListSubset checks if a given list is a subset -// of another set -func StrListSubset(super, sub []string) bool { - for _, item := range sub { - if !StrListContains(super, item) { - return false - } - } - return true -} - -// ParseDedupAndSortStrings parses a comma separated list of strings -// into a slice of strings. The return slice will be sorted and will -// not contain duplicate or empty items. -func ParseDedupAndSortStrings(input string, sep string) []string { - input = strings.TrimSpace(input) - parsed := []string{} - if input == "" { - // Don't return nil - return parsed - } - return RemoveDuplicates(strings.Split(input, sep), false) -} - -// ParseDedupLowercaseAndSortStrings parses a comma separated list of -// strings into a slice of strings. The return slice will be sorted and -// will not contain duplicate or empty items. The values will be converted -// to lower case. -func ParseDedupLowercaseAndSortStrings(input string, sep string) []string { - input = strings.TrimSpace(input) - parsed := []string{} - if input == "" { - // Don't return nil - return parsed - } - return RemoveDuplicates(strings.Split(input, sep), true) -} - -// ParseKeyValues parses a comma separated list of `=` tuples -// into a map[string]string. -func ParseKeyValues(input string, out map[string]string, sep string) error { - if out == nil { - return fmt.Errorf("'out is nil") - } - - keyValues := ParseDedupLowercaseAndSortStrings(input, sep) - if len(keyValues) == 0 { - return nil - } - - for _, keyValue := range keyValues { - shards := strings.Split(keyValue, "=") - if len(shards) != 2 { - return fmt.Errorf("invalid format") - } - - key := strings.TrimSpace(shards[0]) - value := strings.TrimSpace(shards[1]) - if key == "" || value == "" { - return fmt.Errorf("invalid pair: key: %q value: %q", key, value) - } - out[key] = value - } - return nil -} - -// ParseArbitraryKeyValues parses arbitrary tuples. The input -// can be one of the following: -// * JSON string -// * Base64 encoded JSON string -// * Comma separated list of `=` pairs -// * Base64 encoded string containing comma separated list of -// `=` pairs -// -// Input will be parsed into the output parameter, which should -// be a non-nil map[string]string. -func ParseArbitraryKeyValues(input string, out map[string]string, sep string) error { - input = strings.TrimSpace(input) - if input == "" { - return nil - } - if out == nil { - return fmt.Errorf("'out' is nil") - } - - // Try to base64 decode the input. If successful, consider the decoded - // value as input. - inputBytes, err := base64.StdEncoding.DecodeString(input) - if err == nil { - input = string(inputBytes) - } - - // Try to JSON unmarshal the input. If successful, consider that the - // metadata was supplied as JSON input. - err = json.Unmarshal([]byte(input), &out) - if err != nil { - // If JSON unmarshaling fails, consider that the input was - // supplied as a comma separated string of 'key=value' pairs. - if err = ParseKeyValues(input, out, sep); err != nil { - return errwrap.Wrapf("failed to parse the input: {{err}}", err) - } - } - - // Validate the parsed input - for key, value := range out { - if key != "" && value == "" { - return fmt.Errorf("invalid value for key %q", key) - } - } - - return nil -} - -// ParseStringSlice parses a `sep`-separated list of strings into a -// []string with surrounding whitespace removed. -// -// The output will always be a valid slice but may be of length zero. -func ParseStringSlice(input string, sep string) []string { - input = strings.TrimSpace(input) - if input == "" { - return []string{} - } - - splitStr := strings.Split(input, sep) - ret := make([]string, len(splitStr)) - for i, val := range splitStr { - ret[i] = strings.TrimSpace(val) - } - - return ret -} - -// ParseArbitraryStringSlice parses arbitrary string slice. The input -// can be one of the following: -// * JSON string -// * Base64 encoded JSON string -// * `sep` separated list of values -// * Base64-encoded string containing a `sep` separated list of values -// -// Note that the separator is ignored if the input is found to already be in a -// structured format (e.g., JSON) -// -// The output will always be a valid slice but may be of length zero. -func ParseArbitraryStringSlice(input string, sep string) []string { - input = strings.TrimSpace(input) - if input == "" { - return []string{} - } - - // Try to base64 decode the input. If successful, consider the decoded - // value as input. - inputBytes, err := base64.StdEncoding.DecodeString(input) - if err == nil { - input = string(inputBytes) - } - - ret := []string{} - - // Try to JSON unmarshal the input. If successful, consider that the - // metadata was supplied as JSON input. - err = json.Unmarshal([]byte(input), &ret) - if err != nil { - // If JSON unmarshaling fails, consider that the input was - // supplied as a separated string of values. - return ParseStringSlice(input, sep) - } - - if ret == nil { - return []string{} - } - - return ret -} - -// TrimStrings takes a slice of strings and returns a slice of strings -// with trimmed spaces -func TrimStrings(items []string) []string { - ret := make([]string, len(items)) - for i, item := range items { - ret[i] = strings.TrimSpace(item) - } - return ret -} - -// RemoveDuplicates removes duplicate and empty elements from a slice of -// strings. This also may convert the items in the slice to lower case and -// returns a sorted slice. -func RemoveDuplicates(items []string, lowercase bool) []string { - itemsMap := map[string]bool{} - for _, item := range items { - item = strings.TrimSpace(item) - if lowercase { - item = strings.ToLower(item) - } - if item == "" { - continue - } - itemsMap[item] = true - } - items = make([]string, 0, len(itemsMap)) - for item := range itemsMap { - items = append(items, item) - } - sort.Strings(items) - return items -} - -// RemoveDuplicatesStable removes duplicate and empty elements from a slice of -// strings, preserving order (and case) of the original slice. -// In all cases, strings are compared after trimming whitespace -// If caseInsensitive, strings will be compared after ToLower() -func RemoveDuplicatesStable(items []string, caseInsensitive bool) []string { - itemsMap := make(map[string]bool, len(items)) - deduplicated := make([]string, 0, len(items)) - - for _, item := range items { - key := strings.TrimSpace(item) - if caseInsensitive { - key = strings.ToLower(key) - } - if key == "" || itemsMap[key] { - continue - } - itemsMap[key] = true - deduplicated = append(deduplicated, item) - } - return deduplicated -} - -// RemoveEmpty removes empty elements from a slice of -// strings -func RemoveEmpty(items []string) []string { - if len(items) == 0 { - return items - } - itemsSlice := make([]string, 0, len(items)) - for _, item := range items { - if item == "" { - continue - } - itemsSlice = append(itemsSlice, item) - } - return itemsSlice -} - -// EquivalentSlices checks whether the given string sets are equivalent, as in, -// they contain the same values. -func EquivalentSlices(a, b []string) bool { - if a == nil && b == nil { - return true - } - - if a == nil || b == nil { - return false - } - - // First we'll build maps to ensure unique values - mapA := map[string]bool{} - mapB := map[string]bool{} - for _, keyA := range a { - mapA[keyA] = true - } - for _, keyB := range b { - mapB[keyB] = true - } - - // Now we'll build our checking slices - var sortedA, sortedB []string - for keyA := range mapA { - sortedA = append(sortedA, keyA) - } - for keyB := range mapB { - sortedB = append(sortedB, keyB) - } - sort.Strings(sortedA) - sort.Strings(sortedB) - - // Finally, compare - if len(sortedA) != len(sortedB) { - return false - } - - for i := range sortedA { - if sortedA[i] != sortedB[i] { - return false - } - } - - return true -} - -// EqualStringMaps tests whether two map[string]string objects are equal. -// Equal means both maps have the same sets of keys and values. This function -// is 6-10x faster than a call to reflect.DeepEqual(). -func EqualStringMaps(a, b map[string]string) bool { - if len(a) != len(b) { - return false - } - - for k := range a { - v, ok := b[k] - if !ok || a[k] != v { - return false - } - } - - return true -} - -// StrListDelete removes the first occurrence of the given item from the slice -// of strings if the item exists. -func StrListDelete(s []string, d string) []string { - if s == nil { - return s - } - - for index, element := range s { - if element == d { - return append(s[:index], s[index+1:]...) - } - } - - return s -} - -// GlobbedStringsMatch compares item to val with support for a leading and/or -// trailing wildcard '*' in item. -func GlobbedStringsMatch(item, val string) bool { - if len(item) < 2 { - return val == item - } - - hasPrefix := strings.HasPrefix(item, "*") - hasSuffix := strings.HasSuffix(item, "*") - - if hasPrefix && hasSuffix { - return strings.Contains(val, item[1:len(item)-1]) - } else if hasPrefix { - return strings.HasSuffix(val, item[1:]) - } else if hasSuffix { - return strings.HasPrefix(val, item[:len(item)-1]) - } - - return val == item -} - -// AppendIfMissing adds a string to a slice if the given string is not present -func AppendIfMissing(slice []string, i string) []string { - if StrListContains(slice, i) { - return slice - } - return append(slice, i) -} - -// MergeSlices adds an arbitrary number of slices together, uniquely -func MergeSlices(args ...[]string) []string { - all := map[string]struct{}{} - for _, slice := range args { - for _, v := range slice { - all[v] = struct{}{} - } - } - - result := make([]string, 0, len(all)) - for k := range all { - result = append(result, k) - } - sort.Strings(result) - return result -} - -// Difference returns the set difference (A - B) of the two given slices. The -// result will also remove any duplicated values in set A regardless of whether -// that matches any values in set B. -func Difference(a, b []string, lowercase bool) []string { - if len(a) == 0 { - return a - } - if len(b) == 0 { - if !lowercase { - return a - } - newA := make([]string, len(a)) - for i, v := range a { - newA[i] = strings.ToLower(v) - } - return newA - } - - a = RemoveDuplicates(a, lowercase) - b = RemoveDuplicates(b, lowercase) - - itemsMap := map[string]bool{} - for _, aVal := range a { - itemsMap[aVal] = true - } - - // Perform difference calculation - for _, bVal := range b { - if _, ok := itemsMap[bVal]; ok { - itemsMap[bVal] = false - } - } - - items := []string{} - for item, exists := range itemsMap { - if exists { - items = append(items, item) - } - } - sort.Strings(items) - return items -} - -// Printable returns true if all characters in the string are printable -// according to Unicode -func Printable(s string) bool { - return strings.IndexFunc(s, func(c rune) bool { - return !unicode.IsPrint(c) - }) == -1 -} - -// StringListToInterfaceList simply takes a []string and turns it into a -// []interface{} to satisfy the input requirements for other library functions -func StringListToInterfaceList(in []string) []interface{} { - ret := make([]interface{}, len(in)) - for i, v := range in { - ret[i] = v - } - return ret -} - -// Reverse reverses the input string -func Reverse(in string) string { - l := len(in) - out := make([]byte, l) - for i := 0; i <= l/2; i++ { - out[i], out[l-1-i] = in[l-1-i], in[i] - } - return string(out) -} diff --git a/sdk/strutil/strutil_test.go b/sdk/strutil/strutil_test.go deleted file mode 100644 index 6257e948f6..0000000000 --- a/sdk/strutil/strutil_test.go +++ /dev/null @@ -1,657 +0,0 @@ -package strutil - -import ( - "encoding/base64" - "encoding/json" - "fmt" - "reflect" - "testing" - - "github.com/stretchr/testify/require" -) - -func TestStrUtil_StrListDelete(t *testing.T) { - output := StrListDelete([]string{"item1", "item2", "item3"}, "item1") - if StrListContains(output, "item1") { - t.Fatal("bad: 'item1' should not have been present") - } - - output = StrListDelete([]string{"item1", "item2", "item3"}, "item2") - if StrListContains(output, "item2") { - t.Fatal("bad: 'item2' should not have been present") - } - - output = StrListDelete([]string{"item1", "item2", "item3"}, "item3") - if StrListContains(output, "item3") { - t.Fatal("bad: 'item3' should not have been present") - } - - output = StrListDelete([]string{"item1", "item1", "item3"}, "item1") - if !StrListContains(output, "item1") { - t.Fatal("bad: 'item1' should have been present") - } - - output = StrListDelete(output, "item1") - if StrListContains(output, "item1") { - t.Fatal("bad: 'item1' should not have been present") - } - - output = StrListDelete(output, "random") - if len(output) != 1 { - t.Fatalf("bad: expected: 1, actual: %d", len(output)) - } - - output = StrListDelete(output, "item3") - if StrListContains(output, "item3") { - t.Fatal("bad: 'item3' should not have been present") - } -} - -func TestStrutil_EquivalentSlices(t *testing.T) { - slice1 := []string{"test2", "test1", "test3"} - slice2 := []string{"test3", "test2", "test1"} - if !EquivalentSlices(slice1, slice2) { - t.Fatalf("bad: expected a match") - } - - slice2 = append(slice2, "test4") - if EquivalentSlices(slice1, slice2) { - t.Fatalf("bad: expected a mismatch") - } -} - -func TestStrutil_ListContainsGlob(t *testing.T) { - haystack := []string{ - "dev", - "ops*", - "root/*", - "*-dev", - "_*_", - } - if StrListContainsGlob(haystack, "tubez") { - t.Fatalf("Value shouldn't exist") - } - if !StrListContainsGlob(haystack, "root/test") { - t.Fatalf("Value should exist") - } - if !StrListContainsGlob(haystack, "ops_test") { - t.Fatalf("Value should exist") - } - if !StrListContainsGlob(haystack, "ops") { - t.Fatalf("Value should exist") - } - if !StrListContainsGlob(haystack, "dev") { - t.Fatalf("Value should exist") - } - if !StrListContainsGlob(haystack, "test-dev") { - t.Fatalf("Value should exist") - } - if !StrListContainsGlob(haystack, "_test_") { - t.Fatalf("Value should exist") - } -} - -func TestStrutil_ListContains(t *testing.T) { - haystack := []string{ - "dev", - "ops", - "prod", - "root", - } - if StrListContains(haystack, "tubez") { - t.Fatalf("Bad") - } - if !StrListContains(haystack, "root") { - t.Fatalf("Bad") - } -} - -func TestStrutil_ListSubset(t *testing.T) { - parent := []string{ - "dev", - "ops", - "prod", - "root", - } - child := []string{ - "prod", - "ops", - } - if !StrListSubset(parent, child) { - t.Fatalf("Bad") - } - if !StrListSubset(parent, parent) { - t.Fatalf("Bad") - } - if !StrListSubset(child, child) { - t.Fatalf("Bad") - } - if !StrListSubset(child, nil) { - t.Fatalf("Bad") - } - if StrListSubset(child, parent) { - t.Fatalf("Bad") - } - if StrListSubset(nil, child) { - t.Fatalf("Bad") - } -} - -func TestStrutil_ParseKeyValues(t *testing.T) { - actual := make(map[string]string) - expected := map[string]string{ - "key1": "value1", - "key2": "value2", - } - var input string - var err error - - input = "key1=value1,key2=value2" - err = ParseKeyValues(input, actual, ",") - if err != nil { - t.Fatal(err) - } - if !reflect.DeepEqual(expected, actual) { - t.Fatalf("bad: expected: %#v\nactual: %#v", expected, actual) - } - for k := range actual { - delete(actual, k) - } - - input = "key1 = value1, key2 = value2" - err = ParseKeyValues(input, actual, ",") - if err != nil { - t.Fatal(err) - } - if !reflect.DeepEqual(expected, actual) { - t.Fatalf("bad: expected: %#v\nactual: %#v", expected, actual) - } - for k := range actual { - delete(actual, k) - } - - input = "key1 = value1, key2 = " - err = ParseKeyValues(input, actual, ",") - if err == nil { - t.Fatalf("expected an error") - } - for k := range actual { - delete(actual, k) - } - - input = "key1 = value1, = value2 " - err = ParseKeyValues(input, actual, ",") - if err == nil { - t.Fatalf("expected an error") - } - for k := range actual { - delete(actual, k) - } - - input = "key1" - err = ParseKeyValues(input, actual, ",") - if err == nil { - t.Fatalf("expected an error") - } -} - -func TestStrutil_ParseArbitraryKeyValues(t *testing.T) { - actual := make(map[string]string) - expected := map[string]string{ - "key1": "value1", - "key2": "value2", - } - var input string - var err error - - // Test = as comma separated string - input = "key1=value1,key2=value2" - err = ParseArbitraryKeyValues(input, actual, ",") - if err != nil { - t.Fatal(err) - } - if !reflect.DeepEqual(expected, actual) { - t.Fatalf("bad: expected: %#v\nactual: %#v", expected, actual) - } - for k := range actual { - delete(actual, k) - } - - // Test = as base64 encoded comma separated string - input = base64.StdEncoding.EncodeToString([]byte(input)) - err = ParseArbitraryKeyValues(input, actual, ",") - if err != nil { - t.Fatal(err) - } - if !reflect.DeepEqual(expected, actual) { - t.Fatalf("bad: expected: %#v\nactual: %#v", expected, actual) - } - for k := range actual { - delete(actual, k) - } - - // Test JSON encoded = tuples - input = `{"key1":"value1", "key2":"value2"}` - err = ParseArbitraryKeyValues(input, actual, ",") - if err != nil { - t.Fatal(err) - } - if !reflect.DeepEqual(expected, actual) { - t.Fatalf("bad: expected: %#v\nactual: %#v", expected, actual) - } - for k := range actual { - delete(actual, k) - } - - // Test base64 encoded JSON string of = tuples - input = base64.StdEncoding.EncodeToString([]byte(input)) - err = ParseArbitraryKeyValues(input, actual, ",") - if err != nil { - t.Fatal(err) - } - if !reflect.DeepEqual(expected, actual) { - t.Fatalf("bad: expected: %#v\nactual: %#v", expected, actual) - } - for k := range actual { - delete(actual, k) - } -} - -func TestStrutil_ParseArbitraryStringSlice(t *testing.T) { - input := `CREATE ROLE "{{name}}" WITH LOGIN PASSWORD '{{password}}' VALID UNTIL '{{expiration}}';GRANT "foo-role" TO "{{name}}";ALTER ROLE "{{name}}" SET search_path = foo;GRANT CONNECT ON DATABASE "postgres" TO "{{name}}";` - - jsonExpected := []string{ - `DO $$ -BEGIN - IF NOT EXISTS (SELECT * FROM pg_catalog.pg_roles WHERE rolname='foo-role') THEN - CREATE ROLE "foo-role"; - CREATE SCHEMA IF NOT EXISTS foo AUTHORIZATION "foo-role"; - ALTER ROLE "foo-role" SET search_path = foo; - GRANT TEMPORARY ON DATABASE "postgres" TO "foo-role"; - GRANT ALL PRIVILEGES ON SCHEMA foo TO "foo-role"; - GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA foo TO "foo-role"; - GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA foo TO "foo-role"; - GRANT ALL PRIVILEGES ON ALL FUNCTIONS IN SCHEMA foo TO "foo-role"; - END IF; -END -$$`, - `CREATE ROLE "{{name}}" WITH LOGIN PASSWORD '{{password}}' VALID UNTIL '{{expiration}}'`, - `GRANT "foo-role" TO "{{name}}"`, - `ALTER ROLE "{{name}}" SET search_path = foo`, - `GRANT CONNECT ON DATABASE "postgres" TO "{{name}}"`, - ``, - } - - nonJSONExpected := jsonExpected[1:] - - var actual []string - var inputB64 string - var err error - - // Test non-JSON string - actual = ParseArbitraryStringSlice(input, ";") - if !reflect.DeepEqual(nonJSONExpected, actual) { - t.Fatalf("bad: expected:\n%#v\nactual:\n%#v", nonJSONExpected, actual) - } - - // Test base64-encoded non-JSON string - inputB64 = base64.StdEncoding.EncodeToString([]byte(input)) - actual = ParseArbitraryStringSlice(inputB64, ";") - if !reflect.DeepEqual(nonJSONExpected, actual) { - t.Fatalf("bad: expected:\n%#v\nactual:\n%#v", nonJSONExpected, actual) - } - - // Test JSON encoded - inputJSON, err := json.Marshal(jsonExpected) - if err != nil { - t.Fatal(err) - } - - actual = ParseArbitraryStringSlice(string(inputJSON), ";") - if !reflect.DeepEqual(jsonExpected, actual) { - t.Fatalf("bad: expected:\n%#v\nactual:\n%#v", string(inputJSON), actual) - } - - // Test base64 encoded JSON string of = tuples - inputB64 = base64.StdEncoding.EncodeToString(inputJSON) - actual = ParseArbitraryStringSlice(inputB64, ";") - if !reflect.DeepEqual(jsonExpected, actual) { - t.Fatalf("bad: expected:\n%#v\nactual:\n%#v", jsonExpected, actual) - } -} - -func TestGlobbedStringsMatch(t *testing.T) { - type tCase struct { - item string - val string - expect bool - } - - tCases := []tCase{ - {"", "", true}, - {"*", "*", true}, - {"**", "**", true}, - {"*t", "t", true}, - {"*t", "test", true}, - {"t*", "test", true}, - {"*test", "test", true}, - {"*test", "a test", true}, - {"test", "a test", false}, - {"*test", "tests", false}, - {"test*", "test", true}, - {"test*", "testsss", true}, - {"test**", "testsss", false}, - {"test**", "test*", true}, - {"**test", "*test", true}, - {"TEST", "test", false}, - {"test", "test", true}, - } - - for _, tc := range tCases { - actual := GlobbedStringsMatch(tc.item, tc.val) - - if actual != tc.expect { - t.Fatalf("Bad testcase %#v, expected %t, got %t", tc, tc.expect, actual) - } - } -} - -func TestTrimStrings(t *testing.T) { - input := []string{"abc", "123", "abcd ", "123 "} - expected := []string{"abc", "123", "abcd", "123"} - actual := TrimStrings(input) - if !reflect.DeepEqual(expected, actual) { - t.Fatalf("Bad TrimStrings: expected:%#v, got:%#v", expected, actual) - } -} - -func TestRemoveEmpty(t *testing.T) { - input := []string{"abc", "", "abc", ""} - expected := []string{"abc", "abc"} - actual := RemoveEmpty(input) - if !reflect.DeepEqual(expected, actual) { - t.Fatalf("Bad TrimStrings: expected:%#v, got:%#v", expected, actual) - } - - input = []string{""} - expected = []string{} - actual = RemoveEmpty(input) - if !reflect.DeepEqual(expected, actual) { - t.Fatalf("Bad TrimStrings: expected:%#v, got:%#v", expected, actual) - } -} - -func TestStrutil_AppendIfMissing(t *testing.T) { - keys := []string{} - - keys = AppendIfMissing(keys, "foo") - - if len(keys) != 1 { - t.Fatalf("expected slice to be length of 1: %v", keys) - } - if keys[0] != "foo" { - t.Fatalf("expected slice to contain key 'foo': %v", keys) - } - - keys = AppendIfMissing(keys, "bar") - - if len(keys) != 2 { - t.Fatalf("expected slice to be length of 2: %v", keys) - } - if keys[0] != "foo" { - t.Fatalf("expected slice to contain key 'foo': %v", keys) - } - if keys[1] != "bar" { - t.Fatalf("expected slice to contain key 'bar': %v", keys) - } - - keys = AppendIfMissing(keys, "foo") - - if len(keys) != 2 { - t.Fatalf("expected slice to still be length of 2: %v", keys) - } - if keys[0] != "foo" { - t.Fatalf("expected slice to still contain key 'foo': %v", keys) - } - if keys[1] != "bar" { - t.Fatalf("expected slice to still contain key 'bar': %v", keys) - } -} - -func TestStrUtil_RemoveDuplicates(t *testing.T) { - type tCase struct { - input []string - expect []string - lowercase bool - } - - tCases := []tCase{ - {[]string{}, []string{}, false}, - {[]string{}, []string{}, true}, - {[]string{"a", "b", "a"}, []string{"a", "b"}, false}, - {[]string{"A", "b", "a"}, []string{"A", "a", "b"}, false}, - {[]string{"A", "b", "a"}, []string{"a", "b"}, true}, - } - - for _, tc := range tCases { - actual := RemoveDuplicates(tc.input, tc.lowercase) - - if !reflect.DeepEqual(actual, tc.expect) { - t.Fatalf("Bad testcase %#v, expected %v, got %v", tc, tc.expect, actual) - } - } -} - -func TestStrUtil_RemoveDuplicatesStable(t *testing.T) { - type tCase struct { - input []string - expect []string - caseInsensitive bool - } - - tCases := []tCase{ - {[]string{}, []string{}, false}, - {[]string{}, []string{}, true}, - {[]string{"a", "b", "a"}, []string{"a", "b"}, false}, - {[]string{"A", "b", "a"}, []string{"A", "b", "a"}, false}, - {[]string{"A", "b", "a"}, []string{"A", "b"}, true}, - {[]string{" ", "d", "c", "d"}, []string{"d", "c"}, false}, - {[]string{"Z ", " z", " z ", "y"}, []string{"Z ", "y"}, true}, - {[]string{"Z ", " z", " z ", "y"}, []string{"Z ", " z", "y"}, false}, - } - - for _, tc := range tCases { - actual := RemoveDuplicatesStable(tc.input, tc.caseInsensitive) - - if !reflect.DeepEqual(actual, tc.expect) { - t.Fatalf("Bad testcase %#v, expected %v, got %v", tc, tc.expect, actual) - } - } -} - -func TestStrUtil_ParseStringSlice(t *testing.T) { - type tCase struct { - input string - sep string - expect []string - } - - tCases := []tCase{ - {"", "", []string{}}, - {" ", ",", []string{}}, - {", ", ",", []string{"", ""}}, - {"a", ",", []string{"a"}}, - {" a, b, c ", ",", []string{"a", "b", "c"}}, - {" a; b; c ", ";", []string{"a", "b", "c"}}, - {" a :: b :: c ", "::", []string{"a", "b", "c"}}, - } - - for _, tc := range tCases { - actual := ParseStringSlice(tc.input, tc.sep) - - if !reflect.DeepEqual(actual, tc.expect) { - t.Fatalf("Bad testcase %#v, expected %v, got %v", tc, tc.expect, actual) - } - } -} - -func TestStrUtil_MergeSlices(t *testing.T) { - res := MergeSlices([]string{"a", "c", "d"}, []string{}, []string{"c", "f", "a"}, nil, []string{"foo"}) - - expect := []string{"a", "c", "d", "f", "foo"} - - if !reflect.DeepEqual(res, expect) { - t.Fatalf("expected %v, got %v", expect, res) - } -} - -func TestDifference(t *testing.T) { - testCases := []struct { - Name string - SetA []string - SetB []string - Lowercase bool - ExpectedResult []string - }{ - { - Name: "case_sensitive", - SetA: []string{"a", "b", "c"}, - SetB: []string{"b", "c"}, - Lowercase: false, - ExpectedResult: []string{"a"}, - }, - { - Name: "case_insensitive", - SetA: []string{"a", "B", "c"}, - SetB: []string{"b", "C"}, - Lowercase: true, - ExpectedResult: []string{"a"}, - }, - { - Name: "no_match", - SetA: []string{"a", "b", "c"}, - SetB: []string{"d"}, - Lowercase: false, - ExpectedResult: []string{"a", "b", "c"}, - }, - { - Name: "empty_set_a", - SetA: []string{}, - SetB: []string{"d", "e"}, - Lowercase: false, - ExpectedResult: []string{}, - }, - { - Name: "empty_set_b", - SetA: []string{"a", "b"}, - SetB: []string{}, - Lowercase: false, - ExpectedResult: []string{"a", "b"}, - }, - } - - for _, tc := range testCases { - t.Run(tc.Name, func(t *testing.T) { - actualResult := Difference(tc.SetA, tc.SetB, tc.Lowercase) - - if !reflect.DeepEqual(actualResult, tc.ExpectedResult) { - t.Fatalf("expected %v, got %v", tc.ExpectedResult, actualResult) - } - }) - } -} - -func TestStrUtil_EqualStringMaps(t *testing.T) { - m1 := map[string]string{ - "foo": "a", - } - m2 := map[string]string{ - "foo": "a", - "bar": "b", - } - var m3 map[string]string - - m4 := map[string]string{ - "dog": "", - } - - m5 := map[string]string{ - "cat": "", - } - - tests := []struct { - a map[string]string - b map[string]string - result bool - }{ - {m1, m1, true}, - {m2, m2, true}, - {m1, m2, false}, - {m2, m1, false}, - {m2, m2, true}, - {m3, m1, false}, - {m3, m3, true}, - {m4, m5, false}, - } - - for i, test := range tests { - actual := EqualStringMaps(test.a, test.b) - if actual != test.result { - t.Fatalf("case %d, expected %v, got %v", i, test.result, actual) - } - } -} - -func TestPrintable(t *testing.T) { - cases := []struct { - input string - err bool - }{ - { - input: "/valid", - }, - { - input: "foobarvalid", - }, - { - input: "/invalid\u000A", - err: true, - }, - { - input: "/invalid\u000D", - err: true, - }, - { - input: "/invalid\u0000", - err: true, - }, - } - - for i, tc := range cases { - t.Run(fmt.Sprint(i), func(t *testing.T) { - require.True(t, Printable(tc.input) != tc.err) - }) - } -} - -func TestReverse(t *testing.T) { - cases := []struct { - in string - out string - }{ - { - in: "abc", - out: "cba", - }, - { - in: "abcd", - out: "dcba", - }, - } - - for i, tc := range cases { - t.Run(fmt.Sprint(i), func(t *testing.T) { - require.Equal(t, Reverse(tc.in), tc.out) - }) - } -} diff --git a/sdk/wrapper/wrapper.go b/sdk/wrapper/wrapper.go index 4194167356..10513e4440 100644 --- a/sdk/wrapper/wrapper.go +++ b/sdk/wrapper/wrapper.go @@ -3,9 +3,9 @@ package wrapper import ( "fmt" - "github.com/hashicorp/boundary/sdk/strutil" wrapping "github.com/hashicorp/go-kms-wrapping" "github.com/hashicorp/shared-secure-libs/configutil" + "github.com/hashicorp/shared-secure-libs/strutil" ) func GetWrapperFromPath(path, purpose string) (wrapping.Wrapper, error) {