--- title: "ADR 0056: Provider URLs are rebuilt on the approved hostname and must be https" --- * Status: accepted * Code: [`pkg/hostpolicy/hostpolicy.go`](https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/hostpolicy/hostpolicy.go) ## Context GitHub derives its API endpoint from a bare hostname. GitLab, Gitea and Bitbucket Data Center are often served under a path prefix such as `https://example.com/gitlab`, which rebuilding from the hostname alone would drop. ## Decision * `TrustedURL` is the gate for providers that keep their own URL. It splits the URL with `vcshost.SplitURL`, checks the host through `Trusted`, and returns the URL with `parsed.Host` set to the host `Trusted` returned (the canonical form), keeping the path. * The caller must dial the returned URL, never the raw input: the two can differ, and dialling the raw value would defeat the check. The `vcshost` package documentation describes the difference; this ADR does not verify it. * URLs with credentials, a query or a fragment (`vcshost.ErrURLUnsafeComponents`) are refused, as is any unparsable URL; the error messages do not echo the input. * The scheme must be `https` (case-insensitive match) and is normalised to lowercase `https`. ## Consequences * A plain-http GitLab or Gitea URL is rejected by `TrustedURL`, unlike the GitHub path (see [ADR 0011]({{< relref "0011-github-credentials-and-endpoints.md" >}})), which keeps http for self-hosted instances. * Query-string based provider URLs are not supported. * Callers that skip `TrustedURL` and use the raw URL bypass the policy.