From 5870768c888b0db2ec5dab68805206e76e320aca Mon Sep 17 00:00:00 2001 From: rosstimothy <39066650+rosstimothy@users.noreply.github.com> Date: Wed, 22 Apr 2026 11:54:43 -0400 Subject: [PATCH] Stop using text/template and html/template to enable DCE (#65401) All existing template usage was converted to make use of github.com/DataDog/datadog-agent/pkg/template. The DataDog package is a fork of the stdlib template packages with method calling removed so that reflect.MethodByName does not prevent DCE. There were a handful of method calls in our templates that were trivially changed to use custom functions defined via FuncMaps or specifying the calculated value to the template instead of calling a function in the template. A future change will add linter rules to prevent new text/template or html/imports from landing. They have not been included here so as to not to break enterprise code while it is migrated. --- build.assets/tooling/cmd/apiversion/main.go | 2 +- build.assets/tooling/cmd/gen-athena-docs/main.go | 4 +++- .../cmd/gen-athena-docs/schema-reference.mdx.tmpl | 2 +- .../tooling/cmd/render-helm-ref/template.go | 2 +- .../tooling/cmd/resource-ref-generator/main.go | 2 +- .../resource-ref-generator/reference/reference.go | 3 ++- build.assets/tooling/go.mod | 1 + build.assets/tooling/go.sum | 2 ++ build.assets/tooling/lib/eventschema/dump.go | 2 +- e2e/runner/cmd/gen-ts-fixtures/main.go | 2 +- e2e/runner/go.mod | 1 + e2e/runner/go.sum | 2 ++ e2e/runner/teleport.go | 3 ++- go.mod | 1 + go.sum | 2 ++ integrations/access/accessrequest/message.go | 8 ++++---- integrations/access/datadog/bot.go | 2 +- integrations/access/email/client.go | 8 ++++---- integrations/access/jira/client.go | 14 +++++++------- integrations/access/mattermost/bot.go | 8 ++++---- integrations/access/msteams/configure.go | 2 +- integrations/access/opsgenie/client.go | 14 +++++++------- integrations/access/pagerduty/client.go | 14 +++++++------- integrations/access/servicenow/client.go | 12 ++++++------ integrations/event-handler/go.mod | 1 + integrations/event-handler/go.sum | 2 ++ integrations/event-handler/lib/templates.go | 2 +- .../kube-agent-updater/hack/cosign-fixtures.go | 2 +- integrations/operator/crdgen/format.go | 2 +- integrations/terraform-mwi/go.mod | 1 + integrations/terraform-mwi/go.sum | 2 ++ integrations/terraform/gen/main.go | 3 ++- integrations/terraform/go.mod | 1 + integrations/terraform/go.sum | 2 ++ integrations/terraform/provider/credentials.go | 2 +- lib/auth/bot_test.go | 2 +- lib/auth/desktop.go | 2 +- lib/autoupdate/agent/setup.go | 2 +- lib/autoupdate/package_url.go | 2 +- lib/client/db/oracle/config.go | 2 +- lib/cloud/provisioning/operations.go | 11 +++++++---- lib/config/database.go | 10 ++++++---- lib/config/openssh/openssh.go | 2 +- lib/config/systemd/systemd.go | 2 +- lib/join/join_iam_test.go | 2 +- lib/kube/kubeconfig/context_overwrite.go | 2 +- lib/kube/proxy/resource_filters_test.go | 2 +- lib/kube/proxy/resource_list_test.go | 2 +- lib/openssh/sshd.go | 2 +- lib/puttyhosts/puttyhosts.go | 2 +- lib/saml/request.go | 2 +- lib/srv/db/common/kerberos/kinit/kinit.go | 2 +- lib/srv/server/installer/defaultinstallers_test.go | 2 +- lib/tbot/config/systemd/template.go | 3 ++- lib/tbot/services/k8s/argocd_output.go | 2 +- lib/utils/aws/region/internal/codegen.go | 2 +- lib/vnet/opensshconfig.go | 2 +- lib/web/apiserver.go | 2 +- lib/web/app/redirect.go | 2 +- lib/web/mwi_wizards.go | 2 +- lib/web/scripts/database.go | 3 ++- lib/web/scripts/install_node.go | 2 +- lib/web/scripts/oneoff/oneoff.go | 2 +- session/selinux/selinux_linux.go | 2 +- session/selinux/selinux_test.go | 2 +- tool/tbot/keypair.go | 2 +- tool/tctl/common/app_command.go | 2 +- tool/tctl/common/auth_command.go | 2 +- tool/tctl/common/bots_command.go | 2 +- tool/tctl/common/db_command.go | 2 +- tool/tctl/common/desktop_command.go | 2 +- tool/tctl/common/kube_command.go | 2 +- tool/tctl/common/node_command.go | 2 +- tool/tctl/common/token_command.go | 2 +- tool/tsh/common/app.go | 2 +- tool/tsh/common/db.go | 2 +- tool/tsh/common/kube_proxy.go | 2 +- tool/tsh/common/mcp_db.go | 2 +- tool/tsh/common/proxy.go | 2 +- tool/tsh/common/proxy_test.go | 2 +- 80 files changed, 136 insertions(+), 106 deletions(-) diff --git a/build.assets/tooling/cmd/apiversion/main.go b/build.assets/tooling/cmd/apiversion/main.go index 6583c1ca133..a01a56fdb3b 100644 --- a/build.assets/tooling/cmd/apiversion/main.go +++ b/build.assets/tooling/cmd/apiversion/main.go @@ -19,8 +19,8 @@ package main import ( "fmt" "os" - "text/template" + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/coreos/go-semver/semver" ) diff --git a/build.assets/tooling/cmd/gen-athena-docs/main.go b/build.assets/tooling/cmd/gen-athena-docs/main.go index ce2f58c8d1d..a542467aab1 100644 --- a/build.assets/tooling/cmd/gen-athena-docs/main.go +++ b/build.assets/tooling/cmd/gen-athena-docs/main.go @@ -23,10 +23,11 @@ import ( "regexp" "slices" "strings" - "text/template" "unicode" "unicode/utf8" + template "github.com/DataDog/datadog-agent/pkg/template/text" + "github.com/gravitational/teleport/gen/go/eventschema" ) @@ -81,6 +82,7 @@ func main() { template.FuncMap{ "ColNameList": colNameList, "PrepareDescription": prepareDescription, + "NameSQL": func(c *eventschema.ColumnSchemaDetails) string { return c.NameSQL() }, }, ).Parse(docTempl)).Execute(os.Stdout, data) } diff --git a/build.assets/tooling/cmd/gen-athena-docs/schema-reference.mdx.tmpl b/build.assets/tooling/cmd/gen-athena-docs/schema-reference.mdx.tmpl index 26c1f988e94..36dedc971d7 100644 --- a/build.assets/tooling/cmd/gen-athena-docs/schema-reference.mdx.tmpl +++ b/build.assets/tooling/cmd/gen-athena-docs/schema-reference.mdx.tmpl @@ -20,7 +20,7 @@ Columns: |SQL Name|Type|Description| |---|---|---| {{- range .Columns }} -|{{ .NameSQL }}|{{ .Type }}|{{ PrepareDescription . }}| +|{{ NameSQL . }}|{{ .Type }}|{{ PrepareDescription . }}| {{- end }} {{ end }} diff --git a/build.assets/tooling/cmd/render-helm-ref/template.go b/build.assets/tooling/cmd/render-helm-ref/template.go index 0bff3775c94..10168526e2d 100644 --- a/build.assets/tooling/cmd/render-helm-ref/template.go +++ b/build.assets/tooling/cmd/render-helm-ref/template.go @@ -20,8 +20,8 @@ package main import ( "bytes" - "text/template" + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/Masterminds/sprig/v3" "github.com/gravitational/trace" ) diff --git a/build.assets/tooling/cmd/resource-ref-generator/main.go b/build.assets/tooling/cmd/resource-ref-generator/main.go index 0c04e835878..170d20f6053 100644 --- a/build.assets/tooling/cmd/resource-ref-generator/main.go +++ b/build.assets/tooling/cmd/resource-ref-generator/main.go @@ -21,8 +21,8 @@ import ( "fmt" "os" "path/filepath" - "text/template" + template "github.com/DataDog/datadog-agent/pkg/template/text" "gopkg.in/yaml.v3" "github.com/gravitational/teleport/build.assets/tooling/cmd/resource-ref-generator/reference" diff --git a/build.assets/tooling/cmd/resource-ref-generator/reference/reference.go b/build.assets/tooling/cmd/resource-ref-generator/reference/reference.go index 78247dd0e50..9d3e005e783 100644 --- a/build.assets/tooling/cmd/resource-ref-generator/reference/reference.go +++ b/build.assets/tooling/cmd/resource-ref-generator/reference/reference.go @@ -22,7 +22,8 @@ import ( "os" "path/filepath" "strings" - "text/template" + + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/gravitational/teleport/build.assets/tooling/cmd/resource-ref-generator/resource" ) diff --git a/build.assets/tooling/go.mod b/build.assets/tooling/go.mod index 2670795d0ed..2c501618655 100644 --- a/build.assets/tooling/go.mod +++ b/build.assets/tooling/go.mod @@ -4,6 +4,7 @@ go 1.25.9 require ( buf.build/go/bufplugin v0.9.0 + github.com/DataDog/datadog-agent/pkg/template v0.77.2 github.com/Masterminds/sprig/v3 v3.3.0 github.com/alecthomas/kingpin/v2 v2.4.0 github.com/awalterschulze/goderive v0.5.1 diff --git a/build.assets/tooling/go.sum b/build.assets/tooling/go.sum index 24723f5852e..6c186e2f7c1 100644 --- a/build.assets/tooling/go.sum +++ b/build.assets/tooling/go.sum @@ -96,6 +96,8 @@ github.com/AzureAD/microsoft-authentication-library-for-go v1.6.0 h1:XRzhVemXdgv github.com/AzureAD/microsoft-authentication-library-for-go v1.6.0/go.mod h1:HKpQxkWaGLJ+D/5H8QRpyQXA1eKjxkFlOMwck5+33Jk= github.com/BurntSushi/toml v1.6.0 h1:dRaEfpa2VI55EwlIW72hMRHdWouJeRF7TPYhI+AUQjk= github.com/BurntSushi/toml v1.6.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= +github.com/DataDog/datadog-agent/pkg/template v0.77.2 h1:jykra+J/uDkVr/LfnNvHLT7YY51Q8RcH7GnCh01rnKA= +github.com/DataDog/datadog-agent/pkg/template v0.77.2/go.mod h1:ZUjICHSlN0of0cmWrYk9Pof0DV0eqHSpTUK1NTnN26Y= github.com/MakeNowJust/heredoc v1.0.0 h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ4pzQ= github.com/MakeNowJust/heredoc v1.0.0/go.mod h1:mG5amYoWBHf8vpLOuehzbGGw0EHxpZZ6lCpQ4fNJ8LE= github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI= diff --git a/build.assets/tooling/lib/eventschema/dump.go b/build.assets/tooling/lib/eventschema/dump.go index 76cb5b6fecc..a0f11b35702 100644 --- a/build.assets/tooling/lib/eventschema/dump.go +++ b/build.assets/tooling/lib/eventschema/dump.go @@ -24,8 +24,8 @@ import ( "go/format" "sort" "strings" - "text/template" + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/Masterminds/sprig/v3" "github.com/gravitational/trace" v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" diff --git a/e2e/runner/cmd/gen-ts-fixtures/main.go b/e2e/runner/cmd/gen-ts-fixtures/main.go index aa0c691a28f..dcf3037bc80 100644 --- a/e2e/runner/cmd/gen-ts-fixtures/main.go +++ b/e2e/runner/cmd/gen-ts-fixtures/main.go @@ -23,7 +23,7 @@ import ( "fmt" "os" "path/filepath" - "text/template" + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/gravitational/teleport/e2e/runner/fixtures" ) diff --git a/e2e/runner/go.mod b/e2e/runner/go.mod index 4b2c13e6872..895192bb97b 100644 --- a/e2e/runner/go.mod +++ b/e2e/runner/go.mod @@ -3,6 +3,7 @@ module github.com/gravitational/teleport/e2e/runner go 1.25.9 require ( + github.com/DataDog/datadog-agent/pkg/template v0.77.2 github.com/docker/go-sdk/container v0.1.0-alpha013 github.com/google/go-github/v84 v84.0.0 github.com/gravitational/teleport v0.0.0-00010101000000-000000000000 diff --git a/e2e/runner/go.sum b/e2e/runner/go.sum index c0eae5530ba..3eaea09d4db 100644 --- a/e2e/runner/go.sum +++ b/e2e/runner/go.sum @@ -82,6 +82,8 @@ github.com/AzureAD/microsoft-authentication-library-for-go v1.6.0 h1:XRzhVemXdgv github.com/AzureAD/microsoft-authentication-library-for-go v1.6.0/go.mod h1:HKpQxkWaGLJ+D/5H8QRpyQXA1eKjxkFlOMwck5+33Jk= github.com/BurntSushi/toml v1.6.0 h1:dRaEfpa2VI55EwlIW72hMRHdWouJeRF7TPYhI+AUQjk= github.com/BurntSushi/toml v1.6.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= +github.com/DataDog/datadog-agent/pkg/template v0.77.2 h1:jykra+J/uDkVr/LfnNvHLT7YY51Q8RcH7GnCh01rnKA= +github.com/DataDog/datadog-agent/pkg/template v0.77.2/go.mod h1:ZUjICHSlN0of0cmWrYk9Pof0DV0eqHSpTUK1NTnN26Y= github.com/MakeNowJust/heredoc v1.0.0 h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ4pzQ= github.com/MakeNowJust/heredoc v1.0.0/go.mod h1:mG5amYoWBHf8vpLOuehzbGGw0EHxpZZ6lCpQ4fNJ8LE= github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI= diff --git a/e2e/runner/teleport.go b/e2e/runner/teleport.go index 99d50f50e33..e2496766d75 100644 --- a/e2e/runner/teleport.go +++ b/e2e/runner/teleport.go @@ -31,8 +31,9 @@ import ( "path/filepath" "strings" "syscall" - "text/template" "time" + + template "github.com/DataDog/datadog-agent/pkg/template/text" ) // clusterName is the name of the Teleport cluster used for E2E testing. diff --git a/go.mod b/go.mod index 8a4ace151b2..3130f7f30b4 100644 --- a/go.mod +++ b/go.mod @@ -46,6 +46,7 @@ require ( github.com/ClickHouse/ch-go v0.69.0 github.com/ClickHouse/clickhouse-go/v2 v2.37.2 github.com/DanielTitkov/go-adaptive-cards v0.2.2 + github.com/DataDog/datadog-agent/pkg/template v0.77.2 github.com/HdrHistogram/hdrhistogram-go v1.2.0 github.com/Masterminds/sprig/v3 v3.3.0 github.com/Microsoft/go-winio v0.6.2 diff --git a/go.sum b/go.sum index 39cef3c8139..3a23f0b291a 100644 --- a/go.sum +++ b/go.sum @@ -130,6 +130,8 @@ github.com/DATA-DOG/go-sqlmock v1.5.2 h1:OcvFkGmslmlZibjAjaHm3L//6LiuBgolP7Oputl github.com/DATA-DOG/go-sqlmock v1.5.2/go.mod h1:88MAG/4G7SMwSE3CeA0ZKzrT5CiOU3OJ+JlNzwDqpNU= github.com/DanielTitkov/go-adaptive-cards v0.2.2 h1:tBFExyvsbCcrBJEvPaV3FW4gcAkwQjXFKiKEBrE7Yuw= github.com/DanielTitkov/go-adaptive-cards v0.2.2/go.mod h1:RtCzt65p/zEos6+zhiCFQmiaHmro6M63l9NP7xXx/Lg= +github.com/DataDog/datadog-agent/pkg/template v0.77.2 h1:jykra+J/uDkVr/LfnNvHLT7YY51Q8RcH7GnCh01rnKA= +github.com/DataDog/datadog-agent/pkg/template v0.77.2/go.mod h1:ZUjICHSlN0of0cmWrYk9Pof0DV0eqHSpTUK1NTnN26Y= github.com/GoogleCloudPlatform/grpc-gcp-go/grpcgcp v1.6.0 h1:BzsL0qE7LvtTEtXG7Dt5NS1EP0CQwI21HZfj9aGghhw= github.com/GoogleCloudPlatform/grpc-gcp-go/grpcgcp v1.6.0/go.mod h1:I7kE2kM3qCr9QPT4cU4cCFYkEpVyVr16YOGUHzy+nR0= github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.31.0 h1:DHa2U07rk8syqvCge0QIGMCE1WxGj9njT44GH7zNJLQ= diff --git a/integrations/access/accessrequest/message.go b/integrations/access/accessrequest/message.go index 41d47f95811..391ff82bff3 100644 --- a/integrations/access/accessrequest/message.go +++ b/integrations/access/accessrequest/message.go @@ -23,9 +23,9 @@ import ( "net/url" "slices" "strings" - "text/template" "time" + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/gravitational/trace" "github.com/gravitational/teleport/api/types" @@ -44,7 +44,7 @@ const ( ) var reviewReplyTemplate = template.Must(template.New("review reply").Parse( - `{{.Author}} reviewed the request at {{.Created.Format .TimeFormat}}. + `{{.Author}} reviewed the request at {{.CreatedTime}}. Resolution: {{.ProposedStateEmoji}} {{.ProposedState}}. {{if .Reason}}Reason: {{.Reason}}{{end}}`, )) @@ -138,12 +138,12 @@ func MsgReview(review types.AccessReview) (string, error) { types.AccessReview ProposedState string ProposedStateEmoji string - TimeFormat string + CreatedTime string }{ review, review.ProposedState.String(), proposedStateEmoji, - time.RFC822, + review.Created.Format(time.RFC822), }) if err != nil { return "", trace.Wrap(err) diff --git a/integrations/access/datadog/bot.go b/integrations/access/datadog/bot.go index c219e72aec7..2ae17f00777 100644 --- a/integrations/access/datadog/bot.go +++ b/integrations/access/datadog/bot.go @@ -24,8 +24,8 @@ import ( "net/url" "slices" "strings" - "text/template" + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/gravitational/trace" "github.com/gravitational/teleport/api/types" diff --git a/integrations/access/email/client.go b/integrations/access/email/client.go index 7fedbf83c26..2f5a27016d2 100644 --- a/integrations/access/email/client.go +++ b/integrations/access/email/client.go @@ -21,9 +21,9 @@ import ( "fmt" "net/url" "strings" - "text/template" "time" + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/gravitational/trace" "github.com/gravitational/teleport/api/types" @@ -33,7 +33,7 @@ import ( ) var reviewReplyTemplate = template.Must(template.New("review reply").Parse( - `{{.Author}} reviewed the request at {{.Created.Format .TimeFormat}}. + `{{.Author}} reviewed the request at {{.CreatedTime}}. Resolution: {{.ProposedStateEmoji}} {{.ProposedState}}. {{if .Reason}}Reason: {{.Reason}}.{{end}}`, )) @@ -122,12 +122,12 @@ func (c *Client) SendReview(ctx context.Context, threads []EmailThread, reqID st types.AccessReview ProposedState string ProposedStateEmoji string - TimeFormat string + CreatedTime string }{ review, review.ProposedState.String(), proposedStateEmoji, - time.RFC822, + review.Created.Format(time.RFC822), }) if err != nil { return threadsSent, trace.Wrap(err) diff --git a/integrations/access/jira/client.go b/integrations/access/jira/client.go index a23381e4d26..07512604a87 100644 --- a/integrations/access/jira/client.go +++ b/integrations/access/jira/client.go @@ -24,9 +24,9 @@ import ( "net/http" "net/url" "strings" - "text/template" "time" + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/go-resty/resty/v2" "github.com/google/go-querystring/query" "github.com/gravitational/trace" @@ -62,7 +62,7 @@ type Jira struct { } var descriptionTemplate = template.Must(template.New("description").Parse( - `User *{{.User}}* requested an access on *{{.Created.Format .TimeFormat}}* with the following roles: + `User *{{.User}}* requested an access on *{{.CreatedTime}}* with the following roles: {{range .Roles}} * {{ . }} {{end}} @@ -73,7 +73,7 @@ Request ID: *{{.ID}}* {{if .RequestLink}}To approve or deny the request, proceed to {{.RequestLink}}{{end}}`, )) var reviewCommentTemplate = template.Must(template.New("review comment").Parse( - `*{{.Author}}* reviewed the request at *{{.Created.Format .TimeFormat}}*. + `*{{.Author}}* reviewed the request at *{{.CreatedTime}}*. Resolution: *{{.ProposedState}}*. {{if .Reason}}Reason: {{.Reason}}.{{end}}`, )) @@ -291,12 +291,12 @@ func (j *Jira) buildIssueDescription(reqID string, reqData RequestData) (string, var builder strings.Builder err := descriptionTemplate.Execute(&builder, struct { ID string - TimeFormat string + CreatedTime string RequestLink string RequestData }{ reqID, - time.RFC822, + reqData.Created.Format(time.RFC822), requestLink, reqData, }) @@ -336,11 +336,11 @@ func (j *Jira) AddIssueReviewComment(ctx context.Context, id string, review type err := reviewCommentTemplate.Execute(&builder, struct { types.AccessReview ProposedState string - TimeFormat string + CreatedTime string }{ review, review.ProposedState.String(), - time.RFC822, + review.Created.Format(time.RFC822), }) if err != nil { return trace.Wrap(err) diff --git a/integrations/access/mattermost/bot.go b/integrations/access/mattermost/bot.go index 0c2559b0194..1fe18a9eba8 100644 --- a/integrations/access/mattermost/bot.go +++ b/integrations/access/mattermost/bot.go @@ -24,9 +24,9 @@ import ( "net/http" "net/url" "strings" - "text/template" "time" + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/go-resty/resty/v2" "github.com/gravitational/trace" lru "github.com/hashicorp/golang-lru/v2" @@ -61,7 +61,7 @@ var postTextTemplate = template.Must(template.New("description").Parse( )) var reviewCommentTemplate = template.Must(template.New("review comment").Parse( - `{{.Author}} reviewed the request at {{.Created.Format .TimeFormat}}. + `{{.Author}} reviewed the request at {{.CreatedTime}}. Resolution: {{.ProposedStateEmoji}} {{.ProposedState}}. {{if .Reason}}Reason: {{.Reason}}.{{end}}`, )) @@ -297,12 +297,12 @@ func (b Bot) PostReviewReply(ctx context.Context, channelID, rootID string, revi types.AccessReview ProposedState string ProposedStateEmoji string - TimeFormat string + CreatedTime string }{ review, review.ProposedState.String(), proposedStateEmoji, - time.RFC822, + review.Created.Format(time.RFC822), }) if err != nil { return trace.Wrap(err) diff --git a/integrations/access/msteams/configure.go b/integrations/access/msteams/configure.go index 9d144c4ee1f..fc656370ef7 100644 --- a/integrations/access/msteams/configure.go +++ b/integrations/access/msteams/configure.go @@ -18,12 +18,12 @@ import ( "archive/zip" "embed" "fmt" - "html/template" "io" "os" "path/filepath" "slices" + template "github.com/DataDog/datadog-agent/pkg/template/html" "github.com/google/uuid" "github.com/gravitational/trace" ) diff --git a/integrations/access/opsgenie/client.go b/integrations/access/opsgenie/client.go index ae9ad5a90af..928a45ad921 100644 --- a/integrations/access/opsgenie/client.go +++ b/integrations/access/opsgenie/client.go @@ -25,9 +25,9 @@ import ( "net/http" "net/url" "strings" - "text/template" "time" + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/go-resty/resty/v2" "github.com/google/uuid" "github.com/gravitational/trace" @@ -52,13 +52,13 @@ const ( ) var alertBodyTemplate = template.Must(template.New("alert body").Parse( - `{{.User}} requested permissions for roles {{range $index, $element := .Roles}}{{if $index}}, {{end}}{{ . }}{{end}} on Teleport at {{.Created.Format .TimeFormat}}. + `{{.User}} requested permissions for roles {{range $index, $element := .Roles}}{{if $index}}, {{end}}{{ . }}{{end}} on Teleport at {{.CreatedTime}}. {{if .RequestReason}}Reason: {{.RequestReason}}{{end}} {{if .RequestLink}}To approve or deny the request, proceed to {{.RequestLink}}{{end}} `, )) var reviewNoteTemplate = template.Must(template.New("review note").Parse( - `{{.Author}} reviewed the request at {{.Created.Format .TimeFormat}}. + `{{.Author}} reviewed the request at {{.CreatedTime}}. Resolution: {{.ProposedState}}. {{if .Reason}}Reason: {{.Reason}}.{{end}}`, )) @@ -356,12 +356,12 @@ func buildAlertBody(webProxyURL *url.URL, reqID string, reqData RequestData) (st var builder strings.Builder err := alertBodyTemplate.Execute(&builder, struct { ID string - TimeFormat string + CreatedTime string RequestLink string RequestData }{ ID: reqID, - TimeFormat: time.RFC822, + CreatedTime: reqData.Created.Format(time.RFC822), RequestLink: requestLink, RequestData: reqData, }) @@ -376,11 +376,11 @@ func buildReviewNoteBody(review types.AccessReview) (string, error) { err := reviewNoteTemplate.Execute(&builder, struct { types.AccessReview ProposedState string - TimeFormat string + CreatedTime string }{ review, review.ProposedState.String(), - time.RFC822, + review.Created.Format(time.RFC822), }) if err != nil { return "", trace.Wrap(err) diff --git a/integrations/access/pagerduty/client.go b/integrations/access/pagerduty/client.go index 3b2f3b28764..b69ac43302e 100644 --- a/integrations/access/pagerduty/client.go +++ b/integrations/access/pagerduty/client.go @@ -24,9 +24,9 @@ import ( "net/http" "net/url" "strings" - "text/template" "time" + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/go-resty/resty/v2" "github.com/google/go-querystring/query" "github.com/gravitational/trace" @@ -49,13 +49,13 @@ const ( ) var incidentBodyTemplate = template.Must(template.New("incident body").Parse( - `{{.User}} requested permissions for roles {{range $index, $element := .Roles}}{{if $index}}, {{end}}{{ . }}{{end}} on Teleport at {{.Created.Format .TimeFormat}}. + `{{.User}} requested permissions for roles {{range $index, $element := .Roles}}{{if $index}}, {{end}}{{ . }}{{end}} on Teleport at {{.CreatedTime}}. {{if .RequestReason}}Reason: {{.RequestReason}}{{end}} {{if .RequestLink}}To approve or deny the request, proceed to {{.RequestLink}}{{end}} `, )) var reviewNoteTemplate = template.Must(template.New("review note").Parse( - `{{.Author}} reviewed the request at {{.Created.Format .TimeFormat}}. + `{{.Author}} reviewed the request at {{.CreatedTime}}. Resolution: {{.ProposedState}}. {{if .Reason}}Reason: {{.Reason}}.{{end}}`, )) @@ -411,12 +411,12 @@ func (p Pagerduty) buildIncidentBody(reqID string, reqData RequestData) (string, var builder strings.Builder err := incidentBodyTemplate.Execute(&builder, struct { ID string - TimeFormat string + CreatedTime string RequestLink string RequestData }{ reqID, - time.RFC822, + reqData.Created.Format(time.RFC822), requestLink, reqData, }) @@ -431,11 +431,11 @@ func (p Pagerduty) buildReviewNoteBody(review types.AccessReview) (string, error err := reviewNoteTemplate.Execute(&builder, struct { types.AccessReview ProposedState string - TimeFormat string + CreatedTime string }{ review, review.ProposedState.String(), - time.RFC822, + review.Created.Format(time.RFC822), }) if err != nil { return "", trace.Wrap(err) diff --git a/integrations/access/servicenow/client.go b/integrations/access/servicenow/client.go index 42d630bdb55..3e3bb6c231a 100644 --- a/integrations/access/servicenow/client.go +++ b/integrations/access/servicenow/client.go @@ -25,9 +25,9 @@ import ( "net/http" "net/url" "strings" - "text/template" "time" + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/go-resty/resty/v2" "github.com/gravitational/trace" @@ -315,7 +315,7 @@ var ( `, )) reviewNoteTemplate = template.Must(template.New("review note").Parse( - `{{.Author}} reviewed the request at {{.Created.Format .TimeFormat}}. + `{{.Author}} reviewed the request at {{.CreatedTime}}. Resolution: {{.ProposedState}}. {{if .Reason}}Reason: {{.Reason}}.{{end}}`, )) @@ -340,13 +340,13 @@ func buildIncidentBody(webProxyURL *url.URL, reqID string, reqData RequestData, } err := template.Execute(&builder, struct { ID string - TimeFormat string + CreatedTime string RequestLink string ClusterName string RequestData }{ ID: reqID, - TimeFormat: time.RFC822, + CreatedTime: reqData.Created.Format(time.RFC822), RequestLink: requestLink, ClusterName: clusterName, RequestData: reqData, @@ -362,11 +362,11 @@ func buildReviewNoteBody(review types.AccessReview) (string, error) { err := reviewNoteTemplate.Execute(&builder, struct { types.AccessReview ProposedState string - TimeFormat string + CreatedTime string }{ review, review.ProposedState.String(), - time.RFC822, + review.Created.Format(time.RFC822), }) if err != nil { return "", trace.Wrap(err) diff --git a/integrations/event-handler/go.mod b/integrations/event-handler/go.mod index 90e2022bdeb..1a6aa9dca78 100644 --- a/integrations/event-handler/go.mod +++ b/integrations/event-handler/go.mod @@ -3,6 +3,7 @@ module github.com/gravitational/teleport/integrations/event-handler go 1.25.9 require ( + github.com/DataDog/datadog-agent/pkg/template v0.77.2 github.com/alecthomas/kong v1.14.0 github.com/google/uuid v1.6.0 github.com/gravitational/teleport v0.0.0-00010101000000-000000000000 diff --git a/integrations/event-handler/go.sum b/integrations/event-handler/go.sum index b5e96bab64f..918457b9b81 100644 --- a/integrations/event-handler/go.sum +++ b/integrations/event-handler/go.sum @@ -95,6 +95,8 @@ github.com/DATA-DOG/go-sqlmock v1.5.2 h1:OcvFkGmslmlZibjAjaHm3L//6LiuBgolP7Oputl github.com/DATA-DOG/go-sqlmock v1.5.2/go.mod h1:88MAG/4G7SMwSE3CeA0ZKzrT5CiOU3OJ+JlNzwDqpNU= github.com/DanielTitkov/go-adaptive-cards v0.2.2 h1:tBFExyvsbCcrBJEvPaV3FW4gcAkwQjXFKiKEBrE7Yuw= github.com/DanielTitkov/go-adaptive-cards v0.2.2/go.mod h1:RtCzt65p/zEos6+zhiCFQmiaHmro6M63l9NP7xXx/Lg= +github.com/DataDog/datadog-agent/pkg/template v0.77.2 h1:jykra+J/uDkVr/LfnNvHLT7YY51Q8RcH7GnCh01rnKA= +github.com/DataDog/datadog-agent/pkg/template v0.77.2/go.mod h1:ZUjICHSlN0of0cmWrYk9Pof0DV0eqHSpTUK1NTnN26Y= github.com/MakeNowJust/heredoc v1.0.0 h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ4pzQ= github.com/MakeNowJust/heredoc v1.0.0/go.mod h1:mG5amYoWBHf8vpLOuehzbGGw0EHxpZZ6lCpQ4fNJ8LE= github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI= diff --git a/integrations/event-handler/lib/templates.go b/integrations/event-handler/lib/templates.go index 486ceacb44d..5092f39f734 100644 --- a/integrations/event-handler/lib/templates.go +++ b/integrations/event-handler/lib/templates.go @@ -18,8 +18,8 @@ package lib import ( "io" - "text/template" + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/gravitational/trace" ) diff --git a/integrations/kube-agent-updater/hack/cosign-fixtures.go b/integrations/kube-agent-updater/hack/cosign-fixtures.go index a9a7574baaf..bf16abb80ba 100644 --- a/integrations/kube-agent-updater/hack/cosign-fixtures.go +++ b/integrations/kube-agent-updater/hack/cosign-fixtures.go @@ -31,8 +31,8 @@ import ( "log" "maps" "strings" - "text/template" + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/Masterminds/sprig/v3" "github.com/google/go-containerregistry/pkg/name" v1 "github.com/google/go-containerregistry/pkg/v1" diff --git a/integrations/operator/crdgen/format.go b/integrations/operator/crdgen/format.go index dfad2e44dde..dd02610b5c8 100644 --- a/integrations/operator/crdgen/format.go +++ b/integrations/operator/crdgen/format.go @@ -23,8 +23,8 @@ import ( "fmt" "sort" "strings" - "text/template" + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/gravitational/trace" apiextv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" "sigs.k8s.io/yaml" diff --git a/integrations/terraform-mwi/go.mod b/integrations/terraform-mwi/go.mod index 1ceb47f0efa..a24593b71b8 100644 --- a/integrations/terraform-mwi/go.mod +++ b/integrations/terraform-mwi/go.mod @@ -61,6 +61,7 @@ require ( github.com/ClickHouse/ch-go v0.69.0 // indirect github.com/ClickHouse/clickhouse-go/v2 v2.37.2 // indirect github.com/DanielTitkov/go-adaptive-cards v0.2.2 // indirect + github.com/DataDog/datadog-agent/pkg/template v0.77.2 // indirect github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.31.0 // indirect github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metric v0.54.0 // indirect github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.54.0 // indirect diff --git a/integrations/terraform-mwi/go.sum b/integrations/terraform-mwi/go.sum index 2f4b07b541c..8f10bec87ac 100644 --- a/integrations/terraform-mwi/go.sum +++ b/integrations/terraform-mwi/go.sum @@ -130,6 +130,8 @@ github.com/DATA-DOG/go-sqlmock v1.5.2 h1:OcvFkGmslmlZibjAjaHm3L//6LiuBgolP7Oputl github.com/DATA-DOG/go-sqlmock v1.5.2/go.mod h1:88MAG/4G7SMwSE3CeA0ZKzrT5CiOU3OJ+JlNzwDqpNU= github.com/DanielTitkov/go-adaptive-cards v0.2.2 h1:tBFExyvsbCcrBJEvPaV3FW4gcAkwQjXFKiKEBrE7Yuw= github.com/DanielTitkov/go-adaptive-cards v0.2.2/go.mod h1:RtCzt65p/zEos6+zhiCFQmiaHmro6M63l9NP7xXx/Lg= +github.com/DataDog/datadog-agent/pkg/template v0.77.2 h1:jykra+J/uDkVr/LfnNvHLT7YY51Q8RcH7GnCh01rnKA= +github.com/DataDog/datadog-agent/pkg/template v0.77.2/go.mod h1:ZUjICHSlN0of0cmWrYk9Pof0DV0eqHSpTUK1NTnN26Y= github.com/GoogleCloudPlatform/grpc-gcp-go/grpcgcp v1.6.0 h1:BzsL0qE7LvtTEtXG7Dt5NS1EP0CQwI21HZfj9aGghhw= github.com/GoogleCloudPlatform/grpc-gcp-go/grpcgcp v1.6.0/go.mod h1:I7kE2kM3qCr9QPT4cU4cCFYkEpVyVr16YOGUHzy+nR0= github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.31.0 h1:DHa2U07rk8syqvCge0QIGMCE1WxGj9njT44GH7zNJLQ= diff --git a/integrations/terraform/gen/main.go b/integrations/terraform/gen/main.go index 60558b2cb03..f5502cb3a2a 100644 --- a/integrations/terraform/gen/main.go +++ b/integrations/terraform/gen/main.go @@ -23,7 +23,8 @@ import ( "os" "path" "strings" - "text/template" + + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/gravitational/teleport/integrations/terraform/gen/strcase" ) diff --git a/integrations/terraform/go.mod b/integrations/terraform/go.mod index 33ed73ce3c8..8622ba4da07 100644 --- a/integrations/terraform/go.mod +++ b/integrations/terraform/go.mod @@ -4,6 +4,7 @@ go 1.25.9 // TF provider dependencies require ( + github.com/DataDog/datadog-agent/pkg/template v0.77.2 github.com/beevik/etree v1.6.0 github.com/gogo/protobuf v1.3.2 github.com/google/go-cmp v0.7.0 diff --git a/integrations/terraform/go.sum b/integrations/terraform/go.sum index 72792c973a3..b427030504f 100644 --- a/integrations/terraform/go.sum +++ b/integrations/terraform/go.sum @@ -162,6 +162,8 @@ github.com/DATA-DOG/go-sqlmock v1.5.2 h1:OcvFkGmslmlZibjAjaHm3L//6LiuBgolP7Oputl github.com/DATA-DOG/go-sqlmock v1.5.2/go.mod h1:88MAG/4G7SMwSE3CeA0ZKzrT5CiOU3OJ+JlNzwDqpNU= github.com/DanielTitkov/go-adaptive-cards v0.2.2 h1:tBFExyvsbCcrBJEvPaV3FW4gcAkwQjXFKiKEBrE7Yuw= github.com/DanielTitkov/go-adaptive-cards v0.2.2/go.mod h1:RtCzt65p/zEos6+zhiCFQmiaHmro6M63l9NP7xXx/Lg= +github.com/DataDog/datadog-agent/pkg/template v0.77.2 h1:jykra+J/uDkVr/LfnNvHLT7YY51Q8RcH7GnCh01rnKA= +github.com/DataDog/datadog-agent/pkg/template v0.77.2/go.mod h1:ZUjICHSlN0of0cmWrYk9Pof0DV0eqHSpTUK1NTnN26Y= github.com/GoogleCloudPlatform/grpc-gcp-go/grpcgcp v1.6.0 h1:BzsL0qE7LvtTEtXG7Dt5NS1EP0CQwI21HZfj9aGghhw= github.com/GoogleCloudPlatform/grpc-gcp-go/grpcgcp v1.6.0/go.mod h1:I7kE2kM3qCr9QPT4cU4cCFYkEpVyVr16YOGUHzy+nR0= github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.31.0 h1:DHa2U07rk8syqvCge0QIGMCE1WxGj9njT44GH7zNJLQ= diff --git a/integrations/terraform/provider/credentials.go b/integrations/terraform/provider/credentials.go index cf2c8891f60..364f96e1802 100644 --- a/integrations/terraform/provider/credentials.go +++ b/integrations/terraform/provider/credentials.go @@ -23,9 +23,9 @@ import ( "fmt" "log/slog" "strings" - "text/template" "time" + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/gravitational/trace" "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-log/tflog" diff --git a/lib/auth/bot_test.go b/lib/auth/bot_test.go index 989d5c9fff7..6409e1092ba 100644 --- a/lib/auth/bot_test.go +++ b/lib/auth/bot_test.go @@ -29,9 +29,9 @@ import ( "net/http" "strings" "testing" - "text/template" "time" + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" diff --git a/lib/auth/desktop.go b/lib/auth/desktop.go index 9e35409a85b..622d95a3110 100644 --- a/lib/auth/desktop.go +++ b/lib/auth/desktop.go @@ -29,8 +29,8 @@ import ( "encoding/pem" "fmt" "strconv" - "text/template" + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/gravitational/trace" "github.com/gravitational/teleport/api/client/proto" diff --git a/lib/autoupdate/agent/setup.go b/lib/autoupdate/agent/setup.go index f51366fbcd0..7ab91ae1b3d 100644 --- a/lib/autoupdate/agent/setup.go +++ b/lib/autoupdate/agent/setup.go @@ -31,8 +31,8 @@ import ( "path/filepath" "regexp" "strings" - "text/template" + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/gravitational/trace" "gopkg.in/yaml.v3" diff --git a/lib/autoupdate/package_url.go b/lib/autoupdate/package_url.go index d0da9a46160..386a52d7e08 100644 --- a/lib/autoupdate/package_url.go +++ b/lib/autoupdate/package_url.go @@ -22,8 +22,8 @@ import ( "bytes" "encoding/json" "runtime" - "text/template" + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/gravitational/trace" "gopkg.in/yaml.v3" ) diff --git a/lib/client/db/oracle/config.go b/lib/client/db/oracle/config.go index 8827b931c15..afd5c0da1b9 100644 --- a/lib/client/db/oracle/config.go +++ b/lib/client/db/oracle/config.go @@ -22,8 +22,8 @@ import ( "bytes" "os" "path/filepath" - "text/template" + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/gravitational/trace" "github.com/gravitational/teleport" diff --git a/lib/cloud/provisioning/operations.go b/lib/cloud/provisioning/operations.go index 614ea89545a..2f6b24d19ea 100644 --- a/lib/cloud/provisioning/operations.go +++ b/lib/cloud/provisioning/operations.go @@ -26,8 +26,8 @@ import ( "os" "regexp" "strings" - "text/template" + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/gravitational/trace" "github.com/gravitational/teleport/api/utils/prompt" @@ -204,15 +204,18 @@ func writeOperationPlan(config OperationConfig) error { var operationPlanTemplate = template.Must(template.New("plan"). Funcs(template.FuncMap{ // used to enumerate the action steps starting from 1 instead of 0. - "addOne": func(x int) int { return x + 1 }, + "addOne": func(x int) int { return x + 1 }, + "getSummary": func(a *Action) string { return a.GetSummary() }, + "getName": func(a *Action) string { return a.GetName() }, + "getDetails": func(a *Action) string { return a.GetDetails() }, }). Parse(` {{- printf "%q" .config.Name }} will perform the following {{ if .showStepNumbers }}actions{{ else }}action{{ end }}: {{ $global := . }} {{- range $index, $action := .config.Actions }} -{{- if $global.showStepNumbers }}{{ addOne $index }}. {{ end -}}{{$action.GetSummary}}. -{{$action.GetName}}: {{$action.GetDetails}} +{{- if $global.showStepNumbers }}{{ addOne $index }}. {{ end -}}{{getSummary $action}}. +{{getName $action}}: {{getDetails $action}} {{end -}} `)) diff --git a/lib/config/database.go b/lib/config/database.go index 07502b62343..7aa7bf8412b 100644 --- a/lib/config/database.go +++ b/lib/config/database.go @@ -22,8 +22,9 @@ import ( "bytes" "fmt" "strings" - "text/template" + "time" + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/gravitational/trace" "github.com/gravitational/teleport/api/types" @@ -36,8 +37,9 @@ import ( // databaseConfigTemplateFunc list of template functions used on the database // config template. var databaseConfigTemplateFuncs = template.FuncMap{ - "quote": quote, - "join": strings.Join, + "quote": quote, + "join": strings.Join, + "duration": func(d types.Duration) time.Duration { return d.Duration() }, } // databaseAgentConfigurationTemplate database configuration template. @@ -457,7 +459,7 @@ db_service: dynamic_labels: {{- range $name, $label := .StaticDatabaseDynamicLabels }} - name: "{{ $name }}" - period: "{{ $label.Period.Duration }}" + period: "{{ duration $label.Period }}" command: {{- range $command := $label.Command }} - {{ $command | quote }} diff --git a/lib/config/openssh/openssh.go b/lib/config/openssh/openssh.go index 50abe0daadc..d43f628e02b 100644 --- a/lib/config/openssh/openssh.go +++ b/lib/config/openssh/openssh.go @@ -21,8 +21,8 @@ package openssh import ( "io" "strings" - "text/template" + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/gravitational/trace" "github.com/gravitational/teleport" diff --git a/lib/config/systemd/systemd.go b/lib/config/systemd/systemd.go index 010318d0ce5..49255b0c489 100644 --- a/lib/config/systemd/systemd.go +++ b/lib/config/systemd/systemd.go @@ -21,8 +21,8 @@ package systemd import ( "io" "os" - "text/template" + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/gravitational/trace" "github.com/gravitational/teleport/lib/defaults" diff --git a/lib/join/join_iam_test.go b/lib/join/join_iam_test.go index 1a1b8693844..0253c455d2c 100644 --- a/lib/join/join_iam_test.go +++ b/lib/join/join_iam_test.go @@ -26,9 +26,9 @@ import ( "net/http" "strings" "testing" - "text/template" "time" + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/organizations" organizationstypes "github.com/aws/aws-sdk-go-v2/service/organizations/types" diff --git a/lib/kube/kubeconfig/context_overwrite.go b/lib/kube/kubeconfig/context_overwrite.go index 8e2bb2c20aa..59ddcffc84e 100644 --- a/lib/kube/kubeconfig/context_overwrite.go +++ b/lib/kube/kubeconfig/context_overwrite.go @@ -21,8 +21,8 @@ package kubeconfig import ( "bytes" - "text/template" + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/gravitational/trace" ) diff --git a/lib/kube/proxy/resource_filters_test.go b/lib/kube/proxy/resource_filters_test.go index 0491b7c0d5e..599c9c0b0a1 100644 --- a/lib/kube/proxy/resource_filters_test.go +++ b/lib/kube/proxy/resource_filters_test.go @@ -27,8 +27,8 @@ import ( "path/filepath" "slices" "testing" - "text/template" + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/gravitational/trace" "github.com/stretchr/testify/require" appsv1 "k8s.io/api/apps/v1" diff --git a/lib/kube/proxy/resource_list_test.go b/lib/kube/proxy/resource_list_test.go index e0e50e25baf..43433b6c21e 100644 --- a/lib/kube/proxy/resource_list_test.go +++ b/lib/kube/proxy/resource_list_test.go @@ -25,8 +25,8 @@ import ( "io" "log/slog" "testing" - "text/template" + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/stretchr/testify/require" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/lib/openssh/sshd.go b/lib/openssh/sshd.go index dd3425dd1c0..24f4768e844 100644 --- a/lib/openssh/sshd.go +++ b/lib/openssh/sshd.go @@ -27,8 +27,8 @@ import ( "os/exec" "path/filepath" "strings" - "text/template" + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/gravitational/trace" "github.com/gravitational/teleport/api/types" diff --git a/lib/puttyhosts/puttyhosts.go b/lib/puttyhosts/puttyhosts.go index 54af8a116c3..b6e21df28a3 100644 --- a/lib/puttyhosts/puttyhosts.go +++ b/lib/puttyhosts/puttyhosts.go @@ -25,8 +25,8 @@ import ( "regexp" "slices" "strings" - "text/template" + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/gravitational/trace" "golang.org/x/crypto/ssh" diff --git a/lib/saml/request.go b/lib/saml/request.go index 3ea1d1fda3b..20fbc89bf65 100644 --- a/lib/saml/request.go +++ b/lib/saml/request.go @@ -20,9 +20,9 @@ package saml import ( "bytes" - "html/template" "net/http" + template "github.com/DataDog/datadog-agent/pkg/template/html" "github.com/gravitational/trace" "github.com/gravitational/teleport/lib/httplib" diff --git a/lib/srv/db/common/kerberos/kinit/kinit.go b/lib/srv/db/common/kerberos/kinit/kinit.go index 90d2a881154..ff5d1316bb0 100644 --- a/lib/srv/db/common/kerberos/kinit/kinit.go +++ b/lib/srv/db/common/kerberos/kinit/kinit.go @@ -28,9 +28,9 @@ import ( "os/exec" "path/filepath" "strings" - "text/template" "time" + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/gravitational/trace" "github.com/jcmturner/gokrb5/v8/client" "github.com/jcmturner/gokrb5/v8/config" diff --git a/lib/srv/server/installer/defaultinstallers_test.go b/lib/srv/server/installer/defaultinstallers_test.go index 82930095dda..4020a854bda 100644 --- a/lib/srv/server/installer/defaultinstallers_test.go +++ b/lib/srv/server/installer/defaultinstallers_test.go @@ -21,8 +21,8 @@ package installer_test import ( "bytes" "testing" - "text/template" + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/stretchr/testify/require" "github.com/gravitational/teleport/api/types/installers" diff --git a/lib/tbot/config/systemd/template.go b/lib/tbot/config/systemd/template.go index da454901337..36e4be15557 100644 --- a/lib/tbot/config/systemd/template.go +++ b/lib/tbot/config/systemd/template.go @@ -20,7 +20,8 @@ package systemd import ( _ "embed" - "text/template" + + template "github.com/DataDog/datadog-agent/pkg/template/text" ) var ( diff --git a/lib/tbot/services/k8s/argocd_output.go b/lib/tbot/services/k8s/argocd_output.go index f19a7fca6f9..f211915c84b 100644 --- a/lib/tbot/services/k8s/argocd_output.go +++ b/lib/tbot/services/k8s/argocd_output.go @@ -29,9 +29,9 @@ import ( "maps" "strconv" "strings" - "text/template" "time" + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/gravitational/trace" corev1 "k8s.io/api/core/v1" kubeerrors "k8s.io/apimachinery/pkg/api/errors" diff --git a/lib/utils/aws/region/internal/codegen.go b/lib/utils/aws/region/internal/codegen.go index 4aa2f893627..dd9bfad602c 100644 --- a/lib/utils/aws/region/internal/codegen.go +++ b/lib/utils/aws/region/internal/codegen.go @@ -26,8 +26,8 @@ import ( "path/filepath" "strconv" "strings" - "text/template" + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/gravitational/trace" ) diff --git a/lib/vnet/opensshconfig.go b/lib/vnet/opensshconfig.go index 7a3fcd52dc1..be92b0d3c51 100644 --- a/lib/vnet/opensshconfig.go +++ b/lib/vnet/opensshconfig.go @@ -29,9 +29,9 @@ import ( "slices" "strconv" "strings" - "text/template" "time" + template "github.com/DataDog/datadog-agent/pkg/template/text" renameio "github.com/google/renameio/v2/maybe" // Writes aren't guaranteed to be atomic on Windows. "github.com/gravitational/trace" "github.com/jonboulle/clockwork" diff --git a/lib/web/apiserver.go b/lib/web/apiserver.go index 5a32cbce2b4..1a03e56783b 100644 --- a/lib/web/apiserver.go +++ b/lib/web/apiserver.go @@ -28,7 +28,6 @@ import ( "encoding/json" "errors" "fmt" - "html/template" "io" "log/slog" "math/rand/v2" @@ -44,6 +43,7 @@ import ( "sync/atomic" "time" + template "github.com/DataDog/datadog-agent/pkg/template/html" gogoproto "github.com/gogo/protobuf/proto" "github.com/google/safetext/shsprintf" "github.com/google/uuid" diff --git a/lib/web/app/redirect.go b/lib/web/app/redirect.go index 48f959478be..276f89ff621 100644 --- a/lib/web/app/redirect.go +++ b/lib/web/app/redirect.go @@ -20,12 +20,12 @@ package app import ( "fmt" - "html/template" "io" "net/http" "slices" "strings" + template "github.com/DataDog/datadog-agent/pkg/template/html" "github.com/gravitational/trace" "golang.org/x/net/html" diff --git a/lib/web/mwi_wizards.go b/lib/web/mwi_wizards.go index e3cd3832c77..a1c7fcdbb81 100644 --- a/lib/web/mwi_wizards.go +++ b/lib/web/mwi_wizards.go @@ -24,8 +24,8 @@ import ( "encoding/json" "fmt" "net/http" - "text/template" + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/gravitational/trace" "github.com/julienschmidt/httprouter" diff --git a/lib/web/scripts/database.go b/lib/web/scripts/database.go index 1a3b0435b88..72946b17b68 100644 --- a/lib/web/scripts/database.go +++ b/lib/web/scripts/database.go @@ -20,7 +20,8 @@ package scripts import ( _ "embed" - "text/template" + + template "github.com/DataDog/datadog-agent/pkg/template/text" ) //go:embed database/sqlserver/configure-ad.ps1 diff --git a/lib/web/scripts/install_node.go b/lib/web/scripts/install_node.go index 1339c3ff600..68db621ee88 100644 --- a/lib/web/scripts/install_node.go +++ b/lib/web/scripts/install_node.go @@ -27,8 +27,8 @@ import ( "sort" "strconv" "strings" - "text/template" + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/google/safetext/shsprintf" "github.com/gravitational/trace" "gopkg.in/yaml.v3" diff --git a/lib/web/scripts/oneoff/oneoff.go b/lib/web/scripts/oneoff/oneoff.go index a4a974f971c..4904fa9ddb5 100644 --- a/lib/web/scripts/oneoff/oneoff.go +++ b/lib/web/scripts/oneoff/oneoff.go @@ -23,8 +23,8 @@ import ( _ "embed" "slices" "strings" - "text/template" + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/gravitational/trace" "github.com/gravitational/teleport/api" diff --git a/session/selinux/selinux_linux.go b/session/selinux/selinux_linux.go index d4e067d4bac..638d454f690 100644 --- a/session/selinux/selinux_linux.go +++ b/session/selinux/selinux_linux.go @@ -28,8 +28,8 @@ import ( "log/slog" "os" "path/filepath" - "text/template" + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/gravitational/trace" ocselinux "github.com/opencontainers/selinux/go-selinux" ) diff --git a/session/selinux/selinux_test.go b/session/selinux/selinux_test.go index 98c43668cf1..2ed9da9a36c 100644 --- a/session/selinux/selinux_test.go +++ b/session/selinux/selinux_test.go @@ -22,8 +22,8 @@ import ( "io" "os" "testing" - "text/template" + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/stretchr/testify/require" ) diff --git a/tool/tbot/keypair.go b/tool/tbot/keypair.go index 74e4dab8c11..499c4a19e3a 100644 --- a/tool/tbot/keypair.go +++ b/tool/tbot/keypair.go @@ -27,8 +27,8 @@ import ( "io" "os" "strings" - "text/template" + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/gravitational/trace" "golang.org/x/crypto/ssh" diff --git a/tool/tctl/common/app_command.go b/tool/tctl/common/app_command.go index ffc43f44edf..12f6e1565bf 100644 --- a/tool/tctl/common/app_command.go +++ b/tool/tctl/common/app_command.go @@ -21,8 +21,8 @@ package common import ( "context" "os" - "text/template" + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/alecthomas/kingpin/v2" "github.com/gravitational/trace" diff --git a/tool/tctl/common/auth_command.go b/tool/tctl/common/auth_command.go index 2f4313f86bd..9ca50ff95b5 100644 --- a/tool/tctl/common/auth_command.go +++ b/tool/tctl/common/auth_command.go @@ -28,9 +28,9 @@ import ( "net/url" "os" "strings" - "text/template" "time" + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/alecthomas/kingpin/v2" "github.com/gravitational/trace" "github.com/jonboulle/clockwork" diff --git a/tool/tctl/common/bots_command.go b/tool/tctl/common/bots_command.go index bea703a4e37..722d01c9c93 100644 --- a/tool/tctl/common/bots_command.go +++ b/tool/tctl/common/bots_command.go @@ -31,9 +31,9 @@ import ( "path/filepath" "slices" "strings" - "text/template" "time" + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/alecthomas/kingpin/v2" "github.com/charmbracelet/lipgloss" "github.com/google/uuid" diff --git a/tool/tctl/common/db_command.go b/tool/tctl/common/db_command.go index b80a4c7954d..9a0852aa588 100644 --- a/tool/tctl/common/db_command.go +++ b/tool/tctl/common/db_command.go @@ -21,8 +21,8 @@ package common import ( "context" "os" - "text/template" + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/alecthomas/kingpin/v2" "github.com/gravitational/trace" diff --git a/tool/tctl/common/desktop_command.go b/tool/tctl/common/desktop_command.go index 537fae0297e..4e9619e4f67 100644 --- a/tool/tctl/common/desktop_command.go +++ b/tool/tctl/common/desktop_command.go @@ -21,8 +21,8 @@ package common import ( "context" "os" - "text/template" + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/alecthomas/kingpin/v2" "github.com/gravitational/trace" diff --git a/tool/tctl/common/kube_command.go b/tool/tctl/common/kube_command.go index 178ec7660dd..917e6a17afc 100644 --- a/tool/tctl/common/kube_command.go +++ b/tool/tctl/common/kube_command.go @@ -21,8 +21,8 @@ package common import ( "context" "os" - "text/template" + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/alecthomas/kingpin/v2" "github.com/gravitational/trace" diff --git a/tool/tctl/common/node_command.go b/tool/tctl/common/node_command.go index 4eba18aac96..b7f38867b06 100644 --- a/tool/tctl/common/node_command.go +++ b/tool/tctl/common/node_command.go @@ -24,9 +24,9 @@ import ( "fmt" "os" "strings" - "text/template" "time" + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/alecthomas/kingpin/v2" "github.com/gravitational/trace" diff --git a/tool/tctl/common/token_command.go b/tool/tctl/common/token_command.go index 0e1f921aaea..4247dfe42bb 100644 --- a/tool/tctl/common/token_command.go +++ b/tool/tctl/common/token_command.go @@ -30,9 +30,9 @@ import ( "slices" "sort" "strings" - "text/template" "time" + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/alecthomas/kingpin/v2" "github.com/go-jose/go-jose/v4" "github.com/gravitational/trace" diff --git a/tool/tsh/common/app.go b/tool/tsh/common/app.go index 70b5e779714..7434bb4c201 100644 --- a/tool/tsh/common/app.go +++ b/tool/tsh/common/app.go @@ -28,8 +28,8 @@ import ( "strconv" "strings" "sync" - "text/template" + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/ghodss/yaml" "github.com/google/safetext/shsprintf" "github.com/gravitational/trace" diff --git a/tool/tsh/common/db.go b/tool/tsh/common/db.go index 83a790f2f26..53d3e9c9a22 100644 --- a/tool/tsh/common/db.go +++ b/tool/tsh/common/db.go @@ -30,9 +30,9 @@ import ( "sort" "strings" "sync" - "text/template" "time" + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/ghodss/yaml" "github.com/gravitational/trace" "go.opentelemetry.io/otel/attribute" diff --git a/tool/tsh/common/kube_proxy.go b/tool/tsh/common/kube_proxy.go index 49197afec5b..bcb1dfeeed9 100644 --- a/tool/tsh/common/kube_proxy.go +++ b/tool/tsh/common/kube_proxy.go @@ -28,9 +28,9 @@ import ( "os" "os/exec" "path/filepath" - "text/template" "time" + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/alecthomas/kingpin/v2" "github.com/gravitational/trace" "k8s.io/client-go/tools/clientcmd" diff --git a/tool/tsh/common/mcp_db.go b/tool/tsh/common/mcp_db.go index 5fb99a7b7dc..648567c30ec 100644 --- a/tool/tsh/common/mcp_db.go +++ b/tool/tsh/common/mcp_db.go @@ -23,8 +23,8 @@ import ( "log/slog" "maps" "net" - "text/template" + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/alecthomas/kingpin/v2" "github.com/gravitational/trace" diff --git a/tool/tsh/common/proxy.go b/tool/tsh/common/proxy.go index 531490ee7d0..5cfd6b82835 100644 --- a/tool/tsh/common/proxy.go +++ b/tool/tsh/common/proxy.go @@ -30,9 +30,9 @@ import ( "runtime" "strconv" "strings" - "text/template" "unicode" + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/coreos/go-semver/semver" "github.com/gravitational/trace" diff --git a/tool/tsh/common/proxy_test.go b/tool/tsh/common/proxy_test.go index f75986bde0f..3d92cd9df76 100644 --- a/tool/tsh/common/proxy_test.go +++ b/tool/tsh/common/proxy_test.go @@ -40,9 +40,9 @@ import ( "path/filepath" "strconv" "testing" - "text/template" "time" + template "github.com/DataDog/datadog-agent/pkg/template/text" "github.com/gravitational/trace" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require"