8000 refactor(policy): Rename key context structures. by c-r33d · Pull Request #2318 · opentdf/platform · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

refactor(policy): Rename key context structures. #2318

8000 New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 27, 2025

Conversation

c-r33d
Copy link
Contributor
@c-r33d c-r33d commented May 27, 2025

Proposed Changes

1.) Remove KAS naming from Asymmetric Key Context.

Checklist

  • I have added or updated unit tests
  • I have added or updated integration tests (if appropriate)
  • I have added or updated documentation

Testing Instructions

@c-r33d c-r33d requested review from 8000 a team as code owners May 27, 2025 15:29
@github-actions github-actions bot added external-contributor External Org Member comp:db DB component comp:policy Policy Configuration ( attributes, subject mappings, resource mappings, kas registry) comp:kas Key Access Server docs Documentation size/s and removed external-contributor External Org Member labels May 27, 2025
Copy link
Contributor
@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @c-r33d, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Summary of Changes

Hello team,

I've put together this pull request to address the naming of the asymmetric key context structures within the policy definitions. As per the title and description, the primary goal is to remove the "Kas" prefix from KasPublicKeyCtx and KasPrivateKeyCtx to make the naming more consistent and less tied to a specific implementation detail (Key Access Server).

This change involves renaming the protobuf messages and updating all references to these types across the codebase, including the generated Go code, OpenAPI specifications for various policy services, and the relevant integration test files. I've also updated the validation rule for the private_key_ctx field in the CreateKeyRequest to be conditionally required based on the key mode, which seems more accurate.

Highlights

  • Type Renaming: The protobuf message KasPublicKeyCtx has been renamed to PublicKeyCtx and KasPrivateKeyCtx has been renamed to PrivateKeyCtx.
  • Reference Updates: All occurrences and references to the old type names (KasPublicKeyCtx, KasPrivateKeyCtx) have been updated to the new names (PublicKeyCtx, PrivateKeyCtx) across protobuf definitions, generated Go code, OpenAPI specifications, and test files.
  • Validation Change: The private_key_ctx field in the CreateKeyRequest protobuf message has been updated from being strictly 'Required' to 'Conditionally Required', with validation rules adjusted accordingly.
  • Documentation Updates: The generated documentation files (gRPC and OpenAPI) have been updated to reflect the new type names and their definitions.

Changelog

