--- title: "ADR 0069: Secret value handling quirks in pkg/secrets" --- * Status: accepted * Code: [`pkg/secrets/basic_auth.go`](https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/secrets/basic_auth.go), [`pkg/secrets/pipelinerun_secrets.go`](https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/secrets/pipelinerun_secrets.go), [`pkg/secrets/secret.go`](https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/secrets/secret.go) ## Context Provider tokens and webhook secrets are read from cluster secrets, written into a basic-auth secret for git-clone, and redacted from output. ## Decision * `MakeBasicAuthSecret` accepts a `CloneURL` different from the repository URL (Bitbucket Data Center) only when both share a host, so the token is not written for another host. The token is passed through `url.QueryEscape` before going into `.git-credentials` and `git-provider-token`; the removed comment said Bitbucket Data Center tokens contain `/`, and that patching the git-clone task was considered and not done. Its claim about GitHub was unverified in the code. * `ReplaceSecretsInText` replaces values longest first (`sortSecretsByLongests`) so a secret that is a prefix of another does not leave the tail of the longer one in the text. * `GetSecretsAttachedToPipelineRun` skips a secret that cannot be read and continues; the removed comment says this should not normally happen. * `GetCurrentNSWebhookSecret` returns the value with `strings.TrimSpace`, because base64 encoding done with `echo` adds a newline; the cost is that a secret that intentionally has leading or trailing whitespace cannot be used. * A repository secret with an empty token returns early without error and leaves failure to client setup, which succeeds for a GitHub App. A missing `webhook_secret` also returns early; the removed comment guessed Bitbucket Cloud, which the code does not confirm. ## Consequences * The trimmed webhook secret and the escaped token are behaviours users can hit without any error message. * The GitHub App token lifetime note (8h) from the removed comment is not checkable in this package.