Skip to content

Conversation

@texastony
Copy link
Contributor

@texastony texastony commented May 28, 2025

Issue #, if available:

Description of changes:

Refactor the Create Branch Key example to consume Nullable Encryption Context

  • Added a dependency to quickly evaluate null or empty maps
  • Refactored the signature of the method to take in EC

Error message details Invalid EC for HV-2 can be due to Emptyish OR Modified EC

Java Integ Test that ensures HV-1 with emptyish EC keys cannot be mutated to HV-2

Squash/merge commit message, if applicable:

test(Dafny): BKSA HV1 w/ Emptyish EC fails Mut to HV2

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@texastony texastony changed the title Texastony/hv 2/hv 2 test migration empty ec test(Dafny): BKSA HV1 w/ Emptyish EC fails Mut to HV2 May 28, 2025
@texastony texastony force-pushed the texastony/hv-2/hv-2-test-migration-empty-ec branch from ac6f03f to 6ba3279 Compare May 28, 2025 14:55
@texastony texastony marked this pull request as ready for review May 28, 2025 15:39
@texastony texastony requested a review from a team as a code owner May 28, 2025 15:39
@rishav-karanjit
Copy link
Member

What if you change this code to <= instead of <?

Copy link
Member

@rishav-karanjit rishav-karanjit left a comment

Choose a reason for hiding this comment

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

I have a blocking comment and a question. All other looks good.

encryptionContext = Collections.unmodifiableMap(_encryptionContext);
}

protected String createHV1WithAnEmptyEncryptionContextKey() {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
protected String createHV1WithAnEmptyEncryptionContextKey() {
private String createHV1WithAnEmptyEncryptionContextKey() {

Copy link
Member

Choose a reason for hiding this comment

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

non blocking comment

return testBranchKeyId;
}

protected void checkBranchKey(final String branchKeyId) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
protected void checkBranchKey(final String branchKeyId) {
private void checkBranchKey(final String branchKeyId) {

Copy link
Member

Choose a reason for hiding this comment

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

non blocking comment

);
}

protected void mutateToHV2(final String branchKeyId) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
protected void mutateToHV2(final String branchKeyId) {
private void mutateToHV2(final String branchKeyId) {

Copy link
Member

Choose a reason for hiding this comment

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

non blocking comment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made this protected, because I am thinking about creating a super class for these sorts of tests that are of the pattern:

  • create BK
  • validate created BK
  • Mutate BK, maybe handle exception
  • validate mutated BK
  • clean up

const MD_DIGEST_SHA_NOT_MATCHED :=
"This branch key item has failed the authentication check. Either it has been tampered with or the wrong 'Logical Key Store Name' has been provided."

const INVALID_EC_FOUND :=
Copy link
Member

Choose a reason for hiding this comment

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

Let's add a TODO for this for hv-2 fast follow. I don't want us to forget about rejecting empty key and I think customer should be getting a KMS error instead of our error.

Copy link
Member

Choose a reason for hiding this comment

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

blocking comment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They cannot get a KMS Error unless we actually call KMS.
And that KMS Call may be hard to construct with our Dafny tooling... I am not sure.
I am also not certain that the KMS exception will be well understood by a customer going from HV-1 to HV-2.

But I can take a TODO; we can then evaluate if this is a launch blocker in an ORR.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, having TODO and then evaluating in ORR is fine.

I am also not sure about the KMS call with empty EC in Dafny. The reason why I like to give them KMS error is because let's say KMS changes and start accepting empty EC after few years, at that time no one in the team will realize that we are rejecting empty EC saying KMS will reject it until someone works on this code space or a user complains. Returning KMS error instead of our error makes me feel like the code that we write will survive for next 5 years.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I hear you, but our customers will need to understand why the KMS error was thrown.

On Branch Key creation, this is trivial.

But on Mutation, particularly one that changes HV, I fear that customers will not be able to relate the KMS error to the root cause.

Copy link
Member

@rishav-karanjit rishav-karanjit left a comment

Choose a reason for hiding this comment

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

LGTM

@rishav-karanjit rishav-karanjit merged commit 0c0eb75 into hv-2/hv-2 May 28, 2025
112 checks passed
@rishav-karanjit rishav-karanjit deleted the texastony/hv-2/hv-2-test-migration-empty-ec branch May 28, 2025 19:50
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.

2 participants