Click here to see the changelog
  • docs/grpc/index.html
    • Removed old KasPrivateKeyCtx and KasPublicKeyCtx entries from the table of contents.
    • Added new PrivateKeyCtx and PublicKeyCtx entries to the table of contents.
    • Updated references within the AsymmetricKey definition to point to the new PublicKeyCtx and PrivateKeyCtx types.
  • docs/openapi/policy/actions/actions.swagger.json
    • Updated $ref pointers for publicKeyCtx and privateKeyCtx to reference the new policyPublicKeyCtx and policyPrivateKeyCtx definitions.
    • Removed the old policyKasPrivateKeyCtx and policyKasPublicKeyCtx definitions.
    • Added new policyPrivateKeyCtx and policyPublicKeyCtx definitions with the same structure as the removed ones.
  • docs/openapi/policy/attributes/attributes.swagger.json
    • Updated $ref pointers for publicKeyCtx and privateKeyCtx to reference the new policyPublicKeyCtx and policyPrivateKeyCtx definitions.
    • Removed the old policyKasPrivateKeyCtx and policyKasPublicKeyCtx definitions.
    • Added new policyPrivateKeyCtx and policyPublicKeyCtx definitions with the same structure as the removed ones.
  • docs/openapi/policy/kasregistry/key_access_server_registry.swagger.json
    • Updated $ref pointers for publicKeyCtx and privateKeyCtx to reference the new policyPublicKeyCtx and policyPrivateKeyCtx definitions.
    • Removed the old policyKasPrivateKeyCtx and policyKasPublicKeyCtx definitions.
    • Added new policyPrivateKeyCtx and policyPublicKeyCtx definitions with the same structure as the removed ones.
  • docs/openapi/policy/namespaces/namespaces.swagger.json
    • Updated $ref pointers for publicKeyCtx and privateKeyCtx to reference the new policyPublicKeyCtx and policyPrivateKeyCtx definitions.
    • Removed the old policyKasPrivateKeyCtx and policyKasPublicKeyCtx definitions.
    • Added new policyPrivateKeyCtx and policyPublicKeyCtx definitions with the same structure as the removed ones.
  • docs/openapi/policy/registeredresources/registered_resources.swagger.json
    • Updated $ref pointers for publicKeyCtx and privateKeyCtx to reference the new policyPublicKeyCtx and policyPrivateKeyCtx definitions.
    • Removed the old policyKasPrivateKeyCtx and policyKasPublicKeyCtx definitions.
    • Added new policyPrivateKeyCtx and policyPublicKeyCtx definitions with the same structure as the removed ones.
  • docs/openapi/policy/resourcemapping/resource_mapping.swagger.json
    • Updated $ref pointers for publicKeyCtx and privateKeyCtx to reference the new policyPublicKeyCtx and policyPrivateKeyCtx definitions.
    • Removed the old policyKasPrivateKeyCtx and policyKasPublicKeyCtx definitions.
    • Added new policyPrivateKeyCtx and policyPublicKeyCtx definitions with the same structure as the removed ones.
  • docs/openapi/policy/subjectmapping/subject_mapping.swagger.json
    • Updated $ref pointers for publicKeyCtx and privateKeyCtx to reference the new policyPublicKeyCtx and policyPrivateKeyCtx definitions.
    • Removed the old policyKasPrivateKeyCtx and policyKasPublicKeyCtx definitions.
    • Added new policyPrivateKeyCtx and policyPublicKeyCtx definitions with the same structure as the removed ones.
  • docs/openapi/policy/unsafe/unsafe.swagger.json
    • Updated $ref pointers for publicKeyCtx and privateKeyCtx to reference the new policyPublicKeyCtx and policyPrivateKeyCtx definitions.
    • Removed the old policyKasPrivateKeyCtx and policyKasPublicKeyCtx definitions.
    • Added new policyPrivateKeyCtx and policyPublicKeyCtx definitions with the same structure as the removed ones.
  • protocol/go/policy/kasregistry/key_access_server_registry.pb.go
    • Updated type references for PublicKeyCtx and PrivateKeyCtx fields and their getter methods in CreateKeyRequest and RotateKeyRequest_NewKey.
    • Changed the comment for the PrivateKeyCtx field in CreateKeyRequest from 'Required' to 'Conditionally Required'.
    • Updated internal protobuf descriptor data to reflect the renaming.
  • protocol/go/policy/objects.pb.go
    • Renamed the KasPublicKeyCtx struct to PublicKeyCtx (line 2224).
    • Renamed the KasPrivateKeyCtx struct to PrivateKeyCtx (line 2272).
    • Updated method receivers and type references for the renamed structs.
    • Updated type references for PublicKeyCtx and PrivateKeyCtx fields and their getter methods in the AsymmetricKey struct.
    • Updated internal protobuf descriptor data and type information to reflect the renaming.
  • service/integration/kas_registry_key_test.go
    • Updated type references for PublicKeyCtx and PrivateKeyCtx in test case structs and variable declarations.
  • service/integration/kas_registry_test.go
    • Updated type references for PublicKeyCtx and PrivateKeyCtx in test case structs and variable declarations.
  • service/kas/key_indexer_test.go
    • Updated type references for PublicKeyCtx in test case structs.
  • service/policy/db/utils.go
    • Updated the function signature and variable types in unmarshalPrivatePublicKeyContext to use *policy.PublicKeyCtx and *policy.PrivateKeyCtx.
  • service/policy/kasregistry/key_access_server_registry.proto
    • Renamed the KasPublicKeyCtx message type to PublicKeyCtx (line 501).
    • Renamed the KasPrivateKeyCtx message type to PrivateKeyCtx (line 506).
    • Updated field types in CreateKeyRequest and RotateKeyRequest.NewKey to use the new message types.
    • Changed the requirement for the private_key_ctx field in CreateKeyRequest from required = true to a conditional validation rule (line 414).
  • service/policy/kasregistry/key_access_server_registry_keys_test.go
    • Updated type references for PublicKeyCtx and PrivateKeyCtx in variable declarations and test case structs.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.


A name change sweeps the code,
Old 'Kas' gives way, a lighter load.
Contexts now stand free,
For all the world to see,
A cleaner path is surely sowed.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor
@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request primarily focuses on refactoring key context structures by removing the "KAS" prefix from their names (e.g., KasPublicKeyCtx to PublicKeyCtx). This change is consistently applied across protocol definitions, generated Go code, documentation (HTML and OpenAPI), and test files, which should improve clarity and reduce redundancy in naming.

However, a significant observation is the change in the requirement for the private_key_ctx field within the CreateKeyRequest message (in service/policy/kasregistry/key_access_server_registry.proto). Its requirement has been altered from "Required" to "Conditionally Required". This is a semantic API change that goes beyond simple renaming and is not explicitly mentioned in the PR title or description. Such changes need careful consideration, clear documentation, and thorough testing.

Additionally, the PR checklist indicates that updates to unit tests, integration tests, and documentation are still pending. Given the API contract modification, ensuring these are comprehensively updated is critical before merging.

No explicit style guide was provided, so feedback is based on common best practices for Go and Protobuf.

Summary of Findings

  • Semantic API Change in CreateKeyRequest: The private_key_ctx field in the CreateKeyRequest message (defined in service/policy/kasregistry/key_access_server_registry.proto) has been changed from being unconditionally "Required" to "Conditionally Required". This is a functional API change that alters the contract for clients. This change was not explicitly mentioned in the PR description, which focuses on renaming. This needs to be confirmed as intentional, justified, clearly documented in the field comments, and thoroughly tested.
  • Incomplete PR Checklist: The PR checklist indicates that unit tests, integration tests, and documentation updates are still pending ([ ]). Given the semantic API change noted above, it's particularly important to ensure that all tests are updated or new tests are added to cover the new conditional logic and that documentation accurately reflects all changes.

Merge Readiness

The refactoring of key context structure names is a positive step for clarity and has been applied consistently. However, there are critical concerns that need addressing before this PR can be considered ready for merging:

  1. Semantic API Change: The modification of private_key_ctx in CreateKeyRequest from "Required" to "Conditionally Required" is a significant API contract change. This needs to be explicitly acknowledged in the PR description, its rationale provided, and its implications fully understood and documented. The field comment in the proto definition should also be updated to reflect this conditionality clearly.
  2. Pending Tests and Documentation: The PR checklist indicates that unit tests, integration tests, and documentation updates are not yet completed. These are essential, especially to validate the new conditional logic introduced by the API change and to ensure all documentation accurately reflects the current state of the API.

Due to these points, particularly the unconfirmed semantic change and the pending tests, I recommend that these changes be addressed. I am unable to approve the pull request in its current state. Please ensure these concerns are resolved and consider further reviews if necessary before merging.

Comment on lines +413 to +414
// Conditionally Required
PrivateKeyCtx private_key_ctx = 6; // Context or additional data specific to the private key, based on the key provider implementation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The requirement for private_key_ctx in CreateKeyRequest has changed from "Required" to "Conditionally Required". This is a semantic change to the API contract, not just a refactor as implied by the PR title ("Rename key context structures").

Could you please:

  • Confirm if this change is intentional? If so, could you update the PR description to reflect this functional change and provide a brief justification for it?
  • Consider updating the field comment for private_key_ctx (currently "Context or additional data specific to the private key, based on the key provider implementation") to more explicitly clarify the conditions under which it's required? For example, you could reference the conditions outlined in the CEL rule private_key_ctx_optionally_required (e.g., "Conditionally Required. Required if key_mode is LOCAL or PROVIDER_ROOT_KEY. Context or additional data..."). This would improve clarity in generated documentation.
  • Ensure that the corresponding validation logic (the CEL rule private_key_ctx_optionally_required) accurately and comprehensively reflects this new conditional requirement across all key modes?
  • The PR checklist indicates tests are not yet updated. It's crucial to add or update tests to cover this new conditional logic thoroughly.

Copy link
Contributor
Benchmark results, click to expand

Benchmark Results:

Metric Value
Approved Decision Requests 5000
Denied Decision Requests 0
Total Time 452.4567ms

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 369.268629ms
Throughput 270.81 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 1m20.16323816s
Average Latency 799.749534ms
Throughput 62.37 requests/second

NANOTDF Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 4944
Failed Requests 56
Concurrent Requests 50
Total Time 1m8.322342493s
Average Latency 678.081587ms
Throughput 72.36 requests/second

Error Summary:

Error Message Occurrences
ReadNanoTDF error: getNanoRewrapKey: rewrapError: internal: internal error
rpc error: code = Internal desc = could not perform access
56 occurrences

Standard Benchmark Metrics Skipped or Failed

@strantalis strantalis merged commit 4cb28a9 into main May 27, 2025
29 of 31 checks passed
@strantalis strantalis deleted the feat/DSPX-1145-rename-key-ctx branch May 27, 2025 15:54
github-merge-queue bot pushed a commit that referenced this pull request May 27, 2025
🤖 I have created a release *beep* *boop*
---


##
[0.3.6](protocol/go/v0.3.5...protocol/go/v0.3.6)
(2025-05-27)


### Features

* **policy:** Update key status's and UpdateKey rpc.
([#2315](#2315))
([7908db9](7908db9))
* **policy** Rename key context structures.
([#2318](#2318))

([4cb28a9](4cb28a9))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: opentdf-automation[bot] <149537512+opentdf-automation[bot]@users.noreply.github.com>
Co-authored-by: Chris Reed <87077975+c-r33d@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:db DB component comp:kas Key Access Server comp:policy Policy Configuration ( attributes, subject mappings, resource mappings, kas registry) docs Documentation size/s
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0