Documentation
¶
Overview ¶
Package bundle builds, signs and stores policy bundles (0004 §4.6). The bundle Secret is both what the distribution server sends and the engines' cold-start source, and it carries the version sequence, so a new leader continues it.
Index ¶
- Constants
- Variables
- func ContentHash(b *bundlev1.Bundle) ([]byte, error)
- func Decode(data []byte) (*bundlev1.SignedBundle, error)
- func Load(ctx context.Context, c client.Reader, namespace string) (*bundlev1.Bundle, error)
- func Next(current, content *bundlev1.Bundle, lastVersion uint64, now time.Time) (*bundlev1.Bundle, bool, error)
- func Store(ctx context.Context, c client.Client, namespace string, b *bundlev1.Bundle, ...) error
- type Signer
Constants ¶
const ( BundleSecret = "inkwall-bundle" SigningKeySecret = "inkwall-bundle-signing-key" // #nosec G101 -- the Secret's name, not a credential )
Names of the Secrets in the operator's namespace.
const ( // BundleKey holds the gzip-compressed, serialized SignedBundle. BundleKey = "bundle.pb.gz" // PublicKeyKey holds the ed25519 public key the bundle is signed with, // so an engine reading the Secret can check which key it needs. PublicKeyKey = "ed25519.pub" )
Keys of the bundle Secret.
const ( VersionAnnotation = "waf.inkwall.dev/bundle-version" HashAnnotation = "waf.inkwall.dev/content-hash" )
Annotations on the bundle Secret, for people and tools.
const MaxCompressedBytes = 900 << 10
MaxCompressedBytes is the largest bundle stored: Secrets are limited to 1 MiB. Bundles reference the Core Rule Set by name, so this takes many thousands of policies.
Variables ¶
var ErrTooLarge = errors.New("bundle too large for a Secret")
ErrTooLarge is returned for a bundle over MaxCompressedBytes.
Functions ¶
func ContentHash ¶
ContentHash hashes what a bundle enforces: everything but its version, creation time and the hash itself. Encoding is deterministic, so equal content gives an equal hash within one operator version.
func Decode ¶
func Decode(data []byte) (*bundlev1.SignedBundle, error)
Decode reads the content of the bundle Secret's BundleKey.
func Next ¶
func Next(current, content *bundlev1.Bundle, lastVersion uint64, now time.Time) (*bundlev1.Bundle, bool, error)
Next returns the bundle to publish for content, given the current one (nil if none), and whether it differs: unchanged content keeps the current version. lastVersion is the highest version this process published, so a deleted Secret doesn't restart the sequence while the leader runs.
Types ¶
type Signer ¶
type Signer struct {
// contains filtered or unexported fields
}
Signer signs bundles.
func LoadOrCreateSigner ¶
LoadOrCreateSigner reads the cluster's signing key from its Secret, and generates it on first use.
func NewSigner ¶
func NewSigner(key ed25519.PrivateKey) *Signer
NewSigner returns a Signer for key, with a key ID derived from its public key.