Add backend, GET, LIST controller for secret redaction#11195
Add backend, GET, LIST controller for secret redaction#11195
Conversation
8e5a762 to
73b55d3
Compare
73b55d3 to
d1848c8
Compare
|
|
||
| // parseRedactPath parses a field path like "credentials.password" or "secrets[*].value" | ||
| // into path segments for traversal. | ||
| func parseRedactPath(path string) []redactPathSegment { |
There was a problem hiding this comment.
this seems similar to schema.parseSensitivePath() below and encryption.parseFieldPath().. split dot-separated paths with [*] wildcards. Can we consider a shared utility function.
| if err != nil { | ||
| logger.Error(err, "Failed to fetch sensitive field paths for GET redaction", | ||
| "resourceType", resourceType, "apiVersion", apiVersion) | ||
| // Continue without redaction on error - don't fail the GET |
There was a problem hiding this comment.
if there was an error here we want to raise it. if there are no paths sensitiveFieldPaths will be empty.
| if provisioningState != v1.ProvisioningStateSucceeded && resource.Properties != nil { | ||
| resourceID := serviceCtx.ResourceID.String() | ||
| resourceType := serviceCtx.ResourceID.Type() | ||
| apiVersion := getResourceAPIVersion(serviceCtx.APIVersion, resource) |
There was a problem hiding this comment.
we should not be updating the internalMetadata or using a fallbackAPIversion. ln~86-97 should be removed. schema should be retrieved for the apiVersion resource was created with.
apiVersion := resource.InternalMetadata.UpdatedAPIVersion
| } | ||
|
|
||
| // Cache sensitive field paths for this resource type (same for all items) | ||
| var sensitiveFieldPaths []string |
There was a problem hiding this comment.
we should probably cache this per apiversion ( use map[string][]string instead of []string) since a list of resources for the resourcetype could return resources belonging to multiple api versions and schemas can differ between them.
pkg/portableresources/backend/controller/createorupdateresource.go
Outdated
Show resolved
Hide resolved
Unit Tests4 844 tests 4 841 ✅ 7m 47s ⏱️ Results for commit 82bd1ad. ♻️ This comment has been updated with latest results. |
| // testGetUCPClientFactoryWithSensitiveFields returns a UCP client that provides | ||
| // a schema with a sensitive "password" field. Uses the shared helper from | ||
| // encryptionfilter_test.go via the same Go test package. | ||
| func testGetUCPClientFactoryWithSensitiveFields() (*v20231001preview.ClientFactory, error) { |
There was a problem hiding this comment.
is this wrapper function and the next one on ln205 testGetUCPClientFactoryWithError() necessary? the inner functions can be called directly
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #11195 +/- ##
==========================================
+ Coverage 50.98% 51.15% +0.16%
==========================================
Files 679 682 +3
Lines 43174 43433 +259
==========================================
+ Hits 22012 22217 +205
- Misses 19040 19069 +29
- Partials 2122 2147 +25 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
4023f7e to
1682d41
Compare
Signed-off-by: sk593 <shruthikumar@microsoft.com>
1682d41 to
2ca13a8
Compare
25ddaeb to
843c263
Compare
Signed-off-by: sk593 <shruthikumar@microsoft.com>
| // normalizeSensitiveFieldTypes normalizes the type constraint on sensitive string fields | ||
| // so that the OpenAPI validator accepts both the original plaintext string and the encrypted object form. | ||
| // Only string types need this adjustment — object types remain objects after encryption and pass validation. | ||
| // normalizeSensitiveFieldTypes normalizes the type constraints on sensitive fields |
There was a problem hiding this comment.
this is needed only for string types. we do not want to normalize for types unless necessary. pls clarfy why this and related functions was updated ??
There was a problem hiding this comment.
synced offline. the addition is for object properties. the encrypted value might not always match the original schema so when the validator runs, it fails without normalization
Radius functional test overviewClick here to see the test run details
Test Status⌛ Building Radius and pushing container images for functional tests... |
Description
This PR adds support for the backend controller, GET controller, and LIST controller for secret decryption and redaction
Type of change
Fixes: #11093 and #11095
Contributor checklist
Please verify that the PR meets the following requirements, where applicable: