diff --git a/go.mod b/go.mod index 917c63c..2ca6d1a 100644 --- a/go.mod +++ b/go.mod @@ -25,11 +25,11 @@ require ( github.com/honeycombio/otel-config-go v1.13.1 github.com/huandu/xstrings v1.4.0 github.com/keptn/go-utils v0.20.4 - github.com/kubeshop/botkube v0.13.1-0.20240527133334-a3f727e2a30f + github.com/kubeshop/botkube v0.13.1-0.20240703085645-9b6b3cea3322 github.com/muesli/reflow v0.3.0 github.com/olekukonko/tablewriter v0.0.5 github.com/prometheus/client_golang v1.16.0 - github.com/sashabaranov/go-openai v1.23.0 + github.com/sashabaranov/go-openai v1.26.2 github.com/sirupsen/logrus v1.9.3 github.com/slack-go/slack v0.12.2 github.com/spf13/pflag v1.0.5 @@ -215,7 +215,3 @@ require ( sigs.k8s.io/kustomize/kyaml v0.14.3-0.20230601165947-6ce0bf390ce3 // indirect sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect ) - -// We need the following PRs to be merged to switch to the official client: -// - https://github.com/sashabaranov/go-openai/pull/760 -replace github.com/sashabaranov/go-openai => github.com/kubeshop/go-openai v0.0.0-20240610112923-333400b567ea diff --git a/go.sum b/go.sum index f8a9f63..818a356 100644 --- a/go.sum +++ b/go.sum @@ -667,10 +667,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/kubeshop/botkube v0.13.1-0.20240527133334-a3f727e2a30f h1:vnOhS1p8eJkxSiqc0ms7NSNLwRmxbK58k4Ig1DX7b6U= -github.com/kubeshop/botkube v0.13.1-0.20240527133334-a3f727e2a30f/go.mod h1:OZeY4kLDrVQlaGxCE3XnTX8UUUhSpENIZ41PmBVIePg= -github.com/kubeshop/go-openai v0.0.0-20240610112923-333400b567ea h1:CTZdRegDi3HHx7FLy+uPiCAbei6fHYenfaRvx5A/zRI= -github.com/kubeshop/go-openai v0.0.0-20240610112923-333400b567ea/go.mod h1:lj5b/K+zjTSFxVLijLSTDZuP7adOgerWeFyZLUhAKRg= +github.com/kubeshop/botkube v0.13.1-0.20240703085645-9b6b3cea3322 h1:JauACf28uCl6LElRulzVNPq+GFxVBk9avcS4+GkoGwU= +github.com/kubeshop/botkube v0.13.1-0.20240703085645-9b6b3cea3322/go.mod h1:OZeY4kLDrVQlaGxCE3XnTX8UUUhSpENIZ41PmBVIePg= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q= github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4= @@ -825,6 +823,8 @@ github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFo github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc= github.com/sanity-io/litter v1.5.5 h1:iE+sBxPBzoK6uaEP5Lt3fHNgpKcHXc/A2HGETy0uJQo= github.com/sanity-io/litter v1.5.5/go.mod h1:9gzJgR2i4ZpjZHsKvUXIRQVk7P+yM3e+jAF7bU2UI5U= +github.com/sashabaranov/go-openai v1.26.2 h1:cVlQa3gn3eYqNXRW03pPlpy6zLG52EU4g0FrWXc0EFI= +github.com/sashabaranov/go-openai v1.26.2/go.mod h1:lj5b/K+zjTSFxVLijLSTDZuP7adOgerWeFyZLUhAKRg= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= diff --git a/internal/source/ai-brain/botkube_tools.go b/internal/source/ai-brain/botkube_tools.go index c090721..917d774 100644 --- a/internal/source/ai-brain/botkube_tools.go +++ b/internal/source/ai-brain/botkube_tools.go @@ -16,8 +16,7 @@ import ( ) const ( - healthURLFmt = "http://127.0.0.1:%s/healthz" - redactedSecretStr = "*** REDACTED ***" + healthURLFmt = "http://127.0.0.1:%s/healthz" ) // BotkubeRunner is a runner that executes Botkube related commands. @@ -133,10 +132,9 @@ func (r *BotkubeRunner) fetchConfig(ctx context.Context) (string, *ConfigWithDet return "", nil, fmt.Errorf("configuration cannot be nil") } - cfg = r.redactSensitiveInfo(cfg) - + redactedCfg := config.HideSensitiveInfo(*cfg) cfgWithDetails := ConfigWithDetails{ - Config: cfg, + Config: &redactedCfg, } if details.ValidateWarnings != nil { cfgWithDetails.LoaderValidationWarnings = details.ValidateWarnings.Error() @@ -150,27 +148,6 @@ func (r *BotkubeRunner) fetchConfig(ctx context.Context) (string, *ConfigWithDet return string(rawCfg), &cfgWithDetails, nil } -// copied from: https://github.com/kubeshop/botkube/blob/796493b9f8949a038b88de56ab3da90390728ccc/pkg/execute/config.go#L64-L79 -// TODO: avoid printing sensitive data without need to resetting them manually (which is an error-prone approach) -func (r *BotkubeRunner) redactSensitiveInfo(cfg *config.Config) *config.Config { - for key, val := range cfg.Communications { - val.SocketSlack.AppToken = redactedSecretStr - val.SocketSlack.BotToken = redactedSecretStr - val.Elasticsearch.Password = redactedSecretStr - val.Discord.Token = redactedSecretStr - val.Mattermost.Token = redactedSecretStr - val.CloudSlack.Token = redactedSecretStr - - // To keep the printed config readable, we don't print the certificate bytes. - val.CloudSlack.Server.TLS.CACertificate = nil - val.CloudTeams.Server.TLS.CACertificate = nil - - // maps are not addressable - cfg.Communications[key] = val - } - return cfg -} - func getPlatform(msgID string) *string { if msgID == "" { return nil