fix(external-kms): use sanitized AWS provider schema in read responses#7008
fix(external-kms): use sanitized AWS provider schema in read responses#7008Vligai wants to merge 1 commit into
Conversation
The get-by-id and get-by-name external-KMS read endpoints serialized the AWS provider config through the full ExternalKmsAwsSchema, while the provider-specific endpoints already use SanitizedExternalKmsAwsSchema. Align the legacy read endpoints with that existing schema so the AWS read response shape is consistent across the external-KMS API (access key and assume-role identifiers only), matching how the GCP branch is already handled. Add a unit test for SanitizedExternalKmsAwsSchema covering the access-key and assume-role cases.
|
💬 Discussion in Slack: #pr-review-infisical-7008-fix-external-kms-use-sanitized-aws-provider-schema-in-r Posted by Review Police — reviews, comments, new commits, and CI failures will stream into this channel. |
|
| Filename | Overview |
|---|---|
| backend/src/ee/routes/v1/external-kms-router.ts | Swaps ExternalKmsAwsSchema for SanitizedExternalKmsAwsSchema in the sanitizedExternalSchemaForGetById response schema, aligning the legacy GET-by-id and GET-by-name endpoints with the provider-specific endpoint; the change is minimal and correct. |
| backend/src/ee/services/external-kms/providers/model.test.ts | New unit tests covering the sanitized AWS schema: verifies secretKey is stripped for access-key credentials, includes a negative control against the unsanitized schema, and confirms assume-role identifiers are preserved. |
Reviews (1): Last reviewed commit: "fix(external-kms): use sanitized AWS pro..." | Re-trigger Greptile
Context
The external-KMS get-by-id and get-by-name read endpoints (
GET /external-kms/:id,GET /external-kms/name/:name) serialize the AWS provider config through the fullExternalKmsAwsSchema. The provider-specific endpoints (for exampleGET /external-kms/aws/:id)already serialize through
SanitizedExternalKmsAwsSchema.This brings the legacy read endpoints in line with that existing schema, so the AWS read response
shape is consistent across the external-KMS API (access key and assume-role identifiers only),
matching how the GCP branch is already handled in the same response. It is not a new control; it
applies the one already used by the provider-specific endpoints to the legacy read endpoints, which
were never migrated to it.
ExternalKmsAwsSchema.SanitizedExternalKmsAwsSchema, the same shape the provider-specificendpoints already return.
Changed files:
backend/src/ee/routes/v1/external-kms-router.ts: useSanitizedExternalKmsAwsSchemain theproviderInputunion of the get-by-id / get-by-name response schema (covers both endpoints);update the import and the adjacent comment.
backend/src/ee/services/external-kms/providers/model.test.ts: unit test for the sanitized schema.Screenshots
Steps to verify the change
npm run test:unit -- src/ee/services/external-kms/providers/model.test.ts.It asserts the sanitized schema returns the access key and assume-role identifiers only, with a
negative control over the prior schema.
already returned by the provider-specific endpoint (
GET /external-kms/aws/:id).Type
Checklist
type(scope): short description(scope is optional, e.g.,fix: prevent crash on syncorfix(api): handle null response).