connsec

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package connsec encrypts and decrypts the sensitive credentials carried by inline ConnectionRef sources (ssh/minio/db) and the beetleDb reference password. Reference sources that hold only identifiers pass through unchanged.

Values are encrypted with AES-256-GCM and prefixed "enc:" (see cryptoutil). Encrypt is idempotent — an already-encrypted value is left as-is — so it is safe to call on plan build even if the request already carried ciphertext. Decrypt passes through any value lacking the "enc:" prefix.

Ciphertext is the shared wire and storage format, and plaintext exists only where a credential is about to be used:

  • POST /plans/target takes plaintext (a person types it) and answers with ciphertext, which the caller pastes into POST /migration unchanged.
  • The plan is stored exactly as it arrived; EncryptPlan's idempotence means nothing is resealed on the way in.
  • The migration resolvers decrypt one ref at a time, immediately before building a storagex/dbmsx config.
  • Read-only responses carry neither: MaskPlan replaces the values with "***", because nothing feeds a GET response back into the API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecryptRef

DecryptRef returns a copy of ref with the sensitive fields decrypted.

func EncryptPlan

EncryptPlan encrypts the sensitive fields of every ConnectionRef in the plan, in place. It is idempotent: a ref that is already encrypted is left alone, so a plan that arrived as ciphertext is stored as it arrived rather than resealed under a fresh nonce.

func EncryptRef

EncryptRef returns a copy of ref with the sensitive fields of its inline sources and db-reference passwords encrypted. Reference sources without secrets are returned unchanged.

func ForEachRef

ForEachRef walks every source and destination ConnectionRef in a plan, in the order the plan lists them.

The ref is passed by pointer: a mutating visitor writes through it, a read-only one ignores it. Encryption, masking and validation all want the same walk, and one walk is one place to add a unit type when the plan grows one.

func MaskPlan

MaskPlan masks the sensitive fields of every ConnectionRef in the plan, in place. Call it on a plan that is on its way into a response, never on one on its way into the database.

func MaskRef

MaskRef returns a copy of ref with every non-empty sensitive field replaced by "***". An empty field stays empty: whether a connection authenticates with a password or a key is not itself a secret, and blanking that distinction would make a response harder to read for no gain.

Masking rather than ciphertext is deliberate for read-only responses. Nothing feeds a GET response back into the API, so there is nothing to round-trip, and a value that cannot be replayed is better than one that can.

func VerifyPlanDecryptable

func VerifyPlanDecryptable(p targetmodel.TargetDataMigrationModel) error

VerifyPlanDecryptable reports whether every encrypted value in the plan can be decrypted with this server's key, naming the first ref that cannot.

It is read-only: DecryptRef takes its argument by value and copies each sub-struct before writing, so discarding the result leaves the plan untouched.

This is what turns "the migration failed somewhere in the middle" into a 400 on the request that introduced the problem — a plan issued by another instance, or before the passphrase changed, cannot run and should not be accepted as though it could.

Types

type RefVisitor

type RefVisitor func(label string, ref *commonmodel.ConnectionRef) error

RefVisitor is called once per ConnectionRef in a plan. label names the ref's position ("fileSystems[0].dstConnection") so an error can say where it came from rather than only what went wrong.

Jump to

Keyboard shortcuts

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