Documentation
¶
Overview ¶
Package preview looks for credentials on a project's preview deployments.
Requirement five of this project's brief names "historical key exposure (Wayback, preview deployments)". The archive half has been implemented since early on. This is the other half, and it is a genuinely different channel: a preview build is a separate origin, usually with its own environment configuration, frequently pointing at the PRODUCTION database, and almost never watched. A key rotated in production can keep being served by a branch deployment nobody remembers.
WHAT IS AND IS NOT DISCOVERABLE, because the difference decides what this package can honestly claim.
Certificate Transparency does not help. Vercel, Netlify and Cloudflare Pages all serve preview hosts under their own wildcard certificates, so no per-host certificate is ever issued and crt.sh returns nothing. Measured against a real target: two names, both wildcards.
Netlify and Cloudflare Pages hostnames ARE derivable, because they embed the branch:
<branch>--<site>.netlify.app deploy-preview-<n>--<site>.netlify.app <branch>.<project>.pages.dev
A pinned branch list and a small range of preview numbers cover the common cases deterministically.
Vercel is NOT derivable. Its preview hosts are <project>-git-<branch>-<team>.vercel.app, and the team slug cannot be guessed from outside. Those have to be supplied by whoever knows them, which is why Options takes an explicit host list as well.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Candidates ¶
Candidates derives preview hostnames from a site plus any supplied explicitly. Sorted and deduplicated, so two runs probe the same names.
Types ¶
type Options ¶
type Options struct {
// Site is the production site, used to derive candidate hostnames.
Site string
// Hosts are additional preview hostnames supplied by the operator. The
// only way to reach a Vercel preview, whose team slug is not guessable.
Hosts []string
// CurrentKey is production's anon key, so a preview serving a DIFFERENT
// key can be distinguished from one serving the same one.
CurrentKey string
Limiter *client.Limiter
// Timeout bounds each host fetch. Zero means discover's own default.
//
// It was declared and never used: never passed to discover.Run, never set
// by the caller, so -timeout did not bind this stage at all and every host
// got a 20-second default. With up to 23 derived hostnames that is seven
// minutes an operator asked to be shorter. Every other stage was fixed for
// this when the flag was introduced; this one arrived later and missed it.
Timeout time.Duration
}
Options configures the sweep.