Repository navigation
Feat: store sensitive workflow data in Secrets instead of ConfigMaps - #242
Paranitharan1110 wants to merge 1 commit into
Conversation
|
Tested this locally. Two bugs came up — could you please fix these and re-test locally?
panic: save context to configMap(...): save sensitive context to secret(default/workflow-crash-app-context-secret): secrets "workflow-crash-app-context-secret" not found
newContext() seeds |
There was a problem hiding this comment.
All reported issues were addressed across 9 files
Tip: instead of fixing issues one by one fix them all with cubic
Re-trigger cubic
There was a problem hiding this comment.
3 issues found across 9 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="pkg/context/storage.go">
<violation number="1" location="pkg/context/storage.go:135">
P3: In-memory secrets for non-default workflow namespaces are never deleted: stored keys always include their namespace, while this condition only matches `default`. Match the secret-name suffix (or accept a namespace) so cleanup behavior matches the method contract.</violation>
</file>
<file name="pkg/context/context.go">
<violation number="1" location="pkg/context/context.go:114">
P1: Sensitive data written through an owner-conflict context is saved to a different Secret than later loads read, so resumed workflows lose those values. Preserve the workflow name independently of the ConfigMap backend name when generating the Secret name.</violation>
<violation number="2" location="pkg/context/context.go:457">
P2: Secret access failures are silently discarded, causing workflows with sensitive inputs to continue with an empty sensitive context and fail as if variables were never written. Ignore only NotFound; return all other retrieval errors.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
- Route sensitive workflow outputs to Kubernetes Secrets via new SetSensitiveVar/GetSensitiveVar API - Lazy secret store creation: Secret only created when first sensitive data is stored - Fix syncSecret panic in in-memory mode (missing return after MemStore update) - Fix owner-conflict secret name mismatch by storing workflowName in struct - Fix silent discard of non-NotFound errors during secret load in LoadContext - Fix context.Background() usage in LoadContext (use caller-provided ctx) - Fix data race in GetInMemoryContext/GetInMemorySecret (add RLock) - Fix namespace normalization in GetInMemoryContext/GetInMemorySecret - Fix DeleteInMemoryContext/DeleteInMemorySecret to match all namespaces - Input lookup: regular store first, then sensitive store (last-write semantics) Signed-off-by: Paranitharan Kalaiselvan <paranitharan.kalaiselvan@gmail.com>
fa8111f to
f7a178d
Compare
Description
Implement dual-store mechanism to store sensitive workflow data in Kubernetes Secrets instead of ConfigMaps.
Fixes: kubevela/kubevela#7153
Depends on: kubevela/pkg#133
Problem
KubeVela's workflow engine stores inter-step runtime state in ConfigMaps. When workflow steps pass sensitive data (tokens, credentials, API keys), that data is persisted in plaintext in the ConfigMap, creating a security vulnerability.
Solution
This PR implements a dual-store mechanism:
Two paths are covered:
workflow.steps[].outputs[]- viapkg/hooks/data_passing.gosensitive: trueis set on an output, it routes to the Secret storeop.ws.#DoVar- viapkg/providers/builtin/workspace.goSensitive boolfield toVarVarsstructPutwithsensitive: truestores in SecretGettries sensitive store first, falls back to regular storeChanges
pkg/context/context.go- AddedsecretStore,sensitiveVars,GetSensitiveVar(),SetSensitiveVar(),syncSecret(),LoadFromSecret()pkg/context/interface.go- Added interface methods for sensitive varspkg/context/storage.go- Added in-memory Secret storage for testingpkg/context/context_test.go- Added 8 tests for sensitive vars functionalitypkg/hooks/data_passing.go- Routes outputs withsensitive: trueto Secret storepkg/hooks/data_passing_test.go- Added tests for output routingpkg/providers/builtin/workspace.go- AddedSensitivefield toVarVars, updatedDoVar()pkg/providers/builtin/workspace_test.go- Added 2 tests for sensitive DoVarpkg/providers/legacy/workspace/workspace.go- Same changes for legacy providerUsage
Via outputs:
Via DoVar in CUE templates:
Backward Compatibility
sensitiveflag continue to work unchangedGetoperations automatically fall back to ConfigMap if data not in SecretTesting
pkg/context/...(73% coverage)pkg/providers/builtin/...(80% coverage)pkg/hooks/...tests will pass after feat: add Sensitive field to OutputItem for secure workflow data storage pkg#133 is mergedNote
go.modis updated. This is expected - raising as draft per maintainer request.Summary by cubic
Store sensitive workflow variables in Kubernetes Secrets instead of ConfigMaps, with lazy Secret creation, clear read/write precedence, and safety fixes to prevent leaking secrets and runtime panics.
New Features
workflow-<name>-context-secret(created lazily with owner refs).op.ws.#DoVarGet reads Secret first, then ConfigMap. Writes route byoutputs[].sensitive: trueandop.ws.#DoVarSensitive: true.GetSensitiveVar/SetSensitiveVar,GetSecretStore, secret sync/load, and in-memory secret support; requireskubevela/pkg#133.Bug Fixes
syncSecret.workflowNameto avoid owner-ref conflicts.LoadContextuses callerctxand surfaces non-NotFound errors when loading Secrets.Written for commit f7a178d. Summary will update on new commits.