kubernetes

package
v0.15.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 19, 2026 License: MIT Imports: 18 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

func (p *Provider) AllowPrivateServers(allow bool)

AllowPrivateServers implements detect.ServerVerifier.

func (*Provider) Find

func (*Provider) Find(content []byte) []detect.Token

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

func (*Provider) Kinds() []detect.KindInfo

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) Name

func (*Provider) Name() string

Name implements detect.Provider.

func (*Provider) Verify

func (p *Provider) Verify(ctx context.Context, tok detect.Token) detect.Verification

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL