Skip to content

Add external Go key-provider plugins - #2358

Draft
winrarr wants to merge 7 commits into
getsops:mainfrom
winrarr:feat/plugin-sdk
Draft

winrarr wants to merge 7 commits into
getsops:mainfrom
winrarr:feat/plugin-sdk

Conversation

@winrarr

@winrarr winrarr commented Nov 25, 2026 •

Copy link
Copy Markdown

Summary

Add an opt-in external Go key-provider API to SOPS. Providers become independently distributed executables, while SOPS continues to own file encryption, data-key orchestration, key groups, and Shamir secret sharing.

API and data model

  • Define a versioned sops.plugin.v1 gRPC protocol and public Go SDK. The provider contract is intentionally limited to Wrap and Unwrap.
  • SOPS passes a 32-byte data key or a 33-byte tagged Shamir share to the provider. The provider's wrapped key remains opaque to SOPS.
  • Persist provider metadata returned by Wrap with the key entry and pass it to later Wrap and Unwrap calls. This supports metadata-aware rewrapping and key rotation without making SOPS understand provider-specific formats.
  • Preserve JSON value types and number precision in plugin config/metadata across structured JSON/YAML and flattened dotenv/INI stores. Typed SDK decoding and compatibility expectations are documented because encrypted files can outlive provider releases.

Runtime and policy

  • Launch only plugins in the user's local allowlist; keep the existing path-only format and add an optional per-plugin invocation timeout.
  • Reuse a plugin process for the lifetime of the owning key-service runtime. The normal CLI uses its existing in-process key service; this does not add a SOPS server that plugins must call.
  • Propagate cancellation. On invocation deadline expiry, return the error and evict the process; concurrent calls using it may also fail, and timed-out operations are not retried. Explicit caller cancellation alone does not evict a healthy process. Startup has a separate 10-second bound.
  • Document that plugins are trusted executables and that config and provider metadata are plaintext in SOPS files, so they must not contain credentials.

Test coverage

Add 19 local/mock provider fixtures exercising varied provider patterns, including offline/local keys, mock remote KMS, keyrings, rewrapping, approval/audit flows, and threshold shares. The tests cover the SDK and SOPS integration rather than live cloud services, including process reuse, cancellation, timeout eviction, concurrent calls, Shamir share sizes, metadata round-trips, typed-value preservation across stores, and key-service behavior. Age passphrase tests use the deterministic test passphrase provider instead of the developer's GPG agent.

Validation

  • go test ./... -count=1 -timeout=20m
  • go test -race ./... -count=1 -timeout=20m
  • go test ./plugin -run '^TestRuntimeEvictsPluginAfterInvocationTimeout$' -count=15
  • go vet ./...
  • git diff --check

The full test suites were run with the repository's PGP test key imported into an isolated GNUPGHOME.

Feedback requested

Please comment on whether the two-operation provider contract and metadata-based rewrapping model are a good fit, whether the timeout/eviction behavior is appropriate, and whether the fixture breadth belongs in this initial PR or should be narrowed.

Signed-off-by: Rasmus Kock Thygesen <rasmus.thygesen.privat@gmail.com>
Signed-off-by: Rasmus Kock Thygesen <rasmus.thygesen.privat@gmail.com>
Signed-off-by: Rasmus Kock Thygesen <rasmus.thygesen.privat@gmail.com>
Signed-off-by: Rasmus Kock Thygesen <rasmus.thygesen.privat@gmail.com>
Signed-off-by: Rasmus Kock Thygesen <rasmus.thygesen.privat@gmail.com>
Signed-off-by: Rasmus Kock Thygesen <rasmus.thygesen.privat@gmail.com>
Signed-off-by: Rasmus Kock Thygesen <rasmus.thygesen.privat@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant