Documentation
¶
Overview ¶
Package kubernetes is the provider for the credentials that reach a Kubernetes API server: the client certificates, bearer tokens and basic auth logins a kubeconfig carries, service account tokens wherever they turn up, and Secret manifests committed with their values in the clear.
None of them can be revoked through an API. A client certificate is valid until it expires or the cluster's CA is rotated; a service account token dies with the Secret or ServiceAccount that issued it. The report carries those procedures. Verification, with --verify, is one GET /version against the server the kubeconfig names, with the credential; a certificate or token found without a server is not sent anywhere. Servers on private addresses are refused unless --verify-private-servers is given: a repository must not be able to point patty at the network it runs in.
A Secret manifest is reported even when no provider recognises its values: plaintext secret material in git is a leak whatever its shape. The values themselves are decoded and searched by the Registry, so a GitHub token inside one is GitHub's finding, attributed to the Secret.
Index ¶
- Constants
- type Provider
- func (p *Provider) AllowPrivateServers(allow bool)
- func (*Provider) Find(content []byte) []detect.Token
- func (*Provider) Kinds() []detect.KindInfo
- func (*Provider) LocalSources() detect.LocalSources
- func (*Provider) Name() string
- func (p *Provider) Verify(ctx context.Context, tok detect.Token) detect.Verification
Constants ¶
const ( // KindClientCertificate is a client certificate with its private key, // as a kubeconfig embeds them; its name is the certificate's SHA-256 // fingerprint. KindClientCertificate detect.Kind = "kubernetes-client-certificate" // KindServiceAccountToken is the JWT of a service account, legacy // (no expiry) or bound (expiring, tied to a pod). KindServiceAccountToken detect.Kind = "kubernetes-service-account-token" // KindToken is any other bearer token a kubeconfig user carries: a // static token, an OIDC id token pasted in. KindToken detect.Kind = "kubernetes-token" // KindBasicAuth is a username and password of a kubeconfig user; its // name is host/username. KindBasicAuth detect.Kind = "kubernetes-basic-auth" // KindSecretManifest is a Secret manifest with at least one value in // the clear; its name is namespace/name. KindSecretManifest detect.Kind = "kubernetes-secret-manifest" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Provider ¶
type Provider struct {
// Timeout bounds the one request --verify makes per credential.
Timeout time.Duration
// LookupIP resolves a server's host before it is contacted, so that
// a private address can be refused; tests fake it.
LookupIP func(ctx context.Context, host string) ([]net.IP, error)
// contains filtered or unexported fields
}
Provider implements detect.Provider for Kubernetes.
func New ¶
func New() *Provider
New returns a Provider that resolves hosts through the system resolver.
func (*Provider) AllowPrivateServers ¶
AllowPrivateServers implements detect.ServerVerifier.
func (*Provider) Find ¶
Find implements detect.Provider: the users of every kubeconfig, service account tokens wherever they stand, and Secret manifests with plaintext values. A token that is both a kubeconfig user and a bare JWT in the same content is one finding, the kubeconfig's, which knows the server.
func (*Provider) Kinds ¶
Kinds implements detect.Provider. Nothing here is revocable through an API; every kind carries the procedure that retires it.
func (*Provider) LocalSources ¶
func (*Provider) LocalSources() detect.LocalSources
LocalSources implements detect.Provider: the kubeconfig kubectl reads, and the files KUBECONFIG lists. Only certificate and token fingerprints are compared.
func (*Provider) Verify ¶
Verify implements detect.Provider with one GET /version against the server the kubeconfig names, with the credential. A credential that carries its own expiry, a certificate or a bound token, and has passed it is dead without asking anyone. A credential found without a server, or a Secret manifest, cannot be checked. A 401, a 403 that ran as system:anonymous, and a TLS handshake the server refuses because of the certificate are the explicit rejections; anything else that is not a clean 200 is unknown, an unreachable server included.